winlin

for #319, support query the vhost info.

@@ -49,6 +49,11 @@ daemon on; @@ -49,6 +49,11 @@ daemon on;
49 # if on, use gmtime() instead, which use UTC time. 49 # if on, use gmtime() instead, which use UTC time.
50 # default: off 50 # default: off
51 utc_time off; 51 utc_time off;
  52 +# config for the pithy print,
  53 +# which always print constant message specified by interval,
  54 +# whatever the clients in concurrency.
  55 +# default: 10000
  56 +pithy_print_ms 10000;
52 57
53 ############################################################################################# 58 #############################################################################################
54 # heartbeat/stats sections 59 # heartbeat/stats sections
@@ -998,6 +1003,92 @@ vhost exec.srs.com { @@ -998,6 +1003,92 @@ vhost exec.srs.com {
998 } 1003 }
999 } 1004 }
1000 1005
  1006 +# vhost for bandwidth check
  1007 +# generally, the bandcheck vhost must be: bandcheck.srs.com,
  1008 +# or need to modify the vhost of client.
  1009 +vhost bandcheck.srs.com {
  1010 + enabled on;
  1011 + chunk_size 65000;
  1012 + # bandwidth check config.
  1013 + bandcheck {
  1014 + # whether support bandwidth check,
  1015 + # default: off.
  1016 + enabled on;
  1017 + # the key for server to valid,
  1018 + # if invalid key, server disconnect and abort the bandwidth check.
  1019 + key "35c9b402c12a7246868752e2878f7e0e";
  1020 + # the interval in seconds for bandwidth check,
  1021 + # server donot allow new test request.
  1022 + # default: 30
  1023 + interval 30;
  1024 + # the max available check bandwidth in kbps.
  1025 + # to avoid attack of bandwidth check.
  1026 + # default: 1000
  1027 + limit_kbps 4000;
  1028 + }
  1029 +}
  1030 +
  1031 +# set the chunk size of vhost.
  1032 +vhost chunksize.srs.com {
  1033 + # the default chunk size is 128, max is 65536,
  1034 + # some client does not support chunk size change,
  1035 + # vhost chunk size will override the global value.
  1036 + # default: global chunk size.
  1037 + chunk_size 128;
  1038 +}
  1039 +
  1040 +# vhost for time jitter
  1041 +vhost jitter.srs.com {
  1042 + # about the stream monotonically increasing:
  1043 + # 1. video timestamp is monotonically increasing,
  1044 + # 2. audio timestamp is monotonically increasing,
  1045 + # 3. video and audio timestamp is interleaved/mixed monotonically increasing.
  1046 + # it's specified by RTMP specification, @see 3. Byte Order, Alignment, and Time Format
  1047 + # however, some encoder cannot provides this feature, please set this to off to ignore time jitter.
  1048 + # the time jitter algorithm:
  1049 + # 1. full, to ensure stream start at zero, and ensure stream monotonically increasing.
  1050 + # 2. zero, only ensure sttream start at zero, ignore timestamp jitter.
  1051 + # 3. off, disable the time jitter algorithm, like atc.
  1052 + # default: full
  1053 + time_jitter full;
  1054 + # whether use the interleaved/mixed algorithm to correct the timestamp.
  1055 + # if on, always ensure the timestamp of audio+video is interleaved/mixed monotonically increase.
  1056 + # if off, use time_jitter to correct the timestamp if required.
  1057 + # default: off
  1058 + mix_correct off;
  1059 +}
  1060 +
  1061 +# vhost for atc.
  1062 +vhost atc.srs.com {
  1063 + # vhost for atc for hls/hds/rtmp backup.
  1064 + # generally, atc default to off, server delivery rtmp stream to client(flash) timestamp from 0.
  1065 + # when atc is on, server delivery rtmp stream by absolute time.
  1066 + # atc is used, for instance, encoder will copy stream to master and slave server,
  1067 + # server use atc to delivery stream to edge/client, where stream time from master/slave server
  1068 + # is always the same, client/tools can slice RTMP stream to HLS according to the same time,
  1069 + # if the time not the same, the HLS stream cannot slice to support system backup.
  1070 + #
  1071 + # @see http://www.adobe.com/cn/devnet/adobe-media-server/articles/varnish-sample-for-failover.html
  1072 + # @see http://www.baidu.com/#wd=hds%20hls%20atc
  1073 + #
  1074 + # default: off
  1075 + atc on;
  1076 + # whether enable the auto atc,
  1077 + # if enabled, detect the bravo_atc="true" in onMetaData packet,
  1078 + # set atc to on if matched.
  1079 + # always ignore the onMetaData if atc_auto is off.
  1080 + # default: on
  1081 + atc_auto on;
  1082 +}
  1083 +
  1084 +# the vhost disabled.
  1085 +vhost removed.srs.com {
  1086 + # whether the vhost is enabled.
  1087 + # if off, all request access denied.
  1088 + # default: on
  1089 + enabled off;
  1090 +}
  1091 +
1001 # the main comments for transcode 1092 # the main comments for transcode
1002 vhost example.transcode.srs.com { 1093 vhost example.transcode.srs.com {
1003 # the streaming transcode configs. 1094 # the streaming transcode configs.
@@ -1441,95 +1532,3 @@ vhost stream.transcode.srs.com { @@ -1441,95 +1532,3 @@ vhost stream.transcode.srs.com {
1441 } 1532 }
1442 } 1533 }
1443 } 1534 }
1444 -  
1445 -# vhost for bandwidth check  
1446 -# generally, the bandcheck vhost must be: bandcheck.srs.com,  
1447 -# or need to modify the vhost of client.  
1448 -vhost bandcheck.srs.com {  
1449 - enabled on;  
1450 - chunk_size 65000;  
1451 - # bandwidth check config.  
1452 - bandcheck {  
1453 - # whether support bandwidth check,  
1454 - # default: off.  
1455 - enabled on;  
1456 - # the key for server to valid,  
1457 - # if invalid key, server disconnect and abort the bandwidth check.  
1458 - key "35c9b402c12a7246868752e2878f7e0e";  
1459 - # the interval in seconds for bandwidth check,  
1460 - # server donot allow new test request.  
1461 - # default: 30  
1462 - interval 30;  
1463 - # the max available check bandwidth in kbps.  
1464 - # to avoid attack of bandwidth check.  
1465 - # default: 1000  
1466 - limit_kbps 4000;  
1467 - }  
1468 -}  
1469 -  
1470 -# set the chunk size of vhost.  
1471 -vhost chunksize.srs.com {  
1472 - # the default chunk size is 128, max is 65536,  
1473 - # some client does not support chunk size change,  
1474 - # vhost chunk size will override the global value.  
1475 - # default: global chunk size.  
1476 - chunk_size 128;  
1477 -}  
1478 -  
1479 -# vhost for time jitter  
1480 -vhost jitter.srs.com {  
1481 - # about the stream monotonically increasing:  
1482 - # 1. video timestamp is monotonically increasing,  
1483 - # 2. audio timestamp is monotonically increasing,  
1484 - # 3. video and audio timestamp is interleaved/mixed monotonically increasing.  
1485 - # it's specified by RTMP specification, @see 3. Byte Order, Alignment, and Time Format  
1486 - # however, some encoder cannot provides this feature, please set this to off to ignore time jitter.  
1487 - # the time jitter algorithm:  
1488 - # 1. full, to ensure stream start at zero, and ensure stream monotonically increasing.  
1489 - # 2. zero, only ensure sttream start at zero, ignore timestamp jitter.  
1490 - # 3. off, disable the time jitter algorithm, like atc.  
1491 - # default: full  
1492 - time_jitter full;  
1493 - # whether use the interleaved/mixed algorithm to correct the timestamp.  
1494 - # if on, always ensure the timestamp of audio+video is interleaved/mixed monotonically increase.  
1495 - # if off, use time_jitter to correct the timestamp if required.  
1496 - # default: off  
1497 - mix_correct off;  
1498 -}  
1499 -  
1500 -# vhost for atc.  
1501 -vhost atc.srs.com {  
1502 - # vhost for atc for hls/hds/rtmp backup.  
1503 - # generally, atc default to off, server delivery rtmp stream to client(flash) timestamp from 0.  
1504 - # when atc is on, server delivery rtmp stream by absolute time.  
1505 - # atc is used, for instance, encoder will copy stream to master and slave server,  
1506 - # server use atc to delivery stream to edge/client, where stream time from master/slave server  
1507 - # is always the same, client/tools can slice RTMP stream to HLS according to the same time,  
1508 - # if the time not the same, the HLS stream cannot slice to support system backup.  
1509 - #  
1510 - # @see http://www.adobe.com/cn/devnet/adobe-media-server/articles/varnish-sample-for-failover.html  
1511 - # @see http://www.baidu.com/#wd=hds%20hls%20atc  
1512 - #  
1513 - # default: off  
1514 - atc on;  
1515 - # whether enable the auto atc,  
1516 - # if enabled, detect the bravo_atc="true" in onMetaData packet,  
1517 - # set atc to on if matched.  
1518 - # always ignore the onMetaData if atc_auto is off.  
1519 - # default: on  
1520 - atc_auto on;  
1521 -}  
1522 -  
1523 -# the vhost disabled.  
1524 -vhost removed.srs.com {  
1525 - # whether the vhost is enabled.  
1526 - # if off, all request access denied.  
1527 - # default: on  
1528 - enabled off;  
1529 -}  
1530 -  
1531 -# config for the pithy print,  
1532 -# which always print constant message specified by interval,  
1533 -# whatever the clients in concurrency.  
1534 -# default: 10000  
1535 -pithy_print_ms 10000;  
  1 +listen 1935;
  2 +pid ./objs/srs.pid;
  3 +chunk_size 60000;
  4 +ff_log_dir ./objs;
  5 +srs_log_tank console;
  6 +srs_log_level trace;
  7 +srs_log_file ./objs/srs.log;
  8 +max_connections 1000;
  9 +daemon off;
  10 +utc_time off;
  11 +pithy_print_ms 10000;
  12 +heartbeat {
  13 + enabled off;
  14 + interval 9.3;
  15 + url http://127.0.0.1:8085/api/v1/servers;
  16 + device_id my-srs-device;
  17 + summaries off;
  18 +}
  19 +stats {
  20 + network 0;
  21 + disk sda sdb xvda xvdb;
  22 +}
  23 +http_api {
  24 + enabled on;
  25 + listen 1985;
  26 + crossdomain on;
  27 + raw_api {
  28 + enabled on;
  29 + allow_reload on;
  30 + allow_query on;
  31 + }
  32 +}
  33 +http_server {
  34 + enabled off;
  35 + listen 8080;
  36 + dir ./objs/nginx/html;
  37 +}
  38 +stream_caster {
  39 + enabled off;
  40 + caster mpegts_over_udp;
  41 + output rtmp://127.0.0.1/live/livestream;
  42 + listen 8935;
  43 + rtp_port_min 57200;
  44 + rtp_port_max 57300;
  45 +}
  46 +stream_caster {
  47 + enabled off;
  48 + caster mpegts_over_udp;
  49 + output rtmp://127.0.0.1/live/livestream;
  50 + listen 8935;
  51 +}
  52 +stream_caster {
  53 + enabled off;
  54 + caster rtsp;
  55 + output rtmp://127.0.0.1/[app]/[stream];
  56 + listen 554;
  57 + rtp_port_min 57200;
  58 + rtp_port_max 57300;
  59 +}
  60 +stream_caster {
  61 + enabled off;
  62 + caster flv;
  63 + output rtmp://127.0.0.1/[app]/[stream];
  64 + listen 8936;
  65 +}
  66 +vhost __defaultVhost__ {
  67 +}
  68 +vhost vhost.srs.com {
  69 + enabled off;
  70 +
  71 + mode remote;
  72 + origin 127.0.0.1:1935 localhost:1935;
  73 + token_traverse off;
  74 + vhost same.edge.srs.com;
  75 +
  76 + forward 127.0.0.1:1936 127.0.0.1:1937;
  77 +
  78 + debug_srs_upnode off;
  79 +
  80 + chunk_size 128;
  81 +
  82 + time_jitter full;
  83 + mix_correct off;
  84 +
  85 + atc on;
  86 + atc_auto on;
  87 +
  88 + min_latency on;
  89 + mr {
  90 + enabled off;
  91 + }
  92 + mw_latency 100;
  93 + gop_cache off;
  94 + queue_length 10;
  95 + tcp_nodelay on;
  96 + send_min_interval 10.0;
  97 + reduce_sequence_header on;
  98 + publish_1stpkt_timeout 20000;
  99 + publish_normal_timeout 7000;
  100 +
  101 + refer github.com github.io;
  102 + refer_publish github.com github.io;
  103 + refer_play github.com github.io;
  104 +
  105 + bandcheck {
  106 + enabled off;
  107 + key 35c9b402c12a7246868752e2878f7e0e;
  108 + interval 30;
  109 + limit_kbps 4000;
  110 + }
  111 +
  112 + security {
  113 + enabled off;
  114 + allow play all;
  115 + allow publish all;
  116 + }
  117 +
  118 + http_static {
  119 + enabled off;
  120 + mount [vhost]/hls;
  121 + dir ./objs/nginx/html/hls;
  122 + }
  123 +
  124 + http_remux {
  125 + enabled off;
  126 + fast_cache 30;
  127 + mount [vhost]/[app]/[stream].flv;
  128 + hstrs on;
  129 + }
  130 +
  131 + http_hooks {
  132 + enabled off;
  133 + on_connect http://127.0.0.1:8085/api/v1/clients http://localhost:8085/api/v1/clients;
  134 + on_close http://127.0.0.1:8085/api/v1/clients http://localhost:8085/api/v1/clients;
  135 + on_publish http://127.0.0.1:8085/api/v1/streams http://localhost:8085/api/v1/streams;
  136 + on_unpublish http://127.0.0.1:8085/api/v1/streams http://localhost:8085/api/v1/streams;
  137 + on_play http://127.0.0.1:8085/api/v1/sessions http://localhost:8085/api/v1/sessions;
  138 + on_stop http://127.0.0.1:8085/api/v1/sessions http://localhost:8085/api/v1/sessions;
  139 + on_dvr http://127.0.0.1:8085/api/v1/dvrs http://localhost:8085/api/v1/dvrs;
  140 + on_hls http://127.0.0.1:8085/api/v1/hls http://localhost:8085/api/v1/hls;
  141 + on_hls_notify http://127.0.0.1:8085/api/v1/hls/[app]/[stream][ts_url];
  142 + }
  143 +
  144 + hls {
  145 + enabled off;
  146 + hls_fragment 10;
  147 + hls_td_ratio 1.5;
  148 + hls_aof_ratio 2.0;
  149 + hls_window 60;
  150 + hls_on_error ignore;
  151 + hls_storage disk;
  152 + hls_path ./objs/nginx/html;
  153 + hls_m3u8_file [app]/[stream].m3u8;
  154 + hls_ts_file [app]/[stream]-[seq].ts;
  155 + hls_ts_floor off;
  156 + hls_entry_prefix http://your-server;
  157 + hls_mount [vhost]/[app]/[stream].m3u8;
  158 + hls_acodec aac;
  159 + hls_vcodec h264;
  160 + hls_cleanup on;
  161 + hls_dispose 0;
  162 + hls_nb_notify 64;
  163 + hls_wait_keyframe on;
  164 + }
  165 +
  166 + hds {
  167 + enabled off;
  168 + hds_fragment 10;
  169 + hds_window 60;
  170 + hds_path ./objs/nginx/html;
  171 + }
  172 +
  173 + exec {
  174 + enabled off;
  175 + publish ./objs/ffmpeg/bin/ffmpeg -f flv -i [url] -c copy -y ./[stream].flv;
  176 + }
  177 +
  178 + dvr {
  179 + enabled off;
  180 + dvr_plan session;
  181 + dvr_path ./objs/nginx/html/[app]/[stream].[timestamp].flv;
  182 + dvr_duration 30;
  183 + dvr_wait_keyframe on;
  184 + time_jitter full;
  185 + }
  186 +
  187 + ingest livestream {
  188 + enabled off;
  189 + input {
  190 + type file;
  191 + url ./doc/source.200kbps.768x320.flv;
  192 + }
  193 + ffmpeg ./objs/ffmpeg/bin/ffmpeg;
  194 + engine {
  195 + enabled off;
  196 + output rtmp://127.0.0.1:[port]/live?vhost=[vhost]/livestream;
  197 + }
  198 + }
  199 +
  200 + transcode {
  201 + enabled off;
  202 + ffmpeg ./objs/ffmpeg/bin/ffmpeg;
  203 + engine ffsuper {
  204 + enabled off;
  205 + iformat flv;
  206 + vfilter {
  207 + i ./doc/ffmpeg-logo.png;
  208 + filter_complex overlay=10:10;
  209 + }
  210 + vcodec libx264;
  211 + vbitrate 1500;
  212 + vfps 25;
  213 + vwidth 768;
  214 + vheight 320;
  215 + vthreads 12;
  216 + vprofile main;
  217 + vpreset medium;
  218 + vparams {
  219 + t 100;
  220 + coder 1;
  221 + b_strategy 2;
  222 + bf 3;
  223 + refs 10;
  224 + }
  225 + acodec libfdk_aac;
  226 + abitrate 70;
  227 + asample_rate 44100;
  228 + achannels 2;
  229 + aparams {
  230 + profile:a aac_low;
  231 + }
  232 + oformat flv;
  233 + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  234 + }
  235 + engine ffhd {
  236 + enabled off;
  237 + vcodec libx264;
  238 + vbitrate 1200;
  239 + vfps 25;
  240 + vwidth 1382;
  241 + vheight 576;
  242 + vthreads 6;
  243 + vprofile main;
  244 + vpreset medium;
  245 + vparams;
  246 + acodec libfdk_aac;
  247 + abitrate 70;
  248 + asample_rate 44100;
  249 + achannels 2;
  250 + aparams;
  251 + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  252 + }
  253 + engine ffsd {
  254 + enabled off;
  255 + vcodec libx264;
  256 + vbitrate 800;
  257 + vfps 25;
  258 + vwidth 1152;
  259 + vheight 480;
  260 + vthreads 4;
  261 + vprofile main;
  262 + vpreset fast;
  263 + vparams;
  264 + acodec libfdk_aac;
  265 + abitrate 60;
  266 + asample_rate 44100;
  267 + achannels 2;
  268 + aparams;
  269 + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  270 + }
  271 + engine fffast {
  272 + enabled off;
  273 + vcodec libx264;
  274 + vbitrate 300;
  275 + vfps 20;
  276 + vwidth 768;
  277 + vheight 320;
  278 + vthreads 2;
  279 + vprofile baseline;
  280 + vpreset superfast;
  281 + vparams;
  282 + acodec libfdk_aac;
  283 + abitrate 45;
  284 + asample_rate 44100;
  285 + achannels 2;
  286 + aparams;
  287 + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  288 + }
  289 + engine vcopy {
  290 + enabled off;
  291 + vcodec copy;
  292 + acodec libfdk_aac;
  293 + abitrate 45;
  294 + asample_rate 44100;
  295 + achannels 2;
  296 + aparams;
  297 + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  298 + }
  299 + engine acopy {
  300 + enabled off;
  301 + vcodec libx264;
  302 + vbitrate 300;
  303 + vfps 20;
  304 + vwidth 768;
  305 + vheight 320;
  306 + vthreads 2;
  307 + vprofile baseline;
  308 + vpreset superfast;
  309 + vparams;
  310 + acodec copy;
  311 + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  312 + }
  313 + engine copy {
  314 + enabled off;
  315 + vcodec copy;
  316 + acodec copy;
  317 + output rtmp://127.0.0.1:[port]/[app]?vhost=[vhost]/[stream]_[engine];
  318 + }
  319 + }
  320 +}
@@ -1798,6 +1798,142 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj) @@ -1798,6 +1798,142 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj)
1798 1798
1799 SrsConfDirective* dir = NULL; 1799 SrsConfDirective* dir = NULL;
1800 1800
  1801 + // stat id and name.
  1802 + SrsStatistic* stat = SrsStatistic::instance();
  1803 +
  1804 + SrsStatisticVhost* svhost = stat->find_vhost(vhost->arg0());
  1805 + obj->set("id", SrsAmf0Any::number(svhost? (double)svhost->id : 0));
  1806 +
  1807 + obj->set("name", vhost->dumps_arg0_to_str());
  1808 +
  1809 + // enabled
  1810 + if ((dir = vhost->get("enabled")) != NULL) {
  1811 + obj->set("enabled", dir->dumps_arg0_to_boolean());
  1812 + }
  1813 +
  1814 + // edge.
  1815 + if ((dir = vhost->get("mode")) != NULL) {
  1816 + obj->set("mode", dir->dumps_arg0_to_str());
  1817 + }
  1818 + if ((dir = vhost->get("origin")) != NULL) {
  1819 + obj->set("origin", dir->dumps_args());
  1820 + }
  1821 + if ((dir = vhost->get("token_traverse")) != NULL) {
  1822 + obj->set("token_traverse", dir->dumps_arg0_to_boolean());
  1823 + }
  1824 + if ((dir = vhost->get("vhost")) != NULL) {
  1825 + obj->set("vhost", dir->dumps_arg0_to_str());
  1826 + }
  1827 +
  1828 + // forward
  1829 + if ((dir = vhost->get("forward")) != NULL) {
  1830 + obj->set("forward", dir->dumps_args());
  1831 + }
  1832 +
  1833 + // debug_srs_upnode
  1834 + if ((dir = vhost->get("debug_srs_upnode")) != NULL) {
  1835 + obj->set("debug_srs_upnode", dir->dumps_arg0_to_boolean());
  1836 + }
  1837 +
  1838 + // chunk_size
  1839 + if ((dir = vhost->get("chunk_size")) != NULL) {
  1840 + obj->set("chunk_size", dir->dumps_arg0_to_number());
  1841 + }
  1842 +
  1843 + // time_jitter
  1844 + if ((dir = vhost->get("time_jitter")) != NULL) {
  1845 + obj->set("time_jitter", dir->dumps_arg0_to_str());
  1846 + }
  1847 + if ((dir = vhost->get("mix_correct")) != NULL) {
  1848 + obj->set("mix_correct", dir->dumps_arg0_to_boolean());
  1849 + }
  1850 +
  1851 + // atc
  1852 + if ((dir = vhost->get("atc")) != NULL) {
  1853 + obj->set("atc", dir->dumps_arg0_to_boolean());
  1854 + }
  1855 + if ((dir = vhost->get("atc_auto")) != NULL) {
  1856 + obj->set("atc_auto", dir->dumps_arg0_to_boolean());
  1857 + }
  1858 +
  1859 + // mrw
  1860 + if ((dir = vhost->get("min_latency")) != NULL) {
  1861 + obj->set("min_latency", dir->dumps_arg0_to_boolean());
  1862 + }
  1863 + if ((dir = vhost->get("mr")) != NULL) {
  1864 + SrsAmf0Object* mr = SrsAmf0Any::object();
  1865 + obj->set("mr", mr);
  1866 +
  1867 + for (int i = 0; i < (int)dir->directives.size(); i++) {
  1868 + SrsConfDirective* sdir = dir->directives.at(i);
  1869 +
  1870 + if (sdir->name == "enabled") {
  1871 + mr->set("enabled", sdir->dumps_arg0_to_boolean());
  1872 + } else if (sdir->name == "latency") {
  1873 + mr->set("latency", sdir->dumps_arg0_to_number());
  1874 + }
  1875 + }
  1876 + }
  1877 + if ((dir = vhost->get("mw_latency")) != NULL) {
  1878 + obj->set("mw_latency", dir->dumps_arg0_to_number());
  1879 + }
  1880 +
  1881 + // realtime latency
  1882 + if ((dir = vhost->get("gop_cache")) != NULL) {
  1883 + obj->set("gop_cache", dir->dumps_arg0_to_boolean());
  1884 + }
  1885 + if ((dir = vhost->get("queue_length")) != NULL) {
  1886 + obj->set("queue_length", dir->dumps_arg0_to_number());
  1887 + }
  1888 + if ((dir = vhost->get("tcp_nodelay")) != NULL) {
  1889 + obj->set("tcp_nodelay", dir->dumps_arg0_to_boolean());
  1890 + }
  1891 +
  1892 + // stream control
  1893 + if ((dir = vhost->get("send_min_interval")) != NULL) {
  1894 + obj->set("send_min_interval", dir->dumps_arg0_to_number());
  1895 + }
  1896 + if ((dir = vhost->get("reduce_sequence_header")) != NULL) {
  1897 + obj->set("reduce_sequence_header", dir->dumps_arg0_to_boolean());
  1898 + }
  1899 + if ((dir = vhost->get("publish_1stpkt_timeout")) != NULL) {
  1900 + obj->set("publish_1stpkt_timeout", dir->dumps_arg0_to_number());
  1901 + }
  1902 + if ((dir = vhost->get("publish_normal_timeout")) != NULL) {
  1903 + obj->set("publish_normal_timeout", dir->dumps_arg0_to_number());
  1904 + }
  1905 +
  1906 + // refer
  1907 + if ((dir = vhost->get("refer")) != NULL) {
  1908 + obj->set("refer", dir->dumps_args());
  1909 + }
  1910 + if ((dir = vhost->get("refer_publish")) != NULL) {
  1911 + obj->set("refer_publish", dir->dumps_args());
  1912 + }
  1913 + if ((dir = vhost->get("refer_play")) != NULL) {
  1914 + obj->set("refer_play", dir->dumps_args());
  1915 + }
  1916 +
  1917 + // bandcheck
  1918 + if ((dir = vhost->get("bandcheck")) != NULL) {
  1919 + SrsAmf0Object* bandcheck = SrsAmf0Any::object();
  1920 + obj->set("bandcheck", bandcheck);
  1921 +
  1922 + for (int i = 0; i < (int)dir->directives.size(); i++) {
  1923 + SrsConfDirective* sdir = dir->directives.at(i);
  1924 +
  1925 + if (sdir->name == "enabled") {
  1926 + bandcheck->set("enabled", sdir->dumps_arg0_to_boolean());
  1927 + } else if (sdir->name == "key") {
  1928 + bandcheck->set("key", sdir->dumps_arg0_to_str());
  1929 + } else if (sdir->name == "interval") {
  1930 + bandcheck->set("interval", sdir->dumps_arg0_to_number());
  1931 + } else if (sdir->name == "limit_kbps") {
  1932 + bandcheck->set("limit_kbps", sdir->dumps_arg0_to_number());
  1933 + }
  1934 + }
  1935 + }
  1936 +
1801 // security 1937 // security
1802 if ((dir = vhost->get("security")) != NULL) { 1938 if ((dir = vhost->get("security")) != NULL) {
1803 SrsAmf0Object* security = SrsAmf0Any::object(); 1939 SrsAmf0Object* security = SrsAmf0Any::object();
@@ -1821,40 +1957,144 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj) @@ -1821,40 +1957,144 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj)
1821 } 1957 }
1822 } 1958 }
1823 1959
1824 - // mrw  
1825 - if ((dir = vhost->get("min_latency")) != NULL) {  
1826 - obj->set("min_latency", dir->dumps_arg0_to_boolean());  
1827 - }  
1828 - if ((dir = vhost->get("mr")) != NULL) {  
1829 - SrsAmf0Object* mr = SrsAmf0Any::object();  
1830 - obj->set("mr", mr); 1960 + // http_static
  1961 + if ((dir = vhost->get("http_static")) != NULL) {
  1962 + SrsAmf0Object* http_static = SrsAmf0Any::object();
  1963 + obj->set("http_static", http_static);
1831 1964
1832 for (int i = 0; i < (int)dir->directives.size(); i++) { 1965 for (int i = 0; i < (int)dir->directives.size(); i++) {
1833 SrsConfDirective* sdir = dir->directives.at(i); 1966 SrsConfDirective* sdir = dir->directives.at(i);
1834 1967
1835 if (sdir->name == "enabled") { 1968 if (sdir->name == "enabled") {
1836 - mr->set("enabled", sdir->dumps_arg0_to_boolean());  
1837 - } else if (sdir->name == "latency") {  
1838 - mr->set("latency", sdir->dumps_arg0_to_number()); 1969 + http_static->set("enabled", sdir->dumps_arg0_to_boolean());
  1970 + } else if (sdir->name == "mount") {
  1971 + http_static->set("mount", sdir->dumps_arg0_to_str());
  1972 + } else if (sdir->name == "dir") {
  1973 + http_static->set("dir", sdir->dumps_arg0_to_str());
1839 } 1974 }
1840 } 1975 }
1841 } 1976 }
1842 - if ((dir = vhost->get("mw_latency")) != NULL) {  
1843 - obj->set("mw_latency", dir->dumps_arg0_to_number());  
1844 - }  
1845 1977
1846 - // edge.  
1847 - if ((dir = vhost->get("mode")) != NULL) {  
1848 - obj->set("mode", dir->dumps_arg0_to_str()); 1978 + // http_remux
  1979 + if ((dir = vhost->get("http_remux")) != NULL) {
  1980 + SrsAmf0Object* http_remux = SrsAmf0Any::object();
  1981 + obj->set("http_remux", http_remux);
  1982 +
  1983 + for (int i = 0; i < (int)dir->directives.size(); i++) {
  1984 + SrsConfDirective* sdir = dir->directives.at(i);
  1985 +
  1986 + if (sdir->name == "enabled") {
  1987 + http_remux->set("enabled", sdir->dumps_arg0_to_boolean());
  1988 + } else if (sdir->name == "fast_cache") {
  1989 + http_remux->set("fast_cache", sdir->dumps_arg0_to_number());
  1990 + } else if (sdir->name == "mount") {
  1991 + http_remux->set("mount", sdir->dumps_arg0_to_str());
  1992 + } else if (sdir->name == "hstrs") {
  1993 + http_remux->set("hstrs", sdir->dumps_arg0_to_boolean());
  1994 + }
  1995 + }
1849 } 1996 }
1850 - if ((dir = vhost->get("origin")) != NULL) {  
1851 - obj->set("origin", dir->dumps_args()); 1997 +
  1998 + // http_hooks
  1999 + if ((dir = vhost->get("http_hooks")) != NULL) {
  2000 + SrsAmf0Object* http_hooks = SrsAmf0Any::object();
  2001 + obj->set("http_hooks", http_hooks);
  2002 +
  2003 + for (int i = 0; i < (int)dir->directives.size(); i++) {
  2004 + SrsConfDirective* sdir = dir->directives.at(i);
  2005 +
  2006 + if (sdir->name == "enabled") {
  2007 + http_hooks->set("enabled", sdir->dumps_arg0_to_boolean());
  2008 + } else if (sdir->name == "on_connect") {
  2009 + http_hooks->set("on_connect", sdir->dumps_args());
  2010 + } else if (sdir->name == "on_close") {
  2011 + http_hooks->set("on_close", sdir->dumps_args());
  2012 + } else if (sdir->name == "on_publish") {
  2013 + http_hooks->set("on_publish", sdir->dumps_args());
  2014 + } else if (sdir->name == "on_unpublish") {
  2015 + http_hooks->set("on_unpublish", sdir->dumps_args());
  2016 + } else if (sdir->name == "on_play") {
  2017 + http_hooks->set("on_play", sdir->dumps_args());
  2018 + } else if (sdir->name == "on_stop") {
  2019 + http_hooks->set("on_stop", sdir->dumps_args());
  2020 + } else if (sdir->name == "on_dvr") {
  2021 + http_hooks->set("on_dvr", sdir->dumps_args());
  2022 + } else if (sdir->name == "on_hls") {
  2023 + http_hooks->set("on_hls", sdir->dumps_args());
  2024 + } else if (sdir->name == "on_hls_notify") {
  2025 + http_hooks->set("on_hls_notify", sdir->dumps_arg0_to_str());
  2026 + }
  2027 + }
1852 } 2028 }
1853 - if ((dir = vhost->get("token_traverse")) != NULL) {  
1854 - obj->set("token_traverse", dir->dumps_arg0_to_boolean()); 2029 +
  2030 + // hls
  2031 + if ((dir = vhost->get("hls")) != NULL) {
  2032 + SrsAmf0Object* hls = SrsAmf0Any::object();
  2033 + obj->set("hls", hls);
  2034 +
  2035 + for (int i = 0; i < (int)dir->directives.size(); i++) {
  2036 + SrsConfDirective* sdir = dir->directives.at(i);
  2037 +
  2038 + if (sdir->name == "enabled") {
  2039 + hls->set("enabled", sdir->dumps_arg0_to_boolean());
  2040 + } else if (sdir->name == "hls_fragment") {
  2041 + hls->set("hls_fragment", sdir->dumps_arg0_to_number());
  2042 + } else if (sdir->name == "hls_td_ratio") {
  2043 + hls->set("hls_td_ratio", sdir->dumps_arg0_to_number());
  2044 + } else if (sdir->name == "hls_aof_ratio") {
  2045 + hls->set("hls_aof_ratio", sdir->dumps_arg0_to_number());
  2046 + } else if (sdir->name == "hls_window") {
  2047 + hls->set("hls_window", sdir->dumps_arg0_to_number());
  2048 + } else if (sdir->name == "hls_on_error") {
  2049 + hls->set("hls_on_error", sdir->dumps_arg0_to_str());
  2050 + } else if (sdir->name == "hls_storage") {
  2051 + hls->set("hls_storage", sdir->dumps_arg0_to_str());
  2052 + } else if (sdir->name == "hls_path") {
  2053 + hls->set("hls_path", sdir->dumps_arg0_to_str());
  2054 + } else if (sdir->name == "hls_m3u8_file") {
  2055 + hls->set("hls_m3u8_file", sdir->dumps_arg0_to_str());
  2056 + } else if (sdir->name == "hls_ts_file") {
  2057 + hls->set("hls_ts_file", sdir->dumps_arg0_to_str());
  2058 + } else if (sdir->name == "hls_ts_floor") {
  2059 + hls->set("hls_ts_floor", sdir->dumps_arg0_to_boolean());
  2060 + } else if (sdir->name == "hls_entry_prefix") {
  2061 + hls->set("hls_entry_prefix", sdir->dumps_arg0_to_str());
  2062 + } else if (sdir->name == "hls_mount") {
  2063 + hls->set("hls_mount", sdir->dumps_arg0_to_str());
  2064 + } else if (sdir->name == "hls_acodec") {
  2065 + hls->set("hls_acodec", sdir->dumps_arg0_to_str());
  2066 + } else if (sdir->name == "hls_vcodec") {
  2067 + hls->set("hls_vcodec", sdir->dumps_arg0_to_str());
  2068 + } else if (sdir->name == "hls_cleanup") {
  2069 + hls->set("hls_cleanup", sdir->dumps_arg0_to_boolean());
  2070 + } else if (sdir->name == "hls_dispose") {
  2071 + hls->set("hls_dispose", sdir->dumps_arg0_to_number());
  2072 + } else if (sdir->name == "hls_nb_notify") {
  2073 + hls->set("hls_nb_notify", sdir->dumps_arg0_to_number());
  2074 + } else if (sdir->name == "hls_wait_keyframe") {
  2075 + hls->set("hls_wait_keyframe", sdir->dumps_arg0_to_boolean());
  2076 + }
  2077 + }
1855 } 2078 }
1856 - if ((dir = vhost->get("vhost")) != NULL) {  
1857 - obj->set("vhost", dir->dumps_arg0_to_str()); 2079 +
  2080 + // hds
  2081 + if ((dir = vhost->get("hds")) != NULL) {
  2082 + SrsAmf0Object* hds = SrsAmf0Any::object();
  2083 + obj->set("hds", hds);
  2084 +
  2085 + for (int i = 0; i < (int)dir->directives.size(); i++) {
  2086 + SrsConfDirective* sdir = dir->directives.at(i);
  2087 +
  2088 + if (sdir->name == "enabled") {
  2089 + hds->set("enabled", sdir->dumps_arg0_to_boolean());
  2090 + } else if (sdir->name == "hds_fragment") {
  2091 + hds->set("hds_fragment", sdir->dumps_arg0_to_number());
  2092 + } else if (sdir->name == "hds_window") {
  2093 + hds->set("hds_window", sdir->dumps_arg0_to_number());
  2094 + } else if (sdir->name == "hds_path") {
  2095 + hds->set("hds_path", sdir->dumps_arg0_to_str());
  2096 + }
  2097 + }
1858 } 2098 }
1859 2099
1860 // dvr 2100 // dvr
@@ -1881,6 +2121,22 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj) @@ -1881,6 +2121,22 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj)
1881 } 2121 }
1882 } 2122 }
1883 2123
  2124 + // exec
  2125 + if ((dir = vhost->get("exec")) != NULL) {
  2126 + SrsAmf0Object* ng_exec = SrsAmf0Any::object();
  2127 + obj->set("exec", ng_exec);
  2128 +
  2129 + for (int i = 0; i < (int)dir->directives.size(); i++) {
  2130 + SrsConfDirective* sdir = dir->directives.at(i);
  2131 +
  2132 + if (sdir->name == "enabled") {
  2133 + ng_exec->set("enabled", sdir->dumps_arg0_to_boolean());
  2134 + } else if (sdir->name == "publish") {
  2135 + ng_exec->set("publish", sdir->dumps_args());
  2136 + }
  2137 + }
  2138 + }
  2139 +
1884 // ingest 2140 // ingest
1885 SrsAmf0StrictArray* ingests = NULL; 2141 SrsAmf0StrictArray* ingests = NULL;
1886 for (int i = 0; i < (int)vhost->directives.size(); i++) { 2142 for (int i = 0; i < (int)vhost->directives.size(); i++) {
@@ -1929,40 +2185,28 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj) @@ -1929,40 +2185,28 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj)
1929 } 2185 }
1930 } 2186 }
1931 2187
1932 - // http_static  
1933 - if ((dir = vhost->get("http_static")) != NULL) {  
1934 - SrsAmf0Object* http_static = SrsAmf0Any::object();  
1935 - obj->set("http_static", http_static); 2188 + // transcode
  2189 + if ((dir = vhost->get("transcode")) != NULL) {
  2190 + SrsAmf0Object* transcode = SrsAmf0Any::object();
  2191 + obj->set("transcode", transcode);
1936 2192
1937 - for (int i = 0; i < (int)dir->directives.size(); i++) {  
1938 - SrsConfDirective* sdir = dir->directives.at(i);  
1939 -  
1940 - if (sdir->name == "enabled") {  
1941 - http_static->set("enabled", sdir->dumps_arg0_to_boolean());  
1942 - } else if (sdir->name == "mount") {  
1943 - http_static->set("mount", sdir->dumps_arg0_to_str());  
1944 - } else if (sdir->name == "dir") {  
1945 - http_static->set("dir", sdir->dumps_arg0_to_str());  
1946 - }  
1947 - }  
1948 - }  
1949 -  
1950 - // http_remux  
1951 - if ((dir = vhost->get("http_remux")) != NULL) {  
1952 - SrsAmf0Object* http_remux = SrsAmf0Any::object();  
1953 - obj->set("http_remux", http_remux); 2193 + SrsAmf0StrictArray* engines = SrsAmf0Any::strict_array();
  2194 + obj->set("engines", engines);
1954 2195
1955 for (int i = 0; i < (int)dir->directives.size(); i++) { 2196 for (int i = 0; i < (int)dir->directives.size(); i++) {
1956 SrsConfDirective* sdir = dir->directives.at(i); 2197 SrsConfDirective* sdir = dir->directives.at(i);
1957 2198
1958 if (sdir->name == "enabled") { 2199 if (sdir->name == "enabled") {
1959 - http_remux->set("enabled", sdir->dumps_arg0_to_boolean());  
1960 - } else if (sdir->name == "fast_cache") {  
1961 - http_remux->set("fast_cache", sdir->dumps_arg0_to_number());  
1962 - } else if (sdir->name == "mount") {  
1963 - http_remux->set("mount", sdir->dumps_arg0_to_str());  
1964 - } else if (sdir->name == "hstrs") {  
1965 - http_remux->set("hstrs", sdir->dumps_arg0_to_boolean()); 2200 + transcode->set("enabled", sdir->dumps_arg0_to_boolean());
  2201 + } else if (sdir->name == "ffmpeg") {
  2202 + transcode->set("ffmpeg", sdir->dumps_arg0_to_str());
  2203 + } else if (sdir->name == "engine") {
  2204 + SrsAmf0Object* engine = SrsAmf0Any::object();
  2205 + engines->append(engine);
  2206 +
  2207 + if ((ret = dumps_engine(sdir, engine)) != ERROR_SUCCESS) {
  2208 + return ret;
  2209 + }
1966 } 2210 }
1967 } 2211 }
1968 } 2212 }
@@ -1997,6 +2241,8 @@ int SrsConfig::dumps_engine(SrsConfDirective* dir, SrsAmf0Object* engine) @@ -1997,6 +2241,8 @@ int SrsConfig::dumps_engine(SrsConfDirective* dir, SrsAmf0Object* engine)
1997 2241
1998 SrsConfDirective* conf = NULL; 2242 SrsConfDirective* conf = NULL;
1999 2243
  2244 + engine->set("name", dir->dumps_arg0_to_str());
  2245 +
2000 if ((conf = dir->get("enabled")) != NULL) { 2246 if ((conf = dir->get("enabled")) != NULL) {
2001 engine->set("enabled", conf->dumps_arg0_to_boolean()); 2247 engine->set("enabled", conf->dumps_arg0_to_boolean());
2002 } 2248 }