2013-12-08 02:46:33 +00:00
|
|
|
/*
|
|
|
|
The MIT License (MIT)
|
|
|
|
|
2014-12-31 12:32:09 +00:00
|
|
|
Copyright (c) 2013-2015 winlin
|
2013-12-08 02:46:33 +00:00
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
|
this software and associated documentation files (the "Software"), to deal in
|
|
|
|
the Software without restriction, including without limitation the rights to
|
|
|
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
|
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
|
|
subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
|
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2014-09-26 08:34:13 +00:00
|
|
|
#ifndef SRS_APP_CONFIG_HPP
|
|
|
|
#define SRS_APP_CONFIG_HPP
|
2013-12-08 02:46:33 +00:00
|
|
|
|
|
|
|
/*
|
2014-03-02 13:49:09 +00:00
|
|
|
#include <srs_app_config.hpp>
|
2013-12-08 02:46:33 +00:00
|
|
|
*/
|
|
|
|
#include <srs_core.hpp>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
2014-03-02 13:49:09 +00:00
|
|
|
#include <srs_app_reload.hpp>
|
2013-12-08 02:46:33 +00:00
|
|
|
|
2014-07-20 05:04:48 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// default consts values
|
|
|
|
///////////////////////////////////////////////////////////
|
2014-03-21 07:45:34 +00:00
|
|
|
#define SRS_CONF_DEFAULT_PID_FILE "./objs/srs.pid"
|
2014-07-20 05:04:48 +00:00
|
|
|
#define SRS_CONF_DEFAULT_LOG_FILE "./objs/srs.log"
|
|
|
|
#define SRS_CONF_DEFAULT_LOG_LEVEL "trace"
|
|
|
|
#define SRS_CONF_DEFAULT_LOG_TANK_CONSOLE "console"
|
|
|
|
#define SRS_CONF_DEFAULT_COFNIG_FILE "conf/srs.conf"
|
|
|
|
#define SRS_CONF_DEFAULT_FF_LOG_DIR "./objs"
|
2013-12-08 02:46:33 +00:00
|
|
|
|
2014-07-26 07:54:40 +00:00
|
|
|
#define SRS_CONF_DEFAULT_MAX_CONNECTIONS 1000
|
2013-12-08 02:46:33 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HLS_PATH "./objs/nginx/html"
|
|
|
|
#define SRS_CONF_DEFAULT_HLS_FRAGMENT 10
|
2015-02-12 05:34:59 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HLS_TD_RATIO 1.5
|
2013-12-08 02:46:33 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HLS_WINDOW 60
|
2014-12-20 03:45:59 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE "ignore"
|
|
|
|
#define SRS_CONF_DEFAULT_HLS_ON_ERROR_DISCONNECT "disconnect"
|
2014-12-22 09:10:51 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HLS_ON_ERROR_CONTINUE "continue"
|
2014-12-20 03:45:59 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HLS_ON_ERROR SRS_CONF_DEFAULT_HLS_ON_ERROR_IGNORE
|
2015-02-03 08:01:07 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HLS_STORAGE "disk"
|
|
|
|
#define SRS_CONF_DEFAULT_HLS_MOUNT "[vhost]/[app]/[stream].m3u8"
|
2015-02-15 09:43:35 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HLS_ACODEC "aac"
|
2015-02-15 10:11:24 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HLS_VCODEC "h264"
|
2014-04-17 08:06:49 +00:00
|
|
|
#define SRS_CONF_DEFAULT_DVR_PATH "./objs/nginx/html"
|
2014-04-17 09:35:21 +00:00
|
|
|
#define SRS_CONF_DEFAULT_DVR_PLAN_SESSION "session"
|
|
|
|
#define SRS_CONF_DEFAULT_DVR_PLAN_SEGMENT "segment"
|
2015-02-21 08:52:37 +00:00
|
|
|
#define SRS_CONF_DEFAULT_DVR_PLAN_APPEND "append"
|
2014-04-17 09:35:21 +00:00
|
|
|
#define SRS_CONF_DEFAULT_DVR_PLAN SRS_CONF_DEFAULT_DVR_PLAN_SESSION
|
|
|
|
#define SRS_CONF_DEFAULT_DVR_DURATION 30
|
2014-06-25 09:14:11 +00:00
|
|
|
#define SRS_CONF_DEFAULT_TIME_JITTER "full"
|
2013-12-15 10:25:55 +00:00
|
|
|
// in seconds, the paused queue length.
|
|
|
|
#define SRS_CONF_DEFAULT_PAUSED_LENGTH 10
|
2013-12-22 09:28:29 +00:00
|
|
|
// the interval in seconds for bandwidth check
|
|
|
|
#define SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL 30
|
|
|
|
// the interval in seconds for bandwidth check
|
|
|
|
#define SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS 1000
|
2013-12-08 02:46:33 +00:00
|
|
|
|
2015-01-18 10:00:40 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HTTP_MOUNT "[vhost]/"
|
2015-01-22 01:34:33 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HTTP_REMUX_MOUNT "[vhost]/[app]/[stream].flv"
|
2014-04-04 10:55:21 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HTTP_DIR SRS_CONF_DEFAULT_HLS_PATH
|
2015-01-22 05:16:54 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HTTP_AUDIO_FAST_CACHE 0
|
2014-04-04 10:55:21 +00:00
|
|
|
|
2014-04-04 15:04:38 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HTTP_STREAM_PORT 8080
|
|
|
|
#define SRS_CONF_DEFAULT_HTTP_API_PORT 1985
|
2015-02-21 13:17:59 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HTTP_API_CROSSDOMAIN true
|
2014-04-04 15:04:38 +00:00
|
|
|
|
2014-05-19 09:39:01 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_ENABLED false
|
|
|
|
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_INTERVAL 9.9
|
2014-07-20 05:04:48 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_URL "http://"SRS_CONSTS_LOCALHOST":8085/api/v1/servers"
|
2014-06-23 07:44:49 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_SUMMARIES false
|
2014-05-19 09:39:01 +00:00
|
|
|
|
2015-01-02 08:02:13 +00:00
|
|
|
#define SRS_CONF_DEFAULT_SECURITY_ENABLED false
|
|
|
|
|
2015-01-24 06:52:52 +00:00
|
|
|
#define SRS_CONF_DEFAULT_STREAM_CASTER_ENABLED false
|
|
|
|
#define SRS_CONF_DEFAULT_STREAM_CASTER_MPEGTS_OVER_UDP "mpegts_over_udp"
|
2015-02-15 13:28:31 +00:00
|
|
|
#define SRS_CONF_DEFAULT_STREAM_CASTER_RTSP "rtsp"
|
2015-01-24 06:52:52 +00:00
|
|
|
|
2014-07-27 06:43:55 +00:00
|
|
|
#define SRS_CONF_DEFAULT_STATS_NETWORK_DEVICE_INDEX 0
|
|
|
|
|
2015-02-19 10:56:21 +00:00
|
|
|
#define SRS_CONF_DEFAULT_PITHY_PRINT_MS 10000
|
2014-07-20 05:16:24 +00:00
|
|
|
|
|
|
|
#define SRS_CONF_DEFAULT_INGEST_TYPE_FILE "file"
|
|
|
|
#define SRS_CONF_DEFAULT_INGEST_TYPE_STREAM "stream"
|
2014-04-07 06:20:03 +00:00
|
|
|
|
2014-07-20 05:04:48 +00:00
|
|
|
#define SRS_CONF_DEFAULT_TRANSCODE_IFORMAT "flv"
|
|
|
|
#define SRS_CONF_DEFAULT_TRANSCODE_OFORMAT "flv"
|
|
|
|
|
2014-07-16 03:49:34 +00:00
|
|
|
namespace _srs_internal
|
|
|
|
{
|
2014-07-17 03:05:09 +00:00
|
|
|
class SrsConfigBuffer;
|
2014-07-16 03:49:34 +00:00
|
|
|
};
|
2013-12-08 02:46:33 +00:00
|
|
|
|
2014-07-17 03:05:09 +00:00
|
|
|
/**
|
|
|
|
* the config directive.
|
|
|
|
* the config file is a group of directives,
|
|
|
|
* all directive has name, args and child-directives.
|
|
|
|
* for example, the following config text:
|
|
|
|
vhost vhost.ossrs.net {
|
|
|
|
enabled on;
|
|
|
|
ingest livestream {
|
|
|
|
enabled on;
|
|
|
|
ffmpeg /bin/ffmpeg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
* will be parsed to:
|
|
|
|
* SrsConfDirective: name="vhost", arg0="vhost.ossrs.net", child-directives=[
|
|
|
|
* SrsConfDirective: name="enabled", arg0="on", child-directives=[]
|
|
|
|
* SrsConfDirective: name="ingest", arg0="livestream", child-directives=[
|
|
|
|
* SrsConfDirective: name="enabled", arg0="on", child-directives=[]
|
|
|
|
* SrsConfDirective: name="ffmpeg", arg0="/bin/ffmpeg", child-directives=[]
|
|
|
|
* ]
|
|
|
|
* ]
|
2014-07-20 07:53:19 +00:00
|
|
|
* @remark, allow empty directive, for example: "dir0 {}"
|
|
|
|
* @remark, don't allow empty name, for example: ";" or "{dir0 arg0;}
|
2014-07-17 03:05:09 +00:00
|
|
|
*/
|
2013-12-08 02:46:33 +00:00
|
|
|
class SrsConfDirective
|
|
|
|
{
|
|
|
|
public:
|
2014-07-17 03:05:09 +00:00
|
|
|
/**
|
|
|
|
* the line of config file in which the directive from
|
|
|
|
*/
|
2014-03-18 03:32:58 +00:00
|
|
|
int conf_line;
|
2014-07-17 03:05:09 +00:00
|
|
|
/**
|
|
|
|
* the name of directive, for example, the following config text:
|
|
|
|
* enabled on;
|
|
|
|
* will be parsed to a directive, its name is "enalbed"
|
|
|
|
*/
|
2014-03-18 03:32:58 +00:00
|
|
|
std::string name;
|
2014-07-17 03:05:09 +00:00
|
|
|
/**
|
|
|
|
* the args of directive, for example, the following config text:
|
|
|
|
* listen 1935 1936;
|
|
|
|
* will be parsed to a directive, its args is ["1935", "1936"].
|
|
|
|
*/
|
2014-03-18 03:32:58 +00:00
|
|
|
std::vector<std::string> args;
|
2014-07-17 03:05:09 +00:00
|
|
|
/**
|
|
|
|
* the child directives, for example, the following config text:
|
|
|
|
* vhost vhost.ossrs.net {
|
|
|
|
* enabled on;
|
|
|
|
* }
|
|
|
|
* will be parsed to a directive, its directives is a vector contains
|
|
|
|
* a directive, which is:
|
|
|
|
* name:"enalbed", args:["on"], directives:[]
|
|
|
|
*
|
|
|
|
* @remark, the directives can contains directives.
|
|
|
|
*/
|
2014-03-18 03:32:58 +00:00
|
|
|
std::vector<SrsConfDirective*> directives;
|
2013-12-08 02:46:33 +00:00
|
|
|
public:
|
2014-03-18 03:32:58 +00:00
|
|
|
SrsConfDirective();
|
|
|
|
virtual ~SrsConfDirective();
|
2014-07-17 03:05:09 +00:00
|
|
|
// args
|
2014-07-16 03:49:34 +00:00
|
|
|
public:
|
2014-07-17 03:05:09 +00:00
|
|
|
/**
|
|
|
|
* get the args0,1,2, if user want to get more args,
|
|
|
|
* directly use the args.at(index).
|
|
|
|
*/
|
2014-07-16 03:49:34 +00:00
|
|
|
virtual std::string arg0();
|
2014-07-17 03:05:09 +00:00
|
|
|
virtual std::string arg1();
|
2014-07-16 03:49:34 +00:00
|
|
|
virtual std::string arg2();
|
2014-07-17 03:05:09 +00:00
|
|
|
// directives
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* get the directive by index.
|
|
|
|
* @remark, assert the index<directives.size().
|
|
|
|
*/
|
2014-07-16 03:49:34 +00:00
|
|
|
virtual SrsConfDirective* at(int index);
|
2014-07-17 03:05:09 +00:00
|
|
|
/**
|
|
|
|
* get the directive by name, return the first match.
|
|
|
|
*/
|
2014-07-16 03:49:34 +00:00
|
|
|
virtual SrsConfDirective* get(std::string _name);
|
2014-07-17 03:05:09 +00:00
|
|
|
/**
|
|
|
|
* get the directive by name and its arg0, return the first match.
|
|
|
|
*/
|
2014-07-16 03:49:34 +00:00
|
|
|
virtual SrsConfDirective* get(std::string _name, std::string _arg0);
|
2014-07-17 03:05:09 +00:00
|
|
|
// help utilities
|
2013-12-08 02:46:33 +00:00
|
|
|
public:
|
2014-07-17 03:05:09 +00:00
|
|
|
/**
|
|
|
|
* whether current directive is vhost.
|
|
|
|
*/
|
2014-04-04 10:55:21 +00:00
|
|
|
virtual bool is_vhost();
|
2015-01-24 06:52:52 +00:00
|
|
|
/**
|
|
|
|
* whether current directive is stream_caster.
|
|
|
|
*/
|
|
|
|
virtual bool is_stream_caster();
|
2014-07-17 03:05:09 +00:00
|
|
|
// parse utilities
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* parse config directive from file buffer.
|
|
|
|
*/
|
|
|
|
virtual int parse(_srs_internal::SrsConfigBuffer* buffer);
|
|
|
|
// private parse.
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* the directive parsing type.
|
|
|
|
*/
|
|
|
|
enum SrsDirectiveType {
|
|
|
|
/**
|
|
|
|
* the root directives, parsing file.
|
|
|
|
*/
|
|
|
|
parse_file,
|
|
|
|
/**
|
|
|
|
* for each direcitve, parsing text block.
|
|
|
|
*/
|
|
|
|
parse_block
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* parse the conf from buffer. the work flow:
|
|
|
|
* 1. read a token(directive args and a ret flag),
|
|
|
|
* 2. initialize the directive by args, args[0] is name, args[1-N] is args of directive,
|
|
|
|
* 3. if ret flag indicates there are child-directives, read_conf(directive, block) recursively.
|
|
|
|
*/
|
|
|
|
virtual int parse_conf(_srs_internal::SrsConfigBuffer* buffer, SrsDirectiveType type);
|
|
|
|
/**
|
|
|
|
* read a token from buffer.
|
|
|
|
* a token, is the directive args and a flag indicates whether has child-directives.
|
|
|
|
* @param args, the output directive args, the first is the directive name, left is the args.
|
2014-07-20 08:16:29 +00:00
|
|
|
* @param line_start, the actual start line of directive.
|
2014-07-17 03:05:09 +00:00
|
|
|
* @return, an error code indicates error or has child-directives.
|
|
|
|
*/
|
2014-07-20 08:16:29 +00:00
|
|
|
virtual int read_token(_srs_internal::SrsConfigBuffer* buffer, std::vector<std::string>& args, int& line_start);
|
2013-12-08 02:46:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2014-07-17 03:34:49 +00:00
|
|
|
* the config service provider.
|
2013-12-08 02:46:33 +00:00
|
|
|
* for the config supports reload, so never keep the reference cross st-thread,
|
|
|
|
* that is, never save the SrsConfDirective* get by any api of config,
|
|
|
|
* for it maybe free in the reload st-thread cycle.
|
|
|
|
* you can keep it before st-thread switch, or simply never keep it.
|
|
|
|
*/
|
|
|
|
class SrsConfig
|
|
|
|
{
|
2014-07-17 03:53:51 +00:00
|
|
|
// user command
|
2013-12-08 02:46:33 +00:00
|
|
|
private:
|
2014-07-17 03:53:51 +00:00
|
|
|
/**
|
|
|
|
* whether show help and exit.
|
|
|
|
*/
|
2014-03-18 03:32:58 +00:00
|
|
|
bool show_help;
|
2014-07-17 03:53:51 +00:00
|
|
|
/**
|
|
|
|
* whether test config file and exit.
|
|
|
|
*/
|
2014-04-13 08:55:42 +00:00
|
|
|
bool test_conf;
|
2014-07-17 03:53:51 +00:00
|
|
|
/**
|
|
|
|
* whether show SRS version and exit.
|
|
|
|
*/
|
2014-03-18 03:32:58 +00:00
|
|
|
bool show_version;
|
2014-07-17 03:53:51 +00:00
|
|
|
// global env variables.
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* the user parameters, the argc and argv.
|
|
|
|
* the argv is " ".join(argv), where argv is from main(argc, argv).
|
|
|
|
*/
|
2014-04-19 13:23:34 +00:00
|
|
|
std::string _argv;
|
2014-07-17 03:53:51 +00:00
|
|
|
/**
|
|
|
|
* current working directory.
|
|
|
|
*/
|
2014-04-19 13:23:34 +00:00
|
|
|
std::string _cwd;
|
2014-07-17 03:53:51 +00:00
|
|
|
// config section
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* the last parsed config file.
|
|
|
|
* if reload, reload the config file.
|
|
|
|
*/
|
|
|
|
std::string config_file;
|
|
|
|
/**
|
|
|
|
* the directive root.
|
|
|
|
*/
|
2014-03-18 03:32:58 +00:00
|
|
|
SrsConfDirective* root;
|
2014-07-17 03:53:51 +00:00
|
|
|
// reload section
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* the reload subscribers, when reload, callback all handlers.
|
|
|
|
*/
|
2014-03-18 03:32:58 +00:00
|
|
|
std::vector<ISrsReloadHandler*> subscribes;
|
2013-12-08 02:46:33 +00:00
|
|
|
public:
|
2014-03-18 03:32:58 +00:00
|
|
|
SrsConfig();
|
|
|
|
virtual ~SrsConfig();
|
2014-04-10 06:06:23 +00:00
|
|
|
// reload
|
2013-12-08 02:46:33 +00:00
|
|
|
public:
|
2014-07-17 03:53:51 +00:00
|
|
|
/**
|
|
|
|
* for reload handler to register itself,
|
|
|
|
* when config service do the reload, callback the handler.
|
|
|
|
*/
|
2014-03-18 03:32:58 +00:00
|
|
|
virtual void subscribe(ISrsReloadHandler* handler);
|
2014-07-17 03:53:51 +00:00
|
|
|
/**
|
|
|
|
* for reload handler to unregister itself.
|
|
|
|
*/
|
2014-03-18 03:32:58 +00:00
|
|
|
virtual void unsubscribe(ISrsReloadHandler* handler);
|
2014-07-17 03:53:51 +00:00
|
|
|
/**
|
|
|
|
* reload the config file.
|
|
|
|
* @remark, user can test the config before reload it.
|
|
|
|
*/
|
2014-04-10 06:05:01 +00:00
|
|
|
virtual int reload();
|
2014-08-16 11:59:14 +00:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* reload from the config.
|
|
|
|
* @remark, use protected for the utest to override with mock.
|
|
|
|
*/
|
|
|
|
virtual int reload_conf(SrsConfig* conf);
|
2014-04-10 06:05:01 +00:00
|
|
|
private:
|
2014-07-17 03:53:51 +00:00
|
|
|
/**
|
|
|
|
* reload the http_api section of config.
|
|
|
|
*/
|
2014-04-13 05:08:10 +00:00
|
|
|
virtual int reload_http_api(SrsConfDirective* old_root);
|
2014-07-17 03:53:51 +00:00
|
|
|
/**
|
|
|
|
* reload the http_stream section of config.
|
|
|
|
*/
|
2014-04-13 05:27:51 +00:00
|
|
|
virtual int reload_http_stream(SrsConfDirective* old_root);
|
2014-07-17 03:53:51 +00:00
|
|
|
/**
|
|
|
|
* reload the vhost section of config.
|
|
|
|
*/
|
2014-04-13 05:08:10 +00:00
|
|
|
virtual int reload_vhost(SrsConfDirective* old_root);
|
2014-07-17 03:53:51 +00:00
|
|
|
/**
|
|
|
|
* reload the transcode section of vhost of config.
|
|
|
|
*/
|
2014-04-10 06:05:01 +00:00
|
|
|
virtual int reload_transcode(SrsConfDirective* new_vhost, SrsConfDirective* old_vhost);
|
2014-07-17 03:53:51 +00:00
|
|
|
/**
|
|
|
|
* reload the ingest section of vhost of config.
|
|
|
|
*/
|
2014-04-10 06:05:01 +00:00
|
|
|
virtual int reload_ingest(SrsConfDirective* new_vhost, SrsConfDirective* old_vhost);
|
2014-04-10 06:06:23 +00:00
|
|
|
// parse options and file
|
2013-12-08 02:46:33 +00:00
|
|
|
public:
|
2014-07-17 03:53:51 +00:00
|
|
|
/**
|
|
|
|
* parse the cli, the main(argc,argv) function.
|
|
|
|
*/
|
2014-03-18 03:32:58 +00:00
|
|
|
virtual int parse_options(int argc, char** argv);
|
2014-08-29 07:07:04 +00:00
|
|
|
/**
|
|
|
|
* get the config file path.
|
|
|
|
*/
|
|
|
|
virtual std::string config();
|
2013-12-08 02:46:33 +00:00
|
|
|
private:
|
2014-07-17 03:53:51 +00:00
|
|
|
/**
|
|
|
|
* parse each argv.
|
|
|
|
*/
|
2014-03-18 03:32:58 +00:00
|
|
|
virtual int parse_argv(int& i, char** argv);
|
2014-07-17 03:53:51 +00:00
|
|
|
/**
|
|
|
|
* print help and exit.
|
|
|
|
*/
|
2014-03-18 03:32:58 +00:00
|
|
|
virtual void print_help(char** argv);
|
2014-07-17 03:53:51 +00:00
|
|
|
/**
|
|
|
|
* parse the config file, which is specified by cli.
|
|
|
|
*/
|
2014-07-17 03:28:20 +00:00
|
|
|
virtual int parse_file(const char* filename);
|
2014-09-26 09:47:43 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* check the parsed config.
|
|
|
|
*/
|
|
|
|
virtual int check_config();
|
2014-07-17 03:34:49 +00:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* parse config from the buffer.
|
|
|
|
* @param buffer, the config buffer, user must delete it.
|
2014-08-16 11:59:14 +00:00
|
|
|
* @remark, use protected for the utest to override with mock.
|
2014-07-17 03:34:49 +00:00
|
|
|
*/
|
|
|
|
virtual int parse_buffer(_srs_internal::SrsConfigBuffer* buffer);
|
2014-07-17 03:53:51 +00:00
|
|
|
// global env
|
2014-04-19 13:23:34 +00:00
|
|
|
public:
|
2014-07-17 03:53:51 +00:00
|
|
|
/**
|
|
|
|
* get the current work directory.
|
|
|
|
*/
|
2014-05-08 07:45:51 +00:00
|
|
|
virtual std::string cwd();
|
2014-07-17 03:53:51 +00:00
|
|
|
/**
|
|
|
|
* get the cli, the main(argc,argv), program start command.
|
|
|
|
*/
|
2014-05-08 07:45:51 +00:00
|
|
|
virtual std::string argv();
|
2014-04-04 09:01:34 +00:00
|
|
|
// global section
|
|
|
|
public:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
|
|
|
* get the directive root, corresponding to the config file.
|
|
|
|
* the root directive, no name and args, contains directives.
|
|
|
|
* all directive parsed can retrieve from root.
|
|
|
|
*/
|
2014-04-04 10:55:21 +00:00
|
|
|
virtual SrsConfDirective* get_root();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:21:34 +00:00
|
|
|
* get the deamon config.
|
|
|
|
* if true, SRS will run in deamon mode, fork and fork to reap the
|
|
|
|
* grand-child process to init process.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-04 09:01:34 +00:00
|
|
|
virtual bool get_deamon();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:21:34 +00:00
|
|
|
* get the max connections limit of system.
|
|
|
|
* if exceed the max connection, SRS will disconnect the connection.
|
|
|
|
* @remark, linux will limit the connections of each process,
|
|
|
|
* for example, when you need SRS to service 10000+ connections,
|
|
|
|
* user must use "ulimit -HSn 10000" and config the max connections
|
|
|
|
* of SRS.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-04 09:01:34 +00:00
|
|
|
virtual int get_max_connections();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:21:34 +00:00
|
|
|
* get the listen port of SRS.
|
|
|
|
* user can specifies multiple listen ports,
|
|
|
|
* each args of directive is a listen port.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:21:34 +00:00
|
|
|
virtual std::vector<std::string> get_listen();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:35:31 +00:00
|
|
|
* get the pid file path.
|
|
|
|
* the pid file is used to save the pid of SRS,
|
|
|
|
* use file lock to prevent multiple SRS starting.
|
|
|
|
* @remark, if user need to run multiple SRS instance,
|
|
|
|
* for example, to start multiple SRS for multiple CPUs,
|
|
|
|
* user can use different pid file for each process.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-04 09:01:34 +00:00
|
|
|
virtual std::string get_pid_file();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2015-02-19 10:56:21 +00:00
|
|
|
* get pithy print pulse ms,
|
|
|
|
* for example, all rtmp connections only print one message
|
|
|
|
* every this interval in ms.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2015-02-19 10:56:21 +00:00
|
|
|
virtual int get_pithy_print_ms();
|
2015-01-24 06:52:52 +00:00
|
|
|
// stream_caster section
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* get all stream_caster in config file.
|
|
|
|
*/
|
|
|
|
virtual std::vector<SrsConfDirective*> get_stream_casters();
|
|
|
|
/**
|
|
|
|
* get whether the specified stream_caster is enabled.
|
|
|
|
*/
|
|
|
|
virtual bool get_stream_caster_enabled(SrsConfDirective* sc);
|
|
|
|
/**
|
|
|
|
* get the engine of stream_caster, the caster config.
|
|
|
|
*/
|
|
|
|
virtual std::string get_stream_caster_engine(SrsConfDirective* sc);
|
|
|
|
/**
|
|
|
|
* get the output rtmp url of stream_caster, the output config.
|
|
|
|
*/
|
|
|
|
virtual std::string get_stream_caster_output(SrsConfDirective* sc);
|
|
|
|
/**
|
|
|
|
* get the listen port of stream caster.
|
|
|
|
*/
|
|
|
|
virtual int get_stream_caster_listen(SrsConfDirective* sc);
|
2015-02-17 08:28:28 +00:00
|
|
|
/**
|
|
|
|
* get the min udp port for rtp of stream caster rtsp.
|
|
|
|
*/
|
|
|
|
virtual int get_stream_caster_rtp_port_min(SrsConfDirective* sc);
|
|
|
|
/**
|
|
|
|
* get the max udp port for rtp of stream caster rtsp.
|
|
|
|
*/
|
|
|
|
virtual int get_stream_caster_rtp_port_max(SrsConfDirective* sc);
|
2014-04-25 07:27:50 +00:00
|
|
|
// vhost specified section
|
2013-12-14 13:19:47 +00:00
|
|
|
public:
|
2014-07-18 02:35:31 +00:00
|
|
|
/**
|
|
|
|
* get the vhost directive by vhost name.
|
|
|
|
* @param vhost, the name of vhost to get.
|
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual SrsConfDirective* get_vhost(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:35:31 +00:00
|
|
|
* get all vhosts in config file.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:35:31 +00:00
|
|
|
virtual std::vector<SrsConfDirective*> get_vhosts();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:50:02 +00:00
|
|
|
* whether vhost is enabled
|
|
|
|
* @param vhost, the vhost name.
|
|
|
|
* @return true when vhost is ok; otherwise, false.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual bool get_vhost_enabled(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:50:02 +00:00
|
|
|
* whether vhost is enabled
|
|
|
|
* @param vhost, the vhost directive.
|
|
|
|
* @return true when vhost is ok; otherwise, false.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual bool get_vhost_enabled(SrsConfDirective* vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:50:02 +00:00
|
|
|
* whether gop_cache is enabled of vhost.
|
|
|
|
* gop_cache used to cache last gop, for client to fast startup.
|
|
|
|
* @return true when gop_cache is ok; otherwise, false.
|
2014-07-21 04:13:01 +00:00
|
|
|
* @remark, default true.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:50:02 +00:00
|
|
|
virtual bool get_gop_cache(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-08-19 02:59:59 +00:00
|
|
|
* whether debug_srs_upnode is enabled of vhost.
|
|
|
|
* debug_srs_upnode is very important feature for tracable log,
|
|
|
|
* but some server, for instance, flussonic donot support it.
|
|
|
|
* @see https://github.com/winlinvip/simple-rtmp-server/issues/160
|
|
|
|
* @return true when debug_srs_upnode is ok; otherwise, false.
|
|
|
|
* @remark, default true.
|
|
|
|
*/
|
|
|
|
virtual bool get_debug_srs_upnode(std::string vhost);
|
|
|
|
/**
|
2014-07-18 02:50:02 +00:00
|
|
|
* whether atc is enabled of vhost.
|
|
|
|
* atc always use encoder timestamp, SRS never adjust the time.
|
|
|
|
* @return true when atc is ok; otherwise, false.
|
2014-07-21 04:13:01 +00:00
|
|
|
* @remark, default false.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:50:02 +00:00
|
|
|
virtual bool get_atc(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:50:02 +00:00
|
|
|
* whether atc_auto is enabled of vhost.
|
|
|
|
* atc_auto used to auto enable atc, when metadata specified the bravo_atc.
|
|
|
|
* @return true when atc_auto is ok; otherwise, false.
|
2014-07-21 04:13:01 +00:00
|
|
|
* @remark, default true.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:50:02 +00:00
|
|
|
virtual bool get_atc_auto(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:50:02 +00:00
|
|
|
* get the time_jitter algorithm.
|
|
|
|
* @return the time_jitter algorithm, defined in SrsRtmpJitterAlgorithm.
|
2014-07-21 04:13:01 +00:00
|
|
|
* @remark, default full.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:50:02 +00:00
|
|
|
virtual int get_time_jitter(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:56:06 +00:00
|
|
|
* get the cache queue length, in seconds.
|
|
|
|
* when exceed the queue length, drop packet util I frame.
|
2014-07-21 04:13:01 +00:00
|
|
|
* @remark, default 10.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:50:02 +00:00
|
|
|
virtual double get_queue_length(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:56:06 +00:00
|
|
|
* get the refer antisuck directive.
|
|
|
|
* each args of directive is a refer config.
|
|
|
|
* when the client refer(pageUrl) not match the refer config,
|
|
|
|
* SRS will reject the connection.
|
2014-07-21 04:13:01 +00:00
|
|
|
* @remark, default NULL.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:50:02 +00:00
|
|
|
virtual SrsConfDirective* get_refer(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:56:06 +00:00
|
|
|
* get the play refer, refer for play clients.
|
2014-07-21 04:13:01 +00:00
|
|
|
* @remark, default NULL.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:50:02 +00:00
|
|
|
virtual SrsConfDirective* get_refer_play(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:56:06 +00:00
|
|
|
* get the publish refer, refer for publish clients.
|
2014-07-21 04:13:01 +00:00
|
|
|
* @remark, default NULL.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:50:02 +00:00
|
|
|
virtual SrsConfDirective* get_refer_publish(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:56:06 +00:00
|
|
|
* get the chunk size of vhost.
|
2014-07-21 02:50:08 +00:00
|
|
|
* @param vhost, the vhost to get the chunk size. use global if not specified.
|
|
|
|
* empty string to get the global.
|
2014-07-21 04:13:01 +00:00
|
|
|
* @remark, default 60000.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:56:06 +00:00
|
|
|
virtual int get_chunk_size(std::string vhost);
|
2014-12-04 10:21:04 +00:00
|
|
|
/**
|
|
|
|
* whether mr is enabled for vhost.
|
|
|
|
* @param vhost, the vhost to get the mr.
|
|
|
|
*/
|
|
|
|
virtual bool get_mr_enabled(std::string vhost);
|
|
|
|
/**
|
|
|
|
* get the mr sleep time in ms for vhost.
|
|
|
|
* @param vhost, the vhost to get the mr sleep time.
|
|
|
|
*/
|
2014-12-04 10:35:50 +00:00
|
|
|
// TODO: FIXME: add utest for mr config.
|
2014-12-04 10:21:04 +00:00
|
|
|
virtual int get_mr_sleep_ms(std::string vhost);
|
2014-12-04 13:35:13 +00:00
|
|
|
/**
|
|
|
|
* get the mw sleep time in ms for vhost.
|
|
|
|
* @param vhost, the vhost to get the mw sleep time.
|
|
|
|
*/
|
|
|
|
// TODO: FIXME: add utest for mw config.
|
|
|
|
virtual int get_mw_sleep_ms(std::string vhost);
|
2014-12-12 13:51:06 +00:00
|
|
|
/**
|
|
|
|
* whether min latency mode enabled.
|
|
|
|
* @param vhost, the vhost to get the min_latency.
|
|
|
|
*/
|
|
|
|
// TODO: FIXME: add utest for min_latency.
|
|
|
|
virtual bool get_realtime_enabled(std::string vhost);
|
2014-07-21 02:50:08 +00:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* get the global chunk size.
|
|
|
|
*/
|
|
|
|
virtual int get_global_chunk_size();
|
2014-07-18 02:50:02 +00:00
|
|
|
// forward section
|
|
|
|
public:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-21 02:50:08 +00:00
|
|
|
* get the forward directive of vhost.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:50:02 +00:00
|
|
|
virtual SrsConfDirective* get_forward(std::string vhost);
|
|
|
|
// http_hooks section
|
2014-07-22 03:01:20 +00:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* get the http_hooks directive of vhost.
|
|
|
|
*/
|
|
|
|
virtual SrsConfDirective* get_vhost_http_hooks(std::string vhost);
|
2014-07-18 02:50:02 +00:00
|
|
|
public:
|
2014-07-22 03:01:20 +00:00
|
|
|
/**
|
|
|
|
* whether vhost http-hooks enabled.
|
|
|
|
* @remark, if not enabled, donot callback all http hooks.
|
|
|
|
*/
|
|
|
|
virtual bool get_vhost_http_hooks_enabled(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:50:02 +00:00
|
|
|
* get the on_connect callbacks of vhost.
|
|
|
|
* @return the on_connect callback directive, the args is the url to callback.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:50:02 +00:00
|
|
|
virtual SrsConfDirective* get_vhost_on_connect(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:50:02 +00:00
|
|
|
* get the on_close callbacks of vhost.
|
|
|
|
* @return the on_close callback directive, the args is the url to callback.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:50:02 +00:00
|
|
|
virtual SrsConfDirective* get_vhost_on_close(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:50:02 +00:00
|
|
|
* get the on_publish callbacks of vhost.
|
|
|
|
* @return the on_publish callback directive, the args is the url to callback.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:50:02 +00:00
|
|
|
virtual SrsConfDirective* get_vhost_on_publish(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:50:02 +00:00
|
|
|
* get the on_unpublish callbacks of vhost.
|
|
|
|
* @return the on_unpublish callback directive, the args is the url to callback.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:50:02 +00:00
|
|
|
virtual SrsConfDirective* get_vhost_on_unpublish(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:50:02 +00:00
|
|
|
* get the on_play callbacks of vhost.
|
|
|
|
* @return the on_play callback directive, the args is the url to callback.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:50:02 +00:00
|
|
|
virtual SrsConfDirective* get_vhost_on_play(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:50:02 +00:00
|
|
|
* get the on_stop callbacks of vhost.
|
|
|
|
* @return the on_stop callback directive, the args is the url to callback.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:50:02 +00:00
|
|
|
virtual SrsConfDirective* get_vhost_on_stop(std::string vhost);
|
2015-01-03 07:33:23 +00:00
|
|
|
/**
|
|
|
|
* get the on_dvr callbacks of vhost.
|
|
|
|
* @return the on_dvr callback directive, the args is the url to callback.
|
|
|
|
*/
|
|
|
|
virtual SrsConfDirective* get_vhost_on_dvr(std::string vhost);
|
2014-04-04 09:01:34 +00:00
|
|
|
// bwct(bandwidth check tool) section
|
|
|
|
public:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:15:59 +00:00
|
|
|
* whether bw check enabled for vhost.
|
|
|
|
* if enabled, serve all clients with bandwidth check services.
|
|
|
|
* oterwise, serve all cleints with stream.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:56:06 +00:00
|
|
|
virtual bool get_bw_check_enabled(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:15:59 +00:00
|
|
|
* the key of server, if client key mot match, reject.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:56:06 +00:00
|
|
|
virtual std::string get_bw_check_key(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:15:59 +00:00
|
|
|
* the check interval, in ms.
|
|
|
|
* if the client request check in very short time(in the interval),
|
|
|
|
* SRS will reject client.
|
|
|
|
* @remark this is used to prevent the bandwidth check attack.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:56:06 +00:00
|
|
|
virtual int get_bw_check_interval_ms(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:15:59 +00:00
|
|
|
* the max kbps that user can test,
|
|
|
|
* if exceed the kbps, server will slowdown the send-recv.
|
|
|
|
* @remark this is used to protect the service bandwidth.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:56:06 +00:00
|
|
|
virtual int get_bw_check_limit_kbps(std::string vhost);
|
2014-04-25 07:27:50 +00:00
|
|
|
// vhost edge section
|
|
|
|
public:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:15:59 +00:00
|
|
|
* whether vhost is edge mode.
|
|
|
|
* for edge, publish client will be proxyed to upnode,
|
|
|
|
* for edge, play client will share a connection to get stream from upnode.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-25 07:27:50 +00:00
|
|
|
virtual bool get_vhost_is_edge(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:15:59 +00:00
|
|
|
* whether vhost is edge mode.
|
|
|
|
* for edge, publish client will be proxyed to upnode,
|
|
|
|
* for edge, play client will share a connection to get stream from upnode.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-28 09:57:59 +00:00
|
|
|
virtual bool get_vhost_is_edge(SrsConfDirective* vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:15:59 +00:00
|
|
|
* get the origin config of edge,
|
|
|
|
* specifies the origin ip address, port.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-26 13:41:18 +00:00
|
|
|
virtual SrsConfDirective* get_vhost_edge_origin(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:15:59 +00:00
|
|
|
* whether edge token tranverse is enabled,
|
|
|
|
* if true, edge will send connect origin to verfy the token of client.
|
|
|
|
* for example, we verify all clients on the origin FMS by server-side as,
|
|
|
|
* all clients connected to edge must be tranverse to origin to verify.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-06-21 04:39:04 +00:00
|
|
|
virtual bool get_vhost_edge_token_traverse(std::string vhost);
|
2015-01-02 08:02:13 +00:00
|
|
|
// vhost security section
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* whether the secrity of vhost enabled.
|
|
|
|
*/
|
|
|
|
virtual bool get_security_enabled(std::string vhost);
|
|
|
|
/**
|
|
|
|
* get the security rules.
|
|
|
|
*/
|
|
|
|
virtual SrsConfDirective* get_security_rules(std::string vhost);
|
2014-04-04 09:01:34 +00:00
|
|
|
// vhost transcode section
|
|
|
|
public:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:15:59 +00:00
|
|
|
* get the transcode directive of vhost in specified scope.
|
|
|
|
* @param vhost, the vhost name to get the transcode directive.
|
|
|
|
* @param scope, the scope, empty to get all. for example, user can transcode
|
|
|
|
* the app scope stream, by config with app:
|
|
|
|
* transcode live {...}
|
|
|
|
* when the scope is "live", this directive is matched.
|
|
|
|
* the scope can be: empty for all, app, app/stream.
|
|
|
|
* @remark, please see the samples of full.conf, the app.transcode.srs.com
|
|
|
|
* and stream.transcode.srs.com.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual SrsConfDirective* get_transcode(std::string vhost, std::string scope);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:15:59 +00:00
|
|
|
* whether the transcode directive is enabled.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual bool get_transcode_enabled(SrsConfDirective* transcode);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:15:59 +00:00
|
|
|
* get the ffmpeg tool path of transcode.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual std::string get_transcode_ffmpeg(SrsConfDirective* transcode);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:15:59 +00:00
|
|
|
* get the engines of transcode.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 03:15:59 +00:00
|
|
|
virtual std::vector<SrsConfDirective*> get_transcode_engines(SrsConfDirective* transcode);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* whether the engine is enabled.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-18 03:32:58 +00:00
|
|
|
virtual bool get_engine_enabled(SrsConfDirective* engine);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-19 02:54:38 +00:00
|
|
|
* get the iformat of engine
|
|
|
|
*/
|
|
|
|
virtual std::string get_engine_iformat(SrsConfDirective* engine);
|
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get the vfilter of engine,
|
|
|
|
* the video filter set before the vcodec of FFMPEG.
|
|
|
|
*/
|
|
|
|
virtual std::vector<std::string> get_engine_vfilter(SrsConfDirective* engine);
|
|
|
|
/**
|
|
|
|
* get the vcodec of engine,
|
|
|
|
* the codec of video, copy or libx264
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual std::string get_engine_vcodec(SrsConfDirective* engine);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get the vbitrate of engine,
|
|
|
|
* the bitrate in kbps of video, for example, 800kbps
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual int get_engine_vbitrate(SrsConfDirective* engine);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get the vfps of engine.
|
|
|
|
* the video fps, for example, 25fps
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual double get_engine_vfps(SrsConfDirective* engine);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get the vwidth of engine,
|
|
|
|
* the video width, for example, 1024
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual int get_engine_vwidth(SrsConfDirective* engine);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get the vheight of engine,
|
|
|
|
* the video height, for example, 576
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual int get_engine_vheight(SrsConfDirective* engine);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get the vthreads of engine,
|
|
|
|
* the video transcode libx264 threads, for instance, 8
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual int get_engine_vthreads(SrsConfDirective* engine);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get the vprofile of engine,
|
|
|
|
* the libx264 profile, can be high,main,baseline
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual std::string get_engine_vprofile(SrsConfDirective* engine);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get the vpreset of engine,
|
|
|
|
* the libx264 preset, can be ultrafast,superfast,veryfast,faster,fast,medium,slow,slower,veryslow,placebo
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual std::string get_engine_vpreset(SrsConfDirective* engine);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get the additional video params.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 03:46:29 +00:00
|
|
|
virtual std::vector<std::string> get_engine_vparams(SrsConfDirective* engine);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get the acodec of engine,
|
|
|
|
* the audio codec can be copy or libaacplus
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual std::string get_engine_acodec(SrsConfDirective* engine);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get the abitrate of engine,
|
|
|
|
* the audio bitrate in kbps, for instance, 64kbps.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual int get_engine_abitrate(SrsConfDirective* engine);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get the asample_rate of engine,
|
|
|
|
* the audio sample_rate, for instance, 44100HZ
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual int get_engine_asample_rate(SrsConfDirective* engine);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get the achannels of engine,
|
|
|
|
* the audio channel, for instance, 1 for mono, 2 for stereo.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual int get_engine_achannels(SrsConfDirective* engine);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get the aparams of engine,
|
|
|
|
* the audio additional params.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 03:46:29 +00:00
|
|
|
virtual std::vector<std::string> get_engine_aparams(SrsConfDirective* engine);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-19 02:54:38 +00:00
|
|
|
* get the oformat of engine
|
|
|
|
*/
|
|
|
|
virtual std::string get_engine_oformat(SrsConfDirective* engine);
|
|
|
|
/**
|
2014-07-20 05:04:48 +00:00
|
|
|
* get the output of engine, for example, rtmp://localhost/live/livestream,
|
2014-07-18 03:46:29 +00:00
|
|
|
* @remark, we will use some variable, for instance, [vhost] to substitude with vhost.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual std::string get_engine_output(SrsConfDirective* engine);
|
2015-01-02 08:02:13 +00:00
|
|
|
// vhost ingest section
|
2014-04-07 03:57:24 +00:00
|
|
|
public:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get the ingest directives of vhost.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 03:46:29 +00:00
|
|
|
virtual std::vector<SrsConfDirective*> get_ingesters(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get specified ingest.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-10 03:24:27 +00:00
|
|
|
virtual SrsConfDirective* get_ingest_by_id(std::string vhost, std::string ingest_id);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* whether ingest is enalbed.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-07 05:13:57 +00:00
|
|
|
virtual bool get_ingest_enabled(SrsConfDirective* ingest);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get the ingest ffmpeg tool
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-07 05:13:57 +00:00
|
|
|
virtual std::string get_ingest_ffmpeg(SrsConfDirective* ingest);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get the ingest input type, file or stream.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-07 06:20:03 +00:00
|
|
|
virtual std::string get_ingest_input_type(SrsConfDirective* ingest);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 03:46:29 +00:00
|
|
|
* get the ingest input url.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-07 06:20:03 +00:00
|
|
|
virtual std::string get_ingest_input_url(SrsConfDirective* ingest);
|
2014-04-04 07:35:17 +00:00
|
|
|
// log section
|
|
|
|
public:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* whether log to file.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-05-18 08:15:35 +00:00
|
|
|
virtual bool get_log_tank_file();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the log level.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-05-18 08:15:35 +00:00
|
|
|
virtual std::string get_log_level();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the log file path.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-05-18 08:15:35 +00:00
|
|
|
virtual std::string get_log_file();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* whether ffmpeg log enabled
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-05-27 06:10:46 +00:00
|
|
|
virtual bool get_ffmpeg_log_enabled();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* the ffmpeg log dir.
|
|
|
|
* @remark, /dev/null to disable it.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-04 07:35:17 +00:00
|
|
|
virtual std::string get_ffmpeg_log_dir();
|
2014-03-27 04:14:04 +00:00
|
|
|
// hls section
|
2013-12-14 13:19:47 +00:00
|
|
|
private:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the hls directive of vhost.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual SrsConfDirective* get_hls(std::string vhost);
|
2013-12-14 13:19:47 +00:00
|
|
|
public:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* whether HLS is enabled.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-18 03:32:58 +00:00
|
|
|
virtual bool get_hls_enabled(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the HLS ts/m3u8 file store path.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual std::string get_hls_path(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the hls fragment time, in seconds.
|
|
|
|
* a fragment is a ts file.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual double get_hls_fragment(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2015-02-12 05:34:59 +00:00
|
|
|
* get the hls td(target duration) ratio.
|
|
|
|
* a fragment is a ts file.
|
|
|
|
*/
|
|
|
|
virtual double get_hls_td_ratio(std::string vhost);
|
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the hls window time, in seconds.
|
|
|
|
* a window is a set of ts, the ts collection in m3u8.
|
|
|
|
* @remark SRS will delete the ts exceed the window.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual double get_hls_window(std::string vhost);
|
2014-12-20 03:45:59 +00:00
|
|
|
/**
|
|
|
|
* get the hls hls_on_error config.
|
|
|
|
* the ignore will ignore error and disable hls.
|
|
|
|
* the disconnect will disconnect publish connection.
|
|
|
|
* @see https://github.com/winlinvip/simple-rtmp-server/issues/264
|
|
|
|
*/
|
|
|
|
virtual std::string get_hls_on_error(std::string vhost);
|
2015-02-03 08:01:07 +00:00
|
|
|
/**
|
|
|
|
* get the HLS storage type.
|
|
|
|
*/
|
|
|
|
virtual std::string get_hls_storage(std::string vhost);
|
|
|
|
/**
|
|
|
|
* get the HLS mount url for HTTP server.
|
|
|
|
*/
|
|
|
|
virtual std::string get_hls_mount(std::string vhost);
|
2015-02-15 09:43:35 +00:00
|
|
|
/**
|
|
|
|
* get the HLS default audio codec.
|
|
|
|
*/
|
|
|
|
virtual std::string get_hls_acodec(std::string vhost);
|
2015-02-15 10:11:24 +00:00
|
|
|
/**
|
|
|
|
* get the HLS default video codec.
|
|
|
|
*/
|
|
|
|
virtual std::string get_hls_vcodec(std::string vhost);
|
2014-04-17 08:06:49 +00:00
|
|
|
// dvr section
|
|
|
|
private:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the dvr directive.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-17 08:06:49 +00:00
|
|
|
virtual SrsConfDirective* get_dvr(std::string vhost);
|
|
|
|
public:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* whether dvr is enabled.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-17 08:06:49 +00:00
|
|
|
virtual bool get_dvr_enabled(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the dvr path, the flv file to save in.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-17 08:06:49 +00:00
|
|
|
virtual std::string get_dvr_path(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the plan of dvr, how to reap the flv file.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-17 09:35:21 +00:00
|
|
|
virtual std::string get_dvr_plan(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2015-02-21 08:25:04 +00:00
|
|
|
* get the duration of dvr flv.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-17 09:35:21 +00:00
|
|
|
virtual int get_dvr_duration(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2015-02-21 08:25:04 +00:00
|
|
|
* whether wait keyframe to reap segment.
|
2014-09-25 02:59:29 +00:00
|
|
|
*/
|
|
|
|
virtual bool get_dvr_wait_keyframe(std::string vhost);
|
2015-02-21 08:25:04 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the time_jitter algorithm for dvr.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-06-25 09:14:11 +00:00
|
|
|
virtual int get_dvr_time_jitter(std::string vhost);
|
2014-03-27 04:14:04 +00:00
|
|
|
// http api section
|
|
|
|
private:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the http api directive.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-27 04:14:04 +00:00
|
|
|
virtual SrsConfDirective* get_http_api();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* whether http api enabled
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 04:12:25 +00:00
|
|
|
virtual bool get_http_api_enabled(SrsConfDirective* conf);
|
|
|
|
public:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* whether http api enabled.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 04:12:25 +00:00
|
|
|
virtual bool get_http_api_enabled();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the http api listen port.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-27 04:14:04 +00:00
|
|
|
virtual int get_http_api_listen();
|
2015-02-21 13:17:59 +00:00
|
|
|
/**
|
|
|
|
* whether enable crossdomain for http api.
|
|
|
|
*/
|
|
|
|
virtual bool get_http_api_crossdomain();
|
2014-03-27 04:14:04 +00:00
|
|
|
// http stream section
|
|
|
|
private:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the http stream directive.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-27 04:14:04 +00:00
|
|
|
virtual SrsConfDirective* get_http_stream();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* whether http stream enabled.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 04:12:25 +00:00
|
|
|
virtual bool get_http_stream_enabled(SrsConfDirective* conf);
|
|
|
|
public:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* whether http stream enabled.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 04:12:25 +00:00
|
|
|
virtual bool get_http_stream_enabled();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the http stream listen port.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-03-27 04:14:04 +00:00
|
|
|
virtual int get_http_stream_listen();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the http stream root dir.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-04 15:04:38 +00:00
|
|
|
virtual std::string get_http_stream_dir();
|
2014-04-04 10:55:21 +00:00
|
|
|
public:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get whether vhost enabled http stream
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-04 10:55:21 +00:00
|
|
|
virtual bool get_vhost_http_enabled(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2015-01-18 10:00:40 +00:00
|
|
|
* get the http mount point for vhost.
|
|
|
|
* for example, http://vhost/live/livestream
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-04 10:55:21 +00:00
|
|
|
virtual std::string get_vhost_http_mount(std::string vhost);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the http dir for vhost.
|
2015-01-18 10:00:40 +00:00
|
|
|
* the path on disk for mount root of http vhost.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-04 10:55:21 +00:00
|
|
|
virtual std::string get_vhost_http_dir(std::string vhost);
|
2015-01-18 10:00:40 +00:00
|
|
|
// flv live streaming section
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* get whether vhost enabled http flv live stream
|
|
|
|
*/
|
2015-01-22 01:34:33 +00:00
|
|
|
virtual bool get_vhost_http_remux_enabled(std::string vhost);
|
2015-01-18 10:00:40 +00:00
|
|
|
/**
|
2015-01-19 05:17:46 +00:00
|
|
|
* get the fast cache duration for http audio live stream.
|
|
|
|
*/
|
2015-01-22 01:34:33 +00:00
|
|
|
virtual double get_vhost_http_remux_fast_cache(std::string vhost);
|
2015-01-19 05:17:46 +00:00
|
|
|
/**
|
2015-01-18 10:00:40 +00:00
|
|
|
* get the http flv live stream mount point for vhost.
|
|
|
|
* used to generate the flv stream mount path.
|
|
|
|
*/
|
2015-01-22 01:34:33 +00:00
|
|
|
virtual std::string get_vhost_http_remux_mount(std::string vhost);
|
2014-05-19 09:39:01 +00:00
|
|
|
// http heartbeart section
|
|
|
|
private:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the heartbeat directive.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-05-19 09:39:01 +00:00
|
|
|
virtual SrsConfDirective* get_heartbeart();
|
|
|
|
public:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* whether heartbeat enabled.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-05-19 09:39:01 +00:00
|
|
|
virtual bool get_heartbeat_enabled();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the heartbeat interval, in ms.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-05-19 09:39:01 +00:00
|
|
|
virtual int64_t get_heartbeat_interval();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the heartbeat report url.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-05-19 09:39:01 +00:00
|
|
|
virtual std::string get_heartbeat_url();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* get the device id of heartbeat, to report to server.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-05-19 09:39:01 +00:00
|
|
|
virtual std::string get_heartbeat_device_id();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 04:12:25 +00:00
|
|
|
* whether report with summaries of http api: /api/v1/summaries.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-06-23 07:44:49 +00:00
|
|
|
virtual bool get_heartbeat_summaries();
|
2014-07-27 06:43:55 +00:00
|
|
|
// stats section
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* get the stats directive.
|
|
|
|
*/
|
|
|
|
virtual SrsConfDirective* get_stats();
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* get the network device index, used to retrieve the ip of device,
|
|
|
|
* for heartbeat to report to server, or to get the local ip.
|
|
|
|
* for example, 0 means the eth0 maybe.
|
|
|
|
*/
|
2014-07-27 10:39:20 +00:00
|
|
|
virtual int get_stats_network();
|
2014-07-27 08:52:00 +00:00
|
|
|
/**
|
|
|
|
* get the disk stat device name list.
|
|
|
|
* the device name configed in args of directive.
|
|
|
|
* @return the disk device name to stat. NULL if not configed.
|
|
|
|
*/
|
|
|
|
virtual SrsConfDirective* get_stats_disk_device();
|
2013-12-08 02:46:33 +00:00
|
|
|
};
|
|
|
|
|
2014-07-16 03:49:34 +00:00
|
|
|
namespace _srs_internal
|
|
|
|
{
|
2014-07-17 03:05:09 +00:00
|
|
|
/**
|
|
|
|
* the buffer of config content.
|
|
|
|
*/
|
|
|
|
class SrsConfigBuffer
|
2014-07-16 03:49:34 +00:00
|
|
|
{
|
2014-07-17 03:05:09 +00:00
|
|
|
protected:
|
2014-07-16 03:49:34 +00:00
|
|
|
// last available position.
|
|
|
|
char* last;
|
|
|
|
// end of buffer.
|
|
|
|
char* end;
|
|
|
|
// start of buffer.
|
|
|
|
char* start;
|
|
|
|
public:
|
|
|
|
// current consumed position.
|
|
|
|
char* pos;
|
|
|
|
// current parsed line.
|
|
|
|
int line;
|
2014-07-17 03:05:09 +00:00
|
|
|
public:
|
|
|
|
SrsConfigBuffer();
|
|
|
|
virtual ~SrsConfigBuffer();
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* fullfill the buffer with content of file specified by filename.
|
|
|
|
*/
|
2014-07-16 03:49:34 +00:00
|
|
|
virtual int fullfill(const char* filename);
|
2014-07-17 03:05:09 +00:00
|
|
|
/**
|
|
|
|
* whether buffer is empty.
|
|
|
|
*/
|
2014-07-16 03:49:34 +00:00
|
|
|
virtual bool empty();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2013-12-08 02:46:33 +00:00
|
|
|
/**
|
|
|
|
* deep compare directive.
|
|
|
|
*/
|
|
|
|
bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b);
|
|
|
|
|
|
|
|
// global config
|
2014-03-01 10:06:20 +00:00
|
|
|
extern SrsConfig* _srs_config;
|
2013-12-08 02:46:33 +00:00
|
|
|
|
2014-08-02 14:18:39 +00:00
|
|
|
#endif
|