From f9bba0a9b0c62e553af887154ec22e3101b325b7 Mon Sep 17 00:00:00 2001 From: Winlin Date: Thu, 21 Sep 2023 18:41:33 +0800 Subject: [PATCH] WebRTC: Support WHEP for play. v5.0.182 v6.0.80 (#3404) RFC for WHIP: https://datatracker.ietf.org/doc/draft-ietf-wish-whip/ RFC for WHEP: https://datatracker.ietf.org/doc/draft-murillo-whep/ Please note that SRS 5.0 already had WHIP support. I didn't write a document about WHIP, because WHIP is not a RFC right now, but there are clues in [srs-unity](https://github.com/ossrs/srs-unity#usage-publisher). SRS WHIP url for publisher: `http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream` This PR is for WHEP, the url for player is `http://localhost:1985/rtc/v1/whep/?app=live&stream=livestream` PS: There is a great PR for OBS to have WHIP support, see https://github.com/obsproject/obs-studio/pull/7926 and #3581 PS: WHIP for FFmpeg https://github.com/ossrs/ffmpeg-webrtc/pull/1 See #3170 --------- Co-authored-by: Haibo Chen <495810242@qq.com> Co-authored-by: john Co-authored-by: ChenGH --- trunk/doc/CHANGELOG.md | 2 ++ trunk/research/players/js/srs.page.js | 2 +- trunk/research/players/js/srs.sdk.js | 2 +- trunk/src/app/srs_app_rtc_api.cpp | 3 ++- trunk/src/app/srs_app_rtc_server.cpp | 7 ++++++- trunk/src/core/srs_core_version5.hpp | 2 +- trunk/src/core/srs_core_version6.hpp | 2 +- 7 files changed, 14 insertions(+), 6 deletions(-) diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index a9824160bf..6547d041f7 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -7,6 +7,7 @@ The changelog for SRS. ## SRS 6.0 Changelog +* v6.0, 2023-09-21, Merge [#3404](https://github.com/ossrs/srs/pull/3404): WebRTC: Support WHEP for play. v6.0.80 (#3404) * v6.0, 2023-09-21, Merge [#3807](https://github.com/ossrs/srs/pull/3807): Prevent the output of srt logs in utest. v6.0.79 (#3807) * v6.0, 2023-09-21, Merge [#3696](https://github.com/ossrs/srs/pull/3696): SRT: modify log level from error to debug when no socket to accept. v6.0.78 (#3696) * v6.0, 2023-09-18, Merge [#3804](https://github.com/ossrs/srs/pull/3804): Support FFmpeg timecode, fix AMF0 parsing failed. v6.0.77 (#3804) @@ -91,6 +92,7 @@ The changelog for SRS. ## SRS 5.0 Changelog +* v5.0, 2023-09-21, Merge [#3404](https://github.com/ossrs/srs/pull/3404): WebRTC: Support WHEP for play. v5.0.182 (#3404) * v5.0, 2023-09-21, Merge [#3807](https://github.com/ossrs/srs/pull/3807): Prevent the output of srt logs in utest. v5.0.181 (#3807) * v5.0, 2023-09-21, Merge [#3696](https://github.com/ossrs/srs/pull/3696): SRT: modify log level from error to debug when no socket to accept. v5.0.180 (#3696) * v5.0, 2023-09-18, Merge [#3804](https://github.com/ossrs/srs/pull/3804): Support FFmpeg timecode, fix AMF0 parsing failed. v5.0.179 (#3804) diff --git a/trunk/research/players/js/srs.page.js b/trunk/research/players/js/srs.page.js index db12ee56c5..ff4415445b 100755 --- a/trunk/research/players/js/srs.page.js +++ b/trunk/research/players/js/srs.page.js @@ -179,5 +179,5 @@ function srs_init_whip(id, query) { } function srs_init_whep(id, query) { update_nav(); - $(id).val(build_default_whip_whep_url(query, '/rtc/v1/whip-play/')); + $(id).val(build_default_whip_whep_url(query, '/rtc/v1/whep/')); } diff --git a/trunk/research/players/js/srs.sdk.js b/trunk/research/players/js/srs.sdk.js index e428ef7f32..ea5189e2c2 100644 --- a/trunk/research/players/js/srs.sdk.js +++ b/trunk/research/players/js/srs.sdk.js @@ -571,7 +571,7 @@ function SrsRtcWhipWhepAsync() { // See https://datatracker.ietf.org/doc/draft-ietf-wish-whip/ // @url The WebRTC url to play with, for example: - // http://localhost:1985/rtc/v1/whip-play/?app=live&stream=livestream + // http://localhost:1985/rtc/v1/whep/?app=live&stream=livestream self.play = async function(url) { if (url.indexOf('/whip-play/') === -1 && url.indexOf('/whep/') === -1) throw new Error(`invalid WHEP url ${url}`); diff --git a/trunk/src/app/srs_app_rtc_api.cpp b/trunk/src/app/srs_app_rtc_api.cpp index 09534e614b..b5b0080f97 100644 --- a/trunk/src/app/srs_app_rtc_api.cpp +++ b/trunk/src/app/srs_app_rtc_api.cpp @@ -678,7 +678,8 @@ srs_error_t SrsGoApiRtcWhip::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe if (action.empty()) { action = "publish"; } - if (srs_string_ends_with(r->path(), "/whip-play/")) { + // For whip-play or whep, parsed to https://datatracker.ietf.org/doc/draft-murillo-whep/ + if (srs_string_ends_with(r->path(), "/whip-play/") || srs_string_ends_with(r->path(), "/whep/")) { action = "play"; } diff --git a/trunk/src/app/srs_app_rtc_server.cpp b/trunk/src/app/srs_app_rtc_server.cpp index 2c34b97a5b..c870e956c6 100644 --- a/trunk/src/app/srs_app_rtc_server.cpp +++ b/trunk/src/app/srs_app_rtc_server.cpp @@ -471,13 +471,18 @@ srs_error_t SrsRtcServer::listen_api() } // Generally, WHIP is a publishing protocol, but it can be also used as playing. + // See https://datatracker.ietf.org/doc/draft-ietf-wish-whep/ if ((err = http_api_mux->handle("/rtc/v1/whip/", new SrsGoApiRtcWhip(this))) != srs_success) { return srs_error_wrap(err, "handle whip"); } // We create another mount, to support play with the same query string as publish. + // See https://datatracker.ietf.org/doc/draft-murillo-whep/ if ((err = http_api_mux->handle("/rtc/v1/whip-play/", new SrsGoApiRtcWhip(this))) != srs_success) { - return srs_error_wrap(err, "handle whip play"); + return srs_error_wrap(err, "handle whep play"); + } + if ((err = http_api_mux->handle("/rtc/v1/whep/", new SrsGoApiRtcWhip(this))) != srs_success) { + return srs_error_wrap(err, "handle whep play"); } #ifdef SRS_SIMULATOR diff --git a/trunk/src/core/srs_core_version5.hpp b/trunk/src/core/srs_core_version5.hpp index d1d7622c4e..ad57ddc131 100644 --- a/trunk/src/core/srs_core_version5.hpp +++ b/trunk/src/core/srs_core_version5.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 5 #define VERSION_MINOR 0 -#define VERSION_REVISION 181 +#define VERSION_REVISION 182 #endif diff --git a/trunk/src/core/srs_core_version6.hpp b/trunk/src/core/srs_core_version6.hpp index dc6a4e8051..14930eab82 100644 --- a/trunk/src/core/srs_core_version6.hpp +++ b/trunk/src/core/srs_core_version6.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 6 #define VERSION_MINOR 0 -#define VERSION_REVISION 79 +#define VERSION_REVISION 80 #endif