From 88826aae8fed0cc30e70d272e1ede6daecf82db6 Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 11 Sep 2020 16:59:22 +0800 Subject: [PATCH] Rename SrsConnection to SrsTcpConnection --- trunk/src/app/srs_app_caster_flv.cpp | 2 +- trunk/src/app/srs_app_conn.cpp | 22 +++++++++++----------- trunk/src/app/srs_app_conn.hpp | 8 ++++---- trunk/src/app/srs_app_http_api.cpp | 3 ++- trunk/src/app/srs_app_http_api.hpp | 2 +- trunk/src/app/srs_app_http_conn.cpp | 3 ++- trunk/src/app/srs_app_http_conn.hpp | 3 +-- trunk/src/app/srs_app_rtc_source.hpp | 2 +- trunk/src/app/srs_app_rtmp_conn.cpp | 5 +++-- trunk/src/app/srs_app_rtmp_conn.hpp | 2 +- trunk/src/app/srs_app_server.cpp | 12 ++++++------ trunk/src/app/srs_app_server.hpp | 8 ++++---- trunk/src/app/srs_app_source.cpp | 4 ++-- trunk/src/app/srs_app_source.hpp | 8 ++++---- trunk/src/app/srs_app_statistic.cpp | 4 ++-- trunk/src/app/srs_app_statistic.hpp | 8 ++++---- 16 files changed, 49 insertions(+), 47 deletions(-) diff --git a/trunk/src/app/srs_app_caster_flv.cpp b/trunk/src/app/srs_app_caster_flv.cpp index 7cfaf8253..44e212c66 100644 --- a/trunk/src/app/srs_app_caster_flv.cpp +++ b/trunk/src/app/srs_app_caster_flv.cpp @@ -97,7 +97,7 @@ srs_error_t SrsAppCasterFlv::on_tcp_client(srs_netfd_t stfd) void SrsAppCasterFlv::remove(ISrsConnection* c) { - SrsConnection* conn = dynamic_cast(c); + SrsTcpConnection* conn = dynamic_cast(c); std::vector::iterator it; if ((it = std::find(conns.begin(), conns.end(), conn)) != conns.end()) { diff --git a/trunk/src/app/srs_app_conn.cpp b/trunk/src/app/srs_app_conn.cpp index d1f1949de..0dc2fec8c 100644 --- a/trunk/src/app/srs_app_conn.cpp +++ b/trunk/src/app/srs_app_conn.cpp @@ -94,7 +94,7 @@ void SrsCoroutineManager::clear() } } -SrsConnection::SrsConnection(IConnectionManager* cm, srs_netfd_t c, string cip, int cport) +SrsTcpConnection::SrsTcpConnection(IConnectionManager* cm, srs_netfd_t c, string cip, int cport) { manager = cm; stfd = c; @@ -110,7 +110,7 @@ SrsConnection::SrsConnection(IConnectionManager* cm, srs_netfd_t c, string cip, trd = new SrsSTCoroutine("conn", this); } -SrsConnection::~SrsConnection() +SrsTcpConnection::~SrsTcpConnection() { dispose(); @@ -122,17 +122,17 @@ SrsConnection::~SrsConnection() srs_close_stfd(stfd); } -void SrsConnection::remark(int64_t* in, int64_t* out) +void SrsTcpConnection::remark(int64_t* in, int64_t* out) { kbps->remark(in, out); } -void SrsConnection::dispose() +void SrsTcpConnection::dispose() { trd->interrupt(); } -srs_error_t SrsConnection::start() +srs_error_t SrsTcpConnection::start() { srs_error_t err = srs_success; @@ -147,7 +147,7 @@ srs_error_t SrsConnection::start() return err; } -srs_error_t SrsConnection::set_tcp_nodelay(bool v) +srs_error_t SrsTcpConnection::set_tcp_nodelay(bool v) { srs_error_t err = srs_success; @@ -178,7 +178,7 @@ srs_error_t SrsConnection::set_tcp_nodelay(bool v) return err; } -srs_error_t SrsConnection::set_socket_buffer(srs_utime_t buffer_v) +srs_error_t SrsTcpConnection::set_socket_buffer(srs_utime_t buffer_v) { srs_error_t err = srs_success; @@ -230,7 +230,7 @@ srs_error_t SrsConnection::set_socket_buffer(srs_utime_t buffer_v) return err; } -srs_error_t SrsConnection::cycle() +srs_error_t SrsTcpConnection::cycle() { srs_error_t err = do_cycle(); @@ -264,17 +264,17 @@ srs_error_t SrsConnection::cycle() return srs_success; } -SrsContextId SrsConnection::srs_id() +SrsContextId SrsTcpConnection::srs_id() { return trd->cid(); } -string SrsConnection::remote_ip() +string SrsTcpConnection::remote_ip() { return ip; } -void SrsConnection::expire() +void SrsTcpConnection::expire() { trd->interrupt(); } diff --git a/trunk/src/app/srs_app_conn.hpp b/trunk/src/app/srs_app_conn.hpp index 14df865a3..c6ab56a5b 100644 --- a/trunk/src/app/srs_app_conn.hpp +++ b/trunk/src/app/srs_app_conn.hpp @@ -61,10 +61,10 @@ private: void clear(); }; -// The basic connection of SRS, +// The basic connection of SRS, for TCP based protocols, // all connections accept from listener must extends from this base class, // server will add the connection to manager, and delete it when remove. -class SrsConnection : virtual public ISrsConnection, virtual public ISrsCoroutineHandler +class SrsTcpConnection : virtual public ISrsConnection, virtual public ISrsCoroutineHandler , virtual public ISrsKbpsDelta, virtual public ISrsReloadHandler { protected: @@ -90,8 +90,8 @@ protected: // for current connection to log self create time and calculate the living time. int64_t create_time; public: - SrsConnection(IConnectionManager* cm, srs_netfd_t c, std::string cip, int cport); - virtual ~SrsConnection(); + SrsTcpConnection(IConnectionManager* cm, srs_netfd_t c, std::string cip, int cport); + virtual ~SrsTcpConnection(); // Interface ISrsKbpsDelta public: virtual void remark(int64_t* in, int64_t* out); diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp index 420b9b8ae..04347022f 100644 --- a/trunk/src/app/srs_app_http_api.cpp +++ b/trunk/src/app/srs_app_http_api.cpp @@ -1674,7 +1674,8 @@ srs_error_t SrsGoApiTcmalloc::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess } #endif -SrsHttpApi::SrsHttpApi(IConnectionManager* cm, srs_netfd_t fd, SrsHttpServeMux* m, string cip, int port) : SrsConnection(cm, fd, cip, port) +SrsHttpApi::SrsHttpApi(IConnectionManager* cm, srs_netfd_t fd, SrsHttpServeMux* m, string cip, int port) + : SrsTcpConnection(cm, fd, cip, port) { mux = m; cors = new SrsHttpCorsMux(); diff --git a/trunk/src/app/srs_app_http_api.hpp b/trunk/src/app/srs_app_http_api.hpp index e71a9a682..00035b222 100644 --- a/trunk/src/app/srs_app_http_api.hpp +++ b/trunk/src/app/srs_app_http_api.hpp @@ -254,7 +254,7 @@ public: }; #endif -class SrsHttpApi : virtual public SrsConnection, virtual public ISrsReloadHandler +class SrsHttpApi : virtual public SrsTcpConnection, virtual public ISrsReloadHandler { private: SrsHttpParser* parser; diff --git a/trunk/src/app/srs_app_http_conn.cpp b/trunk/src/app/srs_app_http_conn.cpp index 05c2ea89b..c8e1cdb1d 100644 --- a/trunk/src/app/srs_app_http_conn.cpp +++ b/trunk/src/app/srs_app_http_conn.cpp @@ -59,7 +59,8 @@ using namespace std; #include #include -SrsHttpConn::SrsHttpConn(IConnectionManager* cm, srs_netfd_t fd, ISrsHttpServeMux* m, string cip, int port) : SrsConnection(cm, fd, cip, port) +SrsHttpConn::SrsHttpConn(IConnectionManager* cm, srs_netfd_t fd, ISrsHttpServeMux* m, string cip, int port) + : SrsTcpConnection(cm, fd, cip, port) { parser = new SrsHttpParser(); cors = new SrsHttpCorsMux(); diff --git a/trunk/src/app/srs_app_http_conn.hpp b/trunk/src/app/srs_app_http_conn.hpp index 67c489088..9bc296c58 100644 --- a/trunk/src/app/srs_app_http_conn.hpp +++ b/trunk/src/app/srs_app_http_conn.hpp @@ -50,13 +50,12 @@ class SrsSharedPtrMessage; class SrsRequest; class SrsFastStream; class SrsHttpUri; -class SrsConnection; class SrsHttpMessage; class SrsHttpStreamServer; class SrsHttpStaticServer; // The http connection which request the static or stream content. -class SrsHttpConn : public SrsConnection +class SrsHttpConn : public SrsTcpConnection { protected: SrsHttpParser* parser; diff --git a/trunk/src/app/srs_app_rtc_source.hpp b/trunk/src/app/srs_app_rtc_source.hpp index 2efad8ca3..5d866266f 100644 --- a/trunk/src/app/srs_app_rtc_source.hpp +++ b/trunk/src/app/srs_app_rtc_source.hpp @@ -38,7 +38,7 @@ #include class SrsRequest; -class SrsConnection; +class SrsTcpConnection; class SrsMetaCache; class SrsSharedPtrMessage; class SrsCommonMessage; diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index 27e6d2e4f..a74ec4296 100644 --- a/trunk/src/app/srs_app_rtmp_conn.cpp +++ b/trunk/src/app/srs_app_rtmp_conn.cpp @@ -104,7 +104,8 @@ SrsClientInfo::~SrsClientInfo() srs_freep(res); } -SrsRtmpConn::SrsRtmpConn(SrsServer* svr, srs_netfd_t c, string cip, int port) : SrsConnection(svr, c, cip, port) +SrsRtmpConn::SrsRtmpConn(SrsServer* svr, srs_netfd_t c, string cip, int port) + : SrsTcpConnection(svr, c, cip, port) { server = svr; @@ -141,7 +142,7 @@ SrsRtmpConn::~SrsRtmpConn() void SrsRtmpConn::dispose() { - SrsConnection::dispose(); + SrsTcpConnection::dispose(); // wakeup the handler which need to notice. if (wakable) { diff --git a/trunk/src/app/srs_app_rtmp_conn.hpp b/trunk/src/app/srs_app_rtmp_conn.hpp index 4e96d474d..ccafe09d8 100644 --- a/trunk/src/app/srs_app_rtmp_conn.hpp +++ b/trunk/src/app/srs_app_rtmp_conn.hpp @@ -83,7 +83,7 @@ public: }; // The client provides the main logic control for RTMP clients. -class SrsRtmpConn : virtual public SrsConnection, virtual public ISrsReloadHandler +class SrsRtmpConn : virtual public SrsTcpConnection, virtual public ISrsReloadHandler { // For the thread to directly access any field of connection. friend class SrsPublishRecvThread; diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 15decf09e..a457dade9 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -1473,8 +1473,8 @@ void SrsServer::resample_kbps() SrsStatistic* stat = SrsStatistic::instance(); // collect delta from all clients. - for (std::vector::iterator it = conns.begin(); it != conns.end(); ++it) { - SrsConnection* conn = *it; + for (std::vector::iterator it = conns.begin(); it != conns.end(); ++it) { + SrsTcpConnection* conn = *it; // add delta of connection to server kbps., // for next sample() of server kbps can get the stat. @@ -1493,7 +1493,7 @@ srs_error_t SrsServer::accept_client(SrsListenerType type, srs_netfd_t stfd) { srs_error_t err = srs_success; - SrsConnection* conn = NULL; + SrsTcpConnection* conn = NULL; if ((err = fd2conn(type, stfd, &conn)) != srs_success) { if (srs_error_code(err) == ERROR_SOCKET_GET_PEER_IP && _srs_config->empty_ip_ok()) { @@ -1521,7 +1521,7 @@ SrsHttpServeMux* SrsServer::api_server() return http_api_mux; } -srs_error_t SrsServer::fd2conn(SrsListenerType type, srs_netfd_t stfd, SrsConnection** pconn) +srs_error_t SrsServer::fd2conn(SrsListenerType type, srs_netfd_t stfd, SrsTcpConnection** pconn) { srs_error_t err = srs_success; @@ -1577,8 +1577,8 @@ srs_error_t SrsServer::fd2conn(SrsListenerType type, srs_netfd_t stfd, SrsConnec void SrsServer::remove(ISrsConnection* c) { - SrsConnection* conn = dynamic_cast(c); - std::vector::iterator it = std::find(conns.begin(), conns.end(), conn); + SrsTcpConnection* conn = dynamic_cast(c); + std::vector::iterator it = std::find(conns.begin(), conns.end(), conn); // removed by destroy, ignore. if (it == conns.end()) { diff --git a/trunk/src/app/srs_app_server.hpp b/trunk/src/app/srs_app_server.hpp index bcb64b845..23f52ea61 100644 --- a/trunk/src/app/srs_app_server.hpp +++ b/trunk/src/app/srs_app_server.hpp @@ -40,7 +40,7 @@ #include class SrsServer; -class SrsConnection; +class SrsTcpConnection; class SrsHttpServeMux; class SrsHttpServer; class SrsIngester; @@ -257,7 +257,7 @@ private: // maybe valid but the process is not SRS, the init.d script will never start server. int pid_fd; // All connections, connection manager - std::vector conns; + std::vector conns; // All listners, listener manager. std::vector listeners; // Signal manager which convert gignal to io message. @@ -343,12 +343,12 @@ public: // TODO: FIXME: Fetch from hybrid server manager. virtual SrsHttpServeMux* api_server(); private: - virtual srs_error_t fd2conn(SrsListenerType type, srs_netfd_t stfd, SrsConnection** pconn); + virtual srs_error_t fd2conn(SrsListenerType type, srs_netfd_t stfd, SrsTcpConnection** pconn); // Interface IConnectionManager public: // A callback for connection to remove itself. // When connection thread cycle terminated, callback this to delete connection. - // @see SrsConnection.on_thread_stop(). + // @see SrsTcpConnection.on_thread_stop(). virtual void remove(ISrsConnection* c); // Interface ISrsReloadHandler. public: diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 389156e9c..93561fc68 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -418,7 +418,7 @@ ISrsWakable::~ISrsWakable() { } -SrsConsumer::SrsConsumer(SrsSource* s, SrsConnection* c) +SrsConsumer::SrsConsumer(SrsSource* s, SrsTcpConnection* c) { source = s; conn = c; @@ -2578,7 +2578,7 @@ void SrsSource::on_unpublish() } } -srs_error_t SrsSource::create_consumer(SrsConnection* conn, SrsConsumer*& consumer) +srs_error_t SrsSource::create_consumer(SrsTcpConnection* conn, SrsConsumer*& consumer) { srs_error_t err = srs_success; diff --git a/trunk/src/app/srs_app_source.hpp b/trunk/src/app/srs_app_source.hpp index ededa3d7c..783ce3fc0 100644 --- a/trunk/src/app/srs_app_source.hpp +++ b/trunk/src/app/srs_app_source.hpp @@ -51,7 +51,7 @@ class SrsRtmpServer; class SrsEdgeProxyContext; class SrsMessageArray; class SrsNgExec; -class SrsConnection; +class SrsTcpConnection; class SrsMessageHeader; class SrsHls; class SrsRtc; @@ -190,7 +190,7 @@ private: SrsSource* source; SrsMessageQueue* queue; // The owner connection for debug, maybe NULL. - SrsConnection* conn; + SrsTcpConnection* conn; bool paused; // when source id changed, notice all consumers bool should_update_source_id; @@ -203,7 +203,7 @@ private: srs_utime_t mw_duration; #endif public: - SrsConsumer(SrsSource* s, SrsConnection* c); + SrsConsumer(SrsSource* s, SrsTcpConnection* c); virtual ~SrsConsumer(); public: // Set the size of queue. @@ -599,7 +599,7 @@ public: public: // Create consumer // @param consumer, output the create consumer. - virtual srs_error_t create_consumer(SrsConnection* conn, SrsConsumer*& consumer); + virtual srs_error_t create_consumer(SrsTcpConnection* conn, SrsConsumer*& consumer); // Dumps packets in cache to consumer. // @param ds, whether dumps the sequence header. // @param dm, whether dumps the metadata. diff --git a/trunk/src/app/srs_app_statistic.cpp b/trunk/src/app/srs_app_statistic.cpp index a2324d31e..851ab86e7 100644 --- a/trunk/src/app/srs_app_statistic.cpp +++ b/trunk/src/app/srs_app_statistic.cpp @@ -422,7 +422,7 @@ void SrsStatistic::on_stream_close(SrsRequest* req) } } -srs_error_t SrsStatistic::on_client(SrsContextId cid, SrsRequest* req, SrsConnection* conn, SrsRtmpConnType type) +srs_error_t SrsStatistic::on_client(SrsContextId cid, SrsRequest* req, SrsTcpConnection* conn, SrsRtmpConnType type) { srs_error_t err = srs_success; @@ -474,7 +474,7 @@ void SrsStatistic::on_disconnect(SrsContextId cid) vhost->nb_clients--; } -void SrsStatistic::kbps_add_delta(SrsConnection* conn) +void SrsStatistic::kbps_add_delta(SrsTcpConnection* conn) { // TODO: FIXME: Should not use context id as connection id. std::string id = conn->srs_id().c_str(); diff --git a/trunk/src/app/srs_app_statistic.hpp b/trunk/src/app/srs_app_statistic.hpp index 2a4aaf3aa..69445df82 100644 --- a/trunk/src/app/srs_app_statistic.hpp +++ b/trunk/src/app/srs_app_statistic.hpp @@ -36,7 +36,7 @@ class SrsKbps; class SrsWallClock; class SrsRequest; -class SrsConnection; +class SrsTcpConnection; class SrsJsonObject; class SrsJsonArray; @@ -110,7 +110,7 @@ struct SrsStatisticClient { public: SrsStatisticStream* stream; - SrsConnection* conn; + SrsTcpConnection* conn; SrsRequest* req; SrsRtmpConnType type; std::string id; @@ -205,7 +205,7 @@ public: // @param conn, the physical absract connection object. // @param type, the type of connection. // TODO: FIXME: We should not use context id as client id. - virtual srs_error_t on_client(SrsContextId id, SrsRequest* req, SrsConnection* conn, SrsRtmpConnType type); + virtual srs_error_t on_client(SrsContextId id, SrsRequest* req, SrsTcpConnection* conn, SrsRtmpConnType type); // Client disconnect // @remark the on_disconnect always call, while the on_client is call when // only got the request object, so the client specified by id maybe not @@ -215,7 +215,7 @@ public: // Sample the kbps, add delta bytes of conn. // Use kbps_sample() to get all result of kbps stat. // TODO: FIXME: the add delta must use ISrsKbpsDelta interface instead. - virtual void kbps_add_delta(SrsConnection* conn); + virtual void kbps_add_delta(SrsTcpConnection* conn); // Calc the result for all kbps. // @return the server kbps. virtual SrsKbps* kbps_sample();