diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index 4ca85c41e..75b4b78ca 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -41,6 +41,14 @@ max_connections 1000; # @remark: donot support reload. # default: on daemon on; +# heartbeat to api server +# when startup, srs will heartbeat to this api. +# @remark: must be a restful http api url, where SRS will POST with following data: +# { +# "device_id": "my-srs-device", +# "ip": "192.168.1.100" +# } +heartbeat http://127.0.0.1:8085/api/v1/servers; ############################################################################################# # HTTP sections diff --git a/trunk/research/api-server/server.py b/trunk/research/api-server/server.py index af1d09a0f..376797890 100755 --- a/trunk/research/api-server/server.py +++ b/trunk/research/api-server/server.py @@ -428,8 +428,8 @@ class RESTServers(object): return None def __refresh_nodes(self): - has_dead_node = False while len(self.__nodes) > 0: + has_dead_node = False for node in self.__nodes: if node.dead(): self.__nodes.remove(node) @@ -639,6 +639,22 @@ class RESTServers(object): "stream6": "http://demo.chnvideo.com:8085/api/v1/servers?id=ingest&action=hls&device_id=chnvideo-meiyi-cubieboard-bk&stream=live/stream6", "stream7": "http://demo.chnvideo.com:8085/api/v1/servers?id=ingest&action=hls&device_id=chnvideo-meiyi-cubieboard-bk&stream=live/stream7" } + }, + "meiyi-dev1": { + "rtmp": { + "livesteam": "http://demo.chnvideo.com:8085/api/v1/servers?id=ingest&action=rtmp&device_id=chnvideo-meiyi-cubieboard-dev1&stream=live/livestream" + }, + "hls": { + "livesteam": "http://demo.chnvideo.com:8085/api/v1/servers?id=ingest&action=hls&device_id=chnvideo-meiyi-cubieboard-dev1&stream=live/livestream" + } + }, + "meiyi-dev2": { + "rtmp": { + "livesteam": "http://demo.chnvideo.com:8085/api/v1/servers?id=ingest&action=rtmp&device_id=chnvideo-meiyi-cubieboard-dev2&stream=live/livestream" + }, + "hls": { + "livesteam": "http://demo.chnvideo.com:8085/api/v1/servers?id=ingest&action=hls&device_id=chnvideo-meiyi-cubieboard-dev2&stream=live/livestream" + } } } } @@ -732,8 +748,8 @@ class RESTNodes(object): return None def __refresh_nodes(self): - has_dead_node = False while len(self.__nodes) > 0: + has_dead_node = False for node in self.__nodes: if node.dead(): self.__nodes.remove(node) diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index a2ef152ad..8382958e2 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -509,7 +509,7 @@ int SrsConfig::reload() // // always support reload without additional code: // chunk_size, ff_log_dir, max_connections, - // bandcheck, http_hooks + // bandcheck, http_hooks, heartbeat // merge config: listen if (!srs_directive_equals(root->get("listen"), old_root->get("listen"))) { @@ -1422,6 +1422,17 @@ string SrsConfig::get_pid_file() return conf->arg0(); } +string SrsConfig::get_heartbeat_url() +{ + SrsConfDirective* conf = root->get("heartbeat"); + + if (!conf) { + return ""; + } + + return conf->arg0(); +} + int SrsConfig::get_pithy_print_publish() { SrsConfDirective* pithy = root->get("pithy_print"); diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp index 4135730b6..05fa9851b 100644 --- a/trunk/src/app/srs_app_config.hpp +++ b/trunk/src/app/srs_app_config.hpp @@ -173,6 +173,7 @@ public: virtual int get_max_connections(); virtual SrsConfDirective* get_listen(); virtual std::string get_pid_file(); + virtual std::string get_heartbeat_url(); virtual int get_pithy_print_publish(); virtual int get_pithy_print_forwarder(); virtual int get_pithy_print_encoder();