1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Refine typo in app.

This commit is contained in:
winlin 2019-04-28 09:08:05 +08:00
parent 4d25520f99
commit aac8a13f42
15 changed files with 1065 additions and 1962 deletions

View file

@ -55,7 +55,7 @@ class SrsKafkaProducer;
#endif
class SrsCoroutineManager;
// listener type for server to identify the connection,
// The listener type for server to identify the connection,
// that is, use different type to process the connection.
enum SrsListenerType
{
@ -73,9 +73,7 @@ enum SrsListenerType
SrsListenerFlv = 5,
};
/**
* the common tcp listener, for RTMP/HTTP server.
*/
// A common tcp listener, for RTMP/HTTP server.
class SrsListener
{
protected:
@ -92,9 +90,7 @@ public:
virtual srs_error_t listen(std::string i, int p) = 0;
};
/**
* tcp listener.
*/
// A buffered TCP listener.
class SrsBufferListener : virtual public SrsListener, virtual public ISrsTcpHandler
{
private:
@ -104,14 +100,12 @@ public:
virtual ~SrsBufferListener();
public:
virtual srs_error_t listen(std::string ip, int port);
// ISrsTcpHandler
// interface ISrsTcpHandler
public:
virtual srs_error_t on_tcp_client(srs_netfd_t stfd);
};
/**
* the tcp listener, for rtsp server.
*/
// A TCP listener, for rtsp server.
class SrsRtspListener : virtual public SrsListener, virtual public ISrsTcpHandler
{
private:
@ -122,14 +116,12 @@ public:
virtual ~SrsRtspListener();
public:
virtual srs_error_t listen(std::string i, int p);
// ISrsTcpHandler
// interface ISrsTcpHandler
public:
virtual srs_error_t on_tcp_client(srs_netfd_t stfd);
};
/**
* the tcp listener, for flv stream server.
*/
// A TCP listener, for flv stream server.
class SrsHttpFlvListener : virtual public SrsListener, virtual public ISrsTcpHandler
{
private:
@ -140,14 +132,12 @@ public:
virtual ~SrsHttpFlvListener();
public:
virtual srs_error_t listen(std::string i, int p);
// ISrsTcpHandler
// interface ISrsTcpHandler
public:
virtual srs_error_t on_tcp_client(srs_netfd_t stfd);
};
/**
* the udp listener, for udp server.
*/
// A UDP listener, for udp server.
class SrsUdpStreamListener : public SrsListener
{
protected:
@ -160,9 +150,7 @@ public:
virtual srs_error_t listen(std::string i, int p);
};
/**
* the udp listener, for udp stream caster server.
*/
// A UDP listener, for udp stream caster server.
class SrsUdpCasterListener : public SrsUdpStreamListener
{
public:
@ -170,15 +158,13 @@ public:
virtual ~SrsUdpCasterListener();
};
/**
* convert signal to io,
* @see: st-1.9/docs/notes.html
*/
// Convert signal to io,
// @see: st-1.9/docs/notes.html
class SrsSignalManager : public ISrsCoroutineHandler
{
private:
/* Per-process pipe which is used as a signal queue. */
/* Up to PIPE_BUF/sizeof(int) signals can be queued up. */
// Per-process pipe which is used as a signal queue.
// Up to PIPE_BUF/sizeof(int) signals can be queued up.
int sig_pipe[2];
srs_netfd_t signal_read_stfd;
private:
@ -194,43 +180,30 @@ public:
public:
virtual srs_error_t cycle();
private:
// global singleton instance
// Global singleton instance
static SrsSignalManager* instance;
/* Signal catching function. */
/* Converts signal event to I/O event. */
// Signal catching function.
// Converts signal event to I/O event.
static void sig_catcher(int signo);
};
/**
* the handler to the handle cycle in SRS RTMP server.
*/
// A handler to the handle cycle in SRS RTMP server.
class ISrsServerCycle
{
public:
ISrsServerCycle();
virtual ~ISrsServerCycle();
public:
/**
* initialize the cycle handler.
*/
// Initialize the cycle handler.
virtual srs_error_t initialize() = 0;
/**
* do on_cycle while server doing cycle.
*/
// Do on_cycle while server doing cycle.
virtual srs_error_t on_cycle() = 0;
/**
* callback the handler when got client.
*/
// Callback the handler when got client.
virtual srs_error_t on_accept_client(int max, int cur) = 0;
};
/**
* SRS RTMP server, initialize and listen,
* start connection service thread, destroy client.
*/
class SrsServer : virtual public ISrsReloadHandler
, virtual public ISrsSourceHandler
, virtual public IConnectionManager
// SRS RTMP server, initialize and listen, start connection service thread, destroy client.
class SrsServer : virtual public ISrsReloadHandler, virtual public ISrsSourceHandler, virtual public IConnectionManager
{
private:
// TODO: FIXME: rename to http_api
@ -240,59 +213,41 @@ private:
SrsIngester* ingester;
SrsCoroutineManager* conn_manager;
private:
/**
* the pid file fd, lock the file write when server is running.
* @remark the init.d script should cleanup the pid file, when stop service,
* for the server never delete the file; when system startup, the pid in pid file
* maybe valid but the process is not SRS, the init.d script will never start server.
*/
// The pid file fd, lock the file write when server is running.
// @remark the init.d script should cleanup the pid file, when stop service,
// for the server never delete the file; when system startup, the pid in pid file
// maybe valid but the process is not SRS, the init.d script will never start server.
int pid_fd;
/**
* all connections, connection manager
*/
// All connections, connection manager
std::vector<SrsConnection*> conns;
/**
* all listners, listener manager.
*/
// All listners, listener manager.
std::vector<SrsListener*> listeners;
/**
* signal manager which convert gignal to io message.
*/
// Signal manager which convert gignal to io message.
SrsSignalManager* signal_manager;
/**
* handle in server cycle.
*/
// Handle in server cycle.
ISrsServerCycle* handler;
/**
* user send the signal, convert to variable.
*/
// User send the signal, convert to variable.
bool signal_reload;
bool signal_persistence_config;
bool signal_gmc_stop;
bool signal_gracefully_quit;
// parent pid for asprocess.
// Parent pid for asprocess.
int ppid;
public:
SrsServer();
virtual ~SrsServer();
private:
/**
* the destroy is for gmc to analysis the memory leak,
* if not destroy global/static data, the gmc will warning memory leak.
* in service, server never destroy, directly exit when restart.
*/
// The destroy is for gmc to analysis the memory leak,
// if not destroy global/static data, the gmc will warning memory leak.
// In service, server never destroy, directly exit when restart.
virtual void destroy();
/**
* when SIGTERM, SRS should do cleanup, for example,
* to stop all ingesters, cleanup HLS and dvr.
*/
// When SIGTERM, SRS should do cleanup, for example,
// to stop all ingesters, cleanup HLS and dvr.
virtual void dispose();
// server startup workflow, @see run_master()
public:
/**
* initialize server with callback handler ch.
* @remark user must free the handler.
*/
// Initialize server with callback handler ch.
// @remark user must free the handler.
virtual srs_error_t initialize(ISrsServerCycle* ch);
virtual srs_error_t initialize_st();
virtual srs_error_t initialize_signal();
@ -304,62 +259,48 @@ public:
virtual srs_error_t cycle();
// server utilities.
public:
/**
* callback for signal manager got a signal.
* the signal manager convert signal to io message,
* whatever, we will got the signo like the orignal signal(int signo) handler.
* @param signo the signal number from user, where:
* SRS_SIGNAL_GRACEFULLY_QUIT, the SIGTERM, dispose then quit.
* SRS_SIGNAL_REOPEN_LOG, the SIGUSR1, reopen the log file.
* SRS_SIGNAL_RELOAD, the SIGHUP, reload the config.
* SRS_SIGNAL_PERSISTENCE_CONFIG, application level signal, persistence config to file.
* @remark, for SIGINT:
* no gmc, directly exit.
* for gmc, set the variable signal_gmc_stop, the cycle will return and cleanup for gmc.
* @remark, maybe the HTTP RAW API will trigger the on_signal() also.
*/
// The callback for signal manager got a signal.
// The signal manager convert signal to io message,
// whatever, we will got the signo like the orignal signal(int signo) handler.
// @param signo the signal number from user, where:
// SRS_SIGNAL_GRACEFULLY_QUIT, the SIGTERM, dispose then quit.
// SRS_SIGNAL_REOPEN_LOG, the SIGUSR1, reopen the log file.
// SRS_SIGNAL_RELOAD, the SIGHUP, reload the config.
// SRS_SIGNAL_PERSISTENCE_CONFIG, application level signal, persistence config to file.
// @remark, for SIGINT:
// no gmc, directly exit.
// for gmc, set the variable signal_gmc_stop, the cycle will return and cleanup for gmc.
// @remark, maybe the HTTP RAW API will trigger the on_signal() also.
virtual void on_signal(int signo);
private:
/**
* the server thread main cycle,
* update the global static data, for instance, the current time,
* the cpu/mem/network statistic.
*/
// The server thread main cycle,
// update the global static data, for instance, the current time,
// the cpu/mem/network statistic.
virtual srs_error_t do_cycle();
/**
* listen at specified protocol.
*/
// listen at specified protocol.
virtual srs_error_t listen_rtmp();
virtual srs_error_t listen_http_api();
virtual srs_error_t listen_http_stream();
virtual srs_error_t listen_stream_caster();
/**
* close the listeners for specified type,
* remove the listen object from manager.
*/
// Close the listeners for specified type,
// Remove the listen object from manager.
virtual void close_listeners(SrsListenerType type);
/**
* resample the server kbs.
*/
// Resample the server kbs.
virtual void resample_kbps();
// internal only
// For internal only
public:
/**
* when listener got a fd, notice server to accept it.
* @param type, the client type, used to create concrete connection,
* for instance RTMP connection to serve client.
* @param stfd, the client fd in st boxed, the underlayer fd.
*/
// When listener got a fd, notice server to accept it.
// @param type, the client type, used to create concrete connection,
// for instance RTMP connection to serve client.
// @param stfd, the client fd in st boxed, the underlayer fd.
virtual srs_error_t accept_client(SrsListenerType type, srs_netfd_t stfd);
private:
virtual srs_error_t fd2conn(SrsListenerType type, srs_netfd_t stfd, SrsConnection** pconn);
// IConnectionManager
// interface IConnectionManager
public:
/**
* callback for connection to remove itself.
* when connection thread cycle terminated, callback this to delete connection.
* @see SrsConnection.on_thread_stop().
*/
// A callback for connection to remove itself.
// When connection thread cycle terminated, callback this to delete connection.
// @see SrsConnection.on_thread_stop().
virtual void remove(ISrsConnection* c);
// interface ISrsReloadHandler.
public: