From 101e4fa3b9d91e489f618a1d2fa74a307bf1698b Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 27 Aug 2022 18:47:49 +0800 Subject: [PATCH] STAT: Add hls-play, flv-play, srt-play and srt-publish. --- trunk/src/app/srs_app_http_static.cpp | 2 +- trunk/src/app/srs_app_http_stream.cpp | 2 +- .../src/protocol/srs_protocol_rtmp_stack.cpp | 6 +++++- .../src/protocol/srs_protocol_rtmp_stack.hpp | 20 ++++++++++++------- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/trunk/src/app/srs_app_http_static.cpp b/trunk/src/app/srs_app_http_static.cpp index ec6aa9c8e..547622622 100644 --- a/trunk/src/app/srs_app_http_static.cpp +++ b/trunk/src/app/srs_app_http_static.cpp @@ -127,7 +127,7 @@ srs_error_t SrsHlsStream::serve_m3u8_ctx(ISrsHttpResponseWriter* w, ISrsHttpMess // update the statistic when source disconveried. SrsStatistic* stat = SrsStatistic::instance(); - if ((err = stat->on_client(ctx, req, NULL, SrsRtmpConnPlay)) != srs_success) { + if ((err = stat->on_client(ctx, req, NULL, SrsHlsPlay)) != srs_success) { return srs_error_wrap(err, "stat on client"); } diff --git a/trunk/src/app/srs_app_http_stream.cpp b/trunk/src/app/srs_app_http_stream.cpp index 31f07c19a..7b7d2d32d 100755 --- a/trunk/src/app/srs_app_http_stream.cpp +++ b/trunk/src/app/srs_app_http_stream.cpp @@ -592,7 +592,7 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess // update the statistic when source disconveried. SrsStatistic* stat = SrsStatistic::instance(); - if ((err = stat->on_client(_srs_context->get_id().c_str(), req, hc, SrsRtmpConnPlay)) != srs_success) { + if ((err = stat->on_client(_srs_context->get_id().c_str(), req, hc, SrsFlvPlay)) != srs_success) { return srs_error_wrap(err, "stat on client"); } diff --git a/trunk/src/protocol/srs_protocol_rtmp_stack.cpp b/trunk/src/protocol/srs_protocol_rtmp_stack.cpp index e4d646650..94eb84ebe 100644 --- a/trunk/src/protocol/srs_protocol_rtmp_stack.cpp +++ b/trunk/src/protocol/srs_protocol_rtmp_stack.cpp @@ -1627,18 +1627,22 @@ string srs_client_type_string(SrsRtmpConnType type) { switch (type) { case SrsRtmpConnPlay: return "rtmp-play"; + case SrsHlsPlay: return "hls-play"; + case SrsFlvPlay: return "flv-play"; case SrsRtcConnPlay: return "rtc-play"; case SrsRtmpConnFlashPublish: return "flash-publish"; case SrsRtmpConnFMLEPublish: return "fmle-publish"; case SrsRtmpConnHaivisionPublish: return "haivision-publish"; case SrsRtcConnPublish: return "rtc-publish"; + case SrsSrtConnPlay: return "srt-play"; + case SrsSrtConnPublish: return "srt-publish"; default: return "Unknown"; } } bool srs_client_type_is_publish(SrsRtmpConnType type) { - return ((type != SrsRtmpConnPlay) && (type != SrsRtcConnPlay)); + return (type & 0xff00) == 0x0200; } SrsHandshakeBytes::SrsHandshakeBytes() diff --git a/trunk/src/protocol/srs_protocol_rtmp_stack.hpp b/trunk/src/protocol/srs_protocol_rtmp_stack.hpp index 053da11c3..b4a2278b5 100644 --- a/trunk/src/protocol/srs_protocol_rtmp_stack.hpp +++ b/trunk/src/protocol/srs_protocol_rtmp_stack.hpp @@ -470,13 +470,19 @@ public: // The rtmp client type. enum SrsRtmpConnType { - SrsRtmpConnUnknown, - SrsRtmpConnPlay, - SrsRtmpConnFMLEPublish, - SrsRtmpConnFlashPublish, - SrsRtmpConnHaivisionPublish, - SrsRtcConnPlay, - SrsRtcConnPublish, + SrsRtmpConnUnknown = 0x0000, + // All players. + SrsRtmpConnPlay = 0x0100, + SrsHlsPlay = 0x0101, + SrsFlvPlay = 0x0102, + SrsRtcConnPlay = 0x0110, + SrsSrtConnPlay = 0x0120, + // All publishers. + SrsRtmpConnFMLEPublish = 0x0200, + SrsRtmpConnFlashPublish = 0x0201, + SrsRtmpConnHaivisionPublish = 0x0202, + SrsRtcConnPublish = 0x0210, + SrsSrtConnPublish = 0x0220, }; std::string srs_client_type_string(SrsRtmpConnType type); bool srs_client_type_is_publish(SrsRtmpConnType type);