正在显示
3 个修改的文件
包含
101 行增加
和
0 行删除
| @@ -2312,6 +2312,10 @@ SrsConfDirective* SrsConfig::get_ingest_by_id(string vhost, string ingest_id) | @@ -2312,6 +2312,10 @@ SrsConfDirective* SrsConfig::get_ingest_by_id(string vhost, string ingest_id) | ||
| 2312 | 2312 | ||
| 2313 | bool SrsConfig::get_ingest_enabled(SrsConfDirective* ingest) | 2313 | bool SrsConfig::get_ingest_enabled(SrsConfDirective* ingest) |
| 2314 | { | 2314 | { |
| 2315 | + if (!ingest) { | ||
| 2316 | + return false; | ||
| 2317 | + } | ||
| 2318 | + | ||
| 2315 | SrsConfDirective* conf = ingest->get("enabled"); | 2319 | SrsConfDirective* conf = ingest->get("enabled"); |
| 2316 | 2320 | ||
| 2317 | if (!conf || conf->arg0() != "on") { | 2321 | if (!conf || conf->arg0() != "on") { |
| @@ -2323,6 +2327,10 @@ bool SrsConfig::get_ingest_enabled(SrsConfDirective* ingest) | @@ -2323,6 +2327,10 @@ bool SrsConfig::get_ingest_enabled(SrsConfDirective* ingest) | ||
| 2323 | 2327 | ||
| 2324 | string SrsConfig::get_ingest_ffmpeg(SrsConfDirective* ingest) | 2328 | string SrsConfig::get_ingest_ffmpeg(SrsConfDirective* ingest) |
| 2325 | { | 2329 | { |
| 2330 | + if (!ingest) { | ||
| 2331 | + return ""; | ||
| 2332 | + } | ||
| 2333 | + | ||
| 2326 | SrsConfDirective* conf = ingest->get("ffmpeg"); | 2334 | SrsConfDirective* conf = ingest->get("ffmpeg"); |
| 2327 | 2335 | ||
| 2328 | if (!conf) { | 2336 | if (!conf) { |
| @@ -2334,6 +2342,10 @@ string SrsConfig::get_ingest_ffmpeg(SrsConfDirective* ingest) | @@ -2334,6 +2342,10 @@ string SrsConfig::get_ingest_ffmpeg(SrsConfDirective* ingest) | ||
| 2334 | 2342 | ||
| 2335 | string SrsConfig::get_ingest_input_type(SrsConfDirective* ingest) | 2343 | string SrsConfig::get_ingest_input_type(SrsConfDirective* ingest) |
| 2336 | { | 2344 | { |
| 2345 | + if (!ingest) { | ||
| 2346 | + return SRS_CONF_DEFAULT_INGEST_TYPE_FILE; | ||
| 2347 | + } | ||
| 2348 | + | ||
| 2337 | SrsConfDirective* conf = ingest->get("input"); | 2349 | SrsConfDirective* conf = ingest->get("input"); |
| 2338 | 2350 | ||
| 2339 | if (!conf) { | 2351 | if (!conf) { |
| @@ -2351,6 +2363,10 @@ string SrsConfig::get_ingest_input_type(SrsConfDirective* ingest) | @@ -2351,6 +2363,10 @@ string SrsConfig::get_ingest_input_type(SrsConfDirective* ingest) | ||
| 2351 | 2363 | ||
| 2352 | string SrsConfig::get_ingest_input_url(SrsConfDirective* ingest) | 2364 | string SrsConfig::get_ingest_input_url(SrsConfDirective* ingest) |
| 2353 | { | 2365 | { |
| 2366 | + if (!ingest) { | ||
| 2367 | + return ""; | ||
| 2368 | + } | ||
| 2369 | + | ||
| 2354 | SrsConfDirective* conf = ingest->get("input"); | 2370 | SrsConfDirective* conf = ingest->get("input"); |
| 2355 | 2371 | ||
| 2356 | if (!conf) { | 2372 | if (!conf) { |
| @@ -449,28 +449,33 @@ public: | @@ -449,28 +449,33 @@ public: | ||
| 449 | * whether gop_cache is enabled of vhost. | 449 | * whether gop_cache is enabled of vhost. |
| 450 | * gop_cache used to cache last gop, for client to fast startup. | 450 | * gop_cache used to cache last gop, for client to fast startup. |
| 451 | * @return true when gop_cache is ok; otherwise, false. | 451 | * @return true when gop_cache is ok; otherwise, false. |
| 452 | + * @remark, default true. | ||
| 452 | */ | 453 | */ |
| 453 | virtual bool get_gop_cache(std::string vhost); | 454 | virtual bool get_gop_cache(std::string vhost); |
| 454 | /** | 455 | /** |
| 455 | * whether atc is enabled of vhost. | 456 | * whether atc is enabled of vhost. |
| 456 | * atc always use encoder timestamp, SRS never adjust the time. | 457 | * atc always use encoder timestamp, SRS never adjust the time. |
| 457 | * @return true when atc is ok; otherwise, false. | 458 | * @return true when atc is ok; otherwise, false. |
| 459 | + * @remark, default false. | ||
| 458 | */ | 460 | */ |
| 459 | virtual bool get_atc(std::string vhost); | 461 | virtual bool get_atc(std::string vhost); |
| 460 | /** | 462 | /** |
| 461 | * whether atc_auto is enabled of vhost. | 463 | * whether atc_auto is enabled of vhost. |
| 462 | * atc_auto used to auto enable atc, when metadata specified the bravo_atc. | 464 | * atc_auto used to auto enable atc, when metadata specified the bravo_atc. |
| 463 | * @return true when atc_auto is ok; otherwise, false. | 465 | * @return true when atc_auto is ok; otherwise, false. |
| 466 | + * @remark, default true. | ||
| 464 | */ | 467 | */ |
| 465 | virtual bool get_atc_auto(std::string vhost); | 468 | virtual bool get_atc_auto(std::string vhost); |
| 466 | /** | 469 | /** |
| 467 | * get the time_jitter algorithm. | 470 | * get the time_jitter algorithm. |
| 468 | * @return the time_jitter algorithm, defined in SrsRtmpJitterAlgorithm. | 471 | * @return the time_jitter algorithm, defined in SrsRtmpJitterAlgorithm. |
| 472 | + * @remark, default full. | ||
| 469 | */ | 473 | */ |
| 470 | virtual int get_time_jitter(std::string vhost); | 474 | virtual int get_time_jitter(std::string vhost); |
| 471 | /** | 475 | /** |
| 472 | * get the cache queue length, in seconds. | 476 | * get the cache queue length, in seconds. |
| 473 | * when exceed the queue length, drop packet util I frame. | 477 | * when exceed the queue length, drop packet util I frame. |
| 478 | + * @remark, default 10. | ||
| 474 | */ | 479 | */ |
| 475 | virtual double get_queue_length(std::string vhost); | 480 | virtual double get_queue_length(std::string vhost); |
| 476 | /** | 481 | /** |
| @@ -478,20 +483,24 @@ public: | @@ -478,20 +483,24 @@ public: | ||
| 478 | * each args of directive is a refer config. | 483 | * each args of directive is a refer config. |
| 479 | * when the client refer(pageUrl) not match the refer config, | 484 | * when the client refer(pageUrl) not match the refer config, |
| 480 | * SRS will reject the connection. | 485 | * SRS will reject the connection. |
| 486 | + * @remark, default NULL. | ||
| 481 | */ | 487 | */ |
| 482 | virtual SrsConfDirective* get_refer(std::string vhost); | 488 | virtual SrsConfDirective* get_refer(std::string vhost); |
| 483 | /** | 489 | /** |
| 484 | * get the play refer, refer for play clients. | 490 | * get the play refer, refer for play clients. |
| 491 | + * @remark, default NULL. | ||
| 485 | */ | 492 | */ |
| 486 | virtual SrsConfDirective* get_refer_play(std::string vhost); | 493 | virtual SrsConfDirective* get_refer_play(std::string vhost); |
| 487 | /** | 494 | /** |
| 488 | * get the publish refer, refer for publish clients. | 495 | * get the publish refer, refer for publish clients. |
| 496 | + * @remark, default NULL. | ||
| 489 | */ | 497 | */ |
| 490 | virtual SrsConfDirective* get_refer_publish(std::string vhost); | 498 | virtual SrsConfDirective* get_refer_publish(std::string vhost); |
| 491 | /** | 499 | /** |
| 492 | * get the chunk size of vhost. | 500 | * get the chunk size of vhost. |
| 493 | * @param vhost, the vhost to get the chunk size. use global if not specified. | 501 | * @param vhost, the vhost to get the chunk size. use global if not specified. |
| 494 | * empty string to get the global. | 502 | * empty string to get the global. |
| 503 | + * @remark, default 60000. | ||
| 495 | */ | 504 | */ |
| 496 | virtual int get_chunk_size(std::string vhost); | 505 | virtual int get_chunk_size(std::string vhost); |
| 497 | private: | 506 | private: |
| @@ -27,6 +27,7 @@ using namespace std; | @@ -27,6 +27,7 @@ using namespace std; | ||
| 27 | #include <srs_app_config.hpp> | 27 | #include <srs_app_config.hpp> |
| 28 | #include <srs_kernel_consts.hpp> | 28 | #include <srs_kernel_consts.hpp> |
| 29 | #include <srs_kernel_error.hpp> | 29 | #include <srs_kernel_error.hpp> |
| 30 | +#include <srs_app_source.hpp> | ||
| 30 | 31 | ||
| 31 | MockSrsConfigBuffer::MockSrsConfigBuffer(string buf) | 32 | MockSrsConfigBuffer::MockSrsConfigBuffer(string buf) |
| 32 | { | 33 | { |
| @@ -1837,6 +1838,14 @@ VOID TEST(ConfigMainTest, ParseFullConf) | @@ -1837,6 +1838,14 @@ VOID TEST(ConfigMainTest, ParseFullConf) | ||
| 1837 | EXPECT_EQ(8080, conf.get_http_stream_listen()); | 1838 | EXPECT_EQ(8080, conf.get_http_stream_listen()); |
| 1838 | EXPECT_STREQ("./objs/nginx/html", conf.get_http_stream_dir().c_str()); | 1839 | EXPECT_STREQ("./objs/nginx/html", conf.get_http_stream_dir().c_str()); |
| 1839 | 1840 | ||
| 1841 | + EXPECT_EQ(10000, conf.get_pithy_print_publish()); | ||
| 1842 | + EXPECT_EQ(10000, conf.get_pithy_print_play()); | ||
| 1843 | + EXPECT_EQ(10000, conf.get_pithy_print_forwarder()); | ||
| 1844 | + EXPECT_EQ(10000, conf.get_pithy_print_encoder()); | ||
| 1845 | + EXPECT_EQ(10000, conf.get_pithy_print_ingester()); | ||
| 1846 | + EXPECT_EQ(10000, conf.get_pithy_print_hls()); | ||
| 1847 | + EXPECT_EQ(10000, conf.get_pithy_print_edge()); | ||
| 1848 | + | ||
| 1840 | EXPECT_TRUE(NULL != conf.get_vhost("__defaultVhost__")); | 1849 | EXPECT_TRUE(NULL != conf.get_vhost("__defaultVhost__")); |
| 1841 | EXPECT_TRUE(NULL != conf.get_vhost("same.edge.srs.com")); | 1850 | EXPECT_TRUE(NULL != conf.get_vhost("same.edge.srs.com")); |
| 1842 | EXPECT_TRUE(NULL != conf.get_vhost("change.edge.srs.com")); | 1851 | EXPECT_TRUE(NULL != conf.get_vhost("change.edge.srs.com")); |
| @@ -1865,4 +1874,71 @@ VOID TEST(ConfigMainTest, ParseFullConf) | @@ -1865,4 +1874,71 @@ VOID TEST(ConfigMainTest, ParseFullConf) | ||
| 1865 | EXPECT_TRUE(NULL != conf.get_vhost("jitter.srs.com")); | 1874 | EXPECT_TRUE(NULL != conf.get_vhost("jitter.srs.com")); |
| 1866 | EXPECT_TRUE(NULL != conf.get_vhost("atc.srs.com")); | 1875 | EXPECT_TRUE(NULL != conf.get_vhost("atc.srs.com")); |
| 1867 | EXPECT_TRUE(NULL != conf.get_vhost("removed.srs.com")); | 1876 | EXPECT_TRUE(NULL != conf.get_vhost("removed.srs.com")); |
| 1877 | + | ||
| 1878 | + string vhost = "__defaultVhost__"; | ||
| 1879 | + EXPECT_TRUE(conf.get_vhost_enabled(vhost)); | ||
| 1880 | + EXPECT_TRUE(conf.get_vhost_enabled(conf.get_vhost(vhost))); | ||
| 1881 | + EXPECT_TRUE(conf.get_gop_cache(vhost)); | ||
| 1882 | + EXPECT_FALSE(conf.get_atc(vhost)); | ||
| 1883 | + EXPECT_TRUE(conf.get_atc_auto(vhost)); | ||
| 1884 | + EXPECT_TRUE(conf.get_time_jitter(vhost) == SrsRtmpJitterAlgorithmFULL); | ||
| 1885 | + EXPECT_FLOAT_EQ(30, conf.get_queue_length(vhost)); | ||
| 1886 | + EXPECT_TRUE(NULL == conf.get_refer(vhost)); | ||
| 1887 | + EXPECT_TRUE(NULL == conf.get_refer_play(vhost)); | ||
| 1888 | + EXPECT_TRUE(NULL == conf.get_refer_publish(vhost)); | ||
| 1889 | + EXPECT_EQ(60000, conf.get_chunk_size(vhost)); | ||
| 1890 | + EXPECT_TRUE(NULL == conf.get_forward(vhost)); | ||
| 1891 | + EXPECT_TRUE(NULL == conf.get_vhost_on_connect(vhost)); | ||
| 1892 | + EXPECT_TRUE(NULL == conf.get_vhost_on_close(vhost)); | ||
| 1893 | + EXPECT_TRUE(NULL == conf.get_vhost_on_publish(vhost)); | ||
| 1894 | + EXPECT_TRUE(NULL == conf.get_vhost_on_unpublish(vhost)); | ||
| 1895 | + EXPECT_TRUE(NULL == conf.get_vhost_on_play(vhost)); | ||
| 1896 | + EXPECT_TRUE(NULL == conf.get_vhost_on_stop(vhost)); | ||
| 1897 | + EXPECT_TRUE(NULL == conf.get_vhost_on_dvr_hss_reap_flv(vhost)); | ||
| 1898 | + EXPECT_FALSE(conf.get_bw_check_enabled(vhost)); | ||
| 1899 | + EXPECT_TRUE(conf.get_bw_check_key(vhost).empty()); | ||
| 1900 | + EXPECT_EQ(30000, conf.get_bw_check_interval_ms(vhost)); | ||
| 1901 | + EXPECT_EQ(1000, conf.get_bw_check_limit_kbps(vhost)); | ||
| 1902 | + EXPECT_FALSE(conf.get_vhost_is_edge(vhost)); | ||
| 1903 | + EXPECT_FALSE(conf.get_vhost_is_edge(conf.get_vhost(vhost))); | ||
| 1904 | + EXPECT_TRUE(NULL == conf.get_vhost_edge_origin(vhost)); | ||
| 1905 | + EXPECT_FALSE(conf.get_vhost_edge_token_traverse(vhost)); | ||
| 1906 | + EXPECT_TRUE(NULL == conf.get_transcode(vhost, "")); | ||
| 1907 | + EXPECT_FALSE(conf.get_transcode_enabled(NULL)); | ||
| 1908 | + EXPECT_TRUE(conf.get_transcode_ffmpeg(NULL).empty()); | ||
| 1909 | + EXPECT_TRUE(conf.get_transcode_engines(NULL).size() == 0); | ||
| 1910 | + EXPECT_FALSE(conf.get_engine_enabled(NULL)); | ||
| 1911 | + EXPECT_STREQ("flv", conf.get_engine_iformat(NULL).c_str()); | ||
| 1912 | + EXPECT_TRUE(conf.get_engine_vfilter(NULL).size() == 0); | ||
| 1913 | + EXPECT_TRUE(conf.get_engine_vcodec(NULL).empty()); | ||
| 1914 | + EXPECT_TRUE(conf.get_engine_vbitrate(NULL) == 0); | ||
| 1915 | + EXPECT_TRUE(conf.get_engine_vfps(NULL) == 0); | ||
| 1916 | + EXPECT_TRUE(conf.get_engine_vwidth(NULL) == 0); | ||
| 1917 | + EXPECT_TRUE(conf.get_engine_vheight(NULL) == 0); | ||
| 1918 | + EXPECT_TRUE(conf.get_engine_vthreads(NULL) == 0); | ||
| 1919 | + EXPECT_TRUE(conf.get_engine_vprofile(NULL).empty()); | ||
| 1920 | + EXPECT_TRUE(conf.get_engine_vpreset(NULL).empty()); | ||
| 1921 | + EXPECT_TRUE(conf.get_engine_vparams(NULL).size() == 0); | ||
| 1922 | + EXPECT_TRUE(conf.get_engine_acodec(NULL).empty()); | ||
| 1923 | + EXPECT_TRUE(conf.get_engine_abitrate(NULL) == 0); | ||
| 1924 | + EXPECT_TRUE(conf.get_engine_asample_rate(NULL) == 0); | ||
| 1925 | + EXPECT_TRUE(conf.get_engine_achannels(NULL) == 0); | ||
| 1926 | + EXPECT_TRUE(conf.get_engine_aparams(NULL).size() == 0); | ||
| 1927 | + EXPECT_STREQ("flv", conf.get_engine_oformat(NULL).c_str()); | ||
| 1928 | + EXPECT_TRUE(conf.get_engine_output(NULL).empty()); | ||
| 1929 | + EXPECT_TRUE(conf.get_ingesters(vhost).size() == 0); | ||
| 1930 | + EXPECT_TRUE(NULL == conf.get_ingest_by_id(vhost, "")); | ||
| 1931 | + EXPECT_FALSE(conf.get_ingest_enabled(NULL)); | ||
| 1932 | + EXPECT_TRUE(conf.get_ingest_ffmpeg(NULL).empty()); | ||
| 1933 | + EXPECT_STREQ("file", conf.get_ingest_input_type(NULL).c_str()); | ||
| 1934 | + EXPECT_TRUE(conf.get_ingest_input_url(NULL).empty()); | ||
| 1935 | + EXPECT_FALSE(conf.get_hls_enabled(vhost)); | ||
| 1936 | + EXPECT_STREQ("./objs/nginx/html", conf.get_hls_path(vhost).c_str()); | ||
| 1937 | + EXPECT_EQ(10, conf.get_hls_fragment(vhost)); | ||
| 1938 | + EXPECT_EQ(60, conf.get_hls_window(vhost)); | ||
| 1939 | + EXPECT_FALSE(conf.get_dvr_enabled(vhost)); | ||
| 1940 | + EXPECT_STREQ("./objs/nginx/html", conf.get_dvr_path(vhost).c_str()); | ||
| 1941 | + EXPECT_STREQ("session", conf.get_dvr_plan(vhost).c_str()); | ||
| 1942 | + EXPECT_EQ(30, conf.get_dvr_duration(vhost)); | ||
| 1943 | + EXPECT_TRUE(SrsRtmpJitterAlgorithmFULL == conf.get_dvr_time_jitter(vhost)); | ||
| 1868 | } | 1944 | } |
-
请 注册 或 登录 后发表评论