diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index 894be819..617b6b1d 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit 894be81929f227583081755288ab0927c077e411 +Subproject commit 617b6b1db23f13e2592b29204b84b1b9dbbf81c0 diff --git a/api/source/mk_common.cpp b/api/source/mk_common.cpp index a69fdc8c..59bbfde7 100644 --- a/api/source/mk_common.cpp +++ b/api/source/mk_common.cpp @@ -174,7 +174,7 @@ API_EXPORT uint16_t API_CALL mk_http_server_start(uint16_t port, int ssl) { try { http_server[ssl] = std::make_shared(); if(ssl){ - http_server[ssl]->start >(port); + http_server[ssl]->start >(port); } else{ http_server[ssl]->start(port); } @@ -191,7 +191,7 @@ API_EXPORT uint16_t API_CALL mk_rtsp_server_start(uint16_t port, int ssl) { try { rtsp_server[ssl] = std::make_shared(); if(ssl){ - rtsp_server[ssl]->start >(port); + rtsp_server[ssl]->start >(port); }else{ rtsp_server[ssl]->start(port); } @@ -208,7 +208,7 @@ API_EXPORT uint16_t API_CALL mk_rtmp_server_start(uint16_t port, int ssl) { try { rtmp_server[ssl] = std::make_shared(); if(ssl){ - rtmp_server[ssl]->start >(port); + rtmp_server[ssl]->start >(port); }else{ rtmp_server[ssl]->start(port); } diff --git a/api/source/mk_tcp.cpp b/api/source/mk_tcp.cpp index ea15fdb5..2e2dc6e1 100644 --- a/api/source/mk_tcp.cpp +++ b/api/source/mk_tcp.cpp @@ -109,19 +109,19 @@ API_EXPORT uint16_t API_CALL mk_sock_info_local_port(const mk_sock_info ctx){ //////////////////////////////////////////////////////////////////////////////////////// API_EXPORT mk_sock_info API_CALL mk_tcp_session_get_sock_info(const mk_tcp_session ctx){ assert(ctx); - TcpSessionForC *session = (TcpSessionForC *)ctx; + SessionForC *session = (SessionForC *)ctx; return (SockInfo *)session; } API_EXPORT void API_CALL mk_tcp_session_shutdown(const mk_tcp_session ctx,int err,const char *err_msg){ assert(ctx); - TcpSessionForC *session = (TcpSessionForC *)ctx; + SessionForC *session = (SessionForC *)ctx; session->safeShutdown(SockException((ErrCode)err,err_msg)); } API_EXPORT void API_CALL mk_tcp_session_send_buffer(const mk_tcp_session ctx, mk_buffer buffer) { assert(ctx && buffer); - TcpSessionForC *session = (TcpSessionForC *) ctx; + SessionForC *session = (SessionForC *) ctx; session->send(*((Buffer::Ptr *) buffer)); } @@ -134,9 +134,9 @@ 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 = ((TcpSessionForC *) ctx)->shared_from_this(); + std::weak_ptr weak_session = ((SessionForC *) ctx)->shared_from_this(); auto ref = mk_buffer_ref(buffer); - ((TcpSessionForC *) ctx)->async([weak_session, ref]() { + ((SessionForC *) ctx)->async([weak_session, ref]() { auto session_session = weak_session.lock(); if (session_session) { session_session->send(*((Buffer::Ptr *) ref)); @@ -149,16 +149,16 @@ API_EXPORT void API_CALL mk_tcp_session_send_buffer_safe(const mk_tcp_session ct } API_EXPORT mk_tcp_session_ref API_CALL mk_tcp_session_ref_from(const mk_tcp_session ctx) { - auto ref = ((TcpSessionForC *) ctx)->shared_from_this(); - return new std::shared_ptr(std::dynamic_pointer_cast(ref)); + auto ref = ((SessionForC *) ctx)->shared_from_this(); + return new std::shared_ptr(std::dynamic_pointer_cast(ref)); } API_EXPORT void mk_tcp_session_ref_release(const mk_tcp_session_ref ref) { - delete (std::shared_ptr *) ref; + delete (std::shared_ptr *) ref; } API_EXPORT mk_tcp_session mk_tcp_session_from_ref(const mk_tcp_session_ref ref) { - return ((std::shared_ptr *) ref)->get(); + return ((std::shared_ptr *) ref)->get(); } API_EXPORT void API_CALL mk_tcp_session_send_safe(const mk_tcp_session ctx, const char *data, size_t len) { @@ -167,30 +167,30 @@ API_EXPORT void API_CALL mk_tcp_session_send_safe(const mk_tcp_session ctx, cons mk_buffer_unref(buffer); } -////////////////////////////////////////TcpSessionForC//////////////////////////////////////////////// +////////////////////////////////////////SessionForC//////////////////////////////////////////////// static TcpServer::Ptr s_tcp_server[4]; static mk_tcp_session_events s_events_server = {0}; -TcpSessionForC::TcpSessionForC(const Socket::Ptr &pSock) : TcpSession(pSock) { +SessionForC::SessionForC(const Socket::Ptr &pSock) : Session(pSock) { _local_port = get_local_port(); if (s_events_server.on_mk_tcp_session_create) { s_events_server.on_mk_tcp_session_create(_local_port,this); } } -void TcpSessionForC::onRecv(const Buffer::Ptr &buffer) { +void SessionForC::onRecv(const Buffer::Ptr &buffer) { if (s_events_server.on_mk_tcp_session_data) { s_events_server.on_mk_tcp_session_data(_local_port, this, (mk_buffer)&buffer); } } -void TcpSessionForC::onError(const SockException &err) { +void SessionForC::onError(const SockException &err) { if (s_events_server.on_mk_tcp_session_disconnect) { s_events_server.on_mk_tcp_session_disconnect(_local_port,this, err.getErrCode(), err.what()); } } -void TcpSessionForC::onManager() { +void SessionForC::onManager() { if (s_events_server.on_mk_tcp_session_manager) { s_events_server.on_mk_tcp_session_manager(_local_port,this); } @@ -202,13 +202,13 @@ void stopAllTcpServer(){ API_EXPORT void API_CALL mk_tcp_session_set_user_data(mk_tcp_session session,void *user_data){ assert(session); - TcpSessionForC *obj = (TcpSessionForC *)session; + SessionForC *obj = (SessionForC *)session; obj->_user_data = user_data; } API_EXPORT void* API_CALL mk_tcp_session_get_user_data(mk_tcp_session session){ assert(session); - TcpSessionForC *obj = (TcpSessionForC *)session; + SessionForC *obj = (SessionForC *)session; return obj->_user_data; } @@ -226,18 +226,18 @@ API_EXPORT uint16_t API_CALL mk_tcp_server_start(uint16_t port, mk_tcp_type type s_tcp_server[type] = std::make_shared(); switch (type) { case mk_type_tcp: - s_tcp_server[type]->start(port); + s_tcp_server[type]->start(port); break; case mk_type_ssl: - s_tcp_server[type]->start >(port); + s_tcp_server[type]->start >(port); break; case mk_type_ws: //此处你也可以修改WebSocketHeader::BINARY - s_tcp_server[type]->start >(port); + s_tcp_server[type]->start >(port); break; case mk_type_wss: //此处你也可以修改WebSocketHeader::BINARY - s_tcp_server[type]->start >(port); + s_tcp_server[type]->start >(port); break; default: return 0; @@ -295,7 +295,7 @@ TcpClientForC::Ptr *mk_tcp_client_create_l(mk_tcp_client_events *events, mk_tcp_ case mk_type_tcp: return new TcpClientForC::Ptr(new TcpClientForC(events)); case mk_type_ssl: - return (TcpClientForC::Ptr *)new std::shared_ptr >(new TcpSessionWithSSL(events)); + return (TcpClientForC::Ptr *)new std::shared_ptr >(new SessionWithSSL(events)); case mk_type_ws: //此处你也可以修改WebSocketHeader::BINARY return (TcpClientForC::Ptr *)new std::shared_ptr >(new WebSocketClient(events)); diff --git a/api/source/mk_tcp_private.h b/api/source/mk_tcp_private.h index 46cdc6f3..053602dc 100644 --- a/api/source/mk_tcp_private.h +++ b/api/source/mk_tcp_private.h @@ -13,7 +13,7 @@ #include "mk_tcp.h" #include "Network/TcpClient.h" -#include "Network/TcpSession.h" +#include "Network/Session.h" class TcpClientForC : public toolkit::TcpClient { public: @@ -31,10 +31,10 @@ private: mk_tcp_client _client; }; -class TcpSessionForC : public toolkit::TcpSession { +class SessionForC : public toolkit::Session { public: - TcpSessionForC(const toolkit::Socket::Ptr &pSock) ; - ~TcpSessionForC() override = default; + SessionForC(const toolkit::Socket::Ptr &pSock) ; + ~SessionForC() override = default; void onRecv(const toolkit::Buffer::Ptr &buffer) override ; void onError(const toolkit::SockException &err) override; void onManager() override; diff --git a/api/source/mk_thread.cpp b/api/source/mk_thread.cpp index 42ed5fef..f3c06ff4 100644 --- a/api/source/mk_thread.cpp +++ b/api/source/mk_thread.cpp @@ -18,7 +18,7 @@ using namespace toolkit; API_EXPORT mk_thread API_CALL mk_thread_from_tcp_session(mk_tcp_session ctx){ assert(ctx); - TcpSessionForC *obj = (TcpSessionForC *)ctx; + SessionForC *obj = (SessionForC *)ctx; return obj->getPoller().get(); } diff --git a/postman/ZLMediaKit.postman_collection.json b/postman/ZLMediaKit.postman_collection.json index 36654ae0..a67aa423 100644 --- a/postman/ZLMediaKit.postman_collection.json +++ b/postman/ZLMediaKit.postman_collection.json @@ -348,7 +348,7 @@ "response": [] }, { - "name": "获取TcpSession列表(getAllSession)", + "name": "获取Session列表(getAllSession)", "request": { "method": "GET", "header": [], diff --git a/server/WebApi.cpp b/server/WebApi.cpp index df34cd5f..41b88dcd 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -854,7 +854,7 @@ void installWebApi() { val["count_closed"] = count_closed; }); - //获取所有TcpSession列表信息 + //获取所有Session列表信息 //可以根据本地端口和远端ip来筛选 //测试url(筛选某端口下的tcp会话) http://127.0.0.1/index/api/getAllSession?local_port=1935 api_regist("/index/api/getAllSession",[](API_ARGS_MAP){ diff --git a/server/WebHook.cpp b/server/WebHook.cpp index 4544d30b..b66707f5 100755 --- a/server/WebHook.cpp +++ b/server/WebHook.cpp @@ -15,7 +15,7 @@ #include "Common/config.h" #include "Common/MediaSource.h" #include "Http/HttpRequester.h" -#include "Network/TcpSession.h" +#include "Network/Session.h" #include "Rtsp/RtspSession.h" #include "Http/HttpSession.h" #include "WebHook.h" diff --git a/src/Common/MediaSource.cpp b/src/Common/MediaSource.cpp index 5f30e215..bcd16cb9 100644 --- a/src/Common/MediaSource.cpp +++ b/src/Common/MediaSource.cpp @@ -11,7 +11,7 @@ #include "Util/util.h" #include "Util/NoticeCenter.h" #include "Network/sockutil.h" -#include "Network/TcpSession.h" +#include "Network/Session.h" #include "MediaSource.h" #include "Common/config.h" #include "Record/MP4Reader.h" diff --git a/src/Http/HttpFileManager.cpp b/src/Http/HttpFileManager.cpp index a7d90497..50014825 100644 --- a/src/Http/HttpFileManager.cpp +++ b/src/Http/HttpFileManager.cpp @@ -181,7 +181,7 @@ static bool makeFolderMenu(const string &httpPath, const string &strFullPath, st } //拦截hls的播放请求 -static bool emitHlsPlayed(const Parser &parser, const MediaInfo &media_info, const HttpSession::HttpAccessPathInvoker &invoker,TcpSession &sender){ +static bool emitHlsPlayed(const Parser &parser, const MediaInfo &media_info, const HttpSession::HttpAccessPathInvoker &invoker,Session &sender){ //访问的hls.m3u8结尾,我们转换成kBroadcastMediaPlayed事件 Broadcast::AuthInvoker auth_invoker = [invoker](const string &err) { //cookie有效期为kHlsCookieSecond @@ -236,7 +236,7 @@ public: * 4、cookie中记录的url参数是否跟本次url参数一致,如果一致直接返回客户端错误码 * 5、触发kBroadcastHttpAccess事件 */ -static void canAccessPath(TcpSession &sender, const Parser &parser, const MediaInfo &media_info, bool is_dir, +static void canAccessPath(Session &sender, const Parser &parser, const MediaInfo &media_info, bool is_dir, const function &callback) { //获取用户唯一id auto uid = parser.Params(); @@ -353,7 +353,7 @@ static string pathCat(const string &a, const string &b){ * @param file_path 文件绝对路径 * @param cb 回调对象 */ -static void accessFile(TcpSession &sender, const Parser &parser, const MediaInfo &media_info, const string &file_path, const HttpFileManager::invoker &cb) { +static void accessFile(Session &sender, const Parser &parser, const MediaInfo &media_info, const string &file_path, const HttpFileManager::invoker &cb) { bool is_hls = end_with(file_path, kHlsSuffix); if (!is_hls && !File::fileExist(file_path.data())) { //文件不存在且不是hls,那么直接返回404 @@ -366,7 +366,7 @@ static void accessFile(TcpSession &sender, const Parser &parser, const MediaInfo replace(const_cast(media_info._streamid), kHlsSuffix, ""); } - weak_ptr weakSession = sender.shared_from_this(); + weak_ptr weakSession = 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(); @@ -456,7 +456,7 @@ static void accessFile(TcpSession &sender, const Parser &parser, const MediaInfo }); } -static string getFilePath(const Parser &parser,const MediaInfo &media_info, TcpSession &sender){ +static string getFilePath(const Parser &parser,const MediaInfo &media_info, Session &sender){ GET_CONFIG(bool, enableVhost, General::kEnableVhost); GET_CONFIG(string, rootPath, Http::kRootPath); GET_CONFIG_FUNC(StrCaseMap, virtualPathMap, Http::kVirtualPath, [](const string &str) { @@ -491,7 +491,7 @@ static string getFilePath(const Parser &parser,const MediaInfo &media_info, TcpS * @param parser http请求 * @param cb 回调对象 */ -void HttpFileManager::onAccessPath(TcpSession &sender, Parser &parser, const HttpFileManager::invoker &cb) { +void HttpFileManager::onAccessPath(Session &sender, Parser &parser, const HttpFileManager::invoker &cb) { auto fullUrl = string(HTTP_SCHEMA) + "://" + parser["Host"] + parser.FullUrl(); MediaInfo media_info(fullUrl); auto file_path = getFilePath(parser, media_info, sender); diff --git a/src/Http/HttpFileManager.h b/src/Http/HttpFileManager.h index 7a3766b1..d30b89b3 100644 --- a/src/Http/HttpFileManager.h +++ b/src/Http/HttpFileManager.h @@ -14,7 +14,7 @@ #include "HttpBody.h" #include "HttpCookie.h" #include "Common/Parser.h" -#include "Network/TcpSession.h" +#include "Network/Session.h" #include "Util/function_traits.h" namespace mediakit { @@ -54,7 +54,7 @@ public: * @param parser http请求 * @param cb 回调对象 */ - static void onAccessPath(toolkit::TcpSession &sender, Parser &parser, const invoker &cb); + static void onAccessPath(toolkit::Session &sender, Parser &parser, const invoker &cb); /** * 获取mime值 diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index a0d3ad28..fd59416b 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -23,7 +23,7 @@ using namespace toolkit; namespace mediakit { -HttpSession::HttpSession(const Socket::Ptr &pSock) : TcpSession(pSock) { +HttpSession::HttpSession(const Socket::Ptr &pSock) : Session(pSock) { TraceP(this); GET_CONFIG(uint32_t,keep_alive_sec,Http::kKeepAliveSecond); pSock->setSendTimeOutSecond(keep_alive_sec); @@ -440,7 +440,7 @@ class AsyncSenderData { public: friend class AsyncSender; typedef std::shared_ptr Ptr; - AsyncSenderData(const TcpSession::Ptr &session, const HttpBody::Ptr &body, bool close_when_complete) { + AsyncSenderData(const Session::Ptr &session, const HttpBody::Ptr &body, bool close_when_complete) { _session = dynamic_pointer_cast(session); _body = body; _close_when_complete = close_when_complete; @@ -675,7 +675,7 @@ std::string HttpSession::get_peer_ip() { if(!forwarded_ip_header.empty() && !_parser.getHeader()[forwarded_ip_header].empty()){ return _parser.getHeader()[forwarded_ip_header]; } - return TcpSession::get_peer_ip(); + return Session::get_peer_ip(); } void HttpSession::Handle_Req_POST(ssize_t &content_len) { diff --git a/src/Http/HttpSession.h b/src/Http/HttpSession.h index 6f5bebdf..dadb5e52 100644 --- a/src/Http/HttpSession.h +++ b/src/Http/HttpSession.h @@ -12,7 +12,7 @@ #define SRC_HTTP_HTTPSESSION_H_ #include -#include "Network/TcpSession.h" +#include "Network/Session.h" #include "Rtmp/RtmpMediaSource.h" #include "Rtmp/FlvMuxer.h" #include "HttpRequestSplitter.h" @@ -24,7 +24,7 @@ namespace mediakit { -class HttpSession: public toolkit::TcpSession, +class HttpSession: public toolkit::Session, public FlvMuxer, public HttpRequestSplitter, public WebSocketSplitter { @@ -139,7 +139,7 @@ private: std::function _contentCallBack; }; -using HttpsSession = toolkit::TcpSessionWithSSL; +using HttpsSession = toolkit::SessionWithSSL; } /* namespace mediakit */ diff --git a/src/Http/WebSocketSession.h b/src/Http/WebSocketSession.h index 832fe338..c7eb9b8f 100644 --- a/src/Http/WebSocketSession.h +++ b/src/Http/WebSocketSession.h @@ -27,18 +27,18 @@ public: }; /** - * 该类实现了TcpSession派生类发送数据的截取 + * 该类实现了Session派生类发送数据的截取 * 目的是发送业务数据前进行websocket协议的打包 */ -template -class TcpSessionTypeImp : public TcpSessionType, public SendInterceptor{ +template +class SessionTypeImp : public SessionType, public SendInterceptor{ public: - typedef std::shared_ptr Ptr; + using Ptr = std::shared_ptr; - TcpSessionTypeImp(const mediakit::Parser &header, const mediakit::HttpSession &parent, const toolkit::Socket::Ptr &pSock) : - TcpSessionType(pSock), _identifier(parent.getIdentifier()) {} + SessionTypeImp(const mediakit::Parser &header, const mediakit::HttpSession &parent, const toolkit::Socket::Ptr &pSock) : + SessionType(pSock), _identifier(parent.getIdentifier()) {} - ~TcpSessionTypeImp() {} + ~SessionTypeImp() = default; /** * 设置发送数据截取回调函数 @@ -58,7 +58,7 @@ protected: if (_beforeSendCB) { return _beforeSendCB(buf); } - return TcpSessionType::send(std::move(buf)); + return SessionType::send(std::move(buf)); } std::string getIdentifier() const override { @@ -70,12 +70,12 @@ private: onBeforeSendCB _beforeSendCB; }; -template -class TcpSessionCreator { +template +class SessionCreator { public: - //返回的TcpSession必须派生于SendInterceptor,可以返回null - toolkit::TcpSession::Ptr operator()(const mediakit::Parser &header, const mediakit::HttpSession &parent, const toolkit::Socket::Ptr &pSock){ - return std::make_shared >(header,parent,pSock); + //返回的Session必须派生于SendInterceptor,可以返回null + toolkit::Session::Ptr operator()(const mediakit::Parser &header, const mediakit::HttpSession &parent, const toolkit::Socket::Ptr &pSock){ + return std::make_shared >(header,parent,pSock); } }; @@ -228,15 +228,15 @@ private: std::string _payload_cache; std::string _payload_section; std::weak_ptr _weak_server; - toolkit::TcpSession::Ptr _session; + toolkit::Session::Ptr _session; Creator _creator; }; -template -class WebSocketSession : public WebSocketSessionBase,HttpSessionType,DataType>{ +template +class WebSocketSession : public WebSocketSessionBase,HttpSessionType,DataType>{ public: - WebSocketSession(const toolkit::Socket::Ptr &pSock) : WebSocketSessionBase,HttpSessionType,DataType>(pSock){} + WebSocketSession(const toolkit::Socket::Ptr &pSock) : WebSocketSessionBase,HttpSessionType,DataType>(pSock){} virtual ~WebSocketSession(){} }; diff --git a/src/Rtmp/RtmpSession.cpp b/src/Rtmp/RtmpSession.cpp index 1bda933b..9d8acf51 100644 --- a/src/Rtmp/RtmpSession.cpp +++ b/src/Rtmp/RtmpSession.cpp @@ -17,7 +17,7 @@ using namespace toolkit; namespace mediakit { -RtmpSession::RtmpSession(const Socket::Ptr &sock) : TcpSession(sock) { +RtmpSession::RtmpSession(const Socket::Ptr &sock) : Session(sock) { DebugP(this); GET_CONFIG(uint32_t,keep_alive_sec,Rtmp::kKeepAliveSecond); sock->setSendTimeOutSecond(keep_alive_sec); diff --git a/src/Rtmp/RtmpSession.h b/src/Rtmp/RtmpSession.h index cc8344e5..d124d858 100644 --- a/src/Rtmp/RtmpSession.h +++ b/src/Rtmp/RtmpSession.h @@ -20,12 +20,12 @@ #include "RtmpMediaSourceImp.h" #include "Util/util.h" #include "Util/TimeTicker.h" -#include "Network/TcpSession.h" +#include "Network/Session.h" #include "Common/Stamp.h" namespace mediakit { -class RtmpSession : public toolkit::TcpSession, public RtmpProtocol, public MediaSourceEvent { +class RtmpSession : public toolkit::Session, public RtmpProtocol, public MediaSourceEvent { public: using Ptr = std::shared_ptr; @@ -109,7 +109,7 @@ private: /** * 支持ssl加密的rtmp服务器 */ -using RtmpSessionWithSSL = toolkit::TcpSessionWithSSL; +using RtmpSessionWithSSL = toolkit::SessionWithSSL; } /* namespace mediakit */ #endif /* SRC_RTMP_RTMPSESSION_H_ */ diff --git a/src/Rtp/RtpSession.h b/src/Rtp/RtpSession.h index 31e804c3..fa346802 100644 --- a/src/Rtp/RtpSession.h +++ b/src/Rtp/RtpSession.h @@ -13,7 +13,7 @@ #if defined(ENABLE_RTPPROXY) -#include "Network/TcpSession.h" +#include "Network/Session.h" #include "RtpSplitter.h" #include "RtpProcess.h" #include "Util/TimeTicker.h" diff --git a/src/Rtsp/RtspSession.cpp b/src/Rtsp/RtspSession.cpp index 0faf852a..2a67a18e 100644 --- a/src/Rtsp/RtspSession.cpp +++ b/src/Rtsp/RtspSession.cpp @@ -49,7 +49,7 @@ static unordered_map > g_mapGetter; //对g_mapGetter上锁保护 static recursive_mutex g_mtxGetter; -RtspSession::RtspSession(const Socket::Ptr &sock) : TcpSession(sock) { +RtspSession::RtspSession(const Socket::Ptr &sock) : Session(sock) { DebugP(this); GET_CONFIG(uint32_t,keep_alive_sec,Rtsp::kKeepAliveSecond); sock->setSendTimeOutSecond(keep_alive_sec); @@ -1078,7 +1078,7 @@ ssize_t RtspSession::send(Buffer::Ptr pkt){ // DebugP(this) << pkt->data(); // } _bytes_usage += pkt->size(); - return TcpSession::send(std::move(pkt)); + return Session::send(std::move(pkt)); } bool RtspSession::sendRtspResponse(const string &res_code, const std::initializer_list &header, const string &sdp, const char *protocol) { diff --git a/src/Rtsp/RtspSession.h b/src/Rtsp/RtspSession.h index 10c0c66e..fb8f080b 100644 --- a/src/Rtsp/RtspSession.h +++ b/src/Rtsp/RtspSession.h @@ -18,7 +18,7 @@ #include "Util/util.h" #include "Util/logger.h" #include "Common/config.h" -#include "Network/TcpSession.h" +#include "Network/Session.h" #include "Player/PlayerBase.h" #include "RtpMultiCaster.h" #include "RtspMediaSource.h" @@ -52,7 +52,7 @@ private: Buffer::Ptr _rtp; }; -class RtspSession : public toolkit::TcpSession, public RtspSplitter, public RtpReceiver, public MediaSourceEvent { +class RtspSession : public toolkit::Session, public RtspSplitter, public RtpReceiver, public MediaSourceEvent { public: using Ptr = std::shared_ptr; using onGetRealm = std::function; @@ -62,7 +62,7 @@ public: RtspSession(const toolkit::Socket::Ptr &sock); virtual ~RtspSession(); - ////TcpSession override//// + ////Session override//// void onRecv(const toolkit::Buffer::Ptr &buf) override; void onError(const toolkit::SockException &err) override; void onManager() override; @@ -94,7 +94,7 @@ protected: // 由于支持断连续推,存在OwnerPoller变更的可能 toolkit::EventPoller::Ptr getOwnerPoller(MediaSource &sender) override; - /////TcpSession override//// + /////Session override//// ssize_t send(toolkit::Buffer::Ptr pkt) override; //收到RTCP包回调 virtual void onRtcpPacket(int track_idx, SdpTrack::Ptr &track, const char *data, size_t len); @@ -225,7 +225,7 @@ private: /** * 支持ssl加密的rtsp服务器,可用于诸如亚马逊echo show这样的设备访问 */ -using RtspSessionWithSSL = toolkit::TcpSessionWithSSL; +using RtspSessionWithSSL = toolkit::SessionWithSSL; } /* namespace mediakit */ diff --git a/src/Shell/ShellSession.cpp b/src/Shell/ShellSession.cpp index 79c7b1b9..fe3ac75b 100644 --- a/src/Shell/ShellSession.cpp +++ b/src/Shell/ShellSession.cpp @@ -24,7 +24,7 @@ static onceToken s_token([]() { REGIST_CMD(media); }, nullptr); -ShellSession::ShellSession(const Socket::Ptr &_sock) : TcpSession(_sock) { +ShellSession::ShellSession(const Socket::Ptr &_sock) : Session(_sock) { DebugP(this); pleaseInputUser(); } diff --git a/src/Shell/ShellSession.h b/src/Shell/ShellSession.h index f061a55f..6f1a1b7b 100644 --- a/src/Shell/ShellSession.h +++ b/src/Shell/ShellSession.h @@ -14,11 +14,11 @@ #include #include "Common/config.h" #include "Util/TimeTicker.h" -#include "Network/TcpSession.h" +#include "Network/Session.h" namespace mediakit { -class ShellSession: public toolkit::TcpSession { +class ShellSession: public toolkit::Session { public: ShellSession(const toolkit::Socket::Ptr &_sock); virtual ~ShellSession(); diff --git a/srt/SrtSession.cpp b/srt/SrtSession.cpp index b6a8a839..5faa02d2 100644 --- a/srt/SrtSession.cpp +++ b/srt/SrtSession.cpp @@ -8,7 +8,7 @@ namespace SRT { using namespace mediakit; SrtSession::SrtSession(const Socket::Ptr &sock) - : UdpSession(sock) { + : Session(sock) { socklen_t addr_len = sizeof(_peer_addr); memset(&_peer_addr, 0, addr_len); // TraceL<<"before addr len "< >(header, parent, pSock); + return std::make_shared >(header, parent, pSock); } - return std::make_shared >(header, parent, pSock); + return std::make_shared >(header, parent, pSock); } }; @@ -107,7 +107,7 @@ int main(int argc, char *argv[]) { httpsSrv->start >(443);//默认443 TcpServer::Ptr httpSrvOld(new TcpServer()); - //兼容之前的代码(但是不支持根据url选择生成TcpSession类型) + //兼容之前的代码(但是不支持根据url选择生成Session类型) httpSrvOld->start >(8080); DebugL << "请打开网页:http://www.websocket-test.com/,进行测试";