AI: Add utest to cover process module
This commit is contained in:
parent
315ae2cd3a
commit
5d01393307
|
|
@ -5,6 +5,7 @@
|
||||||
# ColumnLimit: 0
|
# ColumnLimit: 0
|
||||||
# IndentWidth: 4
|
# IndentWidth: 4
|
||||||
# TabWidth: 4
|
# TabWidth: 4
|
||||||
|
# Macros: SRS_DECLARE_PRIVATE=private, SRS_DECLARE_PROTECTED=protected (treat as access specifiers)
|
||||||
# refer to https://clang.llvm.org/docs/ClangFormatStyleOptions.html for more details.
|
# refer to https://clang.llvm.org/docs/ClangFormatStyleOptions.html for more details.
|
||||||
---
|
---
|
||||||
Language: Cpp
|
Language: Cpp
|
||||||
|
|
@ -198,6 +199,9 @@ LambdaBodyIndentation: Signature
|
||||||
LineEnding: DeriveLF
|
LineEnding: DeriveLF
|
||||||
MacroBlockBegin: ''
|
MacroBlockBegin: ''
|
||||||
MacroBlockEnd: ''
|
MacroBlockEnd: ''
|
||||||
|
Macros:
|
||||||
|
- 'SRS_DECLARE_PRIVATE=private:'
|
||||||
|
- 'SRS_DECLARE_PROTECTED=protected:'
|
||||||
MainIncludeChar: Quote
|
MainIncludeChar: Quote
|
||||||
MaxEmptyLinesToKeep: 1
|
MaxEmptyLinesToKeep: 1
|
||||||
NamespaceIndentation: None
|
NamespaceIndentation: None
|
||||||
|
|
|
||||||
|
|
@ -53,10 +53,12 @@ public:
|
||||||
// That is, the task is execute/call in async mode.
|
// That is, the task is execute/call in async mode.
|
||||||
class SrsAsyncCallWorker : public ISrsCoroutineHandler, public ISrsAsyncCallWorker
|
class SrsAsyncCallWorker : public ISrsCoroutineHandler, public ISrsAsyncCallWorker
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
std::vector<ISrsAsyncCallTask *> tasks_;
|
std::vector<ISrsAsyncCallTask *> tasks_;
|
||||||
srs_cond_t wait_;
|
srs_cond_t wait_;
|
||||||
srs_mutex_t lock_;
|
srs_mutex_t lock_;
|
||||||
|
|
@ -76,7 +78,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual void flush_tasks();
|
virtual void flush_tasks();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,10 +49,12 @@ public:
|
||||||
// A TCP listener, for flv stream server.
|
// A TCP listener, for flv stream server.
|
||||||
class SrsHttpFlvListener : public ISrsHttpFlvListener
|
class SrsHttpFlvListener : public ISrsHttpFlvListener
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsTcpListener *listener_;
|
SrsTcpListener *listener_;
|
||||||
ISrsAppCasterFlv *caster_;
|
ISrsAppCasterFlv *caster_;
|
||||||
|
|
||||||
|
|
@ -83,10 +85,12 @@ public:
|
||||||
// The stream caster for flv stream over HTTP POST.
|
// The stream caster for flv stream over HTTP POST.
|
||||||
class SrsAppCasterFlv : public ISrsAppCasterFlv
|
class SrsAppCasterFlv : public ISrsAppCasterFlv
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string output_;
|
std::string output_;
|
||||||
SrsHttpServeMux *http_mux_;
|
SrsHttpServeMux *http_mux_;
|
||||||
std::vector<ISrsConnection *> conns_;
|
std::vector<ISrsConnection *> conns_;
|
||||||
|
|
@ -135,11 +139,13 @@ public:
|
||||||
// The dynamic http connection, never drop the body.
|
// The dynamic http connection, never drop the body.
|
||||||
class SrsDynamicHttpConn : public ISrsDynamicHttpConn
|
class SrsDynamicHttpConn : public ISrsDynamicHttpConn
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The manager object to manage the connection.
|
// The manager object to manage the connection.
|
||||||
ISrsResourceManager *manager_;
|
ISrsResourceManager *manager_;
|
||||||
std::string output_;
|
std::string output_;
|
||||||
|
|
@ -148,7 +154,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
ISrsProtocolReadWriter *skt_;
|
ISrsProtocolReadWriter *skt_;
|
||||||
ISrsHttpConn *conn_;
|
ISrsHttpConn *conn_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The ip and port of client.
|
// The ip and port of client.
|
||||||
std::string ip_;
|
std::string ip_;
|
||||||
int port_;
|
int port_;
|
||||||
|
|
@ -160,7 +167,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t proxy(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, std::string o);
|
virtual srs_error_t proxy(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, std::string o);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_proxy(ISrsHttpResponseReader *rr, SrsFlvDecoder *dec);
|
virtual srs_error_t do_proxy(ISrsHttpResponseReader *rr, SrsFlvDecoder *dec);
|
||||||
// Extract APIs from SrsTcpConnection.
|
// Extract APIs from SrsTcpConnection.
|
||||||
// Interface ISrsHttpConnOwner.
|
// Interface ISrsHttpConnOwner.
|
||||||
|
|
@ -194,7 +202,8 @@ public:
|
||||||
// The http wrapper for file reader, to read http post stream like a file.
|
// The http wrapper for file reader, to read http post stream like a file.
|
||||||
class SrsHttpFileReader : public ISrsHttpFileReader
|
class SrsHttpFileReader : public ISrsHttpFileReader
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsHttpResponseReader *http_;
|
ISrsHttpResponseReader *http_;
|
||||||
SrsFileReader *file_reader_;
|
SrsFileReader *file_reader_;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,8 @@ public:
|
||||||
|
|
||||||
class SrsCircuitBreaker : public ISrsCircuitBreaker, public ISrsFastTimerHandler
|
class SrsCircuitBreaker : public ISrsCircuitBreaker, public ISrsFastTimerHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool enabled_;
|
bool enabled_;
|
||||||
int high_threshold_;
|
int high_threshold_;
|
||||||
int high_pulse_;
|
int high_pulse_;
|
||||||
|
|
@ -57,7 +58,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
int dying_threshold_;
|
int dying_threshold_;
|
||||||
int dying_pulse_;
|
int dying_pulse_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
int hybrid_high_water_level_;
|
int hybrid_high_water_level_;
|
||||||
int hybrid_critical_water_level_;
|
int hybrid_critical_water_level_;
|
||||||
int hybrid_dying_water_level_;
|
int hybrid_dying_water_level_;
|
||||||
|
|
@ -74,7 +76,8 @@ public:
|
||||||
bool hybrid_critical_water_level();
|
bool hybrid_critical_water_level();
|
||||||
bool hybrid_dying_water_level();
|
bool hybrid_dying_water_level();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t on_timer(srs_utime_t interval);
|
srs_error_t on_timer(srs_utime_t interval);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,8 @@ namespace srs_internal
|
||||||
// The buffer of config content.
|
// The buffer of config content.
|
||||||
class SrsConfigBuffer
|
class SrsConfigBuffer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
// The last available position.
|
// The last available position.
|
||||||
char *last_;
|
char *last_;
|
||||||
// The end of buffer.
|
// The end of buffer.
|
||||||
|
|
@ -228,7 +229,8 @@ public:
|
||||||
virtual SrsJsonAny *dumps_arg0_to_number();
|
virtual SrsJsonAny *dumps_arg0_to_number();
|
||||||
virtual SrsJsonAny *dumps_arg0_to_boolean();
|
virtual SrsJsonAny *dumps_arg0_to_boolean();
|
||||||
// private parse.
|
// private parse.
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The directive parsing context.
|
// The directive parsing context.
|
||||||
enum SrsDirectiveContext {
|
enum SrsDirectiveContext {
|
||||||
// The root directives, parsing file.
|
// The root directives, parsing file.
|
||||||
|
|
@ -606,7 +608,8 @@ class SrsConfig : public ISrsAppConfig
|
||||||
{
|
{
|
||||||
friend class SrsConfDirective;
|
friend class SrsConfDirective;
|
||||||
// user command
|
// user command
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Whether show help and exit.
|
// Whether show help and exit.
|
||||||
bool show_help_;
|
bool show_help_;
|
||||||
// Whether test config file and exit.
|
// Whether test config file and exit.
|
||||||
|
|
@ -619,29 +622,35 @@ SRS_DECLARE_PRIVATE:
|
||||||
// Set it by argv "-e" or env "SRS_ENV_ONLY=on".
|
// Set it by argv "-e" or env "SRS_ENV_ONLY=on".
|
||||||
bool env_only_;
|
bool env_only_;
|
||||||
// global env variables.
|
// global env variables.
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The user parameters, the argc and argv.
|
// The user parameters, the argc and argv.
|
||||||
// The argv is " ".join(argv), where argv is from main(argc, argv).
|
// The argv is " ".join(argv), where argv is from main(argc, argv).
|
||||||
std::string argv_;
|
std::string argv_;
|
||||||
// current working directory.
|
// current working directory.
|
||||||
std::string cwd_;
|
std::string cwd_;
|
||||||
// Config section
|
// Config section
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The last parsed config file.
|
// The last parsed config file.
|
||||||
// If reload, reload the config file.
|
// If reload, reload the config file.
|
||||||
std::string config_file_;
|
std::string config_file_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
// The directive root.
|
// The directive root.
|
||||||
SrsConfDirective *root_;
|
SrsConfDirective *root_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The cache for parsing the config from environment variables.
|
// The cache for parsing the config from environment variables.
|
||||||
SrsConfDirective *env_cache_;
|
SrsConfDirective *env_cache_;
|
||||||
// Reload section
|
// Reload section
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The reload subscribers, when reload, callback all handlers.
|
// The reload subscribers, when reload, callback all handlers.
|
||||||
std::vector<ISrsReloadHandler *> subscribes_;
|
std::vector<ISrsReloadHandler *>
|
||||||
|
subscribes_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SrsConfig();
|
SrsConfig();
|
||||||
|
|
@ -657,37 +666,46 @@ public:
|
||||||
// @remark, user can test the config before reload it.
|
// @remark, user can test the config before reload it.
|
||||||
virtual srs_error_t reload(SrsReloadState *pstate);
|
virtual srs_error_t reload(SrsReloadState *pstate);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
// Reload from the config.
|
// Reload from the config.
|
||||||
// @remark, use protected for the utest to override with mock.
|
// @remark, use protected for the utest to override with mock.
|
||||||
virtual srs_error_t reload_conf(SrsConfig *conf);
|
virtual srs_error_t
|
||||||
|
reload_conf(SrsConfig *conf);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Parse options and file
|
// Parse options and file
|
||||||
public:
|
public:
|
||||||
// Parse the cli, the main(argc,argv) function.
|
// Parse the cli, the main(argc,argv) function.
|
||||||
virtual srs_error_t parse_options(int argc, char **argv);
|
virtual srs_error_t
|
||||||
|
parse_options(int argc, char **argv);
|
||||||
// initialize the cwd for server,
|
// initialize the cwd for server,
|
||||||
// because we may change the workdir.
|
// because we may change the workdir.
|
||||||
virtual srs_error_t initialize_cwd();
|
virtual srs_error_t initialize_cwd();
|
||||||
// Marshal current config to file.
|
// Marshal current config to file.
|
||||||
virtual srs_error_t persistence();
|
virtual srs_error_t persistence();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_persistence(SrsFileWriter *fw);
|
virtual srs_error_t do_persistence(SrsFileWriter *fw);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Dumps the http_api sections to json for raw api info.
|
// Dumps the http_api sections to json for raw api info.
|
||||||
virtual srs_error_t raw_to_json(SrsJsonObject *obj);
|
virtual srs_error_t raw_to_json(SrsJsonObject *obj);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
public:
|
public:
|
||||||
// Get the config file path.
|
// Get the config file path.
|
||||||
virtual std::string config();
|
virtual std::string
|
||||||
|
config();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Parse each argv.
|
// Parse each argv.
|
||||||
virtual srs_error_t parse_argv(int &i, char **argv);
|
virtual srs_error_t
|
||||||
|
parse_argv(int &i, char **argv);
|
||||||
// Print help and exit.
|
// Print help and exit.
|
||||||
virtual void print_help(char **argv);
|
virtual void print_help(char **argv);
|
||||||
|
|
||||||
|
|
@ -695,23 +713,28 @@ public:
|
||||||
// Parse the config file, which is specified by cli.
|
// Parse the config file, which is specified by cli.
|
||||||
virtual srs_error_t parse_file(const char *filename);
|
virtual srs_error_t parse_file(const char *filename);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Build a buffer from a src, which is string content or filename.
|
// Build a buffer from a src, which is string content or filename.
|
||||||
virtual srs_error_t build_buffer(std::string src, srs_internal::SrsConfigBuffer **pbuffer);
|
virtual srs_error_t
|
||||||
|
build_buffer(std::string src, srs_internal::SrsConfigBuffer **pbuffer);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Check the parsed config.
|
// Check the parsed config.
|
||||||
virtual srs_error_t check_config();
|
virtual srs_error_t check_config();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t check_normal_config();
|
virtual srs_error_t check_normal_config();
|
||||||
virtual srs_error_t check_number_connections();
|
virtual srs_error_t check_number_connections();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
// Parse config from the buffer.
|
// Parse config from the buffer.
|
||||||
// @param buffer, the config buffer, user must delete it.
|
// @param buffer, the config buffer, user must delete it.
|
||||||
// @remark, use protected for the utest to override with mock.
|
// @remark, use protected for the utest to override with mock.
|
||||||
virtual srs_error_t parse_buffer(srs_internal::SrsConfigBuffer *buffer);
|
virtual srs_error_t
|
||||||
|
parse_buffer(srs_internal::SrsConfigBuffer *buffer);
|
||||||
// global env
|
// global env
|
||||||
public:
|
public:
|
||||||
// Get the current work directory.
|
// Get the current work directory.
|
||||||
|
|
@ -731,9 +754,11 @@ public:
|
||||||
// Whether srs in docker.
|
// Whether srs in docker.
|
||||||
virtual bool get_in_docker();
|
virtual bool get_in_docker();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Whether user use full.conf
|
// Whether user use full.conf
|
||||||
virtual bool is_full_config();
|
virtual bool
|
||||||
|
is_full_config();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Get the server id, generated a random one if not configured.
|
// Get the server id, generated a random one if not configured.
|
||||||
|
|
@ -845,7 +870,8 @@ public:
|
||||||
virtual bool get_rtc_server_black_hole();
|
virtual bool get_rtc_server_black_hole();
|
||||||
virtual std::string get_rtc_server_black_hole_addr();
|
virtual std::string get_rtc_server_black_hole_addr();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual int get_rtc_server_reuseport2();
|
virtual int get_rtc_server_reuseport2();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -975,9 +1001,11 @@ public:
|
||||||
virtual srs_utime_t get_publish_kickoff_for_idle(std::string vhost);
|
virtual srs_utime_t get_publish_kickoff_for_idle(std::string vhost);
|
||||||
virtual srs_utime_t get_publish_kickoff_for_idle(SrsConfDirective *vhost);
|
virtual srs_utime_t get_publish_kickoff_for_idle(SrsConfDirective *vhost);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Get the global chunk size.
|
// Get the global chunk size.
|
||||||
virtual int get_global_chunk_size();
|
virtual int
|
||||||
|
get_global_chunk_size();
|
||||||
// forward section
|
// forward section
|
||||||
public:
|
public:
|
||||||
// Whether the forwarder enabled.
|
// Whether the forwarder enabled.
|
||||||
|
|
@ -1028,7 +1056,8 @@ public:
|
||||||
// Get the default streamid when client doesn't provide one.
|
// Get the default streamid when client doesn't provide one.
|
||||||
virtual std::string get_srt_default_streamid();
|
virtual std::string get_srt_default_streamid();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsConfDirective *get_srt(std::string vhost);
|
SrsConfDirective *get_srt(std::string vhost);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -1037,9 +1066,11 @@ public:
|
||||||
bool get_srt_to_rtmp(std::string vhost);
|
bool get_srt_to_rtmp(std::string vhost);
|
||||||
|
|
||||||
// http_hooks section
|
// http_hooks section
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Get the http_hooks directive of vhost.
|
// Get the http_hooks directive of vhost.
|
||||||
virtual SrsConfDirective *get_vhost_http_hooks(std::string vhost);
|
virtual SrsConfDirective *
|
||||||
|
get_vhost_http_hooks(std::string vhost);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Whether vhost http-hooks enabled.
|
// Whether vhost http-hooks enabled.
|
||||||
|
|
@ -1185,9 +1216,11 @@ public:
|
||||||
// @remark, we will use some variable, for instance, [vhost] to substitude with vhost.
|
// @remark, we will use some variable, for instance, [vhost] to substitude with vhost.
|
||||||
virtual std::string get_engine_output(SrsConfDirective *conf);
|
virtual std::string get_engine_output(SrsConfDirective *conf);
|
||||||
// vhost exec secion
|
// vhost exec secion
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Get the exec directive of vhost.
|
// Get the exec directive of vhost.
|
||||||
virtual SrsConfDirective *get_exec(std::string vhost);
|
virtual SrsConfDirective *
|
||||||
|
get_exec(std::string vhost);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Whether the exec is enabled of vhost.
|
// Whether the exec is enabled of vhost.
|
||||||
|
|
@ -1226,7 +1259,8 @@ public:
|
||||||
// The ffmpeg log level.
|
// The ffmpeg log level.
|
||||||
virtual std::string get_ff_log_level();
|
virtual std::string get_ff_log_level();
|
||||||
// The MPEG-DASH section.
|
// The MPEG-DASH section.
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual SrsConfDirective *get_dash(std::string vhost);
|
virtual SrsConfDirective *get_dash(std::string vhost);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -1250,9 +1284,11 @@ public:
|
||||||
// The timeout in srs_utime_t to dispose the dash.
|
// The timeout in srs_utime_t to dispose the dash.
|
||||||
virtual srs_utime_t get_dash_dispose(std::string vhost);
|
virtual srs_utime_t get_dash_dispose(std::string vhost);
|
||||||
// hls section
|
// hls section
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Get the hls directive of vhost.
|
// Get the hls directive of vhost.
|
||||||
virtual SrsConfDirective *get_hls(std::string vhost);
|
virtual SrsConfDirective *
|
||||||
|
get_hls(std::string vhost);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Whether HLS is enabled.
|
// Whether HLS is enabled.
|
||||||
|
|
@ -1319,9 +1355,11 @@ public:
|
||||||
// Old fragments are kept. Default is on.
|
// Old fragments are kept. Default is on.
|
||||||
virtual bool get_hls_recover(std::string vhost);
|
virtual bool get_hls_recover(std::string vhost);
|
||||||
// hds section
|
// hds section
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Get the hds directive of vhost.
|
// Get the hds directive of vhost.
|
||||||
virtual SrsConfDirective *get_hds(const std::string &vhost);
|
virtual SrsConfDirective *
|
||||||
|
get_hds(const std::string &vhost);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Whether HDS is enabled.
|
// Whether HDS is enabled.
|
||||||
|
|
@ -1335,9 +1373,11 @@ public:
|
||||||
// a window is a set of hds fragments.
|
// a window is a set of hds fragments.
|
||||||
virtual srs_utime_t get_hds_window(const std::string &vhost);
|
virtual srs_utime_t get_hds_window(const std::string &vhost);
|
||||||
// dvr section
|
// dvr section
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Get the dvr directive.
|
// Get the dvr directive.
|
||||||
virtual SrsConfDirective *get_dvr(std::string vhost);
|
virtual SrsConfDirective *
|
||||||
|
get_dvr(std::string vhost);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Whether dvr is enabled.
|
// Whether dvr is enabled.
|
||||||
|
|
@ -1357,9 +1397,11 @@ public:
|
||||||
// Get the time_jitter algorithm for dvr.
|
// Get the time_jitter algorithm for dvr.
|
||||||
virtual int get_dvr_time_jitter(std::string vhost);
|
virtual int get_dvr_time_jitter(std::string vhost);
|
||||||
// http api section
|
// http api section
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Whether http api enabled
|
// Whether http api enabled
|
||||||
virtual bool get_http_api_enabled(SrsConfDirective *conf);
|
virtual bool
|
||||||
|
get_http_api_enabled(SrsConfDirective *conf);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Whether http api enabled.
|
// Whether http api enabled.
|
||||||
|
|
@ -1383,7 +1425,8 @@ public:
|
||||||
// Get the http api auth password.
|
// Get the http api auth password.
|
||||||
virtual std::string get_http_api_auth_password();
|
virtual std::string get_http_api_auth_password();
|
||||||
// https api section
|
// https api section
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsConfDirective *get_https_api();
|
SrsConfDirective *get_https_api();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -1392,9 +1435,11 @@ public:
|
||||||
virtual std::string get_https_api_ssl_key();
|
virtual std::string get_https_api_ssl_key();
|
||||||
virtual std::string get_https_api_ssl_cert();
|
virtual std::string get_https_api_ssl_cert();
|
||||||
// http stream section
|
// http stream section
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Whether http stream enabled.
|
// Whether http stream enabled.
|
||||||
virtual bool get_http_stream_enabled(SrsConfDirective *conf);
|
virtual bool
|
||||||
|
get_http_stream_enabled(SrsConfDirective *conf);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Whether http stream enabled.
|
// Whether http stream enabled.
|
||||||
|
|
@ -1406,7 +1451,8 @@ public:
|
||||||
// Whether enable crossdomain for http static and stream server.
|
// Whether enable crossdomain for http static and stream server.
|
||||||
virtual bool get_http_stream_crossdomain();
|
virtual bool get_http_stream_crossdomain();
|
||||||
// https api section
|
// https api section
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsConfDirective *get_https_stream();
|
SrsConfDirective *get_https_stream();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -1416,7 +1462,8 @@ public:
|
||||||
virtual std::string get_https_stream_ssl_key();
|
virtual std::string get_https_stream_ssl_key();
|
||||||
virtual std::string get_https_stream_ssl_cert();
|
virtual std::string get_https_stream_ssl_cert();
|
||||||
// rtmps section
|
// rtmps section
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsConfDirective *get_rtmps();
|
SrsConfDirective *get_rtmps();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -1453,9 +1500,11 @@ public:
|
||||||
// used to generate the flv stream mount path.
|
// used to generate the flv stream mount path.
|
||||||
virtual std::string get_vhost_http_remux_mount(std::string vhost);
|
virtual std::string get_vhost_http_remux_mount(std::string vhost);
|
||||||
// http heartbeat section
|
// http heartbeat section
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Get the heartbeat directive.
|
// Get the heartbeat directive.
|
||||||
virtual SrsConfDirective *get_heartbeat();
|
virtual SrsConfDirective *
|
||||||
|
get_heartbeat();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Whether heartbeat enabled.
|
// Whether heartbeat enabled.
|
||||||
|
|
@ -1470,9 +1519,11 @@ public:
|
||||||
virtual bool get_heartbeat_summaries();
|
virtual bool get_heartbeat_summaries();
|
||||||
bool get_heartbeat_ports();
|
bool get_heartbeat_ports();
|
||||||
// stats section
|
// stats section
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Get the stats directive.
|
// Get the stats directive.
|
||||||
virtual SrsConfDirective *get_stats();
|
virtual SrsConfDirective *
|
||||||
|
get_stats();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Whether enabled stats.
|
// Whether enabled stats.
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,16 @@ class SrsLiveSource;
|
||||||
// For origin cluster.
|
// For origin cluster.
|
||||||
class SrsCoWorkers
|
class SrsCoWorkers
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
static SrsCoWorkers *instance_;
|
static SrsCoWorkers *instance_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::map<std::string, ISrsRequest *> streams_;
|
std::map<std::string, ISrsRequest *> streams_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsCoWorkers();
|
SrsCoWorkers();
|
||||||
virtual ~SrsCoWorkers();
|
virtual ~SrsCoWorkers();
|
||||||
|
|
||||||
|
|
@ -35,7 +38,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual SrsJsonAny *dumps(std::string vhost, std::string coworker, std::string app, std::string stream);
|
virtual SrsJsonAny *dumps(std::string vhost, std::string coworker, std::string app, std::string stream);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual ISrsRequest *find_stream_info(std::string vhost, std::string app, std::string stream);
|
virtual ISrsRequest *find_stream_info(std::string vhost, std::string app, std::string stream);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,8 @@ public:
|
||||||
// The init mp4 for FMP4.
|
// The init mp4 for FMP4.
|
||||||
class SrsInitMp4 : public ISrsInitMp4
|
class SrsInitMp4 : public ISrsInitMp4
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsFileWriter *fw_;
|
ISrsFileWriter *fw_;
|
||||||
ISrsMp4M2tsInitEncoder *init_;
|
ISrsMp4M2tsInitEncoder *init_;
|
||||||
ISrsFragment *fragment_;
|
ISrsFragment *fragment_;
|
||||||
|
|
@ -96,10 +97,12 @@ public:
|
||||||
// The FMP4(Fragmented MP4) for DASH streaming.
|
// The FMP4(Fragmented MP4) for DASH streaming.
|
||||||
class SrsFragmentedMp4 : public ISrsFragmentedMp4
|
class SrsFragmentedMp4 : public ISrsFragmentedMp4
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsFileWriter *fw_;
|
ISrsFileWriter *fw_;
|
||||||
ISrsMp4M2tsSegmentEncoder *enc_;
|
ISrsMp4M2tsSegmentEncoder *enc_;
|
||||||
ISrsFragment *fragment_;
|
ISrsFragment *fragment_;
|
||||||
|
|
@ -160,14 +163,17 @@ public:
|
||||||
// The writer to write MPD for DASH.
|
// The writer to write MPD for DASH.
|
||||||
class SrsMpdWriter : public ISrsMpdWriter
|
class SrsMpdWriter : public ISrsMpdWriter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The duration of fragment in srs_utime_t.
|
// The duration of fragment in srs_utime_t.
|
||||||
srs_utime_t fragment_;
|
srs_utime_t fragment_;
|
||||||
// The period to update the mpd in srs_utime_t.
|
// The period to update the mpd in srs_utime_t.
|
||||||
|
|
@ -187,7 +193,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// The number of current audio segment.
|
// The number of current audio segment.
|
||||||
uint64_t audio_number_;
|
uint64_t audio_number_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The home for fragment, relative to home.
|
// The home for fragment, relative to home.
|
||||||
std::string fragment_home_;
|
std::string fragment_home_;
|
||||||
|
|
||||||
|
|
@ -235,16 +242,19 @@ public:
|
||||||
// The controller for DASH, control the MPD and FMP4 generating system.
|
// The controller for DASH, control the MPD and FMP4 generating system.
|
||||||
class SrsDashController : public ISrsDashController
|
class SrsDashController : public ISrsDashController
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
SrsFormat *format_;
|
SrsFormat *format_;
|
||||||
ISrsMpdWriter *mpd_;
|
ISrsMpdWriter *mpd_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsFragmentedMp4 *vcurrent_;
|
ISrsFragmentedMp4 *vcurrent_;
|
||||||
ISrsFragmentWindow *vfragments_;
|
ISrsFragmentWindow *vfragments_;
|
||||||
ISrsFragmentedMp4 *acurrent_;
|
ISrsFragmentedMp4 *acurrent_;
|
||||||
|
|
@ -258,11 +268,13 @@ SRS_DECLARE_PRIVATE:
|
||||||
// Had the video reaped, use to align audio/video segment's timestamp.
|
// Had the video reaped, use to align audio/video segment's timestamp.
|
||||||
bool video_reaped_;
|
bool video_reaped_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The fragment duration in srs_utime_t to reap it.
|
// The fragment duration in srs_utime_t to reap it.
|
||||||
srs_utime_t fragment_;
|
srs_utime_t fragment_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string home_;
|
std::string home_;
|
||||||
int video_track_id_;
|
int video_track_id_;
|
||||||
int audio_track_id_;
|
int audio_track_id_;
|
||||||
|
|
@ -281,7 +293,8 @@ public:
|
||||||
virtual srs_error_t on_audio(SrsMediaPacket *shared_audio, SrsFormat *format);
|
virtual srs_error_t on_audio(SrsMediaPacket *shared_audio, SrsFormat *format);
|
||||||
virtual srs_error_t on_video(SrsMediaPacket *shared_video, SrsFormat *format);
|
virtual srs_error_t on_video(SrsMediaPacket *shared_video, SrsFormat *format);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t refresh_mpd(SrsFormat *format);
|
virtual srs_error_t refresh_mpd(SrsFormat *format);
|
||||||
virtual srs_error_t refresh_init_mp4(SrsMediaPacket *msg, SrsFormat *format);
|
virtual srs_error_t refresh_init_mp4(SrsMediaPacket *msg, SrsFormat *format);
|
||||||
};
|
};
|
||||||
|
|
@ -309,15 +322,18 @@ public:
|
||||||
// The MPEG-DASH encoder, transmux RTMP to DASH.
|
// The MPEG-DASH encoder, transmux RTMP to DASH.
|
||||||
class SrsDash : public ISrsDash
|
class SrsDash : public ISrsDash
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool enabled_;
|
bool enabled_;
|
||||||
bool disposable_;
|
bool disposable_;
|
||||||
srs_utime_t last_update_time_;
|
srs_utime_t last_update_time_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
ISrsOriginHub *hub_;
|
ISrsOriginHub *hub_;
|
||||||
ISrsDashController *controller_;
|
ISrsDashController *controller_;
|
||||||
|
|
|
||||||
|
|
@ -60,10 +60,12 @@ public:
|
||||||
// The segmenter for DVR, to write a segment file in flv/mp4.
|
// The segmenter for DVR, to write a segment file in flv/mp4.
|
||||||
class SrsDvrSegmenter : public ISrsReloadHandler, public ISrsDvrSegmenter
|
class SrsDvrSegmenter : public ISrsReloadHandler, public ISrsDvrSegmenter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
// The underlayer file object.
|
// The underlayer file object.
|
||||||
ISrsFileWriter *fs_;
|
ISrsFileWriter *fs_;
|
||||||
// Whether wait keyframe to reap segment.
|
// Whether wait keyframe to reap segment.
|
||||||
|
|
@ -71,11 +73,13 @@ SRS_DECLARE_PROTECTED:
|
||||||
// The FLV/MP4 fragment file.
|
// The FLV/MP4 fragment file.
|
||||||
SrsFragment *fragment_;
|
SrsFragment *fragment_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
ISrsDvrPlan *plan_;
|
ISrsDvrPlan *plan_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsRtmpJitter *jitter_;
|
SrsRtmpJitter *jitter_;
|
||||||
SrsRtmpJitterAlgorithm jitter_algorithm_;
|
SrsRtmpJitterAlgorithm jitter_algorithm_;
|
||||||
|
|
||||||
|
|
@ -109,16 +113,19 @@ public:
|
||||||
// @remark ignore when already closed.
|
// @remark ignore when already closed.
|
||||||
virtual srs_error_t close();
|
virtual srs_error_t close();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t open_encoder() = 0;
|
virtual srs_error_t open_encoder() = 0;
|
||||||
virtual srs_error_t encode_metadata(SrsMediaPacket *metadata) = 0;
|
virtual srs_error_t encode_metadata(SrsMediaPacket *metadata) = 0;
|
||||||
virtual srs_error_t encode_audio(SrsMediaPacket *audio, SrsFormat *format) = 0;
|
virtual srs_error_t encode_audio(SrsMediaPacket *audio, SrsFormat *format) = 0;
|
||||||
virtual srs_error_t encode_video(SrsMediaPacket *video, SrsFormat *format) = 0;
|
virtual srs_error_t encode_video(SrsMediaPacket *video, SrsFormat *format) = 0;
|
||||||
virtual srs_error_t close_encoder() = 0;
|
virtual srs_error_t close_encoder() = 0;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Generate the flv segment path.
|
// Generate the flv segment path.
|
||||||
virtual std::string generate_path();
|
virtual std::string
|
||||||
|
generate_path();
|
||||||
// When update the duration of segment by rtmp msg.
|
// When update the duration of segment by rtmp msg.
|
||||||
virtual srs_error_t on_update_duration(SrsMediaPacket *msg);
|
virtual srs_error_t on_update_duration(SrsMediaPacket *msg);
|
||||||
};
|
};
|
||||||
|
|
@ -126,14 +133,17 @@ SRS_DECLARE_PRIVATE:
|
||||||
// The FLV segmenter to use FLV encoder to write file.
|
// The FLV segmenter to use FLV encoder to write file.
|
||||||
class SrsDvrFlvSegmenter : public SrsDvrSegmenter
|
class SrsDvrFlvSegmenter : public SrsDvrSegmenter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The FLV encoder, for FLV target.
|
// The FLV encoder, for FLV target.
|
||||||
ISrsFlvTransmuxer *enc_;
|
ISrsFlvTransmuxer *enc_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The offset of file for duration value.
|
// The offset of file for duration value.
|
||||||
// The next 8 bytes is the double value.
|
// The next 8 bytes is the double value.
|
||||||
int64_t duration_offset_;
|
int64_t duration_offset_;
|
||||||
|
|
@ -150,7 +160,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t refresh_metadata();
|
virtual srs_error_t refresh_metadata();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t open_encoder();
|
virtual srs_error_t open_encoder();
|
||||||
virtual srs_error_t encode_metadata(SrsMediaPacket *metadata);
|
virtual srs_error_t encode_metadata(SrsMediaPacket *metadata);
|
||||||
virtual srs_error_t encode_audio(SrsMediaPacket *audio, SrsFormat *format);
|
virtual srs_error_t encode_audio(SrsMediaPacket *audio, SrsFormat *format);
|
||||||
|
|
@ -161,10 +172,12 @@ SRS_DECLARE_PROTECTED:
|
||||||
// The MP4 segmenter to use MP4 encoder to write file.
|
// The MP4 segmenter to use MP4 encoder to write file.
|
||||||
class SrsDvrMp4Segmenter : public SrsDvrSegmenter
|
class SrsDvrMp4Segmenter : public SrsDvrSegmenter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The MP4 encoder, for MP4 target.
|
// The MP4 encoder, for MP4 target.
|
||||||
ISrsMp4Encoder *enc_;
|
ISrsMp4Encoder *enc_;
|
||||||
|
|
||||||
|
|
@ -175,7 +188,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t refresh_metadata();
|
virtual srs_error_t refresh_metadata();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t open_encoder();
|
virtual srs_error_t open_encoder();
|
||||||
virtual srs_error_t encode_metadata(SrsMediaPacket *metadata);
|
virtual srs_error_t encode_metadata(SrsMediaPacket *metadata);
|
||||||
virtual srs_error_t encode_audio(SrsMediaPacket *audio, SrsFormat *format);
|
virtual srs_error_t encode_audio(SrsMediaPacket *audio, SrsFormat *format);
|
||||||
|
|
@ -186,11 +200,13 @@ SRS_DECLARE_PROTECTED:
|
||||||
// the dvr async call.
|
// the dvr async call.
|
||||||
class SrsDvrAsyncCallOnDvr : public ISrsAsyncCallTask
|
class SrsDvrAsyncCallOnDvr : public ISrsAsyncCallTask
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsHttpHooks *hooks_;
|
ISrsHttpHooks *hooks_;
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsContextId cid_;
|
SrsContextId cid_;
|
||||||
std::string path_;
|
std::string path_;
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
|
|
@ -224,14 +240,16 @@ public:
|
||||||
// The DVR plan, when and how to reap segment.
|
// The DVR plan, when and how to reap segment.
|
||||||
class SrsDvrPlan : public ISrsReloadHandler, public ISrsDvrPlan
|
class SrsDvrPlan : public ISrsReloadHandler, public ISrsDvrPlan
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
ISrsAsyncCallWorker *async_;
|
ISrsAsyncCallWorker *async_;
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
ISrsOriginHub *hub_;
|
ISrsOriginHub *hub_;
|
||||||
ISrsDvrSegmenter *segment_;
|
ISrsDvrSegmenter *segment_;
|
||||||
bool dvr_enabled_;
|
bool dvr_enabled_;
|
||||||
|
|
@ -271,7 +289,8 @@ public:
|
||||||
// The DVR segment plan: reap flv when duration exceed.
|
// The DVR segment plan: reap flv when duration exceed.
|
||||||
class SrsDvrSegmentPlan : public SrsDvrPlan
|
class SrsDvrSegmentPlan : public SrsDvrPlan
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// in config, in srs_utime_t
|
// in config, in srs_utime_t
|
||||||
srs_utime_t cduration_;
|
srs_utime_t cduration_;
|
||||||
bool wait_keyframe_;
|
bool wait_keyframe_;
|
||||||
|
|
@ -289,7 +308,8 @@ public:
|
||||||
virtual srs_error_t on_audio(SrsMediaPacket *shared_audio, SrsFormat *format);
|
virtual srs_error_t on_audio(SrsMediaPacket *shared_audio, SrsFormat *format);
|
||||||
virtual srs_error_t on_video(SrsMediaPacket *shared_video, SrsFormat *format);
|
virtual srs_error_t on_video(SrsMediaPacket *shared_video, SrsFormat *format);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t update_duration(SrsMediaPacket *msg);
|
virtual srs_error_t update_duration(SrsMediaPacket *msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -313,16 +333,19 @@ public:
|
||||||
// DVR(Digital Video Recorder) to record RTMP stream to flv/mp4 file.
|
// DVR(Digital Video Recorder) to record RTMP stream to flv/mp4 file.
|
||||||
class SrsDvr : public ISrsReloadHandler, public ISrsDvr
|
class SrsDvr : public ISrsReloadHandler, public ISrsDvr
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsOriginHub *hub_;
|
ISrsOriginHub *hub_;
|
||||||
ISrsDvrPlan *plan_;
|
ISrsDvrPlan *plan_;
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// whether the dvr is actived by filter, which is specified by dvr_apply.
|
// whether the dvr is actived by filter, which is specified by dvr_apply.
|
||||||
// we always initialize the dvr, which crote plan and segment object,
|
// we always initialize the dvr, which crote plan and segment object,
|
||||||
// but they never create actual piece of file util the apply active it.
|
// but they never create actual piece of file util the apply active it.
|
||||||
|
|
|
||||||
|
|
@ -87,17 +87,20 @@ public:
|
||||||
// The RTMP upstream of edge.
|
// The RTMP upstream of edge.
|
||||||
class SrsEdgeRtmpUpstream : public ISrsEdgeUpstream
|
class SrsEdgeRtmpUpstream : public ISrsEdgeUpstream
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// For RTMP 302, if not empty,
|
// For RTMP 302, if not empty,
|
||||||
// use this <ip[:port]> as upstream.
|
// use this <ip[:port]> as upstream.
|
||||||
std::string redirect_;
|
std::string redirect_;
|
||||||
ISrsBasicRtmpClient *sdk_;
|
ISrsBasicRtmpClient *sdk_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Current selected server, the ip:port.
|
// Current selected server, the ip:port.
|
||||||
std::string selected_ip_;
|
std::string selected_ip_;
|
||||||
int selected_port_;
|
int selected_port_;
|
||||||
|
|
@ -122,20 +125,24 @@ public:
|
||||||
// The HTTP FLV upstream of edge.
|
// The HTTP FLV upstream of edge.
|
||||||
class SrsEdgeFlvUpstream : public ISrsEdgeUpstream
|
class SrsEdgeFlvUpstream : public ISrsEdgeUpstream
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string schema_;
|
std::string schema_;
|
||||||
ISrsHttpClient *sdk_;
|
ISrsHttpClient *sdk_;
|
||||||
ISrsHttpMessage *hr_;
|
ISrsHttpMessage *hr_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsFileReader *reader_;
|
ISrsFileReader *reader_;
|
||||||
ISrsFlvDecoder *decoder_;
|
ISrsFlvDecoder *decoder_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// We might modify the request by HTTP redirect.
|
// We might modify the request by HTTP redirect.
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
// Current selected server, the ip:port.
|
// Current selected server, the ip:port.
|
||||||
|
|
@ -149,7 +156,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t connect(ISrsRequest *r, ISrsLbRoundRobin *lb);
|
virtual srs_error_t connect(ISrsRequest *r, ISrsLbRoundRobin *lb);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_connect(ISrsRequest *r, ISrsLbRoundRobin *lb, int redirect_depth);
|
virtual srs_error_t do_connect(ISrsRequest *r, ISrsLbRoundRobin *lb, int redirect_depth);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -182,14 +190,17 @@ public:
|
||||||
// The edge used to ingest stream from origin.
|
// The edge used to ingest stream from origin.
|
||||||
class SrsEdgeIngester : public ISrsCoroutineHandler, public ISrsEdgeIngester
|
class SrsEdgeIngester : public ISrsCoroutineHandler, public ISrsEdgeIngester
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Because source references to this object, so we should directly use the source ptr.
|
// Because source references to this object, so we should directly use the source ptr.
|
||||||
ISrsLiveSource *source_;
|
ISrsLiveSource *source_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsPlayEdge *edge_;
|
ISrsPlayEdge *edge_;
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
|
|
@ -209,10 +220,12 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_cycle();
|
virtual srs_error_t do_cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t ingest(std::string &redirect);
|
virtual srs_error_t ingest(std::string &redirect);
|
||||||
virtual srs_error_t process_publish_message(SrsRtmpCommonMessage *msg, std::string &redirect);
|
virtual srs_error_t process_publish_message(SrsRtmpCommonMessage *msg, std::string &redirect);
|
||||||
};
|
};
|
||||||
|
|
@ -240,14 +253,17 @@ public:
|
||||||
// The edge used to forward stream to origin.
|
// The edge used to forward stream to origin.
|
||||||
class SrsEdgeForwarder : public ISrsCoroutineHandler, public ISrsEdgeForwarder
|
class SrsEdgeForwarder : public ISrsCoroutineHandler, public ISrsEdgeForwarder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Because source references to this object, so we should directly use the source ptr.
|
// Because source references to this object, so we should directly use the source ptr.
|
||||||
ISrsLiveSource *source_;
|
ISrsLiveSource *source_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsPublishEdge *edge_;
|
ISrsPublishEdge *edge_;
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
|
|
@ -276,7 +292,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_cycle();
|
virtual srs_error_t do_cycle();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -298,7 +315,8 @@ public:
|
||||||
// The play edge control service.
|
// The play edge control service.
|
||||||
class SrsPlayEdge : public ISrsPlayEdge
|
class SrsPlayEdge : public ISrsPlayEdge
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsEdgeState state_;
|
SrsEdgeState state_;
|
||||||
ISrsEdgeIngester *ingester_;
|
ISrsEdgeIngester *ingester_;
|
||||||
|
|
||||||
|
|
@ -334,7 +352,8 @@ public:
|
||||||
// The publish edge control service.
|
// The publish edge control service.
|
||||||
class SrsPublishEdge : public ISrsPublishEdge
|
class SrsPublishEdge : public ISrsPublishEdge
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsEdgeState state_;
|
SrsEdgeState state_;
|
||||||
ISrsEdgeForwarder *forwarder_;
|
ISrsEdgeForwarder *forwarder_;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include <srs_app_config.hpp>
|
#include <srs_app_config.hpp>
|
||||||
|
#include <srs_app_factory.hpp>
|
||||||
#include <srs_app_ffmpeg.hpp>
|
#include <srs_app_ffmpeg.hpp>
|
||||||
#include <srs_app_utility.hpp>
|
#include <srs_app_utility.hpp>
|
||||||
#include <srs_kernel_error.hpp>
|
#include <srs_kernel_error.hpp>
|
||||||
|
|
@ -17,7 +18,6 @@ using namespace std;
|
||||||
#include <srs_kernel_pithy_print.hpp>
|
#include <srs_kernel_pithy_print.hpp>
|
||||||
#include <srs_kernel_utility.hpp>
|
#include <srs_kernel_utility.hpp>
|
||||||
#include <srs_protocol_rtmp_stack.hpp>
|
#include <srs_protocol_rtmp_stack.hpp>
|
||||||
#include <srs_app_factory.hpp>
|
|
||||||
|
|
||||||
// for encoder to detect the dead loop
|
// for encoder to detect the dead loop
|
||||||
static std::vector<std::string> _transcoded_url;
|
static std::vector<std::string> _transcoded_url;
|
||||||
|
|
|
||||||
|
|
@ -42,15 +42,18 @@ public:
|
||||||
// ffmpegs to transcode the specified stream.
|
// ffmpegs to transcode the specified stream.
|
||||||
class SrsEncoder : public ISrsCoroutineHandler, public ISrsMediaEncoder
|
class SrsEncoder : public ISrsCoroutineHandler, public ISrsMediaEncoder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string input_stream_name_;
|
std::string input_stream_name_;
|
||||||
std::vector<ISrsFFMPEG *> ffmpegs_;
|
std::vector<ISrsFFMPEG *> ffmpegs_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
ISrsPithyPrint *pprint_;
|
ISrsPithyPrint *pprint_;
|
||||||
|
|
||||||
|
|
@ -65,10 +68,12 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_cycle();
|
virtual srs_error_t do_cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual void clear_engines();
|
virtual void clear_engines();
|
||||||
virtual ISrsFFMPEG *at(int index);
|
virtual ISrsFFMPEG *at(int index);
|
||||||
virtual srs_error_t parse_scope_engines(ISrsRequest *req);
|
virtual srs_error_t parse_scope_engines(ISrsRequest *req);
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,8 @@ public:
|
||||||
// The factory to create app objects.
|
// The factory to create app objects.
|
||||||
class SrsAppFactory : public ISrsAppFactory
|
class SrsAppFactory : public ISrsAppFactory
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsKernelFactory *kernel_factory_;
|
ISrsKernelFactory *kernel_factory_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -51,17 +51,21 @@ public:
|
||||||
// A transcode engine: ffmepg, used to transcode a stream to another.
|
// A transcode engine: ffmepg, used to transcode a stream to another.
|
||||||
class SrsFFMPEG : public ISrsFFMPEG
|
class SrsFFMPEG : public ISrsFFMPEG
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsProcess *process_;
|
ISrsProcess *process_;
|
||||||
std::vector<std::string> params_;
|
std::vector<std::string> params_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string log_file_;
|
std::string log_file_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string ffmpeg_;
|
std::string ffmpeg_;
|
||||||
std::vector<std::string> iparams_;
|
std::vector<std::string> iparams_;
|
||||||
std::vector<std::string> perfile_;
|
std::vector<std::string> perfile_;
|
||||||
|
|
|
||||||
|
|
@ -45,19 +45,23 @@ public:
|
||||||
// Forward the stream to other servers.
|
// Forward the stream to other servers.
|
||||||
class SrsForwarder : public ISrsCoroutineHandler, public ISrsForwarder
|
class SrsForwarder : public ISrsCoroutineHandler, public ISrsForwarder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The ep to forward, server[:port].
|
// The ep to forward, server[:port].
|
||||||
std::string ep_forward_;
|
std::string ep_forward_;
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The source or stream context id to bind to.
|
// The source or stream context id to bind to.
|
||||||
SrsContextId source_cid_;
|
SrsContextId source_cid_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsOriginHub *hub_;
|
SrsOriginHub *hub_;
|
||||||
SrsSimpleRtmpClient *sdk_;
|
SrsSimpleRtmpClient *sdk_;
|
||||||
SrsRtmpJitter *jitter_;
|
SrsRtmpJitter *jitter_;
|
||||||
|
|
@ -90,10 +94,12 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_cycle();
|
virtual srs_error_t do_cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t forward();
|
virtual srs_error_t forward();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,8 @@ public:
|
||||||
// It's a media file, for example FLV or MP4, with duration.
|
// It's a media file, for example FLV or MP4, with duration.
|
||||||
class SrsFragment : public ISrsFragment
|
class SrsFragment : public ISrsFragment
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The duration in srs_utime_t.
|
// The duration in srs_utime_t.
|
||||||
srs_utime_t dur_;
|
srs_utime_t dur_;
|
||||||
// The full file path of fragment.
|
// The full file path of fragment.
|
||||||
|
|
@ -132,7 +133,8 @@ public:
|
||||||
// The fragment window manage a series of fragment.
|
// The fragment window manage a series of fragment.
|
||||||
class SrsFragmentWindow : public ISrsFragmentWindow
|
class SrsFragmentWindow : public ISrsFragmentWindow
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::vector<ISrsFragment *> fragments_;
|
std::vector<ISrsFragment *> fragments_;
|
||||||
// The expired fragments, need to be free in future.
|
// The expired fragments, need to be free in future.
|
||||||
std::vector<ISrsFragment *> expired_fragments_;
|
std::vector<ISrsFragment *> expired_fragments_;
|
||||||
|
|
|
||||||
|
|
@ -91,12 +91,14 @@ std::string srs_gb_state(SrsGbSessionState ostate, SrsGbSessionState state);
|
||||||
// {"port":9000, "is_tcp": true}
|
// {"port":9000, "is_tcp": true}
|
||||||
class SrsGoApiGbPublish : public ISrsHttpHandler
|
class SrsGoApiGbPublish : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsResourceManager *gb_manager_;
|
ISrsResourceManager *gb_manager_;
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsConfDirective *conf_;
|
SrsConfDirective *conf_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -106,7 +108,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsJsonObject *res);
|
virtual srs_error_t do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsJsonObject *res);
|
||||||
srs_error_t bind_session(std::string stream, uint64_t ssrc);
|
srs_error_t bind_session(std::string stream, uint64_t ssrc);
|
||||||
};
|
};
|
||||||
|
|
@ -139,26 +142,31 @@ public:
|
||||||
// media objects use directly pointer to session, while session use shared ptr.
|
// media objects use directly pointer to session, while session use shared ptr.
|
||||||
class SrsGbSession : public ISrsGbSession
|
class SrsGbSession : public ISrsGbSession
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsContextId cid_;
|
SrsContextId cid_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The shared resource which own this object, we should never free it because it's managed by shared ptr.
|
// The shared resource which own this object, we should never free it because it's managed by shared ptr.
|
||||||
SrsSharedResource<ISrsGbSession> *wrapper_;
|
SrsSharedResource<ISrsGbSession> *wrapper_;
|
||||||
// The owner coroutine, allow user to interrupt the loop.
|
// The owner coroutine, allow user to interrupt the loop.
|
||||||
ISrsInterruptable *owner_coroutine_;
|
ISrsInterruptable *owner_coroutine_;
|
||||||
ISrsContextIdSetter *owner_cid_;
|
ISrsContextIdSetter *owner_cid_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsGbSessionState state_;
|
SrsGbSessionState state_;
|
||||||
|
|
||||||
SrsSharedResource<ISrsGbMediaTcpConn> media_;
|
SrsSharedResource<ISrsGbMediaTcpConn> media_;
|
||||||
ISrsGbMuxer *muxer_;
|
ISrsGbMuxer *muxer_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// When wait for media connecting, timeout if exceed.
|
// When wait for media connecting, timeout if exceed.
|
||||||
srs_utime_t connecting_starttime_;
|
srs_utime_t connecting_starttime_;
|
||||||
// The time we enter reinviting state.
|
// The time we enter reinviting state.
|
||||||
|
|
@ -166,7 +174,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// The number of timeout, dispose session if exceed.
|
// The number of timeout, dispose session if exceed.
|
||||||
uint32_t nn_timeout_;
|
uint32_t nn_timeout_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsAlonePithyPrint *ppp_;
|
SrsAlonePithyPrint *ppp_;
|
||||||
srs_utime_t startime_;
|
srs_utime_t startime_;
|
||||||
uint64_t total_packs_;
|
uint64_t total_packs_;
|
||||||
|
|
@ -175,7 +184,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
uint64_t total_msgs_dropped_;
|
uint64_t total_msgs_dropped_;
|
||||||
uint64_t total_reserved_;
|
uint64_t total_reserved_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint32_t media_id_;
|
uint32_t media_id_;
|
||||||
srs_utime_t media_starttime_;
|
srs_utime_t media_starttime_;
|
||||||
uint64_t media_msgs_;
|
uint64_t media_msgs_;
|
||||||
|
|
@ -213,11 +223,13 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_cycle();
|
virtual srs_error_t do_cycle();
|
||||||
srs_error_t drive_state();
|
srs_error_t drive_state();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsGbSessionState set_state(SrsGbSessionState v);
|
SrsGbSessionState set_state(SrsGbSessionState v);
|
||||||
// Interface ISrsResource
|
// Interface ISrsResource
|
||||||
public:
|
public:
|
||||||
|
|
@ -238,13 +250,15 @@ public:
|
||||||
// The Media listener for GB.
|
// The Media listener for GB.
|
||||||
class SrsGbListener : public ISrsGbListener, public ISrsTcpHandler
|
class SrsGbListener : public ISrsGbListener, public ISrsTcpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsApiServerOwner *api_server_owner_;
|
ISrsApiServerOwner *api_server_owner_;
|
||||||
ISrsResourceManager *gb_manager_;
|
ISrsResourceManager *gb_manager_;
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsConfDirective *conf_;
|
SrsConfDirective *conf_;
|
||||||
ISrsIpListener *media_listener_;
|
ISrsIpListener *media_listener_;
|
||||||
|
|
||||||
|
|
@ -260,7 +274,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t on_tcp_client(ISrsListener *listener, srs_netfd_t stfd);
|
virtual srs_error_t on_tcp_client(ISrsListener *listener, srs_netfd_t stfd);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t listen_api();
|
srs_error_t listen_api();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -301,16 +316,19 @@ public:
|
||||||
class SrsGbMediaTcpConn : public ISrsGbMediaTcpConn, // It's a resource, coroutine handler, and executor handler.
|
class SrsGbMediaTcpConn : public ISrsGbMediaTcpConn, // It's a resource, coroutine handler, and executor handler.
|
||||||
public ISrsPsPackHandler
|
public ISrsPsPackHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsResourceManager *gb_manager_;
|
ISrsResourceManager *gb_manager_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool connected_;
|
bool connected_;
|
||||||
// The owner session object, note that we use the raw pointer and should never free it.
|
// The owner session object, note that we use the raw pointer and should never free it.
|
||||||
ISrsGbSession *session_;
|
ISrsGbSession *session_;
|
||||||
uint32_t nn_rtcp_;
|
uint32_t nn_rtcp_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The shared resource which own this object, we should never free it because it's managed by shared ptr.
|
// The shared resource which own this object, we should never free it because it's managed by shared ptr.
|
||||||
SrsSharedResource<ISrsGbMediaTcpConn> *wrapper_;
|
SrsSharedResource<ISrsGbMediaTcpConn> *wrapper_;
|
||||||
// The owner coroutine, allow user to interrupt the loop.
|
// The owner coroutine, allow user to interrupt the loop.
|
||||||
|
|
@ -318,7 +336,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
ISrsContextIdSetter *owner_cid_;
|
ISrsContextIdSetter *owner_cid_;
|
||||||
SrsContextId cid_;
|
SrsContextId cid_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsPackContext *pack_;
|
ISrsPackContext *pack_;
|
||||||
ISrsProtocolReadWriter *conn_;
|
ISrsProtocolReadWriter *conn_;
|
||||||
uint8_t *buffer_;
|
uint8_t *buffer_;
|
||||||
|
|
@ -351,15 +370,18 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_cycle();
|
virtual srs_error_t do_cycle();
|
||||||
// Interface ISrsPsPackHandler
|
// Interface ISrsPsPackHandler
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t on_ps_pack(SrsPsPacket *ps, const std::vector<SrsTsMessage *> &msgs);
|
virtual srs_error_t on_ps_pack(SrsPsPacket *ps, const std::vector<SrsTsMessage *> &msgs);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Create session if no one, or bind to an existed session.
|
// Create session if no one, or bind to an existed session.
|
||||||
srs_error_t bind_session(uint32_t ssrc, ISrsGbSession **psession);
|
srs_error_t
|
||||||
|
bind_session(uint32_t ssrc, ISrsGbSession **psession);
|
||||||
};
|
};
|
||||||
|
|
||||||
// The interface for mpegps queue.
|
// The interface for mpegps queue.
|
||||||
|
|
@ -379,9 +401,11 @@ public:
|
||||||
// we must recalc the timestamp.
|
// we must recalc the timestamp.
|
||||||
class SrsMpegpsQueue : public ISrsMpegpsQueue
|
class SrsMpegpsQueue : public ISrsMpegpsQueue
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The key: dts, value: msg.
|
// The key: dts, value: msg.
|
||||||
std::map<int64_t, SrsMediaPacket *> msgs_;
|
std::map<int64_t, SrsMediaPacket *>
|
||||||
|
msgs_;
|
||||||
int nb_audios_;
|
int nb_audios_;
|
||||||
int nb_videos_;
|
int nb_videos_;
|
||||||
|
|
||||||
|
|
@ -409,16 +433,19 @@ public:
|
||||||
// Mux GB28181 to RTMP.
|
// Mux GB28181 to RTMP.
|
||||||
class SrsGbMuxer : public ISrsGbMuxer
|
class SrsGbMuxer : public ISrsGbMuxer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The owner session object, note that we use the raw pointer and should never free it.
|
// The owner session object, note that we use the raw pointer and should never free it.
|
||||||
ISrsGbSession *session_;
|
ISrsGbSession *session_;
|
||||||
std::string output_;
|
std::string output_;
|
||||||
ISrsBasicRtmpClient *sdk_;
|
ISrsBasicRtmpClient *sdk_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRawH264Stream *avc_;
|
ISrsRawH264Stream *avc_;
|
||||||
std::string h264_sps_;
|
std::string h264_sps_;
|
||||||
bool h264_sps_changed_;
|
bool h264_sps_changed_;
|
||||||
|
|
@ -433,11 +460,13 @@ SRS_DECLARE_PRIVATE:
|
||||||
std::string h265_pps_;
|
std::string h265_pps_;
|
||||||
bool vps_sps_pps_sent_;
|
bool vps_sps_pps_sent_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRawAacStream *aac_;
|
ISrsRawAacStream *aac_;
|
||||||
std::string aac_specific_config_;
|
std::string aac_specific_config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsMpegpsQueue *queue_;
|
ISrsMpegpsQueue *queue_;
|
||||||
ISrsPithyPrint *pprint_;
|
ISrsPithyPrint *pprint_;
|
||||||
|
|
||||||
|
|
@ -449,7 +478,8 @@ public:
|
||||||
void setup(std::string output);
|
void setup(std::string output);
|
||||||
srs_error_t on_ts_message(SrsTsMessage *msg);
|
srs_error_t on_ts_message(SrsTsMessage *msg);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t on_ts_video(SrsTsMessage *msg, SrsBuffer *avs);
|
virtual srs_error_t on_ts_video(SrsTsMessage *msg, SrsBuffer *avs);
|
||||||
virtual srs_error_t mux_h264(SrsTsMessage *msg, SrsBuffer *avs);
|
virtual srs_error_t mux_h264(SrsTsMessage *msg, SrsBuffer *avs);
|
||||||
virtual srs_error_t write_h264_sps_pps(uint32_t dts, uint32_t pts);
|
virtual srs_error_t write_h264_sps_pps(uint32_t dts, uint32_t pts);
|
||||||
|
|
@ -461,9 +491,11 @@ SRS_DECLARE_PRIVATE:
|
||||||
virtual srs_error_t write_audio_raw_frame(char *frame, int frame_size, SrsRawAacStreamCodec *codec, uint32_t dts);
|
virtual srs_error_t write_audio_raw_frame(char *frame, int frame_size, SrsRawAacStreamCodec *codec, uint32_t dts);
|
||||||
virtual srs_error_t rtmp_write_packet(char type, uint32_t timestamp, char *data, int size);
|
virtual srs_error_t rtmp_write_packet(char type, uint32_t timestamp, char *data, int size);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Connect to RTMP server.
|
// Connect to RTMP server.
|
||||||
virtual srs_error_t connect();
|
virtual srs_error_t
|
||||||
|
connect();
|
||||||
// Close the connection to RTMP server.
|
// Close the connection to RTMP server.
|
||||||
virtual void close();
|
virtual void close();
|
||||||
};
|
};
|
||||||
|
|
@ -484,7 +516,8 @@ class SrsRecoverablePsContext : public ISrsRecoverablePsContext
|
||||||
public:
|
public:
|
||||||
ISrsPsContext *ctx_;
|
ISrsPsContext *ctx_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// If decoding error, enter the recover mode. Drop all left bytes util next pack header.
|
// If decoding error, enter the recover mode. Drop all left bytes util next pack header.
|
||||||
int recover_;
|
int recover_;
|
||||||
|
|
||||||
|
|
@ -497,9 +530,11 @@ public:
|
||||||
// parsed by previous decoding, we should move to the start of payload bytes.
|
// parsed by previous decoding, we should move to the start of payload bytes.
|
||||||
virtual srs_error_t decode_rtp(SrsBuffer *stream, int reserved, ISrsPsMessageHandler *handler);
|
virtual srs_error_t decode_rtp(SrsBuffer *stream, int reserved, ISrsPsMessageHandler *handler);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Decode the RTP payload as PS pack stream.
|
// Decode the RTP payload as PS pack stream.
|
||||||
virtual srs_error_t decode(SrsBuffer *stream, ISrsPsMessageHandler *handler);
|
virtual srs_error_t
|
||||||
|
decode(SrsBuffer *stream, ISrsPsMessageHandler *handler);
|
||||||
// When got error, drop data and enter recover mode.
|
// When got error, drop data and enter recover mode.
|
||||||
srs_error_t enter_recover_mode(SrsBuffer *stream, ISrsPsMessageHandler *handler, int pos, srs_error_t err);
|
srs_error_t enter_recover_mode(SrsBuffer *stream, ISrsPsMessageHandler *handler, int pos, srs_error_t err);
|
||||||
// Quit Recover mode when got pack header.
|
// Quit Recover mode when got pack header.
|
||||||
|
|
@ -530,7 +565,8 @@ public:
|
||||||
// PS pack stream.
|
// PS pack stream.
|
||||||
class SrsPackContext : public ISrsPackContext
|
class SrsPackContext : public ISrsPackContext
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// To process a pack of TS/PS messages.
|
// To process a pack of TS/PS messages.
|
||||||
ISrsPsPackHandler *handler_;
|
ISrsPsPackHandler *handler_;
|
||||||
// Note that it might be freed, so never use its fields.
|
// Note that it might be freed, so never use its fields.
|
||||||
|
|
|
||||||
|
|
@ -45,12 +45,14 @@ public:
|
||||||
srs_error_t on_video(SrsMediaPacket *msg);
|
srs_error_t on_video(SrsMediaPacket *msg);
|
||||||
srs_error_t on_audio(SrsMediaPacket *msg);
|
srs_error_t on_audio(SrsMediaPacket *msg);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t flush_mainfest();
|
srs_error_t flush_mainfest();
|
||||||
srs_error_t flush_bootstrap();
|
srs_error_t flush_bootstrap();
|
||||||
void adjust_windows();
|
void adjust_windows();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::list<SrsHdsFragment *> fragments_;
|
std::list<SrsHdsFragment *> fragments_;
|
||||||
SrsHdsFragment *currentSegment_;
|
SrsHdsFragment *currentSegment_;
|
||||||
int fragment_index_;
|
int fragment_index_;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual void heartbeat();
|
virtual void heartbeat();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_heartbeat();
|
virtual srs_error_t do_heartbeat();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,11 +73,13 @@ public:
|
||||||
|
|
||||||
class SrsInitMp4Segment : public SrsFragment
|
class SrsInitMp4Segment : public SrsFragment
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsFileWriter *fw_;
|
ISrsFileWriter *fw_;
|
||||||
SrsMp4M2tsInitEncoder init_;
|
SrsMp4M2tsInitEncoder init_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Key ID for encryption
|
// Key ID for encryption
|
||||||
unsigned char kid_[16];
|
unsigned char kid_[16];
|
||||||
// Constant IV for encryption
|
// Constant IV for encryption
|
||||||
|
|
@ -96,14 +98,16 @@ public:
|
||||||
virtual srs_error_t write_video_only(SrsFormat *format, int v_tid);
|
virtual srs_error_t write_video_only(SrsFormat *format, int v_tid);
|
||||||
virtual srs_error_t write_audio_only(SrsFormat *format, int a_tid);
|
virtual srs_error_t write_audio_only(SrsFormat *format, int a_tid);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t init_encoder();
|
virtual srs_error_t init_encoder();
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: merge this code with SrsFragmentedMp4 in dash
|
// TODO: merge this code with SrsFragmentedMp4 in dash
|
||||||
class SrsHlsM4sSegment : public SrsFragment
|
class SrsHlsM4sSegment : public SrsFragment
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsFileWriter *fw_;
|
ISrsFileWriter *fw_;
|
||||||
SrsFmp4SegmentEncoder enc_;
|
SrsFmp4SegmentEncoder enc_;
|
||||||
|
|
||||||
|
|
@ -130,11 +134,13 @@ public:
|
||||||
// The hls async call: on_hls
|
// The hls async call: on_hls
|
||||||
class SrsDvrAsyncCallOnHls : public ISrsAsyncCallTask
|
class SrsDvrAsyncCallOnHls : public ISrsAsyncCallTask
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsHttpHooks *hooks_;
|
ISrsHttpHooks *hooks_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsContextId cid_;
|
SrsContextId cid_;
|
||||||
std::string path_;
|
std::string path_;
|
||||||
std::string ts_url_;
|
std::string ts_url_;
|
||||||
|
|
@ -157,11 +163,13 @@ public:
|
||||||
// The hls async call: on_hls_notify
|
// The hls async call: on_hls_notify
|
||||||
class SrsDvrAsyncCallOnHlsNotify : public ISrsAsyncCallTask
|
class SrsDvrAsyncCallOnHlsNotify : public ISrsAsyncCallTask
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsHttpHooks *hooks_;
|
ISrsHttpHooks *hooks_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsContextId cid_;
|
SrsContextId cid_;
|
||||||
std::string ts_url_;
|
std::string ts_url_;
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
|
|
@ -184,14 +192,17 @@ public:
|
||||||
// TODO: Rename to SrsHlsTsMuxer, for TS file only.
|
// TODO: Rename to SrsHlsTsMuxer, for TS file only.
|
||||||
class SrsHlsMuxer
|
class SrsHlsMuxer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string hls_entry_prefix_;
|
std::string hls_entry_prefix_;
|
||||||
std::string hls_path_;
|
std::string hls_path_;
|
||||||
std::string hls_ts_file_;
|
std::string hls_ts_file_;
|
||||||
|
|
@ -204,7 +215,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
srs_utime_t hls_window_;
|
srs_utime_t hls_window_;
|
||||||
SrsAsyncCallWorker *async_;
|
SrsAsyncCallWorker *async_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Whether use floor algorithm for timestamp.
|
// Whether use floor algorithm for timestamp.
|
||||||
bool hls_ts_floor_;
|
bool hls_ts_floor_;
|
||||||
// The deviation in piece to adjust the fragment to be more
|
// The deviation in piece to adjust the fragment to be more
|
||||||
|
|
@ -215,7 +227,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
int64_t accept_floor_ts_;
|
int64_t accept_floor_ts_;
|
||||||
int64_t previous_floor_ts_;
|
int64_t previous_floor_ts_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Whether encrypted or not
|
// Whether encrypted or not
|
||||||
bool hls_keys_;
|
bool hls_keys_;
|
||||||
int hls_fragments_per_key_;
|
int hls_fragments_per_key_;
|
||||||
|
|
@ -231,13 +244,15 @@ SRS_DECLARE_PRIVATE:
|
||||||
// The underlayer file writer.
|
// The underlayer file writer.
|
||||||
ISrsFileWriter *writer_;
|
ISrsFileWriter *writer_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
int sequence_no_;
|
int sequence_no_;
|
||||||
srs_utime_t max_td_;
|
srs_utime_t max_td_;
|
||||||
std::string m3u8_;
|
std::string m3u8_;
|
||||||
std::string m3u8_url_;
|
std::string m3u8_url_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The available cached segments in m3u8.
|
// The available cached segments in m3u8.
|
||||||
SrsFragmentWindow *segments_;
|
SrsFragmentWindow *segments_;
|
||||||
// The current writing segment.
|
// The current writing segment.
|
||||||
|
|
@ -245,7 +260,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// The ts context, to keep cc continous between ts.
|
// The ts context, to keep cc continous between ts.
|
||||||
SrsTsContext *context_;
|
SrsTsContext *context_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Latest audio codec, parsed from stream.
|
// Latest audio codec, parsed from stream.
|
||||||
SrsAudioCodecId latest_acodec_;
|
SrsAudioCodecId latest_acodec_;
|
||||||
// Latest audio codec, parsed from stream.
|
// Latest audio codec, parsed from stream.
|
||||||
|
|
@ -306,7 +322,8 @@ public:
|
||||||
// Close segment(ts).
|
// Close segment(ts).
|
||||||
virtual srs_error_t segment_close();
|
virtual srs_error_t segment_close();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_segment_close();
|
virtual srs_error_t do_segment_close();
|
||||||
virtual srs_error_t write_hls_key();
|
virtual srs_error_t write_hls_key();
|
||||||
virtual srs_error_t refresh_m3u8();
|
virtual srs_error_t refresh_m3u8();
|
||||||
|
|
@ -318,7 +335,8 @@ public:
|
||||||
// HLS recover mode.
|
// HLS recover mode.
|
||||||
srs_error_t recover_hls();
|
srs_error_t recover_hls();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_recover_hls();
|
virtual srs_error_t do_recover_hls();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -327,14 +345,17 @@ SRS_DECLARE_PRIVATE:
|
||||||
// to flush video/audio, without any mechenisms.
|
// to flush video/audio, without any mechenisms.
|
||||||
class SrsHlsFmp4Muxer
|
class SrsHlsFmp4Muxer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string hls_entry_prefix_;
|
std::string hls_entry_prefix_;
|
||||||
std::string hls_path_;
|
std::string hls_path_;
|
||||||
std::string hls_m4s_file_;
|
std::string hls_m4s_file_;
|
||||||
|
|
@ -347,7 +368,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
srs_utime_t hls_window_;
|
srs_utime_t hls_window_;
|
||||||
SrsAsyncCallWorker *async_;
|
SrsAsyncCallWorker *async_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Whether use floor algorithm for timestamp.
|
// Whether use floor algorithm for timestamp.
|
||||||
bool hls_ts_floor_;
|
bool hls_ts_floor_;
|
||||||
// The deviation in piece to adjust the fragment to be more
|
// The deviation in piece to adjust the fragment to be more
|
||||||
|
|
@ -359,7 +381,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
int64_t previous_floor_ts_;
|
int64_t previous_floor_ts_;
|
||||||
bool init_mp4_ready_;
|
bool init_mp4_ready_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Whether encrypted or not
|
// Whether encrypted or not
|
||||||
// TODO: fmp4 encryption is not yet implemented.
|
// TODO: fmp4 encryption is not yet implemented.
|
||||||
// fmp4 support four kinds of protection scheme: 'cenc', 'cbc1', 'cens', 'cbcs'.
|
// fmp4 support four kinds of protection scheme: 'cenc', 'cbc1', 'cens', 'cbcs'.
|
||||||
|
|
@ -385,7 +408,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// The underlayer file writer.
|
// The underlayer file writer.
|
||||||
ISrsFileWriter *writer_;
|
ISrsFileWriter *writer_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
int sequence_no_;
|
int sequence_no_;
|
||||||
srs_utime_t max_td_;
|
srs_utime_t max_td_;
|
||||||
std::string m3u8_;
|
std::string m3u8_;
|
||||||
|
|
@ -395,13 +419,15 @@ SRS_DECLARE_PRIVATE:
|
||||||
int audio_track_id_;
|
int audio_track_id_;
|
||||||
uint64_t video_dts_;
|
uint64_t video_dts_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The available cached segments in m3u8.
|
// The available cached segments in m3u8.
|
||||||
SrsFragmentWindow *segments_;
|
SrsFragmentWindow *segments_;
|
||||||
// The current writing segment.
|
// The current writing segment.
|
||||||
SrsHlsM4sSegment *current_;
|
SrsHlsM4sSegment *current_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Latest audio codec, parsed from stream.
|
// Latest audio codec, parsed from stream.
|
||||||
SrsAudioCodecId latest_acodec_;
|
SrsAudioCodecId latest_acodec_;
|
||||||
// Latest audio codec, parsed from stream.
|
// Latest audio codec, parsed from stream.
|
||||||
|
|
@ -461,7 +487,8 @@ public:
|
||||||
// Close segment(ts).
|
// Close segment(ts).
|
||||||
virtual srs_error_t segment_close();
|
virtual srs_error_t segment_close();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_segment_close();
|
virtual srs_error_t do_segment_close();
|
||||||
virtual srs_error_t write_hls_key();
|
virtual srs_error_t write_hls_key();
|
||||||
virtual srs_error_t refresh_m3u8();
|
virtual srs_error_t refresh_m3u8();
|
||||||
|
|
@ -513,10 +540,12 @@ public:
|
||||||
// TODO: Rename to SrsHlsTsController, for TS file only.
|
// TODO: Rename to SrsHlsTsController, for TS file only.
|
||||||
class SrsHlsController : public ISrsHlsController
|
class SrsHlsController : public ISrsHlsController
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The HLS muxer to reap ts and m3u8.
|
// The HLS muxer to reap ts and m3u8.
|
||||||
// The TS is cached to SrsTsMessageCache then flush to ts segment.
|
// The TS is cached to SrsTsMessageCache then flush to ts segment.
|
||||||
SrsHlsMuxer *muxer_;
|
SrsHlsMuxer *muxer_;
|
||||||
|
|
@ -557,39 +586,47 @@ public:
|
||||||
// write video to muxer.
|
// write video to muxer.
|
||||||
virtual srs_error_t write_video(SrsMediaPacket *shared_video, SrsFormat *format);
|
virtual srs_error_t write_video(SrsMediaPacket *shared_video, SrsFormat *format);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Reopen the muxer for a new hls segment,
|
// Reopen the muxer for a new hls segment,
|
||||||
// close current segment, open a new segment,
|
// close current segment, open a new segment,
|
||||||
// then write the key frame to the new segment.
|
// then write the key frame to the new segment.
|
||||||
// so, user must reap_segment then flush_video to hls muxer.
|
// so, user must reap_segment then flush_video to hls muxer.
|
||||||
virtual srs_error_t reap_segment();
|
virtual srs_error_t
|
||||||
|
reap_segment();
|
||||||
};
|
};
|
||||||
|
|
||||||
// HLS controller for fMP4 (.m4s) segments with init.mp4.
|
// HLS controller for fMP4 (.m4s) segments with init.mp4.
|
||||||
// Direct sample processing without caching, simpler than TS controller.
|
// Direct sample processing without caching, simpler than TS controller.
|
||||||
class SrsHlsMp4Controller : public ISrsHlsController
|
class SrsHlsMp4Controller : public ISrsHlsController
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool has_video_sh_;
|
bool has_video_sh_;
|
||||||
bool has_audio_sh_;
|
bool has_audio_sh_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
int video_track_id_;
|
int video_track_id_;
|
||||||
int audio_track_id_;
|
int audio_track_id_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Current audio dts.
|
// Current audio dts.
|
||||||
uint64_t audio_dts_;
|
uint64_t audio_dts_;
|
||||||
// Current video dts.
|
// Current video dts.
|
||||||
uint64_t video_dts_;
|
uint64_t video_dts_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsHlsFmp4Muxer *muxer_;
|
SrsHlsFmp4Muxer *muxer_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -637,13 +674,16 @@ public:
|
||||||
// TODO: FIXME: add utest for hls.
|
// TODO: FIXME: add utest for hls.
|
||||||
class SrsHls : public ISrsHls
|
class SrsHls : public ISrsHls
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsHlsController *controller_;
|
ISrsHlsController *controller_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
// Whether the HLS is enabled.
|
// Whether the HLS is enabled.
|
||||||
bool enabled_;
|
bool enabled_;
|
||||||
|
|
@ -657,7 +697,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// To detect heartbeat and dispose it if configured.
|
// To detect heartbeat and dispose it if configured.
|
||||||
srs_utime_t last_update_time_;
|
srs_utime_t last_update_time_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsOriginHub *hub_;
|
SrsOriginHub *hub_;
|
||||||
SrsRtmpJitter *jitter_;
|
SrsRtmpJitter *jitter_;
|
||||||
SrsPithyPrint *pprint_;
|
SrsPithyPrint *pprint_;
|
||||||
|
|
@ -669,7 +710,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual void async_reload();
|
virtual void async_reload();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t reload();
|
srs_error_t reload();
|
||||||
srs_error_t do_reload(int *reloading, int *reloaded, int *refreshed);
|
srs_error_t do_reload(int *reloading, int *reloaded, int *refreshed);
|
||||||
|
|
||||||
|
|
@ -697,7 +739,8 @@ public:
|
||||||
// TODO: FIXME: Remove param is_sps_pps.
|
// TODO: FIXME: Remove param is_sps_pps.
|
||||||
virtual srs_error_t on_video(SrsMediaPacket *shared_video, SrsFormat *format);
|
virtual srs_error_t on_video(SrsMediaPacket *shared_video, SrsFormat *format);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual void hls_show_mux_log();
|
virtual void hls_show_mux_log();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,8 @@ extern srs_error_t srs_api_response_code(ISrsHttpResponseWriter *w, ISrsHttpMess
|
||||||
// For http root.
|
// For http root.
|
||||||
class SrsGoApiRoot : public ISrsHttpHandler
|
class SrsGoApiRoot : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -51,7 +52,8 @@ public:
|
||||||
|
|
||||||
class SrsGoApiApi : public ISrsHttpHandler
|
class SrsGoApiApi : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -64,7 +66,8 @@ public:
|
||||||
|
|
||||||
class SrsGoApiV1 : public ISrsHttpHandler
|
class SrsGoApiV1 : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -77,7 +80,8 @@ public:
|
||||||
|
|
||||||
class SrsGoApiVersion : public ISrsHttpHandler
|
class SrsGoApiVersion : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -90,7 +94,8 @@ public:
|
||||||
|
|
||||||
class SrsGoApiSummaries : public ISrsHttpHandler
|
class SrsGoApiSummaries : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -103,7 +108,8 @@ public:
|
||||||
|
|
||||||
class SrsGoApiRusages : public ISrsHttpHandler
|
class SrsGoApiRusages : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -116,7 +122,8 @@ public:
|
||||||
|
|
||||||
class SrsGoApiSelfProcStats : public ISrsHttpHandler
|
class SrsGoApiSelfProcStats : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -129,7 +136,8 @@ public:
|
||||||
|
|
||||||
class SrsGoApiSystemProcStats : public ISrsHttpHandler
|
class SrsGoApiSystemProcStats : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -142,7 +150,8 @@ public:
|
||||||
|
|
||||||
class SrsGoApiMemInfos : public ISrsHttpHandler
|
class SrsGoApiMemInfos : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -155,7 +164,8 @@ public:
|
||||||
|
|
||||||
class SrsGoApiAuthors : public ISrsHttpHandler
|
class SrsGoApiAuthors : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -168,7 +178,8 @@ public:
|
||||||
|
|
||||||
class SrsGoApiFeatures : public ISrsHttpHandler
|
class SrsGoApiFeatures : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -181,7 +192,8 @@ public:
|
||||||
|
|
||||||
class SrsGoApiRequests : public ISrsHttpHandler
|
class SrsGoApiRequests : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -194,7 +206,8 @@ public:
|
||||||
|
|
||||||
class SrsGoApiVhosts : public ISrsHttpHandler
|
class SrsGoApiVhosts : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -207,7 +220,8 @@ public:
|
||||||
|
|
||||||
class SrsGoApiStreams : public ISrsHttpHandler
|
class SrsGoApiStreams : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -220,7 +234,8 @@ public:
|
||||||
|
|
||||||
class SrsGoApiClients : public ISrsHttpHandler
|
class SrsGoApiClients : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -233,14 +248,17 @@ public:
|
||||||
|
|
||||||
class SrsGoApiRaw : public ISrsHttpHandler, public ISrsReloadHandler
|
class SrsGoApiRaw : public ISrsHttpHandler, public ISrsReloadHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsSignalHandler *handler_;
|
ISrsSignalHandler *handler_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool raw_api_;
|
bool raw_api_;
|
||||||
bool allow_reload_;
|
bool allow_reload_;
|
||||||
bool allow_query_;
|
bool allow_query_;
|
||||||
|
|
@ -257,7 +275,8 @@ public:
|
||||||
|
|
||||||
class SrsGoApiClusters : public ISrsHttpHandler
|
class SrsGoApiClusters : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -270,7 +289,8 @@ public:
|
||||||
|
|
||||||
class SrsGoApiError : public ISrsHttpHandler
|
class SrsGoApiError : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -284,7 +304,8 @@ public:
|
||||||
#ifdef SRS_GPERF
|
#ifdef SRS_GPERF
|
||||||
class SrsGoApiTcmalloc : public ISrsHttpHandler
|
class SrsGoApiTcmalloc : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -299,10 +320,12 @@ public:
|
||||||
#ifdef SRS_VALGRIND
|
#ifdef SRS_VALGRIND
|
||||||
class SrsGoApiValgrind : public ISrsHttpHandler, public ISrsCoroutineHandler
|
class SrsGoApiValgrind : public ISrsHttpHandler, public ISrsCoroutineHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
std::string task_;
|
std::string task_;
|
||||||
|
|
||||||
|
|
@ -321,7 +344,8 @@ public:
|
||||||
#ifdef SRS_SIGNAL_API
|
#ifdef SRS_SIGNAL_API
|
||||||
class SrsGoApiSignal : public ISrsHttpHandler
|
class SrsGoApiSignal : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -335,11 +359,13 @@ public:
|
||||||
|
|
||||||
class SrsGoApiMetrics : public ISrsHttpHandler
|
class SrsGoApiMetrics : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool enabled_;
|
bool enabled_;
|
||||||
std::string label_;
|
std::string label_;
|
||||||
std::string tag_;
|
std::string tag_;
|
||||||
|
|
|
||||||
|
|
@ -95,17 +95,20 @@ public:
|
||||||
// The http connection which request the static or stream content.
|
// The http connection which request the static or stream content.
|
||||||
class SrsHttpConn : public ISrsHttpConn
|
class SrsHttpConn : public ISrsHttpConn
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
ISrsHttpParser *parser_;
|
ISrsHttpParser *parser_;
|
||||||
ISrsCommonHttpHandler *http_mux_;
|
ISrsCommonHttpHandler *http_mux_;
|
||||||
ISrsHttpCorsMux *cors_;
|
ISrsHttpCorsMux *cors_;
|
||||||
ISrsHttpAuthMux *auth_;
|
ISrsHttpAuthMux *auth_;
|
||||||
ISrsHttpConnOwner *handler_;
|
ISrsHttpConnOwner *handler_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
ISrsProtocolReadWriter *skt_;
|
ISrsProtocolReadWriter *skt_;
|
||||||
// Each connection start a green thread,
|
// Each connection start a green thread,
|
||||||
// when thread stop, the connection will be delete by server.
|
// when thread stop, the connection will be delete by server.
|
||||||
|
|
@ -114,7 +117,8 @@ SRS_DECLARE_PROTECTED:
|
||||||
std::string ip_;
|
std::string ip_;
|
||||||
int port_;
|
int port_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The delta for statistic.
|
// The delta for statistic.
|
||||||
ISrsNetworkDelta *delta_;
|
ISrsNetworkDelta *delta_;
|
||||||
// The create time in microseconds.
|
// The create time in microseconds.
|
||||||
|
|
@ -137,7 +141,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_cycle();
|
virtual srs_error_t do_cycle();
|
||||||
virtual srs_error_t process_requests(ISrsRequest **preq);
|
virtual srs_error_t process_requests(ISrsRequest **preq);
|
||||||
virtual srs_error_t process_request(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, int rid);
|
virtual srs_error_t process_request(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, int rid);
|
||||||
|
|
@ -179,11 +184,13 @@ public:
|
||||||
// Drop body of request, only process the response.
|
// Drop body of request, only process the response.
|
||||||
class SrsHttpxConn : public ISrsHttpxConn
|
class SrsHttpxConn : public ISrsHttpxConn
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The manager object to manage the connection.
|
// The manager object to manage the connection.
|
||||||
ISrsResourceManager *manager_;
|
ISrsResourceManager *manager_;
|
||||||
ISrsProtocolReadWriter *io_;
|
ISrsProtocolReadWriter *io_;
|
||||||
|
|
@ -242,7 +249,8 @@ public:
|
||||||
// The http server, use http stream or static server to serve requests.
|
// The http server, use http stream or static server to serve requests.
|
||||||
class SrsHttpServer : public ISrsHttpServer
|
class SrsHttpServer : public ISrsHttpServer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsHttpStaticServer *http_static_;
|
ISrsHttpStaticServer *http_static_;
|
||||||
ISrsHttpStreamServer *http_stream_;
|
ISrsHttpStreamServer *http_stream_;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,8 @@ public:
|
||||||
|
|
||||||
class SrsHttpHooks : public ISrsHttpHooks
|
class SrsHttpHooks : public ISrsHttpHooks
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppFactory *factory_;
|
ISrsAppFactory *factory_;
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
@ -176,7 +177,8 @@ public:
|
||||||
srs_error_t discover_co_workers(std::string url, std::string &host, int &port);
|
srs_error_t discover_co_workers(std::string url, std::string &host, int &port);
|
||||||
srs_error_t on_forward_backend(std::string url, ISrsRequest *req, std::vector<std::string> &rtmp_urls);
|
srs_error_t on_forward_backend(std::string url, ISrsRequest *req, std::vector<std::string> &rtmp_urls);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t do_post(ISrsHttpClient *hc, std::string url, std::string req, int &code, std::string &res);
|
srs_error_t do_post(ISrsHttpClient *hc, std::string url, std::string req, int &code, std::string &res);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,11 @@ public:
|
||||||
// Server HLS streaming.
|
// Server HLS streaming.
|
||||||
class SrsHlsStream : public ISrsFastTimerHandler
|
class SrsHlsStream : public ISrsFastTimerHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The period of validity of the ctx
|
// The period of validity of the ctx
|
||||||
std::map<std::string, SrsHlsVirtualConn *> map_ctx_info_;
|
std::map<std::string, SrsHlsVirtualConn *>
|
||||||
|
map_ctx_info_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SrsHlsStream();
|
SrsHlsStream();
|
||||||
|
|
@ -47,7 +49,8 @@ public:
|
||||||
virtual srs_error_t serve_m3u8_ctx(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, ISrsFileReaderFactory *factory, std::string fullpath, ISrsRequest *req, bool *served);
|
virtual srs_error_t serve_m3u8_ctx(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, ISrsFileReaderFactory *factory, std::string fullpath, ISrsRequest *req, bool *served);
|
||||||
virtual void on_serve_ts_ctx(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
virtual void on_serve_ts_ctx(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t serve_new_session(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, ISrsRequest *req, std::string &ctx);
|
srs_error_t serve_new_session(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, ISrsRequest *req, std::string &ctx);
|
||||||
srs_error_t serve_exists_session(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, ISrsFileReaderFactory *factory, std::string fullpath);
|
srs_error_t serve_exists_session(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, ISrsFileReaderFactory *factory, std::string fullpath);
|
||||||
bool ctx_is_exist(std::string ctx);
|
bool ctx_is_exist(std::string ctx);
|
||||||
|
|
@ -56,29 +59,34 @@ SRS_DECLARE_PRIVATE:
|
||||||
void http_hooks_on_stop(ISrsRequest *req);
|
void http_hooks_on_stop(ISrsRequest *req);
|
||||||
bool is_interrupt(std::string id);
|
bool is_interrupt(std::string id);
|
||||||
// interface ISrsFastTimerHandler
|
// interface ISrsFastTimerHandler
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t on_timer(srs_utime_t interval);
|
srs_error_t on_timer(srs_utime_t interval);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsSecurity *security_;
|
SrsSecurity *security_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The Vod streaming, like FLV, MP4 or HLS streaming.
|
// The Vod streaming, like FLV, MP4 or HLS streaming.
|
||||||
class SrsVodStream : public SrsHttpFileServer
|
class SrsVodStream : public SrsHttpFileServer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsHlsStream hls_;
|
SrsHlsStream hls_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SrsVodStream(std::string root_dir);
|
SrsVodStream(std::string root_dir);
|
||||||
virtual ~SrsVodStream();
|
virtual ~SrsVodStream();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
// The flv vod stream supports flv?start=offset-bytes.
|
// The flv vod stream supports flv?start=offset-bytes.
|
||||||
// For example, http://server/file.flv?start=10240
|
// For example, http://server/file.flv?start=10240
|
||||||
// server will write flv header and sequence header,
|
// server will write flv header and sequence header,
|
||||||
// then seek(10240) and response flv tag data.
|
// then seek(10240) and response flv tag data.
|
||||||
virtual srs_error_t serve_flv_stream(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, std::string fullpath, int64_t offset);
|
virtual srs_error_t
|
||||||
|
serve_flv_stream(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, std::string fullpath, int64_t offset);
|
||||||
// Support mp4 with start and offset in query string.
|
// Support mp4 with start and offset in query string.
|
||||||
virtual srs_error_t serve_mp4_stream(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, std::string fullpath, int64_t start, int64_t end);
|
virtual srs_error_t serve_mp4_stream(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, std::string fullpath, int64_t start, int64_t end);
|
||||||
// Support HLS streaming with pseudo session id.
|
// Support HLS streaming with pseudo session id.
|
||||||
|
|
@ -103,7 +111,8 @@ public:
|
||||||
// serve http static file and flv/mp4 vod stream.
|
// serve http static file and flv/mp4 vod stream.
|
||||||
class SrsHttpStaticServer : public ISrsHttpStaticServer
|
class SrsHttpStaticServer : public ISrsHttpStaticServer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsHttpServeMux *mux_;
|
ISrsHttpServeMux *mux_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -118,7 +127,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t mount_vhost(std::string vhost, std::string &pmount);
|
virtual srs_error_t mount_vhost(std::string vhost, std::string &pmount);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,14 +51,17 @@ public:
|
||||||
// A cache for HTTP Live Streaming encoder, to make android(weixin) happy.
|
// A cache for HTTP Live Streaming encoder, to make android(weixin) happy.
|
||||||
class SrsBufferCache : public ISrsCoroutineHandler, public ISrsBufferCache
|
class SrsBufferCache : public ISrsCoroutineHandler, public ISrsBufferCache
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsLiveSourceManager *live_sources_;
|
ISrsLiveSourceManager *live_sources_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_utime_t fast_cache_;
|
srs_utime_t fast_cache_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsMessageQueue *queue_;
|
ISrsMessageQueue *queue_;
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
|
|
@ -107,7 +110,8 @@ public:
|
||||||
// Transmux RTMP to HTTP Live Streaming.
|
// Transmux RTMP to HTTP Live Streaming.
|
||||||
class SrsFlvStreamEncoder : public ISrsBufferEncoder
|
class SrsFlvStreamEncoder : public ISrsBufferEncoder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsFlvTransmuxer *enc_;
|
ISrsFlvTransmuxer *enc_;
|
||||||
bool header_written_;
|
bool header_written_;
|
||||||
bool has_audio_;
|
bool has_audio_;
|
||||||
|
|
@ -138,14 +142,16 @@ public:
|
||||||
// Write the tags in a time.
|
// Write the tags in a time.
|
||||||
virtual srs_error_t write_tags(SrsMediaPacket **msgs, int count);
|
virtual srs_error_t write_tags(SrsMediaPacket **msgs, int count);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t write_header(bool has_video, bool has_audio);
|
virtual srs_error_t write_header(bool has_video, bool has_audio);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Transmux RTMP to HTTP TS Streaming.
|
// Transmux RTMP to HTTP TS Streaming.
|
||||||
class SrsTsStreamEncoder : public ISrsBufferEncoder
|
class SrsTsStreamEncoder : public ISrsBufferEncoder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsTsTransmuxer *enc_;
|
ISrsTsTransmuxer *enc_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -171,7 +177,8 @@ public:
|
||||||
// Transmux RTMP with AAC stream to HTTP AAC Streaming.
|
// Transmux RTMP with AAC stream to HTTP AAC Streaming.
|
||||||
class SrsAacStreamEncoder : public ISrsBufferEncoder
|
class SrsAacStreamEncoder : public ISrsBufferEncoder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAacTransmuxer *enc_;
|
ISrsAacTransmuxer *enc_;
|
||||||
ISrsBufferCache *cache_;
|
ISrsBufferCache *cache_;
|
||||||
|
|
||||||
|
|
@ -193,7 +200,8 @@ public:
|
||||||
// Transmux RTMP with MP3 stream to HTTP MP3 Streaming.
|
// Transmux RTMP with MP3 stream to HTTP MP3 Streaming.
|
||||||
class SrsMp3StreamEncoder : public ISrsBufferEncoder
|
class SrsMp3StreamEncoder : public ISrsBufferEncoder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsMp3Transmuxer *enc_;
|
ISrsMp3Transmuxer *enc_;
|
||||||
ISrsBufferCache *cache_;
|
ISrsBufferCache *cache_;
|
||||||
|
|
||||||
|
|
@ -215,7 +223,8 @@ public:
|
||||||
// Write stream to http response direclty.
|
// Write stream to http response direclty.
|
||||||
class SrsBufferWriter : public SrsFileWriter
|
class SrsBufferWriter : public SrsFileWriter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsHttpResponseWriter *writer_;
|
ISrsHttpResponseWriter *writer_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -251,13 +260,15 @@ public:
|
||||||
// TODO: FIXME: Rename to SrsHttpLive
|
// TODO: FIXME: Rename to SrsHttpLive
|
||||||
class SrsLiveStream : public ISrsLiveStream
|
class SrsLiveStream : public ISrsLiveStream
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsLiveSourceManager *live_sources_;
|
ISrsLiveSourceManager *live_sources_;
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
ISrsHttpHooks *hooks_;
|
ISrsHttpHooks *hooks_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
ISrsBufferCache *cache_;
|
ISrsBufferCache *cache_;
|
||||||
ISrsSecurity *security_;
|
ISrsSecurity *security_;
|
||||||
|
|
@ -274,7 +285,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t serve_http_impl(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
srs_error_t serve_http_impl(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -283,7 +295,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual void expire();
|
virtual void expire();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_serve_http(SrsLiveSource *source, ISrsLiveConsumer *consumer, ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
virtual srs_error_t do_serve_http(SrsLiveSource *source, ISrsLiveConsumer *consumer, ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
||||||
virtual srs_error_t http_hooks_on_play(ISrsHttpMessage *r);
|
virtual srs_error_t http_hooks_on_play(ISrsHttpMessage *r);
|
||||||
virtual void http_hooks_on_stop(ISrsHttpMessage *r);
|
virtual void http_hooks_on_stop(ISrsHttpMessage *r);
|
||||||
|
|
@ -292,7 +305,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
|
|
||||||
// The Live Entry, to handle HTTP Live Streaming.
|
// The Live Entry, to handle HTTP Live Streaming.
|
||||||
struct SrsLiveEntry {
|
struct SrsLiveEntry {
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool is_flv_;
|
bool is_flv_;
|
||||||
bool is_ts_;
|
bool is_ts_;
|
||||||
bool is_aac_;
|
bool is_aac_;
|
||||||
|
|
@ -342,11 +356,13 @@ public:
|
||||||
// TODO: Support multiple stream.
|
// TODO: Support multiple stream.
|
||||||
class SrsHttpStreamServer : public ISrsHttpStreamServer
|
class SrsHttpStreamServer : public ISrsHttpStreamServer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsHttpServeMux *mux_;
|
ISrsHttpServeMux *mux_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAsyncCallWorker *async_;
|
ISrsAsyncCallWorker *async_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -373,14 +389,16 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t dynamic_match(ISrsHttpMessage *request, ISrsHttpHandler **ph);
|
virtual srs_error_t dynamic_match(ISrsHttpMessage *request, ISrsHttpHandler **ph);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t initialize_flv_streaming();
|
virtual srs_error_t initialize_flv_streaming();
|
||||||
virtual srs_error_t initialize_flv_entry(std::string vhost);
|
virtual srs_error_t initialize_flv_entry(std::string vhost);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsHttpStreamDestroy : public ISrsAsyncCallTask
|
class SrsHttpStreamDestroy : public ISrsAsyncCallTask
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string sid_;
|
std::string sid_;
|
||||||
std::map<std::string, SrsLiveEntry *> *streamHandlers_;
|
std::map<std::string, SrsLiveEntry *> *streamHandlers_;
|
||||||
ISrsHttpServeMux *mux_;
|
ISrsHttpServeMux *mux_;
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,8 @@ public:
|
||||||
// Ingester ffmpeg object.
|
// Ingester ffmpeg object.
|
||||||
class SrsIngesterFFMPEG : public ISrsIngesterFFMPEG
|
class SrsIngesterFFMPEG : public ISrsIngesterFFMPEG
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string vhost_;
|
std::string vhost_;
|
||||||
std::string id_;
|
std::string id_;
|
||||||
ISrsFFMPEG *ffmpeg_;
|
ISrsFFMPEG *ffmpeg_;
|
||||||
|
|
@ -91,14 +92,17 @@ public:
|
||||||
// push to SRS(or any RTMP server) over RTMP.
|
// push to SRS(or any RTMP server) over RTMP.
|
||||||
class SrsIngester : public ISrsIngester, public ISrsCoroutineHandler
|
class SrsIngester : public ISrsIngester, public ISrsCoroutineHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::vector<ISrsIngesterFFMPEG *> ingesters_;
|
std::vector<ISrsIngesterFFMPEG *> ingesters_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
ISrsPithyPrint *pprint_;
|
ISrsPithyPrint *pprint_;
|
||||||
// Whether the ingesters are expired, for example, the listen port changed,
|
// Whether the ingesters are expired, for example, the listen port changed,
|
||||||
|
|
@ -118,19 +122,23 @@ public:
|
||||||
virtual srs_error_t start();
|
virtual srs_error_t start();
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Notify FFMPEG to fast stop.
|
// Notify FFMPEG to fast stop.
|
||||||
virtual void fast_stop();
|
virtual void
|
||||||
|
fast_stop();
|
||||||
// When SRS quit, directly kill FFMPEG after fast stop.
|
// When SRS quit, directly kill FFMPEG after fast stop.
|
||||||
virtual void fast_kill();
|
virtual void fast_kill();
|
||||||
// Interface ISrsReusableThreadHandler.
|
// Interface ISrsReusableThreadHandler.
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_cycle();
|
virtual srs_error_t do_cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual void clear_engines();
|
virtual void clear_engines();
|
||||||
virtual srs_error_t parse();
|
virtual srs_error_t parse();
|
||||||
virtual srs_error_t parse_ingesters(SrsConfDirective *vhost);
|
virtual srs_error_t parse_ingesters(SrsConfDirective *vhost);
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,14 @@
|
||||||
|
|
||||||
class SrsLatestVersion : public ISrsCoroutineHandler
|
class SrsLatestVersion : public ISrsCoroutineHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
std::string server_id_;
|
std::string server_id_;
|
||||||
std::string session_id_;
|
std::string session_id_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string match_version_;
|
std::string match_version_;
|
||||||
std::string stable_version_;
|
std::string stable_version_;
|
||||||
|
|
||||||
|
|
@ -38,7 +40,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t query_latest_version(std::string &url);
|
srs_error_t query_latest_version(std::string &url);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,19 +94,23 @@ public:
|
||||||
// Bind udp port, start thread to recv packet and handler it.
|
// Bind udp port, start thread to recv packet and handler it.
|
||||||
class SrsUdpListener : public ISrsCoroutineHandler, public ISrsIpListener
|
class SrsUdpListener : public ISrsCoroutineHandler, public ISrsIpListener
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppFactory *factory_;
|
ISrsAppFactory *factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
std::string label_;
|
std::string label_;
|
||||||
srs_netfd_t lfd_;
|
srs_netfd_t lfd_;
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
char *buf_;
|
char *buf_;
|
||||||
int nb_buf_;
|
int nb_buf_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
ISrsUdpHandler *handler_;
|
ISrsUdpHandler *handler_;
|
||||||
std::string ip_;
|
std::string ip_;
|
||||||
int port_;
|
int port_;
|
||||||
|
|
@ -119,11 +123,13 @@ public:
|
||||||
ISrsListener *set_label(const std::string &label);
|
ISrsListener *set_label(const std::string &label);
|
||||||
ISrsListener *set_endpoint(const std::string &i, int p);
|
ISrsListener *set_endpoint(const std::string &i, int p);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual int fd();
|
virtual int fd();
|
||||||
virtual srs_netfd_t stfd();
|
virtual srs_netfd_t stfd();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
void set_socket_buffer();
|
void set_socket_buffer();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -133,22 +139,26 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t do_cycle();
|
srs_error_t do_cycle();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Bind and listen tcp port, use handler to process the client.
|
// Bind and listen tcp port, use handler to process the client.
|
||||||
class SrsTcpListener : public ISrsCoroutineHandler, public ISrsIpListener
|
class SrsTcpListener : public ISrsCoroutineHandler, public ISrsIpListener
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppFactory *factory_;
|
ISrsAppFactory *factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string label_;
|
std::string label_;
|
||||||
srs_netfd_t lfd_;
|
srs_netfd_t lfd_;
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsTcpHandler *handler_;
|
ISrsTcpHandler *handler_;
|
||||||
std::string ip_;
|
std::string ip_;
|
||||||
int port_;
|
int port_;
|
||||||
|
|
@ -170,17 +180,20 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t do_cycle();
|
srs_error_t do_cycle();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Bind and listen tcp port, use handler to process the client.
|
// Bind and listen tcp port, use handler to process the client.
|
||||||
class SrsMultipleTcpListeners : public ISrsIpListener, public ISrsTcpHandler
|
class SrsMultipleTcpListeners : public ISrsIpListener, public ISrsTcpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppFactory *factory_;
|
ISrsAppFactory *factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsTcpHandler *handler_;
|
ISrsTcpHandler *handler_;
|
||||||
std::vector<ISrsIpListener *> listeners_;
|
std::vector<ISrsIpListener *> listeners_;
|
||||||
|
|
||||||
|
|
@ -223,13 +236,15 @@ public:
|
||||||
// TODO: FIXME: Rename it. Refine it for performance issue.
|
// TODO: FIXME: Rename it. Refine it for performance issue.
|
||||||
class SrsUdpMuxSocket : public ISrsUdpMuxSocket
|
class SrsUdpMuxSocket : public ISrsUdpMuxSocket
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// For sender yield only.
|
// For sender yield only.
|
||||||
uint32_t nn_msgs_for_yield_;
|
uint32_t nn_msgs_for_yield_;
|
||||||
std::map<uint32_t, std::string> cache_;
|
std::map<uint32_t, std::string> cache_;
|
||||||
SrsBuffer *cache_buffer_;
|
SrsBuffer *cache_buffer_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
char *buf_;
|
char *buf_;
|
||||||
int nb_buf_;
|
int nb_buf_;
|
||||||
int nread_;
|
int nread_;
|
||||||
|
|
@ -237,11 +252,13 @@ SRS_DECLARE_PRIVATE:
|
||||||
sockaddr_storage from_;
|
sockaddr_storage from_;
|
||||||
int fromlen_;
|
int fromlen_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string peer_ip_;
|
std::string peer_ip_;
|
||||||
int peer_port_;
|
int peer_port_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Cache for peer id.
|
// Cache for peer id.
|
||||||
std::string peer_id_;
|
std::string peer_id_;
|
||||||
// If the address changed, we should generate the peer_id.
|
// If the address changed, we should generate the peer_id.
|
||||||
|
|
@ -271,19 +288,23 @@ public:
|
||||||
|
|
||||||
class SrsUdpMuxListener : public ISrsCoroutineHandler
|
class SrsUdpMuxListener : public ISrsCoroutineHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppFactory *factory_;
|
ISrsAppFactory *factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_netfd_t lfd_;
|
srs_netfd_t lfd_;
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
SrsContextId cid_;
|
SrsContextId cid_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
char *buf_;
|
char *buf_;
|
||||||
int nb_buf_;
|
int nb_buf_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsUdpMuxHandler *handler_;
|
ISrsUdpMuxHandler *handler_;
|
||||||
std::string ip_;
|
std::string ip_;
|
||||||
int port_;
|
int port_;
|
||||||
|
|
@ -302,7 +323,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
void set_socket_buffer();
|
void set_socket_buffer();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,13 @@
|
||||||
// when you want to use different level, override this classs, set the protected _level.
|
// when you want to use different level, override this classs, set the protected _level.
|
||||||
class SrsFileLog : public ISrsLog, public ISrsReloadHandler
|
class SrsFileLog : public ISrsLog, public ISrsReloadHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Defined in SrsLogLevel.
|
// Defined in SrsLogLevel.
|
||||||
SrsLogLevel level_;
|
SrsLogLevel level_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
char *log_data_;
|
char *log_data_;
|
||||||
// Log to file if specified srs_log_file
|
// Log to file if specified srs_log_file
|
||||||
int fd_;
|
int fd_;
|
||||||
|
|
@ -42,7 +44,8 @@ public:
|
||||||
virtual void reopen();
|
virtual void reopen();
|
||||||
virtual void log(SrsLogLevel level, const char *tag, const SrsContextId &context_id, const char *fmt, va_list args);
|
virtual void log(SrsLogLevel level, const char *tag, const SrsContextId &context_id, const char *fmt, va_list args);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual void write_log(int &fd, char *str_log, int size, int level);
|
virtual void write_log(int &fd, char *str_log, int size, int level);
|
||||||
virtual void open_log_file();
|
virtual void open_log_file();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,12 @@ class ISrsAppFactory;
|
||||||
// A UDP listener, for udp stream caster server.
|
// A UDP listener, for udp stream caster server.
|
||||||
class SrsUdpCasterListener : public ISrsListener
|
class SrsUdpCasterListener : public ISrsListener
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsIpListener *listener_;
|
ISrsIpListener *listener_;
|
||||||
ISrsMpegtsOverUdp *caster_;
|
ISrsMpegtsOverUdp *caster_;
|
||||||
|
|
||||||
|
|
@ -78,9 +80,11 @@ public:
|
||||||
// we must recalc the timestamp.
|
// we must recalc the timestamp.
|
||||||
class SrsMpegtsQueue : public ISrsMpegtsQueue
|
class SrsMpegtsQueue : public ISrsMpegtsQueue
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The key: dts, value: msg.
|
// The key: dts, value: msg.
|
||||||
std::map<int64_t, SrsMediaPacket *> msgs_;
|
std::map<int64_t, SrsMediaPacket *>
|
||||||
|
msgs_;
|
||||||
int nb_audios_;
|
int nb_audios_;
|
||||||
int nb_videos_;
|
int nb_videos_;
|
||||||
|
|
||||||
|
|
@ -107,19 +111,23 @@ public:
|
||||||
// The mpegts over udp stream caster.
|
// The mpegts over udp stream caster.
|
||||||
class SrsMpegtsOverUdp : public ISrsMpegtsOverUdp
|
class SrsMpegtsOverUdp : public ISrsMpegtsOverUdp
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsTsContext *context_;
|
ISrsTsContext *context_;
|
||||||
SrsSimpleStream *buffer_;
|
SrsSimpleStream *buffer_;
|
||||||
std::string output_;
|
std::string output_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsBasicRtmpClient *sdk_;
|
ISrsBasicRtmpClient *sdk_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRawH264Stream *avc_;
|
ISrsRawH264Stream *avc_;
|
||||||
std::string h264_sps_;
|
std::string h264_sps_;
|
||||||
bool h264_sps_changed_;
|
bool h264_sps_changed_;
|
||||||
|
|
@ -127,11 +135,13 @@ SRS_DECLARE_PRIVATE:
|
||||||
bool h264_pps_changed_;
|
bool h264_pps_changed_;
|
||||||
bool h264_sps_pps_sent_;
|
bool h264_sps_pps_sent_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRawAacStream *aac_;
|
ISrsRawAacStream *aac_;
|
||||||
std::string aac_specific_config_;
|
std::string aac_specific_config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsMpegtsQueue *queue_;
|
ISrsMpegtsQueue *queue_;
|
||||||
ISrsPithyPrint *pprint_;
|
ISrsPithyPrint *pprint_;
|
||||||
|
|
||||||
|
|
@ -145,25 +155,30 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t on_udp_packet(const sockaddr *from, const int fromlen, char *buf, int nb_buf);
|
virtual srs_error_t on_udp_packet(const sockaddr *from, const int fromlen, char *buf, int nb_buf);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t on_udp_bytes(std::string host, int port, char *buf, int nb_buf);
|
virtual srs_error_t on_udp_bytes(std::string host, int port, char *buf, int nb_buf);
|
||||||
// Interface ISrsTsHandler
|
// Interface ISrsTsHandler
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t on_ts_message(SrsTsMessage *msg);
|
virtual srs_error_t on_ts_message(SrsTsMessage *msg);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t on_ts_video(SrsTsMessage *msg, SrsBuffer *avs);
|
virtual srs_error_t on_ts_video(SrsTsMessage *msg, SrsBuffer *avs);
|
||||||
virtual srs_error_t write_h264_sps_pps(uint32_t dts, uint32_t pts);
|
virtual srs_error_t write_h264_sps_pps(uint32_t dts, uint32_t pts);
|
||||||
virtual srs_error_t write_h264_ipb_frame(char *frame, int frame_size, uint32_t dts, uint32_t pts);
|
virtual srs_error_t write_h264_ipb_frame(char *frame, int frame_size, uint32_t dts, uint32_t pts);
|
||||||
virtual srs_error_t on_ts_audio(SrsTsMessage *msg, SrsBuffer *avs);
|
virtual srs_error_t on_ts_audio(SrsTsMessage *msg, SrsBuffer *avs);
|
||||||
virtual srs_error_t write_audio_raw_frame(char *frame, int frame_size, SrsRawAacStreamCodec *codec, uint32_t dts);
|
virtual srs_error_t write_audio_raw_frame(char *frame, int frame_size, SrsRawAacStreamCodec *codec, uint32_t dts);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t rtmp_write_packet(char type, uint32_t timestamp, char *data, int size);
|
virtual srs_error_t rtmp_write_packet(char type, uint32_t timestamp, char *data, int size);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Connect to RTMP server.
|
// Connect to RTMP server.
|
||||||
virtual srs_error_t connect();
|
virtual srs_error_t
|
||||||
|
connect();
|
||||||
// Close the connection to RTMP server.
|
// Close the connection to RTMP server.
|
||||||
virtual void close();
|
virtual void close();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,8 @@ public:
|
||||||
// @see https://github.com/ossrs/srs/issues/367
|
// @see https://github.com/ossrs/srs/issues/367
|
||||||
class SrsNgExec : public ISrsCoroutineHandler, public ISrsNgExec
|
class SrsNgExec : public ISrsCoroutineHandler, public ISrsNgExec
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
SrsPithyPrint *pprint_;
|
SrsPithyPrint *pprint_;
|
||||||
std::string input_stream_name_;
|
std::string input_stream_name_;
|
||||||
|
|
@ -53,10 +54,12 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_cycle();
|
virtual srs_error_t do_cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t parse_exec_publish(ISrsRequest *req);
|
virtual srs_error_t parse_exec_publish(ISrsRequest *req);
|
||||||
virtual void clear_exec_publish();
|
virtual void clear_exec_publish();
|
||||||
virtual void show_exec_log_message();
|
virtual void show_exec_log_message();
|
||||||
|
|
|
||||||
|
|
@ -57,13 +57,15 @@ public:
|
||||||
// process->stop();
|
// process->stop();
|
||||||
class SrsProcess : public ISrsProcess
|
class SrsProcess : public ISrsProcess
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool is_started_;
|
bool is_started_;
|
||||||
// Whether SIGTERM send but need to wait or SIGKILL.
|
// Whether SIGTERM send but need to wait or SIGKILL.
|
||||||
bool fast_stopped_;
|
bool fast_stopped_;
|
||||||
pid_t pid_;
|
pid_t pid_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string bin_;
|
std::string bin_;
|
||||||
std::string stdout_file_;
|
std::string stdout_file_;
|
||||||
std::string stderr_file_;
|
std::string stderr_file_;
|
||||||
|
|
@ -87,9 +89,11 @@ public:
|
||||||
// @remark the argv[0] must be the binary.
|
// @remark the argv[0] must be the binary.
|
||||||
virtual srs_error_t initialize(std::string binary, std::vector<std::string> argv);
|
virtual srs_error_t initialize(std::string binary, std::vector<std::string> argv);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Redirect standard I/O.
|
// Redirect standard I/O.
|
||||||
virtual srs_error_t redirect_io();
|
virtual srs_error_t
|
||||||
|
redirect_io();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Start the process, ignore when already started.
|
// Start the process, ignore when already started.
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,8 @@ public:
|
||||||
// The recv thread, use message handler to handle each received message.
|
// The recv thread, use message handler to handle each received message.
|
||||||
class SrsRecvThread : public ISrsRecvThread
|
class SrsRecvThread : public ISrsRecvThread
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
ISrsMessagePumper *pumper_;
|
ISrsMessagePumper *pumper_;
|
||||||
ISrsRtmpServer *rtmp_;
|
ISrsRtmpServer *rtmp_;
|
||||||
|
|
@ -105,7 +106,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_cycle();
|
virtual srs_error_t do_cycle();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -125,7 +127,8 @@ public:
|
||||||
// @see: https://github.com/ossrs/srs/issues/217
|
// @see: https://github.com/ossrs/srs/issues/217
|
||||||
class SrsQueueRecvThread : public ISrsQueueRecvThread
|
class SrsQueueRecvThread : public ISrsQueueRecvThread
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::vector<SrsRtmpCommonMessage *> queue_;
|
std::vector<SrsRtmpCommonMessage *> queue_;
|
||||||
ISrsRecvThread *trd_;
|
ISrsRecvThread *trd_;
|
||||||
ISrsRtmpServer *rtmp_;
|
ISrsRtmpServer *rtmp_;
|
||||||
|
|
@ -173,10 +176,12 @@ public:
|
||||||
// @see: https://github.com/ossrs/srs/issues/237
|
// @see: https://github.com/ossrs/srs/issues/237
|
||||||
class SrsPublishRecvThread : public ISrsPublishRecvThread
|
class SrsPublishRecvThread : public ISrsPublishRecvThread
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint32_t nn_msgs_for_yield_;
|
uint32_t nn_msgs_for_yield_;
|
||||||
ISrsRecvThread *trd_;
|
ISrsRecvThread *trd_;
|
||||||
ISrsRtmpServer *rtmp_;
|
ISrsRtmpServer *rtmp_;
|
||||||
|
|
@ -234,7 +239,8 @@ public:
|
||||||
virtual void on_read(ssize_t nread);
|
virtual void on_read(ssize_t nread);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual void set_socket_buffer(srs_utime_t sleep_v);
|
virtual void set_socket_buffer(srs_utime_t sleep_v);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -254,7 +260,8 @@ public:
|
||||||
// @see https://github.com/ossrs/srs/issues/636#issuecomment-298208427
|
// @see https://github.com/ossrs/srs/issues/636#issuecomment-298208427
|
||||||
class SrsHttpRecvThread : public ISrsHttpRecvThread
|
class SrsHttpRecvThread : public ISrsHttpRecvThread
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsHttpxConn *conn_;
|
SrsHttpxConn *conn_;
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ public:
|
||||||
// @param refer the refer in config.
|
// @param refer the refer in config.
|
||||||
virtual srs_error_t check(std::string page_url, SrsConfDirective *refer);
|
virtual srs_error_t check(std::string page_url, SrsConfDirective *refer);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t check_single_refer(std::string page_url, std::string refer);
|
virtual srs_error_t check_single_refer(std::string page_url, std::string refer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,14 +25,16 @@ class ISrsHttpHooks;
|
||||||
|
|
||||||
class SrsGoApiRtcPlay : public ISrsHttpHandler
|
class SrsGoApiRtcPlay : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
ISrsRtcSourceManager *rtc_sources_;
|
ISrsRtcSourceManager *rtc_sources_;
|
||||||
ISrsLiveSourceManager *live_sources_;
|
ISrsLiveSourceManager *live_sources_;
|
||||||
ISrsHttpHooks *hooks_;
|
ISrsHttpHooks *hooks_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRtcApiServer *server_;
|
ISrsRtcApiServer *server_;
|
||||||
ISrsSecurity *security_;
|
ISrsSecurity *security_;
|
||||||
|
|
||||||
|
|
@ -43,27 +45,32 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsJsonObject *res);
|
virtual srs_error_t do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsJsonObject *res);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsRtcUserConfig *ruc);
|
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsRtcUserConfig *ruc);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t check_remote_sdp(const SrsSdp &remote_sdp);
|
srs_error_t check_remote_sdp(const SrsSdp &remote_sdp);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t http_hooks_on_play(ISrsRequest *req);
|
virtual srs_error_t http_hooks_on_play(ISrsRequest *req);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsGoApiRtcPublish : public ISrsHttpHandler
|
class SrsGoApiRtcPublish : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
ISrsHttpHooks *hooks_;
|
ISrsHttpHooks *hooks_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRtcApiServer *server_;
|
ISrsRtcApiServer *server_;
|
||||||
ISrsSecurity *security_;
|
ISrsSecurity *security_;
|
||||||
|
|
||||||
|
|
@ -74,26 +81,31 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsJsonObject *res);
|
virtual srs_error_t do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsJsonObject *res);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsRtcUserConfig *ruc);
|
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsRtcUserConfig *ruc);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t check_remote_sdp(const SrsSdp &remote_sdp);
|
srs_error_t check_remote_sdp(const SrsSdp &remote_sdp);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t http_hooks_on_publish(ISrsRequest *req);
|
virtual srs_error_t http_hooks_on_publish(ISrsRequest *req);
|
||||||
};
|
};
|
||||||
|
|
||||||
// See https://datatracker.ietf.org/doc/draft-ietf-wish-whip/
|
// See https://datatracker.ietf.org/doc/draft-ietf-wish-whip/
|
||||||
class SrsGoApiRtcWhip : public ISrsHttpHandler
|
class SrsGoApiRtcWhip : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRtcApiServer *server_;
|
ISrsRtcApiServer *server_;
|
||||||
SrsGoApiRtcPublish *publish_;
|
SrsGoApiRtcPublish *publish_;
|
||||||
SrsGoApiRtcPlay *play_;
|
SrsGoApiRtcPlay *play_;
|
||||||
|
|
@ -105,13 +117,15 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsRtcUserConfig *ruc);
|
virtual srs_error_t do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsRtcUserConfig *ruc);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsGoApiRtcNACK : public ISrsHttpHandler
|
class SrsGoApiRtcNACK : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRtcApiServer *server_;
|
ISrsRtcApiServer *server_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -121,7 +135,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsJsonObject *res);
|
virtual srs_error_t do_serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, SrsJsonObject *res);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,8 @@ public:
|
||||||
// The audio transcoder, transcode audio from one codec to another.
|
// The audio transcoder, transcode audio from one codec to another.
|
||||||
class SrsAudioTranscoder : public ISrsAudioTranscoder
|
class SrsAudioTranscoder : public ISrsAudioTranscoder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
AVCodecContext *dec_;
|
AVCodecContext *dec_;
|
||||||
AVFrame *dec_frame_;
|
AVFrame *dec_frame_;
|
||||||
AVPacket *dec_packet_;
|
AVPacket *dec_packet_;
|
||||||
|
|
@ -95,7 +96,8 @@ public:
|
||||||
// @remark User should never free the data, it's managed by this transcoder.
|
// @remark User should never free the data, it's managed by this transcoder.
|
||||||
void aac_codec_header(uint8_t **data, int *len);
|
void aac_codec_header(uint8_t **data, int *len);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t init_dec(SrsAudioCodecId from);
|
srs_error_t init_dec(SrsAudioCodecId from);
|
||||||
srs_error_t init_enc(SrsAudioCodecId to, int channels, int samplerate, int bit_rate);
|
srs_error_t init_enc(SrsAudioCodecId to, int channels, int samplerate, int bit_rate);
|
||||||
srs_error_t init_swr(AVCodecContext *decoder);
|
srs_error_t init_swr(AVCodecContext *decoder);
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,8 @@ public:
|
||||||
// The security transport, use DTLS/SRTP to protect the data.
|
// The security transport, use DTLS/SRTP to protect the data.
|
||||||
class SrsSecurityTransport : public ISrsRtcTransport
|
class SrsSecurityTransport : public ISrsRtcTransport
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRtcNetwork *network_;
|
ISrsRtcNetwork *network_;
|
||||||
ISrsDtls *dtls_;
|
ISrsDtls *dtls_;
|
||||||
ISrsSRTP *srtp_;
|
ISrsSRTP *srtp_;
|
||||||
|
|
@ -134,7 +135,8 @@ public:
|
||||||
virtual srs_error_t on_dtls_application_data(const char *data, const int len);
|
virtual srs_error_t on_dtls_application_data(const char *data, const int len);
|
||||||
virtual srs_error_t write_dtls_data(void *data, int size);
|
virtual srs_error_t write_dtls_data(void *data, int size);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t srtp_initialize();
|
srs_error_t srtp_initialize();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -155,7 +157,8 @@ public:
|
||||||
// Plaintext transport, without DTLS or SRTP.
|
// Plaintext transport, without DTLS or SRTP.
|
||||||
class SrsPlaintextTransport : public ISrsRtcTransport
|
class SrsPlaintextTransport : public ISrsRtcTransport
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRtcNetwork *network_;
|
ISrsRtcNetwork *network_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -192,14 +195,17 @@ public:
|
||||||
// A worker coroutine to request the PLI.
|
// A worker coroutine to request the PLI.
|
||||||
class SrsRtcPliWorker : public ISrsCoroutineHandler
|
class SrsRtcPliWorker : public ISrsCoroutineHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
ISrsCond *wait_;
|
ISrsCond *wait_;
|
||||||
ISrsRtcPliWorkerHandler *handler_;
|
ISrsRtcPliWorkerHandler *handler_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Key is SSRC, value is the CID of subscriber which requests PLI.
|
// Key is SSRC, value is the CID of subscriber which requests PLI.
|
||||||
std::map<uint32_t, SrsContextId> plis_;
|
std::map<uint32_t, SrsContextId>
|
||||||
|
plis_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SrsRtcPliWorker(ISrsRtcPliWorkerHandler *h);
|
SrsRtcPliWorker(ISrsRtcPliWorkerHandler *h);
|
||||||
|
|
@ -216,7 +222,8 @@ public:
|
||||||
// the rtc on_stop async call.
|
// the rtc on_stop async call.
|
||||||
class SrsRtcAsyncCallOnStop : public ISrsAsyncCallTask
|
class SrsRtcAsyncCallOnStop : public ISrsAsyncCallTask
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsContextId cid_;
|
SrsContextId cid_;
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
ISrsHttpHooks *hooks_;
|
ISrsHttpHooks *hooks_;
|
||||||
|
|
@ -235,22 +242,26 @@ public:
|
||||||
// A RTC play stream, client pull and play stream from SRS.
|
// A RTC play stream, client pull and play stream from SRS.
|
||||||
class SrsRtcPlayStream : public ISrsCoroutineHandler, public ISrsReloadHandler, public ISrsRtcPliWorkerHandler, public ISrsRtcSourceChangeCallback
|
class SrsRtcPlayStream : public ISrsCoroutineHandler, public ISrsReloadHandler, public ISrsRtcPliWorkerHandler, public ISrsRtcSourceChangeCallback
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsExecRtcAsyncTask *exec_;
|
ISrsExecRtcAsyncTask *exec_;
|
||||||
ISrsExpire *expire_;
|
ISrsExpire *expire_;
|
||||||
ISrsRtcPacketSender *sender_;
|
ISrsRtcPacketSender *sender_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsRtcSourceManager *rtc_sources_;
|
ISrsRtcSourceManager *rtc_sources_;
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsContextId cid_;
|
SrsContextId cid_;
|
||||||
SrsFastCoroutine *trd_;
|
SrsFastCoroutine *trd_;
|
||||||
SrsRtcPliWorker *pli_worker_;
|
SrsRtcPliWorker *pli_worker_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
SrsSharedPtr<SrsRtcSource> source_;
|
SrsSharedPtr<SrsRtcSource> source_;
|
||||||
// key: publish_ssrc, value: send track to process rtp/rtcp
|
// key: publish_ssrc, value: send track to process rtp/rtcp
|
||||||
|
|
@ -259,7 +270,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// The pithy print for special stage.
|
// The pithy print for special stage.
|
||||||
SrsErrorPithyPrint *nack_epp_;
|
SrsErrorPithyPrint *nack_epp_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Fast cache for tracks.
|
// Fast cache for tracks.
|
||||||
uint32_t cache_ssrc0_;
|
uint32_t cache_ssrc0_;
|
||||||
uint32_t cache_ssrc1_;
|
uint32_t cache_ssrc1_;
|
||||||
|
|
@ -268,7 +280,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
SrsRtcSendTrack *cache_track1_;
|
SrsRtcSendTrack *cache_track1_;
|
||||||
SrsRtcSendTrack *cache_track2_;
|
SrsRtcSendTrack *cache_track2_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// For merged-write messages.
|
// For merged-write messages.
|
||||||
int mw_msgs_;
|
int mw_msgs_;
|
||||||
bool realtime_;
|
bool realtime_;
|
||||||
|
|
@ -276,7 +289,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
bool nack_enabled_;
|
bool nack_enabled_;
|
||||||
bool nack_no_copy_;
|
bool nack_no_copy_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Whether player started.
|
// Whether player started.
|
||||||
bool is_started_;
|
bool is_started_;
|
||||||
|
|
||||||
|
|
@ -300,7 +314,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t send_packet(SrsRtpPacket *&pkt);
|
srs_error_t send_packet(SrsRtpPacket *&pkt);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -310,7 +325,8 @@ public:
|
||||||
public:
|
public:
|
||||||
srs_error_t on_rtcp(SrsRtcpCommon *rtcp);
|
srs_error_t on_rtcp(SrsRtcpCommon *rtcp);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t on_rtcp_xr(SrsRtcpXr *rtcp);
|
srs_error_t on_rtcp_xr(SrsRtcpXr *rtcp);
|
||||||
srs_error_t on_rtcp_nack(SrsRtcpNack *rtcp);
|
srs_error_t on_rtcp_nack(SrsRtcpNack *rtcp);
|
||||||
srs_error_t on_rtcp_ps_feedback(SrsRtcpFbCommon *rtcp);
|
srs_error_t on_rtcp_ps_feedback(SrsRtcpFbCommon *rtcp);
|
||||||
|
|
@ -341,7 +357,8 @@ public:
|
||||||
// A fast timer for publish stream, for RTCP feedback.
|
// A fast timer for publish stream, for RTCP feedback.
|
||||||
class SrsRtcPublishRtcpTimer : public ISrsFastTimerHandler
|
class SrsRtcPublishRtcpTimer : public ISrsFastTimerHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRtcRtcpSender *sender_;
|
ISrsRtcRtcpSender *sender_;
|
||||||
srs_mutex_t lock_;
|
srs_mutex_t lock_;
|
||||||
|
|
||||||
|
|
@ -349,17 +366,20 @@ public:
|
||||||
SrsRtcPublishRtcpTimer(ISrsRtcRtcpSender *sender);
|
SrsRtcPublishRtcpTimer(ISrsRtcRtcpSender *sender);
|
||||||
virtual ~SrsRtcPublishRtcpTimer();
|
virtual ~SrsRtcPublishRtcpTimer();
|
||||||
// interface ISrsFastTimerHandler
|
// interface ISrsFastTimerHandler
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t on_timer(srs_utime_t interval);
|
srs_error_t on_timer(srs_utime_t interval);
|
||||||
};
|
};
|
||||||
|
|
||||||
// A fast timer for publish stream, for TWCC feedback.
|
// A fast timer for publish stream, for TWCC feedback.
|
||||||
class SrsRtcPublishTwccTimer : public ISrsFastTimerHandler
|
class SrsRtcPublishTwccTimer : public ISrsFastTimerHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsCircuitBreaker *circuit_breaker_;
|
ISrsCircuitBreaker *circuit_breaker_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRtcRtcpSender *sender_;
|
ISrsRtcRtcpSender *sender_;
|
||||||
srs_mutex_t lock_;
|
srs_mutex_t lock_;
|
||||||
|
|
||||||
|
|
@ -367,18 +387,21 @@ public:
|
||||||
SrsRtcPublishTwccTimer(ISrsRtcRtcpSender *sender);
|
SrsRtcPublishTwccTimer(ISrsRtcRtcpSender *sender);
|
||||||
virtual ~SrsRtcPublishTwccTimer();
|
virtual ~SrsRtcPublishTwccTimer();
|
||||||
// interface ISrsFastTimerHandler
|
// interface ISrsFastTimerHandler
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t on_timer(srs_utime_t interval);
|
srs_error_t on_timer(srs_utime_t interval);
|
||||||
};
|
};
|
||||||
|
|
||||||
// the rtc on_unpublish async call.
|
// the rtc on_unpublish async call.
|
||||||
class SrsRtcAsyncCallOnUnpublish : public ISrsAsyncCallTask
|
class SrsRtcAsyncCallOnUnpublish : public ISrsAsyncCallTask
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsHttpHooks *hooks_;
|
ISrsHttpHooks *hooks_;
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsContextId cid_;
|
SrsContextId cid_;
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
|
|
||||||
|
|
@ -394,54 +417,64 @@ public:
|
||||||
// A RTC publish stream, client push and publish stream to SRS.
|
// A RTC publish stream, client push and publish stream to SRS.
|
||||||
class SrsRtcPublishStream : public ISrsRtpPacketDecodeHandler, public ISrsRtcPublishStream, public ISrsRtcPliWorkerHandler, public ISrsRtcRtcpSender
|
class SrsRtcPublishStream : public ISrsRtpPacketDecodeHandler, public ISrsRtcPublishStream, public ISrsRtcPliWorkerHandler, public ISrsRtcRtcpSender
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsExecRtcAsyncTask *exec_;
|
ISrsExecRtcAsyncTask *exec_;
|
||||||
ISrsExpire *expire_;
|
ISrsExpire *expire_;
|
||||||
ISrsRtcPacketReceiver *receiver_;
|
ISrsRtcPacketReceiver *receiver_;
|
||||||
ISrsCircuitBreaker *circuit_breaker_;
|
ISrsCircuitBreaker *circuit_breaker_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsRtcSourceManager *rtc_sources_;
|
ISrsRtcSourceManager *rtc_sources_;
|
||||||
ISrsLiveSourceManager *live_sources_;
|
ISrsLiveSourceManager *live_sources_;
|
||||||
ISrsSrtSourceManager *srt_sources_;
|
ISrsSrtSourceManager *srt_sources_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
friend class SrsRtcPublishRtcpTimer;
|
friend class SrsRtcPublishRtcpTimer;
|
||||||
friend class SrsRtcPublishTwccTimer;
|
friend class SrsRtcPublishTwccTimer;
|
||||||
SrsRtcPublishRtcpTimer *timer_rtcp_;
|
SrsRtcPublishRtcpTimer *timer_rtcp_;
|
||||||
SrsRtcPublishTwccTimer *timer_twcc_;
|
SrsRtcPublishTwccTimer *timer_twcc_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsContextId cid_;
|
SrsContextId cid_;
|
||||||
uint64_t nn_audio_frames_;
|
uint64_t nn_audio_frames_;
|
||||||
SrsRtcPliWorker *pli_worker_;
|
SrsRtcPliWorker *pli_worker_;
|
||||||
SrsErrorPithyPrint *twcc_epp_;
|
SrsErrorPithyPrint *twcc_epp_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint16_t pt_to_drop_;
|
uint16_t pt_to_drop_;
|
||||||
// Whether enabled nack.
|
// Whether enabled nack.
|
||||||
bool nack_enabled_;
|
bool nack_enabled_;
|
||||||
bool nack_no_copy_;
|
bool nack_no_copy_;
|
||||||
bool twcc_enabled_;
|
bool twcc_enabled_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool request_keyframe_;
|
bool request_keyframe_;
|
||||||
SrsErrorPithyPrint *pli_epp_;
|
SrsErrorPithyPrint *pli_epp_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
SrsSharedPtr<SrsRtcSource> source_;
|
SrsSharedPtr<SrsRtcSource> source_;
|
||||||
// Simulators.
|
// Simulators.
|
||||||
int nn_simulate_nack_drop_;
|
int nn_simulate_nack_drop_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// track vector
|
// track vector
|
||||||
std::vector<SrsRtcAudioRecvTrack *> audio_tracks_;
|
std::vector<SrsRtcAudioRecvTrack *>
|
||||||
|
audio_tracks_;
|
||||||
std::vector<SrsRtcVideoRecvTrack *> video_tracks_;
|
std::vector<SrsRtcVideoRecvTrack *> video_tracks_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
int twcc_id_;
|
int twcc_id_;
|
||||||
uint8_t twcc_fb_count_;
|
uint8_t twcc_fb_count_;
|
||||||
SrsRtcpTWCC rtcp_twcc_;
|
SrsRtcpTWCC rtcp_twcc_;
|
||||||
|
|
@ -460,7 +493,8 @@ public:
|
||||||
void set_all_tracks_status(bool status);
|
void set_all_tracks_status(bool status);
|
||||||
virtual const SrsContextId &context_id();
|
virtual const SrsContextId &context_id();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool is_sender_started();
|
bool is_sender_started();
|
||||||
bool is_sender_twcc_enabled();
|
bool is_sender_twcc_enabled();
|
||||||
srs_error_t send_rtcp_rr();
|
srs_error_t send_rtcp_rr();
|
||||||
|
|
@ -470,7 +504,8 @@ public:
|
||||||
srs_error_t on_rtp_cipher(char *buf, int nb_buf);
|
srs_error_t on_rtp_cipher(char *buf, int nb_buf);
|
||||||
srs_error_t on_rtp_plaintext(char *buf, int nb_buf);
|
srs_error_t on_rtp_plaintext(char *buf, int nb_buf);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t do_on_rtp_plaintext(SrsRtpPacket *&pkt, SrsBuffer *buf);
|
srs_error_t do_on_rtp_plaintext(SrsRtpPacket *&pkt, SrsBuffer *buf);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -479,13 +514,15 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual void on_before_decode_payload(SrsRtpPacket *pkt, SrsBuffer *buf, ISrsRtpPayloader **ppayload, SrsRtpPacketPayloadType *ppt);
|
virtual void on_before_decode_payload(SrsRtpPacket *pkt, SrsBuffer *buf, ISrsRtpPayloader **ppayload, SrsRtpPacketPayloadType *ppt);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t send_periodic_twcc();
|
srs_error_t send_periodic_twcc();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
srs_error_t on_rtcp(SrsRtcpCommon *rtcp);
|
srs_error_t on_rtcp(SrsRtcpCommon *rtcp);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t on_rtcp_sr(SrsRtcpSR *rtcp);
|
srs_error_t on_rtcp_sr(SrsRtcpSR *rtcp);
|
||||||
srs_error_t on_rtcp_xr(SrsRtcpXr *rtcp);
|
srs_error_t on_rtcp_xr(SrsRtcpXr *rtcp);
|
||||||
|
|
||||||
|
|
@ -496,10 +533,12 @@ public:
|
||||||
public:
|
public:
|
||||||
void simulate_nack_drop(int nn);
|
void simulate_nack_drop(int nn);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
void simulate_drop_packet(SrsRtpHeader *h, int nn_bytes);
|
void simulate_drop_packet(SrsRtpHeader *h, int nn_bytes);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t on_twcc(uint16_t sn);
|
srs_error_t on_twcc(uint16_t sn);
|
||||||
SrsRtcAudioRecvTrack *get_audio_track(uint32_t ssrc);
|
SrsRtcAudioRecvTrack *get_audio_track(uint32_t ssrc);
|
||||||
SrsRtcVideoRecvTrack *get_video_track(uint32_t ssrc);
|
SrsRtcVideoRecvTrack *get_video_track(uint32_t ssrc);
|
||||||
|
|
@ -521,11 +560,13 @@ public:
|
||||||
// A fast timer for conntion, for NACK feedback.
|
// A fast timer for conntion, for NACK feedback.
|
||||||
class SrsRtcConnectionNackTimer : public ISrsFastTimerHandler
|
class SrsRtcConnectionNackTimer : public ISrsFastTimerHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsSharedTimer *shared_timer_;
|
ISrsSharedTimer *shared_timer_;
|
||||||
ISrsCircuitBreaker *circuit_breaker_;
|
ISrsCircuitBreaker *circuit_breaker_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRtcConnectionNackTimerHandler *handler_;
|
ISrsRtcConnectionNackTimerHandler *handler_;
|
||||||
srs_mutex_t lock_;
|
srs_mutex_t lock_;
|
||||||
|
|
||||||
|
|
@ -537,7 +578,8 @@ public:
|
||||||
virtual srs_error_t initialize();
|
virtual srs_error_t initialize();
|
||||||
|
|
||||||
// interface ISrsFastTimerHandler
|
// interface ISrsFastTimerHandler
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t on_timer(srs_utime_t interval);
|
srs_error_t on_timer(srs_utime_t interval);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -609,13 +651,15 @@ class SrsRtcConnection : public ISrsRtcConnection
|
||||||
{
|
{
|
||||||
friend class SrsSecurityTransport;
|
friend class SrsSecurityTransport;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsCircuitBreaker *circuit_breaker_;
|
ISrsCircuitBreaker *circuit_breaker_;
|
||||||
ISrsResourceManager *conn_manager_;
|
ISrsResourceManager *conn_manager_;
|
||||||
ISrsRtcSourceManager *rtc_sources_;
|
ISrsRtcSourceManager *rtc_sources_;
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsRtcConnectionNackTimer *timer_nack_;
|
SrsRtcConnectionNackTimer *timer_nack_;
|
||||||
ISrsExecRtcAsyncTask *exec_;
|
ISrsExecRtcAsyncTask *exec_;
|
||||||
SrsRtcPublisherNegotiator *publisher_negotiator_;
|
SrsRtcPublisherNegotiator *publisher_negotiator_;
|
||||||
|
|
@ -624,13 +668,16 @@ SRS_DECLARE_PRIVATE:
|
||||||
public:
|
public:
|
||||||
bool disposing_;
|
bool disposing_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
iovec *cache_iov_;
|
iovec *cache_iov_;
|
||||||
SrsBuffer *cache_buffer_;
|
SrsBuffer *cache_buffer_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// key: stream id
|
// key: stream id
|
||||||
std::map<std::string, SrsRtcPlayStream *> players_;
|
std::map<std::string, SrsRtcPlayStream *>
|
||||||
|
players_;
|
||||||
// key: player track's ssrc
|
// key: player track's ssrc
|
||||||
std::map<uint32_t, SrsRtcPlayStream *> players_ssrc_map_;
|
std::map<uint32_t, SrsRtcPlayStream *> players_ssrc_map_;
|
||||||
// key: stream id
|
// key: stream id
|
||||||
|
|
@ -638,7 +685,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// key: publisher track's ssrc
|
// key: publisher track's ssrc
|
||||||
std::map<uint32_t, SrsRtcPublishStream *> publishers_ssrc_map_;
|
std::map<uint32_t, SrsRtcPublishStream *> publishers_ssrc_map_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The local:remote username, such as m5x0n128:jvOm where local name is m5x0n128.
|
// The local:remote username, such as m5x0n128:jvOm where local name is m5x0n128.
|
||||||
std::string username_;
|
std::string username_;
|
||||||
// The random token to verify the WHIP DELETE request etc.
|
// The random token to verify the WHIP DELETE request etc.
|
||||||
|
|
@ -646,14 +694,16 @@ SRS_DECLARE_PRIVATE:
|
||||||
// A group of networks, each has its own DTLS and SRTP context.
|
// A group of networks, each has its own DTLS and SRTP context.
|
||||||
SrsRtcNetworks *networks_;
|
SrsRtcNetworks *networks_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// TODO: FIXME: Rename it.
|
// TODO: FIXME: Rename it.
|
||||||
// The timeout of session, keep alive by STUN ping pong.
|
// The timeout of session, keep alive by STUN ping pong.
|
||||||
srs_utime_t session_timeout_;
|
srs_utime_t session_timeout_;
|
||||||
// TODO: FIXME: Rename it.
|
// TODO: FIXME: Rename it.
|
||||||
srs_utime_t last_stun_time_;
|
srs_utime_t last_stun_time_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// For each RTC session, we use a specified cid for debugging logs.
|
// For each RTC session, we use a specified cid for debugging logs.
|
||||||
SrsContextId cid_;
|
SrsContextId cid_;
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
|
|
@ -661,7 +711,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
SrsSdp local_sdp_;
|
SrsSdp local_sdp_;
|
||||||
SrsSharedPtr<SrsStreamPublishToken> publish_token_;
|
SrsSharedPtr<SrsStreamPublishToken> publish_token_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// twcc handler
|
// twcc handler
|
||||||
int twcc_id_;
|
int twcc_id_;
|
||||||
// Simulators.
|
// Simulators.
|
||||||
|
|
@ -669,7 +720,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// Pithy print for PLI request.
|
// Pithy print for PLI request.
|
||||||
SrsErrorPithyPrint *pli_epp_;
|
SrsErrorPithyPrint *pli_epp_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool nack_enabled_;
|
bool nack_enabled_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -721,14 +773,17 @@ public:
|
||||||
srs_error_t on_rtp_cipher(char *data, int nb_data);
|
srs_error_t on_rtp_cipher(char *data, int nb_data);
|
||||||
srs_error_t on_rtp_plaintext(char *data, int nb_data);
|
srs_error_t on_rtp_plaintext(char *data, int nb_data);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Decode the RTP header from buf, find the publisher by SSRC.
|
// Decode the RTP header from buf, find the publisher by SSRC.
|
||||||
srs_error_t find_publisher(char *buf, int size, SrsRtcPublishStream **ppublisher);
|
srs_error_t
|
||||||
|
find_publisher(char *buf, int size, SrsRtcPublishStream **ppublisher);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
srs_error_t on_rtcp(char *data, int nb_data);
|
srs_error_t on_rtcp(char *data, int nb_data);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t dispatch_rtcp(SrsRtcpCommon *rtcp);
|
srs_error_t dispatch_rtcp(SrsRtcpCommon *rtcp);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -770,7 +825,8 @@ public:
|
||||||
// Notify by specified network.
|
// Notify by specified network.
|
||||||
srs_error_t on_binding_request(SrsStunPacket *r, std::string &ice_pwd);
|
srs_error_t on_binding_request(SrsStunPacket *r, std::string &ice_pwd);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t create_player(ISrsRequest *request, std::map<uint32_t, SrsRtcTrackDescription *> sub_relations);
|
srs_error_t create_player(ISrsRequest *request, std::map<uint32_t, SrsRtcTrackDescription *> sub_relations);
|
||||||
srs_error_t create_publisher(ISrsRequest *request, SrsRtcSourceDescription *stream_desc);
|
srs_error_t create_publisher(ISrsRequest *request, SrsRtcSourceDescription *stream_desc);
|
||||||
};
|
};
|
||||||
|
|
@ -778,7 +834,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// Negotiate via SDP exchange for WebRTC publisher.
|
// Negotiate via SDP exchange for WebRTC publisher.
|
||||||
class SrsRtcPublisherNegotiator
|
class SrsRtcPublisherNegotiator
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
|
|
@ -798,7 +855,8 @@ public:
|
||||||
// Negotiate via SDP exchange for WebRTC player.
|
// Negotiate via SDP exchange for WebRTC player.
|
||||||
class SrsRtcPlayerNegotiator
|
class SrsRtcPlayerNegotiator
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsRtcSourceManager *rtc_sources_;
|
ISrsRtcSourceManager *rtc_sources_;
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,8 @@ public:
|
||||||
// The DTLS certificate.
|
// The DTLS certificate.
|
||||||
class SrsDtlsCertificate : public ISrsDtlsCertificate
|
class SrsDtlsCertificate : public ISrsDtlsCertificate
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string fingerprint_;
|
std::string fingerprint_;
|
||||||
bool ecdsa_mode_;
|
bool ecdsa_mode_;
|
||||||
X509 *dtls_cert_;
|
X509 *dtls_cert_;
|
||||||
|
|
@ -104,7 +105,8 @@ enum SrsDtlsState {
|
||||||
|
|
||||||
class SrsDtlsImpl
|
class SrsDtlsImpl
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
SSL_CTX *dtls_ctx_;
|
SSL_CTX *dtls_ctx_;
|
||||||
SSL *dtls_;
|
SSL *dtls_;
|
||||||
BIO *bio_in_;
|
BIO *bio_in_;
|
||||||
|
|
@ -113,7 +115,8 @@ SRS_DECLARE_PROTECTED:
|
||||||
// @remark: dtls_version_ default value is SrsDtlsVersionAuto.
|
// @remark: dtls_version_ default value is SrsDtlsVersionAuto.
|
||||||
SrsDtlsVersion version_;
|
SrsDtlsVersion version_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
// Whether the handshake is done, for us only.
|
// Whether the handshake is done, for us only.
|
||||||
// @remark For us only, means peer maybe not done, we also need to handle the DTLS packet.
|
// @remark For us only, means peer maybe not done, we also need to handle the DTLS packet.
|
||||||
bool handshake_done_for_us_;
|
bool handshake_done_for_us_;
|
||||||
|
|
@ -135,7 +138,8 @@ public:
|
||||||
virtual srs_error_t start_active_handshake();
|
virtual srs_error_t start_active_handshake();
|
||||||
virtual srs_error_t on_dtls(char *data, int nb_data);
|
virtual srs_error_t on_dtls(char *data, int nb_data);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
srs_error_t do_on_dtls(char *data, int nb_data);
|
srs_error_t do_on_dtls(char *data, int nb_data);
|
||||||
void state_trace(uint8_t *data, int length, bool incoming, int r0);
|
void state_trace(uint8_t *data, int length, bool incoming, int r0);
|
||||||
|
|
||||||
|
|
@ -143,7 +147,8 @@ public:
|
||||||
srs_error_t get_srtp_key(std::string &recv_key, std::string &send_key);
|
srs_error_t get_srtp_key(std::string &recv_key, std::string &send_key);
|
||||||
void callback_by_ssl(std::string type, std::string desc);
|
void callback_by_ssl(std::string type, std::string desc);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t on_handshake_done() = 0;
|
virtual srs_error_t on_handshake_done() = 0;
|
||||||
virtual bool is_dtls_client() = 0;
|
virtual bool is_dtls_client() = 0;
|
||||||
virtual srs_error_t start_arq() = 0;
|
virtual srs_error_t start_arq() = 0;
|
||||||
|
|
@ -151,7 +156,8 @@ SRS_DECLARE_PROTECTED:
|
||||||
|
|
||||||
class SrsDtlsClientImpl : public SrsDtlsImpl, public ISrsCoroutineHandler
|
class SrsDtlsClientImpl : public SrsDtlsImpl, public ISrsCoroutineHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// ARQ thread, for role active(DTLS client).
|
// ARQ thread, for role active(DTLS client).
|
||||||
// @note If passive(DTLS server), the ARQ is driven by DTLS client.
|
// @note If passive(DTLS server), the ARQ is driven by DTLS client.
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
|
|
@ -167,11 +173,13 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t initialize(std::string version, std::string role);
|
virtual srs_error_t initialize(std::string version, std::string role);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t on_handshake_done();
|
virtual srs_error_t on_handshake_done();
|
||||||
virtual bool is_dtls_client();
|
virtual bool is_dtls_client();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
srs_error_t start_arq();
|
srs_error_t start_arq();
|
||||||
void stop_arq();
|
void stop_arq();
|
||||||
|
|
||||||
|
|
@ -188,7 +196,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t initialize(std::string version, std::string role);
|
virtual srs_error_t initialize(std::string version, std::string role);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t on_handshake_done();
|
virtual srs_error_t on_handshake_done();
|
||||||
virtual bool is_dtls_client();
|
virtual bool is_dtls_client();
|
||||||
srs_error_t start_arq();
|
srs_error_t start_arq();
|
||||||
|
|
@ -208,7 +217,8 @@ public:
|
||||||
srs_error_t get_srtp_key(std::string &recv_key, std::string &send_key);
|
srs_error_t get_srtp_key(std::string &recv_key, std::string &send_key);
|
||||||
void callback_by_ssl(std::string type, std::string desc);
|
void callback_by_ssl(std::string type, std::string desc);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t on_handshake_done();
|
virtual srs_error_t on_handshake_done();
|
||||||
virtual bool is_dtls_client();
|
virtual bool is_dtls_client();
|
||||||
virtual srs_error_t start_arq();
|
virtual srs_error_t start_arq();
|
||||||
|
|
@ -231,7 +241,8 @@ public:
|
||||||
// The DTLS transport.
|
// The DTLS transport.
|
||||||
class SrsDtls : public ISrsDtls
|
class SrsDtls : public ISrsDtls
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsDtlsImpl *impl_;
|
SrsDtlsImpl *impl_;
|
||||||
ISrsDtlsCallback *callback_;
|
ISrsDtlsCallback *callback_;
|
||||||
|
|
||||||
|
|
@ -271,7 +282,8 @@ public:
|
||||||
// The SRTP transport.
|
// The SRTP transport.
|
||||||
class SrsSRTP : public ISrsSRTP
|
class SrsSRTP : public ISrsSRTP
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srtp_t recv_ctx_;
|
srtp_t recv_ctx_;
|
||||||
srtp_t send_ctx_;
|
srtp_t send_ctx_;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,8 @@ public:
|
||||||
// A group of networks, each has its own DTLS and SRTP context.
|
// A group of networks, each has its own DTLS and SRTP context.
|
||||||
class SrsRtcNetworks : public ISrsRtcNetworks
|
class SrsRtcNetworks : public ISrsRtcNetworks
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Network over UDP.
|
// Network over UDP.
|
||||||
ISrsRtcNetwork *udp_;
|
ISrsRtcNetwork *udp_;
|
||||||
// Network over TCP
|
// Network over TCP
|
||||||
|
|
@ -70,7 +71,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// Network over dummy
|
// Network over dummy
|
||||||
ISrsRtcNetwork *dummy_;
|
ISrsRtcNetwork *dummy_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// WebRTC session object.
|
// WebRTC session object.
|
||||||
ISrsRtcConnection *conn_;
|
ISrsRtcConnection *conn_;
|
||||||
// Delta object for statistics.
|
// Delta object for statistics.
|
||||||
|
|
@ -170,17 +172,20 @@ public:
|
||||||
// The WebRTC over UDP network.
|
// The WebRTC over UDP network.
|
||||||
class SrsRtcUdpNetwork : public ISrsRtcNetwork
|
class SrsRtcUdpNetwork : public ISrsRtcNetwork
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsResourceManager *conn_manager_;
|
ISrsResourceManager *conn_manager_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// WebRTC session object.
|
// WebRTC session object.
|
||||||
ISrsRtcConnection *conn_;
|
ISrsRtcConnection *conn_;
|
||||||
// Delta object for statistics.
|
// Delta object for statistics.
|
||||||
ISrsEphemeralDelta *delta_;
|
ISrsEphemeralDelta *delta_;
|
||||||
SrsRtcNetworkState state_;
|
SrsRtcNetworkState state_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Pithy print for address change, use port as error code.
|
// Pithy print for address change, use port as error code.
|
||||||
SrsErrorPithyPrint *pp_address_change_;
|
SrsErrorPithyPrint *pp_address_change_;
|
||||||
// The peer address, client maybe use more than one address, it's the current selected one.
|
// The peer address, client maybe use more than one address, it's the current selected one.
|
||||||
|
|
@ -200,7 +205,8 @@ public:
|
||||||
// When got STUN ping message. The peer address may change, we can identify that by STUN messages.
|
// When got STUN ping message. The peer address may change, we can identify that by STUN messages.
|
||||||
srs_error_t on_stun(SrsStunPacket *r, char *data, int nb_data);
|
srs_error_t on_stun(SrsStunPacket *r, char *data, int nb_data);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t on_binding_request(SrsStunPacket *r, std::string ice_pwd);
|
srs_error_t on_binding_request(SrsStunPacket *r, std::string ice_pwd);
|
||||||
// DTLS transport functions.
|
// DTLS transport functions.
|
||||||
public:
|
public:
|
||||||
|
|
@ -229,17 +235,20 @@ public:
|
||||||
|
|
||||||
class SrsRtcTcpNetwork : public ISrsRtcNetwork
|
class SrsRtcTcpNetwork : public ISrsRtcNetwork
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRtcConnection *conn_;
|
ISrsRtcConnection *conn_;
|
||||||
ISrsEphemeralDelta *delta_;
|
ISrsEphemeralDelta *delta_;
|
||||||
ISrsProtocolReadWriter *sendonly_skt_;
|
ISrsProtocolReadWriter *sendonly_skt_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The DTLS transport over this network.
|
// The DTLS transport over this network.
|
||||||
ISrsRtcTransport *transport_;
|
ISrsRtcTransport *transport_;
|
||||||
SrsSharedResource<ISrsRtcTcpConn> owner_;
|
SrsSharedResource<ISrsRtcTcpConn> owner_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string peer_ip_;
|
std::string peer_ip_;
|
||||||
int peer_port_;
|
int peer_port_;
|
||||||
SrsRtcNetworkState state_;
|
SrsRtcNetworkState state_;
|
||||||
|
|
@ -266,7 +275,8 @@ public:
|
||||||
// When got STUN ping message. The peer address may change, we can identify that by STUN messages.
|
// When got STUN ping message. The peer address may change, we can identify that by STUN messages.
|
||||||
srs_error_t on_stun(SrsStunPacket *r, char *data, int nb_data);
|
srs_error_t on_stun(SrsStunPacket *r, char *data, int nb_data);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t on_binding_request(SrsStunPacket *r, std::string ice_pwd);
|
srs_error_t on_binding_request(SrsStunPacket *r, std::string ice_pwd);
|
||||||
// DTLS transport functions.
|
// DTLS transport functions.
|
||||||
public:
|
public:
|
||||||
|
|
@ -308,15 +318,18 @@ public:
|
||||||
// For WebRTC over TCP.
|
// For WebRTC over TCP.
|
||||||
class SrsRtcTcpConn : public ISrsRtcTcpConn
|
class SrsRtcTcpConn : public ISrsRtcTcpConn
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsResourceManager *conn_manager_;
|
ISrsResourceManager *conn_manager_;
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Because session references to this object, so we should directly use the session ptr.
|
// Because session references to this object, so we should directly use the session ptr.
|
||||||
ISrsRtcConnection *session_;
|
ISrsRtcConnection *session_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The ip and port of client.
|
// The ip and port of client.
|
||||||
std::string ip_;
|
std::string ip_;
|
||||||
int port_;
|
int port_;
|
||||||
|
|
@ -326,7 +339,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// Packet cache.
|
// Packet cache.
|
||||||
char *pkt_;
|
char *pkt_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The shared resource which own this object, we should never free it because it's managed by shared ptr.
|
// The shared resource which own this object, we should never free it because it's managed by shared ptr.
|
||||||
SrsSharedResource<ISrsRtcTcpConn> *wrapper_;
|
SrsSharedResource<ISrsRtcTcpConn> *wrapper_;
|
||||||
// The owner coroutine, allow user to interrupt the loop.
|
// The owner coroutine, allow user to interrupt the loop.
|
||||||
|
|
@ -334,7 +348,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
ISrsContextIdSetter *owner_cid_;
|
ISrsContextIdSetter *owner_cid_;
|
||||||
SrsContextId cid_;
|
SrsContextId cid_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
void setup();
|
void setup();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -364,7 +379,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_cycle();
|
virtual srs_error_t do_cycle();
|
||||||
srs_error_t handshake();
|
srs_error_t handshake();
|
||||||
srs_error_t read_packet(char *pkt, int *nb_pkt);
|
srs_error_t read_packet(char *pkt, int *nb_pkt);
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,8 @@ class SrsRtcBlackhole
|
||||||
public:
|
public:
|
||||||
bool blackhole_;
|
bool blackhole_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
sockaddr_in *blackhole_addr_;
|
sockaddr_in *blackhole_addr_;
|
||||||
srs_netfd_t blackhole_stfd_;
|
srs_netfd_t blackhole_stfd_;
|
||||||
|
|
||||||
|
|
@ -100,7 +101,8 @@ extern std::string srs_dns_resolve(std::string host, int &family);
|
||||||
// RTC session manager to handle WebRTC session lifecycle and management.
|
// RTC session manager to handle WebRTC session lifecycle and management.
|
||||||
class SrsRtcSessionManager : public ISrsExecRtcAsyncTask
|
class SrsRtcSessionManager : public ISrsExecRtcAsyncTask
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsResourceManager *conn_manager_;
|
ISrsResourceManager *conn_manager_;
|
||||||
ISrsStreamPublishTokenManager *stream_publish_tokens_;
|
ISrsStreamPublishTokenManager *stream_publish_tokens_;
|
||||||
ISrsRtcSourceManager *rtc_sources_;
|
ISrsRtcSourceManager *rtc_sources_;
|
||||||
|
|
@ -108,7 +110,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// WebRTC async call worker for non-blocking operations.
|
// WebRTC async call worker for non-blocking operations.
|
||||||
SrsAsyncCallWorker *rtc_async_;
|
SrsAsyncCallWorker *rtc_async_;
|
||||||
|
|
||||||
|
|
@ -123,7 +126,8 @@ public:
|
||||||
virtual ISrsRtcConnection *find_rtc_session_by_username(const std::string &ufrag);
|
virtual ISrsRtcConnection *find_rtc_session_by_username(const std::string &ufrag);
|
||||||
virtual srs_error_t create_rtc_session(SrsRtcUserConfig *ruc, SrsSdp &local_sdp, ISrsRtcConnection **psession);
|
virtual srs_error_t create_rtc_session(SrsRtcUserConfig *ruc, SrsSdp &local_sdp, ISrsRtcConnection **psession);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_create_rtc_session(SrsRtcUserConfig *ruc, SrsSdp &local_sdp, ISrsRtcConnection *session);
|
virtual srs_error_t do_create_rtc_session(SrsRtcUserConfig *ruc, SrsSdp &local_sdp, ISrsRtcConnection *session);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -119,11 +119,13 @@ public:
|
||||||
// The RTC stream consumer, consume packets from RTC stream source.
|
// The RTC stream consumer, consume packets from RTC stream source.
|
||||||
class SrsRtcConsumer : public ISrsRtcConsumer
|
class SrsRtcConsumer : public ISrsRtcConsumer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Because source references to this object, so we should directly use the source ptr.
|
// Because source references to this object, so we should directly use the source ptr.
|
||||||
ISrsRtcSourceForConsumer *source_;
|
ISrsRtcSourceForConsumer *source_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::vector<SrsRtpPacket *> queue_;
|
std::vector<SrsRtpPacket *> queue_;
|
||||||
// when source id changed, notice all consumers
|
// when source id changed, notice all consumers
|
||||||
bool should_update_source_id_;
|
bool should_update_source_id_;
|
||||||
|
|
@ -132,7 +134,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
bool mw_waiting_;
|
bool mw_waiting_;
|
||||||
int mw_min_msgs_;
|
int mw_min_msgs_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The callback for stream change event.
|
// The callback for stream change event.
|
||||||
ISrsRtcSourceChangeCallback *handler_;
|
ISrsRtcSourceChangeCallback *handler_;
|
||||||
|
|
||||||
|
|
@ -172,7 +175,8 @@ public:
|
||||||
// The RTC source manager.
|
// The RTC source manager.
|
||||||
class SrsRtcSourceManager : public ISrsRtcSourceManager, public ISrsHourGlassHandler
|
class SrsRtcSourceManager : public ISrsRtcSourceManager, public ISrsHourGlassHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_mutex_t lock_;
|
srs_mutex_t lock_;
|
||||||
std::map<std::string, SrsSharedPtr<SrsRtcSource> > pool_;
|
std::map<std::string, SrsSharedPtr<SrsRtcSource> > pool_;
|
||||||
SrsHourGlass *timer_;
|
SrsHourGlass *timer_;
|
||||||
|
|
@ -184,7 +188,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t initialize();
|
virtual srs_error_t initialize();
|
||||||
// interface ISrsHourGlassHandler
|
// interface ISrsHourGlassHandler
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t setup_ticks();
|
virtual srs_error_t setup_ticks();
|
||||||
virtual srs_error_t notify(int event, srs_utime_t interval, srs_utime_t tick);
|
virtual srs_error_t notify(int event, srs_utime_t interval, srs_utime_t tick);
|
||||||
|
|
||||||
|
|
@ -233,11 +238,13 @@ public:
|
||||||
// A Source is a stream, to publish and to play with, binding to SrsRtcPublishStream and SrsRtcPlayStream.
|
// A Source is a stream, to publish and to play with, binding to SrsRtcPublishStream and SrsRtcPlayStream.
|
||||||
class SrsRtcSource : public ISrsRtpTarget, public ISrsFastTimerHandler, public ISrsRtcSourceForConsumer
|
class SrsRtcSource : public ISrsRtpTarget, public ISrsFastTimerHandler, public ISrsRtcSourceForConsumer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The RTP bridge, convert RTP packets to other protocols.
|
// The RTP bridge, convert RTP packets to other protocols.
|
||||||
ISrsRtcBridge *rtc_bridge_;
|
ISrsRtcBridge *rtc_bridge_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Circuit breaker for protecting server resources.
|
// Circuit breaker for protecting server resources.
|
||||||
ISrsCircuitBreaker *circuit_breaker_;
|
ISrsCircuitBreaker *circuit_breaker_;
|
||||||
// For publish, it's the publish client id.
|
// For publish, it's the publish client id.
|
||||||
|
|
@ -252,9 +259,11 @@ SRS_DECLARE_PRIVATE:
|
||||||
// Steam description for this steam.
|
// Steam description for this steam.
|
||||||
SrsRtcSourceDescription *stream_desc_;
|
SrsRtcSourceDescription *stream_desc_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// To delivery stream to clients.
|
// To delivery stream to clients.
|
||||||
std::vector<ISrsRtcConsumer *> consumers_;
|
std::vector<ISrsRtcConsumer *>
|
||||||
|
consumers_;
|
||||||
// Whether stream is created, that is, SDP is done.
|
// Whether stream is created, that is, SDP is done.
|
||||||
bool is_created_;
|
bool is_created_;
|
||||||
// Whether stream is delivering data, that is, DTLS is done.
|
// Whether stream is delivering data, that is, DTLS is done.
|
||||||
|
|
@ -262,12 +271,14 @@ SRS_DECLARE_PRIVATE:
|
||||||
// Notify stream event to event handler
|
// Notify stream event to event handler
|
||||||
std::vector<ISrsRtcSourceEventHandler *> event_handlers_;
|
std::vector<ISrsRtcSourceEventHandler *> event_handlers_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The PLI for RTC2RTMP.
|
// The PLI for RTC2RTMP.
|
||||||
srs_utime_t pli_for_rtmp_;
|
srs_utime_t pli_for_rtmp_;
|
||||||
srs_utime_t pli_elapsed_;
|
srs_utime_t pli_elapsed_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The last die time, while die means neither publishers nor players.
|
// The last die time, while die means neither publishers nor players.
|
||||||
srs_utime_t stream_die_at_;
|
srs_utime_t stream_die_at_;
|
||||||
|
|
||||||
|
|
@ -282,16 +293,19 @@ public:
|
||||||
// Whether stream is dead, which is no publisher or player.
|
// Whether stream is dead, which is no publisher or player.
|
||||||
virtual bool stream_is_dead();
|
virtual bool stream_is_dead();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
void init_for_play_before_publishing();
|
void init_for_play_before_publishing();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Update the authentication information in request.
|
// Update the authentication information in request.
|
||||||
virtual void update_auth(ISrsRequest *r);
|
virtual void update_auth(ISrsRequest *r);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The stream source changed.
|
// The stream source changed.
|
||||||
virtual srs_error_t on_source_changed();
|
virtual srs_error_t
|
||||||
|
on_source_changed();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Get current source id.
|
// Get current source id.
|
||||||
|
|
@ -337,7 +351,8 @@ public:
|
||||||
virtual void set_stream_desc(SrsRtcSourceDescription *stream_desc);
|
virtual void set_stream_desc(SrsRtcSourceDescription *stream_desc);
|
||||||
virtual std::vector<SrsRtcTrackDescription *> get_track_desc(std::string type, std::string media_type);
|
virtual std::vector<SrsRtcTrackDescription *> get_track_desc(std::string type, std::string media_type);
|
||||||
// interface ISrsFastTimerHandler
|
// interface ISrsFastTimerHandler
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t on_timer(srs_utime_t interval);
|
srs_error_t on_timer(srs_utime_t interval);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -346,7 +361,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// Convert AV frame to RTC RTP packets.
|
// Convert AV frame to RTC RTP packets.
|
||||||
class SrsRtcRtpBuilder
|
class SrsRtcRtpBuilder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
ISrsRtpTarget *rtp_target_;
|
ISrsRtpTarget *rtp_target_;
|
||||||
// The format, codec information.
|
// The format, codec information.
|
||||||
|
|
@ -356,7 +372,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// The video builder, convert frame to RTP packets.
|
// The video builder, convert frame to RTP packets.
|
||||||
SrsRtpVideoBuilder *video_builder_;
|
SrsRtpVideoBuilder *video_builder_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsAudioCodecId latest_codec_;
|
SrsAudioCodecId latest_codec_;
|
||||||
ISrsAudioTranscoder *codec_;
|
ISrsAudioTranscoder *codec_;
|
||||||
bool keep_bframe_;
|
bool keep_bframe_;
|
||||||
|
|
@ -364,11 +381,13 @@ SRS_DECLARE_PRIVATE:
|
||||||
bool merge_nalus_;
|
bool merge_nalus_;
|
||||||
uint16_t audio_sequence_;
|
uint16_t audio_sequence_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint32_t audio_ssrc_;
|
uint32_t audio_ssrc_;
|
||||||
uint8_t audio_payload_type_;
|
uint8_t audio_payload_type_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsSharedPtr<SrsRtcSource> source_;
|
SrsSharedPtr<SrsRtcSource> source_;
|
||||||
// Lazy initialization flags
|
// Lazy initialization flags
|
||||||
bool audio_initialized_;
|
bool audio_initialized_;
|
||||||
|
|
@ -378,9 +397,11 @@ public:
|
||||||
SrsRtcRtpBuilder(ISrsRtpTarget *target, SrsSharedPtr<SrsRtcSource> source);
|
SrsRtcRtpBuilder(ISrsRtpTarget *target, SrsSharedPtr<SrsRtcSource> source);
|
||||||
virtual ~SrsRtcRtpBuilder();
|
virtual ~SrsRtcRtpBuilder();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Lazy initialization methods
|
// Lazy initialization methods
|
||||||
srs_error_t initialize_audio_track(SrsAudioCodecId codec);
|
srs_error_t
|
||||||
|
initialize_audio_track(SrsAudioCodecId codec);
|
||||||
srs_error_t initialize_video_track(SrsVideoCodecId codec);
|
srs_error_t initialize_video_track(SrsVideoCodecId codec);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -389,18 +410,22 @@ public:
|
||||||
virtual void on_unpublish();
|
virtual void on_unpublish();
|
||||||
virtual srs_error_t on_frame(SrsMediaPacket *frame);
|
virtual srs_error_t on_frame(SrsMediaPacket *frame);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t on_audio(SrsMediaPacket *msg);
|
virtual srs_error_t on_audio(SrsMediaPacket *msg);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t init_codec(SrsAudioCodecId codec);
|
srs_error_t init_codec(SrsAudioCodecId codec);
|
||||||
srs_error_t transcode(SrsParsedAudioPacket *audio);
|
srs_error_t transcode(SrsParsedAudioPacket *audio);
|
||||||
srs_error_t package_opus(SrsParsedAudioPacket *audio, SrsRtpPacket *pkt);
|
srs_error_t package_opus(SrsParsedAudioPacket *audio, SrsRtpPacket *pkt);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t on_video(SrsMediaPacket *msg);
|
virtual srs_error_t on_video(SrsMediaPacket *msg);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t filter(SrsMediaPacket *msg, SrsFormat *format, bool &has_idr, std::vector<SrsNaluSample *> &samples);
|
srs_error_t filter(SrsMediaPacket *msg, SrsFormat *format, bool &has_idr, std::vector<SrsNaluSample *> &samples);
|
||||||
srs_error_t package_stap_a(SrsMediaPacket *msg, SrsRtpPacket *pkt);
|
srs_error_t package_stap_a(SrsMediaPacket *msg, SrsRtpPacket *pkt);
|
||||||
srs_error_t package_nalus(SrsMediaPacket *msg, const std::vector<SrsNaluSample *> &samples, std::vector<SrsRtpPacket *> &pkts);
|
srs_error_t package_nalus(SrsMediaPacket *msg, const std::vector<SrsNaluSample *> &samples, std::vector<SrsRtpPacket *> &pkts);
|
||||||
|
|
@ -413,7 +438,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// TODO: Maybe should use SrsRtpRingBuffer?
|
// TODO: Maybe should use SrsRtpRingBuffer?
|
||||||
class SrsRtcFrameBuilderVideoPacketCache
|
class SrsRtcFrameBuilderVideoPacketCache
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
const static uint16_t cache_size_ = 512;
|
const static uint16_t cache_size_ = 512;
|
||||||
struct RtcPacketCache {
|
struct RtcPacketCache {
|
||||||
bool in_use_;
|
bool in_use_;
|
||||||
|
|
@ -441,7 +467,8 @@ public:
|
||||||
// Check if frame is complete by verifying FU-A start/end fragment counts match
|
// Check if frame is complete by verifying FU-A start/end fragment counts match
|
||||||
bool check_frame_complete(const uint16_t start, const uint16_t end);
|
bool check_frame_complete(const uint16_t start, const uint16_t end);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool is_slot_in_use(uint16_t sequence_number);
|
bool is_slot_in_use(uint16_t sequence_number);
|
||||||
uint32_t get_rtp_timestamp(uint16_t sequence_number);
|
uint32_t get_rtp_timestamp(uint16_t sequence_number);
|
||||||
inline uint16_t cache_index(uint16_t sequence_number)
|
inline uint16_t cache_index(uint16_t sequence_number)
|
||||||
|
|
@ -453,7 +480,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// Video frame detector for managing frame boundaries and packet loss detection
|
// Video frame detector for managing frame boundaries and packet loss detection
|
||||||
class SrsRtcFrameBuilderVideoFrameDetector
|
class SrsRtcFrameBuilderVideoFrameDetector
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsRtcFrameBuilderVideoPacketCache *video_cache_;
|
SrsRtcFrameBuilderVideoPacketCache *video_cache_;
|
||||||
uint16_t header_sn_;
|
uint16_t header_sn_;
|
||||||
uint16_t lost_sn_;
|
uint16_t lost_sn_;
|
||||||
|
|
@ -474,9 +502,11 @@ public:
|
||||||
// Audio packet cache for RTP packet jitter buffer management
|
// Audio packet cache for RTP packet jitter buffer management
|
||||||
class SrsRtcFrameBuilderAudioPacketCache
|
class SrsRtcFrameBuilderAudioPacketCache
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Audio jitter buffer, map sequence number to packet
|
// Audio jitter buffer, map sequence number to packet
|
||||||
std::map<uint16_t, SrsRtpPacket *> audio_buffer_;
|
std::map<uint16_t, SrsRtpPacket *>
|
||||||
|
audio_buffer_;
|
||||||
// Last processed sequence number
|
// Last processed sequence number
|
||||||
uint16_t last_audio_seq_num_;
|
uint16_t last_audio_seq_num_;
|
||||||
// Last time we processed the jitter buffer
|
// Last time we processed the jitter buffer
|
||||||
|
|
@ -503,24 +533,29 @@ public:
|
||||||
// Collect and build WebRTC RTP packets to AV frames.
|
// Collect and build WebRTC RTP packets to AV frames.
|
||||||
class SrsRtcFrameBuilder
|
class SrsRtcFrameBuilder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsFrameTarget *frame_target_;
|
ISrsFrameTarget *frame_target_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool is_first_audio_;
|
bool is_first_audio_;
|
||||||
ISrsAudioTranscoder *audio_transcoder_;
|
ISrsAudioTranscoder *audio_transcoder_;
|
||||||
SrsVideoCodecId video_codec_;
|
SrsVideoCodecId video_codec_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsRtcFrameBuilderAudioPacketCache *audio_cache_;
|
SrsRtcFrameBuilderAudioPacketCache *audio_cache_;
|
||||||
SrsRtcFrameBuilderVideoPacketCache *video_cache_;
|
SrsRtcFrameBuilderVideoPacketCache *video_cache_;
|
||||||
SrsRtcFrameBuilderVideoFrameDetector *frame_detector_;
|
SrsRtcFrameBuilderVideoFrameDetector *frame_detector_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The state for timestamp sync state. -1 for init. 0 not sync. 1 sync.
|
// The state for timestamp sync state. -1 for init. 0 not sync. 1 sync.
|
||||||
int sync_state_;
|
int sync_state_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// For OBS WHIP, send (VPS/)SPS/PPS in dedicated RTP packet.
|
// For OBS WHIP, send (VPS/)SPS/PPS in dedicated RTP packet.
|
||||||
SrsRtpPacket *obs_whip_vps_;
|
SrsRtpPacket *obs_whip_vps_;
|
||||||
SrsRtpPacket *obs_whip_sps_;
|
SrsRtpPacket *obs_whip_sps_;
|
||||||
|
|
@ -536,12 +571,14 @@ public:
|
||||||
virtual void on_unpublish();
|
virtual void on_unpublish();
|
||||||
virtual srs_error_t on_rtp(SrsRtpPacket *pkt);
|
virtual srs_error_t on_rtp(SrsRtpPacket *pkt);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t packet_audio(SrsRtpPacket *pkt);
|
srs_error_t packet_audio(SrsRtpPacket *pkt);
|
||||||
srs_error_t transcode_audio(SrsRtpPacket *pkt);
|
srs_error_t transcode_audio(SrsRtpPacket *pkt);
|
||||||
void packet_aac(SrsRtmpCommonMessage *audio, char *data, int len, uint32_t pts, bool is_header);
|
void packet_aac(SrsRtmpCommonMessage *audio, char *data, int len, uint32_t pts, bool is_header);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t packet_video(SrsRtpPacket *pkt);
|
srs_error_t packet_video(SrsRtpPacket *pkt);
|
||||||
srs_error_t packet_video_key_frame(SrsRtpPacket *pkt);
|
srs_error_t packet_video_key_frame(SrsRtpPacket *pkt);
|
||||||
srs_error_t packet_sequence_header_avc(SrsRtpPacket *pkt);
|
srs_error_t packet_sequence_header_avc(SrsRtpPacket *pkt);
|
||||||
|
|
@ -549,7 +586,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
srs_error_t packet_sequence_header_hevc(SrsRtpPacket *pkt);
|
srs_error_t packet_sequence_header_hevc(SrsRtpPacket *pkt);
|
||||||
srs_error_t do_packet_sequence_header_hevc(SrsRtpPacket *pkt, SrsNaluSample *vps, SrsNaluSample *sps, SrsNaluSample *pps);
|
srs_error_t do_packet_sequence_header_hevc(SrsRtpPacket *pkt, SrsNaluSample *vps, SrsNaluSample *sps, SrsNaluSample *pps);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t packet_video_rtmp(const uint16_t start, const uint16_t end);
|
srs_error_t packet_video_rtmp(const uint16_t start, const uint16_t end);
|
||||||
int calculate_packet_payload_size(SrsRtpPacket *pkt);
|
int calculate_packet_payload_size(SrsRtpPacket *pkt);
|
||||||
void write_packet_payload_to_buffer(SrsRtpPacket *pkt, SrsBuffer &payload, int &nalu_len);
|
void write_packet_payload_to_buffer(SrsRtpPacket *pkt, SrsBuffer &payload, int &nalu_len);
|
||||||
|
|
@ -571,7 +609,8 @@ public:
|
||||||
|
|
||||||
std::vector<std::string> rtcp_fbs_;
|
std::vector<std::string> rtcp_fbs_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The cached codec ID, corresponding to name_.
|
// The cached codec ID, corresponding to name_.
|
||||||
// For video, you can convert it to type SrsVideoCodecId
|
// For video, you can convert it to type SrsVideoCodecId
|
||||||
// For audio, you can convert it to type SrsAudioCodecId
|
// For audio, you can convert it to type SrsAudioCodecId
|
||||||
|
|
@ -777,19 +816,23 @@ public:
|
||||||
// The RTC receive track.
|
// The RTC receive track.
|
||||||
class SrsRtcRecvTrack
|
class SrsRtcRecvTrack
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
SrsRtcTrackDescription *track_desc_;
|
SrsRtcTrackDescription *track_desc_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
ISrsRtcPacketReceiver *receiver_;
|
ISrsRtcPacketReceiver *receiver_;
|
||||||
SrsRtpRingBuffer *rtp_queue_;
|
SrsRtpRingBuffer *rtp_queue_;
|
||||||
SrsRtpNackForReceiver *nack_receiver_;
|
SrsRtpNackForReceiver *nack_receiver_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// By config, whether no copy.
|
// By config, whether no copy.
|
||||||
bool nack_no_copy_;
|
bool nack_no_copy_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
// Latest sender report ntp and rtp time.
|
// Latest sender report ntp and rtp time.
|
||||||
SrsNtp last_sender_report_ntp_;
|
SrsNtp last_sender_report_ntp_;
|
||||||
int64_t last_sender_report_rtp_time_;
|
int64_t last_sender_report_rtp_time_;
|
||||||
|
|
@ -828,7 +871,8 @@ public:
|
||||||
virtual srs_error_t on_rtp(SrsSharedPtr<SrsRtcSource> &source, SrsRtpPacket *pkt) = 0;
|
virtual srs_error_t on_rtp(SrsSharedPtr<SrsRtcSource> &source, SrsRtpPacket *pkt) = 0;
|
||||||
virtual srs_error_t check_send_nacks() = 0;
|
virtual srs_error_t check_send_nacks() = 0;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t do_check_send_nacks(uint32_t &timeout_nacks);
|
virtual srs_error_t do_check_send_nacks(uint32_t &timeout_nacks);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -864,12 +908,14 @@ public:
|
||||||
template <typename T, typename ST>
|
template <typename T, typename ST>
|
||||||
class SrsRtcJitter
|
class SrsRtcJitter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ST threshold_;
|
ST threshold_;
|
||||||
typedef ST (*PFN)(const T &, const T &);
|
typedef ST (*PFN)(const T &, const T &);
|
||||||
PFN distance_;
|
PFN distance_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The value about packet.
|
// The value about packet.
|
||||||
T pkt_base_;
|
T pkt_base_;
|
||||||
T pkt_last_;
|
T pkt_last_;
|
||||||
|
|
@ -926,7 +972,8 @@ public:
|
||||||
// For RTC timestamp jitter.
|
// For RTC timestamp jitter.
|
||||||
class SrsRtcTsJitter
|
class SrsRtcTsJitter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsRtcJitter<uint32_t, int32_t> *jitter_;
|
SrsRtcJitter<uint32_t, int32_t> *jitter_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -940,7 +987,8 @@ public:
|
||||||
// For RTC sequence jitter.
|
// For RTC sequence jitter.
|
||||||
class SrsRtcSeqJitter
|
class SrsRtcSeqJitter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsRtcJitter<uint16_t, int16_t> *jitter_;
|
SrsRtcJitter<uint16_t, int16_t> *jitter_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -968,18 +1016,21 @@ public:
|
||||||
// send track description
|
// send track description
|
||||||
SrsRtcTrackDescription *track_desc_;
|
SrsRtcTrackDescription *track_desc_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
// The owner connection for this track.
|
// The owner connection for this track.
|
||||||
ISrsRtcPacketSender *sender_;
|
ISrsRtcPacketSender *sender_;
|
||||||
// NACK ARQ ring buffer.
|
// NACK ARQ ring buffer.
|
||||||
SrsRtpRingBuffer *rtp_queue_;
|
SrsRtpRingBuffer *rtp_queue_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
// The jitter to correct ts and sequence number.
|
// The jitter to correct ts and sequence number.
|
||||||
SrsRtcTsJitter *jitter_ts_;
|
SrsRtcTsJitter *jitter_ts_;
|
||||||
SrsRtcSeqJitter *jitter_seq_;
|
SrsRtcSeqJitter *jitter_seq_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// By config, whether no copy.
|
// By config, whether no copy.
|
||||||
bool nack_no_copy_;
|
bool nack_no_copy_;
|
||||||
// The pithy print for special stage.
|
// The pithy print for special stage.
|
||||||
|
|
@ -998,7 +1049,8 @@ public:
|
||||||
bool get_track_status();
|
bool get_track_status();
|
||||||
std::string get_track_id();
|
std::string get_track_id();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
void rebuild_packet(SrsRtpPacket *pkt);
|
void rebuild_packet(SrsRtpPacket *pkt);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -1036,13 +1088,16 @@ public:
|
||||||
|
|
||||||
class SrsRtcSSRCGenerator
|
class SrsRtcSSRCGenerator
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
static SrsRtcSSRCGenerator *instance_;
|
static SrsRtcSSRCGenerator *instance_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint32_t ssrc_num_;
|
uint32_t ssrc_num_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsRtcSSRCGenerator();
|
SrsRtcSSRCGenerator();
|
||||||
virtual ~SrsRtcSSRCGenerator();
|
virtual ~SrsRtcSSRCGenerator();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,14 +56,16 @@ class ISrsSecurity;
|
||||||
// The simple rtmp client for SRS.
|
// The simple rtmp client for SRS.
|
||||||
class SrsSimpleRtmpClient : public SrsBasicRtmpClient
|
class SrsSimpleRtmpClient : public SrsBasicRtmpClient
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SrsSimpleRtmpClient(std::string u, srs_utime_t ctm, srs_utime_t stm);
|
SrsSimpleRtmpClient(std::string u, srs_utime_t ctm, srs_utime_t stm);
|
||||||
virtual ~SrsSimpleRtmpClient();
|
virtual ~SrsSimpleRtmpClient();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t connect_app();
|
virtual srs_error_t connect_app();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -106,7 +108,8 @@ public:
|
||||||
// The base transport layer for RTMP connections over plain TCP.
|
// The base transport layer for RTMP connections over plain TCP.
|
||||||
class SrsRtmpTransport : public ISrsRtmpTransport
|
class SrsRtmpTransport : public ISrsRtmpTransport
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
srs_netfd_t stfd_;
|
srs_netfd_t stfd_;
|
||||||
SrsTcpConnection *skt_;
|
SrsTcpConnection *skt_;
|
||||||
|
|
||||||
|
|
@ -135,10 +138,12 @@ public:
|
||||||
// The SSL/TLS transport layer for RTMPS connections.
|
// The SSL/TLS transport layer for RTMPS connections.
|
||||||
class SrsRtmpsTransport : public SrsRtmpTransport
|
class SrsRtmpsTransport : public SrsRtmpTransport
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsSslConnection *ssl_;
|
SrsSslConnection *ssl_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -164,7 +169,8 @@ class SrsRtmpConn : public ISrsConnection, // It's a resource.
|
||||||
// For the thread to directly access any field of connection.
|
// For the thread to directly access any field of connection.
|
||||||
friend class SrsPublishRecvThread;
|
friend class SrsPublishRecvThread;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsResourceManager *manager_;
|
ISrsResourceManager *manager_;
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsStreamPublishTokenManager *stream_publish_tokens_;
|
ISrsStreamPublishTokenManager *stream_publish_tokens_;
|
||||||
|
|
@ -177,7 +183,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
ISrsRtspSourceManager *rtsp_sources_;
|
ISrsRtspSourceManager *rtsp_sources_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRtmpServer *rtmp_;
|
ISrsRtmpServer *rtmp_;
|
||||||
SrsRefer *refer_;
|
SrsRefer *refer_;
|
||||||
SrsBandwidth *bandwidth_;
|
SrsBandwidth *bandwidth_;
|
||||||
|
|
@ -205,7 +212,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// About the rtmp client.
|
// About the rtmp client.
|
||||||
SrsClientInfo *info_;
|
SrsClientInfo *info_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRtmpTransport *transport_;
|
ISrsRtmpTransport *transport_;
|
||||||
// Each connection start a green thread,
|
// Each connection start a green thread,
|
||||||
// when thread stop, the connection will be delete by server.
|
// when thread stop, the connection will be delete by server.
|
||||||
|
|
@ -228,15 +236,18 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual std::string desc();
|
virtual std::string desc();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t do_cycle();
|
virtual srs_error_t do_cycle();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ISrsKbpsDelta *delta();
|
virtual ISrsKbpsDelta *delta();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// When valid and connected to vhost/app, service the client.
|
// When valid and connected to vhost/app, service the client.
|
||||||
virtual srs_error_t service_cycle();
|
virtual srs_error_t
|
||||||
|
service_cycle();
|
||||||
// The stream(play/publish) service cycle, identify client first.
|
// The stream(play/publish) service cycle, identify client first.
|
||||||
virtual srs_error_t stream_service_cycle();
|
virtual srs_error_t stream_service_cycle();
|
||||||
virtual srs_error_t check_vhost(bool try_default_vhost);
|
virtual srs_error_t check_vhost(bool try_default_vhost);
|
||||||
|
|
@ -251,16 +262,20 @@ SRS_DECLARE_PRIVATE:
|
||||||
virtual srs_error_t process_play_control_msg(SrsLiveConsumer *consumer, SrsRtmpCommonMessage *msg);
|
virtual srs_error_t process_play_control_msg(SrsLiveConsumer *consumer, SrsRtmpCommonMessage *msg);
|
||||||
virtual void set_sock_options();
|
virtual void set_sock_options();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t check_edge_token_traverse_auth();
|
virtual srs_error_t check_edge_token_traverse_auth();
|
||||||
virtual srs_error_t do_token_traverse_auth(SrsRtmpClient *client);
|
virtual srs_error_t do_token_traverse_auth(SrsRtmpClient *client);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// When the connection disconnect, call this method.
|
// When the connection disconnect, call this method.
|
||||||
// e.g. log msg of connection and report to other system.
|
// e.g. log msg of connection and report to other system.
|
||||||
virtual srs_error_t on_disconnect();
|
virtual srs_error_t
|
||||||
|
on_disconnect();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t http_hooks_on_connect();
|
virtual srs_error_t http_hooks_on_connect();
|
||||||
virtual void http_hooks_on_close();
|
virtual void http_hooks_on_close();
|
||||||
virtual srs_error_t http_hooks_on_publish();
|
virtual srs_error_t http_hooks_on_publish();
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,8 @@ int srs_time_jitter_string2int(std::string time_jitter);
|
||||||
// Time jitter detect and correct, to ensure the rtmp stream is monotonically.
|
// Time jitter detect and correct, to ensure the rtmp stream is monotonically.
|
||||||
class SrsRtmpJitter
|
class SrsRtmpJitter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
int64_t last_pkt_time_;
|
int64_t last_pkt_time_;
|
||||||
int64_t last_pkt_correct_time_;
|
int64_t last_pkt_correct_time_;
|
||||||
|
|
||||||
|
|
@ -97,7 +98,8 @@ public:
|
||||||
// To alloc and increase fixed space, fast remove and insert for msgs sender.
|
// To alloc and increase fixed space, fast remove and insert for msgs sender.
|
||||||
class SrsFastVector
|
class SrsFastVector
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsMediaPacket **msgs_;
|
SrsMediaPacket **msgs_;
|
||||||
int nb_msgs_;
|
int nb_msgs_;
|
||||||
int count_;
|
int count_;
|
||||||
|
|
@ -140,12 +142,14 @@ public:
|
||||||
// We limit the size in seconds, drop old messages(the whole gop) if full.
|
// We limit the size in seconds, drop old messages(the whole gop) if full.
|
||||||
class SrsMessageQueue : public ISrsMessageQueue
|
class SrsMessageQueue : public ISrsMessageQueue
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The start and end time.
|
// The start and end time.
|
||||||
srs_utime_t av_start_time_;
|
srs_utime_t av_start_time_;
|
||||||
srs_utime_t av_end_time_;
|
srs_utime_t av_end_time_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Whether do logging when shrinking.
|
// Whether do logging when shrinking.
|
||||||
bool _ignore_shrink;
|
bool _ignore_shrink;
|
||||||
// The max queue size, shrink if exceed it.
|
// The max queue size, shrink if exceed it.
|
||||||
|
|
@ -182,10 +186,12 @@ public:
|
||||||
// @remark the atc/tba/tbv/ag are same to SrsLiveConsumer.enqueue().
|
// @remark the atc/tba/tbv/ag are same to SrsLiveConsumer.enqueue().
|
||||||
virtual srs_error_t dump_packets(ISrsLiveConsumer *consumer, bool atc, SrsRtmpJitterAlgorithm ag);
|
virtual srs_error_t dump_packets(ISrsLiveConsumer *consumer, bool atc, SrsRtmpJitterAlgorithm ag);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Remove a gop from the front.
|
// Remove a gop from the front.
|
||||||
// if no iframe found, clear it.
|
// if no iframe found, clear it.
|
||||||
virtual void shrink();
|
virtual void
|
||||||
|
shrink();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// clear all messages in queue.
|
// clear all messages in queue.
|
||||||
|
|
@ -224,11 +230,13 @@ public:
|
||||||
// The consumer for SrsLiveSource, that is a play client.
|
// The consumer for SrsLiveSource, that is a play client.
|
||||||
class SrsLiveConsumer : public ISrsWakable, public ISrsLiveConsumer
|
class SrsLiveConsumer : public ISrsWakable, public ISrsLiveConsumer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Because source references to this object, so we should directly use the source ptr.
|
// Because source references to this object, so we should directly use the source ptr.
|
||||||
ISrsLiveSource *source_;
|
ISrsLiveSource *source_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsRtmpJitter *jitter_;
|
SrsRtmpJitter *jitter_;
|
||||||
SrsMessageQueue *queue_;
|
SrsMessageQueue *queue_;
|
||||||
bool paused_;
|
bool paused_;
|
||||||
|
|
@ -285,7 +293,8 @@ public:
|
||||||
// To enable it to fast startup.
|
// To enable it to fast startup.
|
||||||
class SrsGopCache
|
class SrsGopCache
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// if disabled the gop cache,
|
// if disabled the gop cache,
|
||||||
// The client will wait for the next keyframe for h264,
|
// The client will wait for the next keyframe for h264,
|
||||||
// and will be black-screen.
|
// and will be black-screen.
|
||||||
|
|
@ -360,7 +369,8 @@ public:
|
||||||
// The mix queue to correct the timestamp for mix_correct algorithm.
|
// The mix queue to correct the timestamp for mix_correct algorithm.
|
||||||
class SrsMixQueue
|
class SrsMixQueue
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint32_t nb_videos_;
|
uint32_t nb_videos_;
|
||||||
uint32_t nb_audios_;
|
uint32_t nb_audios_;
|
||||||
std::multimap<int64_t, SrsMediaPacket *> msgs_;
|
std::multimap<int64_t, SrsMediaPacket *> msgs_;
|
||||||
|
|
@ -411,20 +421,24 @@ public:
|
||||||
// they are meanless for edge server.
|
// they are meanless for edge server.
|
||||||
class SrsOriginHub : public ISrsReloadHandler, public ISrsOriginHub
|
class SrsOriginHub : public ISrsReloadHandler, public ISrsOriginHub
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
ISrsHttpHooks *hooks_;
|
ISrsHttpHooks *hooks_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Because source references to this object, so we should directly use the source ptr.
|
// Because source references to this object, so we should directly use the source ptr.
|
||||||
ISrsLiveSource *source_;
|
ISrsLiveSource *source_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
bool is_active_;
|
bool is_active_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// hls handler.
|
// hls handler.
|
||||||
ISrsHls *hls_;
|
ISrsHls *hls_;
|
||||||
// The DASH encoder.
|
// The DASH encoder.
|
||||||
|
|
@ -484,7 +498,8 @@ public:
|
||||||
// For the SrsHls to callback to request the sequence headers.
|
// For the SrsHls to callback to request the sequence headers.
|
||||||
virtual srs_error_t on_hls_request_sh();
|
virtual srs_error_t on_hls_request_sh();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t create_forwarders();
|
virtual srs_error_t create_forwarders();
|
||||||
virtual srs_error_t create_backend_forwarders(bool &applied);
|
virtual srs_error_t create_backend_forwarders(bool &applied);
|
||||||
virtual void destroy_forwarders();
|
virtual void destroy_forwarders();
|
||||||
|
|
@ -494,7 +509,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// This class cache and update the meta.
|
// This class cache and update the meta.
|
||||||
class SrsMetaCache
|
class SrsMetaCache
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The cached metadata, FLV script data tag.
|
// The cached metadata, FLV script data tag.
|
||||||
SrsMediaPacket *meta_;
|
SrsMediaPacket *meta_;
|
||||||
// The cached video sequence header, for example, sps/pps for h.264.
|
// The cached video sequence header, for example, sps/pps for h.264.
|
||||||
|
|
@ -572,10 +588,12 @@ public:
|
||||||
// The source manager to create and refresh all stream sources.
|
// The source manager to create and refresh all stream sources.
|
||||||
class SrsLiveSourceManager : public ISrsHourGlassHandler, public ISrsLiveSourceManager
|
class SrsLiveSourceManager : public ISrsHourGlassHandler, public ISrsLiveSourceManager
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_mutex_t lock_;
|
srs_mutex_t lock_;
|
||||||
std::map<std::string, SrsSharedPtr<SrsLiveSource> > pool_;
|
std::map<std::string, SrsSharedPtr<SrsLiveSource> > pool_;
|
||||||
ISrsHourGlass *timer_;
|
ISrsHourGlass *timer_;
|
||||||
|
|
@ -600,7 +618,8 @@ public:
|
||||||
// dispose and cycle all sources.
|
// dispose and cycle all sources.
|
||||||
virtual void dispose();
|
virtual void dispose();
|
||||||
// interface ISrsHourGlassHandler
|
// interface ISrsHourGlassHandler
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t setup_ticks();
|
virtual srs_error_t setup_ticks();
|
||||||
virtual srs_error_t notify(int event, srs_utime_t interval, srs_utime_t tick);
|
virtual srs_error_t notify(int event, srs_utime_t interval, srs_utime_t tick);
|
||||||
|
|
||||||
|
|
@ -641,13 +660,15 @@ public:
|
||||||
// The live streaming source.
|
// The live streaming source.
|
||||||
class SrsLiveSource : public ISrsReloadHandler, public ISrsFrameTarget, public ISrsLiveSource
|
class SrsLiveSource : public ISrsReloadHandler, public ISrsFrameTarget, public ISrsLiveSource
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
ISrsLiveSourceHandler *handler_;
|
ISrsLiveSourceHandler *handler_;
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// For publish, it's the publish client id.
|
// For publish, it's the publish client id.
|
||||||
// For edge, it's the edge ingest id.
|
// For edge, it's the edge ingest id.
|
||||||
// when source id changed, for example, the edge reconnect,
|
// when source id changed, for example, the edge reconnect,
|
||||||
|
|
@ -688,7 +709,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// The format, codec information.
|
// The format, codec information.
|
||||||
SrsRtmpFormat *format_;
|
SrsRtmpFormat *format_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Whether source is avaiable for publishing.
|
// Whether source is avaiable for publishing.
|
||||||
bool can_publish_;
|
bool can_publish_;
|
||||||
// The last die time, while die means neither publishers nor players.
|
// The last die time, while die means neither publishers nor players.
|
||||||
|
|
@ -738,14 +760,16 @@ public:
|
||||||
virtual srs_error_t on_audio(SrsRtmpCommonMessage *audio);
|
virtual srs_error_t on_audio(SrsRtmpCommonMessage *audio);
|
||||||
srs_error_t on_frame(SrsMediaPacket *msg);
|
srs_error_t on_frame(SrsMediaPacket *msg);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t on_audio_imp(SrsMediaPacket *audio);
|
virtual srs_error_t on_audio_imp(SrsMediaPacket *audio);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// TODO: FIXME: Use SrsMediaPacket instead.
|
// TODO: FIXME: Use SrsMediaPacket instead.
|
||||||
virtual srs_error_t on_video(SrsRtmpCommonMessage *video);
|
virtual srs_error_t on_video(SrsRtmpCommonMessage *video);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t on_video_imp(SrsMediaPacket *video);
|
virtual srs_error_t on_video_imp(SrsMediaPacket *video);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -60,24 +60,28 @@ public:
|
||||||
// A RTSP play stream, client pull and play stream from SRS.
|
// A RTSP play stream, client pull and play stream from SRS.
|
||||||
class SrsRtspPlayStream : public ISrsRtspPlayStream, public ISrsCoroutineHandler, public ISrsRtcSourceChangeCallback
|
class SrsRtspPlayStream : public ISrsRtspPlayStream, public ISrsCoroutineHandler, public ISrsRtcSourceChangeCallback
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
ISrsRtspSourceManager *rtsp_sources_;
|
ISrsRtspSourceManager *rtsp_sources_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsContextId cid_;
|
SrsContextId cid_;
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
ISrsRtspConnection *session_;
|
ISrsRtspConnection *session_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
SrsSharedPtr<SrsRtspSource> source_;
|
SrsSharedPtr<SrsRtspSource> source_;
|
||||||
// key: publish_ssrc, value: send track to process rtp/rtcp
|
// key: publish_ssrc, value: send track to process rtp/rtcp
|
||||||
std::map<uint32_t, ISrsRtspSendTrack *> audio_tracks_;
|
std::map<uint32_t, ISrsRtspSendTrack *> audio_tracks_;
|
||||||
std::map<uint32_t, ISrsRtspSendTrack *> video_tracks_;
|
std::map<uint32_t, ISrsRtspSendTrack *> video_tracks_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Fast cache for tracks.
|
// Fast cache for tracks.
|
||||||
uint32_t cache_ssrc0_;
|
uint32_t cache_ssrc0_;
|
||||||
uint32_t cache_ssrc1_;
|
uint32_t cache_ssrc1_;
|
||||||
|
|
@ -86,7 +90,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
ISrsRtspSendTrack *cache_track1_;
|
ISrsRtspSendTrack *cache_track1_;
|
||||||
ISrsRtspSendTrack *cache_track2_;
|
ISrsRtspSendTrack *cache_track2_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Whether player started.
|
// Whether player started.
|
||||||
bool is_started;
|
bool is_started;
|
||||||
|
|
||||||
|
|
@ -110,7 +115,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t send_packet(SrsRtpPacket *&pkt);
|
srs_error_t send_packet(SrsRtpPacket *&pkt);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -136,17 +142,20 @@ class SrsRtspConnection : public ISrsResource, // It's a resource.
|
||||||
public ISrsStartable,
|
public ISrsStartable,
|
||||||
public ISrsRtspConnection
|
public ISrsRtspConnection
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRtspSourceManager *rtsp_sources_;
|
ISrsRtspSourceManager *rtsp_sources_;
|
||||||
ISrsResourceManager *rtsp_manager_;
|
ISrsResourceManager *rtsp_manager_;
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsHttpHooks *hooks_;
|
ISrsHttpHooks *hooks_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool disposing_;
|
bool disposing_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// TODO: FIXME: Rename it.
|
// TODO: FIXME: Rename it.
|
||||||
// The timeout of session, keep alive by STUN ping pong.
|
// The timeout of session, keep alive by STUN ping pong.
|
||||||
srs_utime_t session_timeout;
|
srs_utime_t session_timeout;
|
||||||
|
|
@ -191,7 +200,8 @@ public:
|
||||||
public:
|
public:
|
||||||
ISrsKbpsDelta *delta();
|
ISrsKbpsDelta *delta();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_describe(SrsRtspRequest *req, std::string &sdp);
|
virtual srs_error_t do_describe(SrsRtspRequest *req, std::string &sdp);
|
||||||
virtual srs_error_t do_setup(SrsRtspRequest *req, uint32_t *ssrc);
|
virtual srs_error_t do_setup(SrsRtspRequest *req, uint32_t *ssrc);
|
||||||
virtual srs_error_t do_play(SrsRtspRequest *req, SrsRtspConnection *conn);
|
virtual srs_error_t do_play(SrsRtspRequest *req, SrsRtspConnection *conn);
|
||||||
|
|
@ -217,7 +227,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t do_cycle();
|
srs_error_t do_cycle();
|
||||||
srs_error_t on_rtsp_request(SrsRtspRequest *req_raw);
|
srs_error_t on_rtsp_request(SrsRtspRequest *req_raw);
|
||||||
|
|
||||||
|
|
@ -233,14 +244,16 @@ public:
|
||||||
bool is_alive();
|
bool is_alive();
|
||||||
void alive();
|
void alive();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t http_hooks_on_play(ISrsRequest *req);
|
srs_error_t http_hooks_on_play(ISrsRequest *req);
|
||||||
srs_error_t get_ssrc_by_stream_id(uint32_t stream_id, uint32_t *ssrc);
|
srs_error_t get_ssrc_by_stream_id(uint32_t stream_id, uint32_t *ssrc);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsRtspTcpNetwork : public ISrsStreamWriter
|
class SrsRtspTcpNetwork : public ISrsStreamWriter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsProtocolReadWriter *skt_;
|
ISrsProtocolReadWriter *skt_;
|
||||||
int channel_;
|
int channel_;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,13 @@ class ISrsRtspConnection;
|
||||||
// The RTSP stream consumer, consume packets from RTSP stream source.
|
// The RTSP stream consumer, consume packets from RTSP stream source.
|
||||||
class SrsRtspConsumer
|
class SrsRtspConsumer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Because source references to this object, so we should directly use the source ptr.
|
// Because source references to this object, so we should directly use the source ptr.
|
||||||
SrsRtspSource *source_;
|
SrsRtspSource *source_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::vector<SrsRtpPacket *> queue_;
|
std::vector<SrsRtpPacket *> queue_;
|
||||||
// when source id changed, notice all consumers
|
// when source id changed, notice all consumers
|
||||||
bool should_update_source_id_;
|
bool should_update_source_id_;
|
||||||
|
|
@ -47,7 +49,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
bool mw_waiting_;
|
bool mw_waiting_;
|
||||||
int mw_min_msgs_;
|
int mw_min_msgs_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The callback for stream change event.
|
// The callback for stream change event.
|
||||||
ISrsRtcSourceChangeCallback *handler_;
|
ISrsRtcSourceChangeCallback *handler_;
|
||||||
|
|
||||||
|
|
@ -87,7 +90,8 @@ public:
|
||||||
// The RTSP source manager.
|
// The RTSP source manager.
|
||||||
class SrsRtspSourceManager : public ISrsHourGlassHandler, public ISrsRtspSourceManager
|
class SrsRtspSourceManager : public ISrsHourGlassHandler, public ISrsRtspSourceManager
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_mutex_t lock_;
|
srs_mutex_t lock_;
|
||||||
std::map<std::string, SrsSharedPtr<SrsRtspSource> > pool_;
|
std::map<std::string, SrsSharedPtr<SrsRtspSource> > pool_;
|
||||||
SrsHourGlass *timer_;
|
SrsHourGlass *timer_;
|
||||||
|
|
@ -99,7 +103,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t initialize();
|
virtual srs_error_t initialize();
|
||||||
// interface ISrsHourGlassHandler
|
// interface ISrsHourGlassHandler
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t setup_ticks();
|
virtual srs_error_t setup_ticks();
|
||||||
virtual srs_error_t notify(int event, srs_utime_t interval, srs_utime_t tick);
|
virtual srs_error_t notify(int event, srs_utime_t interval, srs_utime_t tick);
|
||||||
|
|
||||||
|
|
@ -122,11 +127,13 @@ extern SrsResourceManager *_srs_rtsp_manager;
|
||||||
// A Source is a stream, to publish and to play with, binding to SrsRtspPlayStream.
|
// A Source is a stream, to publish and to play with, binding to SrsRtspPlayStream.
|
||||||
class SrsRtspSource : public ISrsRtpTarget
|
class SrsRtspSource : public ISrsRtpTarget
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
ISrsCircuitBreaker *circuit_breaker_;
|
ISrsCircuitBreaker *circuit_breaker_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// For publish, it's the publish client id.
|
// For publish, it's the publish client id.
|
||||||
// For edge, it's the edge ingest id.
|
// For edge, it's the edge ingest id.
|
||||||
// when source id changed, for example, the edge reconnect,
|
// when source id changed, for example, the edge reconnect,
|
||||||
|
|
@ -139,15 +146,18 @@ SRS_DECLARE_PRIVATE:
|
||||||
SrsRtcTrackDescription *audio_desc_;
|
SrsRtcTrackDescription *audio_desc_;
|
||||||
SrsRtcTrackDescription *video_desc_;
|
SrsRtcTrackDescription *video_desc_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// To delivery stream to clients.
|
// To delivery stream to clients.
|
||||||
std::vector<SrsRtspConsumer *> consumers_;
|
std::vector<SrsRtspConsumer *>
|
||||||
|
consumers_;
|
||||||
// Whether stream is created, that is, SDP is done.
|
// Whether stream is created, that is, SDP is done.
|
||||||
bool is_created_;
|
bool is_created_;
|
||||||
// Whether stream is delivering data, that is, DTLS is done.
|
// Whether stream is delivering data, that is, DTLS is done.
|
||||||
bool is_delivering_packets_;
|
bool is_delivering_packets_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The last die time, while die means neither publishers nor players.
|
// The last die time, while die means neither publishers nor players.
|
||||||
srs_utime_t stream_die_at_;
|
srs_utime_t stream_die_at_;
|
||||||
|
|
||||||
|
|
@ -166,9 +176,11 @@ public:
|
||||||
// Update the authentication information in request.
|
// Update the authentication information in request.
|
||||||
virtual void update_auth(ISrsRequest *r);
|
virtual void update_auth(ISrsRequest *r);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The stream source changed.
|
// The stream source changed.
|
||||||
virtual srs_error_t on_source_changed();
|
virtual srs_error_t
|
||||||
|
on_source_changed();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Get current source id.
|
// Get current source id.
|
||||||
|
|
@ -209,10 +221,12 @@ public:
|
||||||
// Convert AV frame to RTSP RTP packets.
|
// Convert AV frame to RTSP RTP packets.
|
||||||
class SrsRtspRtpBuilder
|
class SrsRtspRtpBuilder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
ISrsRtpTarget *rtp_target_;
|
ISrsRtpTarget *rtp_target_;
|
||||||
// The format, codec information.
|
// The format, codec information.
|
||||||
|
|
@ -222,13 +236,15 @@ SRS_DECLARE_PRIVATE:
|
||||||
// The video builder, convert frame to RTP packets.
|
// The video builder, convert frame to RTP packets.
|
||||||
SrsRtpVideoBuilder *video_builder_;
|
SrsRtpVideoBuilder *video_builder_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint16_t audio_sequence_;
|
uint16_t audio_sequence_;
|
||||||
uint32_t audio_ssrc_;
|
uint32_t audio_ssrc_;
|
||||||
uint8_t audio_payload_type_;
|
uint8_t audio_payload_type_;
|
||||||
int audio_sample_rate_;
|
int audio_sample_rate_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsSharedPtr<SrsRtspSource> source_;
|
SrsSharedPtr<SrsRtspSource> source_;
|
||||||
// Lazy initialization flags
|
// Lazy initialization flags
|
||||||
bool audio_initialized_;
|
bool audio_initialized_;
|
||||||
|
|
@ -238,9 +254,11 @@ public:
|
||||||
SrsRtspRtpBuilder(ISrsRtpTarget *target, SrsSharedPtr<SrsRtspSource> source);
|
SrsRtspRtpBuilder(ISrsRtpTarget *target, SrsSharedPtr<SrsRtspSource> source);
|
||||||
virtual ~SrsRtspRtpBuilder();
|
virtual ~SrsRtspRtpBuilder();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Lazy initialization methods
|
// Lazy initialization methods
|
||||||
srs_error_t initialize_audio_track(SrsAudioCodecId codec);
|
srs_error_t
|
||||||
|
initialize_audio_track(SrsAudioCodecId codec);
|
||||||
srs_error_t initialize_video_track(SrsVideoCodecId codec);
|
srs_error_t initialize_video_track(SrsVideoCodecId codec);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -249,16 +267,20 @@ public:
|
||||||
virtual void on_unpublish();
|
virtual void on_unpublish();
|
||||||
virtual srs_error_t on_frame(SrsMediaPacket *frame);
|
virtual srs_error_t on_frame(SrsMediaPacket *frame);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t on_audio(SrsMediaPacket *msg);
|
virtual srs_error_t on_audio(SrsMediaPacket *msg);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t package_aac(SrsParsedAudioPacket *audio, SrsRtpPacket *pkt);
|
srs_error_t package_aac(SrsParsedAudioPacket *audio, SrsRtpPacket *pkt);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t on_video(SrsMediaPacket *msg);
|
virtual srs_error_t on_video(SrsMediaPacket *msg);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t filter(SrsMediaPacket *msg, SrsFormat *format, bool &has_idr, std::vector<SrsNaluSample *> &samples);
|
srs_error_t filter(SrsMediaPacket *msg, SrsFormat *format, bool &has_idr, std::vector<SrsNaluSample *> &samples);
|
||||||
srs_error_t package_stap_a(SrsMediaPacket *msg, SrsRtpPacket *pkt);
|
srs_error_t package_stap_a(SrsMediaPacket *msg, SrsRtpPacket *pkt);
|
||||||
srs_error_t package_nalus(SrsMediaPacket *msg, const std::vector<SrsNaluSample *> &samples, std::vector<SrsRtpPacket *> &pkts);
|
srs_error_t package_nalus(SrsMediaPacket *msg, const std::vector<SrsNaluSample *> &samples, std::vector<SrsRtpPacket *> &pkts);
|
||||||
|
|
@ -286,7 +308,8 @@ public:
|
||||||
// send track description
|
// send track description
|
||||||
SrsRtcTrackDescription *track_desc_;
|
SrsRtcTrackDescription *track_desc_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
// The owner connection for this track.
|
// The owner connection for this track.
|
||||||
ISrsRtspConnection *session_;
|
ISrsRtspConnection *session_;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,8 @@ public:
|
||||||
// @param req the request object of client.
|
// @param req the request object of client.
|
||||||
virtual srs_error_t check(SrsRtmpConnType type, std::string ip, ISrsRequest *req);
|
virtual srs_error_t check(SrsRtmpConnType type, std::string ip, ISrsRequest *req);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_check(SrsConfDirective *rules, SrsRtmpConnType type, std::string ip, ISrsRequest *req);
|
virtual srs_error_t do_check(SrsConfDirective *rules, SrsRtmpConnType type, std::string ip, ISrsRequest *req);
|
||||||
virtual srs_error_t allow_check(SrsConfDirective *rules, SrsRtmpConnType type, std::string ip);
|
virtual srs_error_t allow_check(SrsConfDirective *rules, SrsRtmpConnType type, std::string ip);
|
||||||
virtual srs_error_t deny_check(SrsConfDirective *rules, SrsRtmpConnType type, std::string ip);
|
virtual srs_error_t deny_check(SrsConfDirective *rules, SrsRtmpConnType type, std::string ip);
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,8 @@ class SrsServer : public ISrsReloadHandler, // Reload framework for permormance
|
||||||
public ISrsApiServerOwner,
|
public ISrsApiServerOwner,
|
||||||
public ISrsRtcApiServer
|
public ISrsRtcApiServer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsLiveSourceManager *live_sources_;
|
ISrsLiveSourceManager *live_sources_;
|
||||||
ISrsResourceManager *conn_manager_;
|
ISrsResourceManager *conn_manager_;
|
||||||
|
|
@ -141,20 +142,24 @@ SRS_DECLARE_PRIVATE:
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
ISrsAppFactory *app_factory_;
|
ISrsAppFactory *app_factory_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsCommonHttpHandler *http_api_mux_;
|
ISrsCommonHttpHandler *http_api_mux_;
|
||||||
SrsHttpServer *http_server_;
|
SrsHttpServer *http_server_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsHttpHeartbeat *http_heartbeat_;
|
SrsHttpHeartbeat *http_heartbeat_;
|
||||||
SrsIngester *ingester_;
|
SrsIngester *ingester_;
|
||||||
ISrsHourGlass *timer_;
|
ISrsHourGlass *timer_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// PID file manager for process identification and locking.
|
// PID file manager for process identification and locking.
|
||||||
SrsPidFileLocker *pid_file_locker_;
|
SrsPidFileLocker *pid_file_locker_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// If reusing, HTTP API use the same port of HTTP server.
|
// If reusing, HTTP API use the same port of HTTP server.
|
||||||
bool reuse_api_over_server_;
|
bool reuse_api_over_server_;
|
||||||
// If reusing, WebRTC TCP use the same port of HTTP server.
|
// If reusing, WebRTC TCP use the same port of HTTP server.
|
||||||
|
|
@ -191,17 +196,22 @@ SRS_DECLARE_PRIVATE:
|
||||||
SrsGbListener *stream_caster_gb28181_;
|
SrsGbListener *stream_caster_gb28181_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// SRT acceptors for MPEG-TS over SRT.
|
// SRT acceptors for MPEG-TS over SRT.
|
||||||
std::vector<SrsSrtAcceptor *> srt_acceptors_;
|
std::vector<SrsSrtAcceptor *>
|
||||||
|
srt_acceptors_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// WebRTC UDP listeners for RTC server functionality.
|
// WebRTC UDP listeners for RTC server functionality.
|
||||||
std::vector<SrsUdpMuxListener *> rtc_listeners_;
|
std::vector<SrsUdpMuxListener *>
|
||||||
|
rtc_listeners_;
|
||||||
// WebRTC session manager.
|
// WebRTC session manager.
|
||||||
SrsRtcSessionManager *rtc_session_manager_;
|
SrsRtcSessionManager *rtc_session_manager_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Signal manager which convert gignal to io message.
|
// Signal manager which convert gignal to io message.
|
||||||
SrsSignalManager *signal_manager_;
|
SrsSignalManager *signal_manager_;
|
||||||
// To query the latest available version of SRS.
|
// To query the latest available version of SRS.
|
||||||
|
|
@ -219,10 +229,12 @@ public:
|
||||||
SrsServer();
|
SrsServer();
|
||||||
virtual ~SrsServer();
|
virtual ~SrsServer();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// When SIGTERM, SRS should do cleanup, for example,
|
// When SIGTERM, SRS should do cleanup, for example,
|
||||||
// to stop all ingesters, cleanup HLS and dvr.
|
// to stop all ingesters, cleanup HLS and dvr.
|
||||||
virtual void dispose();
|
virtual void
|
||||||
|
dispose();
|
||||||
// Close listener to stop accepting new connections,
|
// Close listener to stop accepting new connections,
|
||||||
// then wait and quit when all connections finished.
|
// then wait and quit when all connections finished.
|
||||||
virtual void gracefully_dispose();
|
virtual void gracefully_dispose();
|
||||||
|
|
@ -240,7 +252,8 @@ public:
|
||||||
public:
|
public:
|
||||||
srs_error_t run();
|
srs_error_t run();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t initialize_st();
|
virtual srs_error_t initialize_st();
|
||||||
virtual srs_error_t initialize_signal();
|
virtual srs_error_t initialize_signal();
|
||||||
virtual srs_error_t listen();
|
virtual srs_error_t listen();
|
||||||
|
|
@ -252,7 +265,8 @@ public:
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
// interface ISrsCoroutineHandler
|
// interface ISrsCoroutineHandler
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
// server utilities.
|
// server utilities.
|
||||||
|
|
@ -272,21 +286,26 @@ public:
|
||||||
// @remark, maybe the HTTP RAW API will trigger the on_signal() also.
|
// @remark, maybe the HTTP RAW API will trigger the on_signal() also.
|
||||||
virtual void on_signal(int signo);
|
virtual void on_signal(int signo);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The server thread main cycle,
|
// The server thread main cycle,
|
||||||
// update the global static data, for instance, the current time,
|
// update the global static data, for instance, the current time,
|
||||||
// the cpu/mem/network statistic.
|
// the cpu/mem/network statistic.
|
||||||
virtual srs_error_t do_cycle();
|
virtual srs_error_t
|
||||||
|
do_cycle();
|
||||||
virtual srs_error_t do2_cycle();
|
virtual srs_error_t do2_cycle();
|
||||||
|
|
||||||
// interface ISrsHourGlassHandler
|
// interface ISrsHourGlassHandler
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t setup_ticks();
|
virtual srs_error_t setup_ticks();
|
||||||
virtual srs_error_t notify(int event, srs_utime_t interval, srs_utime_t tick);
|
virtual srs_error_t notify(int event, srs_utime_t interval, srs_utime_t tick);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Resample the server kbs.
|
// Resample the server kbs.
|
||||||
virtual void resample_kbps();
|
virtual void
|
||||||
|
resample_kbps();
|
||||||
|
|
||||||
// SRT-related methods
|
// SRT-related methods
|
||||||
virtual srs_error_t listen_srt_mpegts();
|
virtual srs_error_t listen_srt_mpegts();
|
||||||
|
|
@ -294,29 +313,34 @@ SRS_DECLARE_PRIVATE:
|
||||||
virtual srs_error_t accept_srt_client(srs_srt_t srt_fd);
|
virtual srs_error_t accept_srt_client(srs_srt_t srt_fd);
|
||||||
virtual srs_error_t srt_fd_to_resource(srs_srt_t srt_fd, ISrsResource **pr);
|
virtual srs_error_t srt_fd_to_resource(srs_srt_t srt_fd, ISrsResource **pr);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// WebRTC-related methods
|
// WebRTC-related methods
|
||||||
virtual srs_error_t listen_rtc_udp();
|
virtual srs_error_t
|
||||||
|
listen_rtc_udp();
|
||||||
|
|
||||||
// Interface ISrsUdpMuxHandler
|
// Interface ISrsUdpMuxHandler
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t on_udp_packet(ISrsUdpMuxSocket *skt);
|
virtual srs_error_t on_udp_packet(ISrsUdpMuxSocket *skt);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t listen_rtc_api();
|
virtual srs_error_t listen_rtc_api();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ISrsRtcConnection *find_rtc_session_by_username(const std::string &ufrag);
|
virtual ISrsRtcConnection *find_rtc_session_by_username(const std::string &ufrag);
|
||||||
virtual srs_error_t create_rtc_session(SrsRtcUserConfig *ruc, SrsSdp &local_sdp, ISrsRtcConnection **psession);
|
virtual srs_error_t create_rtc_session(SrsRtcUserConfig *ruc, SrsSdp &local_sdp, ISrsRtcConnection **psession);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t srs_update_server_statistics();
|
virtual srs_error_t srs_update_server_statistics();
|
||||||
|
|
||||||
// Interface ISrsTcpHandler
|
// Interface ISrsTcpHandler
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t on_tcp_client(ISrsListener *listener, srs_netfd_t stfd);
|
virtual srs_error_t on_tcp_client(ISrsListener *listener, srs_netfd_t stfd);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_on_tcp_client(ISrsListener *listener, srs_netfd_t &stfd);
|
virtual srs_error_t do_on_tcp_client(ISrsListener *listener, srs_netfd_t &stfd);
|
||||||
virtual srs_error_t on_before_connection(const char *label, int fd, const std::string &ip, int port);
|
virtual srs_error_t on_before_connection(const char *label, int fd, const std::string &ip, int port);
|
||||||
|
|
||||||
|
|
@ -333,13 +357,15 @@ extern SrsServer *_srs_server;
|
||||||
// @see: st-1.9/docs/notes.html
|
// @see: st-1.9/docs/notes.html
|
||||||
class SrsSignalManager : public ISrsCoroutineHandler
|
class SrsSignalManager : public ISrsCoroutineHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Per-process pipe which is used as a signal queue.
|
// Per-process pipe which is used as a signal queue.
|
||||||
// Up to PIPE_BUF/sizeof(int) signals can be queued up.
|
// Up to PIPE_BUF/sizeof(int) signals can be queued up.
|
||||||
int sig_pipe_[2];
|
int sig_pipe_[2];
|
||||||
srs_netfd_t signal_read_stfd_;
|
srs_netfd_t signal_read_stfd_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsServer *server_;
|
SrsServer *server_;
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
|
|
||||||
|
|
@ -354,7 +380,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Global singleton instance
|
// Global singleton instance
|
||||||
static SrsSignalManager *instance;
|
static SrsSignalManager *instance;
|
||||||
// Signal catching function.
|
// Signal catching function.
|
||||||
|
|
@ -366,10 +393,12 @@ SRS_DECLARE_PRIVATE:
|
||||||
// @see https://github.com/ossrs/srs/issues/1635
|
// @see https://github.com/ossrs/srs/issues/1635
|
||||||
class SrsInotifyWorker : public ISrsCoroutineHandler
|
class SrsInotifyWorker : public ISrsCoroutineHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsServer *server_;
|
SrsServer *server_;
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
srs_netfd_t inotify_fd_;
|
srs_netfd_t inotify_fd_;
|
||||||
|
|
@ -388,10 +417,12 @@ public:
|
||||||
// PID file manager for process identification and locking.
|
// PID file manager for process identification and locking.
|
||||||
class SrsPidFileLocker
|
class SrsPidFileLocker
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
int pid_fd_;
|
int pid_fd_;
|
||||||
std::string pid_file_;
|
std::string pid_file_;
|
||||||
|
|
||||||
|
|
@ -403,9 +434,11 @@ public:
|
||||||
// Acquire the PID file for the whole process.
|
// Acquire the PID file for the whole process.
|
||||||
virtual srs_error_t acquire();
|
virtual srs_error_t acquire();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Close the PID file descriptor.
|
// Close the PID file descriptor.
|
||||||
virtual void close();
|
virtual void
|
||||||
|
close();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,8 @@ public:
|
||||||
virtual srs_error_t write(void *buf, size_t size, ssize_t *nwrite);
|
virtual srs_error_t write(void *buf, size_t size, ssize_t *nwrite);
|
||||||
virtual srs_error_t writev(const iovec *iov, int iov_size, ssize_t *nwrite);
|
virtual srs_error_t writev(const iovec *iov, int iov_size, ssize_t *nwrite);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The underlayer srt fd handler.
|
// The underlayer srt fd handler.
|
||||||
srs_srt_t srt_fd_;
|
srs_srt_t srt_fd_;
|
||||||
// The underlayer srt socket.
|
// The underlayer srt socket.
|
||||||
|
|
@ -86,14 +87,16 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t do_cycle();
|
srs_error_t do_cycle();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
srs_error_t start();
|
srs_error_t start();
|
||||||
srs_error_t get_recv_err();
|
srs_error_t get_recv_err();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsProtocolReadWriter *srt_conn_;
|
ISrsProtocolReadWriter *srt_conn_;
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
srs_error_t recv_err_;
|
srs_error_t recv_err_;
|
||||||
|
|
@ -115,7 +118,8 @@ public:
|
||||||
// The SRT connection, for client to publish or play stream.
|
// The SRT connection, for client to publish or play stream.
|
||||||
class SrsMpegtsSrtConn : public ISrsMpegtsSrtConnection
|
class SrsMpegtsSrtConn : public ISrsMpegtsSrtConnection
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
ISrsAppConfig *config_;
|
ISrsAppConfig *config_;
|
||||||
ISrsStreamPublishTokenManager *stream_publish_tokens_;
|
ISrsStreamPublishTokenManager *stream_publish_tokens_;
|
||||||
|
|
@ -147,10 +151,12 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t do_cycle();
|
virtual srs_error_t do_cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t publishing();
|
srs_error_t publishing();
|
||||||
srs_error_t playing();
|
srs_error_t playing();
|
||||||
srs_error_t acquire_publish();
|
srs_error_t acquire_publish();
|
||||||
|
|
@ -158,10 +164,12 @@ SRS_DECLARE_PRIVATE:
|
||||||
srs_error_t do_publishing();
|
srs_error_t do_publishing();
|
||||||
srs_error_t do_playing();
|
srs_error_t do_playing();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t on_srt_packet(char *buf, int nb_buf);
|
srs_error_t on_srt_packet(char *buf, int nb_buf);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t http_hooks_on_connect();
|
srs_error_t http_hooks_on_connect();
|
||||||
void http_hooks_on_close();
|
void http_hooks_on_close();
|
||||||
srs_error_t http_hooks_on_publish();
|
srs_error_t http_hooks_on_publish();
|
||||||
|
|
@ -169,7 +177,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
srs_error_t http_hooks_on_play();
|
srs_error_t http_hooks_on_play();
|
||||||
void http_hooks_on_stop();
|
void http_hooks_on_stop();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsResourceManager *resource_manager_;
|
ISrsResourceManager *resource_manager_;
|
||||||
srs_srt_t srt_fd_;
|
srs_srt_t srt_fd_;
|
||||||
ISrsProtocolReadWriter *srt_conn_;
|
ISrsProtocolReadWriter *srt_conn_;
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,14 @@ public:
|
||||||
// Bind and listen SRT(udp) port, use handler to process the client.
|
// Bind and listen SRT(udp) port, use handler to process the client.
|
||||||
class SrsSrtListener : public ISrsCoroutineHandler
|
class SrsSrtListener : public ISrsCoroutineHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_srt_t lfd_;
|
srs_srt_t lfd_;
|
||||||
SrsSrtSocket *srt_skt_;
|
SrsSrtSocket *srt_skt_;
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsSrtHandler *handler_;
|
ISrsSrtHandler *handler_;
|
||||||
std::string ip_;
|
std::string ip_;
|
||||||
int port_;
|
int port_;
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,14 @@ public:
|
||||||
// A common srt acceptor, for SRT server.
|
// A common srt acceptor, for SRT server.
|
||||||
class SrsSrtAcceptor : public ISrsSrtHandler
|
class SrsSrtAcceptor : public ISrsSrtHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string ip_;
|
std::string ip_;
|
||||||
int port_;
|
int port_;
|
||||||
ISrsSrtClientHandler *srt_handler_;
|
ISrsSrtClientHandler *srt_handler_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsSrtListener *listener_;
|
SrsSrtListener *listener_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -45,7 +47,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t listen(std::string ip, int port);
|
virtual srs_error_t listen(std::string ip, int port);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t set_srt_opt();
|
virtual srs_error_t set_srt_opt();
|
||||||
// Interface ISrsSrtHandler
|
// Interface ISrsSrtHandler
|
||||||
public:
|
public:
|
||||||
|
|
@ -69,7 +72,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsSrtPoller *srt_poller_;
|
ISrsSrtPoller *srt_poller_;
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,8 @@ public:
|
||||||
char *data();
|
char *data();
|
||||||
int size();
|
int size();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsMediaPacket *shared_buffer_;
|
SrsMediaPacket *shared_buffer_;
|
||||||
// The size of SRT packet or SRT payload.
|
// The size of SRT packet or SRT payload.
|
||||||
int actual_buffer_size_;
|
int actual_buffer_size_;
|
||||||
|
|
@ -70,7 +71,8 @@ public:
|
||||||
// The SRT source manager.
|
// The SRT source manager.
|
||||||
class SrsSrtSourceManager : public ISrsHourGlassHandler, public ISrsSrtSourceManager
|
class SrsSrtSourceManager : public ISrsHourGlassHandler, public ISrsSrtSourceManager
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_mutex_t lock_;
|
srs_mutex_t lock_;
|
||||||
std::map<std::string, SrsSharedPtr<SrsSrtSource> > pool_;
|
std::map<std::string, SrsSharedPtr<SrsSrtSource> > pool_;
|
||||||
SrsHourGlass *timer_;
|
SrsHourGlass *timer_;
|
||||||
|
|
@ -82,7 +84,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t initialize();
|
virtual srs_error_t initialize();
|
||||||
// interface ISrsHourGlassHandler
|
// interface ISrsHourGlassHandler
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t setup_ticks();
|
virtual srs_error_t setup_ticks();
|
||||||
virtual srs_error_t notify(int event, srs_utime_t interval, srs_utime_t tick);
|
virtual srs_error_t notify(int event, srs_utime_t interval, srs_utime_t tick);
|
||||||
|
|
||||||
|
|
@ -116,7 +119,8 @@ public:
|
||||||
// The SRT consumer, consume packets from SRT stream source.
|
// The SRT consumer, consume packets from SRT stream source.
|
||||||
class SrsSrtConsumer : public ISrsSrtConsumer
|
class SrsSrtConsumer : public ISrsSrtConsumer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Because source references to this object, so we should directly use the source ptr.
|
// Because source references to this object, so we should directly use the source ptr.
|
||||||
ISrsSrtSource *source_;
|
ISrsSrtSource *source_;
|
||||||
|
|
||||||
|
|
@ -124,7 +128,8 @@ public:
|
||||||
SrsSrtConsumer(ISrsSrtSource *source);
|
SrsSrtConsumer(ISrsSrtSource *source);
|
||||||
virtual ~SrsSrtConsumer();
|
virtual ~SrsSrtConsumer();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::vector<SrsSrtPacket *> queue_;
|
std::vector<SrsSrtPacket *> queue_;
|
||||||
// when source id changed, notice all consumers
|
// when source id changed, notice all consumers
|
||||||
bool should_update_source_id_;
|
bool should_update_source_id_;
|
||||||
|
|
@ -162,7 +167,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t on_ts_message(SrsTsMessage *msg);
|
virtual srs_error_t on_ts_message(SrsTsMessage *msg);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t on_ts_video_avc(SrsTsMessage *msg, SrsBuffer *avs);
|
srs_error_t on_ts_video_avc(SrsTsMessage *msg, SrsBuffer *avs);
|
||||||
srs_error_t on_ts_audio(SrsTsMessage *msg, SrsBuffer *avs);
|
srs_error_t on_ts_audio(SrsTsMessage *msg, SrsBuffer *avs);
|
||||||
srs_error_t check_sps_pps_change(SrsTsMessage *msg);
|
srs_error_t check_sps_pps_change(SrsTsMessage *msg);
|
||||||
|
|
@ -173,10 +179,12 @@ SRS_DECLARE_PRIVATE:
|
||||||
srs_error_t check_vps_sps_pps_change(SrsTsMessage *msg);
|
srs_error_t check_vps_sps_pps_change(SrsTsMessage *msg);
|
||||||
srs_error_t on_hevc_frame(SrsTsMessage *msg, std::vector<std::pair<char *, int> > &ipb_frames);
|
srs_error_t on_hevc_frame(SrsTsMessage *msg, std::vector<std::pair<char *, int> > &ipb_frames);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsFrameTarget *frame_target_;
|
ISrsFrameTarget *frame_target_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsTsContext *ts_ctx_;
|
SrsTsContext *ts_ctx_;
|
||||||
// Record sps/pps had changed, if change, need to generate new video sh frame.
|
// Record sps/pps had changed, if change, need to generate new video sh frame.
|
||||||
bool sps_pps_change_;
|
bool sps_pps_change_;
|
||||||
|
|
@ -190,10 +198,12 @@ SRS_DECLARE_PRIVATE:
|
||||||
bool audio_sh_change_;
|
bool audio_sh_change_;
|
||||||
std::string audio_sh_;
|
std::string audio_sh_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// SRT to rtmp, video stream id.
|
// SRT to rtmp, video stream id.
|
||||||
int video_streamid_;
|
int video_streamid_;
|
||||||
// SRT to rtmp, audio stream id.
|
// SRT to rtmp, audio stream id.
|
||||||
|
|
@ -218,7 +228,8 @@ public:
|
||||||
// A SRT source is a stream, to publish and to play with.
|
// A SRT source is a stream, to publish and to play with.
|
||||||
class SrsSrtSource : public ISrsSrtSource
|
class SrsSrtSource : public ISrsSrtSource
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStatistic *stat_;
|
ISrsStatistic *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -261,7 +272,8 @@ public:
|
||||||
public:
|
public:
|
||||||
srs_error_t on_packet(SrsSrtPacket *packet);
|
srs_error_t on_packet(SrsSrtPacket *packet);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Source id.
|
// Source id.
|
||||||
SrsContextId _source_id;
|
SrsContextId _source_id;
|
||||||
// previous source id.
|
// previous source id.
|
||||||
|
|
@ -273,7 +285,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// The last die time, while die means neither publishers nor players.
|
// The last die time, while die means neither publishers nor players.
|
||||||
srs_utime_t stream_die_at_;
|
srs_utime_t stream_die_at_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsSrtBridge *srt_bridge_;
|
ISrsSrtBridge *srt_bridge_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ class SrsExecutorCoroutine;
|
||||||
// @see https://github.com/ossrs/srs/pull/908
|
// @see https://github.com/ossrs/srs/pull/908
|
||||||
class SrsDummyCoroutine : public ISrsCoroutine
|
class SrsDummyCoroutine : public ISrsCoroutine
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsContextId cid_;
|
SrsContextId cid_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -55,7 +56,8 @@ public:
|
||||||
// Please read https://github.com/ossrs/srs/issues/78
|
// Please read https://github.com/ossrs/srs/issues/78
|
||||||
class SrsSTCoroutine : public ISrsCoroutine
|
class SrsSTCoroutine : public ISrsCoroutine
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsFastCoroutine *impl_;
|
SrsFastCoroutine *impl_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -96,24 +98,28 @@ public:
|
||||||
// High performance coroutine.
|
// High performance coroutine.
|
||||||
class SrsFastCoroutine : public ISrsCoroutine
|
class SrsFastCoroutine : public ISrsCoroutine
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string name_;
|
std::string name_;
|
||||||
int stack_size_;
|
int stack_size_;
|
||||||
ISrsCoroutineHandler *handler_;
|
ISrsCoroutineHandler *handler_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_thread_t trd_;
|
srs_thread_t trd_;
|
||||||
SrsContextId cid_;
|
SrsContextId cid_;
|
||||||
srs_error_t trd_err_;
|
srs_error_t trd_err_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool started_;
|
bool started_;
|
||||||
bool interrupted_;
|
bool interrupted_;
|
||||||
bool disposed_;
|
bool disposed_;
|
||||||
// Cycle done, no need to interrupt it.
|
// Cycle done, no need to interrupt it.
|
||||||
bool cycle_done_;
|
bool cycle_done_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Sub state in disposed, we need to wait for thread to quit.
|
// Sub state in disposed, we need to wait for thread to quit.
|
||||||
bool stopping_;
|
bool stopping_;
|
||||||
SrsContextId stopping_cid_;
|
SrsContextId stopping_cid_;
|
||||||
|
|
@ -140,7 +146,8 @@ public:
|
||||||
const SrsContextId &cid();
|
const SrsContextId &cid();
|
||||||
virtual void set_cid(const SrsContextId &cid);
|
virtual void set_cid(const SrsContextId &cid);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t cycle();
|
srs_error_t cycle();
|
||||||
static void *pfn(void *arg);
|
static void *pfn(void *arg);
|
||||||
};
|
};
|
||||||
|
|
@ -148,7 +155,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// Like goroutine sync.WaitGroup.
|
// Like goroutine sync.WaitGroup.
|
||||||
class SrsWaitGroup
|
class SrsWaitGroup
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
int nn_;
|
int nn_;
|
||||||
srs_cond_t done_;
|
srs_cond_t done_;
|
||||||
|
|
||||||
|
|
@ -203,13 +211,15 @@ class SrsExecutorCoroutine : public ISrsResource, // It's a resource.
|
||||||
public ISrsContextIdGetter,
|
public ISrsContextIdGetter,
|
||||||
public ISrsCoroutineHandler
|
public ISrsCoroutineHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsResourceManager *manager_;
|
ISrsResourceManager *manager_;
|
||||||
ISrsResource *resource_;
|
ISrsResource *resource_;
|
||||||
ISrsCoroutineHandler *handler_;
|
ISrsCoroutineHandler *handler_;
|
||||||
ISrsExecutorHandler *callback_;
|
ISrsExecutorHandler *callback_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,8 @@ public:
|
||||||
// The global statistic instance.
|
// The global statistic instance.
|
||||||
class SrsStatistic : public ISrsStatistic
|
class SrsStatistic : public ISrsStatistic
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The id to identify the sever.
|
// The id to identify the sever.
|
||||||
std::string server_id_;
|
std::string server_id_;
|
||||||
// The id to identify the service.
|
// The id to identify the service.
|
||||||
|
|
@ -186,27 +187,34 @@ SRS_DECLARE_PRIVATE:
|
||||||
// The pid to identify the service process.
|
// The pid to identify the service process.
|
||||||
std::string service_pid_;
|
std::string service_pid_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The key: vhost id, value: vhost object.
|
// The key: vhost id, value: vhost object.
|
||||||
std::map<std::string, SrsStatisticVhost *> vhosts_;
|
std::map<std::string, SrsStatisticVhost *>
|
||||||
|
vhosts_;
|
||||||
// The key: vhost url, value: vhost Object.
|
// The key: vhost url, value: vhost Object.
|
||||||
// @remark a fast index for vhosts.
|
// @remark a fast index for vhosts.
|
||||||
std::map<std::string, SrsStatisticVhost *> rvhosts_;
|
std::map<std::string, SrsStatisticVhost *> rvhosts_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The key: stream id, value: stream Object.
|
// The key: stream id, value: stream Object.
|
||||||
std::map<std::string, SrsStatisticStream *> streams_;
|
std::map<std::string, SrsStatisticStream *>
|
||||||
|
streams_;
|
||||||
// The key: stream url, value: stream Object.
|
// The key: stream url, value: stream Object.
|
||||||
// @remark a fast index for streams.
|
// @remark a fast index for streams.
|
||||||
std::map<std::string, SrsStatisticStream *> rstreams_;
|
std::map<std::string, SrsStatisticStream *> rstreams_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The key: client id, value: stream object.
|
// The key: client id, value: stream object.
|
||||||
std::map<std::string, SrsStatisticClient *> clients_;
|
std::map<std::string, SrsStatisticClient *>
|
||||||
|
clients_;
|
||||||
// The server total kbps.
|
// The server total kbps.
|
||||||
SrsKbps *kbps_;
|
SrsKbps *kbps_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The total of clients connections.
|
// The total of clients connections.
|
||||||
int64_t nb_clients_;
|
int64_t nb_clients_;
|
||||||
// The total of clients errors.
|
// The total of clients errors.
|
||||||
|
|
@ -252,9 +260,11 @@ public:
|
||||||
// exists in stat.
|
// exists in stat.
|
||||||
virtual void on_disconnect(std::string id, srs_error_t err);
|
virtual void on_disconnect(std::string id, srs_error_t err);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Cleanup the stream if stream is not active and for the last client.
|
// Cleanup the stream if stream is not active and for the last client.
|
||||||
void cleanup_stream(SrsStatisticStream *stream);
|
void
|
||||||
|
cleanup_stream(SrsStatisticStream *stream);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Sample the kbps, add delta bytes of conn.
|
// Sample the kbps, add delta bytes of conn.
|
||||||
|
|
@ -284,7 +294,8 @@ public:
|
||||||
// Dumps the hints about SRS server.
|
// Dumps the hints about SRS server.
|
||||||
void dumps_hints_kv(std::stringstream &ss);
|
void dumps_hints_kv(std::stringstream &ss);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual SrsStatisticVhost *create_vhost(ISrsRequest *req);
|
virtual SrsStatisticVhost *create_vhost(ISrsRequest *req);
|
||||||
virtual SrsStatisticStream *create_stream(SrsStatisticVhost *vhost, ISrsRequest *req);
|
virtual SrsStatisticStream *create_stream(SrsStatisticVhost *vhost, ISrsRequest *req);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,8 @@ public:
|
||||||
// Then, deliver the RTP packets to RTP target, which binds to a RTC/RTSP source.
|
// Then, deliver the RTP packets to RTP target, which binds to a RTC/RTSP source.
|
||||||
class SrsRtmpBridge : public ISrsRtmpBridge
|
class SrsRtmpBridge : public ISrsRtmpBridge
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
#ifdef SRS_FFMPEG_FIT
|
#ifdef SRS_FFMPEG_FIT
|
||||||
SrsRtcRtpBuilder *rtp_builder_;
|
SrsRtcRtpBuilder *rtp_builder_;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -135,7 +136,8 @@ public:
|
||||||
// Then, deliver the AV frames to frame target, which binds to a RTMP/RTC source.
|
// Then, deliver the AV frames to frame target, which binds to a RTMP/RTC source.
|
||||||
class SrsSrtBridge : public ISrsSrtBridge, public ISrsFrameTarget
|
class SrsSrtBridge : public ISrsSrtBridge, public ISrsFrameTarget
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Convert SRT TS packets to media frame packets.
|
// Convert SRT TS packets to media frame packets.
|
||||||
SrsSrtFrameBuilder *frame_builder_;
|
SrsSrtFrameBuilder *frame_builder_;
|
||||||
// Deliver media frame packets to RTMP target.
|
// Deliver media frame packets to RTMP target.
|
||||||
|
|
@ -184,7 +186,8 @@ public:
|
||||||
// Then, deliver the RTMP frame packet to RTMP target, which binds to a live source.
|
// Then, deliver the RTMP frame packet to RTMP target, which binds to a live source.
|
||||||
class SrsRtcBridge : public ISrsRtcBridge
|
class SrsRtcBridge : public ISrsRtcBridge
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
#ifdef SRS_FFMPEG_FIT
|
#ifdef SRS_FFMPEG_FIT
|
||||||
// Collect and build WebRTC RTP packets to AV frames.
|
// Collect and build WebRTC RTP packets to AV frames.
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ class SrsStreamPublishTokenManager;
|
||||||
// This prevents race conditions across all protocols (RTMP, RTC, SRT, etc.).
|
// This prevents race conditions across all protocols (RTMP, RTC, SRT, etc.).
|
||||||
class SrsStreamPublishToken
|
class SrsStreamPublishToken
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The stream URL this token is for
|
// The stream URL this token is for
|
||||||
std::string stream_url_;
|
std::string stream_url_;
|
||||||
// Whether this token is currently acquired
|
// Whether this token is currently acquired
|
||||||
|
|
@ -70,9 +71,11 @@ public:
|
||||||
// This prevents race conditions across all protocols.
|
// This prevents race conditions across all protocols.
|
||||||
class SrsStreamPublishTokenManager : public ISrsStreamPublishTokenManager
|
class SrsStreamPublishTokenManager : public ISrsStreamPublishTokenManager
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Map of stream URL to token
|
// Map of stream URL to token
|
||||||
std::map<std::string, SrsStreamPublishToken *> tokens_;
|
std::map<std::string, SrsStreamPublishToken *>
|
||||||
|
tokens_;
|
||||||
// Mutex to protect the tokens map
|
// Mutex to protect the tokens map
|
||||||
srs_mutex_t mutex_;
|
srs_mutex_t mutex_;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,11 @@
|
||||||
// This ensures consistent class layout between production code and utest code with AddressSanitizer.
|
// This ensures consistent class layout between production code and utest code with AddressSanitizer.
|
||||||
// The macro is automatically enabled when --utest=on is specified in configure.
|
// The macro is automatically enabled when --utest=on is specified in configure.
|
||||||
#ifdef SRS_FORCE_PUBLIC4UTEST
|
#ifdef SRS_FORCE_PUBLIC4UTEST
|
||||||
#define SRS_DECLARE_PRIVATE public
|
#define SRS_DECLARE_PRIVATE public
|
||||||
#define SRS_DECLARE_PROTECTED public
|
#define SRS_DECLARE_PROTECTED public
|
||||||
#else
|
#else
|
||||||
#define SRS_DECLARE_PRIVATE private
|
#define SRS_DECLARE_PRIVATE private
|
||||||
#define SRS_DECLARE_PROTECTED protected
|
#define SRS_DECLARE_PROTECTED protected
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// To convert macro values to string.
|
// To convert macro values to string.
|
||||||
|
|
@ -79,7 +79,8 @@ typedef SrsCplxError *srs_error_t;
|
||||||
#if 1
|
#if 1
|
||||||
class _SrsContextId
|
class _SrsContextId
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string v_;
|
std::string v_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@
|
||||||
template <class T>
|
template <class T>
|
||||||
class SrsUniquePtr
|
class SrsUniquePtr
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
T *ptr_;
|
T *ptr_;
|
||||||
void (*deleter_)(T *);
|
void (*deleter_)(T *);
|
||||||
|
|
||||||
|
|
@ -63,19 +64,23 @@ public:
|
||||||
return ptr_;
|
return ptr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Copy the unique ptr.
|
// Copy the unique ptr.
|
||||||
SrsUniquePtr(const SrsUniquePtr<T> &);
|
SrsUniquePtr(const SrsUniquePtr<T> &);
|
||||||
// The assign operator.
|
// The assign operator.
|
||||||
SrsUniquePtr<T> &operator=(const SrsUniquePtr<T> &);
|
SrsUniquePtr<T> &operator=(const SrsUniquePtr<T> &);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Overload the * operator.
|
// Overload the * operator.
|
||||||
T &operator*();
|
T &
|
||||||
|
operator*();
|
||||||
// Overload the bool operator.
|
// Overload the bool operator.
|
||||||
operator bool() const;
|
operator bool() const;
|
||||||
#if __cplusplus >= 201103L // C++11
|
#if __cplusplus >= 201103L // C++11
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The move constructor.
|
// The move constructor.
|
||||||
SrsUniquePtr(SrsUniquePtr<T> &&);
|
SrsUniquePtr(SrsUniquePtr<T> &&);
|
||||||
// The move assign operator.
|
// The move assign operator.
|
||||||
|
|
@ -96,7 +101,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
template <class T>
|
template <class T>
|
||||||
class SrsUniquePtr<T[]>
|
class SrsUniquePtr<T[]>
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
T *ptr_;
|
T *ptr_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -125,19 +131,23 @@ public:
|
||||||
return ptr_[index];
|
return ptr_[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Copy the unique ptr.
|
// Copy the unique ptr.
|
||||||
SrsUniquePtr(const SrsUniquePtr<T> &);
|
SrsUniquePtr(const SrsUniquePtr<T> &);
|
||||||
// The assign operator.
|
// The assign operator.
|
||||||
SrsUniquePtr<T> &operator=(const SrsUniquePtr<T> &);
|
SrsUniquePtr<T> &operator=(const SrsUniquePtr<T> &);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Overload the * operator.
|
// Overload the * operator.
|
||||||
T &operator*();
|
T &
|
||||||
|
operator*();
|
||||||
// Overload the bool operator.
|
// Overload the bool operator.
|
||||||
operator bool() const;
|
operator bool() const;
|
||||||
#if __cplusplus >= 201103L // C++11
|
#if __cplusplus >= 201103L // C++11
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The move constructor.
|
// The move constructor.
|
||||||
SrsUniquePtr(SrsUniquePtr<T> &&);
|
SrsUniquePtr(SrsUniquePtr<T> &&);
|
||||||
// The move assign operator.
|
// The move assign operator.
|
||||||
|
|
@ -157,7 +167,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
template <class T>
|
template <class T>
|
||||||
class SrsSharedPtr
|
class SrsSharedPtr
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The pointer to the object.
|
// The pointer to the object.
|
||||||
T *ptr_;
|
T *ptr_;
|
||||||
// The reference count of the object.
|
// The reference count of the object.
|
||||||
|
|
@ -181,9 +192,11 @@ public:
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Reset the shared ptr.
|
// Reset the shared ptr.
|
||||||
void reset()
|
void
|
||||||
|
reset()
|
||||||
{
|
{
|
||||||
if (!ref_count_)
|
if (!ref_count_)
|
||||||
return;
|
return;
|
||||||
|
|
@ -235,9 +248,11 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Overload the * operator.
|
// Overload the * operator.
|
||||||
T &operator*()
|
T &
|
||||||
|
operator*()
|
||||||
{
|
{
|
||||||
return *ptr_;
|
return *ptr_;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,12 @@ public:
|
||||||
// Transmux the RTMP packets to AAC stream.
|
// Transmux the RTMP packets to AAC stream.
|
||||||
class SrsAacTransmuxer : public ISrsAacTransmuxer
|
class SrsAacTransmuxer : public ISrsAacTransmuxer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStreamWriter *writer_;
|
ISrsStreamWriter *writer_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsAacObjectType aac_object_;
|
SrsAacObjectType aac_object_;
|
||||||
int8_t aac_sample_rate_;
|
int8_t aac_sample_rate_;
|
||||||
int8_t aac_channels_;
|
int8_t aac_channels_;
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,8 @@ public:
|
||||||
//
|
//
|
||||||
class SrsLbRoundRobin : public ISrsLbRoundRobin
|
class SrsLbRoundRobin : public ISrsLbRoundRobin
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
int index_;
|
int index_;
|
||||||
uint32_t count_;
|
uint32_t count_;
|
||||||
std::string elem_;
|
std::string elem_;
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,8 @@ public:
|
||||||
// @remark The buffer never manages the bytes memory, user must manage it.
|
// @remark The buffer never manages the bytes memory, user must manage it.
|
||||||
class SrsBuffer
|
class SrsBuffer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Current read/write position within the buffer
|
// Current read/write position within the buffer
|
||||||
char *p_;
|
char *p_;
|
||||||
// Pointer to the start of the buffer data (not owned by this class)
|
// Pointer to the start of the buffer data (not owned by this class)
|
||||||
|
|
@ -402,7 +403,8 @@ public:
|
||||||
// @remark This class does not take ownership of the SrsBuffer pointer.
|
// @remark This class does not take ownership of the SrsBuffer pointer.
|
||||||
class SrsBitBuffer
|
class SrsBitBuffer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Current byte being processed (cached from stream)
|
// Current byte being processed (cached from stream)
|
||||||
int8_t cb_;
|
int8_t cb_;
|
||||||
// Number of unread bits remaining in current byte (0-8)
|
// Number of unread bits remaining in current byte (0-8)
|
||||||
|
|
@ -534,7 +536,8 @@ public:
|
||||||
// @remark The size may be less than the allocated buffer size for chunked data.
|
// @remark The size may be less than the allocated buffer size for chunked data.
|
||||||
class SrsMemoryBlock
|
class SrsMemoryBlock
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Current size of valid data in the buffer.
|
// Current size of valid data in the buffer.
|
||||||
// This may be less than the allocated buffer size for chunked data
|
// This may be less than the allocated buffer size for chunked data
|
||||||
// that arrives in multiple parts.
|
// that arrives in multiple parts.
|
||||||
|
|
|
||||||
|
|
@ -434,7 +434,8 @@ extern bool srs_is_server_gracefully_close(srs_error_t err);
|
||||||
// please @read https://github.com/ossrs/srs/issues/913
|
// please @read https://github.com/ossrs/srs/issues/913
|
||||||
class SrsCplxError
|
class SrsCplxError
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
int code_;
|
int code_;
|
||||||
SrsCplxError *wrapped_;
|
SrsCplxError *wrapped_;
|
||||||
std::string msg_;
|
std::string msg_;
|
||||||
|
|
@ -449,13 +450,15 @@ SRS_DECLARE_PRIVATE:
|
||||||
std::string desc_;
|
std::string desc_;
|
||||||
std::string summary_;
|
std::string summary_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsCplxError();
|
SrsCplxError();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~SrsCplxError();
|
virtual ~SrsCplxError();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual std::string description();
|
virtual std::string description();
|
||||||
virtual std::string summary();
|
virtual std::string summary();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,8 @@ public:
|
||||||
// file writer, to write to file.
|
// file writer, to write to file.
|
||||||
class SrsFileWriter : public ISrsFileWriter
|
class SrsFileWriter : public ISrsFileWriter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string path_;
|
std::string path_;
|
||||||
FILE *fp_;
|
FILE *fp_;
|
||||||
char *buf_;
|
char *buf_;
|
||||||
|
|
@ -107,7 +108,8 @@ public:
|
||||||
*/
|
*/
|
||||||
class SrsFileReader : public ISrsFileReader
|
class SrsFileReader : public ISrsFileReader
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string path_;
|
std::string path_;
|
||||||
int fd_;
|
int fd_;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -268,13 +268,15 @@ public:
|
||||||
// Transmux RTMP packets to FLV stream.
|
// Transmux RTMP packets to FLV stream.
|
||||||
class SrsFlvTransmuxer : public ISrsFlvTransmuxer
|
class SrsFlvTransmuxer : public ISrsFlvTransmuxer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool has_audio_;
|
bool has_audio_;
|
||||||
bool has_video_;
|
bool has_video_;
|
||||||
bool drop_if_not_match_;
|
bool drop_if_not_match_;
|
||||||
ISrsWriter *writer_;
|
ISrsWriter *writer_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
char tag_header_[SRS_FLV_TAG_HEADER_SIZE];
|
char tag_header_[SRS_FLV_TAG_HEADER_SIZE];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -317,7 +319,8 @@ public:
|
||||||
// @remark assert data_size is not negative.
|
// @remark assert data_size is not negative.
|
||||||
static int size_tag(int data_size);
|
static int size_tag(int data_size);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The cache tag header.
|
// The cache tag header.
|
||||||
int nb_tag_headers_;
|
int nb_tag_headers_;
|
||||||
char *tag_headers_;
|
char *tag_headers_;
|
||||||
|
|
@ -332,7 +335,8 @@ public:
|
||||||
// Write the tags in a time.
|
// Write the tags in a time.
|
||||||
virtual srs_error_t write_tags(SrsMediaPacket **msgs, int count);
|
virtual srs_error_t write_tags(SrsMediaPacket **msgs, int count);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual void cache_metadata(char type, char *data, int size, char *cache);
|
virtual void cache_metadata(char type, char *data, int size, char *cache);
|
||||||
virtual void cache_audio(int64_t timestamp, char *data, int size, char *cache);
|
virtual void cache_audio(int64_t timestamp, char *data, int size, char *cache);
|
||||||
virtual void cache_video(int64_t timestamp, char *data, int size, char *cache);
|
virtual void cache_video(int64_t timestamp, char *data, int size, char *cache);
|
||||||
|
|
@ -363,7 +367,8 @@ public:
|
||||||
// Decode flv file.
|
// Decode flv file.
|
||||||
class SrsFlvDecoder : public ISrsFlvDecoder
|
class SrsFlvDecoder : public ISrsFlvDecoder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsReader *reader_;
|
ISrsReader *reader_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -396,7 +401,8 @@ public:
|
||||||
// then seek to specified offset.
|
// then seek to specified offset.
|
||||||
class SrsFlvVodStreamDecoder
|
class SrsFlvVodStreamDecoder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsFileReader *reader_;
|
ISrsFileReader *reader_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,8 @@ public:
|
||||||
// hg->start();
|
// hg->start();
|
||||||
class SrsHourGlass : public ISrsCoroutineHandler, public ISrsHourGlass
|
class SrsHourGlass : public ISrsCoroutineHandler, public ISrsHourGlass
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string label_;
|
std::string label_;
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
ISrsHourGlassHandler *handler_;
|
ISrsHourGlassHandler *handler_;
|
||||||
|
|
@ -139,7 +140,8 @@ public:
|
||||||
// instead, we should start only one fast timer in server.
|
// instead, we should start only one fast timer in server.
|
||||||
class SrsFastTimer : public ISrsCoroutineHandler, public ISrsFastTimer
|
class SrsFastTimer : public ISrsCoroutineHandler, public ISrsFastTimer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
srs_utime_t interval_;
|
srs_utime_t interval_;
|
||||||
std::vector<ISrsFastTimerHandler *> handlers_;
|
std::vector<ISrsFastTimerHandler *> handlers_;
|
||||||
|
|
@ -156,23 +158,27 @@ public:
|
||||||
void subscribe(ISrsFastTimerHandler *timer);
|
void subscribe(ISrsFastTimerHandler *timer);
|
||||||
void unsubscribe(ISrsFastTimerHandler *timer);
|
void unsubscribe(ISrsFastTimerHandler *timer);
|
||||||
// Interface ISrsCoroutineHandler
|
// Interface ISrsCoroutineHandler
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Cycle the hourglass, which will sleep resolution every time.
|
// Cycle the hourglass, which will sleep resolution every time.
|
||||||
// and call handler when ticked.
|
// and call handler when ticked.
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t
|
||||||
|
cycle();
|
||||||
};
|
};
|
||||||
|
|
||||||
// To monitor the system wall clock timer deviation.
|
// To monitor the system wall clock timer deviation.
|
||||||
class SrsClockWallMonitor : public ISrsFastTimerHandler
|
class SrsClockWallMonitor : public ISrsFastTimerHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsTime *time_;
|
ISrsTime *time_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SrsClockWallMonitor();
|
SrsClockWallMonitor();
|
||||||
virtual ~SrsClockWallMonitor();
|
virtual ~SrsClockWallMonitor();
|
||||||
// interface ISrsFastTimerHandler
|
// interface ISrsFastTimerHandler
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t on_timer(srs_utime_t interval);
|
srs_error_t on_timer(srs_utime_t interval);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -193,7 +199,8 @@ public:
|
||||||
// Global shared timer manager
|
// Global shared timer manager
|
||||||
class SrsSharedTimer : public ISrsSharedTimer
|
class SrsSharedTimer : public ISrsSharedTimer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsFastTimer *timer20ms_;
|
SrsFastTimer *timer20ms_;
|
||||||
SrsFastTimer *timer100ms_;
|
SrsFastTimer *timer100ms_;
|
||||||
SrsFastTimer *timer1s_;
|
SrsFastTimer *timer1s_;
|
||||||
|
|
|
||||||
|
|
@ -71,10 +71,12 @@ public:
|
||||||
// A pps manager every some duration.
|
// A pps manager every some duration.
|
||||||
class SrsPps
|
class SrsPps
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsClock *clk_;
|
ISrsClock *clk_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// samples
|
// samples
|
||||||
SrsRateSample sample_10s_;
|
SrsRateSample sample_10s_;
|
||||||
SrsRateSample sample_30s_;
|
SrsRateSample sample_30s_;
|
||||||
|
|
@ -252,7 +254,8 @@ void srs_global_rtc_update(SrsKbsRtcStats *stats);
|
||||||
*/
|
*/
|
||||||
class SrsKbpsSlice
|
class SrsKbpsSlice
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsClock *clk_;
|
ISrsClock *clk_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -315,7 +318,8 @@ public:
|
||||||
// sent out each UDP packet.
|
// sent out each UDP packet.
|
||||||
class SrsEphemeralDelta : public ISrsEphemeralDelta
|
class SrsEphemeralDelta : public ISrsEphemeralDelta
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint64_t in_;
|
uint64_t in_;
|
||||||
uint64_t out_;
|
uint64_t out_;
|
||||||
|
|
||||||
|
|
@ -344,7 +348,8 @@ public:
|
||||||
// A network delta data source for SrsKbps.
|
// A network delta data source for SrsKbps.
|
||||||
class SrsNetworkDelta : public ISrsNetworkDelta
|
class SrsNetworkDelta : public ISrsNetworkDelta
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsProtocolStatistic *in_;
|
ISrsProtocolStatistic *in_;
|
||||||
ISrsProtocolStatistic *out_;
|
ISrsProtocolStatistic *out_;
|
||||||
uint64_t in_base_;
|
uint64_t in_base_;
|
||||||
|
|
@ -375,7 +380,8 @@ public:
|
||||||
*/
|
*/
|
||||||
class SrsKbps
|
class SrsKbps
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsKbpsSlice *is_;
|
SrsKbpsSlice *is_;
|
||||||
SrsKbpsSlice *os_;
|
SrsKbpsSlice *os_;
|
||||||
ISrsClock *clk_;
|
ISrsClock *clk_;
|
||||||
|
|
@ -411,7 +417,8 @@ public:
|
||||||
// A sugar to use SrsNetworkDelta and SrsKbps.
|
// A sugar to use SrsNetworkDelta and SrsKbps.
|
||||||
class SrsNetworkKbps
|
class SrsNetworkKbps
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsNetworkDelta *delta_;
|
SrsNetworkDelta *delta_;
|
||||||
SrsKbps *kbps_;
|
SrsKbps *kbps_;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,8 @@ public:
|
||||||
#define SrsContextRestore(cid) impl_SrsContextRestore _context_restore_instance(cid)
|
#define SrsContextRestore(cid) impl_SrsContextRestore _context_restore_instance(cid)
|
||||||
class impl_SrsContextRestore
|
class impl_SrsContextRestore
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsContextId cid_;
|
SrsContextId cid_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@ public:
|
||||||
*/
|
*/
|
||||||
class SrsMp3Transmuxer : public ISrsMp3Transmuxer
|
class SrsMp3Transmuxer : public ISrsMp3Transmuxer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsFileWriter *writer_;
|
ISrsFileWriter *writer_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,8 @@ public:
|
||||||
// ISO_IEC_14496-12-base-format-2012.pdf, page 16
|
// ISO_IEC_14496-12-base-format-2012.pdf, page 16
|
||||||
class SrsMp4Box : public ISrsCodec
|
class SrsMp4Box : public ISrsCodec
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The size is the entire size of the box, including the size and type header, fields,
|
// The size is the entire size of the box, including the size and type header, fields,
|
||||||
// And all contained boxes. This facilitates general parsing of the file.
|
// And all contained boxes. This facilitates general parsing of the file.
|
||||||
//
|
//
|
||||||
|
|
@ -195,10 +196,12 @@ public:
|
||||||
// For box 'uuid'.
|
// For box 'uuid'.
|
||||||
std::vector<char> usertype_;
|
std::vector<char> usertype_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
std::vector<SrsMp4Box *> boxes_;
|
std::vector<SrsMp4Box *> boxes_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The position at buffer to start demux the box.
|
// The position at buffer to start demux the box.
|
||||||
int start_pos_;
|
int start_pos_;
|
||||||
|
|
||||||
|
|
@ -240,14 +243,17 @@ public:
|
||||||
virtual srs_error_t encode(SrsBuffer *buf);
|
virtual srs_error_t encode(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode(SrsBuffer *buf);
|
virtual srs_error_t decode(SrsBuffer *buf);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t encode_boxes(SrsBuffer *buf);
|
virtual srs_error_t encode_boxes(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_boxes(SrsBuffer *buf);
|
virtual srs_error_t decode_boxes(SrsBuffer *buf);
|
||||||
// Sub classes can override these functions for special codec.
|
// Sub classes can override these functions for special codec.
|
||||||
// @remark For mdat box, we use completely different codec.
|
// @remark For mdat box, we use completely different codec.
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
// The size of header, not including the contained boxes.
|
// The size of header, not including the contained boxes.
|
||||||
virtual int nb_header();
|
virtual int
|
||||||
|
nb_header();
|
||||||
// It's not necessary to check the buffer, because we already know the size in parent function,
|
// It's not necessary to check the buffer, because we already know the size in parent function,
|
||||||
// so we have checked the buffer is ok to write.
|
// so we have checked the buffer is ok to write.
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
|
|
@ -276,7 +282,8 @@ public:
|
||||||
SrsMp4FullBox();
|
SrsMp4FullBox();
|
||||||
virtual ~SrsMp4FullBox();
|
virtual ~SrsMp4FullBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -299,9 +306,11 @@ public:
|
||||||
// An informative integer for the minor version of the major brand
|
// An informative integer for the minor version of the major brand
|
||||||
uint32_t minor_version_;
|
uint32_t minor_version_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// A list, to the end of the box, of brands
|
// A list, to the end of the box, of brands
|
||||||
std::vector<SrsMp4BoxBrand> compatible_brands_;
|
std::vector<SrsMp4BoxBrand>
|
||||||
|
compatible_brands_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SrsMp4FileTypeBox();
|
SrsMp4FileTypeBox();
|
||||||
|
|
@ -312,7 +321,8 @@ public:
|
||||||
virtual void set_compatible_brands(SrsMp4BoxBrand b0, SrsMp4BoxBrand b1, SrsMp4BoxBrand b2);
|
virtual void set_compatible_brands(SrsMp4BoxBrand b0, SrsMp4BoxBrand b1, SrsMp4BoxBrand b2);
|
||||||
virtual void set_compatible_brands(SrsMp4BoxBrand b0, SrsMp4BoxBrand b1, SrsMp4BoxBrand b2, SrsMp4BoxBrand b3);
|
virtual void set_compatible_brands(SrsMp4BoxBrand b0, SrsMp4BoxBrand b1, SrsMp4BoxBrand b2, SrsMp4BoxBrand b3);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -370,7 +380,8 @@ public:
|
||||||
SrsMp4MovieFragmentHeaderBox();
|
SrsMp4MovieFragmentHeaderBox();
|
||||||
virtual ~SrsMp4MovieFragmentHeaderBox();
|
virtual ~SrsMp4MovieFragmentHeaderBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -452,7 +463,8 @@ public:
|
||||||
SrsMp4TrackFragmentHeaderBox();
|
SrsMp4TrackFragmentHeaderBox();
|
||||||
virtual ~SrsMp4TrackFragmentHeaderBox();
|
virtual ~SrsMp4TrackFragmentHeaderBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -478,7 +490,8 @@ public:
|
||||||
SrsMp4TrackFragmentDecodeTimeBox();
|
SrsMp4TrackFragmentDecodeTimeBox();
|
||||||
virtual ~SrsMp4TrackFragmentDecodeTimeBox();
|
virtual ~SrsMp4TrackFragmentDecodeTimeBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -554,7 +567,8 @@ public:
|
||||||
SrsMp4TrackFragmentRunBox();
|
SrsMp4TrackFragmentRunBox();
|
||||||
virtual ~SrsMp4TrackFragmentRunBox();
|
virtual ~SrsMp4TrackFragmentRunBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -629,7 +643,8 @@ public:
|
||||||
// because the mdat only decode the header.
|
// because the mdat only decode the header.
|
||||||
virtual srs_error_t decode(SrsBuffer *buf);
|
virtual srs_error_t decode(SrsBuffer *buf);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t encode_boxes(SrsBuffer *buf);
|
virtual srs_error_t encode_boxes(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_boxes(SrsBuffer *buf);
|
virtual srs_error_t decode_boxes(SrsBuffer *buf);
|
||||||
|
|
||||||
|
|
@ -641,14 +656,16 @@ public:
|
||||||
// ISO_IEC_14496-12-base-format-2012.pdf, page 29
|
// ISO_IEC_14496-12-base-format-2012.pdf, page 29
|
||||||
class SrsMp4FreeSpaceBox : public SrsMp4Box
|
class SrsMp4FreeSpaceBox : public SrsMp4Box
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::vector<char> data_;
|
std::vector<char> data_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SrsMp4FreeSpaceBox(SrsMp4BoxType v);
|
SrsMp4FreeSpaceBox(SrsMp4BoxType v);
|
||||||
virtual ~SrsMp4FreeSpaceBox();
|
virtual ~SrsMp4FreeSpaceBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -685,7 +702,8 @@ public:
|
||||||
// Get the number of audio tracks.
|
// Get the number of audio tracks.
|
||||||
virtual int nb_soun_tracks();
|
virtual int nb_soun_tracks();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -738,7 +756,8 @@ public:
|
||||||
// Get the duration in ms.
|
// Get the duration in ms.
|
||||||
virtual uint64_t duration();
|
virtual uint64_t duration();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -787,7 +806,8 @@ public:
|
||||||
SrsMp4TrackExtendsBox();
|
SrsMp4TrackExtendsBox();
|
||||||
virtual ~SrsMp4TrackExtendsBox();
|
virtual ~SrsMp4TrackExtendsBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -915,7 +935,8 @@ public:
|
||||||
SrsMp4TrackHeaderBox();
|
SrsMp4TrackHeaderBox();
|
||||||
virtual ~SrsMp4TrackHeaderBox();
|
virtual ~SrsMp4TrackHeaderBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -985,7 +1006,8 @@ public:
|
||||||
SrsMp4EditListBox();
|
SrsMp4EditListBox();
|
||||||
virtual ~SrsMp4EditListBox();
|
virtual ~SrsMp4EditListBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1042,7 +1064,8 @@ public:
|
||||||
// longest track in the presentation. If the duration cannot be determined then duration is set to all 1s.
|
// longest track in the presentation. If the duration cannot be determined then duration is set to all 1s.
|
||||||
uint64_t duration_;
|
uint64_t duration_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The language code for this media. See ISO 639-2/T for the set of three character
|
// The language code for this media. See ISO 639-2/T for the set of three character
|
||||||
// codes. Each character is packed as the difference between its ASCII value and 0x60. Since the code
|
// codes. Each character is packed as the difference between its ASCII value and 0x60. Since the code
|
||||||
// is confined to being three lower-case letters, these values are strictly positive.
|
// is confined to being three lower-case letters, these values are strictly positive.
|
||||||
|
|
@ -1067,7 +1090,8 @@ public:
|
||||||
virtual char language2();
|
virtual char language2();
|
||||||
virtual void set_language2(char v);
|
virtual void set_language2(char v);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1101,7 +1125,8 @@ public:
|
||||||
virtual bool is_video();
|
virtual bool is_video();
|
||||||
virtual bool is_audio();
|
virtual bool is_audio();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1152,7 +1177,8 @@ public:
|
||||||
SrsMp4VideoMeidaHeaderBox();
|
SrsMp4VideoMeidaHeaderBox();
|
||||||
virtual ~SrsMp4VideoMeidaHeaderBox();
|
virtual ~SrsMp4VideoMeidaHeaderBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1174,7 +1200,8 @@ public:
|
||||||
SrsMp4SoundMeidaHeaderBox();
|
SrsMp4SoundMeidaHeaderBox();
|
||||||
virtual ~SrsMp4SoundMeidaHeaderBox();
|
virtual ~SrsMp4SoundMeidaHeaderBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1220,7 +1247,8 @@ public:
|
||||||
SrsMp4DataEntryUrlBox();
|
SrsMp4DataEntryUrlBox();
|
||||||
virtual ~SrsMp4DataEntryUrlBox();
|
virtual ~SrsMp4DataEntryUrlBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1240,7 +1268,8 @@ public:
|
||||||
SrsMp4DataEntryUrnBox();
|
SrsMp4DataEntryUrnBox();
|
||||||
virtual ~SrsMp4DataEntryUrnBox();
|
virtual ~SrsMp4DataEntryUrnBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1256,7 +1285,8 @@ public:
|
||||||
// in this table to the samples in the track. A track may be split over several sources in this way.
|
// in this table to the samples in the track. A track may be split over several sources in this way.
|
||||||
class SrsMp4DataReferenceBox : public SrsMp4FullBox
|
class SrsMp4DataReferenceBox : public SrsMp4FullBox
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::vector<SrsMp4DataEntryBox *> entries_;
|
std::vector<SrsMp4DataEntryBox *> entries_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -1269,7 +1299,8 @@ public:
|
||||||
// Note that box must be SrsMp4DataEntryBox*
|
// Note that box must be SrsMp4DataEntryBox*
|
||||||
virtual void append(SrsMp4Box *box);
|
virtual void append(SrsMp4Box *box);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1315,7 +1346,8 @@ public:
|
||||||
virtual SrsMp4SyncSampleBox *stss();
|
virtual SrsMp4SyncSampleBox *stss();
|
||||||
virtual void set_stss(SrsMp4SyncSampleBox *v);
|
virtual void set_stss(SrsMp4SyncSampleBox *v);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1336,7 +1368,8 @@ public:
|
||||||
SrsMp4SampleEntry();
|
SrsMp4SampleEntry();
|
||||||
virtual ~SrsMp4SampleEntry();
|
virtual ~SrsMp4SampleEntry();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1386,7 +1419,8 @@ public:
|
||||||
virtual SrsMp4HvcCBox *hvcC();
|
virtual SrsMp4HvcCBox *hvcC();
|
||||||
virtual void set_hvcC(SrsMp4HvcCBox *v);
|
virtual void set_hvcC(SrsMp4HvcCBox *v);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1406,7 +1440,8 @@ public:
|
||||||
SrsMp4AvccBox();
|
SrsMp4AvccBox();
|
||||||
virtual ~SrsMp4AvccBox();
|
virtual ~SrsMp4AvccBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1426,7 +1461,8 @@ public:
|
||||||
SrsMp4HvcCBox();
|
SrsMp4HvcCBox();
|
||||||
virtual ~SrsMp4HvcCBox();
|
virtual ~SrsMp4HvcCBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1458,7 +1494,8 @@ public:
|
||||||
// For AAC codec, get the asc.
|
// For AAC codec, get the asc.
|
||||||
virtual SrsMp4DecoderSpecificInfo *asc();
|
virtual SrsMp4DecoderSpecificInfo *asc();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1490,8 +1527,9 @@ public:
|
||||||
// through the instance variable sizeOfInstance (see 8.3.3).
|
// through the instance variable sizeOfInstance (see 8.3.3).
|
||||||
SrsMp4ESTagEs tag; // bit(8)
|
SrsMp4ESTagEs tag; // bit(8)
|
||||||
// The decoded or encoded variant length.
|
// The decoded or encoded variant length.
|
||||||
int32_t vlen; // bit(28)
|
int32_t vlen; // bit(28)
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The position at buffer to start demux the box.
|
// The position at buffer to start demux the box.
|
||||||
int start_pos;
|
int start_pos;
|
||||||
|
|
||||||
|
|
@ -1508,7 +1546,8 @@ public:
|
||||||
virtual srs_error_t encode(SrsBuffer *buf);
|
virtual srs_error_t encode(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode(SrsBuffer *buf);
|
virtual srs_error_t decode(SrsBuffer *buf);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int32_t nb_payload() = 0;
|
virtual int32_t nb_payload() = 0;
|
||||||
virtual srs_error_t encode_payload(SrsBuffer *buf) = 0;
|
virtual srs_error_t encode_payload(SrsBuffer *buf) = 0;
|
||||||
virtual srs_error_t decode_payload(SrsBuffer *buf) = 0;
|
virtual srs_error_t decode_payload(SrsBuffer *buf) = 0;
|
||||||
|
|
@ -1549,7 +1588,8 @@ public:
|
||||||
SrsMp4DecoderSpecificInfo();
|
SrsMp4DecoderSpecificInfo();
|
||||||
virtual ~SrsMp4DecoderSpecificInfo();
|
virtual ~SrsMp4DecoderSpecificInfo();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int32_t nb_payload();
|
virtual int32_t nb_payload();
|
||||||
virtual srs_error_t encode_payload(SrsBuffer *buf);
|
virtual srs_error_t encode_payload(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_payload(SrsBuffer *buf);
|
virtual srs_error_t decode_payload(SrsBuffer *buf);
|
||||||
|
|
@ -1577,7 +1617,8 @@ public:
|
||||||
SrsMp4DecoderConfigDescriptor();
|
SrsMp4DecoderConfigDescriptor();
|
||||||
virtual ~SrsMp4DecoderConfigDescriptor();
|
virtual ~SrsMp4DecoderConfigDescriptor();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int32_t nb_payload();
|
virtual int32_t nb_payload();
|
||||||
virtual srs_error_t encode_payload(SrsBuffer *buf);
|
virtual srs_error_t encode_payload(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_payload(SrsBuffer *buf);
|
virtual srs_error_t decode_payload(SrsBuffer *buf);
|
||||||
|
|
@ -1597,7 +1638,8 @@ public:
|
||||||
SrsMp4SLConfigDescriptor();
|
SrsMp4SLConfigDescriptor();
|
||||||
virtual ~SrsMp4SLConfigDescriptor();
|
virtual ~SrsMp4SLConfigDescriptor();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int32_t nb_payload();
|
virtual int32_t nb_payload();
|
||||||
virtual srs_error_t encode_payload(SrsBuffer *buf);
|
virtual srs_error_t encode_payload(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_payload(SrsBuffer *buf);
|
virtual srs_error_t decode_payload(SrsBuffer *buf);
|
||||||
|
|
@ -1626,7 +1668,8 @@ public:
|
||||||
SrsMp4ES_Descriptor();
|
SrsMp4ES_Descriptor();
|
||||||
virtual ~SrsMp4ES_Descriptor();
|
virtual ~SrsMp4ES_Descriptor();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int32_t nb_payload();
|
virtual int32_t nb_payload();
|
||||||
virtual srs_error_t encode_payload(SrsBuffer *buf);
|
virtual srs_error_t encode_payload(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_payload(SrsBuffer *buf);
|
virtual srs_error_t decode_payload(SrsBuffer *buf);
|
||||||
|
|
@ -1652,7 +1695,8 @@ public:
|
||||||
// For AAC codec, get the asc.
|
// For AAC codec, get the asc.
|
||||||
virtual SrsMp4DecoderSpecificInfo *asc();
|
virtual SrsMp4DecoderSpecificInfo *asc();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1667,7 +1711,8 @@ public:
|
||||||
// information needed for that coding.
|
// information needed for that coding.
|
||||||
class SrsMp4SampleDescriptionBox : public SrsMp4FullBox
|
class SrsMp4SampleDescriptionBox : public SrsMp4FullBox
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::vector<SrsMp4SampleEntry *> entries_;
|
std::vector<SrsMp4SampleEntry *> entries_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -1686,7 +1731,8 @@ public:
|
||||||
// Note that box must be SrsMp4SampleEntry*
|
// Note that box must be SrsMp4SampleEntry*
|
||||||
virtual void append(SrsMp4Box *box);
|
virtual void append(SrsMp4Box *box);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1726,7 +1772,8 @@ public:
|
||||||
// An integer that gives the number of entries in the following table.
|
// An integer that gives the number of entries in the following table.
|
||||||
std::vector<SrsMp4SttsEntry> entries_;
|
std::vector<SrsMp4SttsEntry> entries_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The index for counter to calc the dts for samples.
|
// The index for counter to calc the dts for samples.
|
||||||
uint32_t index_;
|
uint32_t index_;
|
||||||
uint32_t count_;
|
uint32_t count_;
|
||||||
|
|
@ -1741,7 +1788,8 @@ public:
|
||||||
// When got an sample, index starts from 0.
|
// When got an sample, index starts from 0.
|
||||||
virtual srs_error_t on_sample(uint32_t sample_index, SrsMp4SttsEntry **ppentry);
|
virtual srs_error_t on_sample(uint32_t sample_index, SrsMp4SttsEntry **ppentry);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1786,7 +1834,8 @@ public:
|
||||||
// An integer that gives the number of entries in the following table.
|
// An integer that gives the number of entries in the following table.
|
||||||
std::vector<SrsMp4CttsEntry> entries_;
|
std::vector<SrsMp4CttsEntry> entries_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The index for counter to calc the dts for samples.
|
// The index for counter to calc the dts for samples.
|
||||||
uint32_t index_;
|
uint32_t index_;
|
||||||
uint32_t count_;
|
uint32_t count_;
|
||||||
|
|
@ -1801,7 +1850,8 @@ public:
|
||||||
// When got an sample, index starts from 0.
|
// When got an sample, index starts from 0.
|
||||||
virtual srs_error_t on_sample(uint32_t sample_index, SrsMp4CttsEntry **ppentry);
|
virtual srs_error_t on_sample(uint32_t sample_index, SrsMp4CttsEntry **ppentry);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1831,7 +1881,8 @@ public:
|
||||||
// Whether the sample is sync, index starts from 0.
|
// Whether the sample is sync, index starts from 0.
|
||||||
virtual bool is_sync(uint32_t sample_index);
|
virtual bool is_sync(uint32_t sample_index);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1876,7 +1927,8 @@ public:
|
||||||
// The numbers of the samples that are sync samples in the stream.
|
// The numbers of the samples that are sync samples in the stream.
|
||||||
SrsMp4StscEntry *entries_;
|
SrsMp4StscEntry *entries_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The index for counter to calc the dts for samples.
|
// The index for counter to calc the dts for samples.
|
||||||
uint32_t index_;
|
uint32_t index_;
|
||||||
|
|
||||||
|
|
@ -1890,7 +1942,8 @@ public:
|
||||||
// When got an chunk, index starts from 0.
|
// When got an chunk, index starts from 0.
|
||||||
virtual SrsMp4StscEntry *on_chunk(uint32_t chunk_index);
|
virtual SrsMp4StscEntry *on_chunk(uint32_t chunk_index);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1917,7 +1970,8 @@ public:
|
||||||
SrsMp4ChunkOffsetBox();
|
SrsMp4ChunkOffsetBox();
|
||||||
virtual ~SrsMp4ChunkOffsetBox();
|
virtual ~SrsMp4ChunkOffsetBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1944,7 +1998,8 @@ public:
|
||||||
SrsMp4ChunkLargeOffsetBox();
|
SrsMp4ChunkLargeOffsetBox();
|
||||||
virtual ~SrsMp4ChunkLargeOffsetBox();
|
virtual ~SrsMp4ChunkLargeOffsetBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -1979,7 +2034,8 @@ public:
|
||||||
// Get the size of sample.
|
// Get the size of sample.
|
||||||
virtual srs_error_t get_sample_size(uint32_t sample_index, uint32_t *psample_size);
|
virtual srs_error_t get_sample_size(uint32_t sample_index, uint32_t *psample_size);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -2001,7 +2057,8 @@ public:
|
||||||
SrsMp4UserDataBox();
|
SrsMp4UserDataBox();
|
||||||
virtual ~SrsMp4UserDataBox();
|
virtual ~SrsMp4UserDataBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -2040,7 +2097,8 @@ public:
|
||||||
SrsMp4SegmentIndexBox();
|
SrsMp4SegmentIndexBox();
|
||||||
virtual ~SrsMp4SegmentIndexBox();
|
virtual ~SrsMp4SegmentIndexBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -2079,7 +2137,8 @@ public:
|
||||||
SrsMp4SampleAuxiliaryInfoSizeBox();
|
SrsMp4SampleAuxiliaryInfoSizeBox();
|
||||||
virtual ~SrsMp4SampleAuxiliaryInfoSizeBox();
|
virtual ~SrsMp4SampleAuxiliaryInfoSizeBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -2117,7 +2176,8 @@ public:
|
||||||
SrsMp4SampleAuxiliaryInfoOffsetBox();
|
SrsMp4SampleAuxiliaryInfoOffsetBox();
|
||||||
virtual ~SrsMp4SampleAuxiliaryInfoOffsetBox();
|
virtual ~SrsMp4SampleAuxiliaryInfoOffsetBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -2162,7 +2222,8 @@ public:
|
||||||
|
|
||||||
virtual std::stringstream &dumps(std::stringstream &ss, SrsMp4DumpContext dc);
|
virtual std::stringstream &dumps(std::stringstream &ss, SrsMp4DumpContext dc);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsMp4FullBox *senc_;
|
SrsMp4FullBox *senc_;
|
||||||
uint8_t per_sample_iv_size_;
|
uint8_t per_sample_iv_size_;
|
||||||
uint8_t *iv_;
|
uint8_t *iv_;
|
||||||
|
|
@ -2195,7 +2256,8 @@ class SrsMp4SampleEncryptionBox : public SrsMp4FullBox
|
||||||
public:
|
public:
|
||||||
std::vector<SrsMp4SampleEncryptionEntry *> entries_;
|
std::vector<SrsMp4SampleEncryptionEntry *> entries_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint8_t per_sample_iv_size_;
|
uint8_t per_sample_iv_size_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -2204,7 +2266,8 @@ public:
|
||||||
SrsMp4SampleEncryptionBox(uint8_t per_sample_iv_size);
|
SrsMp4SampleEncryptionBox(uint8_t per_sample_iv_size);
|
||||||
virtual ~SrsMp4SampleEncryptionBox();
|
virtual ~SrsMp4SampleEncryptionBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -2220,14 +2283,16 @@ public:
|
||||||
// }
|
// }
|
||||||
class SrsMp4OriginalFormatBox : public SrsMp4Box
|
class SrsMp4OriginalFormatBox : public SrsMp4Box
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint32_t data_format_;
|
uint32_t data_format_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SrsMp4OriginalFormatBox(uint32_t original_format);
|
SrsMp4OriginalFormatBox(uint32_t original_format);
|
||||||
virtual ~SrsMp4OriginalFormatBox();
|
virtual ~SrsMp4OriginalFormatBox();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -2263,7 +2328,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual void set_scheme_uri(char *uri, uint32_t uri_size);
|
virtual void set_scheme_uri(char *uri, uint32_t uri_size);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -2387,7 +2453,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual void set_default_constant_IV(uint8_t *iv, uint8_t iv_size);
|
virtual void set_default_constant_IV(uint8_t *iv, uint8_t iv_size);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int nb_header();
|
virtual int nb_header();
|
||||||
virtual srs_error_t encode_header(SrsBuffer *buf);
|
virtual srs_error_t encode_header(SrsBuffer *buf);
|
||||||
virtual srs_error_t decode_header(SrsBuffer *buf);
|
virtual srs_error_t decode_header(SrsBuffer *buf);
|
||||||
|
|
@ -2438,7 +2505,8 @@ public:
|
||||||
// Handles timing offset between audio and video tracks to ensure proper A/V sync in MP4 files.
|
// Handles timing offset between audio and video tracks to ensure proper A/V sync in MP4 files.
|
||||||
class SrsMp4DvrJitter
|
class SrsMp4DvrJitter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint64_t video_start_dts_;
|
uint64_t video_start_dts_;
|
||||||
uint64_t audio_start_dts_;
|
uint64_t audio_start_dts_;
|
||||||
bool has_first_video_;
|
bool has_first_video_;
|
||||||
|
|
@ -2455,9 +2523,11 @@ public:
|
||||||
// to maintain A/V synchronization in MP4 files
|
// to maintain A/V synchronization in MP4 files
|
||||||
virtual uint32_t get_first_sample_delta(SrsFrameType track);
|
virtual uint32_t get_first_sample_delta(SrsFrameType track);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Reset the jitter state (useful for new recording sessions)
|
// Reset the jitter state (useful for new recording sessions)
|
||||||
virtual void reset();
|
virtual void
|
||||||
|
reset();
|
||||||
// Check if both audio and video start times have been captured
|
// Check if both audio and video start times have been captured
|
||||||
virtual bool is_initialized();
|
virtual bool is_initialized();
|
||||||
};
|
};
|
||||||
|
|
@ -2473,8 +2543,9 @@ SRS_DECLARE_PRIVATE:
|
||||||
// The keyframe is specified by stss.
|
// The keyframe is specified by stss.
|
||||||
class SrsMp4SampleManager
|
class SrsMp4SampleManager
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
SrsMp4DvrJitter *jitter_; // MP4 A/V sync jitter handler
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
|
SrsMp4DvrJitter *jitter_; // MP4 A/V sync jitter handler
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<SrsMp4Sample *> samples_;
|
std::vector<SrsMp4Sample *> samples_;
|
||||||
|
|
@ -2497,27 +2568,31 @@ public:
|
||||||
// @param The dts is the dts of last segment.
|
// @param The dts is the dts of last segment.
|
||||||
virtual srs_error_t write(SrsMp4TrackFragmentBox *traf, uint64_t dts);
|
virtual srs_error_t write(SrsMp4TrackFragmentBox *traf, uint64_t dts);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t write_track(SrsFrameType track,
|
virtual srs_error_t write_track(SrsFrameType track,
|
||||||
SrsMp4DecodingTime2SampleBox *stts, SrsMp4SyncSampleBox *stss, SrsMp4CompositionTime2SampleBox *ctts,
|
SrsMp4DecodingTime2SampleBox *stts, SrsMp4SyncSampleBox *stss, SrsMp4CompositionTime2SampleBox *ctts,
|
||||||
SrsMp4Sample2ChunkBox *stsc, SrsMp4SampleSizeBox *stsz, SrsMp4FullBox *co);
|
SrsMp4Sample2ChunkBox *stsc, SrsMp4SampleSizeBox *stsz, SrsMp4FullBox *co);
|
||||||
virtual srs_error_t do_load(std::map<uint64_t, SrsMp4Sample *> &tses, SrsMp4MovieBox *moov);
|
virtual srs_error_t do_load(std::map<uint64_t, SrsMp4Sample *> &tses, SrsMp4MovieBox *moov);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Load the samples of track from stco, stsz and stsc.
|
// Load the samples of track from stco, stsz and stsc.
|
||||||
// @param tses The temporary samples, key is offset, value is sample.
|
// @param tses The temporary samples, key is offset, value is sample.
|
||||||
// @param tt The type of sample, convert to flv tag type.
|
// @param tt The type of sample, convert to flv tag type.
|
||||||
// TODO: Support co64 for stco.
|
// TODO: Support co64 for stco.
|
||||||
virtual srs_error_t load_trak(std::map<uint64_t, SrsMp4Sample *> &tses, SrsFrameType tt,
|
virtual srs_error_t
|
||||||
SrsMp4MediaHeaderBox *mdhd, SrsMp4ChunkOffsetBox *stco, SrsMp4SampleSizeBox *stsz, SrsMp4Sample2ChunkBox *stsc,
|
load_trak(std::map<uint64_t, SrsMp4Sample *> &tses, SrsFrameType tt,
|
||||||
SrsMp4DecodingTime2SampleBox *stts, SrsMp4CompositionTime2SampleBox *ctts, SrsMp4SyncSampleBox *stss);
|
SrsMp4MediaHeaderBox *mdhd, SrsMp4ChunkOffsetBox *stco, SrsMp4SampleSizeBox *stsz, SrsMp4Sample2ChunkBox *stsc,
|
||||||
|
SrsMp4DecodingTime2SampleBox *stts, SrsMp4CompositionTime2SampleBox *ctts, SrsMp4SyncSampleBox *stss);
|
||||||
};
|
};
|
||||||
|
|
||||||
// The MP4 box reader, to get the RAW boxes without decode.
|
// The MP4 box reader, to get the RAW boxes without decode.
|
||||||
// @remark For mdat box, we only decode the header, then skip the data.
|
// @remark For mdat box, we only decode the header, then skip the data.
|
||||||
class SrsMp4BoxReader
|
class SrsMp4BoxReader
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsReadSeeker *rsio_;
|
ISrsReadSeeker *rsio_;
|
||||||
// The temporary buffer to read from buffer.
|
// The temporary buffer to read from buffer.
|
||||||
char *buf_;
|
char *buf_;
|
||||||
|
|
@ -2533,7 +2608,8 @@ public:
|
||||||
// Read a MP4 box to pbox, the stream is fill with the bytes of box to decode.
|
// Read a MP4 box to pbox, the stream is fill with the bytes of box to decode.
|
||||||
virtual srs_error_t read(SrsSimpleStream *stream, SrsMp4Box **ppbox);
|
virtual srs_error_t read(SrsSimpleStream *stream, SrsMp4Box **ppbox);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t do_read(SrsSimpleStream *stream, SrsMp4Box *&box);
|
srs_error_t do_read(SrsSimpleStream *stream, SrsMp4Box *&box);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -2544,7 +2620,8 @@ public:
|
||||||
// The MP4 demuxer.
|
// The MP4 demuxer.
|
||||||
class SrsMp4Decoder
|
class SrsMp4Decoder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The major brand of decoder, parse from ftyp.
|
// The major brand of decoder, parse from ftyp.
|
||||||
SrsMp4BoxBrand brand_;
|
SrsMp4BoxBrand brand_;
|
||||||
// The samples build from moov.
|
// The samples build from moov.
|
||||||
|
|
@ -2559,9 +2636,11 @@ public:
|
||||||
// TODO: FIXME: Use SrsFormat instead.
|
// TODO: FIXME: Use SrsFormat instead.
|
||||||
SrsVideoCodecId vcodec_;
|
SrsVideoCodecId vcodec_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// For H.264/AVC, the avcc contains the sps/pps.
|
// For H.264/AVC, the avcc contains the sps/pps.
|
||||||
std::vector<char> pavcc_;
|
std::vector<char>
|
||||||
|
pavcc_;
|
||||||
// Whether avcc is written to reader.
|
// Whether avcc is written to reader.
|
||||||
bool avcc_written_;
|
bool avcc_written_;
|
||||||
|
|
||||||
|
|
@ -2576,13 +2655,16 @@ public:
|
||||||
// The audio sound type.
|
// The audio sound type.
|
||||||
SrsAudioChannels channels_;
|
SrsAudioChannels channels_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// For AAC, the asc in esds box.
|
// For AAC, the asc in esds box.
|
||||||
std::vector<char> pasc_;
|
std::vector<char>
|
||||||
|
pasc_;
|
||||||
// Whether asc is written to reader.
|
// Whether asc is written to reader.
|
||||||
bool asc_written_;
|
bool asc_written_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Underlayer reader and seeker.
|
// Underlayer reader and seeker.
|
||||||
// @remark The demuxer must use seeker for general MP4 to seek the moov.
|
// @remark The demuxer must use seeker for general MP4 to seek the moov.
|
||||||
ISrsReadSeeker *rsio_;
|
ISrsReadSeeker *rsio_;
|
||||||
|
|
@ -2612,14 +2694,17 @@ public:
|
||||||
virtual srs_error_t read_sample(SrsMp4HandlerType *pht, uint16_t *pft, uint16_t *pct,
|
virtual srs_error_t read_sample(SrsMp4HandlerType *pht, uint16_t *pft, uint16_t *pct,
|
||||||
uint32_t *pdts, uint32_t *ppts, uint8_t **psample, uint32_t *pnb_sample);
|
uint32_t *pdts, uint32_t *ppts, uint8_t **psample, uint32_t *pnb_sample);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t parse_ftyp(SrsMp4FileTypeBox *ftyp);
|
virtual srs_error_t parse_ftyp(SrsMp4FileTypeBox *ftyp);
|
||||||
virtual srs_error_t parse_moov(SrsMp4MovieBox *moov);
|
virtual srs_error_t parse_moov(SrsMp4MovieBox *moov);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Load the next box from reader.
|
// Load the next box from reader.
|
||||||
// @param required_box_type The box type required, 0 for any box.
|
// @param required_box_type The box type required, 0 for any box.
|
||||||
virtual srs_error_t load_next_box(SrsMp4Box **ppbox, uint32_t required_box_type);
|
virtual srs_error_t
|
||||||
|
load_next_box(SrsMp4Box **ppbox, uint32_t required_box_type);
|
||||||
// @remark Never load the mdat box content, for it's too large.
|
// @remark Never load the mdat box content, for it's too large.
|
||||||
virtual srs_error_t do_load_next_box(SrsMp4Box **ppbox, uint32_t required_box_type);
|
virtual srs_error_t do_load_next_box(SrsMp4Box **ppbox, uint32_t required_box_type);
|
||||||
};
|
};
|
||||||
|
|
@ -2646,7 +2731,8 @@ public:
|
||||||
// The MP4 muxer.
|
// The MP4 muxer.
|
||||||
class SrsMp4Encoder : public ISrsMp4Encoder
|
class SrsMp4Encoder : public ISrsMp4Encoder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsWriteSeeker *wsio_;
|
ISrsWriteSeeker *wsio_;
|
||||||
// The mdat offset at file, we must update the header when flush.
|
// The mdat offset at file, we must update the header when flush.
|
||||||
off_t mdat_offset_;
|
off_t mdat_offset_;
|
||||||
|
|
@ -2666,9 +2752,11 @@ public:
|
||||||
// The audio sound type.
|
// The audio sound type.
|
||||||
SrsAudioChannels channels_;
|
SrsAudioChannels channels_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// For AAC, the asc in esds box.
|
// For AAC, the asc in esds box.
|
||||||
std::vector<char> pasc_;
|
std::vector<char>
|
||||||
|
pasc_;
|
||||||
// The number of audio samples.
|
// The number of audio samples.
|
||||||
uint32_t nb_audios_;
|
uint32_t nb_audios_;
|
||||||
// The duration of audio stream.
|
// The duration of audio stream.
|
||||||
|
|
@ -2679,9 +2767,11 @@ public:
|
||||||
// Forbidden if no video stream.
|
// Forbidden if no video stream.
|
||||||
SrsVideoCodecId vcodec_;
|
SrsVideoCodecId vcodec_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// For H.264/AVC, the avcc contains the sps/pps.
|
// For H.264/AVC, the avcc contains the sps/pps.
|
||||||
std::vector<char> pavcc_;
|
std::vector<char>
|
||||||
|
pavcc_;
|
||||||
// For H.265/HEVC, the hvcC contains the vps/sps/pps.
|
// For H.265/HEVC, the hvcC contains the vps/sps/pps.
|
||||||
std::vector<char> phvcc_;
|
std::vector<char> phvcc_;
|
||||||
// The number of video samples.
|
// The number of video samples.
|
||||||
|
|
@ -2715,7 +2805,8 @@ public:
|
||||||
|
|
||||||
virtual void set_audio_codec(SrsAudioCodecId vcodec, SrsAudioSampleRate sample_rate, SrsAudioSampleBits sound_bits, SrsAudioChannels channels);
|
virtual void set_audio_codec(SrsAudioCodecId vcodec, SrsAudioSampleRate sample_rate, SrsAudioSampleBits sound_bits, SrsAudioChannels channels);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t copy_sequence_header(SrsFormat *format, bool vsh, uint8_t *sample, uint32_t nb_sample);
|
virtual srs_error_t copy_sequence_header(SrsFormat *format, bool vsh, uint8_t *sample, uint32_t nb_sample);
|
||||||
virtual srs_error_t do_write_sample(SrsMp4Sample *ps, uint8_t *sample, uint32_t nb_sample);
|
virtual srs_error_t do_write_sample(SrsMp4Sample *ps, uint8_t *sample, uint32_t nb_sample);
|
||||||
virtual SrsMp4ObjectType get_audio_object_type();
|
virtual SrsMp4ObjectType get_audio_object_type();
|
||||||
|
|
@ -2739,10 +2830,12 @@ public:
|
||||||
// TODO: What the M2ts short for?
|
// TODO: What the M2ts short for?
|
||||||
class SrsMp4M2tsInitEncoder : public ISrsMp4M2tsInitEncoder
|
class SrsMp4M2tsInitEncoder : public ISrsMp4M2tsInitEncoder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsWriter *writer_;
|
ISrsWriter *writer_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint8_t crypt_byte_block_;
|
uint8_t crypt_byte_block_;
|
||||||
uint8_t skip_byte_block_;
|
uint8_t skip_byte_block_;
|
||||||
unsigned char kid_[16];
|
unsigned char kid_[16];
|
||||||
|
|
@ -2782,7 +2875,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual srs_error_t write(SrsFormat *format, int v_tid, int a_tid);
|
virtual srs_error_t write(SrsFormat *format, int v_tid, int a_tid);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
/**
|
/**
|
||||||
* box->type = 'encv' or 'enca'
|
* box->type = 'encv' or 'enca'
|
||||||
* |encv|
|
* |encv|
|
||||||
|
|
@ -2792,7 +2886,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
* | | |schi|
|
* | | |schi|
|
||||||
* | | | |tenc|
|
* | | | |tenc|
|
||||||
*/
|
*/
|
||||||
virtual srs_error_t config_sample_description_encryption(SrsMp4SampleEntry *box);
|
virtual srs_error_t
|
||||||
|
config_sample_description_encryption(SrsMp4SampleEntry *box);
|
||||||
};
|
};
|
||||||
|
|
||||||
// The fMP4 segment encoder interface.
|
// The fMP4 segment encoder interface.
|
||||||
|
|
@ -2824,13 +2919,15 @@ public:
|
||||||
// TODO: fmp4 support package more than one tracks.
|
// TODO: fmp4 support package more than one tracks.
|
||||||
class SrsMp4M2tsSegmentEncoder : public ISrsMp4M2tsSegmentEncoder
|
class SrsMp4M2tsSegmentEncoder : public ISrsMp4M2tsSegmentEncoder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsWriter *writer_;
|
ISrsWriter *writer_;
|
||||||
uint32_t sequence_number_;
|
uint32_t sequence_number_;
|
||||||
srs_utime_t decode_basetime_;
|
srs_utime_t decode_basetime_;
|
||||||
uint32_t track_id_;
|
uint32_t track_id_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint32_t nb_audios_;
|
uint32_t nb_audios_;
|
||||||
uint32_t nb_videos_;
|
uint32_t nb_videos_;
|
||||||
uint32_t styp_bytes_;
|
uint32_t styp_bytes_;
|
||||||
|
|
@ -2863,7 +2960,8 @@ public:
|
||||||
// TODO: fmp4 support package more than one tracks.
|
// TODO: fmp4 support package more than one tracks.
|
||||||
class SrsFmp4SegmentEncoder
|
class SrsFmp4SegmentEncoder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsWriter *writer_;
|
ISrsWriter *writer_;
|
||||||
uint32_t sequence_number_;
|
uint32_t sequence_number_;
|
||||||
// TODO: audio, video may have different basetime.
|
// TODO: audio, video may have different basetime.
|
||||||
|
|
@ -2871,7 +2969,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
uint32_t audio_track_id_;
|
uint32_t audio_track_id_;
|
||||||
uint32_t video_track_id_;
|
uint32_t video_track_id_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint32_t nb_audios_;
|
uint32_t nb_audios_;
|
||||||
uint32_t nb_videos_;
|
uint32_t nb_videos_;
|
||||||
uint32_t styp_bytes_;
|
uint32_t styp_bytes_;
|
||||||
|
|
@ -2880,7 +2979,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
SrsMp4SampleManager *audio_samples_;
|
SrsMp4SampleManager *audio_samples_;
|
||||||
SrsMp4SampleManager *video_samples_;
|
SrsMp4SampleManager *video_samples_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Encryption
|
// Encryption
|
||||||
unsigned char *key_;
|
unsigned char *key_;
|
||||||
unsigned char iv_[16];
|
unsigned char iv_[16];
|
||||||
|
|
|
||||||
|
|
@ -252,17 +252,21 @@ public:
|
||||||
virtual SrsParsedVideoPacket *video();
|
virtual SrsParsedVideoPacket *video();
|
||||||
virtual SrsVideoCodecConfig *vcodec();
|
virtual SrsVideoCodecConfig *vcodec();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Demux the video packet in H.264 codec.
|
// Demux the video packet in H.264 codec.
|
||||||
// The packet is muxed in FLV format, defined in flv specification.
|
// The packet is muxed in FLV format, defined in flv specification.
|
||||||
// Demux the sps/pps from sequence header.
|
// Demux the sps/pps from sequence header.
|
||||||
// Demux the samples from NALUs.
|
// Demux the samples from NALUs.
|
||||||
virtual srs_error_t video_avc_demux(SrsBuffer *stream, int64_t timestamp);
|
virtual srs_error_t
|
||||||
|
video_avc_demux(SrsBuffer *stream, int64_t timestamp);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t hevc_demux_hvcc(SrsBuffer *stream);
|
virtual srs_error_t hevc_demux_hvcc(SrsBuffer *stream);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t hevc_demux_vps_sps_pps(SrsHevcHvccNalu *nal);
|
virtual srs_error_t hevc_demux_vps_sps_pps(SrsHevcHvccNalu *nal);
|
||||||
virtual srs_error_t hevc_demux_vps_rbsp(char *rbsp, int nb_rbsp);
|
virtual srs_error_t hevc_demux_vps_rbsp(char *rbsp, int nb_rbsp);
|
||||||
virtual srs_error_t hevc_demux_sps_rbsp(char *rbsp, int nb_rbsp);
|
virtual srs_error_t hevc_demux_sps_rbsp(char *rbsp, int nb_rbsp);
|
||||||
|
|
@ -274,15 +278,19 @@ public:
|
||||||
virtual srs_error_t hevc_demux_sps(SrsBuffer *stream);
|
virtual srs_error_t hevc_demux_sps(SrsBuffer *stream);
|
||||||
virtual srs_error_t hevc_demux_pps(SrsBuffer *stream);
|
virtual srs_error_t hevc_demux_pps(SrsBuffer *stream);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Parse the H.264 SPS/PPS.
|
// Parse the H.264 SPS/PPS.
|
||||||
virtual srs_error_t avc_demux_sps_pps(SrsBuffer *stream);
|
virtual srs_error_t
|
||||||
|
avc_demux_sps_pps(SrsBuffer *stream);
|
||||||
virtual srs_error_t avc_demux_sps();
|
virtual srs_error_t avc_demux_sps();
|
||||||
virtual srs_error_t avc_demux_sps_rbsp(char *rbsp, int nb_rbsp);
|
virtual srs_error_t avc_demux_sps_rbsp(char *rbsp, int nb_rbsp);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Parse the H.264 or H.265 NALUs.
|
// Parse the H.264 or H.265 NALUs.
|
||||||
virtual srs_error_t video_nalu_demux(SrsBuffer *stream);
|
virtual srs_error_t
|
||||||
|
video_nalu_demux(SrsBuffer *stream);
|
||||||
// Demux the avc NALU in "AnnexB" from ISO_IEC_14496-10-AVC-2003.pdf, page 211.
|
// Demux the avc NALU in "AnnexB" from ISO_IEC_14496-10-AVC-2003.pdf, page 211.
|
||||||
virtual srs_error_t avc_demux_annexb_format(SrsBuffer *stream);
|
virtual srs_error_t avc_demux_annexb_format(SrsBuffer *stream);
|
||||||
virtual srs_error_t do_avc_demux_annexb_format(SrsBuffer *stream);
|
virtual srs_error_t do_avc_demux_annexb_format(SrsBuffer *stream);
|
||||||
|
|
@ -290,11 +298,13 @@ SRS_DECLARE_PRIVATE:
|
||||||
virtual srs_error_t avc_demux_ibmf_format(SrsBuffer *stream);
|
virtual srs_error_t avc_demux_ibmf_format(SrsBuffer *stream);
|
||||||
virtual srs_error_t do_avc_demux_ibmf_format(SrsBuffer *stream);
|
virtual srs_error_t do_avc_demux_ibmf_format(SrsBuffer *stream);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Demux the audio packet in AAC codec.
|
// Demux the audio packet in AAC codec.
|
||||||
// Demux the asc from sequence header.
|
// Demux the asc from sequence header.
|
||||||
// Demux the sampels from RAW data.
|
// Demux the sampels from RAW data.
|
||||||
virtual srs_error_t audio_aac_demux(SrsBuffer *stream, int64_t timestamp);
|
virtual srs_error_t
|
||||||
|
audio_aac_demux(SrsBuffer *stream, int64_t timestamp);
|
||||||
virtual srs_error_t audio_mp3_demux(SrsBuffer *stream, int64_t timestamp, bool fresh);
|
virtual srs_error_t audio_mp3_demux(SrsBuffer *stream, int64_t timestamp, bool fresh);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,8 @@ public:
|
||||||
// Of course, we can add the multiple user support, which is SrsPithyPrint.
|
// Of course, we can add the multiple user support, which is SrsPithyPrint.
|
||||||
class SrsStageManager
|
class SrsStageManager
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::map<int, SrsStageInfo *> stages_;
|
std::map<int, SrsStageInfo *> stages_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -63,7 +64,8 @@ public:
|
||||||
// The number of call of can_print().
|
// The number of call of can_print().
|
||||||
uint32_t nn_count_;
|
uint32_t nn_count_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
double ratio_;
|
double ratio_;
|
||||||
SrsStageManager stages_;
|
SrsStageManager stages_;
|
||||||
std::map<int, srs_utime_t> ticks_;
|
std::map<int, srs_utime_t> ticks_;
|
||||||
|
|
@ -82,7 +84,8 @@ public:
|
||||||
// An standalone pithy print, without shared stages.
|
// An standalone pithy print, without shared stages.
|
||||||
class SrsAlonePithyPrint
|
class SrsAlonePithyPrint
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsStageInfo info_;
|
SrsStageInfo info_;
|
||||||
srs_utime_t previous_tick_;
|
srs_utime_t previous_tick_;
|
||||||
|
|
||||||
|
|
@ -127,14 +130,16 @@ public:
|
||||||
// }
|
// }
|
||||||
class SrsPithyPrint : public ISrsPithyPrint
|
class SrsPithyPrint : public ISrsPithyPrint
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
int client_id_;
|
int client_id_;
|
||||||
SrsStageInfo *cache_;
|
SrsStageInfo *cache_;
|
||||||
int stage_id_;
|
int stage_id_;
|
||||||
srs_utime_t age_;
|
srs_utime_t age_;
|
||||||
srs_utime_t previous_tick_;
|
srs_utime_t previous_tick_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsPithyPrint(int _stage_id);
|
SrsPithyPrint(int _stage_id);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -157,9 +162,11 @@ public:
|
||||||
static SrsPithyPrint *create_srt_publish();
|
static SrsPithyPrint *create_srt_publish();
|
||||||
virtual ~SrsPithyPrint();
|
virtual ~SrsPithyPrint();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Enter the specified stage, return the client id.
|
// Enter the specified stage, return the client id.
|
||||||
virtual int enter_stage();
|
virtual int
|
||||||
|
enter_stage();
|
||||||
// Leave the specified stage, release the client id.
|
// Leave the specified stage, release the client id.
|
||||||
virtual void leave_stage();
|
virtual void leave_stage();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,8 @@ class SrsPsContext : public ISrsPsContext
|
||||||
public:
|
public:
|
||||||
SrsPsDecodeHelper helper_;
|
SrsPsDecodeHelper helper_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The last decoding PS(TS) message.
|
// The last decoding PS(TS) message.
|
||||||
SrsTsMessage *last_;
|
SrsTsMessage *last_;
|
||||||
// The current parsing PS packet context.
|
// The current parsing PS packet context.
|
||||||
|
|
@ -112,7 +113,8 @@ public:
|
||||||
// @remark We will consume all bytes in stream.
|
// @remark We will consume all bytes in stream.
|
||||||
virtual srs_error_t decode(SrsBuffer *stream, ISrsPsMessageHandler *handler);
|
virtual srs_error_t decode(SrsBuffer *stream, ISrsPsMessageHandler *handler);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t do_decode(SrsBuffer *stream, ISrsPsMessageHandler *handler);
|
srs_error_t do_decode(SrsBuffer *stream, ISrsPsMessageHandler *handler);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -274,7 +276,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t decode(SrsBuffer *stream);
|
virtual srs_error_t decode(SrsBuffer *stream);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t decode_pack(SrsBuffer *stream);
|
virtual srs_error_t decode_pack(SrsBuffer *stream);
|
||||||
virtual srs_error_t decode_system(SrsBuffer *stream);
|
virtual srs_error_t decode_system(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -123,12 +123,14 @@ public:
|
||||||
// The resource manager remove resource and delete it asynchronously.
|
// The resource manager remove resource and delete it asynchronously.
|
||||||
class SrsResourceManager : public ISrsCoroutineHandler, public ISrsResourceManager
|
class SrsResourceManager : public ISrsCoroutineHandler, public ISrsResourceManager
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string label_;
|
std::string label_;
|
||||||
SrsContextId cid_;
|
SrsContextId cid_;
|
||||||
bool verbose_;
|
bool verbose_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
ISrsCond *cond_;
|
ISrsCond *cond_;
|
||||||
// Callback handlers.
|
// Callback handlers.
|
||||||
|
|
@ -141,9 +143,11 @@ SRS_DECLARE_PRIVATE:
|
||||||
std::vector<ISrsResource *> zombies_;
|
std::vector<ISrsResource *> zombies_;
|
||||||
std::vector<ISrsResource *> *p_disposing_;
|
std::vector<ISrsResource *> *p_disposing_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The connections without any id.
|
// The connections without any id.
|
||||||
std::vector<ISrsResource *> conns_;
|
std::vector<ISrsResource *>
|
||||||
|
conns_;
|
||||||
// The connections with resource id.
|
// The connections with resource id.
|
||||||
std::map<std::string, ISrsResource *> conns_id_;
|
std::map<std::string, ISrsResource *> conns_id_;
|
||||||
// The connections with resource fast(int) id.
|
// The connections with resource fast(int) id.
|
||||||
|
|
@ -183,7 +187,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual void remove(ISrsResource *c);
|
virtual void remove(ISrsResource *c);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
void do_remove(ISrsResource *c);
|
void do_remove(ISrsResource *c);
|
||||||
void check_remove(ISrsResource *c, bool &in_zombie, bool &in_disposing);
|
void check_remove(ISrsResource *c, bool &in_zombie, bool &in_disposing);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
@ -210,7 +215,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class SrsSharedResource : public ISrsResource
|
class SrsSharedResource : public ISrsResource
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsSharedPtr<T> ptr_;
|
SrsSharedPtr<T> ptr_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -244,9 +250,11 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Overload the * operator.
|
// Overload the * operator.
|
||||||
T &operator*()
|
T &
|
||||||
|
operator*()
|
||||||
{
|
{
|
||||||
return ptr_.operator*();
|
return ptr_.operator*();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,8 @@ class SrsRtpRingBuffer;
|
||||||
// We store the received packets in ring buffer.
|
// We store the received packets in ring buffer.
|
||||||
class SrsRtpRingBuffer
|
class SrsRtpRingBuffer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Capacity of the ring-buffer.
|
// Capacity of the ring-buffer.
|
||||||
uint16_t capacity_;
|
uint16_t capacity_;
|
||||||
// Ring bufer.
|
// Ring bufer.
|
||||||
|
|
@ -106,18 +107,22 @@ struct SrsRtpNackInfo {
|
||||||
|
|
||||||
class SrsRtpNackForReceiver
|
class SrsRtpNackForReceiver
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Nack queue, seq order, oldest to newest.
|
// Nack queue, seq order, oldest to newest.
|
||||||
std::map<uint16_t, SrsRtpNackInfo, SrsSeqCompareLess> queue_;
|
std::map<uint16_t, SrsRtpNackInfo, SrsSeqCompareLess>
|
||||||
|
queue_;
|
||||||
// Max nack count.
|
// Max nack count.
|
||||||
size_t max_queue_size_;
|
size_t max_queue_size_;
|
||||||
SrsRtpRingBuffer *rtp_;
|
SrsRtpRingBuffer *rtp_;
|
||||||
SrsNackOption opts_;
|
SrsNackOption opts_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_utime_t pre_check_time_;
|
srs_utime_t pre_check_time_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
int rtt_;
|
int rtt_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,8 @@ struct SrsRtcpHeader {
|
||||||
|
|
||||||
class SrsRtcpCommon : public ISrsCodec
|
class SrsRtcpCommon : public ISrsCodec
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
SrsRtcpHeader header_;
|
SrsRtcpHeader header_;
|
||||||
uint32_t ssrc_;
|
uint32_t ssrc_;
|
||||||
uint8_t payload_[kRtcpPacketSize];
|
uint8_t payload_[kRtcpPacketSize];
|
||||||
|
|
@ -72,7 +73,8 @@ SRS_DECLARE_PROTECTED:
|
||||||
char *data_;
|
char *data_;
|
||||||
int nb_data_;
|
int nb_data_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
srs_error_t decode_header(SrsBuffer *buffer);
|
srs_error_t decode_header(SrsBuffer *buffer);
|
||||||
srs_error_t encode_header(SrsBuffer *buffer);
|
srs_error_t encode_header(SrsBuffer *buffer);
|
||||||
|
|
||||||
|
|
@ -96,7 +98,8 @@ public:
|
||||||
|
|
||||||
class SrsRtcpApp : public SrsRtcpCommon
|
class SrsRtcpApp : public SrsRtcpCommon
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint8_t name_[4];
|
uint8_t name_[4];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -144,7 +147,8 @@ struct SrsRtcpRB {
|
||||||
|
|
||||||
class SrsRtcpSR : public SrsRtcpCommon
|
class SrsRtcpSR : public SrsRtcpCommon
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint64_t ntp_;
|
uint64_t ntp_;
|
||||||
uint32_t rtp_ts_;
|
uint32_t rtp_ts_;
|
||||||
uint32_t send_rtp_packets_;
|
uint32_t send_rtp_packets_;
|
||||||
|
|
@ -175,7 +179,8 @@ public:
|
||||||
|
|
||||||
class SrsRtcpRR : public SrsRtcpCommon
|
class SrsRtcpRR : public SrsRtcpCommon
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsRtcpRB rb_;
|
SrsRtcpRB rb_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -213,7 +218,8 @@ public:
|
||||||
// inlucde Transport layer FB message and Payload-specific FB message.
|
// inlucde Transport layer FB message and Payload-specific FB message.
|
||||||
class SrsRtcpFbCommon : public SrsRtcpCommon
|
class SrsRtcpFbCommon : public SrsRtcpCommon
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
uint32_t media_ssrc_;
|
uint32_t media_ssrc_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -273,7 +279,8 @@ public:
|
||||||
|
|
||||||
class SrsRtcpTWCC : public SrsRtcpFbCommon
|
class SrsRtcpTWCC : public SrsRtcpFbCommon
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint16_t base_sn_;
|
uint16_t base_sn_;
|
||||||
int32_t reference_time_;
|
int32_t reference_time_;
|
||||||
uint8_t fb_pkt_count_;
|
uint8_t fb_pkt_count_;
|
||||||
|
|
@ -294,7 +301,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
int pkt_len_;
|
int pkt_len_;
|
||||||
uint16_t next_base_sn_;
|
uint16_t next_base_sn_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
void clear();
|
void clear();
|
||||||
srs_utime_t calculate_delta_us(srs_utime_t ts, srs_utime_t last);
|
srs_utime_t calculate_delta_us(srs_utime_t ts, srs_utime_t last);
|
||||||
srs_error_t process_pkt_chunk(SrsRtcpTWCCChunk &chunk, int delta_size);
|
srs_error_t process_pkt_chunk(SrsRtcpTWCCChunk &chunk, int delta_size);
|
||||||
|
|
@ -332,13 +340,15 @@ public:
|
||||||
virtual uint64_t nb_bytes();
|
virtual uint64_t nb_bytes();
|
||||||
virtual srs_error_t encode(SrsBuffer *buffer);
|
virtual srs_error_t encode(SrsBuffer *buffer);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t do_encode(SrsBuffer *buffer);
|
srs_error_t do_encode(SrsBuffer *buffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsRtcpNack : public SrsRtcpFbCommon
|
class SrsRtcpNack : public SrsRtcpFbCommon
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
struct SrsPidBlp {
|
struct SrsPidBlp {
|
||||||
uint16_t pid_;
|
uint16_t pid_;
|
||||||
uint16_t blp_;
|
uint16_t blp_;
|
||||||
|
|
@ -377,7 +387,8 @@ public:
|
||||||
|
|
||||||
class SrsRtcpSli : public SrsRtcpFbCommon
|
class SrsRtcpSli : public SrsRtcpFbCommon
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint16_t first_;
|
uint16_t first_;
|
||||||
uint16_t number_;
|
uint16_t number_;
|
||||||
uint8_t picture_;
|
uint8_t picture_;
|
||||||
|
|
@ -395,7 +406,8 @@ public:
|
||||||
|
|
||||||
class SrsRtcpRpsi : public SrsRtcpFbCommon
|
class SrsRtcpRpsi : public SrsRtcpFbCommon
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint8_t pb_;
|
uint8_t pb_;
|
||||||
uint8_t payload_type_;
|
uint8_t payload_type_;
|
||||||
char *native_rpsi_;
|
char *native_rpsi_;
|
||||||
|
|
@ -427,7 +439,8 @@ public:
|
||||||
|
|
||||||
class SrsRtcpCompound : public ISrsCodec
|
class SrsRtcpCompound : public ISrsCodec
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::vector<SrsRtcpCommon *> rtcps_;
|
std::vector<SrsRtcpCommon *> rtcps_;
|
||||||
int nb_bytes_;
|
int nb_bytes_;
|
||||||
char *data_;
|
char *data_;
|
||||||
|
|
|
||||||
|
|
@ -137,10 +137,12 @@ public:
|
||||||
SrsRtpExtensionTypes();
|
SrsRtpExtensionTypes();
|
||||||
virtual ~SrsRtpExtensionTypes();
|
virtual ~SrsRtpExtensionTypes();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool register_id(int id, SrsRtpExtensionType type, std::string uri);
|
bool register_id(int id, SrsRtpExtensionType type, std::string uri);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint8_t ids_[kRtpExtensionNumberOfExtensions];
|
uint8_t ids_[kRtpExtensionNumberOfExtensions];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -197,17 +199,20 @@ public:
|
||||||
// Note that the extensions should never extends from any class, for performance.
|
// Note that the extensions should never extends from any class, for performance.
|
||||||
class SrsRtpExtensions // : public ISrsCodec
|
class SrsRtpExtensions // : public ISrsCodec
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool has_ext_;
|
bool has_ext_;
|
||||||
// by default, twcc isnot decoded. Because it is decoded by fast function(srs_rtp_fast_parse_twcc)
|
// by default, twcc isnot decoded. Because it is decoded by fast function(srs_rtp_fast_parse_twcc)
|
||||||
bool decode_twcc_extension_;
|
bool decode_twcc_extension_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The extension types is used to decode the packet, which is reference to
|
// The extension types is used to decode the packet, which is reference to
|
||||||
// the types in publish stream.
|
// the types in publish stream.
|
||||||
SrsRtpExtensionTypes *types_;
|
SrsRtpExtensionTypes *types_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsRtpExtensionTwcc twcc_;
|
SrsRtpExtensionTwcc twcc_;
|
||||||
SrsRtpExtensionOneByte audio_level_;
|
SrsRtpExtensionOneByte audio_level_;
|
||||||
|
|
||||||
|
|
@ -227,7 +232,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t decode(SrsBuffer *buf);
|
virtual srs_error_t decode(SrsBuffer *buf);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t decode_0xbede(SrsBuffer *buf);
|
srs_error_t decode_0xbede(SrsBuffer *buf);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -238,7 +244,8 @@ public:
|
||||||
// Note that the header should never extends from any class, for performance.
|
// Note that the header should never extends from any class, for performance.
|
||||||
class SrsRtpHeader // : public ISrsCodec
|
class SrsRtpHeader // : public ISrsCodec
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint8_t padding_length_;
|
uint8_t padding_length_;
|
||||||
uint8_t cc_;
|
uint8_t cc_;
|
||||||
bool marker_;
|
bool marker_;
|
||||||
|
|
@ -257,7 +264,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t decode(SrsBuffer *buf);
|
virtual srs_error_t decode(SrsBuffer *buf);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t parse_extensions(SrsBuffer *buf);
|
srs_error_t parse_extensions(SrsBuffer *buf);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -326,16 +334,19 @@ class SrsRtpPacket
|
||||||
public:
|
public:
|
||||||
SrsRtpHeader header_;
|
SrsRtpHeader header_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsRtpPayloader *payload_;
|
ISrsRtpPayloader *payload_;
|
||||||
SrsRtpPacketPayloadType payload_type_;
|
SrsRtpPacketPayloadType payload_type_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The original shared memory block, all RTP packets can refer to its data.
|
// The original shared memory block, all RTP packets can refer to its data.
|
||||||
// Note that the size of shared memory block, is not the packet size, it's a larger aligned buffer.
|
// Note that the size of shared memory block, is not the packet size, it's a larger aligned buffer.
|
||||||
// @remark Note that it may point to the whole RTP packet(for RTP parser, which decode RTP packet from buffer),
|
// @remark Note that it may point to the whole RTP packet(for RTP parser, which decode RTP packet from buffer),
|
||||||
// and it may point to the RTP payload(for RTMP to RTP, which build RTP header and payload).
|
// and it may point to the RTP payload(for RTMP to RTP, which build RTP header and payload).
|
||||||
SrsSharedPtr<SrsMemoryBlock> shared_buffer_;
|
SrsSharedPtr<SrsMemoryBlock>
|
||||||
|
shared_buffer_;
|
||||||
// The size of RTP packet or RTP payload.
|
// The size of RTP packet or RTP payload.
|
||||||
int actual_buffer_size_;
|
int actual_buffer_size_;
|
||||||
// Helper fields.
|
// Helper fields.
|
||||||
|
|
@ -345,13 +356,15 @@ public:
|
||||||
// The frame type, for RTMP bridge or SFU source.
|
// The frame type, for RTMP bridge or SFU source.
|
||||||
SrsFrameType frame_type_;
|
SrsFrameType frame_type_;
|
||||||
// Fast cache for performance.
|
// Fast cache for performance.
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The cached payload size for packet.
|
// The cached payload size for packet.
|
||||||
int cached_payload_size_;
|
int cached_payload_size_;
|
||||||
// The helper handler for decoder, use RAW payload if NULL.
|
// The helper handler for decoder, use RAW payload if NULL.
|
||||||
ISrsRtpPacketDecodeHandler *decode_handler_;
|
ISrsRtpPacketDecodeHandler *decode_handler_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
int64_t avsync_time_;
|
int64_t avsync_time_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -428,9 +441,11 @@ public:
|
||||||
// Multiple NALUs, automatically insert 001 between NALUs.
|
// Multiple NALUs, automatically insert 001 between NALUs.
|
||||||
class SrsRtpRawNALUs : public ISrsRtpPayloader
|
class SrsRtpRawNALUs : public ISrsRtpPayloader
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// We will manage the samples, but the sample itself point to the shared memory.
|
// We will manage the samples, but the sample itself point to the shared memory.
|
||||||
std::vector<SrsNaluSample *> nalus_;
|
std::vector<SrsNaluSample *>
|
||||||
|
nalus_;
|
||||||
int nn_bytes_;
|
int nn_bytes_;
|
||||||
int cursor_;
|
int cursor_;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@
|
||||||
*/
|
*/
|
||||||
class SrsSimpleStream
|
class SrsSimpleStream
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::vector<char> data_;
|
std::vector<char> data_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -338,18 +338,21 @@ public:
|
||||||
// The context of ts, to decode the ts stream.
|
// The context of ts, to decode the ts stream.
|
||||||
class SrsTsContext : public ISrsTsContext
|
class SrsTsContext : public ISrsTsContext
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Whether context is ready, failed if try to write data when not ready.
|
// Whether context is ready, failed if try to write data when not ready.
|
||||||
// When PAT and PMT writen, the context is ready.
|
// When PAT and PMT writen, the context is ready.
|
||||||
// @see https://github.com/ossrs/srs/issues/834
|
// @see https://github.com/ossrs/srs/issues/834
|
||||||
bool ready_;
|
bool ready_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::map<int, SrsTsChannel *> pids_;
|
std::map<int, SrsTsChannel *> pids_;
|
||||||
bool pure_audio_;
|
bool pure_audio_;
|
||||||
int8_t sync_byte_;
|
int8_t sync_byte_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// when any codec changed, write the PAT/PMT.
|
// when any codec changed, write the PAT/PMT.
|
||||||
SrsVideoCodecId vcodec_;
|
SrsVideoCodecId vcodec_;
|
||||||
SrsAudioCodecId acodec_;
|
SrsAudioCodecId acodec_;
|
||||||
|
|
@ -391,7 +394,8 @@ public:
|
||||||
// @param ac The audio codec, write the PAT/PMT table when changed.
|
// @param ac The audio codec, write the PAT/PMT table when changed.
|
||||||
virtual srs_error_t encode(ISrsStreamWriter *writer, SrsTsMessage *msg, SrsVideoCodecId vc, SrsAudioCodecId ac);
|
virtual srs_error_t encode(ISrsStreamWriter *writer, SrsTsMessage *msg, SrsVideoCodecId vc, SrsAudioCodecId ac);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t encode_pat_pmt(ISrsStreamWriter *writer, int16_t vpid, SrsTsStream vs, int16_t apid, SrsTsStream as);
|
virtual srs_error_t encode_pat_pmt(ISrsStreamWriter *writer, int16_t vpid, SrsTsStream vs, int16_t apid, SrsTsStream as);
|
||||||
virtual srs_error_t encode_pes(ISrsStreamWriter *writer, SrsTsMessage *msg, int16_t pid, SrsTsStream sid, bool pure_audio);
|
virtual srs_error_t encode_pes(ISrsStreamWriter *writer, SrsTsMessage *msg, int16_t pid, SrsTsStream sid, bool pure_audio);
|
||||||
};
|
};
|
||||||
|
|
@ -471,7 +475,8 @@ public:
|
||||||
// The continuity counter may be discontinuous when the discontinuity_indicator is set to '1' (refer to 2.4.3.4). In the case of
|
// The continuity counter may be discontinuous when the discontinuity_indicator is set to '1' (refer to 2.4.3.4). In the case of
|
||||||
// a null packet the value of the continuity_counter is undefined.
|
// a null packet the value of the continuity_counter is undefined.
|
||||||
uint8_t continuity_counter_; // 4bits
|
uint8_t continuity_counter_; // 4bits
|
||||||
SRS_DECLARE_PRIVATE:
|
/* clang-format off */
|
||||||
|
SRS_DECLARE_PRIVATE: /* clang-format on */
|
||||||
SrsTsAdaptationField *adaptation_field_;
|
SrsTsAdaptationField *adaptation_field_;
|
||||||
SrsTsPayload *payload_;
|
SrsTsPayload *payload_;
|
||||||
|
|
||||||
|
|
@ -742,7 +747,8 @@ public:
|
||||||
// decoder.
|
// decoder.
|
||||||
int nb_af_reserved_;
|
int nb_af_reserved_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsTsPacket *packet_;
|
SrsTsPacket *packet_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -788,7 +794,8 @@ enum SrsTsPsiId {
|
||||||
// The payload of ts packet, can be PES or PSI payload.
|
// The payload of ts packet, can be PES or PSI payload.
|
||||||
class SrsTsPayload
|
class SrsTsPayload
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
SrsTsPacket *packet_;
|
SrsTsPacket *packet_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -1071,7 +1078,8 @@ public:
|
||||||
virtual int size();
|
virtual int size();
|
||||||
virtual srs_error_t encode(SrsBuffer *stream);
|
virtual srs_error_t encode(SrsBuffer *stream);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t decode_33bits_dts_pts(SrsBuffer *stream, int64_t *pv);
|
virtual srs_error_t decode_33bits_dts_pts(SrsBuffer *stream, int64_t *pv);
|
||||||
virtual srs_error_t encode_33bits_dts_pts(SrsBuffer *stream, uint8_t fb, int64_t v);
|
virtual srs_error_t encode_33bits_dts_pts(SrsBuffer *stream, uint8_t fb, int64_t v);
|
||||||
};
|
};
|
||||||
|
|
@ -1145,7 +1153,8 @@ public:
|
||||||
virtual int size();
|
virtual int size();
|
||||||
virtual srs_error_t encode(SrsBuffer *stream);
|
virtual srs_error_t encode(SrsBuffer *stream);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int psi_size() = 0;
|
virtual int psi_size() = 0;
|
||||||
virtual srs_error_t psi_encode(SrsBuffer *stream) = 0;
|
virtual srs_error_t psi_encode(SrsBuffer *stream) = 0;
|
||||||
virtual srs_error_t psi_decode(SrsBuffer *stream) = 0;
|
virtual srs_error_t psi_decode(SrsBuffer *stream) = 0;
|
||||||
|
|
@ -1226,10 +1235,12 @@ public:
|
||||||
SrsTsPayloadPAT(SrsTsPacket *p);
|
SrsTsPayloadPAT(SrsTsPacket *p);
|
||||||
virtual ~SrsTsPayloadPAT();
|
virtual ~SrsTsPayloadPAT();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t psi_decode(SrsBuffer *stream);
|
virtual srs_error_t psi_decode(SrsBuffer *stream);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int psi_size();
|
virtual int psi_size();
|
||||||
virtual srs_error_t psi_encode(SrsBuffer *stream);
|
virtual srs_error_t psi_encode(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -1331,10 +1342,12 @@ public:
|
||||||
SrsTsPayloadPMT(SrsTsPacket *p);
|
SrsTsPayloadPMT(SrsTsPacket *p);
|
||||||
virtual ~SrsTsPayloadPMT();
|
virtual ~SrsTsPayloadPMT();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t psi_decode(SrsBuffer *stream);
|
virtual srs_error_t psi_decode(SrsBuffer *stream);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int psi_size();
|
virtual int psi_size();
|
||||||
virtual srs_error_t psi_encode(SrsBuffer *stream);
|
virtual srs_error_t psi_encode(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -1366,12 +1379,14 @@ public:
|
||||||
// Write the TS message to TS context.
|
// Write the TS message to TS context.
|
||||||
class SrsTsContextWriter : public ISrsTsContextWriter
|
class SrsTsContextWriter : public ISrsTsContextWriter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// User must config the codec in right way.
|
// User must config the codec in right way.
|
||||||
SrsVideoCodecId vcodec_;
|
SrsVideoCodecId vcodec_;
|
||||||
SrsAudioCodecId acodec_;
|
SrsAudioCodecId acodec_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsTsContext *context_;
|
ISrsTsContext *context_;
|
||||||
ISrsStreamWriter *writer_;
|
ISrsStreamWriter *writer_;
|
||||||
std::string path_;
|
std::string path_;
|
||||||
|
|
@ -1411,11 +1426,13 @@ public:
|
||||||
public:
|
public:
|
||||||
srs_error_t config_cipher(unsigned char *key, unsigned char *iv);
|
srs_error_t config_cipher(unsigned char *key, unsigned char *iv);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
unsigned char *key;
|
unsigned char *key;
|
||||||
unsigned char iv[16];
|
unsigned char iv[16];
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
char *buf;
|
char *buf;
|
||||||
int nb_buf;
|
int nb_buf;
|
||||||
};
|
};
|
||||||
|
|
@ -1469,7 +1486,8 @@ public:
|
||||||
virtual SrsTsMessage *video();
|
virtual SrsTsMessage *video();
|
||||||
virtual void set_video(SrsTsMessage *msg);
|
virtual void set_video(SrsTsMessage *msg);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_cache_mp3(SrsParsedAudioPacket *frame);
|
virtual srs_error_t do_cache_mp3(SrsParsedAudioPacket *frame);
|
||||||
virtual srs_error_t do_cache_aac(SrsParsedAudioPacket *frame);
|
virtual srs_error_t do_cache_aac(SrsParsedAudioPacket *frame);
|
||||||
virtual srs_error_t do_cache_avc(SrsParsedVideoPacket *frame);
|
virtual srs_error_t do_cache_avc(SrsParsedVideoPacket *frame);
|
||||||
|
|
@ -1497,13 +1515,15 @@ public:
|
||||||
// Transmux the RTMP stream to HTTP-TS stream.
|
// Transmux the RTMP stream to HTTP-TS stream.
|
||||||
class SrsTsTransmuxer : public ISrsTsTransmuxer
|
class SrsTsTransmuxer : public ISrsTsTransmuxer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsStreamWriter *writer_;
|
ISrsStreamWriter *writer_;
|
||||||
bool has_audio_;
|
bool has_audio_;
|
||||||
bool has_video_;
|
bool has_video_;
|
||||||
bool guess_has_av_;
|
bool guess_has_av_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsFormat *format_;
|
ISrsFormat *format_;
|
||||||
ISrsTsMessageCache *tsmc_;
|
ISrsTsMessageCache *tsmc_;
|
||||||
ISrsTsContextWriter *tscw_;
|
ISrsTsContextWriter *tscw_;
|
||||||
|
|
@ -1529,7 +1549,8 @@ public:
|
||||||
virtual srs_error_t write_audio(int64_t timestamp, char *data, int size);
|
virtual srs_error_t write_audio(int64_t timestamp, char *data, int size);
|
||||||
virtual srs_error_t write_video(int64_t timestamp, char *data, int size);
|
virtual srs_error_t write_video(int64_t timestamp, char *data, int size);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t flush_audio();
|
virtual srs_error_t flush_audio();
|
||||||
virtual srs_error_t flush_video();
|
virtual srs_error_t flush_video();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -318,11 +318,13 @@ public:
|
||||||
*/
|
*/
|
||||||
class SrsAmf0Object : public SrsAmf0Any
|
class SrsAmf0Object : public SrsAmf0Any
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_internal::SrsUnSortedHashtable *properties_;
|
srs_internal::SrsUnSortedHashtable *properties_;
|
||||||
srs_internal::SrsAmf0ObjectEOF *eof_;
|
srs_internal::SrsAmf0ObjectEOF *eof_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
friend class SrsAmf0Any;
|
friend class SrsAmf0Any;
|
||||||
/**
|
/**
|
||||||
* make amf0 object to private,
|
* make amf0 object to private,
|
||||||
|
|
@ -410,12 +412,14 @@ public:
|
||||||
*/
|
*/
|
||||||
class SrsAmf0EcmaArray : public SrsAmf0Any
|
class SrsAmf0EcmaArray : public SrsAmf0Any
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_internal::SrsUnSortedHashtable *properties_;
|
srs_internal::SrsUnSortedHashtable *properties_;
|
||||||
srs_internal::SrsAmf0ObjectEOF *eof_;
|
srs_internal::SrsAmf0ObjectEOF *eof_;
|
||||||
int32_t count_;
|
int32_t count_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
friend class SrsAmf0Any;
|
friend class SrsAmf0Any;
|
||||||
/**
|
/**
|
||||||
* make amf0 object to private,
|
* make amf0 object to private,
|
||||||
|
|
@ -498,11 +502,13 @@ public:
|
||||||
*/
|
*/
|
||||||
class SrsAmf0StrictArray : public SrsAmf0Any
|
class SrsAmf0StrictArray : public SrsAmf0Any
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::vector<SrsAmf0Any *> properties_;
|
std::vector<SrsAmf0Any *> properties_;
|
||||||
int32_t count_;
|
int32_t count_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
friend class SrsAmf0Any;
|
friend class SrsAmf0Any;
|
||||||
/**
|
/**
|
||||||
* make amf0 object to private,
|
* make amf0 object to private,
|
||||||
|
|
@ -630,7 +636,8 @@ class SrsAmf0String : public SrsAmf0Any
|
||||||
public:
|
public:
|
||||||
std::string value_;
|
std::string value_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
friend class SrsAmf0Any;
|
friend class SrsAmf0Any;
|
||||||
/**
|
/**
|
||||||
* make amf0 string to private,
|
* make amf0 string to private,
|
||||||
|
|
@ -660,7 +667,8 @@ class SrsAmf0Boolean : public SrsAmf0Any
|
||||||
public:
|
public:
|
||||||
bool value_;
|
bool value_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
friend class SrsAmf0Any;
|
friend class SrsAmf0Any;
|
||||||
/**
|
/**
|
||||||
* make amf0 boolean to private,
|
* make amf0 boolean to private,
|
||||||
|
|
@ -689,7 +697,8 @@ class SrsAmf0Number : public SrsAmf0Any
|
||||||
public:
|
public:
|
||||||
double value_;
|
double value_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
friend class SrsAmf0Any;
|
friend class SrsAmf0Any;
|
||||||
/**
|
/**
|
||||||
* make amf0 number to private,
|
* make amf0 number to private,
|
||||||
|
|
@ -715,11 +724,13 @@ public:
|
||||||
*/
|
*/
|
||||||
class SrsAmf0Date : public SrsAmf0Any
|
class SrsAmf0Date : public SrsAmf0Any
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
int64_t date_value_;
|
int64_t date_value_;
|
||||||
int16_t time_zone_;
|
int16_t time_zone_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
friend class SrsAmf0Any;
|
friend class SrsAmf0Any;
|
||||||
/**
|
/**
|
||||||
* make amf0 date to private,
|
* make amf0 date to private,
|
||||||
|
|
@ -754,7 +765,8 @@ public:
|
||||||
*/
|
*/
|
||||||
class SrsAmf0Null : public SrsAmf0Any
|
class SrsAmf0Null : public SrsAmf0Any
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
friend class SrsAmf0Any;
|
friend class SrsAmf0Any;
|
||||||
/**
|
/**
|
||||||
* make amf0 null to private,
|
* make amf0 null to private,
|
||||||
|
|
@ -779,7 +791,8 @@ public:
|
||||||
*/
|
*/
|
||||||
class SrsAmf0Undefined : public SrsAmf0Any
|
class SrsAmf0Undefined : public SrsAmf0Any
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
friend class SrsAmf0Any;
|
friend class SrsAmf0Any;
|
||||||
/**
|
/**
|
||||||
* make amf0 undefined to private,
|
* make amf0 undefined to private,
|
||||||
|
|
@ -805,7 +818,8 @@ public:
|
||||||
*/
|
*/
|
||||||
class SrsUnSortedHashtable
|
class SrsUnSortedHashtable
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
typedef std::pair<std::string, SrsAmf0Any *> SrsAmf0ObjectPropertyType;
|
typedef std::pair<std::string, SrsAmf0Any *> SrsAmf0ObjectPropertyType;
|
||||||
std::vector<SrsAmf0ObjectPropertyType> properties_;
|
std::vector<SrsAmf0ObjectPropertyType> properties_;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,8 @@ public:
|
||||||
// server will add the connection to manager, and delete it when remove.
|
// server will add the connection to manager, and delete it when remove.
|
||||||
class SrsTcpConnection : public ISrsProtocolReadWriter
|
class SrsTcpConnection : public ISrsProtocolReadWriter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The underlayer st fd handler.
|
// The underlayer st fd handler.
|
||||||
srs_netfd_t stfd_;
|
srs_netfd_t stfd_;
|
||||||
// The underlayer socket.
|
// The underlayer socket.
|
||||||
|
|
@ -84,7 +85,8 @@ public:
|
||||||
// cache or buffer.
|
// cache or buffer.
|
||||||
class SrsBufferedReadWriter : public ISrsProtocolReadWriter
|
class SrsBufferedReadWriter : public ISrsProtocolReadWriter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The under-layer transport.
|
// The under-layer transport.
|
||||||
ISrsProtocolReadWriter *io_;
|
ISrsProtocolReadWriter *io_;
|
||||||
// Fixed, small and fast buffer. Note that it must be very small piece of cache, make sure matches all protocols,
|
// Fixed, small and fast buffer. Note that it must be very small piece of cache, make sure matches all protocols,
|
||||||
|
|
@ -101,7 +103,8 @@ public:
|
||||||
// Peek the head of cache to buf in size of bytes.
|
// Peek the head of cache to buf in size of bytes.
|
||||||
srs_error_t peek(char *buf, int *size);
|
srs_error_t peek(char *buf, int *size);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t reload_buffer();
|
srs_error_t reload_buffer();
|
||||||
// Interface ISrsProtocolReadWriter
|
// Interface ISrsProtocolReadWriter
|
||||||
public:
|
public:
|
||||||
|
|
@ -131,11 +134,13 @@ public:
|
||||||
// The SSL connection over TCP transport, in server mode.
|
// The SSL connection over TCP transport, in server mode.
|
||||||
class SrsSslConnection : public ISrsSslConnection
|
class SrsSslConnection : public ISrsSslConnection
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The under-layer plaintext transport.
|
// The under-layer plaintext transport.
|
||||||
ISrsProtocolReadWriter *transport_;
|
ISrsProtocolReadWriter *transport_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SSL_CTX *ssl_ctx_;
|
SSL_CTX *ssl_ctx_;
|
||||||
SSL *ssl_;
|
SSL *ssl_;
|
||||||
BIO *bio_in_;
|
BIO *bio_in_;
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,12 @@ class SrsTcpClient;
|
||||||
// The SSL client over TCP transport.
|
// The SSL client over TCP transport.
|
||||||
class SrsSslClient : public ISrsReader, public ISrsStreamWriter
|
class SrsSslClient : public ISrsReader, public ISrsStreamWriter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsProtocolReadWriter *transport_;
|
ISrsProtocolReadWriter *transport_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SSL_CTX *ssl_ctx_;
|
SSL_CTX *ssl_ctx_;
|
||||||
SSL *ssl_;
|
SSL *ssl_;
|
||||||
BIO *bio_in_;
|
BIO *bio_in_;
|
||||||
|
|
@ -82,7 +84,8 @@ public:
|
||||||
// hc.post("/api/v1/version", "Hello world!", NULL);
|
// hc.post("/api/v1/version", "Hello world!", NULL);
|
||||||
class SrsHttpClient : public ISrsHttpClient
|
class SrsHttpClient : public ISrsHttpClient
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The underlayer TCP transport, set to NULL when disconnect, or never not NULL when connected.
|
// The underlayer TCP transport, set to NULL when disconnect, or never not NULL when connected.
|
||||||
// We will disconnect transport when initialize or channel error, such as send/recv error.
|
// We will disconnect transport when initialize or channel error, such as send/recv error.
|
||||||
SrsTcpClient *transport_;
|
SrsTcpClient *transport_;
|
||||||
|
|
@ -90,7 +93,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
std::map<std::string, std::string> headers_;
|
std::map<std::string, std::string> headers_;
|
||||||
SrsNetworkKbps *kbps_;
|
SrsNetworkKbps *kbps_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The timeout in srs_utime_t.
|
// The timeout in srs_utime_t.
|
||||||
srs_utime_t timeout_;
|
srs_utime_t timeout_;
|
||||||
srs_utime_t recv_timeout_;
|
srs_utime_t recv_timeout_;
|
||||||
|
|
@ -99,7 +103,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
std::string host_;
|
std::string host_;
|
||||||
int port_;
|
int port_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsSslClient *ssl_transport_;
|
SrsSslClient *ssl_transport_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -136,7 +141,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual void kbps_sample(const char *label, srs_utime_t age);
|
virtual void kbps_sample(const char *label, srs_utime_t age);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual void disconnect();
|
virtual void disconnect();
|
||||||
virtual srs_error_t connect();
|
virtual srs_error_t connect();
|
||||||
ISrsStreamWriter *writer();
|
ISrsStreamWriter *writer();
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,8 @@ public:
|
||||||
// provides HTTP message originted service.
|
// provides HTTP message originted service.
|
||||||
class SrsHttpParser : public ISrsHttpParser
|
class SrsHttpParser : public ISrsHttpParser
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
llhttp_settings_t settings_;
|
llhttp_settings_t settings_;
|
||||||
llhttp_t parser_;
|
llhttp_t parser_;
|
||||||
// The global parse buffer.
|
// The global parse buffer.
|
||||||
|
|
@ -55,7 +56,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// Whether allow jsonp parse.
|
// Whether allow jsonp parse.
|
||||||
bool jsonp_;
|
bool jsonp_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string field_name_;
|
std::string field_name_;
|
||||||
std::string field_value_;
|
std::string field_value_;
|
||||||
SrsHttpParseState state_;
|
SrsHttpParseState state_;
|
||||||
|
|
@ -82,11 +84,14 @@ public:
|
||||||
// @remark user must free the ppmsg if not NULL.
|
// @remark user must free the ppmsg if not NULL.
|
||||||
virtual srs_error_t parse_message(ISrsReader *reader, ISrsHttpMessage **ppmsg);
|
virtual srs_error_t parse_message(ISrsReader *reader, ISrsHttpMessage **ppmsg);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// parse the HTTP message to member field: msg.
|
// parse the HTTP message to member field: msg.
|
||||||
virtual srs_error_t parse_message_imp(ISrsReader *reader);
|
virtual srs_error_t
|
||||||
|
parse_message_imp(ISrsReader *reader);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
static int on_message_begin(llhttp_t *parser);
|
static int on_message_begin(llhttp_t *parser);
|
||||||
static int on_headers_complete(llhttp_t *parser);
|
static int on_headers_complete(llhttp_t *parser);
|
||||||
static int on_message_complete(llhttp_t *parser);
|
static int on_message_complete(llhttp_t *parser);
|
||||||
|
|
@ -104,7 +109,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// documentation for Request.Write and RoundTripper.
|
// documentation for Request.Write and RoundTripper.
|
||||||
class SrsHttpMessage : public ISrsHttpMessage
|
class SrsHttpMessage : public ISrsHttpMessage
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The body object, reader object.
|
// The body object, reader object.
|
||||||
// @remark, user can get body in string by get_body().
|
// @remark, user can get body in string by get_body().
|
||||||
SrsHttpResponseReader *_body;
|
SrsHttpResponseReader *_body;
|
||||||
|
|
@ -112,7 +118,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// The transport connection, can be NULL.
|
// The transport connection, can be NULL.
|
||||||
ISrsConnection *owner_conn_;
|
ISrsConnection *owner_conn_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The request type defined as
|
// The request type defined as
|
||||||
// enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH };
|
// enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH };
|
||||||
uint8_t type_;
|
uint8_t type_;
|
||||||
|
|
@ -121,7 +128,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
llhttp_status_t _status;
|
llhttp_status_t _status;
|
||||||
int64_t _content_length;
|
int64_t _content_length;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The http headers
|
// The http headers
|
||||||
SrsHttpHeader _header;
|
SrsHttpHeader _header;
|
||||||
// Whether the request indicates should keep alive for the http connection.
|
// Whether the request indicates should keep alive for the http connection.
|
||||||
|
|
@ -129,7 +137,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// Whether the body is chunked.
|
// Whether the body is chunked.
|
||||||
bool chunked_;
|
bool chunked_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string schema_;
|
std::string schema_;
|
||||||
// The parsed url.
|
// The parsed url.
|
||||||
std::string _url;
|
std::string _url;
|
||||||
|
|
@ -140,7 +149,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// The query map
|
// The query map
|
||||||
std::map<std::string, std::string> _query;
|
std::map<std::string, std::string> _query;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Whether request is jsonp.
|
// Whether request is jsonp.
|
||||||
bool jsonp_;
|
bool jsonp_;
|
||||||
// The method in QueryString will override the HTTP method.
|
// The method in QueryString will override the HTTP method.
|
||||||
|
|
@ -253,7 +263,8 @@ public:
|
||||||
// HTTP request, the first line is RequestLine. While for HTTP response, it's StatusLine.
|
// HTTP request, the first line is RequestLine. While for HTTP response, it's StatusLine.
|
||||||
class SrsHttpMessageWriter
|
class SrsHttpMessageWriter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsProtocolReadWriter *skt_;
|
ISrsProtocolReadWriter *skt_;
|
||||||
SrsHttpHeader *hdr_;
|
SrsHttpHeader *hdr_;
|
||||||
// Before writing header, there is a chance to filter it,
|
// Before writing header, there is a chance to filter it,
|
||||||
|
|
@ -262,22 +273,26 @@ SRS_DECLARE_PRIVATE:
|
||||||
// The first line writer.
|
// The first line writer.
|
||||||
ISrsHttpFirstLineWriter *flw_;
|
ISrsHttpFirstLineWriter *flw_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
char header_cache_[SRS_HTTP_HEADER_CACHE_SIZE];
|
char header_cache_[SRS_HTTP_HEADER_CACHE_SIZE];
|
||||||
iovec *iovss_cache_;
|
iovec *iovss_cache_;
|
||||||
int nb_iovss_cache_;
|
int nb_iovss_cache_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Reply header has been (logically) written
|
// Reply header has been (logically) written
|
||||||
bool header_wrote_;
|
bool header_wrote_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The explicitly-declared Content-Length; or -1
|
// The explicitly-declared Content-Length; or -1
|
||||||
int64_t content_length_;
|
int64_t content_length_;
|
||||||
// The number of bytes written in body
|
// The number of bytes written in body
|
||||||
int64_t written_;
|
int64_t written_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The wroteHeader tells whether the header's been written to "the
|
// The wroteHeader tells whether the header's been written to "the
|
||||||
// wire" (or rather: w.conn.buf). this is unlike
|
// wire" (or rather: w.conn.buf). this is unlike
|
||||||
// (*response).wroteHeader, which tells only whether it was
|
// (*response).wroteHeader, which tells only whether it was
|
||||||
|
|
@ -306,7 +321,8 @@ public:
|
||||||
// Response writer use st socket
|
// Response writer use st socket
|
||||||
class SrsHttpResponseWriter : public ISrsHttpResponseWriter, public ISrsHttpFirstLineWriter
|
class SrsHttpResponseWriter : public ISrsHttpResponseWriter, public ISrsHttpFirstLineWriter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
SrsHttpMessageWriter *writer_;
|
SrsHttpMessageWriter *writer_;
|
||||||
// The status code passed to WriteHeader, for response only.
|
// The status code passed to WriteHeader, for response only.
|
||||||
int status_;
|
int status_;
|
||||||
|
|
@ -333,7 +349,8 @@ public:
|
||||||
// Request writer use st socket
|
// Request writer use st socket
|
||||||
class SrsHttpRequestWriter : public ISrsHttpRequestWriter, public ISrsHttpFirstLineWriter
|
class SrsHttpRequestWriter : public ISrsHttpRequestWriter, public ISrsHttpFirstLineWriter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
SrsHttpMessageWriter *writer_;
|
SrsHttpMessageWriter *writer_;
|
||||||
// The method and path passed to WriteHeader, for request only.
|
// The method and path passed to WriteHeader, for request only.
|
||||||
std::string method_;
|
std::string method_;
|
||||||
|
|
@ -358,7 +375,8 @@ public:
|
||||||
// Response reader use st socket.
|
// Response reader use st socket.
|
||||||
class SrsHttpResponseReader : public ISrsHttpResponseReader
|
class SrsHttpResponseReader : public ISrsHttpResponseReader
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsReader *skt_;
|
ISrsReader *skt_;
|
||||||
SrsHttpMessage *owner_;
|
SrsHttpMessage *owner_;
|
||||||
SrsFastStream *buffer_;
|
SrsFastStream *buffer_;
|
||||||
|
|
@ -386,7 +404,8 @@ public:
|
||||||
virtual bool eof();
|
virtual bool eof();
|
||||||
virtual srs_error_t read(void *buf, size_t size, ssize_t *nread);
|
virtual srs_error_t read(void *buf, size_t size, ssize_t *nread);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t read_chunked(void *buf, size_t size, ssize_t *nread);
|
virtual srs_error_t read_chunked(void *buf, size_t size, ssize_t *nread);
|
||||||
virtual srs_error_t read_specified(void *buf, size_t size, ssize_t *nread);
|
virtual srs_error_t read_specified(void *buf, size_t size, ssize_t *nread);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -85,13 +85,15 @@ enum SrsHttpParseState {
|
||||||
// A Header represents the key-value pairs in an HTTP header.
|
// A Header represents the key-value pairs in an HTTP header.
|
||||||
class SrsHttpHeader
|
class SrsHttpHeader
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The order in which header fields with differing field names are
|
// The order in which header fields with differing field names are
|
||||||
// received is not significant. However, it is "good practice" to send
|
// received is not significant. However, it is "good practice" to send
|
||||||
// general-header fields first, followed by request-header or response-
|
// general-header fields first, followed by request-header or response-
|
||||||
// header fields, and ending with the entity-header fields.
|
// header fields, and ending with the entity-header fields.
|
||||||
// @doc https://tools.ietf.org/html/rfc2616#section-4.2
|
// @doc https://tools.ietf.org/html/rfc2616#section-4.2
|
||||||
std::map<std::string, std::string> headers;
|
std::map<std::string, std::string>
|
||||||
|
headers;
|
||||||
// Store keys to keep fields in order.
|
// Store keys to keep fields in order.
|
||||||
std::vector<std::string> keys_;
|
std::vector<std::string> keys_;
|
||||||
|
|
||||||
|
|
@ -304,7 +306,8 @@ public:
|
||||||
// Redirect to a fixed URL
|
// Redirect to a fixed URL
|
||||||
class SrsHttpRedirectHandler : public ISrsHttpHandler
|
class SrsHttpRedirectHandler : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string url;
|
std::string url;
|
||||||
int code;
|
int code;
|
||||||
|
|
||||||
|
|
@ -341,10 +344,12 @@ extern std::string srs_http_fs_fullpath(std::string dir, std::string pattern, st
|
||||||
// http.Handle("/", SrsHttpFileServer("static-dir"))
|
// http.Handle("/", SrsHttpFileServer("static-dir"))
|
||||||
class SrsHttpFileServer : public ISrsHttpHandler
|
class SrsHttpFileServer : public ISrsHttpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
std::string dir;
|
std::string dir;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
ISrsFileReaderFactory *fs_factory;
|
ISrsFileReaderFactory *fs_factory;
|
||||||
SrsPath *path_;
|
SrsPath *path_;
|
||||||
|
|
||||||
|
|
@ -352,24 +357,30 @@ public:
|
||||||
SrsHttpFileServer(std::string root_dir);
|
SrsHttpFileServer(std::string root_dir);
|
||||||
virtual ~SrsHttpFileServer();
|
virtual ~SrsHttpFileServer();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// For utest to mock the fs.
|
// For utest to mock the fs.
|
||||||
virtual void set_fs_factory(ISrsFileReaderFactory *v);
|
virtual void
|
||||||
|
set_fs_factory(ISrsFileReaderFactory *v);
|
||||||
// For utest to mock the path utility.
|
// For utest to mock the path utility.
|
||||||
virtual void set_path(SrsPath *v);
|
virtual void set_path(SrsPath *v);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Serve the file by specified path
|
// Serve the file by specified path
|
||||||
virtual srs_error_t serve_file(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, std::string fullpath);
|
virtual srs_error_t
|
||||||
|
serve_file(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, std::string fullpath);
|
||||||
virtual srs_error_t serve_flv_file(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, std::string fullpath);
|
virtual srs_error_t serve_flv_file(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, std::string fullpath);
|
||||||
virtual srs_error_t serve_mp4_file(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, std::string fullpath);
|
virtual srs_error_t serve_mp4_file(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, std::string fullpath);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
// When access flv file with x.flv?start=xxx
|
// When access flv file with x.flv?start=xxx
|
||||||
virtual srs_error_t serve_flv_stream(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, std::string fullpath, int64_t offset);
|
virtual srs_error_t
|
||||||
|
serve_flv_stream(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, std::string fullpath, int64_t offset);
|
||||||
// When access mp4 file with x.mp4?range=start-end
|
// When access mp4 file with x.mp4?range=start-end
|
||||||
// @param start the start offset in bytes.
|
// @param start the start offset in bytes.
|
||||||
// @param end the end offset in bytes. -1 to end of file.
|
// @param end the end offset in bytes. -1 to end of file.
|
||||||
|
|
@ -388,9 +399,11 @@ SRS_DECLARE_PROTECTED:
|
||||||
// the ts file including: .ts .m4s init.mp4
|
// the ts file including: .ts .m4s init.mp4
|
||||||
virtual srs_error_t serve_ts_ctx(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, std::string fullpath);
|
virtual srs_error_t serve_ts_ctx(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, std::string fullpath);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
// Copy the fs to response writer in size bytes.
|
// Copy the fs to response writer in size bytes.
|
||||||
virtual srs_error_t copy(ISrsHttpResponseWriter *w, SrsFileReader *fs, ISrsHttpMessage *r, int64_t size);
|
virtual srs_error_t
|
||||||
|
copy(ISrsHttpResponseWriter *w, SrsFileReader *fs, ISrsHttpMessage *r, int64_t size);
|
||||||
};
|
};
|
||||||
|
|
||||||
// The mux entry for server mux.
|
// The mux entry for server mux.
|
||||||
|
|
@ -476,9 +489,11 @@ public:
|
||||||
// equivalent .- and ..-free URL.
|
// equivalent .- and ..-free URL.
|
||||||
class SrsHttpServeMux : public ISrsHttpServeMux
|
class SrsHttpServeMux : public ISrsHttpServeMux
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The pattern handler, to handle the http request.
|
// The pattern handler, to handle the http request.
|
||||||
std::map<std::string, SrsHttpMuxEntry *> static_matchers_;
|
std::map<std::string, SrsHttpMuxEntry *>
|
||||||
|
static_matchers_;
|
||||||
// The vhost handler.
|
// The vhost handler.
|
||||||
// When find the handler to process the request,
|
// When find the handler to process the request,
|
||||||
// append the matched vhost when pattern not starts with /,
|
// append the matched vhost when pattern not starts with /,
|
||||||
|
|
@ -486,11 +501,13 @@ SRS_DECLARE_PRIVATE:
|
||||||
// The path will rewrite to ossrs.net/live/livestream.flv
|
// The path will rewrite to ossrs.net/live/livestream.flv
|
||||||
std::map<std::string, ISrsHttpHandler *> vhosts_;
|
std::map<std::string, ISrsHttpHandler *> vhosts_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// all dynamic matcher for http match.
|
// all dynamic matcher for http match.
|
||||||
// For example, the hstrs(http stream trigger rtmp source)
|
// For example, the hstrs(http stream trigger rtmp source)
|
||||||
// can dynamic match and install handler when request incoming and no handler.
|
// can dynamic match and install handler when request incoming and no handler.
|
||||||
std::vector<ISrsHttpDynamicMatcher *> dynamic_matchers_;
|
std::vector<ISrsHttpDynamicMatcher *>
|
||||||
|
dynamic_matchers_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SrsHttpServeMux();
|
SrsHttpServeMux();
|
||||||
|
|
@ -518,7 +535,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t find_handler(ISrsHttpMessage *r, ISrsHttpHandler **ph);
|
virtual srs_error_t find_handler(ISrsHttpMessage *r, ISrsHttpHandler **ph);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t match(ISrsHttpMessage *r, ISrsHttpHandler **ph);
|
virtual srs_error_t match(ISrsHttpMessage *r, ISrsHttpHandler **ph);
|
||||||
virtual bool path_match(std::string pattern, std::string path);
|
virtual bool path_match(std::string pattern, std::string path);
|
||||||
};
|
};
|
||||||
|
|
@ -537,7 +555,8 @@ public:
|
||||||
// The filter http mux, directly serve the http CORS requests
|
// The filter http mux, directly serve the http CORS requests
|
||||||
class SrsHttpCorsMux : public ISrsHttpCorsMux
|
class SrsHttpCorsMux : public ISrsHttpCorsMux
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool required;
|
bool required;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
ISrsHttpHandler *next_;
|
ISrsHttpHandler *next_;
|
||||||
|
|
@ -570,7 +589,8 @@ public:
|
||||||
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/WWW-Authenticate
|
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/WWW-Authenticate
|
||||||
class SrsHttpAuthMux : public ISrsHttpAuthMux
|
class SrsHttpAuthMux : public ISrsHttpAuthMux
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool enabled_;
|
bool enabled_;
|
||||||
std::string username_;
|
std::string username_;
|
||||||
std::string password_;
|
std::string password_;
|
||||||
|
|
@ -586,7 +606,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
virtual srs_error_t serve_http(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_auth(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
virtual srs_error_t do_auth(ISrsHttpResponseWriter *w, ISrsHttpMessage *r);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -668,7 +689,8 @@ public:
|
||||||
// Used to resolve the http uri.
|
// Used to resolve the http uri.
|
||||||
class SrsHttpUri
|
class SrsHttpUri
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string url_;
|
std::string url_;
|
||||||
std::string schema_;
|
std::string schema_;
|
||||||
std::string host_;
|
std::string host_;
|
||||||
|
|
@ -702,11 +724,13 @@ public:
|
||||||
virtual std::string username();
|
virtual std::string username();
|
||||||
virtual std::string password();
|
virtual std::string password();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Simple URL parser to replace http-parser URL parsing
|
// Simple URL parser to replace http-parser URL parsing
|
||||||
virtual srs_error_t parse_url_simple(const std::string &url, std::string &schema, std::string &host, int &port,
|
virtual srs_error_t
|
||||||
std::string &path, std::string &query, std::string &fragment,
|
parse_url_simple(const std::string &url, std::string &schema, std::string &host, int &port,
|
||||||
std::string &username, std::string &password);
|
std::string &path, std::string &query, std::string &fragment,
|
||||||
|
std::string &username, std::string &password);
|
||||||
srs_error_t parse_query();
|
srs_error_t parse_query();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,8 @@ public:
|
||||||
char marker_;
|
char marker_;
|
||||||
// Don't directly create this object,
|
// Don't directly create this object,
|
||||||
// please use SrsJsonAny::str() to create a concreated one.
|
// please use SrsJsonAny::str() to create a concreated one.
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
SrsJsonAny();
|
SrsJsonAny();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -101,11 +102,13 @@ public:
|
||||||
|
|
||||||
class SrsJsonObject : public SrsJsonAny
|
class SrsJsonObject : public SrsJsonAny
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
typedef std::pair<std::string, SrsJsonAny *> SrsJsonObjectPropertyType;
|
typedef std::pair<std::string, SrsJsonAny *> SrsJsonObjectPropertyType;
|
||||||
std::vector<SrsJsonObjectPropertyType> properties_;
|
std::vector<SrsJsonObjectPropertyType> properties_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Use SrsJsonAny::object() to create it.
|
// Use SrsJsonAny::object() to create it.
|
||||||
friend class SrsJsonAny;
|
friend class SrsJsonAny;
|
||||||
SrsJsonObject();
|
SrsJsonObject();
|
||||||
|
|
@ -137,10 +140,12 @@ public:
|
||||||
|
|
||||||
class SrsJsonArray : public SrsJsonAny
|
class SrsJsonArray : public SrsJsonAny
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::vector<SrsJsonAny *> properties_;
|
std::vector<SrsJsonAny *> properties_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Use SrsJsonAny::array() to create it.
|
// Use SrsJsonAny::array() to create it.
|
||||||
friend class SrsJsonAny;
|
friend class SrsJsonAny;
|
||||||
SrsJsonArray();
|
SrsJsonArray();
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@
|
||||||
// which identify the client.
|
// which identify the client.
|
||||||
class SrsThreadContext : public ISrsContext
|
class SrsThreadContext : public ISrsContext
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::map<srs_thread_t, SrsContextId> cache_;
|
std::map<srs_thread_t, SrsContextId> cache_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -31,7 +32,8 @@ public:
|
||||||
virtual const SrsContextId &get_id();
|
virtual const SrsContextId &get_id();
|
||||||
virtual const SrsContextId &set_id(const SrsContextId &v);
|
virtual const SrsContextId &set_id(const SrsContextId &v);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual void clear_cid();
|
virtual void clear_cid();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,8 @@ class ISrsEncoder;
|
||||||
// See https://developers.google.com/protocol-buffers/docs/encoding#varints
|
// See https://developers.google.com/protocol-buffers/docs/encoding#varints
|
||||||
class SrsProtobufVarints
|
class SrsProtobufVarints
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
static int bits_len64(uint64_t x);
|
static int bits_len64(uint64_t x);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,8 @@ enum SrsStunMessageAttribute {
|
||||||
|
|
||||||
class SrsStunPacket
|
class SrsStunPacket
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint16_t message_type_;
|
uint16_t message_type_;
|
||||||
std::string username_;
|
std::string username_;
|
||||||
std::string local_ufrag_;
|
std::string local_ufrag_;
|
||||||
|
|
@ -97,7 +98,8 @@ public:
|
||||||
srs_error_t decode(const char *buf, const int nb_buf);
|
srs_error_t decode(const char *buf, const int nb_buf);
|
||||||
srs_error_t encode(const std::string &pwd, SrsBuffer *stream);
|
srs_error_t encode(const std::string &pwd, SrsBuffer *stream);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t encode_binding_response(const std::string &pwd, SrsBuffer *stream);
|
srs_error_t encode_binding_response(const std::string &pwd, SrsBuffer *stream);
|
||||||
std::string encode_username();
|
std::string encode_username();
|
||||||
std::string encode_mapped_address();
|
std::string encode_mapped_address();
|
||||||
|
|
|
||||||
|
|
@ -68,15 +68,18 @@ public:
|
||||||
// client.close();
|
// client.close();
|
||||||
class SrsBasicRtmpClient : public ISrsBasicRtmpClient
|
class SrsBasicRtmpClient : public ISrsBasicRtmpClient
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string url_;
|
std::string url_;
|
||||||
srs_utime_t connect_timeout_;
|
srs_utime_t connect_timeout_;
|
||||||
srs_utime_t stream_timeout_;
|
srs_utime_t stream_timeout_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
ISrsRequest *req_;
|
ISrsRequest *req_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsTcpClient *transport_;
|
SrsTcpClient *transport_;
|
||||||
SrsRtmpClient *client_;
|
SrsRtmpClient *client_;
|
||||||
SrsNetworkKbps *kbps_;
|
SrsNetworkKbps *kbps_;
|
||||||
|
|
@ -100,7 +103,8 @@ public:
|
||||||
virtual srs_error_t connect();
|
virtual srs_error_t connect();
|
||||||
virtual void close();
|
virtual void close();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t connect_app();
|
virtual srs_error_t connect_app();
|
||||||
virtual srs_error_t do_connect_app(std::string local_ip, bool debug);
|
virtual srs_error_t do_connect_app(std::string local_ip, bool debug);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,14 +36,16 @@ srs_error_t openssl_generate_key(char *public_key, int32_t size);
|
||||||
// The DH wrapper.
|
// The DH wrapper.
|
||||||
class SrsDH
|
class SrsDH
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
DH *pdh;
|
DH *pdh;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SrsDH();
|
SrsDH();
|
||||||
virtual ~SrsDH();
|
virtual ~SrsDH();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual void close();
|
virtual void close();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -67,7 +69,8 @@ public:
|
||||||
// user should never ignore this size.
|
// user should never ignore this size.
|
||||||
virtual srs_error_t copy_shared_key(const char *ppkey, int32_t ppkey_size, char *skey, int32_t &skey_size);
|
virtual srs_error_t copy_shared_key(const char *ppkey, int32_t ppkey_size, char *skey, int32_t &skey_size);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_initialize();
|
virtual srs_error_t do_initialize();
|
||||||
};
|
};
|
||||||
// The schema type.
|
// The schema type.
|
||||||
|
|
@ -91,7 +94,8 @@ enum srs_schema_type {
|
||||||
// @see also: http://blog.csdn.net/win_lin/article/details/13006803
|
// @see also: http://blog.csdn.net/win_lin/article/details/13006803
|
||||||
class SrsKeyBlock
|
class SrsKeyBlock
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsRand rand_;
|
SrsRand rand_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -119,10 +123,12 @@ public:
|
||||||
// @stream contains c1s1_key_bytes the key start bytes
|
// @stream contains c1s1_key_bytes the key start bytes
|
||||||
srs_error_t parse(SrsBuffer *stream);
|
srs_error_t parse(SrsBuffer *stream);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Calculate the offset of key,
|
// Calculate the offset of key,
|
||||||
// The key->offset cannot be used as the offset of key.
|
// The key->offset cannot be used as the offset of key.
|
||||||
int calc_valid_offset();
|
int
|
||||||
|
calc_valid_offset();
|
||||||
};
|
};
|
||||||
|
|
||||||
// The 764bytes digest structure
|
// The 764bytes digest structure
|
||||||
|
|
@ -133,7 +139,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// @see also: http://blog.csdn.net/win_lin/article/details/13006803
|
// @see also: http://blog.csdn.net/win_lin/article/details/13006803
|
||||||
class SrsDigestBlock
|
class SrsDigestBlock
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsRand rand_;
|
SrsRand rand_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -161,10 +168,12 @@ public:
|
||||||
// @stream contains c1s1_digest_bytes the digest start bytes
|
// @stream contains c1s1_digest_bytes the digest start bytes
|
||||||
srs_error_t parse(SrsBuffer *stream);
|
srs_error_t parse(SrsBuffer *stream);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Calculate the offset of digest,
|
// Calculate the offset of digest,
|
||||||
// The key->offset cannot be used as the offset of digest.
|
// The key->offset cannot be used as the offset of digest.
|
||||||
int calc_valid_offset();
|
int
|
||||||
|
calc_valid_offset();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsC1S1;
|
class SrsC1S1;
|
||||||
|
|
@ -174,7 +183,8 @@ class SrsC1S1;
|
||||||
// while the concrete class to implements in schema0 or schema1.
|
// while the concrete class to implements in schema0 or schema1.
|
||||||
class SrsC1S1Strategy
|
class SrsC1S1Strategy
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
SrsKeyBlock key_;
|
SrsKeyBlock key_;
|
||||||
SrsDigestBlock digest_;
|
SrsDigestBlock digest_;
|
||||||
|
|
||||||
|
|
@ -389,7 +399,8 @@ public:
|
||||||
// @see also: http://blog.csdn.net/win_lin/article/details/13006803
|
// @see also: http://blog.csdn.net/win_lin/article/details/13006803
|
||||||
class SrsC2S2
|
class SrsC2S2
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsRand rand_;
|
SrsRand rand_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,11 @@ public:
|
||||||
// Free specified count of messages.
|
// Free specified count of messages.
|
||||||
virtual void free(int count);
|
virtual void free(int count);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Zero initialize the message array.
|
// Zero initialize the message array.
|
||||||
virtual void zero(int count);
|
virtual void
|
||||||
|
zero(int count);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -121,9 +121,11 @@ public:
|
||||||
// The message type set the RTMP message type in header.
|
// The message type set the RTMP message type in header.
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
// The subpacket can override to calc the packet size.
|
// The subpacket can override to calc the packet size.
|
||||||
virtual int get_size();
|
virtual int
|
||||||
|
get_size();
|
||||||
// The subpacket can override to encode the payload to stream.
|
// The subpacket can override to encode the payload to stream.
|
||||||
// @remark never invoke the super.encode_packet, it always failed.
|
// @remark never invoke the super.encode_packet, it always failed.
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
|
|
@ -134,7 +136,8 @@ SRS_DECLARE_PROTECTED:
|
||||||
// and to send out RTMP message over RTMP chunk stream.
|
// and to send out RTMP message over RTMP chunk stream.
|
||||||
class SrsProtocol
|
class SrsProtocol
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
class AckWindowSize
|
class AckWindowSize
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -147,7 +150,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
AckWindowSize();
|
AckWindowSize();
|
||||||
};
|
};
|
||||||
// For peer in/out
|
// For peer in/out
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The underlayer socket object, send/recv bytes.
|
// The underlayer socket object, send/recv bytes.
|
||||||
ISrsProtocolReadWriter *skt_;
|
ISrsProtocolReadWriter *skt_;
|
||||||
// The requests sent out, used to build the response.
|
// The requests sent out, used to build the response.
|
||||||
|
|
@ -155,9 +159,11 @@ SRS_DECLARE_PRIVATE:
|
||||||
// value: the request command name
|
// value: the request command name
|
||||||
std::map<double, std::string> requests_;
|
std::map<double, std::string> requests_;
|
||||||
// For peer in
|
// For peer in
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The chunk stream to decode RTMP messages.
|
// The chunk stream to decode RTMP messages.
|
||||||
std::map<int, SrsChunkStream *> chunk_streams_;
|
std::map<int, SrsChunkStream *>
|
||||||
|
chunk_streams_;
|
||||||
// Cache some frequently used chunk header.
|
// Cache some frequently used chunk header.
|
||||||
// cs_cache, the chunk stream cache.
|
// cs_cache, the chunk stream cache.
|
||||||
SrsChunkStream **cs_cache_;
|
SrsChunkStream **cs_cache_;
|
||||||
|
|
@ -181,7 +187,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// When not auto response message, manual flush the messages in queue.
|
// When not auto response message, manual flush the messages in queue.
|
||||||
std::vector<SrsRtmpCommand *> manual_response_queue_;
|
std::vector<SrsRtmpCommand *> manual_response_queue_;
|
||||||
// For peer out
|
// For peer out
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Cache for multiple messages send,
|
// Cache for multiple messages send,
|
||||||
// initialize to iovec[SRS_CONSTS_IOVS_MAX] and realloc when consumed,
|
// initialize to iovec[SRS_CONSTS_IOVS_MAX] and realloc when consumed,
|
||||||
// it's ok to realloc the iovs cache, for all ptr is ok.
|
// it's ok to realloc the iovs cache, for all ptr is ok.
|
||||||
|
|
@ -338,10 +345,12 @@ public:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Send out the messages, donot free it,
|
// Send out the messages, donot free it,
|
||||||
// The caller must free the param msgs.
|
// The caller must free the param msgs.
|
||||||
virtual srs_error_t do_send_messages(SrsMediaPacket **msgs, int nb_msgs);
|
virtual srs_error_t
|
||||||
|
do_send_messages(SrsMediaPacket **msgs, int nb_msgs);
|
||||||
// Send iovs. send multiple times if exceed limits.
|
// Send iovs. send multiple times if exceed limits.
|
||||||
virtual srs_error_t do_iovs_send(iovec *iovs, int size);
|
virtual srs_error_t do_iovs_send(iovec *iovs, int size);
|
||||||
// The underlayer api for send and free packet.
|
// The underlayer api for send and free packet.
|
||||||
|
|
@ -367,13 +376,16 @@ SRS_DECLARE_PRIVATE:
|
||||||
// When message sentout, update the context.
|
// When message sentout, update the context.
|
||||||
virtual srs_error_t on_send_packet(SrsMessageHeader *mh, SrsRtmpCommand *packet);
|
virtual srs_error_t on_send_packet(SrsMessageHeader *mh, SrsRtmpCommand *packet);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// Auto response the ack message.
|
// Auto response the ack message.
|
||||||
virtual srs_error_t response_acknowledgement_message();
|
virtual srs_error_t
|
||||||
|
response_acknowledgement_message();
|
||||||
// Auto response the ping message.
|
// Auto response the ping message.
|
||||||
virtual srs_error_t response_ping_message(int32_t timestamp);
|
virtual srs_error_t response_ping_message(int32_t timestamp);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual void print_debug_info();
|
virtual void print_debug_info();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -543,7 +555,8 @@ bool srs_client_type_is_publish(SrsRtmpConnType type);
|
||||||
// For smart switch between complex and simple handshake.
|
// For smart switch between complex and simple handshake.
|
||||||
class SrsHandshakeBytes
|
class SrsHandshakeBytes
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsRand rand_;
|
SrsRand rand_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -589,10 +602,12 @@ struct SrsServerInfo {
|
||||||
// implements the client role protocol.
|
// implements the client role protocol.
|
||||||
class SrsRtmpClient
|
class SrsRtmpClient
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsHandshakeBytes *hs_bytes_;
|
SrsHandshakeBytes *hs_bytes_;
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
SrsProtocol *protocol_;
|
SrsProtocol *protocol_;
|
||||||
ISrsProtocolReadWriter *io_;
|
ISrsProtocolReadWriter *io_;
|
||||||
|
|
||||||
|
|
@ -702,7 +717,8 @@ public:
|
||||||
// such as connect to vhost/app, play stream, get audio/video data.
|
// such as connect to vhost/app, play stream, get audio/video data.
|
||||||
class SrsRtmpServer : public ISrsRtmpServer
|
class SrsRtmpServer : public ISrsRtmpServer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsHandshakeBytes *hs_bytes_;
|
SrsHandshakeBytes *hs_bytes_;
|
||||||
SrsProtocol *protocol_;
|
SrsProtocol *protocol_;
|
||||||
ISrsProtocolReadWriter *io_;
|
ISrsProtocolReadWriter *io_;
|
||||||
|
|
@ -868,13 +884,15 @@ public:
|
||||||
return protocol_->expect_message<T>(pmsg, ppacket);
|
return protocol_->expect_message<T>(pmsg, ppacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t identify_create_stream_client(SrsCreateStreamPacket *req, int stream_id, int depth, SrsRtmpConnType &type, std::string &stream_name, srs_utime_t &duration);
|
virtual srs_error_t identify_create_stream_client(SrsCreateStreamPacket *req, int stream_id, int depth, SrsRtmpConnType &type, std::string &stream_name, srs_utime_t &duration);
|
||||||
virtual srs_error_t identify_fmle_publish_client(SrsFMLEStartPacket *req, SrsRtmpConnType &type, std::string &stream_name);
|
virtual srs_error_t identify_fmle_publish_client(SrsFMLEStartPacket *req, SrsRtmpConnType &type, std::string &stream_name);
|
||||||
virtual srs_error_t identify_haivision_publish_client(SrsFMLEStartPacket *req, SrsRtmpConnType &type, std::string &stream_name);
|
virtual srs_error_t identify_haivision_publish_client(SrsFMLEStartPacket *req, SrsRtmpConnType &type, std::string &stream_name);
|
||||||
virtual srs_error_t identify_flash_publish_client(SrsPublishPacket *req, SrsRtmpConnType &type, std::string &stream_name);
|
virtual srs_error_t identify_flash_publish_client(SrsPublishPacket *req, SrsRtmpConnType &type, std::string &stream_name);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t identify_play_client(SrsPlayPacket *req, SrsRtmpConnType &type, std::string &stream_name, srs_utime_t &duration);
|
virtual srs_error_t identify_play_client(SrsPlayPacket *req, SrsRtmpConnType &type, std::string &stream_name, srs_utime_t &duration);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -907,7 +925,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -937,7 +956,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -971,7 +991,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -997,7 +1018,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -1030,7 +1052,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -1058,7 +1081,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -1109,7 +1133,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
// Factory method to create specified FMLE packet.
|
// Factory method to create specified FMLE packet.
|
||||||
|
|
@ -1145,7 +1170,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -1192,7 +1218,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -1285,7 +1312,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -1320,7 +1348,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -1346,7 +1375,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -1379,7 +1409,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -1407,7 +1438,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -1433,7 +1465,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -1463,7 +1496,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -1486,7 +1520,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -1509,7 +1544,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -1534,7 +1570,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -1565,7 +1602,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
@ -1676,7 +1714,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual int get_message_type();
|
virtual int get_message_type();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual int get_size();
|
virtual int get_size();
|
||||||
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
virtual srs_error_t encode_packet(SrsBuffer *stream);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ class SrsFormat;
|
||||||
// RTP video builder for packaging video NALUs into RTP packets
|
// RTP video builder for packaging video NALUs into RTP packets
|
||||||
class SrsRtpVideoBuilder
|
class SrsRtpVideoBuilder
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
uint16_t video_sequence_;
|
uint16_t video_sequence_;
|
||||||
uint32_t video_ssrc_;
|
uint32_t video_ssrc_;
|
||||||
uint8_t video_payload_type_;
|
uint8_t video_payload_type_;
|
||||||
|
|
|
||||||
|
|
@ -264,9 +264,11 @@ public:
|
||||||
// Encode message to string.
|
// Encode message to string.
|
||||||
virtual srs_error_t encode(std::stringstream &ss);
|
virtual srs_error_t encode(std::stringstream &ss);
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
// Sub classes override this to encode the headers.
|
// Sub classes override this to encode the headers.
|
||||||
virtual srs_error_t encode_header(std::stringstream &ss);
|
virtual srs_error_t
|
||||||
|
encode_header(std::stringstream &ss);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 10.1 OPTIONS, @see rfc2326-1998-rtsp.pdf, page 59
|
// 10.1 OPTIONS, @see rfc2326-1998-rtsp.pdf, page 59
|
||||||
|
|
@ -283,7 +285,8 @@ public:
|
||||||
SrsRtspOptionsResponse(int cseq);
|
SrsRtspOptionsResponse(int cseq);
|
||||||
virtual ~SrsRtspOptionsResponse();
|
virtual ~SrsRtspOptionsResponse();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t encode_header(std::stringstream &ss);
|
virtual srs_error_t encode_header(std::stringstream &ss);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -298,7 +301,8 @@ public:
|
||||||
SrsRtspDescribeResponse(int cseq);
|
SrsRtspDescribeResponse(int cseq);
|
||||||
virtual ~SrsRtspDescribeResponse();
|
virtual ~SrsRtspDescribeResponse();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t encode_header(std::stringstream &ss);
|
virtual srs_error_t encode_header(std::stringstream &ss);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -330,7 +334,8 @@ public:
|
||||||
SrsRtspSetupResponse(int cseq);
|
SrsRtspSetupResponse(int cseq);
|
||||||
virtual ~SrsRtspSetupResponse();
|
virtual ~SrsRtspSetupResponse();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t encode_header(std::stringstream &ss);
|
virtual srs_error_t encode_header(std::stringstream &ss);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -341,7 +346,8 @@ public:
|
||||||
SrsRtspPlayResponse(int cseq);
|
SrsRtspPlayResponse(int cseq);
|
||||||
virtual ~SrsRtspPlayResponse();
|
virtual ~SrsRtspPlayResponse();
|
||||||
|
|
||||||
SRS_DECLARE_PROTECTED:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PROTECTED: // clang-format on
|
||||||
virtual srs_error_t encode_header(std::stringstream &ss);
|
virtual srs_error_t encode_header(std::stringstream &ss);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,8 @@ public:
|
||||||
bool is_audio() const { return type_ == "audio"; }
|
bool is_audio() const { return type_ == "audio"; }
|
||||||
bool is_video() const { return type_ == "video"; }
|
bool is_video() const { return type_ == "video"; }
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t parse_attribute(const std::string &content);
|
srs_error_t parse_attribute(const std::string &content);
|
||||||
srs_error_t parse_attr_rtpmap(const std::string &value);
|
srs_error_t parse_attr_rtpmap(const std::string &value);
|
||||||
srs_error_t parse_attr_rtcp(const std::string &value);
|
srs_error_t parse_attr_rtcp(const std::string &value);
|
||||||
|
|
@ -166,7 +167,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
srs_error_t parse_attr_ssrc_group(const std::string &value);
|
srs_error_t parse_attr_ssrc_group(const std::string &value);
|
||||||
srs_error_t parse_attr_extmap(const std::string &value);
|
srs_error_t parse_attr_extmap(const std::string &value);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsSSRCInfo &fetch_or_create_ssrc_info(uint32_t ssrc);
|
SrsSSRCInfo &fetch_or_create_ssrc_info(uint32_t ssrc);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -224,10 +226,12 @@ public:
|
||||||
std::string get_ice_pwd() const;
|
std::string get_ice_pwd() const;
|
||||||
std::string get_dtls_role() const;
|
std::string get_dtls_role() const;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t parse_line(const std::string &line);
|
srs_error_t parse_line(const std::string &line);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t parse_origin(const std::string &content);
|
srs_error_t parse_origin(const std::string &content);
|
||||||
srs_error_t parse_version(const std::string &content);
|
srs_error_t parse_version(const std::string &content);
|
||||||
srs_error_t parse_session_name(const std::string &content);
|
srs_error_t parse_session_name(const std::string &content);
|
||||||
|
|
@ -237,7 +241,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
srs_error_t parse_media_description(const std::string &content);
|
srs_error_t parse_media_description(const std::string &content);
|
||||||
srs_error_t parse_attr_group(const std::string &content);
|
srs_error_t parse_attr_group(const std::string &content);
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
bool in_media_session_;
|
bool in_media_session_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,8 @@ extern srs_error_t srs_srt_get_remote_ip_port(srs_srt_t srt_fd, std::string &ip,
|
||||||
// Get SRT stats.
|
// Get SRT stats.
|
||||||
class SrsSrtStat
|
class SrsSrtStat
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
void *stat_;
|
void *stat_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -178,12 +179,14 @@ public:
|
||||||
// Unsubscribed OUT event to srt poller.
|
// Unsubscribed OUT event to srt poller.
|
||||||
srs_error_t disable_write();
|
srs_error_t disable_write();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t enable_event(int event);
|
srs_error_t enable_event(int event);
|
||||||
srs_error_t disable_event(int event);
|
srs_error_t disable_event(int event);
|
||||||
srs_error_t check_error();
|
srs_error_t check_error();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_srt_t srt_fd_;
|
srs_srt_t srt_fd_;
|
||||||
// Mark if some error occured in srt socket.
|
// Mark if some error occured in srt socket.
|
||||||
bool has_error_;
|
bool has_error_;
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,8 @@ extern int srs_mutex_unlock(srs_mutex_t mutex);
|
||||||
// cond->signal();
|
// cond->signal();
|
||||||
class SrsCond : public ISrsCond
|
class SrsCond : public ISrsCond
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_cond_t cond_;
|
srs_cond_t cond_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -111,7 +112,8 @@ public:
|
||||||
// SrsLocker(mutex->get());
|
// SrsLocker(mutex->get());
|
||||||
class SrsMutex
|
class SrsMutex
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_mutex_t mutex_;
|
srs_mutex_t mutex_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -153,7 +155,8 @@ extern bool srs_is_never_timeout(srs_utime_t tm);
|
||||||
|
|
||||||
class impl__SrsLocker
|
class impl__SrsLocker
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_mutex_t *lock_;
|
srs_mutex_t *lock_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -174,7 +177,8 @@ public:
|
||||||
// that is, the sync socket mechanism.
|
// that is, the sync socket mechanism.
|
||||||
class SrsStSocket : public ISrsProtocolReadWriter
|
class SrsStSocket : public ISrsProtocolReadWriter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
// The recv/send timeout in srs_utime_t.
|
// The recv/send timeout in srs_utime_t.
|
||||||
// @remark Use SRS_UTIME_NO_TIMEOUT for never timeout.
|
// @remark Use SRS_UTIME_NO_TIMEOUT for never timeout.
|
||||||
srs_utime_t rtm_;
|
srs_utime_t rtm_;
|
||||||
|
|
@ -190,7 +194,8 @@ public:
|
||||||
SrsStSocket(srs_netfd_t fd);
|
SrsStSocket(srs_netfd_t fd);
|
||||||
virtual ~SrsStSocket();
|
virtual ~SrsStSocket();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
void init(srs_netfd_t fd);
|
void init(srs_netfd_t fd);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -220,11 +225,13 @@ public:
|
||||||
// @remark User can directly free the object, which will close the fd.
|
// @remark User can directly free the object, which will close the fd.
|
||||||
class SrsTcpClient : public ISrsProtocolReadWriter
|
class SrsTcpClient : public ISrsProtocolReadWriter
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_netfd_t stfd_;
|
srs_netfd_t stfd_;
|
||||||
SrsStSocket *io_;
|
SrsStSocket *io_;
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::string host_;
|
std::string host_;
|
||||||
int port_;
|
int port_;
|
||||||
// The timeout in srs_utime_t.
|
// The timeout in srs_utime_t.
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,8 @@ public:
|
||||||
// TODO: FIXME: add utest for it.
|
// TODO: FIXME: add utest for it.
|
||||||
class SrsFastStream
|
class SrsFastStream
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
#ifdef SRS_PERF_MERGED_READ
|
#ifdef SRS_PERF_MERGED_READ
|
||||||
// the merged handler
|
// the merged handler
|
||||||
bool merged_read_;
|
bool merged_read_;
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,8 @@ public:
|
||||||
return cp;
|
return cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
MockSrsContextId *bind_;
|
MockSrsContextId *bind_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,8 @@ public:
|
||||||
// @remark The size of memory to allocate, should smaller than page size, generally 4096 bytes.
|
// @remark The size of memory to allocate, should smaller than page size, generally 4096 bytes.
|
||||||
class MockProtectedBuffer
|
class MockProtectedBuffer
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
char *raw_memory_;
|
char *raw_memory_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -139,7 +140,8 @@ public:
|
||||||
// The chan never free the args, you must manage the memory.
|
// The chan never free the args, you must manage the memory.
|
||||||
class SrsCoroutineChan
|
class SrsCoroutineChan
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
std::vector<void *> args_;
|
std::vector<void *> args_;
|
||||||
srs_mutex_t lock_;
|
srs_mutex_t lock_;
|
||||||
|
|
||||||
|
|
@ -206,7 +208,7 @@ public:
|
||||||
#define SRS_COROUTINE_GO_IMPL(context, id, code_block) \
|
#define SRS_COROUTINE_GO_IMPL(context, id, code_block) \
|
||||||
class AnonymousCoroutineHandler##id : public ISrsCoroutineHandler \
|
class AnonymousCoroutineHandler##id : public ISrsCoroutineHandler \
|
||||||
{ \
|
{ \
|
||||||
SRS_DECLARE_PRIVATE: \
|
public: \
|
||||||
SrsCoroutineChan *ctx_; \
|
SrsCoroutineChan *ctx_; \
|
||||||
\
|
\
|
||||||
public: \
|
public: \
|
||||||
|
|
@ -283,7 +285,8 @@ public:
|
||||||
// but with proper HTTP response formatting
|
// but with proper HTTP response formatting
|
||||||
class SrsHttpTestServer : public ISrsCoroutineHandler
|
class SrsHttpTestServer : public ISrsCoroutineHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
srs_netfd_t fd_;
|
srs_netfd_t fd_;
|
||||||
string response_body_;
|
string response_body_;
|
||||||
|
|
@ -304,14 +307,16 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_cycle(srs_netfd_t cfd);
|
virtual srs_error_t do_cycle(srs_netfd_t cfd);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Simple HTTPS test server similar to Go's httptest.NewServer but with SSL support
|
// Simple HTTPS test server similar to Go's httptest.NewServer but with SSL support
|
||||||
class SrsHttpsTestServer : public ISrsCoroutineHandler
|
class SrsHttpsTestServer : public ISrsCoroutineHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
srs_netfd_t fd_;
|
srs_netfd_t fd_;
|
||||||
string response_body_;
|
string response_body_;
|
||||||
|
|
@ -329,10 +334,12 @@ public:
|
||||||
virtual int get_port();
|
virtual int get_port();
|
||||||
|
|
||||||
// Interface ISrsCoroutineHandler
|
// Interface ISrsCoroutineHandler
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_error_t handle_client(srs_netfd_t client_fd);
|
srs_error_t handle_client(srs_netfd_t client_fd);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -340,7 +347,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// This server handles basic RTMP handshake and connect app operations
|
// This server handles basic RTMP handshake and connect app operations
|
||||||
class SrsRtmpTestServer : public ISrsCoroutineHandler
|
class SrsRtmpTestServer : public ISrsCoroutineHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
srs_netfd_t fd_;
|
srs_netfd_t fd_;
|
||||||
string app_;
|
string app_;
|
||||||
|
|
@ -366,7 +374,8 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
virtual srs_error_t do_cycle(srs_netfd_t cfd);
|
virtual srs_error_t do_cycle(srs_netfd_t cfd);
|
||||||
virtual srs_error_t handle_rtmp_client(srs_netfd_t cfd);
|
virtual srs_error_t handle_rtmp_client(srs_netfd_t cfd);
|
||||||
};
|
};
|
||||||
|
|
@ -374,7 +383,8 @@ SRS_DECLARE_PRIVATE:
|
||||||
// Test TCP server for testing SrsTcpConnection
|
// Test TCP server for testing SrsTcpConnection
|
||||||
class SrsTestTcpServer : public ISrsCoroutineHandler, public ISrsTcpHandler
|
class SrsTestTcpServer : public ISrsCoroutineHandler, public ISrsTcpHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
SrsTcpListener *listener_;
|
SrsTcpListener *listener_;
|
||||||
string ip_;
|
string ip_;
|
||||||
|
|
@ -403,7 +413,8 @@ public:
|
||||||
// Test TCP client for testing SrsTcpConnection
|
// Test TCP client for testing SrsTcpConnection
|
||||||
class SrsTestTcpClient
|
class SrsTestTcpClient
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsTcpClient *client_;
|
SrsTcpClient *client_;
|
||||||
SrsTcpConnection *conn_;
|
SrsTcpConnection *conn_;
|
||||||
string host_;
|
string host_;
|
||||||
|
|
@ -425,7 +436,8 @@ public:
|
||||||
// Test UDP server for testing UDP socket communication
|
// Test UDP server for testing UDP socket communication
|
||||||
class SrsUdpTestServer : public ISrsCoroutineHandler
|
class SrsUdpTestServer : public ISrsCoroutineHandler
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_netfd_t lfd_;
|
srs_netfd_t lfd_;
|
||||||
ISrsCoroutine *trd_;
|
ISrsCoroutine *trd_;
|
||||||
SrsStSocket *socket_;
|
SrsStSocket *socket_;
|
||||||
|
|
@ -450,7 +462,8 @@ public:
|
||||||
// Test UDP client for testing UDP socket communication
|
// Test UDP client for testing UDP socket communication
|
||||||
class SrsUdpTestClient
|
class SrsUdpTestClient
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
srs_netfd_t stfd_;
|
srs_netfd_t stfd_;
|
||||||
SrsStSocket *socket_;
|
SrsStSocket *socket_;
|
||||||
string host_;
|
string host_;
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ using namespace std;
|
||||||
#include <srs_app_ffmpeg.hpp>
|
#include <srs_app_ffmpeg.hpp>
|
||||||
#include <srs_app_http_conn.hpp>
|
#include <srs_app_http_conn.hpp>
|
||||||
#include <srs_app_mpegts_udp.hpp>
|
#include <srs_app_mpegts_udp.hpp>
|
||||||
|
#include <srs_app_process.hpp>
|
||||||
#include <srs_app_recv_thread.hpp>
|
#include <srs_app_recv_thread.hpp>
|
||||||
#include <srs_kernel_error.hpp>
|
#include <srs_kernel_error.hpp>
|
||||||
#include <srs_kernel_packet.hpp>
|
#include <srs_kernel_packet.hpp>
|
||||||
|
|
@ -3248,7 +3249,7 @@ MockAppConfigForEncoder::MockAppConfigForEncoder()
|
||||||
transcode_enabled_ = true;
|
transcode_enabled_ = true;
|
||||||
transcode_ffmpeg_bin_ = "/usr/bin/ffmpeg";
|
transcode_ffmpeg_bin_ = "/usr/bin/ffmpeg";
|
||||||
engine_enabled_ = true;
|
engine_enabled_ = true;
|
||||||
target_scope_ = ""; // Default to vhost scope (empty string)
|
target_scope_ = ""; // Default to vhost scope (empty string)
|
||||||
}
|
}
|
||||||
|
|
||||||
MockAppConfigForEncoder::~MockAppConfigForEncoder()
|
MockAppConfigForEncoder::~MockAppConfigForEncoder()
|
||||||
|
|
@ -3314,7 +3315,7 @@ MockAppFactoryForEncoder::~MockAppFactoryForEncoder()
|
||||||
|
|
||||||
ISrsFFMPEG *MockAppFactoryForEncoder::create_ffmpeg(std::string ffmpeg_bin)
|
ISrsFFMPEG *MockAppFactoryForEncoder::create_ffmpeg(std::string ffmpeg_bin)
|
||||||
{
|
{
|
||||||
return (ISrsFFMPEG*)mock_ffmpeg_;
|
return (ISrsFFMPEG *)mock_ffmpeg_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MockAppFactoryForEncoder::reset()
|
void MockAppFactoryForEncoder::reset()
|
||||||
|
|
@ -3381,7 +3382,7 @@ VOID TEST(EncoderTest, ParseScopeEnginesAndClearEngines)
|
||||||
mock_config->transcode_ffmpeg_bin_ = "/usr/bin/ffmpeg";
|
mock_config->transcode_ffmpeg_bin_ = "/usr/bin/ffmpeg";
|
||||||
mock_config->transcode_engines_.push_back(engine_conf);
|
mock_config->transcode_engines_.push_back(engine_conf);
|
||||||
mock_config->engine_enabled_ = true;
|
mock_config->engine_enabled_ = true;
|
||||||
mock_config->target_scope_ = "live/livestream"; // Stream scope
|
mock_config->target_scope_ = "live/livestream"; // Stream scope
|
||||||
|
|
||||||
// Create mock factory
|
// Create mock factory
|
||||||
SrsUniquePtr<MockAppFactoryForEncoder> mock_factory(new MockAppFactoryForEncoder());
|
SrsUniquePtr<MockAppFactoryForEncoder> mock_factory(new MockAppFactoryForEncoder());
|
||||||
|
|
@ -3416,7 +3417,7 @@ VOID TEST(EncoderTest, ParseScopeEnginesAndClearEngines)
|
||||||
// Verify that at() method returns the correct engine
|
// Verify that at() method returns the correct engine
|
||||||
ISrsFFMPEG *ffmpeg_at_0 = encoder->at(0);
|
ISrsFFMPEG *ffmpeg_at_0 = encoder->at(0);
|
||||||
EXPECT_TRUE(ffmpeg_at_0 != NULL);
|
EXPECT_TRUE(ffmpeg_at_0 != NULL);
|
||||||
EXPECT_EQ((ISrsFFMPEG*)mock_ffmpeg, ffmpeg_at_0);
|
EXPECT_EQ((ISrsFFMPEG *)mock_ffmpeg, ffmpeg_at_0);
|
||||||
|
|
||||||
// Test clear_engines() - should free all engines and remove from _transcoded_url
|
// Test clear_engines() - should free all engines and remove from _transcoded_url
|
||||||
encoder->clear_engines();
|
encoder->clear_engines();
|
||||||
|
|
@ -3456,11 +3457,11 @@ VOID TEST(EncoderTest, InitializeFFmpegMajorScenario)
|
||||||
// Create mock engine directive with args for variable substitution
|
// Create mock engine directive with args for variable substitution
|
||||||
SrsUniquePtr<SrsConfDirective> engine(new SrsConfDirective());
|
SrsUniquePtr<SrsConfDirective> engine(new SrsConfDirective());
|
||||||
engine->name_ = "engine";
|
engine->name_ = "engine";
|
||||||
engine->args_.push_back("hd"); // engine name for [engine] substitution
|
engine->args_.push_back("hd"); // engine name for [engine] substitution
|
||||||
|
|
||||||
// Configure mock config to return output URL with variables
|
// Configure mock config to return output URL with variables
|
||||||
// The output URL will be processed by initialize_ffmpeg to replace variables
|
// The output URL will be processed by initialize_ffmpeg to replace variables
|
||||||
mock_config->get_engine_output(engine.get()); // Will return "rtmp://127.0.0.1/live/livestream_hd"
|
mock_config->get_engine_output(engine.get()); // Will return "rtmp://127.0.0.1/live/livestream_hd"
|
||||||
|
|
||||||
// Create SrsEncoder and inject mock dependencies
|
// Create SrsEncoder and inject mock dependencies
|
||||||
SrsUniquePtr<SrsEncoder> encoder(new SrsEncoder());
|
SrsUniquePtr<SrsEncoder> encoder(new SrsEncoder());
|
||||||
|
|
@ -3482,3 +3483,51 @@ VOID TEST(EncoderTest, InitializeFFmpegMajorScenario)
|
||||||
// Clean up - set to NULL to avoid double-free
|
// Clean up - set to NULL to avoid double-free
|
||||||
encoder->config_ = NULL;
|
encoder->config_ = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID TEST(ProcessTest, InitializeWithRedirection)
|
||||||
|
{
|
||||||
|
srs_error_t err;
|
||||||
|
|
||||||
|
// Create SrsProcess instance
|
||||||
|
SrsUniquePtr<SrsProcess> process(new SrsProcess());
|
||||||
|
|
||||||
|
// Test major use scenario: FFmpeg command with stdout and stderr redirection
|
||||||
|
// Simulates: ffmpeg -i input.flv -c copy output.flv 1>/dev/null 2>/dev/null
|
||||||
|
string binary = "/usr/bin/ffmpeg";
|
||||||
|
vector<string> argv;
|
||||||
|
argv.push_back("/usr/bin/ffmpeg");
|
||||||
|
argv.push_back("-i");
|
||||||
|
argv.push_back("input.flv");
|
||||||
|
argv.push_back("-c");
|
||||||
|
argv.push_back("copy");
|
||||||
|
argv.push_back("output.flv");
|
||||||
|
argv.push_back("1>/dev/null");
|
||||||
|
argv.push_back("2>/dev/null");
|
||||||
|
|
||||||
|
// Initialize the process
|
||||||
|
HELPER_EXPECT_SUCCESS(process->initialize(binary, argv));
|
||||||
|
|
||||||
|
// Verify binary is set correctly
|
||||||
|
EXPECT_STREQ("/usr/bin/ffmpeg", process->bin_.c_str());
|
||||||
|
|
||||||
|
// Verify stdout redirection is parsed correctly
|
||||||
|
EXPECT_STREQ("/dev/null", process->stdout_file_.c_str());
|
||||||
|
|
||||||
|
// Verify stderr redirection is parsed correctly
|
||||||
|
EXPECT_STREQ("/dev/null", process->stderr_file_.c_str());
|
||||||
|
|
||||||
|
// Verify params_ contains only the actual command parameters (without redirection)
|
||||||
|
EXPECT_EQ(6, (int)process->params_.size());
|
||||||
|
EXPECT_STREQ("/usr/bin/ffmpeg", process->params_[0].c_str());
|
||||||
|
EXPECT_STREQ("-i", process->params_[1].c_str());
|
||||||
|
EXPECT_STREQ("input.flv", process->params_[2].c_str());
|
||||||
|
EXPECT_STREQ("-c", process->params_[3].c_str());
|
||||||
|
EXPECT_STREQ("copy", process->params_[4].c_str());
|
||||||
|
EXPECT_STREQ("output.flv", process->params_[5].c_str());
|
||||||
|
|
||||||
|
// Verify actual_cli_ contains command without redirection
|
||||||
|
EXPECT_STREQ("/usr/bin/ffmpeg -i input.flv -c copy output.flv", process->actual_cli_.c_str());
|
||||||
|
|
||||||
|
// Verify cli_ contains full original command with redirection
|
||||||
|
EXPECT_STREQ("/usr/bin/ffmpeg -i input.flv -c copy output.flv 1>/dev/null 2>/dev/null", process->cli_.c_str());
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -727,7 +727,7 @@ public:
|
||||||
std::string transcode_ffmpeg_bin_;
|
std::string transcode_ffmpeg_bin_;
|
||||||
std::vector<SrsConfDirective *> transcode_engines_;
|
std::vector<SrsConfDirective *> transcode_engines_;
|
||||||
bool engine_enabled_;
|
bool engine_enabled_;
|
||||||
std::string target_scope_; // The scope for which to return transcode_directive_
|
std::string target_scope_; // The scope for which to return transcode_directive_
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MockAppConfigForEncoder();
|
MockAppConfigForEncoder();
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,8 @@ public:
|
||||||
// Mock ISrsLiveSource for testing SrsOriginHub::on_audio
|
// Mock ISrsLiveSource for testing SrsOriginHub::on_audio
|
||||||
class MockLiveSourceForOriginHub : public ISrsLiveSource
|
class MockLiveSourceForOriginHub : public ISrsLiveSource
|
||||||
{
|
{
|
||||||
SRS_DECLARE_PRIVATE:
|
// clang-format off
|
||||||
|
SRS_DECLARE_PRIVATE: // clang-format on
|
||||||
SrsRtmpFormat *format_;
|
SrsRtmpFormat *format_;
|
||||||
SrsMetaCache *meta_;
|
SrsMetaCache *meta_;
|
||||||
|
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user