Skip to content

Commit b0e7f62

Browse files
suzp1984winlinvip
andcommitted
RTC2RTMP: Fix screen sharing stutter caused by packet loss. v5.0.216 (#4160)
1. Refer this commit, which contains the web demo to capture screen as video stream through RTC. 2. Copy the `trunk/research/players/whip.html` and `trunk/research/players/js/srs.sdk.js` to replace the `develop` branch source code. 3. `./configure && make` 4. `./objs/srs -c conf/rtc2rtmp.conf` 5. open `http://localhost:8080/players/whip.html?schema=http` 6. check `Screen` radio option. 7. click `publish`, then check the screen to share. 8. play the rtmp live stream: `rtmp://localhost/live/livestream` 9. check the video stuttering. When capture screen by the chrome web browser, which send RTP packet with empty payload frequently, then all the cached RTP packets are dropped before next key frame arrive in this case. The OBS screen stream and camera stream do not have such problem. ><img width="581" alt="Screenshot 2024-08-28 at 2 49 46 PM" src="https://github.com/user-attachments/assets/9557dbd2-c799-4dfd-b336-5bbf2e4f8fb8"> --------- Co-authored-by: winlin <[email protected]>
1 parent bfdbbb9 commit b0e7f62

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

trunk/doc/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The changelog for SRS.
77
<a name="v5-changes"></a>
88

99
## SRS 5.0 Changelog
10+
* v5.0, 2024-10-15, Merge [#4160](https://github.com/ossrs/srs/pull/4160): RTC2RTMP: Fix screen sharing stutter caused by packet loss. v5.0.216 (#4160)
1011
* v5.0, 2024-09-09, Merge [#4171](https://github.com/ossrs/srs/pull/4171): Heartbeat: Report ports for proxy server. v5.0.215 (#4171)
1112
* v5.0, 2024-07-24, Merge [#4126](https://github.com/ossrs/srs/pull/4126): Edge: Improve stability for state and fd closing. v5.0.214 (#4126)
1213
* v5.0, 2024-06-03, Merge [#4057](https://github.com/ossrs/srs/pull/4057): RTC: Support dropping h.264 SEI from NALUs. v5.0.213 (#4057)

trunk/src/app/srs_app_rtc_source.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -1705,6 +1705,23 @@ srs_error_t SrsRtmpFromRtcBridge::packet_video_rtmp(const uint16_t start, const
17051705

17061706
if (0 == nb_payload) {
17071707
srs_warn("empty nalu");
1708+
1709+
// The chrome web browser send RTP packet with empty payload frequently,
1710+
// reset header_sn_, lost_sn_ and continue to found next frame in this case,
1711+
// otherwise, all the cached RTP packets are dropped before next key frame arrive.
1712+
header_sn_ = end + 1;
1713+
uint16_t tail_sn = 0;
1714+
int sn = find_next_lost_sn(header_sn_, tail_sn);
1715+
if (-1 == sn) {
1716+
if (check_frame_complete(header_sn_, tail_sn)) {
1717+
err = packet_video_rtmp(header_sn_, tail_sn);
1718+
}
1719+
} else if (-2 == sn) {
1720+
return srs_error_new(ERROR_RTC_RTP_MUXER, "video cache is overflow");
1721+
} else {
1722+
lost_sn_ = sn;
1723+
}
1724+
17081725
return err;
17091726
}
17101727

trunk/src/core/srs_core_version5.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
#define VERSION_MAJOR 5
1111
#define VERSION_MINOR 0
12-
#define VERSION_REVISION 215
12+
#define VERSION_REVISION 216
1313

1414
#endif

0 commit comments

Comments
 (0)