1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

extracta parse_buffer for config

This commit is contained in:
winlin 2014-07-17 11:34:49 +08:00
parent 784d7499cf
commit 1e8981eb08
2 changed files with 16 additions and 2 deletions

View file

@ -1161,7 +1161,14 @@ int SrsConfig::parse_file(const char* filename)
return ret; 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; return ret;
} }

View file

@ -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, * 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, * that is, never save the SrsConfDirective* get by any api of config,
* for it maybe free in the reload st-thread cycle. * for it maybe free in the reload st-thread cycle.
@ -248,6 +248,13 @@ private:
virtual int parse_argv(int& i, char** argv); virtual int parse_argv(int& i, char** argv);
virtual void print_help(char** argv); virtual void print_help(char** argv);
virtual int parse_file(const char* filename); 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: public:
virtual std::string cwd(); virtual std::string cwd();
virtual std::string argv(); virtual std::string argv();