1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-15 04:42:04 +00:00

Rename SrsConnection to SrsTcpConnection

This commit is contained in:
winlin 2020-09-11 16:59:22 +08:00
parent 2135b638b1
commit 88826aae8f
16 changed files with 49 additions and 47 deletions

View file

@ -97,7 +97,7 @@ srs_error_t SrsAppCasterFlv::on_tcp_client(srs_netfd_t stfd)
void SrsAppCasterFlv::remove(ISrsConnection* c)
{
SrsConnection* conn = dynamic_cast<SrsConnection*>(c);
SrsTcpConnection* conn = dynamic_cast<SrsTcpConnection*>(c);
std::vector<SrsHttpConn*>::iterator it;
if ((it = std::find(conns.begin(), conns.end(), conn)) != conns.end()) {

View file

@ -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();
}

View file

@ -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);

View file

@ -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();

View file

@ -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;

View file

@ -59,7 +59,8 @@ using namespace std;
#include <srs_app_utility.hpp>
#include <srs_app_st.hpp>
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();

View file

@ -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;

View file

@ -38,7 +38,7 @@
#include <srs_app_source.hpp>
class SrsRequest;
class SrsConnection;
class SrsTcpConnection;
class SrsMetaCache;
class SrsSharedPtrMessage;
class SrsCommonMessage;

View file

@ -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) {

View file

@ -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;

View file

@ -1473,8 +1473,8 @@ void SrsServer::resample_kbps()
SrsStatistic* stat = SrsStatistic::instance();
// collect delta from all clients.
for (std::vector<SrsConnection*>::iterator it = conns.begin(); it != conns.end(); ++it) {
SrsConnection* conn = *it;
for (std::vector<SrsTcpConnection*>::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<SrsConnection*>(c);
std::vector<SrsConnection*>::iterator it = std::find(conns.begin(), conns.end(), conn);
SrsTcpConnection* conn = dynamic_cast<SrsTcpConnection*>(c);
std::vector<SrsTcpConnection*>::iterator it = std::find(conns.begin(), conns.end(), conn);
// removed by destroy, ignore.
if (it == conns.end()) {

View file

@ -40,7 +40,7 @@
#include <srs_app_gb28181_sip.hpp>
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<SrsConnection*> conns;
std::vector<SrsTcpConnection*> conns;
// All listners, listener manager.
std::vector<SrsListener*> 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:

View file

@ -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;

View file

@ -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.

View file

@ -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();

View file

@ -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();