From cdf97e7605d15e6ac218d786e9578241209823be Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Fri, 28 Apr 2023 22:03:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0zltoolkit,=E9=80=82=E9=85=8D?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdpart/ZLToolKit | 2 +- api/source/mk_tcp.cpp | 6 +++--- api/source/mk_tcp_private.h | 2 +- src/Http/HttpClient.cpp | 2 +- src/Http/HttpClient.h | 2 +- src/Http/HttpFileManager.cpp | 2 +- src/Http/HttpSession.cpp | 2 +- src/Http/WebSocketClient.h | 4 ++-- src/Rtmp/RtmpPlayer.cpp | 2 +- src/Rtmp/RtmpPlayer.h | 2 +- src/Rtmp/RtmpPusher.cpp | 2 +- src/Rtmp/RtmpPusher.h | 2 +- src/Rtsp/RtspPlayer.cpp | 2 +- src/Rtsp/RtspPlayer.h | 2 +- src/Rtsp/RtspPusher.cpp | 2 +- src/Rtsp/RtspPusher.h | 2 +- srt/SrtSession.cpp | 2 +- tests/test_wsClient.cpp | 2 +- webrtc/IceServer.cpp | 2 +- webrtc/WebRtcPlayer.cpp | 2 +- webrtc/WebRtcSession.cpp | 2 +- webrtc/WebRtcTransport.cpp | 4 ++-- 22 files changed, 26 insertions(+), 26 deletions(-) diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index 7e40c751..d134fbb9 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit 7e40c751659d5c1ec623699732284c12e0a4feb8 +Subproject commit d134fbb9fe0b108dddb66a7bfa35b7b438426411 diff --git a/api/source/mk_tcp.cpp b/api/source/mk_tcp.cpp index 2b79d08a..e96ce4bf 100644 --- a/api/source/mk_tcp.cpp +++ b/api/source/mk_tcp.cpp @@ -139,7 +139,7 @@ API_EXPORT void API_CALL mk_tcp_session_send(const mk_tcp_session ctx, const cha API_EXPORT void API_CALL mk_tcp_session_send_buffer_safe(const mk_tcp_session ctx, mk_buffer buffer) { assert(ctx && buffer); try { - std::weak_ptr weak_session = ((SessionForC *) ctx)->shared_from_this(); + std::weak_ptr weak_session = ((SessionForC *) ctx)->shared_from_this(); auto ref = mk_buffer_ref(buffer); ((SessionForC *) ctx)->async([weak_session, ref]() { auto session_session = weak_session.lock(); @@ -149,7 +149,7 @@ API_EXPORT void API_CALL mk_tcp_session_send_buffer_safe(const mk_tcp_session ct mk_buffer_unref(ref); }); } catch (std::exception &ex) { - WarnL << "can not got the strong pionter of this mk_tcp_session:" << ex.what(); + WarnL << "can not got the strong pointer of this mk_tcp_session:" << ex.what(); } } @@ -271,7 +271,7 @@ void TcpClientForC::onRecv(const Buffer::Ptr &pBuf) { } } -void TcpClientForC::onErr(const SockException &ex) { +void TcpClientForC::onError(const SockException &ex) { if(_events.on_mk_tcp_client_disconnect){ _events.on_mk_tcp_client_disconnect(_client,ex.getErrCode(),ex.what()); } diff --git a/api/source/mk_tcp_private.h b/api/source/mk_tcp_private.h index 241e88b6..e569ca16 100644 --- a/api/source/mk_tcp_private.h +++ b/api/source/mk_tcp_private.h @@ -21,7 +21,7 @@ public: TcpClientForC(mk_tcp_client_events *events) ; ~TcpClientForC() override ; void onRecv(const toolkit::Buffer::Ptr &pBuf) override; - void onErr(const toolkit::SockException &ex) override; + void onError(const toolkit::SockException &ex) override; void onManager() override; void onConnect(const toolkit::SockException &ex) override; void setClient(mk_tcp_client client); diff --git a/src/Http/HttpClient.cpp b/src/Http/HttpClient.cpp index 0e50fe0c..0ff9b789 100644 --- a/src/Http/HttpClient.cpp +++ b/src/Http/HttpClient.cpp @@ -176,7 +176,7 @@ void HttpClient::onRecv(const Buffer::Ptr &pBuf) { HttpRequestSplitter::input(pBuf->data(), pBuf->size()); } -void HttpClient::onErr(const SockException &ex) { +void HttpClient::onError(const SockException &ex) { onResponseCompleted_l(ex); } diff --git a/src/Http/HttpClient.h b/src/Http/HttpClient.h index 82fc2f9d..c82804d4 100644 --- a/src/Http/HttpClient.h +++ b/src/Http/HttpClient.h @@ -177,7 +177,7 @@ protected: //// TcpClient override //// void onConnect(const toolkit::SockException &ex) override; void onRecv(const toolkit::Buffer::Ptr &pBuf) override; - void onErr(const toolkit::SockException &ex) override; + void onError(const toolkit::SockException &ex) override; void onFlush() override; void onManager() override; diff --git a/src/Http/HttpFileManager.cpp b/src/Http/HttpFileManager.cpp index b690801a..fbd9c174 100644 --- a/src/Http/HttpFileManager.cpp +++ b/src/Http/HttpFileManager.cpp @@ -367,7 +367,7 @@ static void accessFile(Session &sender, const Parser &parser, const MediaInfo &m replace(const_cast(media_info._streamid), kHlsSuffix, ""); } - weak_ptr weakSession = sender.shared_from_this(); + weak_ptr weakSession = static_pointer_cast(sender.shared_from_this()); //判断是否有权限访问该文件 canAccessPath(sender, parser, media_info, false, [cb, file_path, parser, is_hls, media_info, weakSession](const string &err_msg, const HttpServerCookie::Ptr &cookie) { auto strongSession = weakSession.lock(); diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index 79924933..7acd9fa7 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -612,7 +612,7 @@ void HttpSession::sendResponse(int code, } //发送http body - AsyncSenderData::Ptr data = std::make_shared(shared_from_this(), body, bClose); + AsyncSenderData::Ptr data = std::make_shared(static_pointer_cast(shared_from_this()), body, bClose); getSock()->setOnFlush([data]() { return AsyncSender::onSocketFlushed(data); }); AsyncSender::onSocketFlushed(data); } diff --git a/src/Http/WebSocketClient.h b/src/Http/WebSocketClient.h index 737ebcda..379ae66d 100644 --- a/src/Http/WebSocketClient.h +++ b/src/Http/WebSocketClient.h @@ -218,7 +218,7 @@ protected: /** * tcp连接断开 */ - void onErr(const toolkit::SockException &ex) override { + void onError(const toolkit::SockException &ex) override { // tcp断开或者shutdown导致的断开 onWebSocketException(ex); } @@ -350,7 +350,7 @@ private: // 握手成功之后的中途断开 _onRecv = nullptr; if (auto strong_ref = _weak_delegate.lock()) { - strong_ref->onErr(ex); + strong_ref->onError(ex); } return; } diff --git a/src/Rtmp/RtmpPlayer.cpp b/src/Rtmp/RtmpPlayer.cpp index 780ce980..4e7d903d 100644 --- a/src/Rtmp/RtmpPlayer.cpp +++ b/src/Rtmp/RtmpPlayer.cpp @@ -90,7 +90,7 @@ void RtmpPlayer::play(const string &url) { startConnect(host_url, port, play_timeout_sec); } -void RtmpPlayer::onErr(const SockException &ex){ +void RtmpPlayer::onError(const SockException &ex){ //定时器_pPlayTimer为空后表明握手结束了 onPlayResult_l(ex, !_play_timer); } diff --git a/src/Rtmp/RtmpPlayer.h b/src/Rtmp/RtmpPlayer.h index 55e4c9c4..0a45f1b5 100644 --- a/src/Rtmp/RtmpPlayer.h +++ b/src/Rtmp/RtmpPlayer.h @@ -50,7 +50,7 @@ protected: //form Tcpclient void onRecv(const toolkit::Buffer::Ptr &buf) override; void onConnect(const toolkit::SockException &err) override; - void onErr(const toolkit::SockException &ex) override; + void onError(const toolkit::SockException &ex) override; //from RtmpProtocol void onRtmpChunk(RtmpPacket::Ptr chunk_data) override; void onStreamDry(uint32_t stream_index) override; diff --git a/src/Rtmp/RtmpPusher.cpp b/src/Rtmp/RtmpPusher.cpp index 109696c5..bf5ca332 100644 --- a/src/Rtmp/RtmpPusher.cpp +++ b/src/Rtmp/RtmpPusher.cpp @@ -97,7 +97,7 @@ void RtmpPusher::publish(const string &url) { startConnect(host_url, port); } -void RtmpPusher::onErr(const SockException &ex){ +void RtmpPusher::onError(const SockException &ex){ //定时器_pPublishTimer为空后表明握手结束了 onPublishResult_l(ex, !_publish_timer); } diff --git a/src/Rtmp/RtmpPusher.h b/src/Rtmp/RtmpPusher.h index bd41fd75..0b9cdb89 100644 --- a/src/Rtmp/RtmpPusher.h +++ b/src/Rtmp/RtmpPusher.h @@ -31,7 +31,7 @@ protected: //for Tcpclient override void onRecv(const toolkit::Buffer::Ptr &buf) override; void onConnect(const toolkit::SockException &err) override; - void onErr(const toolkit::SockException &ex) override; + void onError(const toolkit::SockException &ex) override; //for RtmpProtocol override void onRtmpChunk(RtmpPacket::Ptr chunk_data) override; diff --git a/src/Rtsp/RtspPlayer.cpp b/src/Rtsp/RtspPlayer.cpp index 2d7ab925..6fae5e07 100644 --- a/src/Rtsp/RtspPlayer.cpp +++ b/src/Rtsp/RtspPlayer.cpp @@ -131,7 +131,7 @@ void RtspPlayer::onRecv(const Buffer::Ptr& buf) { } } -void RtspPlayer::onErr(const SockException &ex) { +void RtspPlayer::onError(const SockException &ex) { //定时器_pPlayTimer为空后表明握手结束了 onPlayResult_l(ex,!_play_check_timer); } diff --git a/src/Rtsp/RtspPlayer.h b/src/Rtsp/RtspPlayer.h index 0bd101cd..5a9bd1ee 100644 --- a/src/Rtsp/RtspPlayer.h +++ b/src/Rtsp/RtspPlayer.h @@ -84,7 +84,7 @@ protected: /////////////TcpClient override///////////// void onConnect(const toolkit::SockException &err) override; void onRecv(const toolkit::Buffer::Ptr &buf) override; - void onErr(const toolkit::SockException &ex) override; + void onError(const toolkit::SockException &ex) override; private: void onPlayResult_l(const toolkit::SockException &ex , bool handshake_done); diff --git a/src/Rtsp/RtspPusher.cpp b/src/Rtsp/RtspPusher.cpp index 04d0d1a1..575f551c 100644 --- a/src/Rtsp/RtspPusher.cpp +++ b/src/Rtsp/RtspPusher.cpp @@ -118,7 +118,7 @@ void RtspPusher::onPublishResult_l(const SockException &ex, bool handshake_done) } } -void RtspPusher::onErr(const SockException &ex) { +void RtspPusher::onError(const SockException &ex) { //定时器_pPublishTimer为空后表明握手结束了 onPublishResult_l(ex, !_publish_timer); } diff --git a/src/Rtsp/RtspPusher.h b/src/Rtsp/RtspPusher.h index 2cddd61f..63353368 100644 --- a/src/Rtsp/RtspPusher.h +++ b/src/Rtsp/RtspPusher.h @@ -35,7 +35,7 @@ protected: //for Tcpclient override void onRecv(const toolkit::Buffer::Ptr &buf) override; void onConnect(const toolkit::SockException &err) override; - void onErr(const toolkit::SockException &ex) override; + void onError(const toolkit::SockException &ex) override; //RtspSplitter override void onWholeRtspPacket(Parser &parser) override ; diff --git a/srt/SrtSession.cpp b/srt/SrtSession.cpp index 5f73d92f..9f83ddde 100644 --- a/srt/SrtSession.cpp +++ b/srt/SrtSession.cpp @@ -100,7 +100,7 @@ void SrtSession::onRecv(const Buffer::Ptr &buffer) { } if (_transport) { - _transport->setSession(shared_from_this()); + _transport->setSession(static_pointer_cast(shared_from_this())); } InfoP(this); } diff --git a/tests/test_wsClient.cpp b/tests/test_wsClient.cpp index bd3ba0b5..a3819799 100644 --- a/tests/test_wsClient.cpp +++ b/tests/test_wsClient.cpp @@ -32,7 +32,7 @@ protected: DebugL << pBuf->toString(); } //被动断开连接回调 - void onErr(const SockException &ex) override { + void onError(const SockException &ex) override { WarnL << ex; } //tcp连接成功后每2秒触发一次该事件 diff --git a/webrtc/IceServer.cpp b/webrtc/IceServer.cpp index f0f79358..40e53aa8 100644 --- a/webrtc/IceServer.cpp +++ b/webrtc/IceServer.cpp @@ -520,7 +520,7 @@ namespace RTC return; this->selectedTuple = storedTuple; - this->lastSelectedTuple = storedTuple->shared_from_this(); + this->lastSelectedTuple = static_pointer_cast(storedTuple->shared_from_this()); // Notify the listener. this->listener->OnIceServerSelectedTuple(this, this->selectedTuple); diff --git a/webrtc/WebRtcPlayer.cpp b/webrtc/WebRtcPlayer.cpp index bbdb6274..a766607f 100644 --- a/webrtc/WebRtcPlayer.cpp +++ b/webrtc/WebRtcPlayer.cpp @@ -47,7 +47,7 @@ void WebRtcPlayer::onStartWebRTC() { playSrc->pause(false); _reader = playSrc->getRing()->attach(getPoller(), true); weak_ptr weak_self = static_pointer_cast(shared_from_this()); - weak_ptr weak_session = getSession(); + weak_ptr weak_session = static_pointer_cast(getSession()); _reader->setGetInfoCB([weak_session]() { return weak_session.lock(); }); _reader->setReadCB([weak_self](const RtspMediaSource::RingDataType &pkt) { auto strong_self = weak_self.lock(); diff --git a/webrtc/WebRtcSession.cpp b/webrtc/WebRtcSession.cpp index 6216802c..28c60d58 100644 --- a/webrtc/WebRtcSession.cpp +++ b/webrtc/WebRtcSession.cpp @@ -108,7 +108,7 @@ void WebRtcSession::onError(const SockException &err) { if (!_transport) { return; } - auto self = shared_from_this(); + auto self = static_pointer_cast(shared_from_this()); auto transport = std::move(_transport); getPoller()->async([transport, self]() mutable { //延时减引用,防止使用transport对象时,销毁对象 diff --git a/webrtc/WebRtcTransport.cpp b/webrtc/WebRtcTransport.cpp index 1d1431c9..05935076 100644 --- a/webrtc/WebRtcTransport.cpp +++ b/webrtc/WebRtcTransport.cpp @@ -230,7 +230,7 @@ void WebRtcTransport::sendSockData(const char *buf, size_t len, RTC::TransportTu Session::Ptr WebRtcTransport::getSession() const { auto tuple = _ice_server->GetSelectedTuple(true); - return tuple ? tuple->shared_from_this() : nullptr; + return tuple ? static_pointer_cast(tuple->shared_from_this()) : nullptr; } void WebRtcTransport::sendRtcpRemb(uint32_t ssrc, size_t bit_rate) { @@ -1209,7 +1209,7 @@ void play_plugin(Session &sender, const WebRtcArgs &args, const WebRtcPluginMana MediaInfo info(args["url"]); bool preferred_tcp = args["preferred_tcp"]; - auto session_ptr = sender.shared_from_this(); + auto session_ptr = static_pointer_cast(sender.shared_from_this()); Broadcast::AuthInvoker invoker = [cb, info, session_ptr, preferred_tcp](const string &err) mutable { if (!err.empty()) { cb(WebRtcException(SockException(Err_other, err)));