正在显示
3 个修改的文件
包含
63 行增加
和
2 行删除
@@ -364,6 +364,8 @@ int SrsConfDirective::read_token(SrsConfigBuffer* buffer, vector<string>& args, | @@ -364,6 +364,8 @@ int SrsConfDirective::read_token(SrsConfigBuffer* buffer, vector<string>& args, | ||
364 | 364 | ||
365 | SrsConfig::SrsConfig() | 365 | SrsConfig::SrsConfig() |
366 | { | 366 | { |
367 | + dolphin = false; | ||
368 | + | ||
367 | show_help = false; | 369 | show_help = false; |
368 | show_version = false; | 370 | show_version = false; |
369 | test_conf = false; | 371 | test_conf = false; |
@@ -378,6 +380,25 @@ SrsConfig::~SrsConfig() | @@ -378,6 +380,25 @@ SrsConfig::~SrsConfig() | ||
378 | srs_freep(root); | 380 | srs_freep(root); |
379 | } | 381 | } |
380 | 382 | ||
383 | +bool SrsConfig::is_dolphin() | ||
384 | +{ | ||
385 | + return dolphin; | ||
386 | +} | ||
387 | + | ||
388 | +void SrsConfig::set_config_directive(SrsConfDirective* parent, string dir, string value) | ||
389 | +{ | ||
390 | + SrsConfDirective* d = parent->get(dir); | ||
391 | + | ||
392 | + if (!d) { | ||
393 | + d = new SrsConfDirective(); | ||
394 | + d->name = dir; | ||
395 | + parent->directives.push_back(d); | ||
396 | + } | ||
397 | + | ||
398 | + d->args.clear(); | ||
399 | + d->args.push_back(value); | ||
400 | +} | ||
401 | + | ||
381 | void SrsConfig::subscribe(ISrsReloadHandler* handler) | 402 | void SrsConfig::subscribe(ISrsReloadHandler* handler) |
382 | { | 403 | { |
383 | std::vector<ISrsReloadHandler*>::iterator it; | 404 | std::vector<ISrsReloadHandler*>::iterator it; |
@@ -1260,6 +1281,19 @@ int SrsConfig::parse_argv(int& i, char** argv) | @@ -1260,6 +1281,19 @@ int SrsConfig::parse_argv(int& i, char** argv) | ||
1260 | show_help = false; | 1281 | show_help = false; |
1261 | test_conf = true; | 1282 | test_conf = true; |
1262 | break; | 1283 | break; |
1284 | + case 'p': | ||
1285 | + dolphin = true; | ||
1286 | + if (*p) { | ||
1287 | + dolphin_port = p; | ||
1288 | + continue; | ||
1289 | + } | ||
1290 | + if (argv[++i]) { | ||
1291 | + dolphin_port = argv[i]; | ||
1292 | + continue; | ||
1293 | + } | ||
1294 | + ret = ERROR_SYSTEM_CONFIG_INVALID; | ||
1295 | + srs_error("option \"-p\" requires params, ret=%d", ret); | ||
1296 | + return ret; | ||
1263 | case 'v': | 1297 | case 'v': |
1264 | case 'V': | 1298 | case 'V': |
1265 | show_help = false; | 1299 | show_help = false; |
@@ -1269,11 +1303,11 @@ int SrsConfig::parse_argv(int& i, char** argv) | @@ -1269,11 +1303,11 @@ int SrsConfig::parse_argv(int& i, char** argv) | ||
1269 | show_help = false; | 1303 | show_help = false; |
1270 | if (*p) { | 1304 | if (*p) { |
1271 | config_file = p; | 1305 | config_file = p; |
1272 | - return ret; | 1306 | + continue; |
1273 | } | 1307 | } |
1274 | if (argv[++i]) { | 1308 | if (argv[++i]) { |
1275 | config_file = argv[i]; | 1309 | config_file = argv[i]; |
1276 | - return ret; | 1310 | + continue; |
1277 | } | 1311 | } |
1278 | ret = ERROR_SYSTEM_CONFIG_INVALID; | 1312 | ret = ERROR_SYSTEM_CONFIG_INVALID; |
1279 | srs_error("option \"-c\" requires parameter, ret=%d", ret); | 1313 | srs_error("option \"-c\" requires parameter, ret=%d", ret); |
@@ -1845,6 +1879,14 @@ int SrsConfig::parse_buffer(SrsConfigBuffer* buffer) | @@ -1845,6 +1879,14 @@ int SrsConfig::parse_buffer(SrsConfigBuffer* buffer) | ||
1845 | return ret; | 1879 | return ret; |
1846 | } | 1880 | } |
1847 | 1881 | ||
1882 | + // mock by dolphin mode. | ||
1883 | + // for the dolphin will start srs with specified params. | ||
1884 | + if (dolphin) { | ||
1885 | + set_config_directive(root, "listen", dolphin_port); | ||
1886 | + set_config_directive(root, "daemon", "off"); | ||
1887 | + set_config_directive(root, "srs_log_tank", "console"); | ||
1888 | + } | ||
1889 | + | ||
1848 | return ret; | 1890 | return ret; |
1849 | } | 1891 | } |
1850 | 1892 |
@@ -267,6 +267,12 @@ class SrsConfig | @@ -267,6 +267,12 @@ class SrsConfig | ||
267 | // user command | 267 | // user command |
268 | private: | 268 | private: |
269 | /** | 269 | /** |
270 | + * whether srs is run in dolphin mode. | ||
271 | + * @see https://github.com/simple-rtmp-server/srs-dolphin | ||
272 | + */ | ||
273 | + bool dolphin; | ||
274 | + std::string dolphin_port; | ||
275 | + /** | ||
270 | * whether show help and exit. | 276 | * whether show help and exit. |
271 | */ | 277 | */ |
272 | bool show_help; | 278 | bool show_help; |
@@ -309,6 +315,14 @@ private: | @@ -309,6 +315,14 @@ private: | ||
309 | public: | 315 | public: |
310 | SrsConfig(); | 316 | SrsConfig(); |
311 | virtual ~SrsConfig(); | 317 | virtual ~SrsConfig(); |
318 | +// dolphin | ||
319 | +public: | ||
320 | + /** | ||
321 | + * whether srs is in dolphin mode. | ||
322 | + */ | ||
323 | + virtual bool is_dolphin(); | ||
324 | +private: | ||
325 | + virtual void set_config_directive(SrsConfDirective* parent, std::string dir, std::string value); | ||
312 | // reload | 326 | // reload |
313 | public: | 327 | public: |
314 | /** | 328 | /** |
@@ -639,6 +639,11 @@ int SrsServer::acquire_pid_file() | @@ -639,6 +639,11 @@ int SrsServer::acquire_pid_file() | ||
639 | { | 639 | { |
640 | int ret = ERROR_SUCCESS; | 640 | int ret = ERROR_SUCCESS; |
641 | 641 | ||
642 | + // when srs in dolphin mode, no need the pid file. | ||
643 | + if (_srs_config->is_dolphin()) { | ||
644 | + return ret; | ||
645 | + } | ||
646 | + | ||
642 | std::string pid_file = _srs_config->get_pid_file(); | 647 | std::string pid_file = _srs_config->get_pid_file(); |
643 | 648 | ||
644 | // -rw-r--r-- | 649 | // -rw-r--r-- |
-
请 注册 或 登录 后发表评论