diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 22328c377..5878d3706 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -1161,7 +1161,14 @@ int SrsConfig::parse_file(const char* filename) return ret; } - if ((ret = root->parse(&buffer)) != ERROR_SUCCESS) { + return parse_buffer(&buffer); +} + +int SrsConfig::parse_buffer(_srs_internal::SrsConfigBuffer* buffer) +{ + int ret = ERROR_SUCCESS; + + if ((ret = root->parse(buffer)) != ERROR_SUCCESS) { return ret; } diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp index 46fe4a516..94a463b22 100644 --- a/trunk/src/app/srs_app_config.hpp +++ b/trunk/src/app/srs_app_config.hpp @@ -210,7 +210,7 @@ private: }; /** -* the config parser. +* the config service provider. * 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. @@ -248,6 +248,13 @@ private: virtual int parse_argv(int& i, char** argv); virtual void print_help(char** argv); virtual int parse_file(const char* filename); +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); public: virtual std::string cwd(); virtual std::string argv();