Skip to content

Commit

Permalink
Update webrtc native (#143)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
mamaheux and doumdi authored Jul 10, 2024
1 parent b6a53b2 commit fa6d0fe
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 32 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.0
1.2.1
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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})
Expand Down Expand Up @@ -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})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ namespace opentera

std::vector<webrtc::SdpVideoFormat> GetSupportedFormats() const override;
CodecSupport QueryCodecSupport(const webrtc::SdpVideoFormat& format, bool referenceScaling) const override;
std::unique_ptr<webrtc::VideoDecoder> CreateVideoDecoder(const webrtc::SdpVideoFormat& format) override;
std::unique_ptr<webrtc::VideoDecoder> Create(
const webrtc::Environment& env,
const webrtc::SdpVideoFormat& format) override;
};

class ForcedCodecVideoEncoderFactory : public webrtc::VideoEncoderFactory
Expand All @@ -49,7 +51,9 @@ namespace opentera
absl::optional<std::string> scalabilityMode) const override;

// Creates a VideoEncoder for the specified format.
std::unique_ptr<webrtc::VideoEncoder> CreateVideoEncoder(const webrtc::SdpVideoFormat& format) override;
std::unique_ptr<webrtc::VideoEncoder> Create(
const webrtc::Environment& env,
const webrtc::SdpVideoFormat& format) override;
};

std::unique_ptr<webrtc::VideoDecoderFactory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ webrtc::VideoDecoderFactory::CodecSupport
}

unique_ptr<webrtc::VideoDecoder>
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);
}


Expand All @@ -134,9 +134,9 @@ webrtc::VideoEncoderFactory::CodecSupport ForcedCodecVideoEncoderFactory::QueryC
}

unique_ptr<webrtc::VideoEncoder>
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);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <OpenteraWebrtcNativeClient/Codecs/VideoCodecFactories.h>

#include <api/environment/environment_factory.h>
#include <api/video_codecs/video_decoder.h>
#include <api/video_codecs/video_encoder.h>
#include <modules/video_coding/include/video_error_codes.h>
Expand Down Expand Up @@ -87,7 +88,8 @@ class DummyVideoDecoderFactory : public webrtc::VideoDecoderFactory
}

// Creates a VideoDecoder for the specified format.
unique_ptr<webrtc::VideoDecoder> CreateVideoDecoder(const webrtc::SdpVideoFormat& format) override
unique_ptr<webrtc::VideoDecoder>
Create(const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) override
{
return make_unique<DummyVideoDecoder>(format);
}
Expand Down Expand Up @@ -118,7 +120,8 @@ class DummyVideoEncoderFactory : public webrtc::VideoEncoderFactory
}

// Creates a VideoDecoder for the specified format.
unique_ptr<webrtc::VideoEncoder> CreateVideoEncoder(const webrtc::SdpVideoFormat& format) override
unique_ptr<webrtc::VideoEncoder>
Create(const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) override
{
return make_unique<DummyVideoEncoder>(format);
}
Expand Down Expand Up @@ -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<VideoStreamCodec> forcedCodecs;

ForcedCodecVideoDecoderFactory decoderFactory(make_unique<DummyVideoDecoderFactory>(), forcedCodecs);
ForcedCodecVideoEncoderFactory encoderFactory(make_unique<DummyVideoEncoderFactory>(), 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<DummyVideoDecoder&>(*decoder).format().name, cricket::kVp9CodecName);
EXPECT_EQ(dynamic_cast<DummyVideoEncoder&>(*encoder).format().name, cricket::kH264CodecName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ TEST(EncodedVideoSinkTests, VideoCodecType_shouldMatchWebrtcVideoCodecType)
EXPECT_EQ(VideoCodecType::VP9, static_cast<VideoCodecType>(webrtc::kVideoCodecVP9));
EXPECT_EQ(VideoCodecType::AV1, static_cast<VideoCodecType>(webrtc::kVideoCodecAV1));
EXPECT_EQ(VideoCodecType::H264, static_cast<VideoCodecType>(webrtc::kVideoCodecH264));
EXPECT_EQ(VideoCodecType::Multiplex, static_cast<VideoCodecType>(webrtc::kVideoCodecMultiplex));
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ namespace opentera
{
int priority;
bool isHardwareAccelerated;
std::function<std::unique_ptr<webrtc::VideoDecoder>(const webrtc::SdpVideoFormat&)> factory;
std::function<
std::unique_ptr<webrtc::VideoDecoder>(const webrtc::Environment& env, const webrtc::SdpVideoFormat&)>
factory;
};

std::unique_ptr<VideoDecoderFactory> m_builtinVideoDecoderFactory;
Expand All @@ -46,7 +48,8 @@ namespace opentera

std::vector<webrtc::SdpVideoFormat> GetSupportedFormats() const override;
CodecSupport QueryCodecSupport(const webrtc::SdpVideoFormat& format, bool referenceScaling) const override;
std::unique_ptr<webrtc::VideoDecoder> CreateVideoDecoder(const webrtc::SdpVideoFormat& format) override;
std::unique_ptr<webrtc::VideoDecoder>
Create(const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) override;

private:
void addH264Decoders(bool forceHardwareAcceleration, bool useGStreamerSoftwareDecoder);
Expand All @@ -64,7 +67,9 @@ namespace opentera
WebRtcGStreamerVideoDecoderFactory::DecoderFactory
WebRtcGStreamerVideoDecoderFactory::createDecoderFactory(int priority)
{
return {priority, Decoder::isHardwareAccelerated(), [](auto _) { return std::make_unique<Decoder>(); }};
return {priority, Decoder::isHardwareAccelerated(), [](auto _env, auto _format) {
return std::make_unique<Decoder>();
}};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ namespace opentera
int priority;
bool isHardwareAccelerated;
std::function<bool(const webrtc::SdpVideoFormat::Parameters&)> areParametersSupported;
std::function<std::unique_ptr<webrtc::VideoEncoder>(const webrtc::SdpVideoFormat&)> factory;
std::function<
std::unique_ptr<webrtc::VideoEncoder>(const webrtc::Environment& env, const webrtc::SdpVideoFormat&)>
factory;
};

std::unique_ptr<VideoEncoderFactory> m_builtinVideoEncoderFactory;
Expand All @@ -49,7 +51,8 @@ namespace opentera
CodecSupport QueryCodecSupport(
const webrtc::SdpVideoFormat& format,
absl::optional<std::string> scalabilityMode) const override;
std::unique_ptr<webrtc::VideoEncoder> CreateVideoEncoder(const webrtc::SdpVideoFormat& format) override;
std::unique_ptr<webrtc::VideoEncoder>
Create(const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) override;

private:
void addH264Encoders(bool forceHardwareAcceleration, bool useGStreamerSoftwareEncoder);
Expand All @@ -71,7 +74,7 @@ namespace opentera
priority,
Encoder::isHardwareAccelerated(),
[](auto parameters) { return Encoder::areParametersSupported(parameters); },
[](auto format) { return std::make_unique<Encoder>(format.parameters); }};
[](auto env, auto format) { return std::make_unique<Encoder>(format.parameters); }};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ webrtc::VideoDecoderFactory::CodecSupport WebRtcGStreamerVideoDecoderFactory::Qu
}

unique_ptr<webrtc::VideoDecoder>
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())
Expand All @@ -85,7 +85,7 @@ unique_ptr<webrtc::VideoDecoder>
}
else
{
return it->second.factory(format);
return it->second.factory(env, format);
}
}

Expand Down Expand Up @@ -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);
}};
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ webrtc::VideoEncoderFactory::CodecSupport WebRtcGStreamerVideoEncoderFactory::Qu
}

unique_ptr<webrtc::VideoEncoder>
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())
Expand All @@ -86,7 +86,7 @@ unique_ptr<webrtc::VideoEncoder>
}
else
{
return it->second.factory(format);
return it->second.factory(env, format);
}
}

Expand Down Expand Up @@ -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); }};
}

0 comments on commit fa6d0fe

Please sign in to comment.