2013-12-08 02:46:33 +00:00
|
|
|
/*
|
|
|
|
The MIT License (MIT)
|
|
|
|
|
2014-01-01 02:37:12 +00:00
|
|
|
Copyright (c) 2013-2014 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-03-02 13:49:09 +00:00
|
|
|
#ifndef SRS_APP_CONIFG_HPP
|
|
|
|
#define SRS_APP_CONIFG_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
|
|
|
|
|
|
|
#define SRS_LOCALHOST "127.0.0.1"
|
2014-03-21 07:45:34 +00:00
|
|
|
#define SRS_CONF_DEFAULT_PID_FILE "./objs/srs.pid"
|
2014-04-13 08:55:42 +00:00
|
|
|
#define SRS_DEFAULT_CONF "conf/srs.conf"
|
2013-12-08 02:46:33 +00:00
|
|
|
|
2014-06-22 12:01:25 +00:00
|
|
|
#define SRS_CONF_DEFAULT_MAX_CONNECTIONS 12345
|
2013-12-08 02:46:33 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HLS_PATH "./objs/nginx/html"
|
|
|
|
#define SRS_CONF_DEFAULT_HLS_FRAGMENT 10
|
|
|
|
#define SRS_CONF_DEFAULT_HLS_WINDOW 60
|
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"
|
2014-04-24 04:22:36 +00:00
|
|
|
// chnvideo hss
|
|
|
|
#define SRS_CONF_DEFAULT_DVR_PLAN_HSS "hss"
|
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 live queue length.
|
|
|
|
#define SRS_CONF_DEFAULT_QUEUE_LENGTH 30
|
|
|
|
// 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
|
|
|
|
2014-04-04 10:55:21 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HTTP_MOUNT "/"
|
|
|
|
#define SRS_CONF_DEFAULT_HTTP_DIR SRS_CONF_DEFAULT_HLS_PATH
|
|
|
|
|
2014-04-04 15:04:38 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HTTP_STREAM_PORT 8080
|
|
|
|
#define SRS_CONF_DEFAULT_HTTP_API_PORT 1985
|
|
|
|
|
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
|
|
|
|
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_URL "http://127.0.0.1:8085/api/v1/servers"
|
2014-06-23 07:44:49 +00:00
|
|
|
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_INDEX 0
|
|
|
|
#define SRS_CONF_DEFAULT_HTTP_HEAETBEAT_SUMMARIES false
|
2014-05-19 09:39:01 +00:00
|
|
|
|
2014-05-04 02:45:13 +00:00
|
|
|
#define SRS_STAGE_PLAY_USER_INTERVAL_MS 10000
|
|
|
|
#define SRS_STAGE_PUBLISH_USER_INTERVAL_MS 10000
|
|
|
|
#define SRS_STAGE_FORWARDER_INTERVAL_MS 10000
|
|
|
|
#define SRS_STAGE_ENCODER_INTERVAL_MS 10000
|
|
|
|
#define SRS_STAGE_INGESTER_INTERVAL_MS 10000
|
|
|
|
#define SRS_STAGE_HLS_INTERVAL_MS 10000
|
|
|
|
#define SRS_STAGE_EDGE_INTERVAL_MS 10000
|
2013-12-14 13:19:47 +00:00
|
|
|
|
2014-04-15 06:01:57 +00:00
|
|
|
#define SRS_AUTO_INGEST_TYPE_FILE "file"
|
|
|
|
#define SRS_AUTO_INGEST_TYPE_STREAM "stream"
|
2014-04-07 06:20:03 +00:00
|
|
|
|
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=[]
|
|
|
|
* ]
|
|
|
|
* ]
|
|
|
|
*/
|
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();
|
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.
|
|
|
|
* @return, an error code indicates error or has child-directives.
|
|
|
|
*/
|
|
|
|
virtual int read_token(_srs_internal::SrsConfigBuffer* buffer, std::vector<std::string>& args);
|
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();
|
|
|
|
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);
|
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-07-17 03:34:49 +00:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* parse config from the buffer.
|
|
|
|
* @param buffer, the config buffer, user must delete it.
|
|
|
|
* @remark, protected for the utest to override with mock.
|
|
|
|
*/
|
|
|
|
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
|
|
|
/**
|
2014-07-18 02:35:31 +00:00
|
|
|
* get the pithy print interval for publish, in ms,
|
|
|
|
* the publish(flash/FMLE) message print.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-04 09:01:34 +00:00
|
|
|
virtual int get_pithy_print_publish();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:35:31 +00:00
|
|
|
* get the pithy print interval for forwarder, in ms,
|
|
|
|
* the forwarder message print, for SRS forward stream to other servers.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-04 09:01:34 +00:00
|
|
|
virtual int get_pithy_print_forwarder();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:35:31 +00:00
|
|
|
* get the pithy print interval for encoder, in ms,
|
|
|
|
* the encoder message print, for FFMPEG transcoder.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-04 09:01:34 +00:00
|
|
|
virtual int get_pithy_print_encoder();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:35:31 +00:00
|
|
|
* get the pithy print interval for ingester, in ms,
|
|
|
|
* the ingest used FFMPEG, or your tools, to read and transcode other stream
|
|
|
|
* to RTMP to SRS.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-07 06:20:03 +00:00
|
|
|
virtual int get_pithy_print_ingester();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:35:31 +00:00
|
|
|
* get the pithy print interval for HLS, in ms,
|
|
|
|
* the HLS used for IOS/android/PC, SRS will mux RTMP to HLS.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-04 09:01:34 +00:00
|
|
|
virtual int get_pithy_print_hls();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:35:31 +00:00
|
|
|
* get the pithy print interval for Play, in ms,
|
|
|
|
* the play is client or edge playing RTMP stream
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-04 09:01:34 +00:00
|
|
|
virtual int get_pithy_print_play();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:35:31 +00:00
|
|
|
* get the pithy print interval for edge, in ms,
|
|
|
|
* the edge will get stream from upnode.
|
2014-07-17 04:07:01 +00:00
|
|
|
*/
|
2014-04-26 13:41:18 +00:00
|
|
|
virtual int get_pithy_print_edge();
|
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-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-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-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-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-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-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-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-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-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-17 04:07:01 +00:00
|
|
|
*/
|
2014-07-18 02:56:06 +00:00
|
|
|
virtual int get_chunk_size(std::string vhost);
|
2014-07-18 02:50:02 +00:00
|
|
|
// forward section
|
|
|
|
public:
|
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
|
|
|
|
public:
|
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);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
2014-07-18 02:50:02 +00:00
|
|
|
* get the on_dvr_hss_reap_flv callbacks of vhost.
|
|
|
|
* @return the on_dvr_hss_reap_flv 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_dvr_hss_reap_flv(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);
|
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-03-18 03:32:58 +00:00
|
|
|
virtual bool get_engine_enabled(SrsConfDirective* engine);
|
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-03-21 07:45:34 +00:00
|
|
|
virtual int get_engine_vbitrate(SrsConfDirective* engine);
|
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-03-21 07:45:34 +00:00
|
|
|
virtual int get_engine_vwidth(SrsConfDirective* engine);
|
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-03-21 07:45:34 +00:00
|
|
|
virtual int get_engine_vthreads(SrsConfDirective* engine);
|
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-03-21 07:45:34 +00:00
|
|
|
virtual std::string get_engine_vpreset(SrsConfDirective* engine);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2014-03-18 03:32:58 +00:00
|
|
|
virtual void get_engine_vparams(SrsConfDirective* engine, std::vector<std::string>& vparams);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2014-03-18 03:32:58 +00:00
|
|
|
virtual void get_engine_vfilter(SrsConfDirective* engine, std::vector<std::string>& vfilter);
|
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-03-21 07:45:34 +00:00
|
|
|
virtual int get_engine_abitrate(SrsConfDirective* engine);
|
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-03-21 07:45:34 +00:00
|
|
|
virtual int get_engine_achannels(SrsConfDirective* engine);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2014-03-18 03:32:58 +00:00
|
|
|
virtual void get_engine_aparams(SrsConfDirective* engine, std::vector<std::string>& aparams);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2014-03-21 07:45:34 +00:00
|
|
|
virtual std::string get_engine_output(SrsConfDirective* engine);
|
2014-04-07 05:13:57 +00:00
|
|
|
// ingest section
|
2014-04-07 03:57:24 +00:00
|
|
|
public:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2014-04-07 03:57:24 +00:00
|
|
|
virtual void get_ingesters(std::string vhost, std::vector<SrsConfDirective*>& ingeters);
|
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-04-07 05:13:57 +00:00
|
|
|
virtual bool get_ingest_enabled(SrsConfDirective* ingest);
|
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-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-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-05-18 08:15:35 +00:00
|
|
|
virtual bool get_log_tank_file();
|
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-05-18 08:15:35 +00:00
|
|
|
virtual std::string get_log_file();
|
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-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-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-03-18 03:32:58 +00:00
|
|
|
virtual bool get_hls_enabled(std::string vhost);
|
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-03-21 07:45:34 +00:00
|
|
|
virtual double get_hls_fragment(std::string vhost);
|
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-04-17 08:06:49 +00:00
|
|
|
// dvr section
|
|
|
|
private:
|
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-04-17 08:06:49 +00:00
|
|
|
virtual bool get_dvr_enabled(std::string vhost);
|
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-04-17 09:35:21 +00:00
|
|
|
virtual std::string get_dvr_plan(std::string vhost);
|
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
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
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-03-27 04:14:04 +00:00
|
|
|
virtual SrsConfDirective* get_http_api();
|
|
|
|
public:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2014-03-27 04:14:04 +00:00
|
|
|
virtual bool get_http_api_enabled();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2014-04-13 05:08:10 +00:00
|
|
|
virtual bool get_http_api_enabled(SrsConfDirective* conf);
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2014-03-27 04:14:04 +00:00
|
|
|
virtual int get_http_api_listen();
|
|
|
|
// http stream section
|
|
|
|
private:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2014-03-27 04:14:04 +00:00
|
|
|
virtual SrsConfDirective* get_http_stream();
|
|
|
|
public:
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2014-03-27 04:14:04 +00:00
|
|
|
virtual bool get_http_stream_enabled();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2014-04-13 05:27:51 +00:00
|
|
|
virtual bool get_http_stream_enabled(SrsConfDirective* conf);
|
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-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-04-04 10:55:21 +00:00
|
|
|
virtual bool get_vhost_http_enabled(std::string vhost);
|
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-04-04 10:55:21 +00:00
|
|
|
virtual std::string get_vhost_http_dir(std::string vhost);
|
2014-05-19 09:39:01 +00:00
|
|
|
// http heartbeart section
|
|
|
|
private:
|
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-05-19 09:39:01 +00:00
|
|
|
virtual bool get_heartbeat_enabled();
|
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-05-19 09:39:01 +00:00
|
|
|
virtual std::string get_heartbeat_url();
|
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-06-23 07:44:49 +00:00
|
|
|
virtual int get_heartbeat_device_index();
|
2014-07-17 04:07:01 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2014-06-23 07:44:49 +00:00
|
|
|
virtual bool get_heartbeat_summaries();
|
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
|
|
|
|
2013-11-02 09:55:59 +00:00
|
|
|
#endif
|