From 878833bb95e38b255d673ac2ccc598a7a764b6b7 Mon Sep 17 00:00:00 2001 From: john Date: Tue, 9 Nov 2021 07:35:00 +0800 Subject: [PATCH 1/4] Rtc2Rtmp: Using rtp timestamp to distinguish different video frame (#2721) --- trunk/src/app/srs_app_rtc_source.cpp | 8 ++++++-- trunk/src/app/srs_app_rtc_source.hpp | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/trunk/src/app/srs_app_rtc_source.cpp b/trunk/src/app/srs_app_rtc_source.cpp index a07e61d10..083b2dc46 100644 --- a/trunk/src/app/srs_app_rtc_source.cpp +++ b/trunk/src/app/srs_app_rtc_source.cpp @@ -1437,6 +1437,7 @@ srs_error_t SrsRtmpFromRtcBridger::packet_video(SrsRtpPacket* src) cache_video_pkts_[index].pkt = pkt; cache_video_pkts_[index].sn = pkt->header.get_sequence(); cache_video_pkts_[index].ts = pkt->get_avsync_time(); + cache_video_pkts_[index].rtp_ts = pkt->header.get_timestamp(); // check whether to recovery lost packet and can construct a video frame if (lost_sn_ == pkt->header.get_sequence()) { @@ -1525,6 +1526,7 @@ srs_error_t SrsRtmpFromRtcBridger::packet_video_key_frame(SrsRtpPacket* pkt) cache_video_pkts_[index].pkt = pkt; cache_video_pkts_[index].sn = pkt->header.get_sequence(); cache_video_pkts_[index].ts = pkt->get_avsync_time(); + cache_video_pkts_[index].rtp_ts = pkt->header.get_timestamp(); int32_t sn = lost_sn_; uint16_t tail_sn = 0; @@ -1622,6 +1624,7 @@ srs_error_t SrsRtmpFromRtcBridger::packet_video_rtmp(const uint16_t start, const cache_video_pkts_[index].in_use = false; cache_video_pkts_[index].pkt = NULL; cache_video_pkts_[index].ts = 0; + cache_video_pkts_[index].rtp_ts = 0; cache_video_pkts_[index].sn = 0; SrsRtpFUAPayload2* fua_payload = dynamic_cast(pkt->payload()); @@ -1692,7 +1695,7 @@ srs_error_t SrsRtmpFromRtcBridger::packet_video_rtmp(const uint16_t start, const int32_t SrsRtmpFromRtcBridger::find_next_lost_sn(uint16_t current_sn, uint16_t& end_sn) { - uint32_t last_ts = cache_video_pkts_[cache_index(header_sn_)].ts; + uint32_t last_rtp_ts = cache_video_pkts_[cache_index(header_sn_)].rtp_ts; for (int i = 0; i < s_cache_size; ++i) { uint16_t lost_sn = current_sn + i; int index = cache_index(lost_sn); @@ -1701,7 +1704,7 @@ int32_t SrsRtmpFromRtcBridger::find_next_lost_sn(uint16_t current_sn, uint16_t& return lost_sn; } //check time first, avoid two small frame mixed case decode fail - if (last_ts != cache_video_pkts_[index].ts) { + if (last_rtp_ts != cache_video_pkts_[index].rtp_ts) { end_sn = lost_sn - 1; return -1; } @@ -1724,6 +1727,7 @@ void SrsRtmpFromRtcBridger::clear_cached_video() srs_freep(cache_video_pkts_[i].pkt); cache_video_pkts_[i].sn = 0; cache_video_pkts_[i].ts = 0; + cache_video_pkts_[i].rtp_ts = 0; cache_video_pkts_[i].in_use = false; } } diff --git a/trunk/src/app/srs_app_rtc_source.hpp b/trunk/src/app/srs_app_rtc_source.hpp index d49e6f230..c8000e02d 100644 --- a/trunk/src/app/srs_app_rtc_source.hpp +++ b/trunk/src/app/srs_app_rtc_source.hpp @@ -300,6 +300,7 @@ private: bool in_use; uint16_t sn; uint32_t ts; + uint32_t rtp_ts; SrsRtpPacket* pkt; }; const static uint16_t s_cache_size = 512; @@ -325,7 +326,7 @@ private: int32_t find_next_lost_sn(uint16_t current_sn, uint16_t& end_sn); void clear_cached_video(); inline uint16_t cache_index(uint16_t current_sn) { - return current_sn%s_cache_size; + return current_sn % s_cache_size; } bool check_frame_complete(const uint16_t start, const uint16_t end); }; From 92f061ee7da278a792617f72a4e33b08cf998486 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 9 Nov 2021 07:36:48 +0800 Subject: [PATCH 2/4] Rtc2Rtmp: Use RTP timestamp to identify video frames. v4.0.195 (#2721) --- trunk/doc/CHANGELOG.md | 1 + trunk/src/core/srs_core_version4.hpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index ad41718d9..9bcd9939d 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -8,6 +8,7 @@ The changelog for SRS. ## SRS 4.0 Changelog +* v4.0, 2021-11-09, Merge [#2721](https://github.com/ossrs/srs/pull/2721): Rtc2Rtmp: Use RTP timestamp to identify video frames. v4.0.195 * v4.0, 2021-11-07, Merge [#2711](https://github.com/ossrs/srs/pull/2711): Config: Guess config files by [FHS](https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard). v4.0.194 * v4.0, 2021-11-07, Merge [#2714](https://github.com/ossrs/srs/pull/2714): DVR: copy req from publish. v4.0.193 * v4.0, 2021-11-04, Merge [#2707](https://github.com/ossrs/srs/pull/2707): Refuse edge request when state is stopping. v4.0.192 diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index e23b3c149..6cc4e59d8 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 4 #define VERSION_MINOR 0 -#define VERSION_REVISION 194 +#define VERSION_REVISION 195 #endif From 5c09dec224fcccb1d2c3ff20a384672798f03f62 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 10 Nov 2021 09:57:48 +0800 Subject: [PATCH 3/4] Update README, Add FAQ --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5db6faec2..37510c3e5 100755 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ [![](https://github.com/ossrs/srs/actions/workflows/release.yml/badge.svg)](https://github.com/ossrs/srs/actions/workflows/release.yml?query=workflow%3ARelease) [![](https://github.com/ossrs/srs/actions/workflows/test.yml/badge.svg?branch=4.0release)](https://github.com/ossrs/srs/actions?query=workflow%3ATest+branch%3A4.0release) [![](https://codecov.io/gh/ossrs/srs/branch/4.0release/graph/badge.svg)](https://codecov.io/gh/ossrs/srs/branch/4.0release) -[![](https://gitee.com/winlinvip/srs-wiki/raw/master/images/wechat-badge2.png)](../../wikis/Contact#wechat) -[![](https://gitee.com/winlinvip/srs-wiki/raw/master/images/bbs2.png)](http://bbs.ossrs.net) +[![](https://gitee.com/winlinvip/srs-wiki/raw/master/images/wechat-badge4.svg)](../../wikis/Contact#wechat) +[![](https://gitee.com/winlinvip/srs-wiki/raw/master/images/srs-faq.svg)](https://github.com/ossrs/srs/issues/2716) SRS/4.0,[Leo][release4],是一个简单高效的实时视频服务器,支持RTMP/WebRTC/HLS/HTTP-FLV/SRT。 From 469bd8cfe2165e2dceaf2c1e4e5eddea487ae5e7 Mon Sep 17 00:00:00 2001 From: john Date: Sat, 13 Nov 2021 19:09:45 +0800 Subject: [PATCH 4/4] RTC: check audio track exist when negotiate (#2729) --- trunk/src/app/srs_app_rtc_source.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/trunk/src/app/srs_app_rtc_source.cpp b/trunk/src/app/srs_app_rtc_source.cpp index 083b2dc46..75db9b9ac 100644 --- a/trunk/src/app/srs_app_rtc_source.cpp +++ b/trunk/src/app/srs_app_rtc_source.cpp @@ -659,6 +659,9 @@ std::vector SrsRtcSource::get_track_desc(std::string ty } if (type == "audio") { + if (! stream_desc_->audio_track_desc_) { + return track_descs; + } if (stream_desc_->audio_track_desc_->media_->name_ == media_name) { track_descs.push_back(stream_desc_->audio_track_desc_); }