From fa6d0feab3ef91aa8483253153cbc9abf0eca6b8 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Maheux <35638081+mamaheux@users.noreply.github.com> Date: Wed, 10 Jul 2024 12:17:47 -0400 Subject: [PATCH] Update webrtc native (#143) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add logs. Fix signaling-server. * Add callAll * Prevent creating a new peer connection after the desctuctor is called. * Use bool and callSync instead of atomic_bool for m_destructorCalled. * Add client connectin failed callback. Set ICE timeout. * Add onClientConnectionFail to the JS API. * Remove invalid changes. * Fix * Add print to debug the deadlock. * Add print to debug the deadlock. * Add print to debug the deadlock. * Add debug print in StreamClientPython.cpp. * Update pybind11. * Remove debug prints. * Update WebRTC Native to 6478.a18e38.173. * Downgrade the webrtc native version. * Update VERSION * Update VERSION --------- Co-authored-by: Dominic Létourneau --- VERSION | 2 +- .../3rdParty/webrtc_native/CMakeLists.txt | 10 +++++----- .../Codecs/VideoCodecFactories.h | 8 ++++++-- .../src/Codecs/VideoCodecFactories.cpp | 8 ++++---- .../test/src/Codecs/VideoCodecFactoriesTests.cpp | 15 ++++++++++----- .../test/src/Sinks/EncodedVideoSinkTests.cpp | 1 - .../WebRtcGStreamerVideoDecoderFactory.h | 11 ++++++++--- .../WebRtcGStreamerVideoEncoderFactory.h | 9 ++++++--- .../WebRtcGStreamerVideoDecoderFactory.cpp | 8 ++++---- .../WebRtcGStreamerVideoEncoderFactory.cpp | 8 ++++---- 10 files changed, 48 insertions(+), 32 deletions(-) diff --git a/VERSION b/VERSION index 26aaba0e..6085e946 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.2.0 +1.2.1 diff --git a/opentera-webrtc-native-client/3rdParty/webrtc_native/CMakeLists.txt b/opentera-webrtc-native-client/3rdParty/webrtc_native/CMakeLists.txt index 067aadc5..11e3c654 100644 --- a/opentera-webrtc-native-client/3rdParty/webrtc_native/CMakeLists.txt +++ b/opentera-webrtc-native-client/3rdParty/webrtc_native/CMakeLists.txt @@ -1,4 +1,4 @@ -set(webrtc_native_build_version "6167.3df661.54" CACHE INTERNAL "") +set(webrtc_native_build_version "6422.8505a9.224" CACHE INTERNAL "") if(WIN32) set(architecture "win64") @@ -12,8 +12,8 @@ elseif(UNIX) include(${CMAKE_SOURCE_DIR}/cmake/macos_get_version.cmake) get_macos_sw_vers_product_version() - if (NOT ${SW_VERS_VERSION_SHORT} MATCHES "11" AND NOT ${SW_VERS_VERSION_SHORT} MATCHES "12" AND NOT ${SW_VERS_VERSION_SHORT} MATCHES "13") - message(FATAL_ERROR "MacOS version not supported: ${SW_VERS_VERSION_SHORT}, must be 11, 12 or 13.") + if (NOT ${SW_VERS_VERSION_SHORT} MATCHES "12" AND NOT ${SW_VERS_VERSION_SHORT} MATCHES "13") + message(FATAL_ERROR "MacOS version not supported: ${SW_VERS_VERSION_SHORT}, must be 12 or 13.") endif() set(archive_stem webrtc-native-build-macos-${SW_VERS_VERSION_SHORT}-${architecture}-${CMAKE_BUILD_TYPE}-${webrtc_native_build_version}) @@ -52,8 +52,8 @@ elseif(UNIX) message(FATAL_ERROR "System not supported: ${LSB_RELEASE_ID_SHORT}, must be ubuntu") endif() - if (NOT ${LSB_RELEASE_VERSION_SHORT} MATCHES "20.04" AND NOT ${LSB_RELEASE_VERSION_SHORT} MATCHES "22.04") - message(FATAL_ERROR "Ubuntu version not supported: ${LSB_RELEASE_VERSION_SHORT}, must be 20.04 or 22.04.") + if (NOT ${LSB_RELEASE_VERSION_SHORT} MATCHES "20.04" AND NOT ${LSB_RELEASE_VERSION_SHORT} MATCHES "22.04" AND NOT ${LSB_RELEASE_VERSION_SHORT} MATCHES "24.04") + message(FATAL_ERROR "Ubuntu version not supported: ${LSB_RELEASE_VERSION_SHORT}, must be 20.04 or 22.04 or 24.04.") endif() set(archive_stem webrtc-native-build-${LSB_RELEASE_ID_SHORT}-${LSB_RELEASE_VERSION_SHORT}-${architecture}-${CMAKE_BUILD_TYPE}-${webrtc_native_build_version}) diff --git a/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/include/OpenteraWebrtcNativeClient/Codecs/VideoCodecFactories.h b/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/include/OpenteraWebrtcNativeClient/Codecs/VideoCodecFactories.h index 2261bd0c..47d4406e 100644 --- a/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/include/OpenteraWebrtcNativeClient/Codecs/VideoCodecFactories.h +++ b/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/include/OpenteraWebrtcNativeClient/Codecs/VideoCodecFactories.h @@ -25,7 +25,9 @@ namespace opentera std::vector GetSupportedFormats() const override; CodecSupport QueryCodecSupport(const webrtc::SdpVideoFormat& format, bool referenceScaling) const override; - std::unique_ptr CreateVideoDecoder(const webrtc::SdpVideoFormat& format) override; + std::unique_ptr Create( + const webrtc::Environment& env, + const webrtc::SdpVideoFormat& format) override; }; class ForcedCodecVideoEncoderFactory : public webrtc::VideoEncoderFactory @@ -49,7 +51,9 @@ namespace opentera absl::optional scalabilityMode) const override; // Creates a VideoEncoder for the specified format. - std::unique_ptr CreateVideoEncoder(const webrtc::SdpVideoFormat& format) override; + std::unique_ptr Create( + const webrtc::Environment& env, + const webrtc::SdpVideoFormat& format) override; }; std::unique_ptr diff --git a/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/src/Codecs/VideoCodecFactories.cpp b/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/src/Codecs/VideoCodecFactories.cpp index be4a8929..0623a1b3 100644 --- a/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/src/Codecs/VideoCodecFactories.cpp +++ b/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/src/Codecs/VideoCodecFactories.cpp @@ -107,9 +107,9 @@ webrtc::VideoDecoderFactory::CodecSupport } unique_ptr - ForcedCodecVideoDecoderFactory::CreateVideoDecoder(const webrtc::SdpVideoFormat& format) + ForcedCodecVideoDecoderFactory::Create(const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) { - return m_factory->CreateVideoDecoder(format); + return m_factory->Create(env, format); } @@ -134,9 +134,9 @@ webrtc::VideoEncoderFactory::CodecSupport ForcedCodecVideoEncoderFactory::QueryC } unique_ptr - ForcedCodecVideoEncoderFactory::CreateVideoEncoder(const webrtc::SdpVideoFormat& format) + ForcedCodecVideoEncoderFactory::Create(const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) { - return m_factory->CreateVideoEncoder(format); + return m_factory->Create(env, format); } diff --git a/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/test/src/Codecs/VideoCodecFactoriesTests.cpp b/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/test/src/Codecs/VideoCodecFactoriesTests.cpp index 52a3f9ef..8af3909f 100644 --- a/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/test/src/Codecs/VideoCodecFactoriesTests.cpp +++ b/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/test/src/Codecs/VideoCodecFactoriesTests.cpp @@ -1,5 +1,6 @@ #include +#include #include #include #include @@ -87,7 +88,8 @@ class DummyVideoDecoderFactory : public webrtc::VideoDecoderFactory } // Creates a VideoDecoder for the specified format. - unique_ptr CreateVideoDecoder(const webrtc::SdpVideoFormat& format) override + unique_ptr + Create(const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) override { return make_unique(format); } @@ -118,7 +120,8 @@ class DummyVideoEncoderFactory : public webrtc::VideoEncoderFactory } // Creates a VideoDecoder for the specified format. - unique_ptr CreateVideoEncoder(const webrtc::SdpVideoFormat& format) override + unique_ptr + Create(const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) override { return make_unique(format); } @@ -228,15 +231,17 @@ TEST(VideoCodecFactoriesTests, QueryCodecSupport_vp8ForcedCodecs_shouldReturnSup EXPECT_FALSE(av1EncoderSupport.is_power_efficient); } -TEST(VideoCodecFactoriesTests, CreateVideoDecoder_shouldCallDummyFactory) +TEST(VideoCodecFactoriesTests, Create_shouldCallDummyFactory) { unordered_set forcedCodecs; ForcedCodecVideoDecoderFactory decoderFactory(make_unique(), forcedCodecs); ForcedCodecVideoEncoderFactory encoderFactory(make_unique(), forcedCodecs); - auto decoder = decoderFactory.CreateVideoDecoder(webrtc::SdpVideoFormat(cricket::kVp9CodecName)); - auto encoder = encoderFactory.CreateVideoEncoder(webrtc::SdpVideoFormat(cricket::kH264CodecName)); + auto environmentFactory = webrtc::EnvironmentFactory(); + auto env = environmentFactory.Create(); + auto decoder = decoderFactory.Create(env, webrtc::SdpVideoFormat(cricket::kVp9CodecName)); + auto encoder = encoderFactory.Create(env, webrtc::SdpVideoFormat(cricket::kH264CodecName)); EXPECT_EQ(dynamic_cast(*decoder).format().name, cricket::kVp9CodecName); EXPECT_EQ(dynamic_cast(*encoder).format().name, cricket::kH264CodecName); diff --git a/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/test/src/Sinks/EncodedVideoSinkTests.cpp b/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/test/src/Sinks/EncodedVideoSinkTests.cpp index 35220728..4dfbbecc 100644 --- a/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/test/src/Sinks/EncodedVideoSinkTests.cpp +++ b/opentera-webrtc-native-client/OpenteraWebrtcNativeClient/test/src/Sinks/EncodedVideoSinkTests.cpp @@ -12,5 +12,4 @@ TEST(EncodedVideoSinkTests, VideoCodecType_shouldMatchWebrtcVideoCodecType) EXPECT_EQ(VideoCodecType::VP9, static_cast(webrtc::kVideoCodecVP9)); EXPECT_EQ(VideoCodecType::AV1, static_cast(webrtc::kVideoCodecAV1)); EXPECT_EQ(VideoCodecType::H264, static_cast(webrtc::kVideoCodecH264)); - EXPECT_EQ(VideoCodecType::Multiplex, static_cast(webrtc::kVideoCodecMultiplex)); } diff --git a/opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/include/OpenteraWebrtcNativeGStreamer/Factories/WebRtcGStreamerVideoDecoderFactory.h b/opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/include/OpenteraWebrtcNativeGStreamer/Factories/WebRtcGStreamerVideoDecoderFactory.h index a9e013a1..3bd0dcf4 100644 --- a/opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/include/OpenteraWebrtcNativeGStreamer/Factories/WebRtcGStreamerVideoDecoderFactory.h +++ b/opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/include/OpenteraWebrtcNativeGStreamer/Factories/WebRtcGStreamerVideoDecoderFactory.h @@ -34,7 +34,9 @@ namespace opentera { int priority; bool isHardwareAccelerated; - std::function(const webrtc::SdpVideoFormat&)> factory; + std::function< + std::unique_ptr(const webrtc::Environment& env, const webrtc::SdpVideoFormat&)> + factory; }; std::unique_ptr m_builtinVideoDecoderFactory; @@ -46,7 +48,8 @@ namespace opentera std::vector GetSupportedFormats() const override; CodecSupport QueryCodecSupport(const webrtc::SdpVideoFormat& format, bool referenceScaling) const override; - std::unique_ptr CreateVideoDecoder(const webrtc::SdpVideoFormat& format) override; + std::unique_ptr + Create(const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) override; private: void addH264Decoders(bool forceHardwareAcceleration, bool useGStreamerSoftwareDecoder); @@ -64,7 +67,9 @@ namespace opentera WebRtcGStreamerVideoDecoderFactory::DecoderFactory WebRtcGStreamerVideoDecoderFactory::createDecoderFactory(int priority) { - return {priority, Decoder::isHardwareAccelerated(), [](auto _) { return std::make_unique(); }}; + return {priority, Decoder::isHardwareAccelerated(), [](auto _env, auto _format) { + return std::make_unique(); + }}; } } diff --git a/opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/include/OpenteraWebrtcNativeGStreamer/Factories/WebRtcGStreamerVideoEncoderFactory.h b/opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/include/OpenteraWebrtcNativeGStreamer/Factories/WebRtcGStreamerVideoEncoderFactory.h index 3d08ca0f..e6a3d316 100644 --- a/opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/include/OpenteraWebrtcNativeGStreamer/Factories/WebRtcGStreamerVideoEncoderFactory.h +++ b/opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/include/OpenteraWebrtcNativeGStreamer/Factories/WebRtcGStreamerVideoEncoderFactory.h @@ -35,7 +35,9 @@ namespace opentera int priority; bool isHardwareAccelerated; std::function areParametersSupported; - std::function(const webrtc::SdpVideoFormat&)> factory; + std::function< + std::unique_ptr(const webrtc::Environment& env, const webrtc::SdpVideoFormat&)> + factory; }; std::unique_ptr m_builtinVideoEncoderFactory; @@ -49,7 +51,8 @@ namespace opentera CodecSupport QueryCodecSupport( const webrtc::SdpVideoFormat& format, absl::optional scalabilityMode) const override; - std::unique_ptr CreateVideoEncoder(const webrtc::SdpVideoFormat& format) override; + std::unique_ptr + Create(const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) override; private: void addH264Encoders(bool forceHardwareAcceleration, bool useGStreamerSoftwareEncoder); @@ -71,7 +74,7 @@ namespace opentera priority, Encoder::isHardwareAccelerated(), [](auto parameters) { return Encoder::areParametersSupported(parameters); }, - [](auto format) { return std::make_unique(format.parameters); }}; + [](auto env, auto format) { return std::make_unique(format.parameters); }}; } } diff --git a/opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/src/Factories/WebRtcGStreamerVideoDecoderFactory.cpp b/opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/src/Factories/WebRtcGStreamerVideoDecoderFactory.cpp index 29844b27..f2b9042e 100644 --- a/opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/src/Factories/WebRtcGStreamerVideoDecoderFactory.cpp +++ b/opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/src/Factories/WebRtcGStreamerVideoDecoderFactory.cpp @@ -76,7 +76,7 @@ webrtc::VideoDecoderFactory::CodecSupport WebRtcGStreamerVideoDecoderFactory::Qu } unique_ptr - WebRtcGStreamerVideoDecoderFactory::CreateVideoDecoder(const webrtc::SdpVideoFormat& format) + WebRtcGStreamerVideoDecoderFactory::Create(const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) { auto it = m_decoderFactories.find(format.name); if (it == m_decoderFactories.end()) @@ -85,7 +85,7 @@ unique_ptr } else { - return it->second.factory(format); + return it->second.factory(env, format); } } @@ -193,7 +193,7 @@ bool WebRtcGStreamerVideoDecoderFactory::builtinVideoDecoderFactorySupports(stri WebRtcGStreamerVideoDecoderFactory::DecoderFactory WebRtcGStreamerVideoDecoderFactory::createBuiltinDecoderFactory(int priority) { - return {priority, false, [this](const webrtc::SdpVideoFormat& format) { - return m_builtinVideoDecoderFactory->CreateVideoDecoder(format); + return {priority, false, [this](const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) { + return m_builtinVideoDecoderFactory->Create(env, format); }}; } diff --git a/opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/src/Factories/WebRtcGStreamerVideoEncoderFactory.cpp b/opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/src/Factories/WebRtcGStreamerVideoEncoderFactory.cpp index 37f505cc..dad0e858 100644 --- a/opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/src/Factories/WebRtcGStreamerVideoEncoderFactory.cpp +++ b/opentera-webrtc-native-client/OpenteraWebrtcNativeGStreamer/src/Factories/WebRtcGStreamerVideoEncoderFactory.cpp @@ -77,7 +77,7 @@ webrtc::VideoEncoderFactory::CodecSupport WebRtcGStreamerVideoEncoderFactory::Qu } unique_ptr - WebRtcGStreamerVideoEncoderFactory::CreateVideoEncoder(const webrtc::SdpVideoFormat& format) + WebRtcGStreamerVideoEncoderFactory::Create(const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) { auto it = m_encoderFactories.find(format.name); if (it == m_encoderFactories.end()) @@ -86,7 +86,7 @@ unique_ptr } else { - return it->second.factory(format); + return it->second.factory(env, format); } } @@ -201,6 +201,6 @@ WebRtcGStreamerVideoEncoderFactory::EncoderFactory priority, false, [](const webrtc::SdpVideoFormat::Parameters& parameters) { return true; }, - [this](const webrtc::SdpVideoFormat& format) - { return m_builtinVideoEncoderFactory->CreateVideoEncoder(format); }}; + [this](const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) + { return m_builtinVideoEncoderFactory->Create(env, format); }}; }