From e50582f9c72258bfb057cf6a143f9cf1f2b1e54d Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 21 May 2021 19:57:59 +0800 Subject: [PATCH] SquashSRS4: Refine SDK --- README.md | 2 + trunk/research/players/js/srs.sdk.js | 16 +++-- trunk/research/players/rtc_player.html | 84 +++++++++++------------ trunk/research/players/rtc_publisher.html | 83 +++++++++++----------- trunk/src/app/srs_app_rtc_conn.cpp | 4 ++ trunk/src/core/srs_core_version4.hpp | 2 +- 6 files changed, 102 insertions(+), 89 deletions(-) diff --git a/README.md b/README.md index af1f15bd9..de3266765 100755 --- a/README.md +++ b/README.md @@ -181,6 +181,7 @@ The ports used by SRS: ## V4 changes +* v4.0, 2021-05-21, Fix [#2370][bug #2370] bug for Firefox play stream(published by Chrome). 4.0.121 * v4.0, 2021-05-21, RTC: Refine sdk, migrate from onaddstream to ontrack. 4.0.120 * v4.0, 2021-05-21, Tools: Refine configure options. 4.0.119 * v4.0, 2021-05-20, Fix build fail when disable RTC by --rtc=off. 4.0.118 @@ -1924,6 +1925,7 @@ Winlin [bug #2355]: https://github.com/ossrs/srs/issues/2355 [bug #307]: https://github.com/ossrs/srs/issues/307 [bug #2362]: https://github.com/ossrs/srs/issues/2362 +[bug #2370]: https://github.com/ossrs/srs/issues/2370 [bug #yyyyyyyyyyyyy]: https://github.com/ossrs/srs/issues/yyyyyyyyyyyyy [bug #1631]: https://github.com/ossrs/srs/issues/1631 diff --git a/trunk/research/players/js/srs.sdk.js b/trunk/research/players/js/srs.sdk.js index 860735413..2e3cd87d1 100644 --- a/trunk/research/players/js/srs.sdk.js +++ b/trunk/research/players/js/srs.sdk.js @@ -29,6 +29,14 @@ function SrsRtcPublisherAsync() { var self = {}; + // https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia + self.constraints = { + audio: true, + video: { + width: {ideal: 320, max: 576} + } + }; + // @see https://github.com/rtcdn/rtcdn-draft // @url The WebRTC url to play with, for example: // webrtc://r.ossrs.net/live/livestream @@ -56,9 +64,8 @@ function SrsRtcPublisherAsync() { self.pc.addTransceiver("audio", {direction: "sendonly"}); self.pc.addTransceiver("video", {direction: "sendonly"}); - var stream = await navigator.mediaDevices.getUserMedia( - {audio: true, video: {width: {max: 320}}} - ); + var stream = await navigator.mediaDevices.getUserMedia(self.constraints); + // @see https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/addStream#Migrating_to_addTrack stream.getTracks().forEach(function (track) { self.pc.addTrack(track); @@ -500,7 +507,8 @@ function SrsRtcPlayerAsync() { function SrsRtcFormatSenders(senders, kind) { var codecs = []; senders.forEach(function (sender) { - sender.getParameters().codecs.forEach(function(c) { + var params = sender.getParameters(); + params && params.codecs && params.codecs.forEach(function(c) { if (kind && sender.track.kind !== kind) { return; } diff --git a/trunk/research/players/rtc_player.html b/trunk/research/players/rtc_player.html index 0a4c3a3a5..c1e574e23 100644 --- a/trunk/research/players/rtc_player.html +++ b/trunk/research/players/rtc_player.html @@ -64,51 +64,51 @@ diff --git a/trunk/research/players/rtc_publisher.html b/trunk/research/players/rtc_publisher.html index 1159d0e8f..3d1681051 100644 --- a/trunk/research/players/rtc_publisher.html +++ b/trunk/research/players/rtc_publisher.html @@ -68,53 +68,52 @@ diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index a2cac352c..96a1a9714 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -3096,6 +3096,10 @@ srs_error_t SrsRtcConnection::negotiate_play_capability(SrsRtcUserConfig* ruc, s for (int j = 0; j < (int)track_descs.size(); ++j) { SrsRtcTrackDescription* track = track_descs.at(j)->copy(); + // We should clear the extmaps of source(publisher). + // @see https://github.com/ossrs/srs/issues/2370 + track->extmaps_.clear(); + // Use remote/source/offer PayloadType. track->media_->pt_of_publisher_ = track->media_->pt_; track->media_->pt_ = remote_payload.payload_type_; diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index f4e0917d0..44eec8dc1 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -26,6 +26,6 @@ #define VERSION_MAJOR 4 #define VERSION_MINOR 0 -#define VERSION_REVISION 120 +#define VERSION_REVISION 121 #endif