diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh old mode 100755 new mode 100644 index a843868a3..b068d28f2 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -572,7 +572,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then rm -rf research/api-server/static-dir/forward && mkdir -p `pwd`/${SRS_OBJS}/nginx/html/forward && ln -sf `pwd`/${SRS_OBJS}/nginx/html/forward research/api-server/static-dir/forward - ret=$?; if [[ $ret -ne 0 ]]; then echo "link players to cherrypy static-dir failed, ret=$ret"; exit $ret; fi + ret=$?; if [[ $ret -ne 0 ]]; then echo "[warn] link players to cherrypy static-dir failed"; fi fi ##################################################################################### diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 9943780ce..59aec4328 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -2570,7 +2570,7 @@ bool SrsConfig::get_vhost_is_edge(SrsConfDirective* vhost) return SRS_CONF_DEFAULT_EDGE_MODE; } - return conf->arg0() == "remote"; + return "remote" == conf->arg0(); } SrsConfDirective* SrsConfig::get_vhost_edge_origin(string vhost) diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 8eb657f64..d4c4d7823 100644 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -1917,7 +1917,8 @@ int SrsSource::on_publish() srs_error("handle on publish failed. ret=%d", ret); return ret; } - + SrsStatistic* stat = SrsStatistic::instance(); + stat->on_stream_publish(_req); return ret; } @@ -1958,6 +1959,8 @@ void SrsSource::on_unpublish() // notify the handler. srs_assert(handler); + SrsStatistic* stat = SrsStatistic::instance(); + stat->on_stream_close(_req); handler->on_unpublish(this, _req); } diff --git a/trunk/src/app/srs_app_statistic.cpp b/trunk/src/app/srs_app_statistic.cpp index 2df8c7460..59076db0f 100644 --- a/trunk/src/app/srs_app_statistic.cpp +++ b/trunk/src/app/srs_app_statistic.cpp @@ -58,6 +58,7 @@ SrsStatisticStream::SrsStatisticStream() { id = srs_generate_id(); vhost = NULL; + status = STATISTIC_STREAM_STATUS_IDLING; has_video = false; vcodec = SrsCodecVideoReserved; @@ -79,10 +80,16 @@ SrsStatisticStream::~SrsStatisticStream() srs_freep(kbps); } +void SrsStatisticStream::publish() +{ + status = STATISTIC_STREAM_STATUS_PUBLISHING; +} + void SrsStatisticStream::close() { has_video = false; has_audio = false; + status = STATISTIC_STREAM_STATUS_IDLING; } SrsStatistic* SrsStatistic::_instance = new SrsStatistic(); @@ -161,6 +168,14 @@ int SrsStatistic::on_audio_info(SrsRequest* req, return ret; } +void SrsStatistic::on_stream_publish(SrsRequest* req) +{ + SrsStatisticVhost* vhost = create_vhost(req); + SrsStatisticStream* stream = create_stream(vhost, req); + + stream->publish(); +} + void SrsStatistic::on_stream_close(SrsRequest* req) { SrsStatisticVhost* vhost = create_vhost(req); @@ -308,7 +323,8 @@ int SrsStatistic::dumps_streams(stringstream& ss) << SRS_JFIELD_ORG("clients", client_num) << SRS_JFIELD_CONT << SRS_JFIELD_ORG("send_bytes", stream->kbps->get_send_bytes()) << SRS_JFIELD_CONT << SRS_JFIELD_ORG("recv_bytes", stream->kbps->get_recv_bytes()) << SRS_JFIELD_CONT - << SRS_JFIELD_ORG("live_ms", srs_get_system_time_ms()) << SRS_JFIELD_CONT; + << SRS_JFIELD_ORG("live_ms", srs_get_system_time_ms()) << SRS_JFIELD_CONT + << SRS_JFIELD_STR("status", stream->status) << SRS_JFIELD_CONT; if (!stream->has_video) { ss << SRS_JFIELD_NULL("video") << SRS_JFIELD_CONT; diff --git a/trunk/src/app/srs_app_statistic.hpp b/trunk/src/app/srs_app_statistic.hpp index 66daaa130..2468acf62 100644 --- a/trunk/src/app/srs_app_statistic.hpp +++ b/trunk/src/app/srs_app_statistic.hpp @@ -35,6 +35,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include +#define STATISTIC_STREAM_STATUS_PUBLISHING "publishing" +#define STATISTIC_STREAM_STATUS_IDLING "idling" + class SrsKbps; class SrsRequest; class SrsConnection; @@ -62,6 +65,7 @@ public: std::string app; std::string stream; std::string url; + std::string status; public: /** * stream total kbps. @@ -90,6 +94,10 @@ public: SrsStatisticStream(); virtual ~SrsStatisticStream(); public: + /** + * publish the stream. + */ + virtual void publish(); /** * close the stream. */ @@ -137,6 +145,10 @@ public: SrsAacObjectType aac_object ); /** + * when publish stream. + */ + virtual void on_stream_publish(SrsRequest* req); + /** * when close stream. */ virtual void on_stream_close(SrsRequest* req);