diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 5878d3706..dbdf870b1 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -1019,6 +1019,7 @@ int SrsConfig::parse_options(int argc, char** argv) { int ret = ERROR_SUCCESS; + // argv for (int i = 0; i < argc; i++) { _argv.append(argv[i]); @@ -1027,10 +1028,12 @@ int SrsConfig::parse_options(int argc, char** argv) } } + // cwd char cwd[256]; getcwd(cwd, sizeof(cwd)); _cwd = cwd; + // config show_help = true; for (int i = 1; i < argc; i++) { if ((ret = parse_argv(i, argv)) != ERROR_SUCCESS) { diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp index 94a463b22..62c0c906c 100644 --- a/trunk/src/app/srs_app_config.hpp +++ b/trunk/src/app/srs_app_config.hpp @@ -218,35 +218,106 @@ private: */ class SrsConfig { +// user command private: + /** + * whether show help and exit. + */ bool show_help; + /** + * whether test config file and exit. + */ bool test_conf; + /** + * whether show SRS version and exit. + */ bool show_version; - std::string config_file; +// global env variables. +private: + /** + * the user parameters, the argc and argv. + * the argv is " ".join(argv), where argv is from main(argc, argv). + */ std::string _argv; + /** + * current working directory. + */ std::string _cwd; +// config section +private: + /** + * the last parsed config file. + * if reload, reload the config file. + */ + std::string config_file; + /** + * the directive root. + */ SrsConfDirective* root; +// reload section +private: + /** + * the reload subscribers, when reload, callback all handlers. + */ std::vector subscribes; public: SrsConfig(); virtual ~SrsConfig(); // reload public: + /** + * for reload handler to register itself, + * when config service do the reload, callback the handler. + */ virtual void subscribe(ISrsReloadHandler* handler); + /** + * for reload handler to unregister itself. + */ virtual void unsubscribe(ISrsReloadHandler* handler); + /** + * reload the config file. + * @remark, user can test the config before reload it. + */ virtual int reload(); private: + /** + * reload the http_api section of config. + */ virtual int reload_http_api(SrsConfDirective* old_root); + /** + * reload the http_stream section of config. + */ virtual int reload_http_stream(SrsConfDirective* old_root); + /** + * reload the vhost section of config. + */ virtual int reload_vhost(SrsConfDirective* old_root); + /** + * reload the transcode section of vhost of config. + */ virtual int reload_transcode(SrsConfDirective* new_vhost, SrsConfDirective* old_vhost); + /** + * reload the ingest section of vhost of config. + */ virtual int reload_ingest(SrsConfDirective* new_vhost, SrsConfDirective* old_vhost); // parse options and file public: + /** + * parse the cli, the main(argc,argv) function. + */ virtual int parse_options(int argc, char** argv); private: + /** + * parse each argv. + */ virtual int parse_argv(int& i, char** argv); + /** + * print help and exit. + */ virtual void print_help(char** argv); + /** + * parse the config file, which is specified by cli. + */ virtual int parse_file(const char* filename); protected: /** @@ -255,8 +326,15 @@ protected: * @remark, protected for the utest to override with mock. */ virtual int parse_buffer(_srs_internal::SrsConfigBuffer* buffer); +// global env public: + /** + * get the current work directory. + */ virtual std::string cwd(); + /** + * get the cli, the main(argc,argv), program start command. + */ virtual std::string argv(); // global section public: