正在显示
23 个修改的文件
包含
242 行增加
和
332 行删除
| @@ -16,10 +16,11 @@ Download from ossrs.net: | @@ -16,10 +16,11 @@ Download from ossrs.net: | ||
| 16 | 16 | ||
| 17 | SRS(SIMPLE RTMP Server) over state-threads created in 2013.10. | 17 | SRS(SIMPLE RTMP Server) over state-threads created in 2013.10. |
| 18 | 18 | ||
| 19 | -SRS delivers rtmp/hls live on x86/x64/arm/mips linux, | 19 | +SRS delivers rtmp/hls/http live on x86/x64/arm/mips linux, |
| 20 | supports origin/edge/vhost and transcode/ingest and dvr/forward | 20 | supports origin/edge/vhost and transcode/ingest and dvr/forward |
| 21 | and http-api/http-callback/reload, introduces tracable | 21 | and http-api/http-callback/reload, introduces tracable |
| 22 | session-oriented log, exports client srs-librtmp, | 22 | session-oriented log, exports client srs-librtmp, |
| 23 | +with stream caster to push MPEGTS-over-UDP/RTSP to SRS, | ||
| 23 | provides EN/CN wiki and the most simple architecture. | 24 | provides EN/CN wiki and the most simple architecture. |
| 24 | 25 | ||
| 25 | SRS focus on small problem domain, which is the most complex for all software(see OOAD). | 26 | SRS focus on small problem domain, which is the most complex for all software(see OOAD). |
| @@ -529,6 +530,7 @@ Supported operating systems and hardware: | @@ -529,6 +530,7 @@ Supported operating systems and hardware: | ||
| 529 | 530 | ||
| 530 | ### SRS 2.0 history | 531 | ### SRS 2.0 history |
| 531 | 532 | ||
| 533 | +* v2.0, 2015-02-19, refine pithy print to more easyer to use 2.0.121. | ||
| 532 | * v2.0, 2015-02-18, fix [#133](https://github.com/winlinvip/simple-rtmp-server/issues/133), support push rtsp to srs. 2.0.120. | 534 | * v2.0, 2015-02-18, fix [#133](https://github.com/winlinvip/simple-rtmp-server/issues/133), support push rtsp to srs. 2.0.120. |
| 533 | * v2.0, 2015-02-17, the join maybe failed, should use a variable to ensure thread terminated. 2.0.119. | 535 | * v2.0, 2015-02-17, the join maybe failed, should use a variable to ensure thread terminated. 2.0.119. |
| 534 | * v2.0, 2015-02-15, for [#304](https://github.com/winlinvip/simple-rtmp-server/issues/304), support config default acodec/vcodec. 2.0.118. | 536 | * v2.0, 2015-02-15, for [#304](https://github.com/winlinvip/simple-rtmp-server/issues/304), support config default acodec/vcodec. 2.0.118. |
| @@ -1227,26 +1227,4 @@ vhost removed.srs.com { | @@ -1227,26 +1227,4 @@ vhost removed.srs.com { | ||
| 1227 | # config for the pithy print, | 1227 | # config for the pithy print, |
| 1228 | # which always print constant message specified by interval, | 1228 | # which always print constant message specified by interval, |
| 1229 | # whatever the clients in concurrency. | 1229 | # whatever the clients in concurrency. |
| 1230 | -pithy_print { | ||
| 1231 | - # shared print interval for all publish clients, in milliseconds. | ||
| 1232 | - # default: 10000 | ||
| 1233 | - publish 10000; | ||
| 1234 | - # shared print interval for all play clients, in milliseconds. | ||
| 1235 | - # default: 10000 | ||
| 1236 | - play 10000; | ||
| 1237 | - # shared print interval for all forwarders, in milliseconds. | ||
| 1238 | - # default: 10000 | ||
| 1239 | - forwarder 10000; | ||
| 1240 | - # shared print interval for all encoders, in milliseconds. | ||
| 1241 | - # default: 10000 | ||
| 1242 | - encoder 10000; | ||
| 1243 | - # shared print interval for all ingesters, in milliseconds. | ||
| 1244 | - # default: 10000 | ||
| 1245 | - ingester 10000; | ||
| 1246 | - # shared print interval for all hls, in milliseconds. | ||
| 1247 | - # default: 10000 | ||
| 1248 | - hls 10000; | ||
| 1249 | - # shared print interval for all edge, in milliseconds. | ||
| 1250 | - # default: 10000 | ||
| 1251 | - edge 10000; | ||
| 1252 | -} | 1230 | +pithy_print_ms 10000; |
| @@ -502,16 +502,16 @@ int SrsConfig::reload_conf(SrsConfig* conf) | @@ -502,16 +502,16 @@ int SrsConfig::reload_conf(SrsConfig* conf) | ||
| 502 | srs_trace("reload srs_log_file success."); | 502 | srs_trace("reload srs_log_file success."); |
| 503 | } | 503 | } |
| 504 | 504 | ||
| 505 | - // merge config: pithy_print | ||
| 506 | - if (!srs_directive_equals(root->get("pithy_print"), old_root->get("pithy_print"))) { | 505 | + // merge config: pithy_print_ms |
| 506 | + if (!srs_directive_equals(root->get("pithy_print_ms"), old_root->get("pithy_print_ms"))) { | ||
| 507 | for (it = subscribes.begin(); it != subscribes.end(); ++it) { | 507 | for (it = subscribes.begin(); it != subscribes.end(); ++it) { |
| 508 | ISrsReloadHandler* subscribe = *it; | 508 | ISrsReloadHandler* subscribe = *it; |
| 509 | if ((ret = subscribe->on_reload_pithy_print()) != ERROR_SUCCESS) { | 509 | if ((ret = subscribe->on_reload_pithy_print()) != ERROR_SUCCESS) { |
| 510 | - srs_error("notify subscribes pithy_print listen failed. ret=%d", ret); | 510 | + srs_error("notify subscribes pithy_print_ms listen failed. ret=%d", ret); |
| 511 | return ret; | 511 | return ret; |
| 512 | } | 512 | } |
| 513 | } | 513 | } |
| 514 | - srs_trace("reload pithy_print success."); | 514 | + srs_trace("reload pithy_print_ms success."); |
| 515 | } | 515 | } |
| 516 | 516 | ||
| 517 | // merge config: http_api | 517 | // merge config: http_api |
| @@ -1322,7 +1322,7 @@ int SrsConfig::check_config() | @@ -1322,7 +1322,7 @@ int SrsConfig::check_config() | ||
| 1322 | if (n != "listen" && n != "pid" && n != "chunk_size" && n != "ff_log_dir" | 1322 | if (n != "listen" && n != "pid" && n != "chunk_size" && n != "ff_log_dir" |
| 1323 | && n != "srs_log_tank" && n != "srs_log_level" && n != "srs_log_file" | 1323 | && n != "srs_log_tank" && n != "srs_log_level" && n != "srs_log_file" |
| 1324 | && n != "max_connections" && n != "daemon" && n != "heartbeat" | 1324 | && n != "max_connections" && n != "daemon" && n != "heartbeat" |
| 1325 | - && n != "http_api" && n != "stats" && n != "vhost" && n != "pithy_print" | 1325 | + && n != "http_api" && n != "stats" && n != "vhost" && n != "pithy_print_ms" |
| 1326 | && n != "http_stream" && n != "http_server" && n != "stream_caster") | 1326 | && n != "http_stream" && n != "http_server" && n != "stream_caster") |
| 1327 | { | 1327 | { |
| 1328 | ret = ERROR_SYSTEM_CONFIG_INVALID; | 1328 | ret = ERROR_SYSTEM_CONFIG_INVALID; |
| @@ -1376,19 +1376,6 @@ int SrsConfig::check_config() | @@ -1376,19 +1376,6 @@ int SrsConfig::check_config() | ||
| 1376 | } | 1376 | } |
| 1377 | } | 1377 | } |
| 1378 | } | 1378 | } |
| 1379 | - if (true) { | ||
| 1380 | - SrsConfDirective* conf = get_pithy_print(); | ||
| 1381 | - for (int i = 0; conf && i < (int)conf->directives.size(); i++) { | ||
| 1382 | - string n = conf->at(i)->name; | ||
| 1383 | - if (n != "publish" && n != "play" && n != "forwarder" | ||
| 1384 | - && n != "encoder" && n != "ingester" && n != "hls" && n != "edge" | ||
| 1385 | - ) { | ||
| 1386 | - ret = ERROR_SYSTEM_CONFIG_INVALID; | ||
| 1387 | - srs_error("unsupported pithy_print directive %s, ret=%d", n.c_str(), ret); | ||
| 1388 | - return ret; | ||
| 1389 | - } | ||
| 1390 | - } | ||
| 1391 | - } | ||
| 1392 | for (int n = 0; n < (int)stream_casters.size(); n++) { | 1379 | for (int n = 0; n < (int)stream_casters.size(); n++) { |
| 1393 | SrsConfDirective* stream_caster = stream_casters[n]; | 1380 | SrsConfDirective* stream_caster = stream_casters[n]; |
| 1394 | for (int i = 0; stream_caster && i < (int)stream_caster->directives.size(); i++) { | 1381 | for (int i = 0; stream_caster && i < (int)stream_caster->directives.size(); i++) { |
| @@ -1884,111 +1871,11 @@ string SrsConfig::get_pid_file() | @@ -1884,111 +1871,11 @@ string SrsConfig::get_pid_file() | ||
| 1884 | return conf->arg0(); | 1871 | return conf->arg0(); |
| 1885 | } | 1872 | } |
| 1886 | 1873 | ||
| 1887 | -SrsConfDirective* SrsConfig::get_pithy_print() | ||
| 1888 | -{ | ||
| 1889 | - return root->get("pithy_print"); | ||
| 1890 | -} | ||
| 1891 | - | ||
| 1892 | -int SrsConfig::get_pithy_print_publish() | ||
| 1893 | -{ | ||
| 1894 | - SrsConfDirective* pithy = get_pithy_print(); | ||
| 1895 | - if (!pithy) { | ||
| 1896 | - return SRS_CONF_DEFAULT_STAGE_PUBLISH_USER_INTERVAL_MS; | ||
| 1897 | - } | ||
| 1898 | - | ||
| 1899 | - pithy = pithy->get("publish"); | ||
| 1900 | - if (!pithy) { | ||
| 1901 | - return SRS_CONF_DEFAULT_STAGE_PUBLISH_USER_INTERVAL_MS; | ||
| 1902 | - } | ||
| 1903 | - | ||
| 1904 | - return ::atoi(pithy->arg0().c_str()); | ||
| 1905 | -} | ||
| 1906 | - | ||
| 1907 | -int SrsConfig::get_pithy_print_forwarder() | ||
| 1908 | -{ | ||
| 1909 | - SrsConfDirective* pithy = get_pithy_print(); | ||
| 1910 | - if (!pithy) { | ||
| 1911 | - return SRS_CONF_DEFAULT_STAGE_FORWARDER_INTERVAL_MS; | ||
| 1912 | - } | ||
| 1913 | - | ||
| 1914 | - pithy = pithy->get("forwarder"); | ||
| 1915 | - if (!pithy) { | ||
| 1916 | - return SRS_CONF_DEFAULT_STAGE_FORWARDER_INTERVAL_MS; | ||
| 1917 | - } | ||
| 1918 | - | ||
| 1919 | - return ::atoi(pithy->arg0().c_str()); | ||
| 1920 | -} | ||
| 1921 | - | ||
| 1922 | -int SrsConfig::get_pithy_print_encoder() | ||
| 1923 | -{ | ||
| 1924 | - SrsConfDirective* pithy = get_pithy_print(); | ||
| 1925 | - if (!pithy) { | ||
| 1926 | - return SRS_CONF_DEFAULT_STAGE_ENCODER_INTERVAL_MS; | ||
| 1927 | - } | ||
| 1928 | - | ||
| 1929 | - pithy = pithy->get("encoder"); | ||
| 1930 | - if (!pithy) { | ||
| 1931 | - return SRS_CONF_DEFAULT_STAGE_ENCODER_INTERVAL_MS; | ||
| 1932 | - } | ||
| 1933 | - | ||
| 1934 | - return ::atoi(pithy->arg0().c_str()); | ||
| 1935 | -} | ||
| 1936 | - | ||
| 1937 | -int SrsConfig::get_pithy_print_ingester() | ||
| 1938 | -{ | ||
| 1939 | - SrsConfDirective* pithy = get_pithy_print(); | ||
| 1940 | - if (!pithy) { | ||
| 1941 | - return SRS_CONF_DEFAULT_STAGE_INGESTER_INTERVAL_MS; | ||
| 1942 | - } | ||
| 1943 | - | ||
| 1944 | - pithy = pithy->get("ingester"); | ||
| 1945 | - if (!pithy) { | ||
| 1946 | - return SRS_CONF_DEFAULT_STAGE_INGESTER_INTERVAL_MS; | ||
| 1947 | - } | ||
| 1948 | - | ||
| 1949 | - return ::atoi(pithy->arg0().c_str()); | ||
| 1950 | -} | ||
| 1951 | - | ||
| 1952 | -int SrsConfig::get_pithy_print_hls() | 1874 | +int SrsConfig::get_pithy_print_ms() |
| 1953 | { | 1875 | { |
| 1954 | - SrsConfDirective* pithy = get_pithy_print(); | ||
| 1955 | - if (!pithy) { | ||
| 1956 | - return SRS_CONF_DEFAULT_STAGE_HLS_INTERVAL_MS; | ||
| 1957 | - } | ||
| 1958 | - | ||
| 1959 | - pithy = pithy->get("hls"); | ||
| 1960 | - if (!pithy) { | ||
| 1961 | - return SRS_CONF_DEFAULT_STAGE_HLS_INTERVAL_MS; | ||
| 1962 | - } | ||
| 1963 | - | ||
| 1964 | - return ::atoi(pithy->arg0().c_str()); | ||
| 1965 | -} | ||
| 1966 | - | ||
| 1967 | -int SrsConfig::get_pithy_print_play() | ||
| 1968 | -{ | ||
| 1969 | - SrsConfDirective* pithy = get_pithy_print(); | ||
| 1970 | - if (!pithy) { | ||
| 1971 | - return SRS_CONF_DEFAULT_STAGE_PLAY_USER_INTERVAL_MS; | ||
| 1972 | - } | ||
| 1973 | - | ||
| 1974 | - pithy = pithy->get("play"); | ||
| 1975 | - if (!pithy) { | ||
| 1976 | - return SRS_CONF_DEFAULT_STAGE_PLAY_USER_INTERVAL_MS; | ||
| 1977 | - } | ||
| 1978 | - | ||
| 1979 | - return ::atoi(pithy->arg0().c_str()); | ||
| 1980 | -} | ||
| 1981 | - | ||
| 1982 | -int SrsConfig::get_pithy_print_edge() | ||
| 1983 | -{ | ||
| 1984 | - SrsConfDirective* pithy = get_pithy_print(); | ||
| 1985 | - if (!pithy) { | ||
| 1986 | - return SRS_CONF_DEFAULT_STAGE_EDGE_INTERVAL_MS; | ||
| 1987 | - } | ||
| 1988 | - | ||
| 1989 | - pithy = pithy->get("edge"); | ||
| 1990 | - if (!pithy) { | ||
| 1991 | - return SRS_CONF_DEFAULT_STAGE_EDGE_INTERVAL_MS; | 1876 | + SrsConfDirective* pithy = root->get("pithy_print_ms"); |
| 1877 | + if (!pithy || pithy->arg0().empty()) { | ||
| 1878 | + return SRS_CONF_DEFAULT_PITHY_PRINT_MS; | ||
| 1992 | } | 1879 | } |
| 1993 | 1880 | ||
| 1994 | return ::atoi(pithy->arg0().c_str()); | 1881 | return ::atoi(pithy->arg0().c_str()); |
| @@ -91,13 +91,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -91,13 +91,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 91 | 91 | ||
| 92 | #define SRS_CONF_DEFAULT_STATS_NETWORK_DEVICE_INDEX 0 | 92 | #define SRS_CONF_DEFAULT_STATS_NETWORK_DEVICE_INDEX 0 |
| 93 | 93 | ||
| 94 | -#define SRS_CONF_DEFAULT_STAGE_PLAY_USER_INTERVAL_MS 10000 | ||
| 95 | -#define SRS_CONF_DEFAULT_STAGE_PUBLISH_USER_INTERVAL_MS 10000 | ||
| 96 | -#define SRS_CONF_DEFAULT_STAGE_FORWARDER_INTERVAL_MS 10000 | ||
| 97 | -#define SRS_CONF_DEFAULT_STAGE_ENCODER_INTERVAL_MS 10000 | ||
| 98 | -#define SRS_CONF_DEFAULT_STAGE_INGESTER_INTERVAL_MS 10000 | ||
| 99 | -#define SRS_CONF_DEFAULT_STAGE_HLS_INTERVAL_MS 10000 | ||
| 100 | -#define SRS_CONF_DEFAULT_STAGE_EDGE_INTERVAL_MS 10000 | 94 | +#define SRS_CONF_DEFAULT_PITHY_PRINT_MS 10000 |
| 101 | 95 | ||
| 102 | #define SRS_CONF_DEFAULT_INGEST_TYPE_FILE "file" | 96 | #define SRS_CONF_DEFAULT_INGEST_TYPE_FILE "file" |
| 103 | #define SRS_CONF_DEFAULT_INGEST_TYPE_STREAM "stream" | 97 | #define SRS_CONF_DEFAULT_INGEST_TYPE_STREAM "stream" |
| @@ -419,46 +413,12 @@ public: | @@ -419,46 +413,12 @@ public: | ||
| 419 | * user can use different pid file for each process. | 413 | * user can use different pid file for each process. |
| 420 | */ | 414 | */ |
| 421 | virtual std::string get_pid_file(); | 415 | virtual std::string get_pid_file(); |
| 422 | -// pithy print | ||
| 423 | -private: | ||
| 424 | - virtual SrsConfDirective* get_pithy_print(); | ||
| 425 | -public: | ||
| 426 | - /** | ||
| 427 | - * get the pithy print interval for publish, in ms, | ||
| 428 | - * the publish(flash/FMLE) message print. | ||
| 429 | - */ | ||
| 430 | - virtual int get_pithy_print_publish(); | ||
| 431 | - /** | ||
| 432 | - * get the pithy print interval for forwarder, in ms, | ||
| 433 | - * the forwarder message print, for SRS forward stream to other servers. | ||
| 434 | - */ | ||
| 435 | - virtual int get_pithy_print_forwarder(); | ||
| 436 | - /** | ||
| 437 | - * get the pithy print interval for encoder, in ms, | ||
| 438 | - * the encoder message print, for FFMPEG transcoder. | ||
| 439 | - */ | ||
| 440 | - virtual int get_pithy_print_encoder(); | ||
| 441 | - /** | ||
| 442 | - * get the pithy print interval for ingester, in ms, | ||
| 443 | - * the ingest used FFMPEG, or your tools, to read and transcode other stream | ||
| 444 | - * to RTMP to SRS. | ||
| 445 | - */ | ||
| 446 | - virtual int get_pithy_print_ingester(); | ||
| 447 | - /** | ||
| 448 | - * get the pithy print interval for HLS, in ms, | ||
| 449 | - * the HLS used for IOS/android/PC, SRS will mux RTMP to HLS. | ||
| 450 | - */ | ||
| 451 | - virtual int get_pithy_print_hls(); | ||
| 452 | - /** | ||
| 453 | - * get the pithy print interval for Play, in ms, | ||
| 454 | - * the play is client or edge playing RTMP stream | ||
| 455 | - */ | ||
| 456 | - virtual int get_pithy_print_play(); | ||
| 457 | /** | 416 | /** |
| 458 | - * get the pithy print interval for edge, in ms, | ||
| 459 | - * the edge will get stream from upnode. | 417 | + * get pithy print pulse ms, |
| 418 | + * for example, all rtmp connections only print one message | ||
| 419 | + * every this interval in ms. | ||
| 460 | */ | 420 | */ |
| 461 | - virtual int get_pithy_print_edge(); | 421 | + virtual int get_pithy_print_ms(); |
| 462 | // stream_caster section | 422 | // stream_caster section |
| 463 | public: | 423 | public: |
| 464 | /** | 424 | /** |
| @@ -167,17 +167,18 @@ int SrsEdgeIngester::ingest() | @@ -167,17 +167,18 @@ int SrsEdgeIngester::ingest() | ||
| 167 | 167 | ||
| 168 | client->set_recv_timeout(SRS_EDGE_INGESTER_TIMEOUT_US); | 168 | client->set_recv_timeout(SRS_EDGE_INGESTER_TIMEOUT_US); |
| 169 | 169 | ||
| 170 | - SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_EDGE); | 170 | + SrsPithyPrint* pprint = SrsPithyPrint::create_edge(); |
| 171 | + SrsAutoFree(SrsPithyPrint, pprint); | ||
| 171 | 172 | ||
| 172 | while (pthread->can_loop()) { | 173 | while (pthread->can_loop()) { |
| 173 | - pithy_print.elapse(); | 174 | + pprint->elapse(); |
| 174 | 175 | ||
| 175 | // pithy print | 176 | // pithy print |
| 176 | - if (pithy_print.can_print()) { | 177 | + if (pprint->can_print()) { |
| 177 | kbps->sample(); | 178 | kbps->sample(); |
| 178 | srs_trace("<- "SRS_CONSTS_LOG_EDGE_PLAY | 179 | srs_trace("<- "SRS_CONSTS_LOG_EDGE_PLAY |
| 179 | " time=%"PRId64", okbps=%d,%d,%d, ikbps=%d,%d,%d", | 180 | " time=%"PRId64", okbps=%d,%d,%d, ikbps=%d,%d,%d", |
| 180 | - pithy_print.age(), | 181 | + pprint->age(), |
| 181 | kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(), | 182 | kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(), |
| 182 | kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m()); | 183 | kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m()); |
| 183 | } | 184 | } |
| @@ -473,7 +474,8 @@ int SrsEdgeForwarder::cycle() | @@ -473,7 +474,8 @@ int SrsEdgeForwarder::cycle() | ||
| 473 | 474 | ||
| 474 | client->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US); | 475 | client->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US); |
| 475 | 476 | ||
| 476 | - SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_EDGE); | 477 | + SrsPithyPrint* pprint = SrsPithyPrint::create_edge(); |
| 478 | + SrsAutoFree(SrsPithyPrint, pprint); | ||
| 477 | 479 | ||
| 478 | SrsMessageArray msgs(SYS_MAX_EDGE_SEND_MSGS); | 480 | SrsMessageArray msgs(SYS_MAX_EDGE_SEND_MSGS); |
| 479 | 481 | ||
| @@ -506,14 +508,14 @@ int SrsEdgeForwarder::cycle() | @@ -506,14 +508,14 @@ int SrsEdgeForwarder::cycle() | ||
| 506 | return ret; | 508 | return ret; |
| 507 | } | 509 | } |
| 508 | 510 | ||
| 509 | - pithy_print.elapse(); | 511 | + pprint->elapse(); |
| 510 | 512 | ||
| 511 | // pithy print | 513 | // pithy print |
| 512 | - if (pithy_print.can_print()) { | 514 | + if (pprint->can_print()) { |
| 513 | kbps->sample(); | 515 | kbps->sample(); |
| 514 | srs_trace("-> "SRS_CONSTS_LOG_EDGE_PUBLISH | 516 | srs_trace("-> "SRS_CONSTS_LOG_EDGE_PUBLISH |
| 515 | " time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d", | 517 | " time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d", |
| 516 | - pithy_print.age(), count, | 518 | + pprint->age(), count, |
| 517 | kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(), | 519 | kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(), |
| 518 | kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m()); | 520 | kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m()); |
| 519 | } | 521 | } |
| @@ -45,7 +45,7 @@ static std::vector<std::string> _transcoded_url; | @@ -45,7 +45,7 @@ static std::vector<std::string> _transcoded_url; | ||
| 45 | SrsEncoder::SrsEncoder() | 45 | SrsEncoder::SrsEncoder() |
| 46 | { | 46 | { |
| 47 | pthread = new SrsThread("encoder", this, SRS_RTMP_ENCODER_SLEEP_US, true); | 47 | pthread = new SrsThread("encoder", this, SRS_RTMP_ENCODER_SLEEP_US, true); |
| 48 | - pithy_print = new SrsPithyPrint(SRS_CONSTS_STAGE_ENCODER); | 48 | + pprint = SrsPithyPrint::create_encoder(); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | SrsEncoder::~SrsEncoder() | 51 | SrsEncoder::~SrsEncoder() |
| @@ -53,7 +53,7 @@ SrsEncoder::~SrsEncoder() | @@ -53,7 +53,7 @@ SrsEncoder::~SrsEncoder() | ||
| 53 | on_unpublish(); | 53 | on_unpublish(); |
| 54 | 54 | ||
| 55 | srs_freep(pthread); | 55 | srs_freep(pthread); |
| 56 | - srs_freep(pithy_print); | 56 | + srs_freep(pprint); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | int SrsEncoder::on_publish(SrsRequest* req) | 59 | int SrsEncoder::on_publish(SrsRequest* req) |
| @@ -113,8 +113,7 @@ int SrsEncoder::cycle() | @@ -113,8 +113,7 @@ int SrsEncoder::cycle() | ||
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | // pithy print | 115 | // pithy print |
| 116 | - encoder(); | ||
| 117 | - pithy_print->elapse(); | 116 | + show_encode_log_message(); |
| 118 | 117 | ||
| 119 | return ret; | 118 | return ret; |
| 120 | } | 119 | } |
| @@ -324,13 +323,15 @@ int SrsEncoder::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsRequest* req, SrsConfDir | @@ -324,13 +323,15 @@ int SrsEncoder::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsRequest* req, SrsConfDir | ||
| 324 | return ret; | 323 | return ret; |
| 325 | } | 324 | } |
| 326 | 325 | ||
| 327 | -void SrsEncoder::encoder() | 326 | +void SrsEncoder::show_encode_log_message() |
| 328 | { | 327 | { |
| 328 | + pprint->elapse(); | ||
| 329 | + | ||
| 329 | // reportable | 330 | // reportable |
| 330 | - if (pithy_print->can_print()) { | 331 | + if (pprint->can_print()) { |
| 331 | // TODO: FIXME: show more info. | 332 | // TODO: FIXME: show more info. |
| 332 | srs_trace("-> "SRS_CONSTS_LOG_ENCODER" time=%"PRId64", encoders=%d, input=%s", | 333 | srs_trace("-> "SRS_CONSTS_LOG_ENCODER" time=%"PRId64", encoders=%d, input=%s", |
| 333 | - pithy_print->age(), (int)ffmpegs.size(), input_stream_name.c_str()); | 334 | + pprint->age(), (int)ffmpegs.size(), input_stream_name.c_str()); |
| 334 | } | 335 | } |
| 335 | } | 336 | } |
| 336 | 337 |
| @@ -52,7 +52,7 @@ private: | @@ -52,7 +52,7 @@ private: | ||
| 52 | std::vector<SrsFFMPEG*> ffmpegs; | 52 | std::vector<SrsFFMPEG*> ffmpegs; |
| 53 | private: | 53 | private: |
| 54 | SrsThread* pthread; | 54 | SrsThread* pthread; |
| 55 | - SrsPithyPrint* pithy_print; | 55 | + SrsPithyPrint* pprint; |
| 56 | public: | 56 | public: |
| 57 | SrsEncoder(); | 57 | SrsEncoder(); |
| 58 | virtual ~SrsEncoder(); | 58 | virtual ~SrsEncoder(); |
| @@ -69,7 +69,7 @@ private: | @@ -69,7 +69,7 @@ private: | ||
| 69 | virtual int parse_scope_engines(SrsRequest* req); | 69 | virtual int parse_scope_engines(SrsRequest* req); |
| 70 | virtual int parse_ffmpeg(SrsRequest* req, SrsConfDirective* conf); | 70 | virtual int parse_ffmpeg(SrsRequest* req, SrsConfDirective* conf); |
| 71 | virtual int initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsRequest* req, SrsConfDirective* engine); | 71 | virtual int initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsRequest* req, SrsConfDirective* engine); |
| 72 | - virtual void encoder(); | 72 | + virtual void show_encode_log_message(); |
| 73 | }; | 73 | }; |
| 74 | 74 | ||
| 75 | #endif | 75 | #endif |
| @@ -43,6 +43,7 @@ using namespace std; | @@ -43,6 +43,7 @@ using namespace std; | ||
| 43 | #include <srs_app_utility.hpp> | 43 | #include <srs_app_utility.hpp> |
| 44 | #include <srs_rtmp_amf0.hpp> | 44 | #include <srs_rtmp_amf0.hpp> |
| 45 | #include <srs_kernel_codec.hpp> | 45 | #include <srs_kernel_codec.hpp> |
| 46 | +#include <srs_core_autofree.hpp> | ||
| 46 | 47 | ||
| 47 | // when error, forwarder sleep for a while and retry. | 48 | // when error, forwarder sleep for a while and retry. |
| 48 | #define SRS_FORWARDER_SLEEP_US (int64_t)(3*1000*1000LL) | 49 | #define SRS_FORWARDER_SLEEP_US (int64_t)(3*1000*1000LL) |
| @@ -386,7 +387,8 @@ int SrsForwarder::forward() | @@ -386,7 +387,8 @@ int SrsForwarder::forward() | ||
| 386 | 387 | ||
| 387 | client->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US); | 388 | client->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US); |
| 388 | 389 | ||
| 389 | - SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_FORWARDER); | 390 | + SrsPithyPrint* pprint = SrsPithyPrint::create_forwarder(); |
| 391 | + SrsAutoFree(SrsPithyPrint, pprint); | ||
| 390 | 392 | ||
| 391 | SrsMessageArray msgs(SYS_MAX_FORWARD_SEND_MSGS); | 393 | SrsMessageArray msgs(SYS_MAX_FORWARD_SEND_MSGS); |
| 392 | 394 | ||
| @@ -406,7 +408,7 @@ int SrsForwarder::forward() | @@ -406,7 +408,7 @@ int SrsForwarder::forward() | ||
| 406 | } | 408 | } |
| 407 | 409 | ||
| 408 | while (pthread->can_loop()) { | 410 | while (pthread->can_loop()) { |
| 409 | - pithy_print.elapse(); | 411 | + pprint->elapse(); |
| 410 | 412 | ||
| 411 | // read from client. | 413 | // read from client. |
| 412 | if (true) { | 414 | if (true) { |
| @@ -431,11 +433,11 @@ int SrsForwarder::forward() | @@ -431,11 +433,11 @@ int SrsForwarder::forward() | ||
| 431 | } | 433 | } |
| 432 | 434 | ||
| 433 | // pithy print | 435 | // pithy print |
| 434 | - if (pithy_print.can_print()) { | 436 | + if (pprint->can_print()) { |
| 435 | kbps->sample(); | 437 | kbps->sample(); |
| 436 | srs_trace("-> "SRS_CONSTS_LOG_FOWARDER | 438 | srs_trace("-> "SRS_CONSTS_LOG_FOWARDER |
| 437 | " time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d", | 439 | " time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d", |
| 438 | - pithy_print.age(), count, | 440 | + pprint->age(), count, |
| 439 | kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(), | 441 | kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(), |
| 440 | kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m()); | 442 | kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m()); |
| 441 | } | 443 | } |
| @@ -825,7 +825,7 @@ SrsHls::SrsHls(SrsSource* s, ISrsHlsHandler* h) | @@ -825,7 +825,7 @@ SrsHls::SrsHls(SrsSource* s, ISrsHlsHandler* h) | ||
| 825 | muxer = new SrsHlsMuxer(h); | 825 | muxer = new SrsHlsMuxer(h); |
| 826 | hls_cache = new SrsHlsCache(); | 826 | hls_cache = new SrsHlsCache(); |
| 827 | 827 | ||
| 828 | - pithy_print = new SrsPithyPrint(SRS_CONSTS_STAGE_HLS); | 828 | + pprint = SrsPithyPrint::create_hls(); |
| 829 | stream_dts = 0; | 829 | stream_dts = 0; |
| 830 | } | 830 | } |
| 831 | 831 | ||
| @@ -838,7 +838,7 @@ SrsHls::~SrsHls() | @@ -838,7 +838,7 @@ SrsHls::~SrsHls() | ||
| 838 | srs_freep(muxer); | 838 | srs_freep(muxer); |
| 839 | srs_freep(hls_cache); | 839 | srs_freep(hls_cache); |
| 840 | 840 | ||
| 841 | - srs_freep(pithy_print); | 841 | + srs_freep(pprint); |
| 842 | } | 842 | } |
| 843 | 843 | ||
| 844 | int SrsHls::on_publish(SrsRequest* req) | 844 | int SrsHls::on_publish(SrsRequest* req) |
| @@ -1012,24 +1012,25 @@ int SrsHls::on_video(SrsSharedPtrMessage* __video) | @@ -1012,24 +1012,25 @@ int SrsHls::on_video(SrsSharedPtrMessage* __video) | ||
| 1012 | return ret; | 1012 | return ret; |
| 1013 | } | 1013 | } |
| 1014 | 1014 | ||
| 1015 | - hls_mux(); | 1015 | + // pithy print message. |
| 1016 | + hls_show_mux_log(); | ||
| 1016 | 1017 | ||
| 1017 | return ret; | 1018 | return ret; |
| 1018 | } | 1019 | } |
| 1019 | 1020 | ||
| 1020 | -void SrsHls::hls_mux() | 1021 | +void SrsHls::hls_show_mux_log() |
| 1021 | { | 1022 | { |
| 1023 | + pprint->elapse(); | ||
| 1024 | + | ||
| 1022 | // reportable | 1025 | // reportable |
| 1023 | - if (pithy_print->can_print()) { | 1026 | + if (pprint->can_print()) { |
| 1024 | // the run time is not equals to stream time, | 1027 | // the run time is not equals to stream time, |
| 1025 | // @see: https://github.com/winlinvip/simple-rtmp-server/issues/81#issuecomment-48100994 | 1028 | // @see: https://github.com/winlinvip/simple-rtmp-server/issues/81#issuecomment-48100994 |
| 1026 | // it's ok. | 1029 | // it's ok. |
| 1027 | srs_trace("-> "SRS_CONSTS_LOG_HLS | 1030 | srs_trace("-> "SRS_CONSTS_LOG_HLS |
| 1028 | " time=%"PRId64", stream dts=%"PRId64"(%"PRId64"ms), sequence_no=%d", | 1031 | " time=%"PRId64", stream dts=%"PRId64"(%"PRId64"ms), sequence_no=%d", |
| 1029 | - pithy_print->age(), stream_dts, stream_dts / 90, muxer->sequence_no()); | 1032 | + pprint->age(), stream_dts, stream_dts / 90, muxer->sequence_no()); |
| 1030 | } | 1033 | } |
| 1031 | - | ||
| 1032 | - pithy_print->elapse(); | ||
| 1033 | } | 1034 | } |
| 1034 | 1035 | ||
| 1035 | #endif | 1036 | #endif |
| @@ -309,7 +309,7 @@ private: | @@ -309,7 +309,7 @@ private: | ||
| 309 | SrsAvcAacCodec* codec; | 309 | SrsAvcAacCodec* codec; |
| 310 | SrsCodecSample* sample; | 310 | SrsCodecSample* sample; |
| 311 | SrsRtmpJitter* jitter; | 311 | SrsRtmpJitter* jitter; |
| 312 | - SrsPithyPrint* pithy_print; | 312 | + SrsPithyPrint* pprint; |
| 313 | /** | 313 | /** |
| 314 | * we store the stream dts, | 314 | * we store the stream dts, |
| 315 | * for when we notice the hls cache to publish, | 315 | * for when we notice the hls cache to publish, |
| @@ -353,7 +353,7 @@ public: | @@ -353,7 +353,7 @@ public: | ||
| 353 | */ | 353 | */ |
| 354 | virtual int on_video(SrsSharedPtrMessage* __video); | 354 | virtual int on_video(SrsSharedPtrMessage* __video); |
| 355 | private: | 355 | private: |
| 356 | - virtual void hls_mux(); | 356 | + virtual void hls_show_mux_log(); |
| 357 | }; | 357 | }; |
| 358 | 358 | ||
| 359 | #endif | 359 | #endif |
| @@ -47,6 +47,7 @@ using namespace std; | @@ -47,6 +47,7 @@ using namespace std; | ||
| 47 | #include <srs_kernel_aac.hpp> | 47 | #include <srs_kernel_aac.hpp> |
| 48 | #include <srs_kernel_mp3.hpp> | 48 | #include <srs_kernel_mp3.hpp> |
| 49 | #include <srs_kernel_ts.hpp> | 49 | #include <srs_kernel_ts.hpp> |
| 50 | +#include <srs_app_pithy_print.hpp> | ||
| 50 | 51 | ||
| 51 | SrsVodStream::SrsVodStream(string root_dir) | 52 | SrsVodStream::SrsVodStream(string root_dir) |
| 52 | : SrsGoHttpFileServer(root_dir) | 53 | : SrsGoHttpFileServer(root_dir) |
| @@ -248,10 +249,12 @@ int SrsStreamCache::cycle() | @@ -248,10 +249,12 @@ int SrsStreamCache::cycle() | ||
| 248 | return ret; | 249 | return ret; |
| 249 | } | 250 | } |
| 250 | SrsAutoFree(SrsConsumer, consumer); | 251 | SrsAutoFree(SrsConsumer, consumer); |
| 252 | + | ||
| 253 | + SrsPithyPrint* pprint = SrsPithyPrint::create_http_stream_cache(); | ||
| 254 | + SrsAutoFree(SrsPithyPrint, pprint); | ||
| 251 | 255 | ||
| 252 | SrsMessageArray msgs(SRS_PERF_MW_MSGS); | 256 | SrsMessageArray msgs(SRS_PERF_MW_MSGS); |
| 253 | - // TODO: FIMXE: add pithy print. | ||
| 254 | - | 257 | + |
| 255 | // TODO: FIXME: support reload. | 258 | // TODO: FIXME: support reload. |
| 256 | double fast_cache = _srs_config->get_vhost_http_remux_fast_cache(req->vhost); | 259 | double fast_cache = _srs_config->get_vhost_http_remux_fast_cache(req->vhost); |
| 257 | if (fast_cache > 0) { | 260 | if (fast_cache > 0) { |
| @@ -259,6 +262,8 @@ int SrsStreamCache::cycle() | @@ -259,6 +262,8 @@ int SrsStreamCache::cycle() | ||
| 259 | } | 262 | } |
| 260 | 263 | ||
| 261 | while (true) { | 264 | while (true) { |
| 265 | + pprint->elapse(); | ||
| 266 | + | ||
| 262 | // get messages from consumer. | 267 | // get messages from consumer. |
| 263 | // each msg in msgs.msgs must be free, for the SrsMessageArray never free them. | 268 | // each msg in msgs.msgs must be free, for the SrsMessageArray never free them. |
| 264 | int count = 0; | 269 | int count = 0; |
| @@ -275,8 +280,11 @@ int SrsStreamCache::cycle() | @@ -275,8 +280,11 @@ int SrsStreamCache::cycle() | ||
| 275 | // ignore when nothing got. | 280 | // ignore when nothing got. |
| 276 | continue; | 281 | continue; |
| 277 | } | 282 | } |
| 278 | - srs_info("http: got %d msgs, min=%d, mw=%d", count, | ||
| 279 | - SRS_PERF_MW_MIN_MSGS, SRS_CONSTS_RTMP_PULSE_TIMEOUT_US / 1000); | 283 | + |
| 284 | + if (pprint->can_print()) { | ||
| 285 | + srs_trace("-> "SRS_CONSTS_LOG_HTTP_STREAM_CACHE" http: got %d msgs, age=%d, min=%d, mw=%d", | ||
| 286 | + pprint->age(), count, SRS_PERF_MW_MIN_MSGS, SRS_CONSTS_RTMP_PULSE_TIMEOUT_US / 1000); | ||
| 287 | + } | ||
| 280 | 288 | ||
| 281 | // free the messages. | 289 | // free the messages. |
| 282 | for (int i = 0; i < count; i++) { | 290 | for (int i = 0; i < count; i++) { |
| @@ -591,9 +599,11 @@ int SrsLiveStream::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) | @@ -591,9 +599,11 @@ int SrsLiveStream::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) | ||
| 591 | } | 599 | } |
| 592 | SrsAutoFree(SrsConsumer, consumer); | 600 | SrsAutoFree(SrsConsumer, consumer); |
| 593 | srs_verbose("http: consumer created success."); | 601 | srs_verbose("http: consumer created success."); |
| 602 | + | ||
| 603 | + SrsPithyPrint* pprint = SrsPithyPrint::create_http_stream(); | ||
| 604 | + SrsAutoFree(SrsPithyPrint, pprint); | ||
| 594 | 605 | ||
| 595 | SrsMessageArray msgs(SRS_PERF_MW_MSGS); | 606 | SrsMessageArray msgs(SRS_PERF_MW_MSGS); |
| 596 | - // TODO: FIMXE: add pithy print. | ||
| 597 | 607 | ||
| 598 | // the memory writer. | 608 | // the memory writer. |
| 599 | SrsStreamWriter writer(w); | 609 | SrsStreamWriter writer(w); |
| @@ -611,6 +621,8 @@ int SrsLiveStream::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) | @@ -611,6 +621,8 @@ int SrsLiveStream::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) | ||
| 611 | } | 621 | } |
| 612 | 622 | ||
| 613 | while (true) { | 623 | while (true) { |
| 624 | + pprint->elapse(); | ||
| 625 | + | ||
| 614 | // get messages from consumer. | 626 | // get messages from consumer. |
| 615 | // each msg in msgs.msgs must be free, for the SrsMessageArray never free them. | 627 | // each msg in msgs.msgs must be free, for the SrsMessageArray never free them. |
| 616 | int count = 0; | 628 | int count = 0; |
| @@ -627,8 +639,11 @@ int SrsLiveStream::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) | @@ -627,8 +639,11 @@ int SrsLiveStream::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r) | ||
| 627 | // ignore when nothing got. | 639 | // ignore when nothing got. |
| 628 | continue; | 640 | continue; |
| 629 | } | 641 | } |
| 630 | - srs_info("http: got %d msgs, min=%d, mw=%d", count, | ||
| 631 | - SRS_PERF_MW_MIN_MSGS, SRS_CONSTS_RTMP_PULSE_TIMEOUT_US / 1000); | 642 | + |
| 643 | + if (pprint->can_print()) { | ||
| 644 | + srs_info("-> "SRS_CONSTS_LOG_HTTP_STREAM" http: got %d msgs, age=%d, min=%d, mw=%d", | ||
| 645 | + pprint->age(), count, SRS_PERF_MW_MIN_MSGS, SRS_CONSTS_RTMP_PULSE_TIMEOUT_US / 1000); | ||
| 646 | + } | ||
| 632 | 647 | ||
| 633 | // sendout all messages. | 648 | // sendout all messages. |
| 634 | ret = streaming_send_messages(enc, msgs.msgs, count); | 649 | ret = streaming_send_messages(enc, msgs.msgs, count); |
| @@ -55,7 +55,7 @@ SrsIngester::SrsIngester() | @@ -55,7 +55,7 @@ SrsIngester::SrsIngester() | ||
| 55 | _srs_config->subscribe(this); | 55 | _srs_config->subscribe(this); |
| 56 | 56 | ||
| 57 | pthread = new SrsThread("ingest", this, SRS_AUTO_INGESTER_SLEEP_US, true); | 57 | pthread = new SrsThread("ingest", this, SRS_AUTO_INGESTER_SLEEP_US, true); |
| 58 | - pithy_print = new SrsPithyPrint(SRS_CONSTS_STAGE_INGESTER); | 58 | + pprint = SrsPithyPrint::create_ingester(); |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | SrsIngester::~SrsIngester() | 61 | SrsIngester::~SrsIngester() |
| @@ -186,8 +186,7 @@ int SrsIngester::cycle() | @@ -186,8 +186,7 @@ int SrsIngester::cycle() | ||
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | // pithy print | 188 | // pithy print |
| 189 | - ingester(); | ||
| 190 | - pithy_print->elapse(); | 189 | + show_ingest_log_message(); |
| 191 | 190 | ||
| 192 | return ret; | 191 | return ret; |
| 193 | } | 192 | } |
| @@ -340,17 +339,19 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S | @@ -340,17 +339,19 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S | ||
| 340 | return ret; | 339 | return ret; |
| 341 | } | 340 | } |
| 342 | 341 | ||
| 343 | -void SrsIngester::ingester() | 342 | +void SrsIngester::show_ingest_log_message() |
| 344 | { | 343 | { |
| 344 | + pprint->elapse(); | ||
| 345 | + | ||
| 345 | if ((int)ingesters.size() <= 0) { | 346 | if ((int)ingesters.size() <= 0) { |
| 346 | return; | 347 | return; |
| 347 | } | 348 | } |
| 348 | 349 | ||
| 349 | // reportable | 350 | // reportable |
| 350 | - if (pithy_print->can_print()) { | 351 | + if (pprint->can_print()) { |
| 351 | // TODO: FIXME: show more info. | 352 | // TODO: FIXME: show more info. |
| 352 | srs_trace("-> "SRS_CONSTS_LOG_INGESTER | 353 | srs_trace("-> "SRS_CONSTS_LOG_INGESTER |
| 353 | - " time=%"PRId64", ingesters=%d", pithy_print->age(), (int)ingesters.size()); | 354 | + " time=%"PRId64", ingesters=%d", pprint->age(), (int)ingesters.size()); |
| 354 | } | 355 | } |
| 355 | } | 356 | } |
| 356 | 357 |
| @@ -65,7 +65,7 @@ private: | @@ -65,7 +65,7 @@ private: | ||
| 65 | std::vector<SrsIngesterFFMPEG*> ingesters; | 65 | std::vector<SrsIngesterFFMPEG*> ingesters; |
| 66 | private: | 66 | private: |
| 67 | SrsThread* pthread; | 67 | SrsThread* pthread; |
| 68 | - SrsPithyPrint* pithy_print; | 68 | + SrsPithyPrint* pprint; |
| 69 | public: | 69 | public: |
| 70 | SrsIngester(); | 70 | SrsIngester(); |
| 71 | virtual ~SrsIngester(); | 71 | virtual ~SrsIngester(); |
| @@ -82,7 +82,7 @@ private: | @@ -82,7 +82,7 @@ private: | ||
| 82 | virtual int parse_ingesters(SrsConfDirective* vhost); | 82 | virtual int parse_ingesters(SrsConfDirective* vhost); |
| 83 | virtual int parse_engines(SrsConfDirective* vhost, SrsConfDirective* ingest); | 83 | virtual int parse_engines(SrsConfDirective* vhost, SrsConfDirective* ingest); |
| 84 | virtual int initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, SrsConfDirective* ingest, SrsConfDirective* engine); | 84 | virtual int initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, SrsConfDirective* ingest, SrsConfDirective* engine); |
| 85 | - virtual void ingester(); | 85 | + virtual void show_ingest_log_message(); |
| 86 | // interface ISrsReloadHandler. | 86 | // interface ISrsReloadHandler. |
| 87 | public: | 87 | public: |
| 88 | virtual int on_reload_vhost_removed(std::string vhost); | 88 | virtual int on_reload_vhost_removed(std::string vhost); |
| @@ -48,6 +48,7 @@ using namespace std; | @@ -48,6 +48,7 @@ using namespace std; | ||
| 48 | #include <srs_app_utility.hpp> | 48 | #include <srs_app_utility.hpp> |
| 49 | #include <srs_rtmp_amf0.hpp> | 49 | #include <srs_rtmp_amf0.hpp> |
| 50 | #include <srs_raw_avc.hpp> | 50 | #include <srs_raw_avc.hpp> |
| 51 | +#include <srs_app_pithy_print.hpp> | ||
| 51 | 52 | ||
| 52 | SrsMpegtsQueue::SrsMpegtsQueue() | 53 | SrsMpegtsQueue::SrsMpegtsQueue() |
| 53 | { | 54 | { |
| @@ -140,6 +141,7 @@ SrsMpegtsOverUdp::SrsMpegtsOverUdp(SrsConfDirective* c) | @@ -140,6 +141,7 @@ SrsMpegtsOverUdp::SrsMpegtsOverUdp(SrsConfDirective* c) | ||
| 140 | h264_pps_changed = false; | 141 | h264_pps_changed = false; |
| 141 | h264_sps_pps_sent = false; | 142 | h264_sps_pps_sent = false; |
| 142 | queue = new SrsMpegtsQueue(); | 143 | queue = new SrsMpegtsQueue(); |
| 144 | + pprint = SrsPithyPrint::create_caster(); | ||
| 143 | } | 145 | } |
| 144 | 146 | ||
| 145 | SrsMpegtsOverUdp::~SrsMpegtsOverUdp() | 147 | SrsMpegtsOverUdp::~SrsMpegtsOverUdp() |
| @@ -152,6 +154,7 @@ SrsMpegtsOverUdp::~SrsMpegtsOverUdp() | @@ -152,6 +154,7 @@ SrsMpegtsOverUdp::~SrsMpegtsOverUdp() | ||
| 152 | srs_freep(avc); | 154 | srs_freep(avc); |
| 153 | srs_freep(aac); | 155 | srs_freep(aac); |
| 154 | srs_freep(queue); | 156 | srs_freep(queue); |
| 157 | + srs_freep(pprint); | ||
| 155 | } | 158 | } |
| 156 | 159 | ||
| 157 | int SrsMpegtsOverUdp::on_udp_packet(sockaddr_in* from, char* buf, int nb_buf) | 160 | int SrsMpegtsOverUdp::on_udp_packet(sockaddr_in* from, char* buf, int nb_buf) |
| @@ -246,6 +249,8 @@ int SrsMpegtsOverUdp::on_ts_message(SrsTsMessage* msg) | @@ -246,6 +249,8 @@ int SrsMpegtsOverUdp::on_ts_message(SrsTsMessage* msg) | ||
| 246 | { | 249 | { |
| 247 | int ret = ERROR_SUCCESS; | 250 | int ret = ERROR_SUCCESS; |
| 248 | 251 | ||
| 252 | + pprint->elapse(); | ||
| 253 | + | ||
| 249 | // about the bytes of msg, specified by elementary stream which indicates by PES_packet_data_byte and stream_id | 254 | // about the bytes of msg, specified by elementary stream which indicates by PES_packet_data_byte and stream_id |
| 250 | // for example, when SrsTsStream of SrsTsChannel indicates stream_type is SrsTsStreamVideoMpeg4 and SrsTsStreamAudioMpeg4, | 255 | // for example, when SrsTsStream of SrsTsChannel indicates stream_type is SrsTsStreamVideoMpeg4 and SrsTsStreamAudioMpeg4, |
| 251 | // the elementary stream can be mux in "2.11 Carriage of ISO/IEC 14496 data" in hls-mpeg-ts-iso13818-1.pdf, page 103 | 256 | // the elementary stream can be mux in "2.11 Carriage of ISO/IEC 14496 data" in hls-mpeg-ts-iso13818-1.pdf, page 103 |
| @@ -283,11 +288,12 @@ int SrsMpegtsOverUdp::on_ts_message(SrsTsMessage* msg) | @@ -283,11 +288,12 @@ int SrsMpegtsOverUdp::on_ts_message(SrsTsMessage* msg) | ||
| 283 | // 14496-2 video stream number xxxx | 288 | // 14496-2 video stream number xxxx |
| 284 | // ((stream_id >> 4) & 0x0f) == SrsTsPESStreamIdVideo | 289 | // ((stream_id >> 4) & 0x0f) == SrsTsPESStreamIdVideo |
| 285 | 290 | ||
| 286 | - // TODO: FIXME: support pithy print. | ||
| 287 | - srs_info("mpegts: got %s stream=%s, dts=%"PRId64", pts=%"PRId64", size=%d, us=%d, cc=%d, sid=%#x(%s-%d)", | ||
| 288 | - (msg->channel->apply == SrsTsPidApplyVideo)? "Video":"Audio", srs_ts_stream2string(msg->channel->stream).c_str(), | ||
| 289 | - msg->dts, msg->pts, msg->payload->length(), msg->packet->payload_unit_start_indicator, msg->continuity_counter, msg->sid, | ||
| 290 | - msg->is_audio()? "A":msg->is_video()? "V":"N", msg->stream_number()); | 291 | + if (pprint->can_print()) { |
| 292 | + srs_trace("<- "SRS_CONSTS_LOG_STREAM_CASTER" mpegts: got %s age=%d stream=%s, dts=%"PRId64", pts=%"PRId64", size=%d, us=%d, cc=%d, sid=%#x(%s-%d)", | ||
| 293 | + (msg->channel->apply == SrsTsPidApplyVideo)? "Video":"Audio", pprint->age(), srs_ts_stream2string(msg->channel->stream).c_str(), | ||
| 294 | + msg->dts, msg->pts, msg->payload->length(), msg->packet->payload_unit_start_indicator, msg->continuity_counter, msg->sid, | ||
| 295 | + msg->is_audio()? "A":msg->is_video()? "V":"N", msg->stream_number()); | ||
| 296 | + } | ||
| 291 | 297 | ||
| 292 | // when not audio/video, or not adts/annexb format, donot support. | 298 | // when not audio/video, or not adts/annexb format, donot support. |
| 293 | if (msg->stream_number() != 0) { | 299 | if (msg->stream_number() != 0) { |
| @@ -557,9 +563,10 @@ int SrsMpegtsOverUdp::rtmp_write_packet(char type, u_int32_t timestamp, char* da | @@ -557,9 +563,10 @@ int SrsMpegtsOverUdp::rtmp_write_packet(char type, u_int32_t timestamp, char* da | ||
| 557 | break; | 563 | break; |
| 558 | } | 564 | } |
| 559 | 565 | ||
| 560 | - // TODO: FIXME: use pithy print. | ||
| 561 | - srs_info("mpegts: send msg %s dts=%"PRId64", size=%d", | ||
| 562 | - msg->is_audio()? "A":msg->is_video()? "V":"N", msg->timestamp, msg->size); | 566 | + if (pprint->can_print()) { |
| 567 | + srs_trace("mpegts: send msg %s age=%d, dts=%"PRId64", size=%d", | ||
| 568 | + msg->is_audio()? "A":msg->is_video()? "V":"N", pprint->age(), msg->timestamp, msg->size); | ||
| 569 | + } | ||
| 563 | 570 | ||
| 564 | // send out encoded msg. | 571 | // send out encoded msg. |
| 565 | if ((ret = client->send_and_free_message(msg, stream_id)) != ERROR_SUCCESS) { | 572 | if ((ret = client->send_and_free_message(msg, stream_id)) != ERROR_SUCCESS) { |
| @@ -47,6 +47,7 @@ class SrsRawH264Stream; | @@ -47,6 +47,7 @@ class SrsRawH264Stream; | ||
| 47 | class SrsSharedPtrMessage; | 47 | class SrsSharedPtrMessage; |
| 48 | class SrsRawAacStream; | 48 | class SrsRawAacStream; |
| 49 | class SrsRawAacStreamCodec; | 49 | class SrsRawAacStreamCodec; |
| 50 | +class SrsPithyPrint; | ||
| 50 | 51 | ||
| 51 | #include <srs_app_st.hpp> | 52 | #include <srs_app_st.hpp> |
| 52 | #include <srs_kernel_ts.hpp> | 53 | #include <srs_kernel_ts.hpp> |
| @@ -101,6 +102,7 @@ private: | @@ -101,6 +102,7 @@ private: | ||
| 101 | std::string aac_specific_config; | 102 | std::string aac_specific_config; |
| 102 | private: | 103 | private: |
| 103 | SrsMpegtsQueue* queue; | 104 | SrsMpegtsQueue* queue; |
| 105 | + SrsPithyPrint* pprint; | ||
| 104 | public: | 106 | public: |
| 105 | SrsMpegtsOverUdp(SrsConfDirective* c); | 107 | SrsMpegtsOverUdp(SrsConfDirective* c); |
| 106 | virtual ~SrsMpegtsOverUdp(); | 108 | virtual ~SrsMpegtsOverUdp(); |
| @@ -31,8 +31,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,8 +31,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | #include <srs_kernel_error.hpp> | 31 | #include <srs_kernel_error.hpp> |
| 32 | #include <srs_kernel_utility.hpp> | 32 | #include <srs_kernel_utility.hpp> |
| 33 | 33 | ||
| 34 | -#define SRS_CONSTS_STAGE_DEFAULT_INTERVAL_MS 1200 | ||
| 35 | - | ||
| 36 | SrsStageInfo::SrsStageInfo(int _stage_id) | 34 | SrsStageInfo::SrsStageInfo(int _stage_id) |
| 37 | { | 35 | { |
| 38 | stage_id = _stage_id; | 36 | stage_id = _stage_id; |
| @@ -51,40 +49,7 @@ SrsStageInfo::~SrsStageInfo() | @@ -51,40 +49,7 @@ SrsStageInfo::~SrsStageInfo() | ||
| 51 | 49 | ||
| 52 | void SrsStageInfo::update_print_time() | 50 | void SrsStageInfo::update_print_time() |
| 53 | { | 51 | { |
| 54 | - switch (stage_id) { | ||
| 55 | - case SRS_CONSTS_STAGE_PLAY_USER: { | ||
| 56 | - pithy_print_time_ms = _srs_config->get_pithy_print_play(); | ||
| 57 | - break; | ||
| 58 | - } | ||
| 59 | - case SRS_CONSTS_STAGE_PUBLISH_USER: { | ||
| 60 | - pithy_print_time_ms = _srs_config->get_pithy_print_publish(); | ||
| 61 | - break; | ||
| 62 | - } | ||
| 63 | - case SRS_CONSTS_STAGE_FORWARDER: { | ||
| 64 | - pithy_print_time_ms = _srs_config->get_pithy_print_forwarder(); | ||
| 65 | - break; | ||
| 66 | - } | ||
| 67 | - case SRS_CONSTS_STAGE_ENCODER: { | ||
| 68 | - pithy_print_time_ms = _srs_config->get_pithy_print_encoder(); | ||
| 69 | - break; | ||
| 70 | - } | ||
| 71 | - case SRS_CONSTS_STAGE_INGESTER: { | ||
| 72 | - pithy_print_time_ms = _srs_config->get_pithy_print_ingester(); | ||
| 73 | - break; | ||
| 74 | - } | ||
| 75 | - case SRS_CONSTS_STAGE_EDGE: { | ||
| 76 | - pithy_print_time_ms = _srs_config->get_pithy_print_edge(); | ||
| 77 | - break; | ||
| 78 | - } | ||
| 79 | - case SRS_CONSTS_STAGE_HLS: { | ||
| 80 | - pithy_print_time_ms = _srs_config->get_pithy_print_hls(); | ||
| 81 | - break; | ||
| 82 | - } | ||
| 83 | - default: { | ||
| 84 | - pithy_print_time_ms = SRS_CONSTS_STAGE_DEFAULT_INTERVAL_MS; | ||
| 85 | - break; | ||
| 86 | - } | ||
| 87 | - } | 52 | + pithy_print_time_ms = _srs_config->get_pithy_print_ms(); |
| 88 | } | 53 | } |
| 89 | 54 | ||
| 90 | void SrsStageInfo::elapse(int64_t diff) | 55 | void SrsStageInfo::elapse(int64_t diff) |
| @@ -120,6 +85,80 @@ SrsPithyPrint::SrsPithyPrint(int _stage_id) | @@ -120,6 +85,80 @@ SrsPithyPrint::SrsPithyPrint(int _stage_id) | ||
| 120 | _age = 0; | 85 | _age = 0; |
| 121 | } | 86 | } |
| 122 | 87 | ||
| 88 | +/////////////////////////////////////////////////////////// | ||
| 89 | +// pithy-print consts values | ||
| 90 | +/////////////////////////////////////////////////////////// | ||
| 91 | +// the pithy stage for all play clients. | ||
| 92 | +#define SRS_CONSTS_STAGE_PLAY_USER 1 | ||
| 93 | +// the pithy stage for all publish clients. | ||
| 94 | +#define SRS_CONSTS_STAGE_PUBLISH_USER 2 | ||
| 95 | +// the pithy stage for all forward clients. | ||
| 96 | +#define SRS_CONSTS_STAGE_FORWARDER 3 | ||
| 97 | +// the pithy stage for all encoders. | ||
| 98 | +#define SRS_CONSTS_STAGE_ENCODER 4 | ||
| 99 | +// the pithy stage for all hls. | ||
| 100 | +#define SRS_CONSTS_STAGE_HLS 5 | ||
| 101 | +// the pithy stage for all ingesters. | ||
| 102 | +#define SRS_CONSTS_STAGE_INGESTER 6 | ||
| 103 | +// the pithy stage for all edge. | ||
| 104 | +#define SRS_CONSTS_STAGE_EDGE 7 | ||
| 105 | +// the pithy stage for all stream caster. | ||
| 106 | +#define SRS_CONSTS_STAGE_CASTER 8 | ||
| 107 | +// the pithy stage for all http stream. | ||
| 108 | +#define SRS_CONSTS_STAGE_HTTP_STREAM 9 | ||
| 109 | +// the pithy stage for all http stream cache. | ||
| 110 | +#define SRS_CONSTS_STAGE_HTTP_STREAM_CACHE 10 | ||
| 111 | + | ||
| 112 | +SrsPithyPrint* SrsPithyPrint::create_rtmp_play() | ||
| 113 | +{ | ||
| 114 | + return new SrsPithyPrint(SRS_CONSTS_STAGE_PLAY_USER); | ||
| 115 | +} | ||
| 116 | + | ||
| 117 | +SrsPithyPrint* SrsPithyPrint::create_rtmp_publish() | ||
| 118 | +{ | ||
| 119 | + return new SrsPithyPrint(SRS_CONSTS_STAGE_PUBLISH_USER); | ||
| 120 | +} | ||
| 121 | + | ||
| 122 | +SrsPithyPrint* SrsPithyPrint::create_hls() | ||
| 123 | +{ | ||
| 124 | + return new SrsPithyPrint(SRS_CONSTS_STAGE_HLS); | ||
| 125 | +} | ||
| 126 | + | ||
| 127 | +SrsPithyPrint* SrsPithyPrint::create_forwarder() | ||
| 128 | +{ | ||
| 129 | + return new SrsPithyPrint(SRS_CONSTS_STAGE_FORWARDER); | ||
| 130 | +} | ||
| 131 | + | ||
| 132 | +SrsPithyPrint* SrsPithyPrint::create_encoder() | ||
| 133 | +{ | ||
| 134 | + return new SrsPithyPrint(SRS_CONSTS_STAGE_ENCODER); | ||
| 135 | +} | ||
| 136 | + | ||
| 137 | +SrsPithyPrint* SrsPithyPrint::create_ingester() | ||
| 138 | +{ | ||
| 139 | + return new SrsPithyPrint(SRS_CONSTS_STAGE_INGESTER); | ||
| 140 | +} | ||
| 141 | + | ||
| 142 | +SrsPithyPrint* SrsPithyPrint::create_edge() | ||
| 143 | +{ | ||
| 144 | + return new SrsPithyPrint(SRS_CONSTS_STAGE_EDGE); | ||
| 145 | +} | ||
| 146 | + | ||
| 147 | +SrsPithyPrint* SrsPithyPrint::create_caster() | ||
| 148 | +{ | ||
| 149 | + return new SrsPithyPrint(SRS_CONSTS_STAGE_CASTER); | ||
| 150 | +} | ||
| 151 | + | ||
| 152 | +SrsPithyPrint* SrsPithyPrint::create_http_stream() | ||
| 153 | +{ | ||
| 154 | + return new SrsPithyPrint(SRS_CONSTS_STAGE_HTTP_STREAM); | ||
| 155 | +} | ||
| 156 | + | ||
| 157 | +SrsPithyPrint* SrsPithyPrint::create_http_stream_cache() | ||
| 158 | +{ | ||
| 159 | + return new SrsPithyPrint(SRS_CONSTS_STAGE_HTTP_STREAM_CACHE); | ||
| 160 | +} | ||
| 161 | + | ||
| 123 | SrsPithyPrint::~SrsPithyPrint() | 162 | SrsPithyPrint::~SrsPithyPrint() |
| 124 | { | 163 | { |
| 125 | leave_stage(); | 164 | leave_stage(); |
| @@ -32,6 +32,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -32,6 +32,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 32 | 32 | ||
| 33 | #include <srs_app_reload.hpp> | 33 | #include <srs_app_reload.hpp> |
| 34 | 34 | ||
| 35 | +/** | ||
| 36 | +* the stage info to calc the age. | ||
| 37 | +*/ | ||
| 35 | class SrsStageInfo : public ISrsReloadHandler | 38 | class SrsStageInfo : public ISrsReloadHandler |
| 36 | { | 39 | { |
| 37 | public: | 40 | public: |
| @@ -56,6 +59,17 @@ public: | @@ -56,6 +59,17 @@ public: | ||
| 56 | * the print time in a stage is constant and not changed. | 59 | * the print time in a stage is constant and not changed. |
| 57 | * for example, stage #1 for all play clients, print time is 3s, | 60 | * for example, stage #1 for all play clients, print time is 3s, |
| 58 | * if there is 10clients, then all clients should print in 10*3s. | 61 | * if there is 10clients, then all clients should print in 10*3s. |
| 62 | +* Usage: | ||
| 63 | + SrsPithyPrint* pprint = SrsPithyPrint::create_rtmp_play(); | ||
| 64 | + SrsAutoFree(SrsPithyPrint, pprint); | ||
| 65 | + while (true) { | ||
| 66 | + pprint->elapse(); | ||
| 67 | + if (pprint->can_print()) { | ||
| 68 | + // print pithy message. | ||
| 69 | + // user can get the elapse time by: pprint->age() | ||
| 70 | + } | ||
| 71 | + // read and write RTMP messages. | ||
| 72 | + } | ||
| 59 | */ | 73 | */ |
| 60 | class SrsPithyPrint | 74 | class SrsPithyPrint |
| 61 | { | 75 | { |
| @@ -65,11 +79,19 @@ private: | @@ -65,11 +79,19 @@ private: | ||
| 65 | // in ms. | 79 | // in ms. |
| 66 | int64_t _age; | 80 | int64_t _age; |
| 67 | int64_t previous_tick; | 81 | int64_t previous_tick; |
| 68 | -public: | ||
| 69 | - /** | ||
| 70 | - * @param _stage_id defined in SRS_CONSTS_STAGE_xxx, eg. SRS_CONSTS_STAGE_PLAY_USER. | ||
| 71 | - */ | 82 | +private: |
| 72 | SrsPithyPrint(int _stage_id); | 83 | SrsPithyPrint(int _stage_id); |
| 84 | +public: | ||
| 85 | + static SrsPithyPrint* create_rtmp_play(); | ||
| 86 | + static SrsPithyPrint* create_rtmp_publish(); | ||
| 87 | + static SrsPithyPrint* create_hls(); | ||
| 88 | + static SrsPithyPrint* create_forwarder(); | ||
| 89 | + static SrsPithyPrint* create_encoder(); | ||
| 90 | + static SrsPithyPrint* create_ingester(); | ||
| 91 | + static SrsPithyPrint* create_edge(); | ||
| 92 | + static SrsPithyPrint* create_caster(); | ||
| 93 | + static SrsPithyPrint* create_http_stream(); | ||
| 94 | + static SrsPithyPrint* create_http_stream_cache(); | ||
| 73 | virtual ~SrsPithyPrint(); | 95 | virtual ~SrsPithyPrint(); |
| 74 | private: | 96 | private: |
| 75 | /** | 97 | /** |
| @@ -608,7 +608,9 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe | @@ -608,7 +608,9 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe | ||
| 608 | srs_verbose("check play_refer success."); | 608 | srs_verbose("check play_refer success."); |
| 609 | 609 | ||
| 610 | // initialize other components | 610 | // initialize other components |
| 611 | - SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_PLAY_USER); | 611 | + SrsPithyPrint* pprint = SrsPithyPrint::create_rtmp_play(); |
| 612 | + SrsAutoFree(SrsPithyPrint, pprint); | ||
| 613 | + | ||
| 612 | SrsMessageArray msgs(SRS_PERF_MW_MSGS); | 614 | SrsMessageArray msgs(SRS_PERF_MW_MSGS); |
| 613 | bool user_specified_duration_to_stop = (req->duration > 0); | 615 | bool user_specified_duration_to_stop = (req->duration > 0); |
| 614 | int64_t starttime = -1; | 616 | int64_t starttime = -1; |
| @@ -621,6 +623,9 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe | @@ -621,6 +623,9 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe | ||
| 621 | change_mw_sleep(_srs_config->get_mw_sleep_ms(req->vhost)); | 623 | change_mw_sleep(_srs_config->get_mw_sleep_ms(req->vhost)); |
| 622 | 624 | ||
| 623 | while (true) { | 625 | while (true) { |
| 626 | + // collect elapse for pithy print. | ||
| 627 | + pprint->elapse(); | ||
| 628 | + | ||
| 624 | // to use isolate thread to recv, can improve about 33% performance. | 629 | // to use isolate thread to recv, can improve about 33% performance. |
| 625 | // @see: https://github.com/winlinvip/simple-rtmp-server/issues/196 | 630 | // @see: https://github.com/winlinvip/simple-rtmp-server/issues/196 |
| 626 | // @see: https://github.com/winlinvip/simple-rtmp-server/issues/217 | 631 | // @see: https://github.com/winlinvip/simple-rtmp-server/issues/217 |
| @@ -644,9 +649,6 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe | @@ -644,9 +649,6 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe | ||
| 644 | return ret; | 649 | return ret; |
| 645 | } | 650 | } |
| 646 | 651 | ||
| 647 | - // collect elapse for pithy print. | ||
| 648 | - pithy_print.elapse(); | ||
| 649 | - | ||
| 650 | #ifdef SRS_PERF_QUEUE_COND_WAIT | 652 | #ifdef SRS_PERF_QUEUE_COND_WAIT |
| 651 | // for send wait time debug | 653 | // for send wait time debug |
| 652 | srs_verbose("send thread now=%"PRId64"us, wait %dms", srs_update_system_time_ms(), mw_sleep); | 654 | srs_verbose("send thread now=%"PRId64"us, wait %dms", srs_update_system_time_ms(), mw_sleep); |
| @@ -675,11 +677,11 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe | @@ -675,11 +677,11 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe | ||
| 675 | } | 677 | } |
| 676 | 678 | ||
| 677 | // reportable | 679 | // reportable |
| 678 | - if (pithy_print.can_print()) { | 680 | + if (pprint->can_print()) { |
| 679 | kbps->sample(); | 681 | kbps->sample(); |
| 680 | srs_trace("-> "SRS_CONSTS_LOG_PLAY | 682 | srs_trace("-> "SRS_CONSTS_LOG_PLAY |
| 681 | " time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d, mw=%d", | 683 | " time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d, mw=%d", |
| 682 | - pithy_print.age(), count, | 684 | + pprint->age(), count, |
| 683 | kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(), | 685 | kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(), |
| 684 | kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m(), | 686 | kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m(), |
| 685 | mw_sleep | 687 | mw_sleep |
| @@ -827,8 +829,9 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd) | @@ -827,8 +829,9 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd) | ||
| 827 | return ret; | 829 | return ret; |
| 828 | } | 830 | } |
| 829 | srs_verbose("check publish_refer success."); | 831 | srs_verbose("check publish_refer success."); |
| 830 | - | ||
| 831 | - SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_PUBLISH_USER); | 832 | + |
| 833 | + SrsPithyPrint* pprint = SrsPithyPrint::create_rtmp_publish(); | ||
| 834 | + SrsAutoFree(SrsPithyPrint, pprint); | ||
| 832 | 835 | ||
| 833 | bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost); | 836 | bool vhost_is_edge = _srs_config->get_vhost_is_edge(req->vhost); |
| 834 | 837 | ||
| @@ -850,6 +853,8 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd) | @@ -850,6 +853,8 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd) | ||
| 850 | 853 | ||
| 851 | int64_t nb_msgs = 0; | 854 | int64_t nb_msgs = 0; |
| 852 | while (true) { | 855 | while (true) { |
| 856 | + pprint->elapse(); | ||
| 857 | + | ||
| 853 | // cond wait for error. | 858 | // cond wait for error. |
| 854 | trd->wait(SRS_CONSTS_RTMP_RECV_TIMEOUT_US / 1000); | 859 | trd->wait(SRS_CONSTS_RTMP_RECV_TIMEOUT_US / 1000); |
| 855 | 860 | ||
| @@ -870,15 +875,13 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd) | @@ -870,15 +875,13 @@ int SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread* trd) | ||
| 870 | } | 875 | } |
| 871 | nb_msgs = trd->nb_msgs(); | 876 | nb_msgs = trd->nb_msgs(); |
| 872 | 877 | ||
| 873 | - pithy_print.elapse(); | ||
| 874 | - | ||
| 875 | // reportable | 878 | // reportable |
| 876 | - if (pithy_print.can_print()) { | 879 | + if (pprint->can_print()) { |
| 877 | kbps->sample(); | 880 | kbps->sample(); |
| 878 | bool mr = _srs_config->get_mr_enabled(req->vhost); | 881 | bool mr = _srs_config->get_mr_enabled(req->vhost); |
| 879 | int mr_sleep = _srs_config->get_mr_sleep_ms(req->vhost); | 882 | int mr_sleep = _srs_config->get_mr_sleep_ms(req->vhost); |
| 880 | srs_trace("<- "SRS_CONSTS_LOG_CLIENT_PUBLISH | 883 | srs_trace("<- "SRS_CONSTS_LOG_CLIENT_PUBLISH |
| 881 | - " time=%"PRId64", okbps=%d,%d,%d, ikbps=%d,%d,%d, mr=%d/%d", pithy_print.age(), | 884 | + " time=%"PRId64", okbps=%d,%d,%d, ikbps=%d,%d,%d, mr=%d/%d", pprint->age(), |
| 882 | kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(), | 885 | kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(), |
| 883 | kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m(), | 886 | kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m(), |
| 884 | mr, mr_sleep | 887 | mr, mr_sleep |
| @@ -41,6 +41,7 @@ using namespace std; | @@ -41,6 +41,7 @@ using namespace std; | ||
| 41 | #include <srs_kernel_utility.hpp> | 41 | #include <srs_kernel_utility.hpp> |
| 42 | #include <srs_raw_avc.hpp> | 42 | #include <srs_raw_avc.hpp> |
| 43 | #include <srs_kernel_codec.hpp> | 43 | #include <srs_kernel_codec.hpp> |
| 44 | +#include <srs_app_pithy_print.hpp> | ||
| 44 | 45 | ||
| 45 | #ifdef SRS_AUTO_STREAM_CASTER | 46 | #ifdef SRS_AUTO_STREAM_CASTER |
| 46 | 47 | ||
| @@ -51,12 +52,14 @@ SrsRtpConn::SrsRtpConn(SrsRtspConn* r, int p, int sid) | @@ -51,12 +52,14 @@ SrsRtpConn::SrsRtpConn(SrsRtspConn* r, int p, int sid) | ||
| 51 | stream_id = sid; | 52 | stream_id = sid; |
| 52 | listener = new SrsUdpListener(this, p); | 53 | listener = new SrsUdpListener(this, p); |
| 53 | cache = new SrsRtpPacket(); | 54 | cache = new SrsRtpPacket(); |
| 55 | + pprint = SrsPithyPrint::create_caster(); | ||
| 54 | } | 56 | } |
| 55 | 57 | ||
| 56 | SrsRtpConn::~SrsRtpConn() | 58 | SrsRtpConn::~SrsRtpConn() |
| 57 | { | 59 | { |
| 58 | srs_freep(listener); | 60 | srs_freep(listener); |
| 59 | srs_freep(cache); | 61 | srs_freep(cache); |
| 62 | + srs_freep(pprint); | ||
| 60 | } | 63 | } |
| 61 | 64 | ||
| 62 | int SrsRtpConn::port() | 65 | int SrsRtpConn::port() |
| @@ -73,6 +76,8 @@ int SrsRtpConn::on_udp_packet(sockaddr_in* from, char* buf, int nb_buf) | @@ -73,6 +76,8 @@ int SrsRtpConn::on_udp_packet(sockaddr_in* from, char* buf, int nb_buf) | ||
| 73 | { | 76 | { |
| 74 | int ret = ERROR_SUCCESS; | 77 | int ret = ERROR_SUCCESS; |
| 75 | 78 | ||
| 79 | + pprint->elapse(); | ||
| 80 | + | ||
| 76 | if (true) { | 81 | if (true) { |
| 77 | SrsStream stream; | 82 | SrsStream stream; |
| 78 | 83 | ||
| @@ -92,9 +97,9 @@ int SrsRtpConn::on_udp_packet(sockaddr_in* from, char* buf, int nb_buf) | @@ -92,9 +97,9 @@ int SrsRtpConn::on_udp_packet(sockaddr_in* from, char* buf, int nb_buf) | ||
| 92 | } | 97 | } |
| 93 | cache->copy(&pkt); | 98 | cache->copy(&pkt); |
| 94 | cache->payload->append(pkt.payload->bytes(), pkt.payload->length()); | 99 | cache->payload->append(pkt.payload->bytes(), pkt.payload->length()); |
| 95 | - if (!cache->completed) { | ||
| 96 | - srs_trace("rtsp: rtp chunked %dB, vt=%d/%u, sts=%u/%#x/%#x, paylod=%dB", | ||
| 97 | - nb_buf, cache->version, cache->payload_type, cache->sequence_number, cache->timestamp, cache->ssrc, | 100 | + if (!cache->completed && pprint->can_print()) { |
| 101 | + srs_trace("<- "SRS_CONSTS_LOG_STREAM_CASTER" rtsp: rtp chunked %dB, age=%d, vt=%d/%u, sts=%u/%#x/%#x, paylod=%dB", | ||
| 102 | + nb_buf, pprint->age(), cache->version, cache->payload_type, cache->sequence_number, cache->timestamp, cache->ssrc, | ||
| 98 | cache->payload->length() | 103 | cache->payload->length() |
| 99 | ); | 104 | ); |
| 100 | return ret; | 105 | return ret; |
| @@ -106,10 +111,12 @@ int SrsRtpConn::on_udp_packet(sockaddr_in* from, char* buf, int nb_buf) | @@ -106,10 +111,12 @@ int SrsRtpConn::on_udp_packet(sockaddr_in* from, char* buf, int nb_buf) | ||
| 106 | } | 111 | } |
| 107 | } | 112 | } |
| 108 | 113 | ||
| 109 | - srs_trace("rtsp: rtp #%d %dB, vt=%d/%u, sts=%u/%u/%#x, paylod=%dB, chunked=%d", | ||
| 110 | - stream_id, nb_buf, cache->version, cache->payload_type, cache->sequence_number, cache->timestamp, cache->ssrc, | ||
| 111 | - cache->payload->length(), cache->chunked | ||
| 112 | - ); | 114 | + if (pprint->can_print()) { |
| 115 | + srs_trace("<- "SRS_CONSTS_LOG_STREAM_CASTER" rtsp: rtp #%d %dB, age=%d, vt=%d/%u, sts=%u/%u/%#x, paylod=%dB, chunked=%d", | ||
| 116 | + stream_id, nb_buf, pprint->age(), cache->version, cache->payload_type, cache->sequence_number, cache->timestamp, cache->ssrc, | ||
| 117 | + cache->payload->length(), cache->chunked | ||
| 118 | + ); | ||
| 119 | + } | ||
| 113 | 120 | ||
| 114 | // always free it. | 121 | // always free it. |
| 115 | SrsAutoFree(SrsRtpPacket, cache); | 122 | SrsAutoFree(SrsRtpPacket, cache); |
| @@ -55,6 +55,7 @@ class SrsRawAacStreamCodec; | @@ -55,6 +55,7 @@ class SrsRawAacStreamCodec; | ||
| 55 | class SrsSharedPtrMessage; | 55 | class SrsSharedPtrMessage; |
| 56 | class SrsCodecSample; | 56 | class SrsCodecSample; |
| 57 | class SrsSimpleBuffer; | 57 | class SrsSimpleBuffer; |
| 58 | +class SrsPithyPrint; | ||
| 58 | 59 | ||
| 59 | /** | 60 | /** |
| 60 | * a rtp connection which transport a stream. | 61 | * a rtp connection which transport a stream. |
| @@ -62,6 +63,7 @@ class SrsSimpleBuffer; | @@ -62,6 +63,7 @@ class SrsSimpleBuffer; | ||
| 62 | class SrsRtpConn: public ISrsUdpHandler | 63 | class SrsRtpConn: public ISrsUdpHandler |
| 63 | { | 64 | { |
| 64 | private: | 65 | private: |
| 66 | + SrsPithyPrint* pprint; | ||
| 65 | SrsUdpListener* listener; | 67 | SrsUdpListener* listener; |
| 66 | SrsRtspConn* rtsp; | 68 | SrsRtspConn* rtsp; |
| 67 | SrsRtpPacket* cache; | 69 | SrsRtpPacket* cache; |
| @@ -117,7 +119,6 @@ private: | @@ -117,7 +119,6 @@ private: | ||
| 117 | std::string output_template; | 119 | std::string output_template; |
| 118 | std::string rtsp_tcUrl; | 120 | std::string rtsp_tcUrl; |
| 119 | std::string rtsp_stream; | 121 | std::string rtsp_stream; |
| 120 | - | ||
| 121 | private: | 122 | private: |
| 122 | std::string session; | 123 | std::string session; |
| 123 | // video stream. | 124 | // video stream. |
| @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR 2 | 32 | #define VERSION_MAJOR 2 |
| 33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
| 34 | -#define VERSION_REVISION 120 | 34 | +#define VERSION_REVISION 121 |
| 35 | 35 | ||
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
| @@ -162,31 +162,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -162,31 +162,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 162 | #define SRS_CONSTS_LOG_HLS "HLS" | 162 | #define SRS_CONSTS_LOG_HLS "HLS" |
| 163 | // encoder log id. | 163 | // encoder log id. |
| 164 | #define SRS_CONSTS_LOG_ENCODER "ENC" | 164 | #define SRS_CONSTS_LOG_ENCODER "ENC" |
| 165 | - | ||
| 166 | -/////////////////////////////////////////////////////////// | ||
| 167 | -/////////////////////////////////////////////////////////// | ||
| 168 | -/////////////////////////////////////////////////////////// | ||
| 169 | -/////////////////////////////////////////////////////////// | ||
| 170 | -/////////////////////////////////////////////////////////// | ||
| 171 | -/////////////////////////////////////////////////////////// | ||
| 172 | - | ||
| 173 | -/////////////////////////////////////////////////////////// | ||
| 174 | -// pithy-print consts values | ||
| 175 | -/////////////////////////////////////////////////////////// | ||
| 176 | -// the pithy stage for all play clients. | ||
| 177 | -#define SRS_CONSTS_STAGE_PLAY_USER 1 | ||
| 178 | -// the pithy stage for all publish clients. | ||
| 179 | -#define SRS_CONSTS_STAGE_PUBLISH_USER 2 | ||
| 180 | -// the pithy stage for all forward clients. | ||
| 181 | -#define SRS_CONSTS_STAGE_FORWARDER 3 | ||
| 182 | -// the pithy stage for all encoders. | ||
| 183 | -#define SRS_CONSTS_STAGE_ENCODER 4 | ||
| 184 | -// the pithy stage for all hls. | ||
| 185 | -#define SRS_CONSTS_STAGE_HLS 5 | ||
| 186 | -// the pithy stage for all ingesters. | ||
| 187 | -#define SRS_CONSTS_STAGE_INGESTER 6 | ||
| 188 | -// the pithy stage for all edge. | ||
| 189 | -#define SRS_CONSTS_STAGE_EDGE 7 | 165 | +// http stream log id. |
| 166 | +#define SRS_CONSTS_LOG_HTTP_STREAM "HTS" | ||
| 167 | +// http stream cache log id. | ||
| 168 | +#define SRS_CONSTS_LOG_HTTP_STREAM_CACHE "HTC" | ||
| 169 | +// stream caster log id. | ||
| 170 | +#define SRS_CONSTS_LOG_STREAM_CASTER "SCS" | ||
| 190 | 171 | ||
| 191 | /////////////////////////////////////////////////////////// | 172 | /////////////////////////////////////////////////////////// |
| 192 | /////////////////////////////////////////////////////////// | 173 | /////////////////////////////////////////////////////////// |
| @@ -233,7 +233,6 @@ int SrsRtpPacket::decode_97(SrsStream* stream) | @@ -233,7 +233,6 @@ int SrsRtpPacket::decode_97(SrsStream* stream) | ||
| 233 | return ret; | 233 | return ret; |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | - int nb_samples = au_size / 2; | ||
| 237 | int required_size = 0; | 236 | int required_size = 0; |
| 238 | 237 | ||
| 239 | // append left bytes to payload. | 238 | // append left bytes to payload. |
-
请 注册 或 登录 后发表评论