正在显示
3 个修改的文件
包含
22 行增加
和
17 行删除
@@ -2066,7 +2066,7 @@ int SrsSource::on_publish() | @@ -2066,7 +2066,7 @@ int SrsSource::on_publish() | ||
2066 | return ret; | 2066 | return ret; |
2067 | } | 2067 | } |
2068 | SrsStatistic* stat = SrsStatistic::instance(); | 2068 | SrsStatistic* stat = SrsStatistic::instance(); |
2069 | - stat->on_stream_publish(_req); | 2069 | + stat->on_stream_publish(_req, _source_id); |
2070 | return ret; | 2070 | return ret; |
2071 | } | 2071 | } |
2072 | 2072 |
@@ -91,7 +91,8 @@ SrsStatisticStream::SrsStatisticStream() | @@ -91,7 +91,8 @@ SrsStatisticStream::SrsStatisticStream() | ||
91 | { | 91 | { |
92 | id = srs_generate_id(); | 92 | id = srs_generate_id(); |
93 | vhost = NULL; | 93 | vhost = NULL; |
94 | - status = STATISTIC_STREAM_STATUS_IDLING; | 94 | + active = false; |
95 | + connection_cid = -1; | ||
95 | 96 | ||
96 | has_video = false; | 97 | has_video = false; |
97 | vcodec = SrsCodecVideoReserved; | 98 | vcodec = SrsCodecVideoReserved; |
@@ -124,6 +125,7 @@ int SrsStatisticStream::dumps(stringstream& ss) | @@ -124,6 +125,7 @@ int SrsStatisticStream::dumps(stringstream& ss) | ||
124 | << SRS_JFIELD_STR("name", stream) << SRS_JFIELD_CONT | 125 | << SRS_JFIELD_STR("name", stream) << SRS_JFIELD_CONT |
125 | << SRS_JFIELD_ORG("vhost", vhost->id) << SRS_JFIELD_CONT | 126 | << SRS_JFIELD_ORG("vhost", vhost->id) << SRS_JFIELD_CONT |
126 | << SRS_JFIELD_STR("app", app) << SRS_JFIELD_CONT | 127 | << SRS_JFIELD_STR("app", app) << SRS_JFIELD_CONT |
128 | + << SRS_JFIELD_ORG("live_ms", srs_get_system_time_ms()) << SRS_JFIELD_CONT | ||
127 | << SRS_JFIELD_ORG("clients", nb_clients) << SRS_JFIELD_CONT | 129 | << SRS_JFIELD_ORG("clients", nb_clients) << SRS_JFIELD_CONT |
128 | << SRS_JFIELD_ORG("send_bytes", kbps->get_send_bytes()) << SRS_JFIELD_CONT | 130 | << SRS_JFIELD_ORG("send_bytes", kbps->get_send_bytes()) << SRS_JFIELD_CONT |
129 | << SRS_JFIELD_ORG("recv_bytes", kbps->get_recv_bytes()) << SRS_JFIELD_CONT | 131 | << SRS_JFIELD_ORG("recv_bytes", kbps->get_recv_bytes()) << SRS_JFIELD_CONT |
@@ -131,8 +133,10 @@ int SrsStatisticStream::dumps(stringstream& ss) | @@ -131,8 +133,10 @@ int SrsStatisticStream::dumps(stringstream& ss) | ||
131 | << SRS_JFIELD_ORG("recv_30s", kbps->get_recv_kbps_30s()) << SRS_JFIELD_CONT | 133 | << SRS_JFIELD_ORG("recv_30s", kbps->get_recv_kbps_30s()) << SRS_JFIELD_CONT |
132 | << SRS_JFIELD_ORG("send_30s", kbps->get_send_kbps_30s()) | 134 | << SRS_JFIELD_ORG("send_30s", kbps->get_send_kbps_30s()) |
133 | << SRS_JOBJECT_END << SRS_JFIELD_CONT | 135 | << SRS_JOBJECT_END << SRS_JFIELD_CONT |
134 | - << SRS_JFIELD_ORG("live_ms", srs_get_system_time_ms()) << SRS_JFIELD_CONT | ||
135 | - << SRS_JFIELD_STR("status", status) << SRS_JFIELD_CONT; | 136 | + << SRS_JFIELD_OBJ("publish") |
137 | + << SRS_JFIELD_BOOL("active", active) << SRS_JFIELD_CONT | ||
138 | + << SRS_JFIELD_ORG("cid", connection_cid) | ||
139 | + << SRS_JOBJECT_END << SRS_JFIELD_CONT; | ||
136 | 140 | ||
137 | if (!has_video) { | 141 | if (!has_video) { |
138 | ss << SRS_JFIELD_NULL("video") << SRS_JFIELD_CONT; | 142 | ss << SRS_JFIELD_NULL("video") << SRS_JFIELD_CONT; |
@@ -161,16 +165,17 @@ int SrsStatisticStream::dumps(stringstream& ss) | @@ -161,16 +165,17 @@ int SrsStatisticStream::dumps(stringstream& ss) | ||
161 | return ret; | 165 | return ret; |
162 | } | 166 | } |
163 | 167 | ||
164 | -void SrsStatisticStream::publish() | 168 | +void SrsStatisticStream::publish(int cid) |
165 | { | 169 | { |
166 | - status = STATISTIC_STREAM_STATUS_PUBLISHING; | 170 | + connection_cid = cid; |
171 | + active = true; | ||
167 | } | 172 | } |
168 | 173 | ||
169 | void SrsStatisticStream::close() | 174 | void SrsStatisticStream::close() |
170 | { | 175 | { |
171 | has_video = false; | 176 | has_video = false; |
172 | has_audio = false; | 177 | has_audio = false; |
173 | - status = STATISTIC_STREAM_STATUS_IDLING; | 178 | + active = false; |
174 | } | 179 | } |
175 | 180 | ||
176 | SrsStatisticClient::SrsStatisticClient() | 181 | SrsStatisticClient::SrsStatisticClient() |
@@ -301,12 +306,12 @@ int SrsStatistic::on_audio_info(SrsRequest* req, | @@ -301,12 +306,12 @@ int SrsStatistic::on_audio_info(SrsRequest* req, | ||
301 | return ret; | 306 | return ret; |
302 | } | 307 | } |
303 | 308 | ||
304 | -void SrsStatistic::on_stream_publish(SrsRequest* req) | 309 | +void SrsStatistic::on_stream_publish(SrsRequest* req, int cid) |
305 | { | 310 | { |
306 | SrsStatisticVhost* vhost = create_vhost(req); | 311 | SrsStatisticVhost* vhost = create_vhost(req); |
307 | SrsStatisticStream* stream = create_stream(vhost, req); | 312 | SrsStatisticStream* stream = create_stream(vhost, req); |
308 | 313 | ||
309 | - stream->publish(); | 314 | + stream->publish(cid); |
310 | } | 315 | } |
311 | 316 | ||
312 | void SrsStatistic::on_stream_close(SrsRequest* req) | 317 | void SrsStatistic::on_stream_close(SrsRequest* req) |
@@ -35,9 +35,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -35,9 +35,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
35 | 35 | ||
36 | #include <srs_kernel_codec.hpp> | 36 | #include <srs_kernel_codec.hpp> |
37 | 37 | ||
38 | -#define STATISTIC_STREAM_STATUS_PUBLISHING "publishing" | ||
39 | -#define STATISTIC_STREAM_STATUS_IDLING "idling" | ||
40 | - | ||
41 | class SrsKbps; | 38 | class SrsKbps; |
42 | class SrsRequest; | 39 | class SrsRequest; |
43 | class SrsConnection; | 40 | class SrsConnection; |
@@ -68,7 +65,8 @@ public: | @@ -68,7 +65,8 @@ public: | ||
68 | std::string app; | 65 | std::string app; |
69 | std::string stream; | 66 | std::string stream; |
70 | std::string url; | 67 | std::string url; |
71 | - std::string status; | 68 | + bool active; |
69 | + int connection_cid; | ||
72 | int nb_clients; | 70 | int nb_clients; |
73 | public: | 71 | public: |
74 | /** | 72 | /** |
@@ -103,7 +101,7 @@ public: | @@ -103,7 +101,7 @@ public: | ||
103 | /** | 101 | /** |
104 | * publish the stream. | 102 | * publish the stream. |
105 | */ | 103 | */ |
106 | - virtual void publish(); | 104 | + virtual void publish(int cid); |
107 | /** | 105 | /** |
108 | * close the stream. | 106 | * close the stream. |
109 | */ | 107 | */ |
@@ -169,9 +167,11 @@ public: | @@ -169,9 +167,11 @@ public: | ||
169 | SrsAacObjectType aac_object | 167 | SrsAacObjectType aac_object |
170 | ); | 168 | ); |
171 | /** | 169 | /** |
172 | - * when publish stream. | ||
173 | - */ | ||
174 | - virtual void on_stream_publish(SrsRequest* req); | 170 | + * when publish stream. |
171 | + * @param req the request object of publish connection. | ||
172 | + * @param cid the cid of publish connection. | ||
173 | + */ | ||
174 | + virtual void on_stream_publish(SrsRequest* req, int cid); | ||
175 | /** | 175 | /** |
176 | * when close stream. | 176 | * when close stream. |
177 | */ | 177 | */ |
-
请 注册 或 登录 后发表评论