AI: Add utest to cover process module

This commit is contained in:
OSSRS-AI 2025-10-15 07:24:24 -04:00 committed by winlin
parent 315ae2cd3a
commit 5d01393307
109 changed files with 2278 additions and 1123 deletions

View File

@ -5,6 +5,7 @@
# ColumnLimit: 0
# IndentWidth: 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.
---
Language: Cpp
@ -198,6 +199,9 @@ LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ''
MacroBlockEnd: ''
Macros:
- 'SRS_DECLARE_PRIVATE=private:'
- 'SRS_DECLARE_PROTECTED=protected:'
MainIncludeChar: Quote
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None

View File

@ -53,10 +53,12 @@ public:
// That is, the task is execute/call in async mode.
class SrsAsyncCallWorker : public ISrsCoroutineHandler, public ISrsAsyncCallWorker
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsCoroutine *trd_;
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
std::vector<ISrsAsyncCallTask *> tasks_;
srs_cond_t wait_;
srs_mutex_t lock_;
@ -76,7 +78,8 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual void flush_tasks();
};

View File

@ -49,10 +49,12 @@ public:
// A TCP listener, for flv stream server.
class SrsHttpFlvListener : public ISrsHttpFlvListener
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsTcpListener *listener_;
ISrsAppCasterFlv *caster_;
@ -83,10 +85,12 @@ public:
// The stream caster for flv stream over HTTP POST.
class SrsAppCasterFlv : public ISrsAppCasterFlv
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string output_;
SrsHttpServeMux *http_mux_;
std::vector<ISrsConnection *> conns_;
@ -135,11 +139,13 @@ public:
// The dynamic http connection, never drop the body.
class SrsDynamicHttpConn : public ISrsDynamicHttpConn
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsAppFactory *app_factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The manager object to manage the connection.
ISrsResourceManager *manager_;
std::string output_;
@ -148,7 +154,8 @@ SRS_DECLARE_PRIVATE:
ISrsProtocolReadWriter *skt_;
ISrsHttpConn *conn_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The ip and port of client.
std::string ip_;
int port_;
@ -160,7 +167,8 @@ public:
public:
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);
// Extract APIs from SrsTcpConnection.
// Interface ISrsHttpConnOwner.
@ -194,7 +202,8 @@ public:
// The http wrapper for file reader, to read http post stream like a file.
class SrsHttpFileReader : public ISrsHttpFileReader
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsHttpResponseReader *http_;
SrsFileReader *file_reader_;

View File

@ -48,7 +48,8 @@ public:
class SrsCircuitBreaker : public ISrsCircuitBreaker, public ISrsFastTimerHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool enabled_;
int high_threshold_;
int high_pulse_;
@ -57,7 +58,8 @@ SRS_DECLARE_PRIVATE:
int dying_threshold_;
int dying_pulse_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
int hybrid_high_water_level_;
int hybrid_critical_water_level_;
int hybrid_dying_water_level_;
@ -74,7 +76,8 @@ public:
bool hybrid_critical_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);
};

View File

@ -65,7 +65,8 @@ namespace srs_internal
// The buffer of config content.
class SrsConfigBuffer
{
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
// The last available position.
char *last_;
// The end of buffer.
@ -228,7 +229,8 @@ public:
virtual SrsJsonAny *dumps_arg0_to_number();
virtual SrsJsonAny *dumps_arg0_to_boolean();
// private parse.
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The directive parsing context.
enum SrsDirectiveContext {
// The root directives, parsing file.
@ -606,7 +608,8 @@ class SrsConfig : public ISrsAppConfig
{
friend class SrsConfDirective;
// user command
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Whether show help and exit.
bool show_help_;
// Whether test config file and exit.
@ -619,29 +622,35 @@ SRS_DECLARE_PRIVATE:
// Set it by argv "-e" or env "SRS_ENV_ONLY=on".
bool env_only_;
// global env variables.
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The user parameters, the argc and argv.
// The argv is " ".join(argv), where argv is from main(argc, argv).
std::string argv_;
// current working directory.
std::string cwd_;
// Config section
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The last parsed config file.
// If reload, reload the config file.
std::string config_file_;
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
// The directive root.
SrsConfDirective *root_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The cache for parsing the config from environment variables.
SrsConfDirective *env_cache_;
// Reload section
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The reload subscribers, when reload, callback all handlers.
std::vector<ISrsReloadHandler *> subscribes_;
std::vector<ISrsReloadHandler *>
subscribes_;
public:
SrsConfig();
@ -657,37 +666,46 @@ public:
// @remark, user can test the config before reload it.
virtual srs_error_t reload(SrsReloadState *pstate);
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
// Reload from the config.
// @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
public:
// 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,
// because we may change the workdir.
virtual srs_error_t initialize_cwd();
// Marshal current config to file.
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);
public:
// Dumps the http_api sections to json for raw api info.
virtual srs_error_t raw_to_json(SrsJsonObject *obj);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
public:
// 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.
virtual srs_error_t parse_argv(int &i, char **argv);
virtual srs_error_t
parse_argv(int &i, char **argv);
// Print help and exit.
virtual void print_help(char **argv);
@ -695,23 +713,28 @@ public:
// Parse the config file, which is specified by cli.
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.
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:
// Check the parsed 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_number_connections();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
// Parse config from the buffer.
// @param buffer, the config buffer, user must delete it.
// @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
public:
// Get the current work directory.
@ -731,9 +754,11 @@ public:
// Whether srs in docker.
virtual bool get_in_docker();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Whether user use full.conf
virtual bool is_full_config();
virtual bool
is_full_config();
public:
// Get the server id, generated a random one if not configured.
@ -845,7 +870,8 @@ public:
virtual bool get_rtc_server_black_hole();
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();
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(SrsConfDirective *vhost);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Get the global chunk size.
virtual int get_global_chunk_size();
virtual int
get_global_chunk_size();
// forward section
public:
// Whether the forwarder enabled.
@ -1028,7 +1056,8 @@ public:
// Get the default streamid when client doesn't provide one.
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);
public:
@ -1037,9 +1066,11 @@ public:
bool get_srt_to_rtmp(std::string vhost);
// http_hooks section
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// 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:
// Whether vhost http-hooks enabled.
@ -1185,9 +1216,11 @@ public:
// @remark, we will use some variable, for instance, [vhost] to substitude with vhost.
virtual std::string get_engine_output(SrsConfDirective *conf);
// vhost exec secion
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Get the exec directive of vhost.
virtual SrsConfDirective *get_exec(std::string vhost);
virtual SrsConfDirective *
get_exec(std::string vhost);
public:
// Whether the exec is enabled of vhost.
@ -1226,7 +1259,8 @@ public:
// The ffmpeg log level.
virtual std::string get_ff_log_level();
// The MPEG-DASH section.
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual SrsConfDirective *get_dash(std::string vhost);
public:
@ -1250,9 +1284,11 @@ public:
// The timeout in srs_utime_t to dispose the dash.
virtual srs_utime_t get_dash_dispose(std::string vhost);
// hls section
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Get the hls directive of vhost.
virtual SrsConfDirective *get_hls(std::string vhost);
virtual SrsConfDirective *
get_hls(std::string vhost);
public:
// Whether HLS is enabled.
@ -1319,9 +1355,11 @@ public:
// Old fragments are kept. Default is on.
virtual bool get_hls_recover(std::string vhost);
// hds section
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Get the hds directive of vhost.
virtual SrsConfDirective *get_hds(const std::string &vhost);
virtual SrsConfDirective *
get_hds(const std::string &vhost);
public:
// Whether HDS is enabled.
@ -1335,9 +1373,11 @@ public:
// a window is a set of hds fragments.
virtual srs_utime_t get_hds_window(const std::string &vhost);
// dvr section
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Get the dvr directive.
virtual SrsConfDirective *get_dvr(std::string vhost);
virtual SrsConfDirective *
get_dvr(std::string vhost);
public:
// Whether dvr is enabled.
@ -1357,9 +1397,11 @@ public:
// Get the time_jitter algorithm for dvr.
virtual int get_dvr_time_jitter(std::string vhost);
// http api section
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Whether http api enabled
virtual bool get_http_api_enabled(SrsConfDirective *conf);
virtual bool
get_http_api_enabled(SrsConfDirective *conf);
public:
// Whether http api enabled.
@ -1383,7 +1425,8 @@ public:
// Get the http api auth password.
virtual std::string get_http_api_auth_password();
// https api section
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsConfDirective *get_https_api();
public:
@ -1392,9 +1435,11 @@ public:
virtual std::string get_https_api_ssl_key();
virtual std::string get_https_api_ssl_cert();
// http stream section
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Whether http stream enabled.
virtual bool get_http_stream_enabled(SrsConfDirective *conf);
virtual bool
get_http_stream_enabled(SrsConfDirective *conf);
public:
// Whether http stream enabled.
@ -1406,7 +1451,8 @@ public:
// Whether enable crossdomain for http static and stream server.
virtual bool get_http_stream_crossdomain();
// https api section
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsConfDirective *get_https_stream();
public:
@ -1416,7 +1462,8 @@ public:
virtual std::string get_https_stream_ssl_key();
virtual std::string get_https_stream_ssl_cert();
// rtmps section
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsConfDirective *get_rtmps();
public:
@ -1453,9 +1500,11 @@ public:
// used to generate the flv stream mount path.
virtual std::string get_vhost_http_remux_mount(std::string vhost);
// http heartbeat section
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Get the heartbeat directive.
virtual SrsConfDirective *get_heartbeat();
virtual SrsConfDirective *
get_heartbeat();
public:
// Whether heartbeat enabled.
@ -1470,9 +1519,11 @@ public:
virtual bool get_heartbeat_summaries();
bool get_heartbeat_ports();
// stats section
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Get the stats directive.
virtual SrsConfDirective *get_stats();
virtual SrsConfDirective *
get_stats();
public:
// Whether enabled stats.

View File

@ -19,13 +19,16 @@ class SrsLiveSource;
// For origin cluster.
class SrsCoWorkers
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
static SrsCoWorkers *instance_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::map<std::string, ISrsRequest *> streams_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsCoWorkers();
virtual ~SrsCoWorkers();
@ -35,7 +38,8 @@ public:
public:
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);
public:

View File

@ -49,7 +49,8 @@ public:
// The init mp4 for FMP4.
class SrsInitMp4 : public ISrsInitMp4
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsFileWriter *fw_;
ISrsMp4M2tsInitEncoder *init_;
ISrsFragment *fragment_;
@ -96,10 +97,12 @@ public:
// The FMP4(Fragmented MP4) for DASH streaming.
class SrsFragmentedMp4 : public ISrsFragmentedMp4
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsFileWriter *fw_;
ISrsMp4M2tsSegmentEncoder *enc_;
ISrsFragment *fragment_;
@ -160,14 +163,17 @@ public:
// The writer to write MPD for DASH.
class SrsMpdWriter : public ISrsMpdWriter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsAppFactory *app_factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The duration of fragment in srs_utime_t.
srs_utime_t fragment_;
// The period to update the mpd in srs_utime_t.
@ -187,7 +193,8 @@ SRS_DECLARE_PRIVATE:
// The number of current audio segment.
uint64_t audio_number_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The home for fragment, relative to home.
std::string fragment_home_;
@ -235,16 +242,19 @@ public:
// The controller for DASH, control the MPD and FMP4 generating system.
class SrsDashController : public ISrsDashController
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsAppFactory *app_factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
SrsFormat *format_;
ISrsMpdWriter *mpd_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsFragmentedMp4 *vcurrent_;
ISrsFragmentWindow *vfragments_;
ISrsFragmentedMp4 *acurrent_;
@ -258,11 +268,13 @@ SRS_DECLARE_PRIVATE:
// Had the video reaped, use to align audio/video segment's timestamp.
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.
srs_utime_t fragment_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string home_;
int video_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_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_init_mp4(SrsMediaPacket *msg, SrsFormat *format);
};
@ -309,15 +322,18 @@ public:
// The MPEG-DASH encoder, transmux RTMP to DASH.
class SrsDash : public ISrsDash
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool enabled_;
bool disposable_;
srs_utime_t last_update_time_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
ISrsOriginHub *hub_;
ISrsDashController *controller_;

View File

@ -60,10 +60,12 @@ public:
// The segmenter for DVR, to write a segment file in flv/mp4.
class SrsDvrSegmenter : public ISrsReloadHandler, public ISrsDvrSegmenter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
// The underlayer file object.
ISrsFileWriter *fs_;
// Whether wait keyframe to reap segment.
@ -71,11 +73,13 @@ SRS_DECLARE_PROTECTED:
// The FLV/MP4 fragment file.
SrsFragment *fragment_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
ISrsDvrPlan *plan_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsRtmpJitter *jitter_;
SrsRtmpJitterAlgorithm jitter_algorithm_;
@ -109,16 +113,19 @@ public:
// @remark ignore when already closed.
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 encode_metadata(SrsMediaPacket *metadata) = 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 close_encoder() = 0;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Generate the flv segment path.
virtual std::string generate_path();
virtual std::string
generate_path();
// When update the duration of segment by rtmp 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.
class SrsDvrFlvSegmenter : public SrsDvrSegmenter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppFactory *app_factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The FLV encoder, for FLV target.
ISrsFlvTransmuxer *enc_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The offset of file for duration value.
// The next 8 bytes is the double value.
int64_t duration_offset_;
@ -150,7 +160,8 @@ public:
public:
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 encode_metadata(SrsMediaPacket *metadata);
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.
class SrsDvrMp4Segmenter : public SrsDvrSegmenter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppFactory *app_factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The MP4 encoder, for MP4 target.
ISrsMp4Encoder *enc_;
@ -175,7 +188,8 @@ public:
public:
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 encode_metadata(SrsMediaPacket *metadata);
virtual srs_error_t encode_audio(SrsMediaPacket *audio, SrsFormat *format);
@ -186,11 +200,13 @@ SRS_DECLARE_PROTECTED:
// the dvr async call.
class SrsDvrAsyncCallOnDvr : public ISrsAsyncCallTask
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsHttpHooks *hooks_;
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsContextId cid_;
std::string path_;
ISrsRequest *req_;
@ -224,14 +240,16 @@ public:
// The DVR plan, when and how to reap segment.
class SrsDvrPlan : public ISrsReloadHandler, public ISrsDvrPlan
{
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
ISrsAsyncCallWorker *async_;
ISrsAppConfig *config_;
public:
ISrsRequest *req_;
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
ISrsOriginHub *hub_;
ISrsDvrSegmenter *segment_;
bool dvr_enabled_;
@ -271,7 +289,8 @@ public:
// The DVR segment plan: reap flv when duration exceed.
class SrsDvrSegmentPlan : public SrsDvrPlan
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// in config, in srs_utime_t
srs_utime_t cduration_;
bool wait_keyframe_;
@ -289,7 +308,8 @@ public:
virtual srs_error_t on_audio(SrsMediaPacket *shared_audio, 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);
};
@ -313,16 +333,19 @@ public:
// DVR(Digital Video Recorder) to record RTMP stream to flv/mp4 file.
class SrsDvr : public ISrsReloadHandler, public ISrsDvr
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsAppFactory *app_factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsOriginHub *hub_;
ISrsDvrPlan *plan_;
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.
// we always initialize the dvr, which crote plan and segment object,
// but they never create actual piece of file util the apply active it.

View File

@ -87,17 +87,20 @@ public:
// The RTMP upstream of edge.
class SrsEdgeRtmpUpstream : public ISrsEdgeUpstream
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsAppFactory *app_factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// For RTMP 302, if not empty,
// use this <ip[:port]> as upstream.
std::string redirect_;
ISrsBasicRtmpClient *sdk_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Current selected server, the ip:port.
std::string selected_ip_;
int selected_port_;
@ -122,20 +125,24 @@ public:
// The HTTP FLV upstream of edge.
class SrsEdgeFlvUpstream : public ISrsEdgeUpstream
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsAppFactory *app_factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string schema_;
ISrsHttpClient *sdk_;
ISrsHttpMessage *hr_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsFileReader *reader_;
ISrsFlvDecoder *decoder_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// We might modify the request by HTTP redirect.
ISrsRequest *req_;
// Current selected server, the ip:port.
@ -149,7 +156,8 @@ public:
public:
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);
public:
@ -182,14 +190,17 @@ public:
// The edge used to ingest stream from origin.
class SrsEdgeIngester : public ISrsCoroutineHandler, public ISrsEdgeIngester
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
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.
ISrsLiveSource *source_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsPlayEdge *edge_;
ISrsRequest *req_;
ISrsCoroutine *trd_;
@ -209,10 +220,12 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
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 process_publish_message(SrsRtmpCommonMessage *msg, std::string &redirect);
};
@ -240,14 +253,17 @@ public:
// The edge used to forward stream to origin.
class SrsEdgeForwarder : public ISrsCoroutineHandler, public ISrsEdgeForwarder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
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.
ISrsLiveSource *source_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsPublishEdge *edge_;
ISrsRequest *req_;
ISrsCoroutine *trd_;
@ -276,7 +292,8 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t do_cycle();
public:
@ -298,7 +315,8 @@ public:
// The play edge control service.
class SrsPlayEdge : public ISrsPlayEdge
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsEdgeState state_;
ISrsEdgeIngester *ingester_;
@ -334,7 +352,8 @@ public:
// The publish edge control service.
class SrsPublishEdge : public ISrsPublishEdge
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsEdgeState state_;
ISrsEdgeForwarder *forwarder_;

View File

@ -10,6 +10,7 @@
using namespace std;
#include <srs_app_config.hpp>
#include <srs_app_factory.hpp>
#include <srs_app_ffmpeg.hpp>
#include <srs_app_utility.hpp>
#include <srs_kernel_error.hpp>
@ -17,7 +18,6 @@ using namespace std;
#include <srs_kernel_pithy_print.hpp>
#include <srs_kernel_utility.hpp>
#include <srs_protocol_rtmp_stack.hpp>
#include <srs_app_factory.hpp>
// for encoder to detect the dead loop
static std::vector<std::string> _transcoded_url;

View File

@ -42,15 +42,18 @@ public:
// ffmpegs to transcode the specified stream.
class SrsEncoder : public ISrsCoroutineHandler, public ISrsMediaEncoder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsAppFactory *app_factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string input_stream_name_;
std::vector<ISrsFFMPEG *> ffmpegs_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsCoroutine *trd_;
ISrsPithyPrint *pprint_;
@ -65,10 +68,12 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t do_cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual void clear_engines();
virtual ISrsFFMPEG *at(int index);
virtual srs_error_t parse_scope_engines(ISrsRequest *req);

View File

@ -86,7 +86,8 @@ public:
// The factory to create app objects.
class SrsAppFactory : public ISrsAppFactory
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsKernelFactory *kernel_factory_;
public:

View File

@ -51,17 +51,21 @@ public:
// A transcode engine: ffmepg, used to transcode a stream to another.
class SrsFFMPEG : public ISrsFFMPEG
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsProcess *process_;
std::vector<std::string> params_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string log_file_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string ffmpeg_;
std::vector<std::string> iparams_;
std::vector<std::string> perfile_;

View File

@ -45,19 +45,23 @@ public:
// Forward the stream to other servers.
class SrsForwarder : public ISrsCoroutineHandler, public ISrsForwarder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The ep to forward, server[:port].
std::string ep_forward_;
ISrsRequest *req_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The source or stream context id to bind to.
SrsContextId source_cid_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsCoroutine *trd_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsOriginHub *hub_;
SrsSimpleRtmpClient *sdk_;
SrsRtmpJitter *jitter_;
@ -90,10 +94,12 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t do_cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t forward();
};

View File

@ -51,7 +51,8 @@ public:
// It's a media file, for example FLV or MP4, with duration.
class SrsFragment : public ISrsFragment
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The duration in srs_utime_t.
srs_utime_t dur_;
// The full file path of fragment.
@ -132,7 +133,8 @@ public:
// The fragment window manage a series of fragment.
class SrsFragmentWindow : public ISrsFragmentWindow
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::vector<ISrsFragment *> fragments_;
// The expired fragments, need to be free in future.
std::vector<ISrsFragment *> expired_fragments_;

View File

@ -91,12 +91,14 @@ std::string srs_gb_state(SrsGbSessionState ostate, SrsGbSessionState state);
// {"port":9000, "is_tcp": true}
class SrsGoApiGbPublish : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsResourceManager *gb_manager_;
ISrsAppFactory *app_factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsConfDirective *conf_;
public:
@ -106,7 +108,8 @@ public:
public:
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);
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.
class SrsGbSession : public ISrsGbSession
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
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.
SrsSharedResource<ISrsGbSession> *wrapper_;
// The owner coroutine, allow user to interrupt the loop.
ISrsInterruptable *owner_coroutine_;
ISrsContextIdSetter *owner_cid_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsGbSessionState state_;
SrsSharedResource<ISrsGbMediaTcpConn> media_;
ISrsGbMuxer *muxer_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// When wait for media connecting, timeout if exceed.
srs_utime_t connecting_starttime_;
// The time we enter reinviting state.
@ -166,7 +174,8 @@ SRS_DECLARE_PRIVATE:
// The number of timeout, dispose session if exceed.
uint32_t nn_timeout_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsAlonePithyPrint *ppp_;
srs_utime_t startime_;
uint64_t total_packs_;
@ -175,7 +184,8 @@ SRS_DECLARE_PRIVATE:
uint64_t total_msgs_dropped_;
uint64_t total_reserved_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint32_t media_id_;
srs_utime_t media_starttime_;
uint64_t media_msgs_;
@ -213,11 +223,13 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t do_cycle();
srs_error_t drive_state();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsGbSessionState set_state(SrsGbSessionState v);
// Interface ISrsResource
public:
@ -238,13 +250,15 @@ public:
// The Media listener for GB.
class SrsGbListener : public ISrsGbListener, public ISrsTcpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsApiServerOwner *api_server_owner_;
ISrsResourceManager *gb_manager_;
ISrsAppFactory *app_factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsConfDirective *conf_;
ISrsIpListener *media_listener_;
@ -260,7 +274,8 @@ public:
public:
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();
};
@ -301,16 +316,19 @@ public:
class SrsGbMediaTcpConn : public ISrsGbMediaTcpConn, // It's a resource, coroutine handler, and executor handler.
public ISrsPsPackHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsResourceManager *gb_manager_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool connected_;
// The owner session object, note that we use the raw pointer and should never free it.
ISrsGbSession *session_;
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.
SrsSharedResource<ISrsGbMediaTcpConn> *wrapper_;
// The owner coroutine, allow user to interrupt the loop.
@ -318,7 +336,8 @@ SRS_DECLARE_PRIVATE:
ISrsContextIdSetter *owner_cid_;
SrsContextId cid_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsPackContext *pack_;
ISrsProtocolReadWriter *conn_;
uint8_t *buffer_;
@ -351,15 +370,18 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t do_cycle();
// Interface ISrsPsPackHandler
public:
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.
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.
@ -379,9 +401,11 @@ public:
// we must recalc the timestamp.
class SrsMpegpsQueue : public ISrsMpegpsQueue
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The key: dts, value: msg.
std::map<int64_t, SrsMediaPacket *> msgs_;
std::map<int64_t, SrsMediaPacket *>
msgs_;
int nb_audios_;
int nb_videos_;
@ -409,16 +433,19 @@ public:
// Mux GB28181 to RTMP.
class SrsGbMuxer : public ISrsGbMuxer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
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.
ISrsGbSession *session_;
std::string output_;
ISrsBasicRtmpClient *sdk_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRawH264Stream *avc_;
std::string h264_sps_;
bool h264_sps_changed_;
@ -433,11 +460,13 @@ SRS_DECLARE_PRIVATE:
std::string h265_pps_;
bool vps_sps_pps_sent_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRawAacStream *aac_;
std::string aac_specific_config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsMpegpsQueue *queue_;
ISrsPithyPrint *pprint_;
@ -449,7 +478,8 @@ public:
void setup(std::string output);
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 mux_h264(SrsTsMessage *msg, SrsBuffer *avs);
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 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.
virtual srs_error_t connect();
virtual srs_error_t
connect();
// Close the connection to RTMP server.
virtual void close();
};
@ -484,7 +516,8 @@ class SrsRecoverablePsContext : public ISrsRecoverablePsContext
public:
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.
int recover_;
@ -497,9 +530,11 @@ public:
// 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);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// 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.
srs_error_t enter_recover_mode(SrsBuffer *stream, ISrsPsMessageHandler *handler, int pos, srs_error_t err);
// Quit Recover mode when got pack header.
@ -530,7 +565,8 @@ public:
// PS pack stream.
class SrsPackContext : public ISrsPackContext
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// To process a pack of TS/PS messages.
ISrsPsPackHandler *handler_;
// Note that it might be freed, so never use its fields.

View File

@ -45,12 +45,14 @@ public:
srs_error_t on_video(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_bootstrap();
void adjust_windows();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::list<SrsHdsFragment *> fragments_;
SrsHdsFragment *currentSegment_;
int fragment_index_;

View File

@ -19,7 +19,8 @@ public:
public:
virtual void heartbeat();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t do_heartbeat();
};

View File

@ -73,11 +73,13 @@ public:
class SrsInitMp4Segment : public SrsFragment
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsFileWriter *fw_;
SrsMp4M2tsInitEncoder init_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Key ID for encryption
unsigned char kid_[16];
// 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_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();
};
// TODO: merge this code with SrsFragmentedMp4 in dash
class SrsHlsM4sSegment : public SrsFragment
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsFileWriter *fw_;
SrsFmp4SegmentEncoder enc_;
@ -130,11 +134,13 @@ public:
// The hls async call: on_hls
class SrsDvrAsyncCallOnHls : public ISrsAsyncCallTask
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsHttpHooks *hooks_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsContextId cid_;
std::string path_;
std::string ts_url_;
@ -157,11 +163,13 @@ public:
// The hls async call: on_hls_notify
class SrsDvrAsyncCallOnHlsNotify : public ISrsAsyncCallTask
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsHttpHooks *hooks_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsContextId cid_;
std::string ts_url_;
ISrsRequest *req_;
@ -184,14 +192,17 @@ public:
// TODO: Rename to SrsHlsTsMuxer, for TS file only.
class SrsHlsMuxer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsAppFactory *app_factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string hls_entry_prefix_;
std::string hls_path_;
std::string hls_ts_file_;
@ -204,7 +215,8 @@ SRS_DECLARE_PRIVATE:
srs_utime_t hls_window_;
SrsAsyncCallWorker *async_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Whether use floor algorithm for timestamp.
bool hls_ts_floor_;
// 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 previous_floor_ts_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Whether encrypted or not
bool hls_keys_;
int hls_fragments_per_key_;
@ -231,13 +244,15 @@ SRS_DECLARE_PRIVATE:
// The underlayer file writer.
ISrsFileWriter *writer_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
int sequence_no_;
srs_utime_t max_td_;
std::string m3u8_;
std::string m3u8_url_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The available cached segments in m3u8.
SrsFragmentWindow *segments_;
// The current writing segment.
@ -245,7 +260,8 @@ SRS_DECLARE_PRIVATE:
// The ts context, to keep cc continous between ts.
SrsTsContext *context_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Latest audio codec, parsed from stream.
SrsAudioCodecId latest_acodec_;
// Latest audio codec, parsed from stream.
@ -306,7 +322,8 @@ public:
// Close segment(ts).
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 write_hls_key();
virtual srs_error_t refresh_m3u8();
@ -318,7 +335,8 @@ public:
// HLS recover mode.
srs_error_t recover_hls();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t do_recover_hls();
};
@ -327,14 +345,17 @@ SRS_DECLARE_PRIVATE:
// to flush video/audio, without any mechenisms.
class SrsHlsFmp4Muxer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsAppFactory *app_factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string hls_entry_prefix_;
std::string hls_path_;
std::string hls_m4s_file_;
@ -347,7 +368,8 @@ SRS_DECLARE_PRIVATE:
srs_utime_t hls_window_;
SrsAsyncCallWorker *async_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Whether use floor algorithm for timestamp.
bool hls_ts_floor_;
// The deviation in piece to adjust the fragment to be more
@ -359,7 +381,8 @@ SRS_DECLARE_PRIVATE:
int64_t previous_floor_ts_;
bool init_mp4_ready_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Whether encrypted or not
// TODO: fmp4 encryption is not yet implemented.
// fmp4 support four kinds of protection scheme: 'cenc', 'cbc1', 'cens', 'cbcs'.
@ -385,7 +408,8 @@ SRS_DECLARE_PRIVATE:
// The underlayer file writer.
ISrsFileWriter *writer_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
int sequence_no_;
srs_utime_t max_td_;
std::string m3u8_;
@ -395,13 +419,15 @@ SRS_DECLARE_PRIVATE:
int audio_track_id_;
uint64_t video_dts_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The available cached segments in m3u8.
SrsFragmentWindow *segments_;
// The current writing segment.
SrsHlsM4sSegment *current_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Latest audio codec, parsed from stream.
SrsAudioCodecId latest_acodec_;
// Latest audio codec, parsed from stream.
@ -461,7 +487,8 @@ public:
// Close segment(ts).
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 write_hls_key();
virtual srs_error_t refresh_m3u8();
@ -513,10 +540,12 @@ public:
// TODO: Rename to SrsHlsTsController, for TS file only.
class SrsHlsController : public ISrsHlsController
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The HLS muxer to reap ts and m3u8.
// The TS is cached to SrsTsMessageCache then flush to ts segment.
SrsHlsMuxer *muxer_;
@ -557,39 +586,47 @@ public:
// write video to muxer.
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,
// close current segment, open a new segment,
// then write the key frame to the new segment.
// 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.
// Direct sample processing without caching, simpler than TS controller.
class SrsHlsMp4Controller : public ISrsHlsController
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool has_video_sh_;
bool has_audio_sh_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
int video_track_id_;
int audio_track_id_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Current audio dts.
uint64_t audio_dts_;
// Current video dts.
uint64_t video_dts_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsHlsFmp4Muxer *muxer_;
public:
@ -637,13 +674,16 @@ public:
// TODO: FIXME: add utest for hls.
class SrsHls : public ISrsHls
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsHlsController *controller_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
// Whether the HLS is enabled.
bool enabled_;
@ -657,7 +697,8 @@ SRS_DECLARE_PRIVATE:
// To detect heartbeat and dispose it if configured.
srs_utime_t last_update_time_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsOriginHub *hub_;
SrsRtmpJitter *jitter_;
SrsPithyPrint *pprint_;
@ -669,7 +710,8 @@ public:
public:
virtual void async_reload();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t reload();
srs_error_t do_reload(int *reloading, int *reloaded, int *refreshed);
@ -697,7 +739,8 @@ public:
// TODO: FIXME: Remove param is_sps_pps.
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();
};

View File

@ -38,7 +38,8 @@ extern srs_error_t srs_api_response_code(ISrsHttpResponseWriter *w, ISrsHttpMess
// For http root.
class SrsGoApiRoot : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -51,7 +52,8 @@ public:
class SrsGoApiApi : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -64,7 +66,8 @@ public:
class SrsGoApiV1 : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -77,7 +80,8 @@ public:
class SrsGoApiVersion : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -90,7 +94,8 @@ public:
class SrsGoApiSummaries : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -103,7 +108,8 @@ public:
class SrsGoApiRusages : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -116,7 +122,8 @@ public:
class SrsGoApiSelfProcStats : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -129,7 +136,8 @@ public:
class SrsGoApiSystemProcStats : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -142,7 +150,8 @@ public:
class SrsGoApiMemInfos : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -155,7 +164,8 @@ public:
class SrsGoApiAuthors : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -168,7 +178,8 @@ public:
class SrsGoApiFeatures : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -181,7 +192,8 @@ public:
class SrsGoApiRequests : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -194,7 +206,8 @@ public:
class SrsGoApiVhosts : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -207,7 +220,8 @@ public:
class SrsGoApiStreams : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -220,7 +234,8 @@ public:
class SrsGoApiClients : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -233,14 +248,17 @@ public:
class SrsGoApiRaw : public ISrsHttpHandler, public ISrsReloadHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsSignalHandler *handler_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool raw_api_;
bool allow_reload_;
bool allow_query_;
@ -257,7 +275,8 @@ public:
class SrsGoApiClusters : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -270,7 +289,8 @@ public:
class SrsGoApiError : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -284,7 +304,8 @@ public:
#ifdef SRS_GPERF
class SrsGoApiTcmalloc : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -299,10 +320,12 @@ public:
#ifdef SRS_VALGRIND
class SrsGoApiValgrind : public ISrsHttpHandler, public ISrsCoroutineHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsCoroutine *trd_;
std::string task_;
@ -321,7 +344,8 @@ public:
#ifdef SRS_SIGNAL_API
class SrsGoApiSignal : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -335,11 +359,13 @@ public:
class SrsGoApiMetrics : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool enabled_;
std::string label_;
std::string tag_;

View File

@ -95,17 +95,20 @@ public:
// The http connection which request the static or stream content.
class SrsHttpConn : public ISrsHttpConn
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
ISrsHttpParser *parser_;
ISrsCommonHttpHandler *http_mux_;
ISrsHttpCorsMux *cors_;
ISrsHttpAuthMux *auth_;
ISrsHttpConnOwner *handler_;
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
ISrsProtocolReadWriter *skt_;
// Each connection start a green thread,
// when thread stop, the connection will be delete by server.
@ -114,7 +117,8 @@ SRS_DECLARE_PROTECTED:
std::string ip_;
int port_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The delta for statistic.
ISrsNetworkDelta *delta_;
// The create time in microseconds.
@ -137,7 +141,8 @@ public:
public:
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 process_requests(ISrsRequest **preq);
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.
class SrsHttpxConn : public ISrsHttpxConn
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsStatistic *stat_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The manager object to manage the connection.
ISrsResourceManager *manager_;
ISrsProtocolReadWriter *io_;
@ -242,7 +249,8 @@ public:
// The http server, use http stream or static server to serve requests.
class SrsHttpServer : public ISrsHttpServer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsHttpStaticServer *http_static_;
ISrsHttpStreamServer *http_stream_;

View File

@ -153,7 +153,8 @@ public:
class SrsHttpHooks : public ISrsHttpHooks
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppFactory *factory_;
ISrsStatistic *stat_;
ISrsAppConfig *config_;
@ -176,7 +177,8 @@ public:
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_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);
};

View File

@ -35,9 +35,11 @@ public:
// Server HLS streaming.
class SrsHlsStream : public ISrsFastTimerHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The period of validity of the ctx
std::map<std::string, SrsHlsVirtualConn *> map_ctx_info_;
std::map<std::string, SrsHlsVirtualConn *>
map_ctx_info_;
public:
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 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_exists_session(ISrsHttpResponseWriter *w, ISrsHttpMessage *r, ISrsFileReaderFactory *factory, std::string fullpath);
bool ctx_is_exist(std::string ctx);
@ -56,29 +59,34 @@ SRS_DECLARE_PRIVATE:
void http_hooks_on_stop(ISrsRequest *req);
bool is_interrupt(std::string id);
// interface ISrsFastTimerHandler
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t on_timer(srs_utime_t interval);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsSecurity *security_;
};
// The Vod streaming, like FLV, MP4 or HLS streaming.
class SrsVodStream : public SrsHttpFileServer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsHlsStream hls_;
public:
SrsVodStream(std::string root_dir);
virtual ~SrsVodStream();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
// The flv vod stream supports flv?start=offset-bytes.
// For example, http://server/file.flv?start=10240
// server will write flv header and sequence header,
// 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.
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.
@ -103,7 +111,8 @@ public:
// serve http static file and flv/mp4 vod stream.
class SrsHttpStaticServer : public ISrsHttpStaticServer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsHttpServeMux *mux_;
public:
@ -118,7 +127,8 @@ public:
public:
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);
};

View File

@ -51,14 +51,17 @@ public:
// A cache for HTTP Live Streaming encoder, to make android(weixin) happy.
class SrsBufferCache : public ISrsCoroutineHandler, public ISrsBufferCache
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsLiveSourceManager *live_sources_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_utime_t fast_cache_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsMessageQueue *queue_;
ISrsRequest *req_;
ISrsCoroutine *trd_;
@ -107,7 +110,8 @@ public:
// Transmux RTMP to HTTP Live Streaming.
class SrsFlvStreamEncoder : public ISrsBufferEncoder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsFlvTransmuxer *enc_;
bool header_written_;
bool has_audio_;
@ -138,14 +142,16 @@ public:
// Write the tags in a time.
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);
};
// Transmux RTMP to HTTP TS Streaming.
class SrsTsStreamEncoder : public ISrsBufferEncoder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsTsTransmuxer *enc_;
public:
@ -171,7 +177,8 @@ public:
// Transmux RTMP with AAC stream to HTTP AAC Streaming.
class SrsAacStreamEncoder : public ISrsBufferEncoder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAacTransmuxer *enc_;
ISrsBufferCache *cache_;
@ -193,7 +200,8 @@ public:
// Transmux RTMP with MP3 stream to HTTP MP3 Streaming.
class SrsMp3StreamEncoder : public ISrsBufferEncoder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsMp3Transmuxer *enc_;
ISrsBufferCache *cache_;
@ -215,7 +223,8 @@ public:
// Write stream to http response direclty.
class SrsBufferWriter : public SrsFileWriter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsHttpResponseWriter *writer_;
public:
@ -251,13 +260,15 @@ public:
// TODO: FIXME: Rename to SrsHttpLive
class SrsLiveStream : public ISrsLiveStream
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsLiveSourceManager *live_sources_;
ISrsStatistic *stat_;
ISrsHttpHooks *hooks_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
ISrsBufferCache *cache_;
ISrsSecurity *security_;
@ -274,7 +285,8 @@ public:
public:
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);
public:
@ -283,7 +295,8 @@ public:
public:
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 http_hooks_on_play(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.
struct SrsLiveEntry {
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool is_flv_;
bool is_ts_;
bool is_aac_;
@ -342,11 +356,13 @@ public:
// TODO: Support multiple stream.
class SrsHttpStreamServer : public ISrsHttpStreamServer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsHttpServeMux *mux_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAsyncCallWorker *async_;
public:
@ -373,14 +389,16 @@ public:
public:
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_entry(std::string vhost);
};
class SrsHttpStreamDestroy : public ISrsAsyncCallTask
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string sid_;
std::map<std::string, SrsLiveEntry *> *streamHandlers_;
ISrsHttpServeMux *mux_;

View File

@ -49,7 +49,8 @@ public:
// Ingester ffmpeg object.
class SrsIngesterFFMPEG : public ISrsIngesterFFMPEG
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string vhost_;
std::string id_;
ISrsFFMPEG *ffmpeg_;
@ -91,14 +92,17 @@ public:
// push to SRS(or any RTMP server) over RTMP.
class SrsIngester : public ISrsIngester, public ISrsCoroutineHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppFactory *app_factory_;
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::vector<ISrsIngesterFFMPEG *> ingesters_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsCoroutine *trd_;
ISrsPithyPrint *pprint_;
// Whether the ingesters are expired, for example, the listen port changed,
@ -118,19 +122,23 @@ public:
virtual srs_error_t start();
virtual void stop();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Notify FFMPEG to fast stop.
virtual void fast_stop();
virtual void
fast_stop();
// When SRS quit, directly kill FFMPEG after fast stop.
virtual void fast_kill();
// Interface ISrsReusableThreadHandler.
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t do_cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual void clear_engines();
virtual srs_error_t parse();
virtual srs_error_t parse_ingesters(SrsConfDirective *vhost);

View File

@ -19,12 +19,14 @@
class SrsLatestVersion : public ISrsCoroutineHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsCoroutine *trd_;
std::string server_id_;
std::string session_id_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string match_version_;
std::string stable_version_;
@ -38,7 +40,8 @@ public:
public:
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);
};

View File

@ -94,19 +94,23 @@ public:
// Bind udp port, start thread to recv packet and handler it.
class SrsUdpListener : public ISrsCoroutineHandler, public ISrsIpListener
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppFactory *factory_;
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
std::string label_;
srs_netfd_t lfd_;
ISrsCoroutine *trd_;
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
char *buf_;
int nb_buf_;
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
ISrsUdpHandler *handler_;
std::string ip_;
int port_;
@ -119,11 +123,13 @@ public:
ISrsListener *set_label(const std::string &label);
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 srs_netfd_t stfd();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
void set_socket_buffer();
public:
@ -133,22 +139,26 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t do_cycle();
};
// Bind and listen tcp port, use handler to process the client.
class SrsTcpListener : public ISrsCoroutineHandler, public ISrsIpListener
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppFactory *factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string label_;
srs_netfd_t lfd_;
ISrsCoroutine *trd_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsTcpHandler *handler_;
std::string ip_;
int port_;
@ -170,17 +180,20 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t do_cycle();
};
// Bind and listen tcp port, use handler to process the client.
class SrsMultipleTcpListeners : public ISrsIpListener, public ISrsTcpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppFactory *factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsTcpHandler *handler_;
std::vector<ISrsIpListener *> listeners_;
@ -223,13 +236,15 @@ public:
// TODO: FIXME: Rename it. Refine it for performance issue.
class SrsUdpMuxSocket : public ISrsUdpMuxSocket
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// For sender yield only.
uint32_t nn_msgs_for_yield_;
std::map<uint32_t, std::string> cache_;
SrsBuffer *cache_buffer_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
char *buf_;
int nb_buf_;
int nread_;
@ -237,11 +252,13 @@ SRS_DECLARE_PRIVATE:
sockaddr_storage from_;
int fromlen_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string peer_ip_;
int peer_port_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Cache for peer id.
std::string peer_id_;
// If the address changed, we should generate the peer_id.
@ -271,19 +288,23 @@ public:
class SrsUdpMuxListener : public ISrsCoroutineHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppFactory *factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_netfd_t lfd_;
ISrsCoroutine *trd_;
SrsContextId cid_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
char *buf_;
int nb_buf_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsUdpMuxHandler *handler_;
std::string ip_;
int port_;
@ -302,7 +323,8 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
void set_socket_buffer();
};

View File

@ -20,11 +20,13 @@
// when you want to use different level, override this classs, set the protected _level.
class SrsFileLog : public ISrsLog, public ISrsReloadHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Defined in SrsLogLevel.
SrsLogLevel level_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
char *log_data_;
// Log to file if specified srs_log_file
int fd_;
@ -42,7 +44,8 @@ public:
virtual void reopen();
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 open_log_file();
};

View File

@ -44,10 +44,12 @@ class ISrsAppFactory;
// A UDP listener, for udp stream caster server.
class SrsUdpCasterListener : public ISrsListener
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsIpListener *listener_;
ISrsMpegtsOverUdp *caster_;
@ -78,9 +80,11 @@ public:
// we must recalc the timestamp.
class SrsMpegtsQueue : public ISrsMpegtsQueue
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The key: dts, value: msg.
std::map<int64_t, SrsMediaPacket *> msgs_;
std::map<int64_t, SrsMediaPacket *>
msgs_;
int nb_audios_;
int nb_videos_;
@ -107,19 +111,23 @@ public:
// The mpegts over udp stream caster.
class SrsMpegtsOverUdp : public ISrsMpegtsOverUdp
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsAppFactory *app_factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsTsContext *context_;
SrsSimpleStream *buffer_;
std::string output_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsBasicRtmpClient *sdk_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRawH264Stream *avc_;
std::string h264_sps_;
bool h264_sps_changed_;
@ -127,11 +135,13 @@ SRS_DECLARE_PRIVATE:
bool h264_pps_changed_;
bool h264_sps_pps_sent_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRawAacStream *aac_;
std::string aac_specific_config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsMpegtsQueue *queue_;
ISrsPithyPrint *pprint_;
@ -145,25 +155,30 @@ public:
public:
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);
// Interface ISrsTsHandler
public:
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 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 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);
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);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Connect to RTMP server.
virtual srs_error_t connect();
virtual srs_error_t
connect();
// Close the connection to RTMP server.
virtual void close();
};

View File

@ -36,7 +36,8 @@ public:
// @see https://github.com/ossrs/srs/issues/367
class SrsNgExec : public ISrsCoroutineHandler, public ISrsNgExec
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsCoroutine *trd_;
SrsPithyPrint *pprint_;
std::string input_stream_name_;
@ -53,10 +54,12 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
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 void clear_exec_publish();
virtual void show_exec_log_message();

View File

@ -57,13 +57,15 @@ public:
// process->stop();
class SrsProcess : public ISrsProcess
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool is_started_;
// Whether SIGTERM send but need to wait or SIGKILL.
bool fast_stopped_;
pid_t pid_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string bin_;
std::string stdout_file_;
std::string stderr_file_;
@ -87,9 +89,11 @@ public:
// @remark the argv[0] must be the binary.
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.
virtual srs_error_t redirect_io();
virtual srs_error_t
redirect_io();
public:
// Start the process, ignore when already started.

View File

@ -80,7 +80,8 @@ public:
// The recv thread, use message handler to handle each received message.
class SrsRecvThread : public ISrsRecvThread
{
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
ISrsCoroutine *trd_;
ISrsMessagePumper *pumper_;
ISrsRtmpServer *rtmp_;
@ -105,7 +106,8 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t do_cycle();
};
@ -125,7 +127,8 @@ public:
// @see: https://github.com/ossrs/srs/issues/217
class SrsQueueRecvThread : public ISrsQueueRecvThread
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::vector<SrsRtmpCommonMessage *> queue_;
ISrsRecvThread *trd_;
ISrsRtmpServer *rtmp_;
@ -173,10 +176,12 @@ public:
// @see: https://github.com/ossrs/srs/issues/237
class SrsPublishRecvThread : public ISrsPublishRecvThread
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint32_t nn_msgs_for_yield_;
ISrsRecvThread *trd_;
ISrsRtmpServer *rtmp_;
@ -234,7 +239,8 @@ public:
virtual void on_read(ssize_t nread);
#endif
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
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
class SrsHttpRecvThread : public ISrsHttpRecvThread
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsHttpxConn *conn_;
ISrsCoroutine *trd_;

View File

@ -25,7 +25,8 @@ public:
// @param refer the refer in config.
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);
};

View File

@ -25,14 +25,16 @@ class ISrsHttpHooks;
class SrsGoApiRtcPlay : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsStatistic *stat_;
ISrsRtcSourceManager *rtc_sources_;
ISrsLiveSourceManager *live_sources_;
ISrsHttpHooks *hooks_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRtcApiServer *server_;
ISrsSecurity *security_;
@ -43,27 +45,32 @@ public:
public:
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);
public:
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_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t http_hooks_on_play(ISrsRequest *req);
};
class SrsGoApiRtcPublish : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsStatistic *stat_;
ISrsHttpHooks *hooks_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRtcApiServer *server_;
ISrsSecurity *security_;
@ -74,26 +81,31 @@ public:
public:
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);
public:
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_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t http_hooks_on_publish(ISrsRequest *req);
};
// See https://datatracker.ietf.org/doc/draft-ietf-wish-whip/
class SrsGoApiRtcWhip : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRtcApiServer *server_;
SrsGoApiRtcPublish *publish_;
SrsGoApiRtcPlay *play_;
@ -105,13 +117,15 @@ public:
public:
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);
};
class SrsGoApiRtcNACK : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRtcApiServer *server_;
public:
@ -121,7 +135,8 @@ public:
public:
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);
};

View File

@ -58,7 +58,8 @@ public:
// The audio transcoder, transcode audio from one codec to another.
class SrsAudioTranscoder : public ISrsAudioTranscoder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
AVCodecContext *dec_;
AVFrame *dec_frame_;
AVPacket *dec_packet_;
@ -95,7 +96,8 @@ public:
// @remark User should never free the data, it's managed by this transcoder.
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_enc(SrsAudioCodecId to, int channels, int samplerate, int bit_rate);
srs_error_t init_swr(AVCodecContext *decoder);

View File

@ -103,7 +103,8 @@ public:
// The security transport, use DTLS/SRTP to protect the data.
class SrsSecurityTransport : public ISrsRtcTransport
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRtcNetwork *network_;
ISrsDtls *dtls_;
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 write_dtls_data(void *data, int size);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t srtp_initialize();
};
@ -155,7 +157,8 @@ public:
// Plaintext transport, without DTLS or SRTP.
class SrsPlaintextTransport : public ISrsRtcTransport
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRtcNetwork *network_;
public:
@ -192,14 +195,17 @@ public:
// A worker coroutine to request the PLI.
class SrsRtcPliWorker : public ISrsCoroutineHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsCoroutine *trd_;
ISrsCond *wait_;
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.
std::map<uint32_t, SrsContextId> plis_;
std::map<uint32_t, SrsContextId>
plis_;
public:
SrsRtcPliWorker(ISrsRtcPliWorkerHandler *h);
@ -216,7 +222,8 @@ public:
// the rtc on_stop async call.
class SrsRtcAsyncCallOnStop : public ISrsAsyncCallTask
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsContextId cid_;
ISrsRequest *req_;
ISrsHttpHooks *hooks_;
@ -235,22 +242,26 @@ public:
// A RTC play stream, client pull and play stream from SRS.
class SrsRtcPlayStream : public ISrsCoroutineHandler, public ISrsReloadHandler, public ISrsRtcPliWorkerHandler, public ISrsRtcSourceChangeCallback
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsExecRtcAsyncTask *exec_;
ISrsExpire *expire_;
ISrsRtcPacketSender *sender_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsRtcSourceManager *rtc_sources_;
ISrsStatistic *stat_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsContextId cid_;
SrsFastCoroutine *trd_;
SrsRtcPliWorker *pli_worker_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
SrsSharedPtr<SrsRtcSource> source_;
// key: publish_ssrc, value: send track to process rtp/rtcp
@ -259,7 +270,8 @@ SRS_DECLARE_PRIVATE:
// The pithy print for special stage.
SrsErrorPithyPrint *nack_epp_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Fast cache for tracks.
uint32_t cache_ssrc0_;
uint32_t cache_ssrc1_;
@ -268,7 +280,8 @@ SRS_DECLARE_PRIVATE:
SrsRtcSendTrack *cache_track1_;
SrsRtcSendTrack *cache_track2_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// For merged-write messages.
int mw_msgs_;
bool realtime_;
@ -276,7 +289,8 @@ SRS_DECLARE_PRIVATE:
bool nack_enabled_;
bool nack_no_copy_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Whether player started.
bool is_started_;
@ -300,7 +314,8 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t send_packet(SrsRtpPacket *&pkt);
public:
@ -310,7 +325,8 @@ public:
public:
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_nack(SrsRtcpNack *rtcp);
srs_error_t on_rtcp_ps_feedback(SrsRtcpFbCommon *rtcp);
@ -341,7 +357,8 @@ public:
// A fast timer for publish stream, for RTCP feedback.
class SrsRtcPublishRtcpTimer : public ISrsFastTimerHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRtcRtcpSender *sender_;
srs_mutex_t lock_;
@ -349,17 +366,20 @@ public:
SrsRtcPublishRtcpTimer(ISrsRtcRtcpSender *sender);
virtual ~SrsRtcPublishRtcpTimer();
// interface ISrsFastTimerHandler
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t on_timer(srs_utime_t interval);
};
// A fast timer for publish stream, for TWCC feedback.
class SrsRtcPublishTwccTimer : public ISrsFastTimerHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsCircuitBreaker *circuit_breaker_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRtcRtcpSender *sender_;
srs_mutex_t lock_;
@ -367,18 +387,21 @@ public:
SrsRtcPublishTwccTimer(ISrsRtcRtcpSender *sender);
virtual ~SrsRtcPublishTwccTimer();
// interface ISrsFastTimerHandler
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t on_timer(srs_utime_t interval);
};
// the rtc on_unpublish async call.
class SrsRtcAsyncCallOnUnpublish : public ISrsAsyncCallTask
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsHttpHooks *hooks_;
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsContextId cid_;
ISrsRequest *req_;
@ -394,54 +417,64 @@ public:
// A RTC publish stream, client push and publish stream to SRS.
class SrsRtcPublishStream : public ISrsRtpPacketDecodeHandler, public ISrsRtcPublishStream, public ISrsRtcPliWorkerHandler, public ISrsRtcRtcpSender
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsExecRtcAsyncTask *exec_;
ISrsExpire *expire_;
ISrsRtcPacketReceiver *receiver_;
ISrsCircuitBreaker *circuit_breaker_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
ISrsAppConfig *config_;
ISrsRtcSourceManager *rtc_sources_;
ISrsLiveSourceManager *live_sources_;
ISrsSrtSourceManager *srt_sources_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
friend class SrsRtcPublishRtcpTimer;
friend class SrsRtcPublishTwccTimer;
SrsRtcPublishRtcpTimer *timer_rtcp_;
SrsRtcPublishTwccTimer *timer_twcc_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsContextId cid_;
uint64_t nn_audio_frames_;
SrsRtcPliWorker *pli_worker_;
SrsErrorPithyPrint *twcc_epp_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint16_t pt_to_drop_;
// Whether enabled nack.
bool nack_enabled_;
bool nack_no_copy_;
bool twcc_enabled_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool request_keyframe_;
SrsErrorPithyPrint *pli_epp_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
SrsSharedPtr<SrsRtcSource> source_;
// Simulators.
int nn_simulate_nack_drop_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// track vector
std::vector<SrsRtcAudioRecvTrack *> audio_tracks_;
std::vector<SrsRtcAudioRecvTrack *>
audio_tracks_;
std::vector<SrsRtcVideoRecvTrack *> video_tracks_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
int twcc_id_;
uint8_t twcc_fb_count_;
SrsRtcpTWCC rtcp_twcc_;
@ -460,7 +493,8 @@ public:
void set_all_tracks_status(bool status);
virtual const SrsContextId &context_id();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool is_sender_started();
bool is_sender_twcc_enabled();
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_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);
public:
@ -479,13 +514,15 @@ public:
public:
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();
public:
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_xr(SrsRtcpXr *rtcp);
@ -496,10 +533,12 @@ public:
public:
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);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t on_twcc(uint16_t sn);
SrsRtcAudioRecvTrack *get_audio_track(uint32_t ssrc);
SrsRtcVideoRecvTrack *get_video_track(uint32_t ssrc);
@ -521,11 +560,13 @@ public:
// A fast timer for conntion, for NACK feedback.
class SrsRtcConnectionNackTimer : public ISrsFastTimerHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsSharedTimer *shared_timer_;
ISrsCircuitBreaker *circuit_breaker_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRtcConnectionNackTimerHandler *handler_;
srs_mutex_t lock_;
@ -537,7 +578,8 @@ public:
virtual srs_error_t initialize();
// interface ISrsFastTimerHandler
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t on_timer(srs_utime_t interval);
};
@ -609,13 +651,15 @@ class SrsRtcConnection : public ISrsRtcConnection
{
friend class SrsSecurityTransport;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsCircuitBreaker *circuit_breaker_;
ISrsResourceManager *conn_manager_;
ISrsRtcSourceManager *rtc_sources_;
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsRtcConnectionNackTimer *timer_nack_;
ISrsExecRtcAsyncTask *exec_;
SrsRtcPublisherNegotiator *publisher_negotiator_;
@ -624,13 +668,16 @@ SRS_DECLARE_PRIVATE:
public:
bool disposing_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
iovec *cache_iov_;
SrsBuffer *cache_buffer_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// key: stream id
std::map<std::string, SrsRtcPlayStream *> players_;
std::map<std::string, SrsRtcPlayStream *>
players_;
// key: player track's ssrc
std::map<uint32_t, SrsRtcPlayStream *> players_ssrc_map_;
// key: stream id
@ -638,7 +685,8 @@ SRS_DECLARE_PRIVATE:
// key: publisher track's ssrc
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.
std::string username_;
// 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.
SrsRtcNetworks *networks_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// TODO: FIXME: Rename it.
// The timeout of session, keep alive by STUN ping pong.
srs_utime_t session_timeout_;
// TODO: FIXME: Rename it.
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.
SrsContextId cid_;
ISrsRequest *req_;
@ -661,7 +711,8 @@ SRS_DECLARE_PRIVATE:
SrsSdp local_sdp_;
SrsSharedPtr<SrsStreamPublishToken> publish_token_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// twcc handler
int twcc_id_;
// Simulators.
@ -669,7 +720,8 @@ SRS_DECLARE_PRIVATE:
// Pithy print for PLI request.
SrsErrorPithyPrint *pli_epp_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool nack_enabled_;
public:
@ -721,14 +773,17 @@ public:
srs_error_t on_rtp_cipher(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.
srs_error_t find_publisher(char *buf, int size, SrsRtcPublishStream **ppublisher);
srs_error_t
find_publisher(char *buf, int size, SrsRtcPublishStream **ppublisher);
public:
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);
public:
@ -770,7 +825,8 @@ public:
// Notify by specified network.
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_publisher(ISrsRequest *request, SrsRtcSourceDescription *stream_desc);
};
@ -778,7 +834,8 @@ SRS_DECLARE_PRIVATE:
// Negotiate via SDP exchange for WebRTC publisher.
class SrsRtcPublisherNegotiator
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
ISrsAppConfig *config_;
@ -798,7 +855,8 @@ public:
// Negotiate via SDP exchange for WebRTC player.
class SrsRtcPlayerNegotiator
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
ISrsAppConfig *config_;
ISrsRtcSourceManager *rtc_sources_;

View File

@ -34,7 +34,8 @@ public:
// The DTLS certificate.
class SrsDtlsCertificate : public ISrsDtlsCertificate
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string fingerprint_;
bool ecdsa_mode_;
X509 *dtls_cert_;
@ -104,7 +105,8 @@ enum SrsDtlsState {
class SrsDtlsImpl
{
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
SSL_CTX *dtls_ctx_;
SSL *dtls_;
BIO *bio_in_;
@ -113,7 +115,8 @@ SRS_DECLARE_PROTECTED:
// @remark: dtls_version_ default value is SrsDtlsVersionAuto.
SrsDtlsVersion version_;
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
// 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.
bool handshake_done_for_us_;
@ -135,7 +138,8 @@ public:
virtual srs_error_t start_active_handshake();
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);
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);
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 bool is_dtls_client() = 0;
virtual srs_error_t start_arq() = 0;
@ -151,7 +156,8 @@ SRS_DECLARE_PROTECTED:
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).
// @note If passive(DTLS server), the ARQ is driven by DTLS client.
ISrsCoroutine *trd_;
@ -167,11 +173,13 @@ public:
public:
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 bool is_dtls_client();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
srs_error_t start_arq();
void stop_arq();
@ -188,7 +196,8 @@ public:
public:
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 bool is_dtls_client();
srs_error_t start_arq();
@ -208,7 +217,8 @@ public:
srs_error_t get_srtp_key(std::string &recv_key, std::string &send_key);
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 bool is_dtls_client();
virtual srs_error_t start_arq();
@ -231,7 +241,8 @@ public:
// The DTLS transport.
class SrsDtls : public ISrsDtls
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsDtlsImpl *impl_;
ISrsDtlsCallback *callback_;
@ -271,7 +282,8 @@ public:
// The SRTP transport.
class SrsSRTP : public ISrsSRTP
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srtp_t recv_ctx_;
srtp_t send_ctx_;

View File

@ -62,7 +62,8 @@ public:
// A group of networks, each has its own DTLS and SRTP context.
class SrsRtcNetworks : public ISrsRtcNetworks
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Network over UDP.
ISrsRtcNetwork *udp_;
// Network over TCP
@ -70,7 +71,8 @@ SRS_DECLARE_PRIVATE:
// Network over dummy
ISrsRtcNetwork *dummy_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// WebRTC session object.
ISrsRtcConnection *conn_;
// Delta object for statistics.
@ -170,17 +172,20 @@ public:
// The WebRTC over UDP network.
class SrsRtcUdpNetwork : public ISrsRtcNetwork
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsResourceManager *conn_manager_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// WebRTC session object.
ISrsRtcConnection *conn_;
// Delta object for statistics.
ISrsEphemeralDelta *delta_;
SrsRtcNetworkState state_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Pithy print for address change, use port as error code.
SrsErrorPithyPrint *pp_address_change_;
// 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.
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);
// DTLS transport functions.
public:
@ -229,17 +235,20 @@ public:
class SrsRtcTcpNetwork : public ISrsRtcNetwork
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRtcConnection *conn_;
ISrsEphemeralDelta *delta_;
ISrsProtocolReadWriter *sendonly_skt_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The DTLS transport over this network.
ISrsRtcTransport *transport_;
SrsSharedResource<ISrsRtcTcpConn> owner_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string peer_ip_;
int peer_port_;
SrsRtcNetworkState state_;
@ -266,7 +275,8 @@ public:
// 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_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t on_binding_request(SrsStunPacket *r, std::string ice_pwd);
// DTLS transport functions.
public:
@ -308,15 +318,18 @@ public:
// For WebRTC over TCP.
class SrsRtcTcpConn : public ISrsRtcTcpConn
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsResourceManager *conn_manager_;
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.
ISrsRtcConnection *session_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The ip and port of client.
std::string ip_;
int port_;
@ -326,7 +339,8 @@ SRS_DECLARE_PRIVATE:
// Packet cache.
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.
SrsSharedResource<ISrsRtcTcpConn> *wrapper_;
// The owner coroutine, allow user to interrupt the loop.
@ -334,7 +348,8 @@ SRS_DECLARE_PRIVATE:
ISrsContextIdSetter *owner_cid_;
SrsContextId cid_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
void setup();
public:
@ -364,7 +379,8 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t do_cycle();
srs_error_t handshake();
srs_error_t read_packet(char *pkt, int *nb_pkt);

View File

@ -45,7 +45,8 @@ class SrsRtcBlackhole
public:
bool blackhole_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
sockaddr_in *blackhole_addr_;
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.
class SrsRtcSessionManager : public ISrsExecRtcAsyncTask
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsResourceManager *conn_manager_;
ISrsStreamPublishTokenManager *stream_publish_tokens_;
ISrsRtcSourceManager *rtc_sources_;
@ -108,7 +110,8 @@ SRS_DECLARE_PRIVATE:
ISrsAppConfig *config_;
ISrsAppFactory *app_factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// WebRTC async call worker for non-blocking operations.
SrsAsyncCallWorker *rtc_async_;
@ -123,7 +126,8 @@ public:
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);
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);
public:

View File

@ -119,11 +119,13 @@ public:
// The RTC stream consumer, consume packets from RTC stream source.
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.
ISrsRtcSourceForConsumer *source_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::vector<SrsRtpPacket *> queue_;
// when source id changed, notice all consumers
bool should_update_source_id_;
@ -132,7 +134,8 @@ SRS_DECLARE_PRIVATE:
bool mw_waiting_;
int mw_min_msgs_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The callback for stream change event.
ISrsRtcSourceChangeCallback *handler_;
@ -172,7 +175,8 @@ public:
// The RTC source manager.
class SrsRtcSourceManager : public ISrsRtcSourceManager, public ISrsHourGlassHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_mutex_t lock_;
std::map<std::string, SrsSharedPtr<SrsRtcSource> > pool_;
SrsHourGlass *timer_;
@ -184,7 +188,8 @@ public:
public:
virtual srs_error_t initialize();
// interface ISrsHourGlassHandler
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t setup_ticks();
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.
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.
ISrsRtcBridge *rtc_bridge_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Circuit breaker for protecting server resources.
ISrsCircuitBreaker *circuit_breaker_;
// For publish, it's the publish client id.
@ -252,9 +259,11 @@ SRS_DECLARE_PRIVATE:
// Steam description for this steam.
SrsRtcSourceDescription *stream_desc_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// To delivery stream to clients.
std::vector<ISrsRtcConsumer *> consumers_;
std::vector<ISrsRtcConsumer *>
consumers_;
// Whether stream is created, that is, SDP is done.
bool is_created_;
// Whether stream is delivering data, that is, DTLS is done.
@ -262,12 +271,14 @@ SRS_DECLARE_PRIVATE:
// Notify stream event to event handler
std::vector<ISrsRtcSourceEventHandler *> event_handlers_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The PLI for RTC2RTMP.
srs_utime_t pli_for_rtmp_;
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.
srs_utime_t stream_die_at_;
@ -282,16 +293,19 @@ public:
// Whether stream is dead, which is no publisher or player.
virtual bool stream_is_dead();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
void init_for_play_before_publishing();
public:
// Update the authentication information in request.
virtual void update_auth(ISrsRequest *r);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The stream source changed.
virtual srs_error_t on_source_changed();
virtual srs_error_t
on_source_changed();
public:
// Get current source id.
@ -337,7 +351,8 @@ public:
virtual void set_stream_desc(SrsRtcSourceDescription *stream_desc);
virtual std::vector<SrsRtcTrackDescription *> get_track_desc(std::string type, std::string media_type);
// interface ISrsFastTimerHandler
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t on_timer(srs_utime_t interval);
};
@ -346,7 +361,8 @@ SRS_DECLARE_PRIVATE:
// Convert AV frame to RTC RTP packets.
class SrsRtcRtpBuilder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
ISrsRtpTarget *rtp_target_;
// The format, codec information.
@ -356,7 +372,8 @@ SRS_DECLARE_PRIVATE:
// The video builder, convert frame to RTP packets.
SrsRtpVideoBuilder *video_builder_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsAudioCodecId latest_codec_;
ISrsAudioTranscoder *codec_;
bool keep_bframe_;
@ -364,11 +381,13 @@ SRS_DECLARE_PRIVATE:
bool merge_nalus_;
uint16_t audio_sequence_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint32_t audio_ssrc_;
uint8_t audio_payload_type_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsSharedPtr<SrsRtcSource> source_;
// Lazy initialization flags
bool audio_initialized_;
@ -378,9 +397,11 @@ public:
SrsRtcRtpBuilder(ISrsRtpTarget *target, SrsSharedPtr<SrsRtcSource> source);
virtual ~SrsRtcRtpBuilder();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// 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);
public:
@ -389,18 +410,22 @@ public:
virtual void on_unpublish();
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);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t init_codec(SrsAudioCodecId codec);
srs_error_t transcode(SrsParsedAudioPacket *audio);
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);
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 package_stap_a(SrsMediaPacket *msg, SrsRtpPacket *pkt);
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?
class SrsRtcFrameBuilderVideoPacketCache
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
const static uint16_t cache_size_ = 512;
struct RtcPacketCache {
bool in_use_;
@ -441,7 +467,8 @@ public:
// 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);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool is_slot_in_use(uint16_t sequence_number);
uint32_t get_rtp_timestamp(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
class SrsRtcFrameBuilderVideoFrameDetector
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsRtcFrameBuilderVideoPacketCache *video_cache_;
uint16_t header_sn_;
uint16_t lost_sn_;
@ -474,9 +502,11 @@ public:
// Audio packet cache for RTP packet jitter buffer management
class SrsRtcFrameBuilderAudioPacketCache
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// 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
uint16_t last_audio_seq_num_;
// Last time we processed the jitter buffer
@ -503,24 +533,29 @@ public:
// Collect and build WebRTC RTP packets to AV frames.
class SrsRtcFrameBuilder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsFrameTarget *frame_target_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool is_first_audio_;
ISrsAudioTranscoder *audio_transcoder_;
SrsVideoCodecId video_codec_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsRtcFrameBuilderAudioPacketCache *audio_cache_;
SrsRtcFrameBuilderVideoPacketCache *video_cache_;
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.
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.
SrsRtpPacket *obs_whip_vps_;
SrsRtpPacket *obs_whip_sps_;
@ -536,12 +571,14 @@ public:
virtual void on_unpublish();
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 transcode_audio(SrsRtpPacket *pkt);
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_key_frame(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 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);
int calculate_packet_payload_size(SrsRtpPacket *pkt);
void write_packet_payload_to_buffer(SrsRtpPacket *pkt, SrsBuffer &payload, int &nalu_len);
@ -571,7 +609,8 @@ public:
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_.
// For video, you can convert it to type SrsVideoCodecId
// For audio, you can convert it to type SrsAudioCodecId
@ -777,19 +816,23 @@ public:
// The RTC receive track.
class SrsRtcRecvTrack
{
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
SrsRtcTrackDescription *track_desc_;
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
ISrsRtcPacketReceiver *receiver_;
SrsRtpRingBuffer *rtp_queue_;
SrsRtpNackForReceiver *nack_receiver_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// By config, whether 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.
SrsNtp last_sender_report_ntp_;
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 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);
};
@ -864,12 +908,14 @@ public:
template <typename T, typename ST>
class SrsRtcJitter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ST threshold_;
typedef ST (*PFN)(const T &, const T &);
PFN distance_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The value about packet.
T pkt_base_;
T pkt_last_;
@ -926,7 +972,8 @@ public:
// For RTC timestamp jitter.
class SrsRtcTsJitter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsRtcJitter<uint32_t, int32_t> *jitter_;
public:
@ -940,7 +987,8 @@ public:
// For RTC sequence jitter.
class SrsRtcSeqJitter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsRtcJitter<uint16_t, int16_t> *jitter_;
public:
@ -968,18 +1016,21 @@ public:
// send track description
SrsRtcTrackDescription *track_desc_;
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
// The owner connection for this track.
ISrsRtcPacketSender *sender_;
// NACK ARQ ring buffer.
SrsRtpRingBuffer *rtp_queue_;
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
// The jitter to correct ts and sequence number.
SrsRtcTsJitter *jitter_ts_;
SrsRtcSeqJitter *jitter_seq_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// By config, whether no copy.
bool nack_no_copy_;
// The pithy print for special stage.
@ -998,7 +1049,8 @@ public:
bool get_track_status();
std::string get_track_id();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
void rebuild_packet(SrsRtpPacket *pkt);
public:
@ -1036,13 +1088,16 @@ public:
class SrsRtcSSRCGenerator
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
static SrsRtcSSRCGenerator *instance_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint32_t ssrc_num_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsRtcSSRCGenerator();
virtual ~SrsRtcSSRCGenerator();

View File

@ -56,14 +56,16 @@ class ISrsSecurity;
// The simple rtmp client for SRS.
class SrsSimpleRtmpClient : public SrsBasicRtmpClient
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
public:
SrsSimpleRtmpClient(std::string u, srs_utime_t ctm, srs_utime_t stm);
virtual ~SrsSimpleRtmpClient();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual srs_error_t connect_app();
};
@ -106,7 +108,8 @@ public:
// The base transport layer for RTMP connections over plain TCP.
class SrsRtmpTransport : public ISrsRtmpTransport
{
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
srs_netfd_t stfd_;
SrsTcpConnection *skt_;
@ -135,10 +138,12 @@ public:
// The SSL/TLS transport layer for RTMPS connections.
class SrsRtmpsTransport : public SrsRtmpTransport
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsSslConnection *ssl_;
public:
@ -164,7 +169,8 @@ class SrsRtmpConn : public ISrsConnection, // It's a resource.
// For the thread to directly access any field of connection.
friend class SrsPublishRecvThread;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsResourceManager *manager_;
ISrsAppConfig *config_;
ISrsStreamPublishTokenManager *stream_publish_tokens_;
@ -177,7 +183,8 @@ SRS_DECLARE_PRIVATE:
ISrsRtspSourceManager *rtsp_sources_;
#endif
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRtmpServer *rtmp_;
SrsRefer *refer_;
SrsBandwidth *bandwidth_;
@ -205,7 +212,8 @@ SRS_DECLARE_PRIVATE:
// About the rtmp client.
SrsClientInfo *info_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRtmpTransport *transport_;
// Each connection start a green thread,
// when thread stop, the connection will be delete by server.
@ -228,15 +236,18 @@ public:
public:
virtual std::string desc();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual srs_error_t do_cycle();
public:
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.
virtual srs_error_t service_cycle();
virtual srs_error_t
service_cycle();
// The stream(play/publish) service cycle, identify client first.
virtual srs_error_t stream_service_cycle();
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 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 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.
// 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 void http_hooks_on_close();
virtual srs_error_t http_hooks_on_publish();

View File

@ -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.
class SrsRtmpJitter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
int64_t last_pkt_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.
class SrsFastVector
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsMediaPacket **msgs_;
int nb_msgs_;
int count_;
@ -140,12 +142,14 @@ public:
// We limit the size in seconds, drop old messages(the whole gop) if full.
class SrsMessageQueue : public ISrsMessageQueue
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The start and end time.
srs_utime_t av_start_time_;
srs_utime_t av_end_time_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Whether do logging when shrinking.
bool _ignore_shrink;
// The max queue size, shrink if exceed it.
@ -182,10 +186,12 @@ public:
// @remark the atc/tba/tbv/ag are same to SrsLiveConsumer.enqueue().
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.
// if no iframe found, clear it.
virtual void shrink();
virtual void
shrink();
public:
// clear all messages in queue.
@ -224,11 +230,13 @@ public:
// The consumer for SrsLiveSource, that is a play client.
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.
ISrsLiveSource *source_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsRtmpJitter *jitter_;
SrsMessageQueue *queue_;
bool paused_;
@ -285,7 +293,8 @@ public:
// To enable it to fast startup.
class SrsGopCache
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// if disabled the gop cache,
// The client will wait for the next keyframe for h264,
// and will be black-screen.
@ -360,7 +369,8 @@ public:
// The mix queue to correct the timestamp for mix_correct algorithm.
class SrsMixQueue
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint32_t nb_videos_;
uint32_t nb_audios_;
std::multimap<int64_t, SrsMediaPacket *> msgs_;
@ -411,20 +421,24 @@ public:
// they are meanless for edge server.
class SrsOriginHub : public ISrsReloadHandler, public ISrsOriginHub
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsStatistic *stat_;
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.
ISrsLiveSource *source_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
bool is_active_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// hls handler.
ISrsHls *hls_;
// The DASH encoder.
@ -484,7 +498,8 @@ public:
// For the SrsHls to callback to request the sequence headers.
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_backend_forwarders(bool &applied);
virtual void destroy_forwarders();
@ -494,7 +509,8 @@ SRS_DECLARE_PRIVATE:
// This class cache and update the meta.
class SrsMetaCache
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The cached metadata, FLV script data tag.
SrsMediaPacket *meta_;
// 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.
class SrsLiveSourceManager : public ISrsHourGlassHandler, public ISrsLiveSourceManager
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppFactory *app_factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_mutex_t lock_;
std::map<std::string, SrsSharedPtr<SrsLiveSource> > pool_;
ISrsHourGlass *timer_;
@ -600,7 +618,8 @@ public:
// dispose and cycle all sources.
virtual void dispose();
// interface ISrsHourGlassHandler
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t setup_ticks();
virtual srs_error_t notify(int event, srs_utime_t interval, srs_utime_t tick);
@ -641,13 +660,15 @@ public:
// The live streaming source.
class SrsLiveSource : public ISrsReloadHandler, public ISrsFrameTarget, public ISrsLiveSource
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsStatistic *stat_;
ISrsLiveSourceHandler *handler_;
ISrsAppFactory *app_factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// For publish, it's the publish client id.
// For edge, it's the edge ingest id.
// when source id changed, for example, the edge reconnect,
@ -688,7 +709,8 @@ SRS_DECLARE_PRIVATE:
// The format, codec information.
SrsRtmpFormat *format_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Whether source is avaiable for publishing.
bool can_publish_;
// The last die time, while die means neither publishers nor players.
@ -738,14 +760,16 @@ public:
virtual srs_error_t on_audio(SrsRtmpCommonMessage *audio);
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);
public:
// TODO: FIXME: Use SrsMediaPacket instead.
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);
public:

View File

@ -60,24 +60,28 @@ public:
// A RTSP play stream, client pull and play stream from SRS.
class SrsRtspPlayStream : public ISrsRtspPlayStream, public ISrsCoroutineHandler, public ISrsRtcSourceChangeCallback
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppFactory *app_factory_;
ISrsStatistic *stat_;
ISrsRtspSourceManager *rtsp_sources_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsContextId cid_;
ISrsCoroutine *trd_;
ISrsRtspConnection *session_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
SrsSharedPtr<SrsRtspSource> source_;
// key: publish_ssrc, value: send track to process rtp/rtcp
std::map<uint32_t, ISrsRtspSendTrack *> audio_tracks_;
std::map<uint32_t, ISrsRtspSendTrack *> video_tracks_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Fast cache for tracks.
uint32_t cache_ssrc0_;
uint32_t cache_ssrc1_;
@ -86,7 +90,8 @@ SRS_DECLARE_PRIVATE:
ISrsRtspSendTrack *cache_track1_;
ISrsRtspSendTrack *cache_track2_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Whether player started.
bool is_started;
@ -110,7 +115,8 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t send_packet(SrsRtpPacket *&pkt);
public:
@ -136,17 +142,20 @@ class SrsRtspConnection : public ISrsResource, // It's a resource.
public ISrsStartable,
public ISrsRtspConnection
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRtspSourceManager *rtsp_sources_;
ISrsResourceManager *rtsp_manager_;
ISrsStatistic *stat_;
ISrsAppConfig *config_;
ISrsHttpHooks *hooks_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool disposing_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// TODO: FIXME: Rename it.
// The timeout of session, keep alive by STUN ping pong.
srs_utime_t session_timeout;
@ -191,7 +200,8 @@ public:
public:
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_setup(SrsRtspRequest *req, uint32_t *ssrc);
virtual srs_error_t do_play(SrsRtspRequest *req, SrsRtspConnection *conn);
@ -217,7 +227,8 @@ public:
public:
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 on_rtsp_request(SrsRtspRequest *req_raw);
@ -233,14 +244,16 @@ public:
bool is_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 get_ssrc_by_stream_id(uint32_t stream_id, uint32_t *ssrc);
};
class SrsRtspTcpNetwork : public ISrsStreamWriter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsProtocolReadWriter *skt_;
int channel_;

View File

@ -34,11 +34,13 @@ class ISrsRtspConnection;
// The RTSP stream consumer, consume packets from RTSP stream source.
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.
SrsRtspSource *source_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::vector<SrsRtpPacket *> queue_;
// when source id changed, notice all consumers
bool should_update_source_id_;
@ -47,7 +49,8 @@ SRS_DECLARE_PRIVATE:
bool mw_waiting_;
int mw_min_msgs_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The callback for stream change event.
ISrsRtcSourceChangeCallback *handler_;
@ -87,7 +90,8 @@ public:
// The RTSP source manager.
class SrsRtspSourceManager : public ISrsHourGlassHandler, public ISrsRtspSourceManager
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_mutex_t lock_;
std::map<std::string, SrsSharedPtr<SrsRtspSource> > pool_;
SrsHourGlass *timer_;
@ -99,7 +103,8 @@ public:
public:
virtual srs_error_t initialize();
// interface ISrsHourGlassHandler
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t setup_ticks();
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.
class SrsRtspSource : public ISrsRtpTarget
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
ISrsCircuitBreaker *circuit_breaker_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// For publish, it's the publish client id.
// For edge, it's the edge ingest id.
// when source id changed, for example, the edge reconnect,
@ -139,15 +146,18 @@ SRS_DECLARE_PRIVATE:
SrsRtcTrackDescription *audio_desc_;
SrsRtcTrackDescription *video_desc_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// To delivery stream to clients.
std::vector<SrsRtspConsumer *> consumers_;
std::vector<SrsRtspConsumer *>
consumers_;
// Whether stream is created, that is, SDP is done.
bool is_created_;
// Whether stream is delivering data, that is, DTLS is done.
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.
srs_utime_t stream_die_at_;
@ -166,9 +176,11 @@ public:
// Update the authentication information in request.
virtual void update_auth(ISrsRequest *r);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The stream source changed.
virtual srs_error_t on_source_changed();
virtual srs_error_t
on_source_changed();
public:
// Get current source id.
@ -209,10 +221,12 @@ public:
// Convert AV frame to RTSP RTP packets.
class SrsRtspRtpBuilder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
ISrsRtpTarget *rtp_target_;
// The format, codec information.
@ -222,13 +236,15 @@ SRS_DECLARE_PRIVATE:
// The video builder, convert frame to RTP packets.
SrsRtpVideoBuilder *video_builder_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint16_t audio_sequence_;
uint32_t audio_ssrc_;
uint8_t audio_payload_type_;
int audio_sample_rate_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsSharedPtr<SrsRtspSource> source_;
// Lazy initialization flags
bool audio_initialized_;
@ -238,9 +254,11 @@ public:
SrsRtspRtpBuilder(ISrsRtpTarget *target, SrsSharedPtr<SrsRtspSource> source);
virtual ~SrsRtspRtpBuilder();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// 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);
public:
@ -249,16 +267,20 @@ public:
virtual void on_unpublish();
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);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
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);
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 package_stap_a(SrsMediaPacket *msg, SrsRtpPacket *pkt);
srs_error_t package_nalus(SrsMediaPacket *msg, const std::vector<SrsNaluSample *> &samples, std::vector<SrsRtpPacket *> &pkts);
@ -286,7 +308,8 @@ public:
// send track description
SrsRtcTrackDescription *track_desc_;
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
// The owner connection for this track.
ISrsRtspConnection *session_;

View File

@ -41,7 +41,8 @@ public:
// @param req the request object of client.
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 allow_check(SrsConfDirective *rules, SrsRtmpConnType type, std::string ip);
virtual srs_error_t deny_check(SrsConfDirective *rules, SrsRtmpConnType type, std::string ip);

View File

@ -81,7 +81,7 @@ extern SrsDtlsCertificate *_srs_rtc_dtls_certificate;
bool _srs_global_initialized = false;
srs_error_t srs_global_initialize()
{
srs_error_t err = srs_success;
srs_error_t err = srs_success;
// Initialize the global kbps statistics variables
if ((err = srs_global_kbps_initialize()) != srs_success) {

View File

@ -122,7 +122,8 @@ class SrsServer : public ISrsReloadHandler, // Reload framework for permormance
public ISrsApiServerOwner,
public ISrsRtcApiServer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
ISrsLiveSourceManager *live_sources_;
ISrsResourceManager *conn_manager_;
@ -141,20 +142,24 @@ SRS_DECLARE_PRIVATE:
ISrsStatistic *stat_;
ISrsAppFactory *app_factory_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsCommonHttpHandler *http_api_mux_;
SrsHttpServer *http_server_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsHttpHeartbeat *http_heartbeat_;
SrsIngester *ingester_;
ISrsHourGlass *timer_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// PID file manager for process identification and locking.
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.
bool reuse_api_over_server_;
// If reusing, WebRTC TCP use the same port of HTTP server.
@ -191,17 +196,22 @@ SRS_DECLARE_PRIVATE:
SrsGbListener *stream_caster_gb28181_;
#endif
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// 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.
std::vector<SrsUdpMuxListener *> rtc_listeners_;
std::vector<SrsUdpMuxListener *>
rtc_listeners_;
// WebRTC 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.
SrsSignalManager *signal_manager_;
// To query the latest available version of SRS.
@ -219,10 +229,12 @@ public:
SrsServer();
virtual ~SrsServer();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// When SIGTERM, SRS should do cleanup, for example,
// to stop all ingesters, cleanup HLS and dvr.
virtual void dispose();
virtual void
dispose();
// Close listener to stop accepting new connections,
// then wait and quit when all connections finished.
virtual void gracefully_dispose();
@ -240,7 +252,8 @@ public:
public:
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_signal();
virtual srs_error_t listen();
@ -252,7 +265,8 @@ public:
void stop();
// interface ISrsCoroutineHandler
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t cycle();
// server utilities.
@ -272,21 +286,26 @@ public:
// @remark, maybe the HTTP RAW API will trigger the on_signal() also.
virtual void on_signal(int signo);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The server thread main cycle,
// update the global static data, for instance, the current time,
// the cpu/mem/network statistic.
virtual srs_error_t do_cycle();
virtual srs_error_t
do_cycle();
virtual srs_error_t do2_cycle();
// interface ISrsHourGlassHandler
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t setup_ticks();
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.
virtual void resample_kbps();
virtual void
resample_kbps();
// SRT-related methods
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 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
virtual srs_error_t listen_rtc_udp();
virtual srs_error_t
listen_rtc_udp();
// Interface ISrsUdpMuxHandler
public:
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();
public:
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);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t srs_update_server_statistics();
// Interface ISrsTcpHandler
public:
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 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
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.
// Up to PIPE_BUF/sizeof(int) signals can be queued up.
int sig_pipe_[2];
srs_netfd_t signal_read_stfd_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsServer *server_;
ISrsCoroutine *trd_;
@ -354,7 +380,8 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Global singleton instance
static SrsSignalManager *instance;
// Signal catching function.
@ -366,10 +393,12 @@ SRS_DECLARE_PRIVATE:
// @see https://github.com/ossrs/srs/issues/1635
class SrsInotifyWorker : public ISrsCoroutineHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsServer *server_;
ISrsCoroutine *trd_;
srs_netfd_t inotify_fd_;
@ -388,10 +417,12 @@ public:
// PID file manager for process identification and locking.
class SrsPidFileLocker
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsAppConfig *config_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
int pid_fd_;
std::string pid_file_;
@ -403,9 +434,11 @@ public:
// Acquire the PID file for the whole process.
virtual srs_error_t acquire();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Close the PID file descriptor.
virtual void close();
virtual void
close();
};
#endif

View File

@ -59,7 +59,8 @@ public:
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);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The underlayer srt fd handler.
srs_srt_t srt_fd_;
// The underlayer srt socket.
@ -86,14 +87,16 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t do_cycle();
public:
srs_error_t start();
srs_error_t get_recv_err();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsProtocolReadWriter *srt_conn_;
ISrsCoroutine *trd_;
srs_error_t recv_err_;
@ -115,7 +118,8 @@ public:
// The SRT connection, for client to publish or play stream.
class SrsMpegtsSrtConn : public ISrsMpegtsSrtConnection
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
ISrsAppConfig *config_;
ISrsStreamPublishTokenManager *stream_publish_tokens_;
@ -147,10 +151,12 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
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 playing();
srs_error_t acquire_publish();
@ -158,10 +164,12 @@ SRS_DECLARE_PRIVATE:
srs_error_t do_publishing();
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_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t http_hooks_on_connect();
void http_hooks_on_close();
srs_error_t http_hooks_on_publish();
@ -169,7 +177,8 @@ SRS_DECLARE_PRIVATE:
srs_error_t http_hooks_on_play();
void http_hooks_on_stop();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsResourceManager *resource_manager_;
srs_srt_t srt_fd_;
ISrsProtocolReadWriter *srt_conn_;

View File

@ -28,12 +28,14 @@ public:
// Bind and listen SRT(udp) port, use handler to process the client.
class SrsSrtListener : public ISrsCoroutineHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_srt_t lfd_;
SrsSrtSocket *srt_skt_;
ISrsCoroutine *trd_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsSrtHandler *handler_;
std::string ip_;
int port_;

View File

@ -30,12 +30,14 @@ public:
// A common srt acceptor, for SRT server.
class SrsSrtAcceptor : public ISrsSrtHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string ip_;
int port_;
ISrsSrtClientHandler *srt_handler_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsSrtListener *listener_;
public:
@ -45,7 +47,8 @@ public:
public:
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();
// Interface ISrsSrtHandler
public:
@ -69,7 +72,8 @@ public:
public:
virtual srs_error_t cycle();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsSrtPoller *srt_poller_;
ISrsCoroutine *trd_;
};

View File

@ -48,7 +48,8 @@ public:
char *data();
int size();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsMediaPacket *shared_buffer_;
// The size of SRT packet or SRT payload.
int actual_buffer_size_;
@ -70,7 +71,8 @@ public:
// The SRT source manager.
class SrsSrtSourceManager : public ISrsHourGlassHandler, public ISrsSrtSourceManager
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_mutex_t lock_;
std::map<std::string, SrsSharedPtr<SrsSrtSource> > pool_;
SrsHourGlass *timer_;
@ -82,7 +84,8 @@ public:
public:
virtual srs_error_t initialize();
// interface ISrsHourGlassHandler
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t setup_ticks();
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.
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.
ISrsSrtSource *source_;
@ -124,7 +128,8 @@ public:
SrsSrtConsumer(ISrsSrtSource *source);
virtual ~SrsSrtConsumer();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::vector<SrsSrtPacket *> queue_;
// when source id changed, notice all consumers
bool should_update_source_id_;
@ -162,7 +167,8 @@ public:
public:
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_audio(SrsTsMessage *msg, SrsBuffer *avs);
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 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_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsTsContext *ts_ctx_;
// Record sps/pps had changed, if change, need to generate new video sh frame.
bool sps_pps_change_;
@ -190,10 +198,12 @@ SRS_DECLARE_PRIVATE:
bool audio_sh_change_;
std::string audio_sh_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// SRT to rtmp, video stream id.
int video_streamid_;
// SRT to rtmp, audio stream id.
@ -218,7 +228,8 @@ public:
// A SRT source is a stream, to publish and to play with.
class SrsSrtSource : public ISrsSrtSource
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStatistic *stat_;
public:
@ -261,7 +272,8 @@ public:
public:
srs_error_t on_packet(SrsSrtPacket *packet);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Source id.
SrsContextId _source_id;
// previous source id.
@ -273,7 +285,8 @@ SRS_DECLARE_PRIVATE:
// The last die time, while die means neither publishers nor players.
srs_utime_t stream_die_at_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsSrtBridge *srt_bridge_;
};

View File

@ -25,7 +25,8 @@ class SrsExecutorCoroutine;
// @see https://github.com/ossrs/srs/pull/908
class SrsDummyCoroutine : public ISrsCoroutine
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsContextId cid_;
public:
@ -55,7 +56,8 @@ public:
// Please read https://github.com/ossrs/srs/issues/78
class SrsSTCoroutine : public ISrsCoroutine
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsFastCoroutine *impl_;
public:
@ -96,24 +98,28 @@ public:
// High performance coroutine.
class SrsFastCoroutine : public ISrsCoroutine
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string name_;
int stack_size_;
ISrsCoroutineHandler *handler_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_thread_t trd_;
SrsContextId cid_;
srs_error_t trd_err_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool started_;
bool interrupted_;
bool disposed_;
// Cycle done, no need to interrupt it.
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.
bool stopping_;
SrsContextId stopping_cid_;
@ -140,7 +146,8 @@ public:
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();
static void *pfn(void *arg);
};
@ -148,7 +155,8 @@ SRS_DECLARE_PRIVATE:
// Like goroutine sync.WaitGroup.
class SrsWaitGroup
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
int nn_;
srs_cond_t done_;
@ -203,13 +211,15 @@ class SrsExecutorCoroutine : public ISrsResource, // It's a resource.
public ISrsContextIdGetter,
public ISrsCoroutineHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsResourceManager *manager_;
ISrsResource *resource_;
ISrsCoroutineHandler *handler_;
ISrsExecutorHandler *callback_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsCoroutine *trd_;
public:

View File

@ -178,7 +178,8 @@ public:
// The global statistic instance.
class SrsStatistic : public ISrsStatistic
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The id to identify the sever.
std::string server_id_;
// The id to identify the service.
@ -186,27 +187,34 @@ SRS_DECLARE_PRIVATE:
// The pid to identify the service process.
std::string service_pid_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// 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.
// @remark a fast index for vhosts.
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.
std::map<std::string, SrsStatisticStream *> streams_;
std::map<std::string, SrsStatisticStream *>
streams_;
// The key: stream url, value: stream Object.
// @remark a fast index for streams.
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.
std::map<std::string, SrsStatisticClient *> clients_;
std::map<std::string, SrsStatisticClient *>
clients_;
// The server total kbps.
SrsKbps *kbps_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The total of clients connections.
int64_t nb_clients_;
// The total of clients errors.
@ -252,9 +260,11 @@ public:
// exists in stat.
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.
void cleanup_stream(SrsStatisticStream *stream);
void
cleanup_stream(SrsStatisticStream *stream);
public:
// Sample the kbps, add delta bytes of conn.
@ -284,7 +294,8 @@ public:
// Dumps the hints about SRS server.
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 SrsStatisticStream *create_stream(SrsStatisticVhost *vhost, ISrsRequest *req);

View File

@ -85,7 +85,8 @@ public:
// Then, deliver the RTP packets to RTP target, which binds to a RTC/RTSP source.
class SrsRtmpBridge : public ISrsRtmpBridge
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
#ifdef SRS_FFMPEG_FIT
SrsRtcRtpBuilder *rtp_builder_;
#endif
@ -135,7 +136,8 @@ public:
// Then, deliver the AV frames to frame target, which binds to a RTMP/RTC source.
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.
SrsSrtFrameBuilder *frame_builder_;
// 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.
class SrsRtcBridge : public ISrsRtcBridge
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRequest *req_;
#ifdef SRS_FFMPEG_FIT
// Collect and build WebRTC RTP packets to AV frames.

View File

@ -24,7 +24,8 @@ class SrsStreamPublishTokenManager;
// This prevents race conditions across all protocols (RTMP, RTC, SRT, etc.).
class SrsStreamPublishToken
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The stream URL this token is for
std::string stream_url_;
// Whether this token is currently acquired
@ -70,9 +71,11 @@ public:
// This prevents race conditions across all protocols.
class SrsStreamPublishTokenManager : public ISrsStreamPublishTokenManager
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Map of stream URL to token
std::map<std::string, SrsStreamPublishToken *> tokens_;
std::map<std::string, SrsStreamPublishToken *>
tokens_;
// Mutex to protect the tokens map
srs_mutex_t mutex_;

View File

@ -17,11 +17,11 @@
// 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.
#ifdef SRS_FORCE_PUBLIC4UTEST
#define SRS_DECLARE_PRIVATE public
#define SRS_DECLARE_PROTECTED public
#define SRS_DECLARE_PRIVATE public
#define SRS_DECLARE_PROTECTED public
#else
#define SRS_DECLARE_PRIVATE private
#define SRS_DECLARE_PROTECTED protected
#define SRS_DECLARE_PRIVATE private
#define SRS_DECLARE_PROTECTED protected
#endif
// To convert macro values to string.
@ -79,7 +79,8 @@ typedef SrsCplxError *srs_error_t;
#if 1
class _SrsContextId
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string v_;
public:

View File

@ -32,7 +32,8 @@
template <class T>
class SrsUniquePtr
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
T *ptr_;
void (*deleter_)(T *);
@ -63,19 +64,23 @@ public:
return ptr_;
}
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Copy the unique ptr.
SrsUniquePtr(const SrsUniquePtr<T> &);
// The assign operator.
SrsUniquePtr<T> &operator=(const SrsUniquePtr<T> &);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Overload the * operator.
T &operator*();
T &
operator*();
// Overload the bool operator.
operator bool() const;
#if __cplusplus >= 201103L // C++11
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The move constructor.
SrsUniquePtr(SrsUniquePtr<T> &&);
// The move assign operator.
@ -96,7 +101,8 @@ SRS_DECLARE_PRIVATE:
template <class T>
class SrsUniquePtr<T[]>
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
T *ptr_;
public:
@ -125,19 +131,23 @@ public:
return ptr_[index];
}
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Copy the unique ptr.
SrsUniquePtr(const SrsUniquePtr<T> &);
// The assign operator.
SrsUniquePtr<T> &operator=(const SrsUniquePtr<T> &);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Overload the * operator.
T &operator*();
T &
operator*();
// Overload the bool operator.
operator bool() const;
#if __cplusplus >= 201103L // C++11
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The move constructor.
SrsUniquePtr(SrsUniquePtr<T> &&);
// The move assign operator.
@ -157,7 +167,8 @@ SRS_DECLARE_PRIVATE:
template <class T>
class SrsSharedPtr
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The pointer to the object.
T *ptr_;
// The reference count of the object.
@ -181,9 +192,11 @@ public:
reset();
}
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Reset the shared ptr.
void reset()
void
reset()
{
if (!ref_count_)
return;
@ -235,9 +248,11 @@ public:
return *this;
}
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Overload the * operator.
T &operator*()
T &
operator*()
{
return *ptr_;
}

View File

@ -30,10 +30,12 @@ public:
// Transmux the RTMP packets to AAC stream.
class SrsAacTransmuxer : public ISrsAacTransmuxer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStreamWriter *writer_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsAacObjectType aac_object_;
int8_t aac_sample_rate_;
int8_t aac_channels_;

View File

@ -50,7 +50,8 @@ public:
//
class SrsLbRoundRobin : public ISrsLbRoundRobin
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
int index_;
uint32_t count_;
std::string elem_;

View File

@ -182,7 +182,8 @@ public:
// @remark The buffer never manages the bytes memory, user must manage it.
class SrsBuffer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Current read/write position within the buffer
char *p_;
// 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.
class SrsBitBuffer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Current byte being processed (cached from stream)
int8_t cb_;
// 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.
class SrsMemoryBlock
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Current size of valid data in the buffer.
// This may be less than the allocated buffer size for chunked data
// that arrives in multiple parts.

View File

@ -434,7 +434,8 @@ extern bool srs_is_server_gracefully_close(srs_error_t err);
// please @read https://github.com/ossrs/srs/issues/913
class SrsCplxError
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
int code_;
SrsCplxError *wrapped_;
std::string msg_;
@ -449,13 +450,15 @@ SRS_DECLARE_PRIVATE:
std::string desc_;
std::string summary_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsCplxError();
public:
virtual ~SrsCplxError();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual std::string description();
virtual std::string summary();

View File

@ -38,7 +38,8 @@ public:
// file writer, to write to file.
class SrsFileWriter : public ISrsFileWriter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string path_;
FILE *fp_;
char *buf_;
@ -107,7 +108,8 @@ public:
*/
class SrsFileReader : public ISrsFileReader
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string path_;
int fd_;

View File

@ -268,13 +268,15 @@ public:
// Transmux RTMP packets to FLV stream.
class SrsFlvTransmuxer : public ISrsFlvTransmuxer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool has_audio_;
bool has_video_;
bool drop_if_not_match_;
ISrsWriter *writer_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
char tag_header_[SRS_FLV_TAG_HEADER_SIZE];
public:
@ -317,7 +319,8 @@ public:
// @remark assert data_size is not negative.
static int size_tag(int data_size);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The cache tag header.
int nb_tag_headers_;
char *tag_headers_;
@ -332,7 +335,8 @@ public:
// Write the tags in a time.
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_audio(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.
class SrsFlvDecoder : public ISrsFlvDecoder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsReader *reader_;
public:
@ -396,7 +401,8 @@ public:
// then seek to specified offset.
class SrsFlvVodStreamDecoder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsFileReader *reader_;
public:

View File

@ -70,7 +70,8 @@ public:
// hg->start();
class SrsHourGlass : public ISrsCoroutineHandler, public ISrsHourGlass
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string label_;
ISrsCoroutine *trd_;
ISrsHourGlassHandler *handler_;
@ -139,7 +140,8 @@ public:
// instead, we should start only one fast timer in server.
class SrsFastTimer : public ISrsCoroutineHandler, public ISrsFastTimer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsCoroutine *trd_;
srs_utime_t interval_;
std::vector<ISrsFastTimerHandler *> handlers_;
@ -156,23 +158,27 @@ public:
void subscribe(ISrsFastTimerHandler *timer);
void unsubscribe(ISrsFastTimerHandler *timer);
// Interface ISrsCoroutineHandler
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Cycle the hourglass, which will sleep resolution every time.
// and call handler when ticked.
virtual srs_error_t cycle();
virtual srs_error_t
cycle();
};
// To monitor the system wall clock timer deviation.
class SrsClockWallMonitor : public ISrsFastTimerHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsTime *time_;
public:
SrsClockWallMonitor();
virtual ~SrsClockWallMonitor();
// interface ISrsFastTimerHandler
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t on_timer(srs_utime_t interval);
};
@ -193,7 +199,8 @@ public:
// Global shared timer manager
class SrsSharedTimer : public ISrsSharedTimer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsFastTimer *timer20ms_;
SrsFastTimer *timer100ms_;
SrsFastTimer *timer1s_;

View File

@ -71,10 +71,12 @@ public:
// A pps manager every some duration.
class SrsPps
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsClock *clk_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// samples
SrsRateSample sample_10s_;
SrsRateSample sample_30s_;
@ -252,7 +254,8 @@ void srs_global_rtc_update(SrsKbsRtcStats *stats);
*/
class SrsKbpsSlice
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsClock *clk_;
public:
@ -315,7 +318,8 @@ public:
// sent out each UDP packet.
class SrsEphemeralDelta : public ISrsEphemeralDelta
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint64_t in_;
uint64_t out_;
@ -344,7 +348,8 @@ public:
// A network delta data source for SrsKbps.
class SrsNetworkDelta : public ISrsNetworkDelta
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsProtocolStatistic *in_;
ISrsProtocolStatistic *out_;
uint64_t in_base_;
@ -375,7 +380,8 @@ public:
*/
class SrsKbps
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsKbpsSlice *is_;
SrsKbpsSlice *os_;
ISrsClock *clk_;
@ -411,7 +417,8 @@ public:
// A sugar to use SrsNetworkDelta and SrsKbps.
class SrsNetworkKbps
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsNetworkDelta *delta_;
SrsKbps *kbps_;

View File

@ -94,7 +94,8 @@ public:
#define SrsContextRestore(cid) impl_SrsContextRestore _context_restore_instance(cid)
class impl_SrsContextRestore
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsContextId cid_;
public:

View File

@ -32,7 +32,8 @@ public:
*/
class SrsMp3Transmuxer : public ISrsMp3Transmuxer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsFileWriter *writer_;
public:

View File

@ -177,7 +177,8 @@ public:
// ISO_IEC_14496-12-base-format-2012.pdf, page 16
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,
// And all contained boxes. This facilitates general parsing of the file.
//
@ -195,10 +196,12 @@ public:
// For box 'uuid'.
std::vector<char> usertype_;
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
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.
int start_pos_;
@ -240,14 +243,17 @@ public:
virtual srs_error_t encode(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 decode_boxes(SrsBuffer *buf);
// Sub classes can override these functions for special 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.
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,
// so we have checked the buffer is ok to write.
virtual srs_error_t encode_header(SrsBuffer *buf);
@ -276,7 +282,8 @@ public:
SrsMp4FullBox();
virtual ~SrsMp4FullBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_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
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
std::vector<SrsMp4BoxBrand> compatible_brands_;
std::vector<SrsMp4BoxBrand>
compatible_brands_;
public:
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, SrsMp4BoxBrand b3);
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -370,7 +380,8 @@ public:
SrsMp4MovieFragmentHeaderBox();
virtual ~SrsMp4MovieFragmentHeaderBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -452,7 +463,8 @@ public:
SrsMp4TrackFragmentHeaderBox();
virtual ~SrsMp4TrackFragmentHeaderBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -478,7 +490,8 @@ public:
SrsMp4TrackFragmentDecodeTimeBox();
virtual ~SrsMp4TrackFragmentDecodeTimeBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -554,7 +567,8 @@ public:
SrsMp4TrackFragmentRunBox();
virtual ~SrsMp4TrackFragmentRunBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -629,7 +643,8 @@ public:
// because the mdat only decode the header.
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 decode_boxes(SrsBuffer *buf);
@ -641,14 +656,16 @@ public:
// ISO_IEC_14496-12-base-format-2012.pdf, page 29
class SrsMp4FreeSpaceBox : public SrsMp4Box
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::vector<char> data_;
public:
SrsMp4FreeSpaceBox(SrsMp4BoxType v);
virtual ~SrsMp4FreeSpaceBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -685,7 +702,8 @@ public:
// Get the number of audio tracks.
virtual int nb_soun_tracks();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -738,7 +756,8 @@ public:
// Get the duration in ms.
virtual uint64_t duration();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -787,7 +806,8 @@ public:
SrsMp4TrackExtendsBox();
virtual ~SrsMp4TrackExtendsBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -915,7 +935,8 @@ public:
SrsMp4TrackHeaderBox();
virtual ~SrsMp4TrackHeaderBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -985,7 +1006,8 @@ public:
SrsMp4EditListBox();
virtual ~SrsMp4EditListBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_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.
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
// 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.
@ -1067,7 +1090,8 @@ public:
virtual char language2();
virtual void set_language2(char v);
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -1101,7 +1125,8 @@ public:
virtual bool is_video();
virtual bool is_audio();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -1152,7 +1177,8 @@ public:
SrsMp4VideoMeidaHeaderBox();
virtual ~SrsMp4VideoMeidaHeaderBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -1174,7 +1200,8 @@ public:
SrsMp4SoundMeidaHeaderBox();
virtual ~SrsMp4SoundMeidaHeaderBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -1220,7 +1247,8 @@ public:
SrsMp4DataEntryUrlBox();
virtual ~SrsMp4DataEntryUrlBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -1240,7 +1268,8 @@ public:
SrsMp4DataEntryUrnBox();
virtual ~SrsMp4DataEntryUrnBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_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.
class SrsMp4DataReferenceBox : public SrsMp4FullBox
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::vector<SrsMp4DataEntryBox *> entries_;
public:
@ -1269,7 +1299,8 @@ public:
// Note that box must be SrsMp4DataEntryBox*
virtual void append(SrsMp4Box *box);
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -1315,7 +1346,8 @@ public:
virtual SrsMp4SyncSampleBox *stss();
virtual void set_stss(SrsMp4SyncSampleBox *v);
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -1336,7 +1368,8 @@ public:
SrsMp4SampleEntry();
virtual ~SrsMp4SampleEntry();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -1386,7 +1419,8 @@ public:
virtual SrsMp4HvcCBox *hvcC();
virtual void set_hvcC(SrsMp4HvcCBox *v);
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -1406,7 +1440,8 @@ public:
SrsMp4AvccBox();
virtual ~SrsMp4AvccBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -1426,7 +1461,8 @@ public:
SrsMp4HvcCBox();
virtual ~SrsMp4HvcCBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -1458,7 +1494,8 @@ public:
// For AAC codec, get the asc.
virtual SrsMp4DecoderSpecificInfo *asc();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_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).
SrsMp4ESTagEs tag; // bit(8)
// The decoded or encoded variant length.
int32_t vlen; // bit(28)
SRS_DECLARE_PRIVATE:
int32_t vlen; // bit(28)
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The position at buffer to start demux the box.
int start_pos;
@ -1508,7 +1546,8 @@ public:
virtual srs_error_t encode(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 srs_error_t encode_payload(SrsBuffer *buf) = 0;
virtual srs_error_t decode_payload(SrsBuffer *buf) = 0;
@ -1549,7 +1588,8 @@ public:
SrsMp4DecoderSpecificInfo();
virtual ~SrsMp4DecoderSpecificInfo();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int32_t nb_payload();
virtual srs_error_t encode_payload(SrsBuffer *buf);
virtual srs_error_t decode_payload(SrsBuffer *buf);
@ -1577,7 +1617,8 @@ public:
SrsMp4DecoderConfigDescriptor();
virtual ~SrsMp4DecoderConfigDescriptor();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int32_t nb_payload();
virtual srs_error_t encode_payload(SrsBuffer *buf);
virtual srs_error_t decode_payload(SrsBuffer *buf);
@ -1597,7 +1638,8 @@ public:
SrsMp4SLConfigDescriptor();
virtual ~SrsMp4SLConfigDescriptor();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int32_t nb_payload();
virtual srs_error_t encode_payload(SrsBuffer *buf);
virtual srs_error_t decode_payload(SrsBuffer *buf);
@ -1626,7 +1668,8 @@ public:
SrsMp4ES_Descriptor();
virtual ~SrsMp4ES_Descriptor();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int32_t nb_payload();
virtual srs_error_t encode_payload(SrsBuffer *buf);
virtual srs_error_t decode_payload(SrsBuffer *buf);
@ -1652,7 +1695,8 @@ public:
// For AAC codec, get the asc.
virtual SrsMp4DecoderSpecificInfo *asc();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -1667,7 +1711,8 @@ public:
// information needed for that coding.
class SrsMp4SampleDescriptionBox : public SrsMp4FullBox
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::vector<SrsMp4SampleEntry *> entries_;
public:
@ -1686,7 +1731,8 @@ public:
// Note that box must be SrsMp4SampleEntry*
virtual void append(SrsMp4Box *box);
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_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.
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.
uint32_t index_;
uint32_t count_;
@ -1741,7 +1788,8 @@ public:
// When got an sample, index starts from 0.
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 srs_error_t encode_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.
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.
uint32_t index_;
uint32_t count_;
@ -1801,7 +1850,8 @@ public:
// When got an sample, index starts from 0.
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 srs_error_t encode_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.
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 srs_error_t encode_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.
SrsMp4StscEntry *entries_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The index for counter to calc the dts for samples.
uint32_t index_;
@ -1890,7 +1942,8 @@ public:
// When got an chunk, index starts from 0.
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 srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -1917,7 +1970,8 @@ public:
SrsMp4ChunkOffsetBox();
virtual ~SrsMp4ChunkOffsetBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -1944,7 +1998,8 @@ public:
SrsMp4ChunkLargeOffsetBox();
virtual ~SrsMp4ChunkLargeOffsetBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -1979,7 +2034,8 @@ public:
// Get the size of sample.
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 srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -2001,7 +2057,8 @@ public:
SrsMp4UserDataBox();
virtual ~SrsMp4UserDataBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -2040,7 +2097,8 @@ public:
SrsMp4SegmentIndexBox();
virtual ~SrsMp4SegmentIndexBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -2079,7 +2137,8 @@ public:
SrsMp4SampleAuxiliaryInfoSizeBox();
virtual ~SrsMp4SampleAuxiliaryInfoSizeBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -2117,7 +2176,8 @@ public:
SrsMp4SampleAuxiliaryInfoOffsetBox();
virtual ~SrsMp4SampleAuxiliaryInfoOffsetBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_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);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsMp4FullBox *senc_;
uint8_t per_sample_iv_size_;
uint8_t *iv_;
@ -2195,7 +2256,8 @@ class SrsMp4SampleEncryptionBox : public SrsMp4FullBox
public:
std::vector<SrsMp4SampleEncryptionEntry *> entries_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint8_t per_sample_iv_size_;
public:
@ -2204,7 +2266,8 @@ public:
SrsMp4SampleEncryptionBox(uint8_t per_sample_iv_size);
virtual ~SrsMp4SampleEncryptionBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -2220,14 +2283,16 @@ public:
// }
class SrsMp4OriginalFormatBox : public SrsMp4Box
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint32_t data_format_;
public:
SrsMp4OriginalFormatBox(uint32_t original_format);
virtual ~SrsMp4OriginalFormatBox();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int nb_header();
virtual srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -2263,7 +2328,8 @@ public:
public:
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 srs_error_t encode_header(SrsBuffer *buf);
virtual srs_error_t decode_header(SrsBuffer *buf);
@ -2387,7 +2453,8 @@ public:
public:
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 srs_error_t encode_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.
class SrsMp4DvrJitter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint64_t video_start_dts_;
uint64_t audio_start_dts_;
bool has_first_video_;
@ -2455,9 +2523,11 @@ public:
// to maintain A/V synchronization in MP4 files
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)
virtual void reset();
virtual void
reset();
// Check if both audio and video start times have been captured
virtual bool is_initialized();
};
@ -2473,8 +2543,9 @@ SRS_DECLARE_PRIVATE:
// The keyframe is specified by stss.
class SrsMp4SampleManager
{
SRS_DECLARE_PRIVATE:
SrsMp4DvrJitter *jitter_; // MP4 A/V sync jitter handler
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsMp4DvrJitter *jitter_; // MP4 A/V sync jitter handler
public:
std::vector<SrsMp4Sample *> samples_;
@ -2497,27 +2568,31 @@ public:
// @param The dts is the dts of last segment.
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,
SrsMp4DecodingTime2SampleBox *stts, SrsMp4SyncSampleBox *stss, SrsMp4CompositionTime2SampleBox *ctts,
SrsMp4Sample2ChunkBox *stsc, SrsMp4SampleSizeBox *stsz, SrsMp4FullBox *co);
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.
// @param tses The temporary samples, key is offset, value is sample.
// @param tt The type of sample, convert to flv tag type.
// TODO: Support co64 for stco.
virtual srs_error_t load_trak(std::map<uint64_t, SrsMp4Sample *> &tses, SrsFrameType tt,
SrsMp4MediaHeaderBox *mdhd, SrsMp4ChunkOffsetBox *stco, SrsMp4SampleSizeBox *stsz, SrsMp4Sample2ChunkBox *stsc,
SrsMp4DecodingTime2SampleBox *stts, SrsMp4CompositionTime2SampleBox *ctts, SrsMp4SyncSampleBox *stss);
virtual srs_error_t
load_trak(std::map<uint64_t, SrsMp4Sample *> &tses, SrsFrameType tt,
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.
// @remark For mdat box, we only decode the header, then skip the data.
class SrsMp4BoxReader
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsReadSeeker *rsio_;
// The temporary buffer to read from buffer.
char *buf_;
@ -2533,7 +2608,8 @@ public:
// 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);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t do_read(SrsSimpleStream *stream, SrsMp4Box *&box);
public:
@ -2544,7 +2620,8 @@ public:
// The MP4 demuxer.
class SrsMp4Decoder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The major brand of decoder, parse from ftyp.
SrsMp4BoxBrand brand_;
// The samples build from moov.
@ -2559,9 +2636,11 @@ public:
// TODO: FIXME: Use SrsFormat instead.
SrsVideoCodecId vcodec_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// For H.264/AVC, the avcc contains the sps/pps.
std::vector<char> pavcc_;
std::vector<char>
pavcc_;
// Whether avcc is written to reader.
bool avcc_written_;
@ -2576,13 +2655,16 @@ public:
// The audio sound type.
SrsAudioChannels channels_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// For AAC, the asc in esds box.
std::vector<char> pasc_;
std::vector<char>
pasc_;
// Whether asc is written to reader.
bool asc_written_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Underlayer reader and seeker.
// @remark The demuxer must use seeker for general MP4 to seek the moov.
ISrsReadSeeker *rsio_;
@ -2612,14 +2694,17 @@ public:
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);
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_moov(SrsMp4MovieBox *moov);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Load the next box from reader.
// @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.
virtual srs_error_t do_load_next_box(SrsMp4Box **ppbox, uint32_t required_box_type);
};
@ -2646,7 +2731,8 @@ public:
// The MP4 muxer.
class SrsMp4Encoder : public ISrsMp4Encoder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsWriteSeeker *wsio_;
// The mdat offset at file, we must update the header when flush.
off_t mdat_offset_;
@ -2666,9 +2752,11 @@ public:
// The audio sound type.
SrsAudioChannels channels_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// For AAC, the asc in esds box.
std::vector<char> pasc_;
std::vector<char>
pasc_;
// The number of audio samples.
uint32_t nb_audios_;
// The duration of audio stream.
@ -2679,9 +2767,11 @@ public:
// Forbidden if no video stream.
SrsVideoCodecId vcodec_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// 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.
std::vector<char> phvcc_;
// 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);
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 do_write_sample(SrsMp4Sample *ps, uint8_t *sample, uint32_t nb_sample);
virtual SrsMp4ObjectType get_audio_object_type();
@ -2739,10 +2830,12 @@ public:
// TODO: What the M2ts short for?
class SrsMp4M2tsInitEncoder : public ISrsMp4M2tsInitEncoder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsWriter *writer_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint8_t crypt_byte_block_;
uint8_t skip_byte_block_;
unsigned char kid_[16];
@ -2782,7 +2875,8 @@ public:
*/
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'
* |encv|
@ -2792,7 +2886,8 @@ SRS_DECLARE_PRIVATE:
* | | |schi|
* | | | |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.
@ -2824,13 +2919,15 @@ public:
// TODO: fmp4 support package more than one tracks.
class SrsMp4M2tsSegmentEncoder : public ISrsMp4M2tsSegmentEncoder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsWriter *writer_;
uint32_t sequence_number_;
srs_utime_t decode_basetime_;
uint32_t track_id_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint32_t nb_audios_;
uint32_t nb_videos_;
uint32_t styp_bytes_;
@ -2863,7 +2960,8 @@ public:
// TODO: fmp4 support package more than one tracks.
class SrsFmp4SegmentEncoder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsWriter *writer_;
uint32_t sequence_number_;
// TODO: audio, video may have different basetime.
@ -2871,7 +2969,8 @@ SRS_DECLARE_PRIVATE:
uint32_t audio_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_videos_;
uint32_t styp_bytes_;
@ -2880,7 +2979,8 @@ SRS_DECLARE_PRIVATE:
SrsMp4SampleManager *audio_samples_;
SrsMp4SampleManager *video_samples_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Encryption
unsigned char *key_;
unsigned char iv_[16];

View File

@ -252,17 +252,21 @@ public:
virtual SrsParsedVideoPacket *video();
virtual SrsVideoCodecConfig *vcodec();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Demux the video packet in H.264 codec.
// The packet is muxed in FLV format, defined in flv specification.
// Demux the sps/pps from sequence header.
// 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);
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_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_pps(SrsBuffer *stream);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// 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_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.
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.
virtual srs_error_t 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 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 asc from sequence header.
// 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);
public:

View File

@ -43,7 +43,8 @@ public:
// Of course, we can add the multiple user support, which is SrsPithyPrint.
class SrsStageManager
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::map<int, SrsStageInfo *> stages_;
public:
@ -63,7 +64,8 @@ public:
// The number of call of can_print().
uint32_t nn_count_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
double ratio_;
SrsStageManager stages_;
std::map<int, srs_utime_t> ticks_;
@ -82,7 +84,8 @@ public:
// An standalone pithy print, without shared stages.
class SrsAlonePithyPrint
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsStageInfo info_;
srs_utime_t previous_tick_;
@ -127,14 +130,16 @@ public:
// }
class SrsPithyPrint : public ISrsPithyPrint
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
int client_id_;
SrsStageInfo *cache_;
int stage_id_;
srs_utime_t age_;
srs_utime_t previous_tick_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsPithyPrint(int _stage_id);
public:
@ -157,9 +162,11 @@ public:
static SrsPithyPrint *create_srt_publish();
virtual ~SrsPithyPrint();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Enter the specified stage, return the client id.
virtual int enter_stage();
virtual int
enter_stage();
// Leave the specified stage, release the client id.
virtual void leave_stage();

View File

@ -78,7 +78,8 @@ class SrsPsContext : public ISrsPsContext
public:
SrsPsDecodeHelper helper_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The last decoding PS(TS) message.
SrsTsMessage *last_;
// The current parsing PS packet context.
@ -112,7 +113,8 @@ public:
// @remark We will consume all bytes in stream.
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);
};
@ -274,7 +276,8 @@ public:
public:
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_system(SrsBuffer *stream);
};

View File

@ -123,12 +123,14 @@ public:
// The resource manager remove resource and delete it asynchronously.
class SrsResourceManager : public ISrsCoroutineHandler, public ISrsResourceManager
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string label_;
SrsContextId cid_;
bool verbose_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsCoroutine *trd_;
ISrsCond *cond_;
// Callback handlers.
@ -141,9 +143,11 @@ SRS_DECLARE_PRIVATE:
std::vector<ISrsResource *> zombies_;
std::vector<ISrsResource *> *p_disposing_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The connections without any id.
std::vector<ISrsResource *> conns_;
std::vector<ISrsResource *>
conns_;
// The connections with resource id.
std::map<std::string, ISrsResource *> conns_id_;
// The connections with resource fast(int) id.
@ -183,7 +187,8 @@ public:
public:
virtual void remove(ISrsResource *c);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
void do_remove(ISrsResource *c);
void check_remove(ISrsResource *c, bool &in_zombie, bool &in_disposing);
void clear();
@ -210,7 +215,8 @@ SRS_DECLARE_PRIVATE:
template <typename T>
class SrsSharedResource : public ISrsResource
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsSharedPtr<T> ptr_;
public:
@ -244,9 +250,11 @@ public:
return *this;
}
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Overload the * operator.
T &operator*()
T &
operator*()
{
return ptr_.operator*();
}

View File

@ -30,7 +30,8 @@ class SrsRtpRingBuffer;
// We store the received packets in ring buffer.
class SrsRtpRingBuffer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Capacity of the ring-buffer.
uint16_t capacity_;
// Ring bufer.
@ -106,18 +107,22 @@ struct SrsRtpNackInfo {
class SrsRtpNackForReceiver
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Nack queue, seq order, oldest to newest.
std::map<uint16_t, SrsRtpNackInfo, SrsSeqCompareLess> queue_;
std::map<uint16_t, SrsRtpNackInfo, SrsSeqCompareLess>
queue_;
// Max nack count.
size_t max_queue_size_;
SrsRtpRingBuffer *rtp_;
SrsNackOption opts_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_utime_t pre_check_time_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
int rtt_;
public:

View File

@ -63,7 +63,8 @@ struct SrsRtcpHeader {
class SrsRtcpCommon : public ISrsCodec
{
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
SrsRtcpHeader header_;
uint32_t ssrc_;
uint8_t payload_[kRtcpPacketSize];
@ -72,7 +73,8 @@ SRS_DECLARE_PROTECTED:
char *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 encode_header(SrsBuffer *buffer);
@ -96,7 +98,8 @@ public:
class SrsRtcpApp : public SrsRtcpCommon
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint8_t name_[4];
public:
@ -144,7 +147,8 @@ struct SrsRtcpRB {
class SrsRtcpSR : public SrsRtcpCommon
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint64_t ntp_;
uint32_t rtp_ts_;
uint32_t send_rtp_packets_;
@ -175,7 +179,8 @@ public:
class SrsRtcpRR : public SrsRtcpCommon
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsRtcpRB rb_;
public:
@ -213,7 +218,8 @@ public:
// inlucde Transport layer FB message and Payload-specific FB message.
class SrsRtcpFbCommon : public SrsRtcpCommon
{
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
uint32_t media_ssrc_;
public:
@ -273,7 +279,8 @@ public:
class SrsRtcpTWCC : public SrsRtcpFbCommon
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint16_t base_sn_;
int32_t reference_time_;
uint8_t fb_pkt_count_;
@ -294,7 +301,8 @@ SRS_DECLARE_PRIVATE:
int pkt_len_;
uint16_t next_base_sn_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
void clear();
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);
@ -332,13 +340,15 @@ public:
virtual uint64_t nb_bytes();
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);
};
class SrsRtcpNack : public SrsRtcpFbCommon
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
struct SrsPidBlp {
uint16_t pid_;
uint16_t blp_;
@ -377,7 +387,8 @@ public:
class SrsRtcpSli : public SrsRtcpFbCommon
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint16_t first_;
uint16_t number_;
uint8_t picture_;
@ -395,7 +406,8 @@ public:
class SrsRtcpRpsi : public SrsRtcpFbCommon
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint8_t pb_;
uint8_t payload_type_;
char *native_rpsi_;
@ -427,7 +439,8 @@ public:
class SrsRtcpCompound : public ISrsCodec
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::vector<SrsRtcpCommon *> rtcps_;
int nb_bytes_;
char *data_;

View File

@ -137,10 +137,12 @@ public:
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);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint8_t ids_[kRtpExtensionNumberOfExtensions];
};
@ -197,17 +199,20 @@ public:
// Note that the extensions should never extends from any class, for performance.
class SrsRtpExtensions // : public ISrsCodec
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool has_ext_;
// by default, twcc isnot decoded. Because it is decoded by fast function(srs_rtp_fast_parse_twcc)
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 types in publish stream.
SrsRtpExtensionTypes *types_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsRtpExtensionTwcc twcc_;
SrsRtpExtensionOneByte audio_level_;
@ -227,7 +232,8 @@ public:
public:
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);
public:
@ -238,7 +244,8 @@ public:
// Note that the header should never extends from any class, for performance.
class SrsRtpHeader // : public ISrsCodec
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint8_t padding_length_;
uint8_t cc_;
bool marker_;
@ -257,7 +264,8 @@ public:
public:
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);
public:
@ -326,16 +334,19 @@ class SrsRtpPacket
public:
SrsRtpHeader header_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsRtpPayloader *payload_;
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.
// 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),
// 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.
int actual_buffer_size_;
// Helper fields.
@ -345,13 +356,15 @@ public:
// The frame type, for RTMP bridge or SFU source.
SrsFrameType frame_type_;
// Fast cache for performance.
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The cached payload size for packet.
int cached_payload_size_;
// The helper handler for decoder, use RAW payload if NULL.
ISrsRtpPacketDecodeHandler *decode_handler_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
int64_t avsync_time_;
public:
@ -428,9 +441,11 @@ public:
// Multiple NALUs, automatically insert 001 between NALUs.
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.
std::vector<SrsNaluSample *> nalus_;
std::vector<SrsNaluSample *>
nalus_;
int nn_bytes_;
int cursor_;

View File

@ -17,7 +17,8 @@
*/
class SrsSimpleStream
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::vector<char> data_;
public:

View File

@ -338,18 +338,21 @@ public:
// The context of ts, to decode the ts stream.
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.
// When PAT and PMT writen, the context is ready.
// @see https://github.com/ossrs/srs/issues/834
bool ready_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::map<int, SrsTsChannel *> pids_;
bool pure_audio_;
int8_t sync_byte_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// when any codec changed, write the PAT/PMT.
SrsVideoCodecId vcodec_;
SrsAudioCodecId acodec_;
@ -391,7 +394,8 @@ public:
// @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);
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_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
// a null packet the value of the continuity_counter is undefined.
uint8_t continuity_counter_; // 4bits
SRS_DECLARE_PRIVATE:
/* clang-format off */
SRS_DECLARE_PRIVATE: /* clang-format on */
SrsTsAdaptationField *adaptation_field_;
SrsTsPayload *payload_;
@ -742,7 +747,8 @@ public:
// decoder.
int nb_af_reserved_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsTsPacket *packet_;
public:
@ -788,7 +794,8 @@ enum SrsTsPsiId {
// The payload of ts packet, can be PES or PSI payload.
class SrsTsPayload
{
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
SrsTsPacket *packet_;
public:
@ -1071,7 +1078,8 @@ public:
virtual int size();
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 encode_33bits_dts_pts(SrsBuffer *stream, uint8_t fb, int64_t v);
};
@ -1145,7 +1153,8 @@ public:
virtual int size();
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 srs_error_t psi_encode(SrsBuffer *stream) = 0;
virtual srs_error_t psi_decode(SrsBuffer *stream) = 0;
@ -1226,10 +1235,12 @@ public:
SrsTsPayloadPAT(SrsTsPacket *p);
virtual ~SrsTsPayloadPAT();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
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 srs_error_t psi_encode(SrsBuffer *stream);
};
@ -1331,10 +1342,12 @@ public:
SrsTsPayloadPMT(SrsTsPacket *p);
virtual ~SrsTsPayloadPMT();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
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 srs_error_t psi_encode(SrsBuffer *stream);
};
@ -1366,12 +1379,14 @@ public:
// Write the TS message to TS context.
class SrsTsContextWriter : public ISrsTsContextWriter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// User must config the codec in right way.
SrsVideoCodecId vcodec_;
SrsAudioCodecId acodec_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsTsContext *context_;
ISrsStreamWriter *writer_;
std::string path_;
@ -1411,11 +1426,13 @@ public:
public:
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 iv[16];
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
char *buf;
int nb_buf;
};
@ -1469,7 +1486,8 @@ public:
virtual SrsTsMessage *video();
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_aac(SrsParsedAudioPacket *frame);
virtual srs_error_t do_cache_avc(SrsParsedVideoPacket *frame);
@ -1497,13 +1515,15 @@ public:
// Transmux the RTMP stream to HTTP-TS stream.
class SrsTsTransmuxer : public ISrsTsTransmuxer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsStreamWriter *writer_;
bool has_audio_;
bool has_video_;
bool guess_has_av_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsFormat *format_;
ISrsTsMessageCache *tsmc_;
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_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_video();
};

View File

@ -318,11 +318,13 @@ public:
*/
class SrsAmf0Object : public SrsAmf0Any
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_internal::SrsUnSortedHashtable *properties_;
srs_internal::SrsAmf0ObjectEOF *eof_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
friend class SrsAmf0Any;
/**
* make amf0 object to private,
@ -410,12 +412,14 @@ public:
*/
class SrsAmf0EcmaArray : public SrsAmf0Any
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_internal::SrsUnSortedHashtable *properties_;
srs_internal::SrsAmf0ObjectEOF *eof_;
int32_t count_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
friend class SrsAmf0Any;
/**
* make amf0 object to private,
@ -498,11 +502,13 @@ public:
*/
class SrsAmf0StrictArray : public SrsAmf0Any
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::vector<SrsAmf0Any *> properties_;
int32_t count_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
friend class SrsAmf0Any;
/**
* make amf0 object to private,
@ -630,7 +636,8 @@ class SrsAmf0String : public SrsAmf0Any
public:
std::string value_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
friend class SrsAmf0Any;
/**
* make amf0 string to private,
@ -660,7 +667,8 @@ class SrsAmf0Boolean : public SrsAmf0Any
public:
bool value_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
friend class SrsAmf0Any;
/**
* make amf0 boolean to private,
@ -689,7 +697,8 @@ class SrsAmf0Number : public SrsAmf0Any
public:
double value_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
friend class SrsAmf0Any;
/**
* make amf0 number to private,
@ -715,11 +724,13 @@ public:
*/
class SrsAmf0Date : public SrsAmf0Any
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
int64_t date_value_;
int16_t time_zone_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
friend class SrsAmf0Any;
/**
* make amf0 date to private,
@ -754,7 +765,8 @@ public:
*/
class SrsAmf0Null : public SrsAmf0Any
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
friend class SrsAmf0Any;
/**
* make amf0 null to private,
@ -779,7 +791,8 @@ public:
*/
class SrsAmf0Undefined : public SrsAmf0Any
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
friend class SrsAmf0Any;
/**
* make amf0 undefined to private,
@ -805,7 +818,8 @@ public:
*/
class SrsUnSortedHashtable
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
typedef std::pair<std::string, SrsAmf0Any *> SrsAmf0ObjectPropertyType;
std::vector<SrsAmf0ObjectPropertyType> properties_;

View File

@ -51,7 +51,8 @@ public:
// server will add the connection to manager, and delete it when remove.
class SrsTcpConnection : public ISrsProtocolReadWriter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The underlayer st fd handler.
srs_netfd_t stfd_;
// The underlayer socket.
@ -84,7 +85,8 @@ public:
// cache or buffer.
class SrsBufferedReadWriter : public ISrsProtocolReadWriter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The under-layer transport.
ISrsProtocolReadWriter *io_;
// 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.
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();
// Interface ISrsProtocolReadWriter
public:
@ -131,11 +134,13 @@ public:
// The SSL connection over TCP transport, in server mode.
class SrsSslConnection : public ISrsSslConnection
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The under-layer plaintext transport.
ISrsProtocolReadWriter *transport_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SSL_CTX *ssl_ctx_;
SSL *ssl_;
BIO *bio_in_;

View File

@ -32,10 +32,12 @@ class SrsTcpClient;
// The SSL client over TCP transport.
class SrsSslClient : public ISrsReader, public ISrsStreamWriter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsProtocolReadWriter *transport_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SSL_CTX *ssl_ctx_;
SSL *ssl_;
BIO *bio_in_;
@ -82,7 +84,8 @@ public:
// hc.post("/api/v1/version", "Hello world!", NULL);
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.
// We will disconnect transport when initialize or channel error, such as send/recv error.
SrsTcpClient *transport_;
@ -90,7 +93,8 @@ SRS_DECLARE_PRIVATE:
std::map<std::string, std::string> headers_;
SrsNetworkKbps *kbps_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The timeout in srs_utime_t.
srs_utime_t timeout_;
srs_utime_t recv_timeout_;
@ -99,7 +103,8 @@ SRS_DECLARE_PRIVATE:
std::string host_;
int port_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsSslClient *ssl_transport_;
public:
@ -136,7 +141,8 @@ public:
public:
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 srs_error_t connect();
ISrsStreamWriter *writer();

View File

@ -47,7 +47,8 @@ public:
// provides HTTP message originted service.
class SrsHttpParser : public ISrsHttpParser
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
llhttp_settings_t settings_;
llhttp_t parser_;
// The global parse buffer.
@ -55,7 +56,8 @@ SRS_DECLARE_PRIVATE:
// Whether allow jsonp parse.
bool jsonp_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string field_name_;
std::string field_value_;
SrsHttpParseState state_;
@ -82,11 +84,14 @@ public:
// @remark user must free the ppmsg if not NULL.
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.
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_headers_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.
class SrsHttpMessage : public ISrsHttpMessage
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The body object, reader object.
// @remark, user can get body in string by get_body().
SrsHttpResponseReader *_body;
@ -112,7 +118,8 @@ SRS_DECLARE_PRIVATE:
// The transport connection, can be NULL.
ISrsConnection *owner_conn_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The request type defined as
// enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH };
uint8_t type_;
@ -121,7 +128,8 @@ SRS_DECLARE_PRIVATE:
llhttp_status_t _status;
int64_t _content_length;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The http headers
SrsHttpHeader _header;
// Whether the request indicates should keep alive for the http connection.
@ -129,7 +137,8 @@ SRS_DECLARE_PRIVATE:
// Whether the body is chunked.
bool chunked_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string schema_;
// The parsed url.
std::string _url;
@ -140,7 +149,8 @@ SRS_DECLARE_PRIVATE:
// The query map
std::map<std::string, std::string> _query;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Whether request is jsonp.
bool jsonp_;
// 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.
class SrsHttpMessageWriter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsProtocolReadWriter *skt_;
SrsHttpHeader *hdr_;
// Before writing header, there is a chance to filter it,
@ -262,22 +273,26 @@ SRS_DECLARE_PRIVATE:
// The first line writer.
ISrsHttpFirstLineWriter *flw_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
char header_cache_[SRS_HTTP_HEADER_CACHE_SIZE];
iovec *iovss_cache_;
int nb_iovss_cache_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Reply header has been (logically) written
bool header_wrote_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The explicitly-declared Content-Length; or -1
int64_t content_length_;
// The number of bytes written in body
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
// wire" (or rather: w.conn.buf). this is unlike
// (*response).wroteHeader, which tells only whether it was
@ -306,7 +321,8 @@ public:
// Response writer use st socket
class SrsHttpResponseWriter : public ISrsHttpResponseWriter, public ISrsHttpFirstLineWriter
{
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
SrsHttpMessageWriter *writer_;
// The status code passed to WriteHeader, for response only.
int status_;
@ -333,7 +349,8 @@ public:
// Request writer use st socket
class SrsHttpRequestWriter : public ISrsHttpRequestWriter, public ISrsHttpFirstLineWriter
{
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
SrsHttpMessageWriter *writer_;
// The method and path passed to WriteHeader, for request only.
std::string method_;
@ -358,7 +375,8 @@ public:
// Response reader use st socket.
class SrsHttpResponseReader : public ISrsHttpResponseReader
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsReader *skt_;
SrsHttpMessage *owner_;
SrsFastStream *buffer_;
@ -386,7 +404,8 @@ public:
virtual bool eof();
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_specified(void *buf, size_t size, ssize_t *nread);
};

View File

@ -85,13 +85,15 @@ enum SrsHttpParseState {
// A Header represents the key-value pairs in an HTTP header.
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
// received is not significant. However, it is "good practice" to send
// general-header fields first, followed by request-header or response-
// header fields, and ending with the entity-header fields.
// @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.
std::vector<std::string> keys_;
@ -304,7 +306,8 @@ public:
// Redirect to a fixed URL
class SrsHttpRedirectHandler : public ISrsHttpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string url;
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"))
class SrsHttpFileServer : public ISrsHttpHandler
{
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
std::string dir;
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
ISrsFileReaderFactory *fs_factory;
SrsPath *path_;
@ -352,24 +357,30 @@ public:
SrsHttpFileServer(std::string root_dir);
virtual ~SrsHttpFileServer();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// 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.
virtual void set_path(SrsPath *v);
public:
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
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_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
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
// @param start the start offset in bytes.
// @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
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.
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.
@ -476,9 +489,11 @@ public:
// equivalent .- and ..-free URL.
class SrsHttpServeMux : public ISrsHttpServeMux
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// 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.
// When find the handler to process the request,
// 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
std::map<std::string, ISrsHttpHandler *> vhosts_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// all dynamic matcher for http match.
// For example, the hstrs(http stream trigger rtmp source)
// can dynamic match and install handler when request incoming and no handler.
std::vector<ISrsHttpDynamicMatcher *> dynamic_matchers_;
std::vector<ISrsHttpDynamicMatcher *>
dynamic_matchers_;
public:
SrsHttpServeMux();
@ -518,7 +535,8 @@ public:
public:
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 bool path_match(std::string pattern, std::string path);
};
@ -537,7 +555,8 @@ public:
// The filter http mux, directly serve the http CORS requests
class SrsHttpCorsMux : public ISrsHttpCorsMux
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool required;
bool enabled;
ISrsHttpHandler *next_;
@ -570,7 +589,8 @@ public:
// @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/WWW-Authenticate
class SrsHttpAuthMux : public ISrsHttpAuthMux
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool enabled_;
std::string username_;
std::string password_;
@ -586,7 +606,8 @@ public:
public:
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);
};
@ -668,7 +689,8 @@ public:
// Used to resolve the http uri.
class SrsHttpUri
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string url_;
std::string schema_;
std::string host_;
@ -702,11 +724,13 @@ public:
virtual std::string username();
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
virtual srs_error_t parse_url_simple(const std::string &url, std::string &schema, std::string &host, int &port,
std::string &path, std::string &query, std::string &fragment,
std::string &username, std::string &password);
virtual srs_error_t
parse_url_simple(const std::string &url, std::string &schema, std::string &host, int &port,
std::string &path, std::string &query, std::string &fragment,
std::string &username, std::string &password);
srs_error_t parse_query();
public:

View File

@ -44,7 +44,8 @@ public:
char marker_;
// Don't directly create this object,
// please use SrsJsonAny::str() to create a concreated one.
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
SrsJsonAny();
public:
@ -101,11 +102,13 @@ public:
class SrsJsonObject : public SrsJsonAny
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
typedef std::pair<std::string, SrsJsonAny *> SrsJsonObjectPropertyType;
std::vector<SrsJsonObjectPropertyType> properties_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Use SrsJsonAny::object() to create it.
friend class SrsJsonAny;
SrsJsonObject();
@ -137,10 +140,12 @@ public:
class SrsJsonArray : public SrsJsonAny
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::vector<SrsJsonAny *> properties_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Use SrsJsonAny::array() to create it.
friend class SrsJsonAny;
SrsJsonArray();

View File

@ -19,7 +19,8 @@
// which identify the client.
class SrsThreadContext : public ISrsContext
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::map<srs_thread_t, SrsContextId> cache_;
public:
@ -31,7 +32,8 @@ public:
virtual const SrsContextId &get_id();
virtual const SrsContextId &set_id(const SrsContextId &v);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual void clear_cid();
};

View File

@ -17,7 +17,8 @@ class ISrsEncoder;
// See https://developers.google.com/protocol-buffers/docs/encoding#varints
class SrsProtobufVarints
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
static int bits_len64(uint64_t x);
public:

View File

@ -59,7 +59,8 @@ enum SrsStunMessageAttribute {
class SrsStunPacket
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint16_t message_type_;
std::string username_;
std::string local_ufrag_;
@ -97,7 +98,8 @@ public:
srs_error_t decode(const char *buf, const int nb_buf);
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);
std::string encode_username();
std::string encode_mapped_address();

View File

@ -68,15 +68,18 @@ public:
// client.close();
class SrsBasicRtmpClient : public ISrsBasicRtmpClient
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string url_;
srs_utime_t connect_timeout_;
srs_utime_t stream_timeout_;
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
ISrsRequest *req_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsTcpClient *transport_;
SrsRtmpClient *client_;
SrsNetworkKbps *kbps_;
@ -100,7 +103,8 @@ public:
virtual srs_error_t connect();
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 do_connect_app(std::string local_ip, bool debug);

View File

@ -36,14 +36,16 @@ srs_error_t openssl_generate_key(char *public_key, int32_t size);
// The DH wrapper.
class SrsDH
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
DH *pdh;
public:
SrsDH();
virtual ~SrsDH();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual void close();
public:
@ -67,7 +69,8 @@ public:
// 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);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
virtual srs_error_t do_initialize();
};
// The schema type.
@ -91,7 +94,8 @@ enum srs_schema_type {
// @see also: http://blog.csdn.net/win_lin/article/details/13006803
class SrsKeyBlock
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsRand rand_;
public:
@ -119,10 +123,12 @@ public:
// @stream contains c1s1_key_bytes the key start bytes
srs_error_t parse(SrsBuffer *stream);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Calculate 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
@ -133,7 +139,8 @@ SRS_DECLARE_PRIVATE:
// @see also: http://blog.csdn.net/win_lin/article/details/13006803
class SrsDigestBlock
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsRand rand_;
public:
@ -161,10 +168,12 @@ public:
// @stream contains c1s1_digest_bytes the digest start bytes
srs_error_t parse(SrsBuffer *stream);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Calculate 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;
@ -174,7 +183,8 @@ class SrsC1S1;
// while the concrete class to implements in schema0 or schema1.
class SrsC1S1Strategy
{
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
SrsKeyBlock key_;
SrsDigestBlock digest_;
@ -389,7 +399,8 @@ public:
// @see also: http://blog.csdn.net/win_lin/article/details/13006803
class SrsC2S2
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsRand rand_;
public:

View File

@ -37,9 +37,11 @@ public:
// Free specified count of messages.
virtual void free(int count);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Zero initialize the message array.
virtual void zero(int count);
virtual void
zero(int count);
};
#endif

View File

@ -121,9 +121,11 @@ public:
// The message type set the RTMP message type in header.
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.
virtual int get_size();
virtual int
get_size();
// The subpacket can override to encode the payload to stream.
// @remark never invoke the super.encode_packet, it always failed.
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.
class SrsProtocol
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
class AckWindowSize
{
public:
@ -147,7 +150,8 @@ SRS_DECLARE_PRIVATE:
AckWindowSize();
};
// For peer in/out
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The underlayer socket object, send/recv bytes.
ISrsProtocolReadWriter *skt_;
// The requests sent out, used to build the response.
@ -155,9 +159,11 @@ SRS_DECLARE_PRIVATE:
// value: the request command name
std::map<double, std::string> requests_;
// For peer in
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// 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.
// cs_cache, the chunk stream cache.
SrsChunkStream **cs_cache_;
@ -181,7 +187,8 @@ SRS_DECLARE_PRIVATE:
// When not auto response message, manual flush the messages in queue.
std::vector<SrsRtmpCommand *> manual_response_queue_;
// For peer out
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Cache for multiple messages send,
// initialize to iovec[SRS_CONSTS_IOVS_MAX] and realloc when consumed,
// it's ok to realloc the iovs cache, for all ptr is ok.
@ -338,10 +345,12 @@ public:
return err;
}
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// Send out the messages, donot free it,
// 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.
virtual srs_error_t do_iovs_send(iovec *iovs, int size);
// The underlayer api for send and free packet.
@ -367,13 +376,16 @@ SRS_DECLARE_PRIVATE:
// When message sentout, update the context.
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.
virtual srs_error_t response_acknowledgement_message();
virtual srs_error_t
response_acknowledgement_message();
// Auto response the ping message.
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();
};
@ -543,7 +555,8 @@ bool srs_client_type_is_publish(SrsRtmpConnType type);
// For smart switch between complex and simple handshake.
class SrsHandshakeBytes
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsRand rand_;
public:
@ -589,10 +602,12 @@ struct SrsServerInfo {
// implements the client role protocol.
class SrsRtmpClient
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsHandshakeBytes *hs_bytes_;
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
SrsProtocol *protocol_;
ISrsProtocolReadWriter *io_;
@ -702,7 +717,8 @@ public:
// such as connect to vhost/app, play stream, get audio/video data.
class SrsRtmpServer : public ISrsRtmpServer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsHandshakeBytes *hs_bytes_;
SrsProtocol *protocol_;
ISrsProtocolReadWriter *io_;
@ -868,13 +884,15 @@ public:
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_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_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);
};
@ -907,7 +925,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -937,7 +956,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -971,7 +991,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -997,7 +1018,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -1030,7 +1052,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -1058,7 +1081,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -1109,7 +1133,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
// Factory method to create specified FMLE packet.
@ -1145,7 +1170,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -1192,7 +1218,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -1285,7 +1312,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -1320,7 +1348,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -1346,7 +1375,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -1379,7 +1409,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -1407,7 +1438,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -1433,7 +1465,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -1463,7 +1496,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -1486,7 +1520,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -1509,7 +1544,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -1534,7 +1570,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -1565,7 +1602,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};
@ -1676,7 +1714,8 @@ public:
public:
virtual int get_message_type();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual int get_size();
virtual srs_error_t encode_packet(SrsBuffer *stream);
};

View File

@ -24,7 +24,8 @@ class SrsFormat;
// RTP video builder for packaging video NALUs into RTP packets
class SrsRtpVideoBuilder
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
uint16_t video_sequence_;
uint32_t video_ssrc_;
uint8_t video_payload_type_;

View File

@ -264,9 +264,11 @@ public:
// Encode message to string.
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.
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
@ -283,7 +285,8 @@ public:
SrsRtspOptionsResponse(int cseq);
virtual ~SrsRtspOptionsResponse();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual srs_error_t encode_header(std::stringstream &ss);
};
@ -298,7 +301,8 @@ public:
SrsRtspDescribeResponse(int cseq);
virtual ~SrsRtspDescribeResponse();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual srs_error_t encode_header(std::stringstream &ss);
};
@ -330,7 +334,8 @@ public:
SrsRtspSetupResponse(int cseq);
virtual ~SrsRtspSetupResponse();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual srs_error_t encode_header(std::stringstream &ss);
};
@ -341,7 +346,8 @@ public:
SrsRtspPlayResponse(int cseq);
virtual ~SrsRtspPlayResponse();
SRS_DECLARE_PROTECTED:
// clang-format off
SRS_DECLARE_PROTECTED: // clang-format on
virtual srs_error_t encode_header(std::stringstream &ss);
};

View File

@ -154,7 +154,8 @@ public:
bool is_audio() const { return type_ == "audio"; }
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_attr_rtpmap(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_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);
public:
@ -224,10 +226,12 @@ public:
std::string get_ice_pwd() 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_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_error_t parse_origin(const std::string &content);
srs_error_t parse_version(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_attr_group(const std::string &content);
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
bool in_media_session_;
public:

View File

@ -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.
class SrsSrtStat
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
void *stat_;
public:
@ -178,12 +179,14 @@ public:
// Unsubscribed OUT event to srt poller.
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 disable_event(int event);
srs_error_t check_error();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_srt_t srt_fd_;
// Mark if some error occured in srt socket.
bool has_error_;

View File

@ -91,7 +91,8 @@ extern int srs_mutex_unlock(srs_mutex_t mutex);
// cond->signal();
class SrsCond : public ISrsCond
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_cond_t cond_;
public:
@ -111,7 +112,8 @@ public:
// SrsLocker(mutex->get());
class SrsMutex
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_mutex_t mutex_;
public:
@ -153,7 +155,8 @@ extern bool srs_is_never_timeout(srs_utime_t tm);
class impl__SrsLocker
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_mutex_t *lock_;
public:
@ -174,7 +177,8 @@ public:
// that is, the sync socket mechanism.
class SrsStSocket : public ISrsProtocolReadWriter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
// The recv/send timeout in srs_utime_t.
// @remark Use SRS_UTIME_NO_TIMEOUT for never timeout.
srs_utime_t rtm_;
@ -190,7 +194,8 @@ public:
SrsStSocket(srs_netfd_t fd);
virtual ~SrsStSocket();
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
void init(srs_netfd_t fd);
public:
@ -220,11 +225,13 @@ public:
// @remark User can directly free the object, which will close the fd.
class SrsTcpClient : public ISrsProtocolReadWriter
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_netfd_t stfd_;
SrsStSocket *io_;
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::string host_;
int port_;
// The timeout in srs_utime_t.

View File

@ -49,7 +49,8 @@ public:
// TODO: FIXME: add utest for it.
class SrsFastStream
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
#ifdef SRS_PERF_MERGED_READ
// the merged handler
bool merged_read_;

View File

@ -230,7 +230,8 @@ public:
return cp;
}
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
MockSrsContextId *bind_;
};

View File

@ -120,7 +120,8 @@ public:
// @remark The size of memory to allocate, should smaller than page size, generally 4096 bytes.
class MockProtectedBuffer
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
char *raw_memory_;
public:
@ -139,7 +140,8 @@ public:
// The chan never free the args, you must manage the memory.
class SrsCoroutineChan
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
std::vector<void *> args_;
srs_mutex_t lock_;
@ -206,7 +208,7 @@ public:
#define SRS_COROUTINE_GO_IMPL(context, id, code_block) \
class AnonymousCoroutineHandler##id : public ISrsCoroutineHandler \
{ \
SRS_DECLARE_PRIVATE: \
public: \
SrsCoroutineChan *ctx_; \
\
public: \
@ -283,7 +285,8 @@ public:
// but with proper HTTP response formatting
class SrsHttpTestServer : public ISrsCoroutineHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsCoroutine *trd_;
srs_netfd_t fd_;
string response_body_;
@ -304,14 +307,16 @@ public:
public:
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);
};
// Simple HTTPS test server similar to Go's httptest.NewServer but with SSL support
class SrsHttpsTestServer : public ISrsCoroutineHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsCoroutine *trd_;
srs_netfd_t fd_;
string response_body_;
@ -329,10 +334,12 @@ public:
virtual int get_port();
// Interface ISrsCoroutineHandler
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
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);
};
@ -340,7 +347,8 @@ SRS_DECLARE_PRIVATE:
// This server handles basic RTMP handshake and connect app operations
class SrsRtmpTestServer : public ISrsCoroutineHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsCoroutine *trd_;
srs_netfd_t fd_;
string app_;
@ -366,7 +374,8 @@ public:
public:
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 handle_rtmp_client(srs_netfd_t cfd);
};
@ -374,7 +383,8 @@ SRS_DECLARE_PRIVATE:
// Test TCP server for testing SrsTcpConnection
class SrsTestTcpServer : public ISrsCoroutineHandler, public ISrsTcpHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
ISrsCoroutine *trd_;
SrsTcpListener *listener_;
string ip_;
@ -403,7 +413,8 @@ public:
// Test TCP client for testing SrsTcpConnection
class SrsTestTcpClient
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
SrsTcpClient *client_;
SrsTcpConnection *conn_;
string host_;
@ -425,7 +436,8 @@ public:
// Test UDP server for testing UDP socket communication
class SrsUdpTestServer : public ISrsCoroutineHandler
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_netfd_t lfd_;
ISrsCoroutine *trd_;
SrsStSocket *socket_;
@ -450,7 +462,8 @@ public:
// Test UDP client for testing UDP socket communication
class SrsUdpTestClient
{
SRS_DECLARE_PRIVATE:
// clang-format off
SRS_DECLARE_PRIVATE: // clang-format on
srs_netfd_t stfd_;
SrsStSocket *socket_;
string host_;

View File

@ -13,6 +13,7 @@ using namespace std;
#include <srs_app_ffmpeg.hpp>
#include <srs_app_http_conn.hpp>
#include <srs_app_mpegts_udp.hpp>
#include <srs_app_process.hpp>
#include <srs_app_recv_thread.hpp>
#include <srs_kernel_error.hpp>
#include <srs_kernel_packet.hpp>
@ -3248,7 +3249,7 @@ MockAppConfigForEncoder::MockAppConfigForEncoder()
transcode_enabled_ = true;
transcode_ffmpeg_bin_ = "/usr/bin/ffmpeg";
engine_enabled_ = true;
target_scope_ = ""; // Default to vhost scope (empty string)
target_scope_ = ""; // Default to vhost scope (empty string)
}
MockAppConfigForEncoder::~MockAppConfigForEncoder()
@ -3314,7 +3315,7 @@ MockAppFactoryForEncoder::~MockAppFactoryForEncoder()
ISrsFFMPEG *MockAppFactoryForEncoder::create_ffmpeg(std::string ffmpeg_bin)
{
return (ISrsFFMPEG*)mock_ffmpeg_;
return (ISrsFFMPEG *)mock_ffmpeg_;
}
void MockAppFactoryForEncoder::reset()
@ -3381,7 +3382,7 @@ VOID TEST(EncoderTest, ParseScopeEnginesAndClearEngines)
mock_config->transcode_ffmpeg_bin_ = "/usr/bin/ffmpeg";
mock_config->transcode_engines_.push_back(engine_conf);
mock_config->engine_enabled_ = true;
mock_config->target_scope_ = "live/livestream"; // Stream scope
mock_config->target_scope_ = "live/livestream"; // Stream scope
// Create mock factory
SrsUniquePtr<MockAppFactoryForEncoder> mock_factory(new MockAppFactoryForEncoder());
@ -3416,7 +3417,7 @@ VOID TEST(EncoderTest, ParseScopeEnginesAndClearEngines)
// Verify that at() method returns the correct engine
ISrsFFMPEG *ffmpeg_at_0 = encoder->at(0);
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
encoder->clear_engines();
@ -3456,11 +3457,11 @@ VOID TEST(EncoderTest, InitializeFFmpegMajorScenario)
// Create mock engine directive with args for variable substitution
SrsUniquePtr<SrsConfDirective> engine(new SrsConfDirective());
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
// 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
SrsUniquePtr<SrsEncoder> encoder(new SrsEncoder());
@ -3482,3 +3483,51 @@ VOID TEST(EncoderTest, InitializeFFmpegMajorScenario)
// Clean up - set to NULL to avoid double-free
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());
}

View File

@ -727,7 +727,7 @@ public:
std::string transcode_ffmpeg_bin_;
std::vector<SrsConfDirective *> transcode_engines_;
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:
MockAppConfigForEncoder();

Some files were not shown because too many files have changed in this diff Show More