正在显示
2 个修改的文件
包含
16 行增加
和
2 行删除
@@ -1161,7 +1161,14 @@ int SrsConfig::parse_file(const char* filename) | @@ -1161,7 +1161,14 @@ int SrsConfig::parse_file(const char* filename) | ||
1161 | return ret; | 1161 | return ret; |
1162 | } | 1162 | } |
1163 | 1163 | ||
1164 | - if ((ret = root->parse(&buffer)) != ERROR_SUCCESS) { | 1164 | + return parse_buffer(&buffer); |
1165 | +} | ||
1166 | + | ||
1167 | +int SrsConfig::parse_buffer(_srs_internal::SrsConfigBuffer* buffer) | ||
1168 | +{ | ||
1169 | + int ret = ERROR_SUCCESS; | ||
1170 | + | ||
1171 | + if ((ret = root->parse(buffer)) != ERROR_SUCCESS) { | ||
1165 | return ret; | 1172 | return ret; |
1166 | } | 1173 | } |
1167 | 1174 |
@@ -210,7 +210,7 @@ private: | @@ -210,7 +210,7 @@ private: | ||
210 | }; | 210 | }; |
211 | 211 | ||
212 | /** | 212 | /** |
213 | -* the config parser. | 213 | +* the config service provider. |
214 | * for the config supports reload, so never keep the reference cross st-thread, | 214 | * for the config supports reload, so never keep the reference cross st-thread, |
215 | * that is, never save the SrsConfDirective* get by any api of config, | 215 | * that is, never save the SrsConfDirective* get by any api of config, |
216 | * for it maybe free in the reload st-thread cycle. | 216 | * for it maybe free in the reload st-thread cycle. |
@@ -248,6 +248,13 @@ private: | @@ -248,6 +248,13 @@ private: | ||
248 | virtual int parse_argv(int& i, char** argv); | 248 | virtual int parse_argv(int& i, char** argv); |
249 | virtual void print_help(char** argv); | 249 | virtual void print_help(char** argv); |
250 | virtual int parse_file(const char* filename); | 250 | virtual int parse_file(const char* filename); |
251 | +protected: | ||
252 | + /** | ||
253 | + * parse config from the buffer. | ||
254 | + * @param buffer, the config buffer, user must delete it. | ||
255 | + * @remark, protected for the utest to override with mock. | ||
256 | + */ | ||
257 | + virtual int parse_buffer(_srs_internal::SrsConfigBuffer* buffer); | ||
251 | public: | 258 | public: |
252 | virtual std::string cwd(); | 259 | virtual std::string cwd(); |
253 | virtual std::string argv(); | 260 | virtual std::string argv(); |
-
请 注册 或 登录 后发表评论