diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index f60f28887..b86a04490 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -2066,7 +2066,7 @@ int SrsSource::on_publish() return ret; } SrsStatistic* stat = SrsStatistic::instance(); - stat->on_stream_publish(_req); + stat->on_stream_publish(_req, _source_id); return ret; } diff --git a/trunk/src/app/srs_app_statistic.cpp b/trunk/src/app/srs_app_statistic.cpp index aba82490b..386404680 100755 --- a/trunk/src/app/srs_app_statistic.cpp +++ b/trunk/src/app/srs_app_statistic.cpp @@ -91,7 +91,8 @@ SrsStatisticStream::SrsStatisticStream() { id = srs_generate_id(); vhost = NULL; - status = STATISTIC_STREAM_STATUS_IDLING; + active = false; + connection_cid = -1; has_video = false; vcodec = SrsCodecVideoReserved; @@ -124,6 +125,7 @@ int SrsStatisticStream::dumps(stringstream& ss) << SRS_JFIELD_STR("name", stream) << SRS_JFIELD_CONT << SRS_JFIELD_ORG("vhost", vhost->id) << SRS_JFIELD_CONT << SRS_JFIELD_STR("app", app) << SRS_JFIELD_CONT + << SRS_JFIELD_ORG("live_ms", srs_get_system_time_ms()) << SRS_JFIELD_CONT << SRS_JFIELD_ORG("clients", nb_clients) << SRS_JFIELD_CONT << SRS_JFIELD_ORG("send_bytes", kbps->get_send_bytes()) << SRS_JFIELD_CONT << SRS_JFIELD_ORG("recv_bytes", kbps->get_recv_bytes()) << SRS_JFIELD_CONT @@ -131,8 +133,10 @@ int SrsStatisticStream::dumps(stringstream& ss) << SRS_JFIELD_ORG("recv_30s", kbps->get_recv_kbps_30s()) << SRS_JFIELD_CONT << SRS_JFIELD_ORG("send_30s", kbps->get_send_kbps_30s()) << SRS_JOBJECT_END << SRS_JFIELD_CONT - << SRS_JFIELD_ORG("live_ms", srs_get_system_time_ms()) << SRS_JFIELD_CONT - << SRS_JFIELD_STR("status", status) << SRS_JFIELD_CONT; + << SRS_JFIELD_OBJ("publish") + << SRS_JFIELD_BOOL("active", active) << SRS_JFIELD_CONT + << SRS_JFIELD_ORG("cid", connection_cid) + << SRS_JOBJECT_END << SRS_JFIELD_CONT; if (!has_video) { ss << SRS_JFIELD_NULL("video") << SRS_JFIELD_CONT; @@ -161,16 +165,17 @@ int SrsStatisticStream::dumps(stringstream& ss) return ret; } -void SrsStatisticStream::publish() +void SrsStatisticStream::publish(int cid) { - status = STATISTIC_STREAM_STATUS_PUBLISHING; + connection_cid = cid; + active = true; } void SrsStatisticStream::close() { has_video = false; has_audio = false; - status = STATISTIC_STREAM_STATUS_IDLING; + active = false; } SrsStatisticClient::SrsStatisticClient() @@ -301,12 +306,12 @@ int SrsStatistic::on_audio_info(SrsRequest* req, return ret; } -void SrsStatistic::on_stream_publish(SrsRequest* req) +void SrsStatistic::on_stream_publish(SrsRequest* req, int cid) { SrsStatisticVhost* vhost = create_vhost(req); SrsStatisticStream* stream = create_stream(vhost, req); - stream->publish(); + stream->publish(cid); } void SrsStatistic::on_stream_close(SrsRequest* req) diff --git a/trunk/src/app/srs_app_statistic.hpp b/trunk/src/app/srs_app_statistic.hpp index 9a8483245..27ea06daa 100755 --- a/trunk/src/app/srs_app_statistic.hpp +++ b/trunk/src/app/srs_app_statistic.hpp @@ -35,9 +35,6 @@ 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; @@ -68,7 +65,8 @@ public: std::string app; std::string stream; std::string url; - std::string status; + bool active; + int connection_cid; int nb_clients; public: /** @@ -103,7 +101,7 @@ public: /** * publish the stream. */ - virtual void publish(); + virtual void publish(int cid); /** * close the stream. */ @@ -169,9 +167,11 @@ public: SrsAacObjectType aac_object ); /** - * when publish stream. - */ - virtual void on_stream_publish(SrsRequest* req); + * when publish stream. + * @param req the request object of publish connection. + * @param cid the cid of publish connection. + */ + virtual void on_stream_publish(SrsRequest* req, int cid); /** * when close stream. */