正在显示
6 个修改的文件
包含
36 行增加
和
8 行删除
| @@ -495,7 +495,7 @@ int SrsRtmpConn::stream_service_cycle() | @@ -495,7 +495,7 @@ int SrsRtmpConn::stream_service_cycle() | ||
| 495 | 495 | ||
| 496 | // update the statistic when source disconveried. | 496 | // update the statistic when source disconveried. |
| 497 | SrsStatistic* stat = SrsStatistic::instance(); | 497 | SrsStatistic* stat = SrsStatistic::instance(); |
| 498 | - if ((ret = stat->on_client(_srs_context->get_id(), req, this)) != ERROR_SUCCESS) { | 498 | + if ((ret = stat->on_client(_srs_context->get_id(), req, this, type)) != ERROR_SUCCESS) { |
| 499 | srs_error("stat client failed. ret=%d", ret); | 499 | srs_error("stat client failed. ret=%d", ret); |
| 500 | return ret; | 500 | return ret; |
| 501 | } | 501 | } |
| @@ -181,6 +181,11 @@ void SrsStatisticStream::close() | @@ -181,6 +181,11 @@ void SrsStatisticStream::close() | ||
| 181 | SrsStatisticClient::SrsStatisticClient() | 181 | SrsStatisticClient::SrsStatisticClient() |
| 182 | { | 182 | { |
| 183 | id = 0; | 183 | id = 0; |
| 184 | + stream = NULL; | ||
| 185 | + conn = NULL; | ||
| 186 | + req = NULL; | ||
| 187 | + type = SrsRtmpConnUnknown; | ||
| 188 | + create = srs_get_system_time_ms(); | ||
| 184 | } | 189 | } |
| 185 | 190 | ||
| 186 | SrsStatisticClient::~SrsStatisticClient() | 191 | SrsStatisticClient::~SrsStatisticClient() |
| @@ -192,7 +197,17 @@ int SrsStatisticClient::dumps(stringstream& ss) | @@ -192,7 +197,17 @@ int SrsStatisticClient::dumps(stringstream& ss) | ||
| 192 | int ret = ERROR_SUCCESS; | 197 | int ret = ERROR_SUCCESS; |
| 193 | 198 | ||
| 194 | ss << SRS_JOBJECT_START | 199 | ss << SRS_JOBJECT_START |
| 195 | - << SRS_JFIELD_ORG("id", id) | 200 | + << SRS_JFIELD_ORG("id", id) << SRS_JFIELD_CONT |
| 201 | + << SRS_JFIELD_ORG("vhost", stream->vhost->id) << SRS_JFIELD_CONT | ||
| 202 | + << SRS_JFIELD_ORG("stream", stream->id) << SRS_JFIELD_CONT | ||
| 203 | + << SRS_JFIELD_STR("ip", req->ip) << SRS_JFIELD_CONT | ||
| 204 | + << SRS_JFIELD_STR("pageUrl", req->pageUrl) << SRS_JFIELD_CONT | ||
| 205 | + << SRS_JFIELD_STR("swfUrl", req->swfUrl) << SRS_JFIELD_CONT | ||
| 206 | + << SRS_JFIELD_STR("tcUrl", req->tcUrl) << SRS_JFIELD_CONT | ||
| 207 | + << SRS_JFIELD_STR("url", req->get_stream_url()) << SRS_JFIELD_CONT | ||
| 208 | + << SRS_JFIELD_STR("type", srs_client_type_string(type)) << SRS_JFIELD_CONT | ||
| 209 | + << SRS_JFIELD_BOOL("publish", srs_client_type_is_publish(type)) << SRS_JFIELD_CONT | ||
| 210 | + << SRS_JFIELD_ORG("alive", srs_get_system_time_ms() - create) | ||
| 196 | << SRS_JOBJECT_END; | 211 | << SRS_JOBJECT_END; |
| 197 | 212 | ||
| 198 | return ret; | 213 | return ret; |
| @@ -322,7 +337,7 @@ void SrsStatistic::on_stream_close(SrsRequest* req) | @@ -322,7 +337,7 @@ void SrsStatistic::on_stream_close(SrsRequest* req) | ||
| 322 | stream->close(); | 337 | stream->close(); |
| 323 | } | 338 | } |
| 324 | 339 | ||
| 325 | -int SrsStatistic::on_client(int id, SrsRequest* req, SrsConnection* conn) | 340 | +int SrsStatistic::on_client(int id, SrsRequest* req, SrsConnection* conn, SrsRtmpConnType type) |
| 326 | { | 341 | { |
| 327 | int ret = ERROR_SUCCESS; | 342 | int ret = ERROR_SUCCESS; |
| 328 | 343 | ||
| @@ -342,6 +357,8 @@ int SrsStatistic::on_client(int id, SrsRequest* req, SrsConnection* conn) | @@ -342,6 +357,8 @@ int SrsStatistic::on_client(int id, SrsRequest* req, SrsConnection* conn) | ||
| 342 | 357 | ||
| 343 | // got client. | 358 | // got client. |
| 344 | client->conn = conn; | 359 | client->conn = conn; |
| 360 | + client->req = req; | ||
| 361 | + client->type = type; | ||
| 345 | stream->nb_clients++; | 362 | stream->nb_clients++; |
| 346 | vhost->nb_clients++; | 363 | vhost->nb_clients++; |
| 347 | 364 | ||
| @@ -464,7 +481,7 @@ int SrsStatistic::dumps_clients(stringstream& ss, int start, int count) | @@ -464,7 +481,7 @@ int SrsStatistic::dumps_clients(stringstream& ss, int start, int count) | ||
| 464 | 481 | ||
| 465 | ss << SRS_JARRAY_START; | 482 | ss << SRS_JARRAY_START; |
| 466 | std::map<int, SrsStatisticClient*>::iterator it = clients.begin(); | 483 | std::map<int, SrsStatisticClient*>::iterator it = clients.begin(); |
| 467 | - for (int i = 0; i < count && it != clients.end(); it++) { | 484 | + for (int i = 0; i < start + count && it != clients.end(); it++, i++) { |
| 468 | if (i < start) { | 485 | if (i < start) { |
| 469 | continue; | 486 | continue; |
| 470 | } | 487 | } |
| @@ -34,6 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -34,6 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 34 | #include <string> | 34 | #include <string> |
| 35 | 35 | ||
| 36 | #include <srs_kernel_codec.hpp> | 36 | #include <srs_kernel_codec.hpp> |
| 37 | +#include <srs_rtmp_stack.hpp> | ||
| 37 | 38 | ||
| 38 | class SrsKbps; | 39 | class SrsKbps; |
| 39 | class SrsRequest; | 40 | class SrsRequest; |
| @@ -113,7 +114,10 @@ struct SrsStatisticClient | @@ -113,7 +114,10 @@ struct SrsStatisticClient | ||
| 113 | public: | 114 | public: |
| 114 | SrsStatisticStream* stream; | 115 | SrsStatisticStream* stream; |
| 115 | SrsConnection* conn; | 116 | SrsConnection* conn; |
| 117 | + SrsRequest* req; | ||
| 118 | + SrsRtmpConnType type; | ||
| 116 | int id; | 119 | int id; |
| 120 | + int64_t create; | ||
| 117 | public: | 121 | public: |
| 118 | SrsStatisticClient(); | 122 | SrsStatisticClient(); |
| 119 | virtual ~SrsStatisticClient(); | 123 | virtual ~SrsStatisticClient(); |
| @@ -183,8 +187,9 @@ public: | @@ -183,8 +187,9 @@ public: | ||
| 183 | * @param id, the client srs id. | 187 | * @param id, the client srs id. |
| 184 | * @param req, the client request object. | 188 | * @param req, the client request object. |
| 185 | * @param conn, the physical absract connection object. | 189 | * @param conn, the physical absract connection object. |
| 190 | + * @param type, the type of connection. | ||
| 186 | */ | 191 | */ |
| 187 | - virtual int on_client(int id, SrsRequest* req, SrsConnection* conn); | 192 | + virtual int on_client(int id, SrsRequest* req, SrsConnection* conn, SrsRtmpConnType type); |
| 188 | /** | 193 | /** |
| 189 | * client disconnect | 194 | * client disconnect |
| 190 | * @remark the on_disconnect always call, while the on_client is call when | 195 | * @remark the on_disconnect always call, while the on_client is call when |
| @@ -1747,12 +1747,17 @@ string srs_client_type_string(SrsRtmpConnType type) | @@ -1747,12 +1747,17 @@ string srs_client_type_string(SrsRtmpConnType type) | ||
| 1747 | { | 1747 | { |
| 1748 | switch (type) { | 1748 | switch (type) { |
| 1749 | case SrsRtmpConnPlay: return "Play"; | 1749 | case SrsRtmpConnPlay: return "Play"; |
| 1750 | - case SrsRtmpConnFlashPublish: return "publish(FlashPublish)"; | ||
| 1751 | - case SrsRtmpConnFMLEPublish: return "publish(FMLEPublish)"; | 1750 | + case SrsRtmpConnFlashPublish: return "flash-publish)"; |
| 1751 | + case SrsRtmpConnFMLEPublish: return "fmle-publish"; | ||
| 1752 | default: return "Unknown"; | 1752 | default: return "Unknown"; |
| 1753 | } | 1753 | } |
| 1754 | } | 1754 | } |
| 1755 | 1755 | ||
| 1756 | +bool srs_client_type_is_publish(SrsRtmpConnType type) | ||
| 1757 | +{ | ||
| 1758 | + return type != SrsRtmpConnPlay; | ||
| 1759 | +} | ||
| 1760 | + | ||
| 1756 | SrsHandshakeBytes::SrsHandshakeBytes() | 1761 | SrsHandshakeBytes::SrsHandshakeBytes() |
| 1757 | { | 1762 | { |
| 1758 | c0c1 = s0s1s2 = c2 = NULL; | 1763 | c0c1 = s0s1s2 = c2 = NULL; |
| @@ -622,6 +622,7 @@ enum SrsRtmpConnType | @@ -622,6 +622,7 @@ enum SrsRtmpConnType | ||
| 622 | SrsRtmpConnFlashPublish, | 622 | SrsRtmpConnFlashPublish, |
| 623 | }; | 623 | }; |
| 624 | std::string srs_client_type_string(SrsRtmpConnType type); | 624 | std::string srs_client_type_string(SrsRtmpConnType type); |
| 625 | +bool srs_client_type_is_publish(SrsRtmpConnType type); | ||
| 625 | 626 | ||
| 626 | /** | 627 | /** |
| 627 | * store the handshake bytes, | 628 | * store the handshake bytes, |
| @@ -247,7 +247,7 @@ int srs_write_large_iovs(ISrsProtocolReaderWriter* skt, iovec* iovs, int size, s | @@ -247,7 +247,7 @@ int srs_write_large_iovs(ISrsProtocolReaderWriter* skt, iovec* iovs, int size, s | ||
| 247 | // for srs-librtmp, @see https://github.com/simple-rtmp-server/srs/issues/213 | 247 | // for srs-librtmp, @see https://github.com/simple-rtmp-server/srs/issues/213 |
| 248 | #ifndef _WIN32 | 248 | #ifndef _WIN32 |
| 249 | // for linux, generally it's 1024. | 249 | // for linux, generally it's 1024. |
| 250 | - static int limits = sysconf(_SC_IOV_MAX); | 250 | + static int limits = (int)sysconf(_SC_IOV_MAX); |
| 251 | #else | 251 | #else |
| 252 | static int limits = 1024; | 252 | static int limits = 1024; |
| 253 | #endif | 253 | #endif |
-
请 注册 或 登录 后发表评论