From 7e49630e1ba609f43ee04f946d4967cfb9a9ce10 Mon Sep 17 00:00:00 2001 From: aoife cassidy Date: Tue, 3 Dec 2024 21:37:56 +0200 Subject: [PATCH] more --- .../include/livekit/video_decoder_factory.h | 6 ++--- .../include/livekit/video_encoder_factory.h | 4 +-- webrtc-sys/src/peer_connection_factory.cpp | 27 +++++++------------ webrtc-sys/src/video_decoder_factory.cpp | 11 ++++---- webrtc-sys/src/video_encoder_factory.cpp | 4 +-- 5 files changed, 23 insertions(+), 29 deletions(-) diff --git a/webrtc-sys/include/livekit/video_decoder_factory.h b/webrtc-sys/include/livekit/video_decoder_factory.h index 7d2f2a299..9b2d7030d 100644 --- a/webrtc-sys/include/livekit/video_decoder_factory.h +++ b/webrtc-sys/include/livekit/video_decoder_factory.h @@ -18,7 +18,7 @@ #include "api/video_codecs/video_decoder.h" #include "api/video_codecs/video_decoder_factory.h" -#include "absl/strings/numbers.h" +#include "absl/strings/match.h" namespace livekit { class VideoDecoderFactory : public webrtc::VideoDecoderFactory { @@ -30,8 +30,8 @@ class VideoDecoderFactory : public webrtc::VideoDecoderFactory { CodecSupport QueryCodecSupport(const webrtc::SdpVideoFormat& format, bool reference_scaling) 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: std::vector> factories_; diff --git a/webrtc-sys/include/livekit/video_encoder_factory.h b/webrtc-sys/include/livekit/video_encoder_factory.h index c3f90e925..f1e8bc84a 100644 --- a/webrtc-sys/include/livekit/video_encoder_factory.h +++ b/webrtc-sys/include/livekit/video_encoder_factory.h @@ -47,8 +47,8 @@ class VideoEncoderFactory : public webrtc::VideoEncoderFactory { const webrtc::SdpVideoFormat& format, absl::optional scalability_mode) const override; - std::unique_ptr CreateVideoEncoder( - const webrtc::SdpVideoFormat& format); + std::unique_ptr Create( + const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) override; private: std::unique_ptr internal_factory_; diff --git a/webrtc-sys/src/peer_connection_factory.cpp b/webrtc-sys/src/peer_connection_factory.cpp index bbc73bfdc..832250edd 100644 --- a/webrtc-sys/src/peer_connection_factory.cpp +++ b/webrtc-sys/src/peer_connection_factory.cpp @@ -23,6 +23,7 @@ #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/peer_connection_interface.h" #include "api/rtc_error.h" +#include "api/enable_media.h" #include "api/rtc_event_log/rtc_event_log_factory.h" #include "api/task_queue/default_task_queue_factory.h" #include "api/video_codecs/builtin_video_decoder_factory.h" @@ -35,7 +36,6 @@ #include "livekit/video_decoder_factory.h" #include "livekit/video_encoder_factory.h" #include "livekit/webrtc.h" -#include "media/engine/webrtc_media_engine.h" #include "rtc_base/thread.h" #include "webrtc-sys/src/peer_connection.rs.h" #include "webrtc-sys/src/peer_connection_factory.rs.h" @@ -55,32 +55,25 @@ PeerConnectionFactory::PeerConnectionFactory( dependencies.signaling_thread = rtc_runtime_->signaling_thread(); dependencies.socket_factory = rtc_runtime_->network_thread()->socketserver(); dependencies.task_queue_factory = webrtc::CreateDefaultTaskQueueFactory(); - dependencies.event_log_factory = std::make_unique( - dependencies.task_queue_factory.get()); - dependencies.call_factory = webrtc::CreateCallFactory(); + dependencies.event_log_factory = std::make_unique(); dependencies.trials = std::make_unique(); - cricket::MediaEngineDependencies media_deps; - media_deps.task_queue_factory = dependencies.task_queue_factory.get(); - audio_device_ = rtc_runtime_->worker_thread()->BlockingCall([&] { return rtc::make_ref_counted( - media_deps.task_queue_factory); + dependencies.task_queue_factory); }); - media_deps.adm = audio_device_; + dependencies.adm = audio_device_; - media_deps.video_encoder_factory = + dependencies.video_encoder_factory = std::move(std::make_unique()); - media_deps.video_decoder_factory = + dependencies.video_decoder_factory = std::move(std::make_unique()); - media_deps.audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory(); - media_deps.audio_decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory(); - media_deps.audio_processing = webrtc::AudioProcessingBuilder().Create(); - media_deps.trials = dependencies.trials.get(); - - dependencies.media_engine = cricket::CreateMediaEngine(std::move(media_deps)); + dependencies.audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory(); + dependencies.audio_decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory(); + dependencies.audio_processing = webrtc::AudioProcessingBuilder().Create(); + webrtc::EnableMedia(dependencies); peer_factory_ = webrtc::CreateModularPeerConnectionFactory(std::move(dependencies)); diff --git a/webrtc-sys/src/video_decoder_factory.cpp b/webrtc-sys/src/video_decoder_factory.cpp index 40e742897..f7e7bb082 100644 --- a/webrtc-sys/src/video_decoder_factory.cpp +++ b/webrtc-sys/src/video_decoder_factory.cpp @@ -16,6 +16,7 @@ #include "livekit/video_decoder_factory.h" +#include "api/environment/environment.h" #include "api/video_codecs/av1_profile.h" #include "api/video_codecs/sdp_video_format.h" #include "livekit/objc_video_factory.h" @@ -69,7 +70,7 @@ std::vector VideoDecoderFactory::GetSupportedFormats() formats.push_back(webrtc::SdpVideoFormat(cricket::kAv1CodecName)); formats.push_back(webrtc::SdpVideoFormat( cricket::kAv1CodecName, - {{webrtc::kAV1FmtpProfile, + {{cricket::kAv1FmtpProfile, AV1ProfileToString(webrtc::AV1Profile::kProfile1).data()}})); #endif @@ -92,17 +93,17 @@ VideoDecoderFactory::CodecSupport VideoDecoderFactory::QueryCodecSupport( return codec_support; } -std::unique_ptr VideoDecoderFactory::CreateVideoDecoder( - const webrtc::SdpVideoFormat& format) { +std::unique_ptr VideoDecoderFactory::Create( + const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) { for (const auto& factory : factories_) { for (const auto& supported_format : factory->GetSupportedFormats()) { if (supported_format.IsSameCodec(format)) - return factory->CreateVideoDecoder(format); + return factory->Create(env, format); } } if (absl::EqualsIgnoreCase(format.name, cricket::kVp8CodecName)) - return webrtc::VP8Decoder::Create(); + return webrtc::CreateVp8Decoder(env); if (absl::EqualsIgnoreCase(format.name, cricket::kVp9CodecName)) return webrtc::VP9Decoder::Create(); if (absl::EqualsIgnoreCase(format.name, cricket::kH264CodecName)) diff --git a/webrtc-sys/src/video_encoder_factory.cpp b/webrtc-sys/src/video_encoder_factory.cpp index 4696077ca..ebd79cb5e 100644 --- a/webrtc-sys/src/video_encoder_factory.cpp +++ b/webrtc-sys/src/video_encoder_factory.cpp @@ -120,8 +120,8 @@ VideoEncoderFactory::CodecSupport VideoEncoderFactory::QueryCodecSupport( return internal_factory_->QueryCodecSupport(format, scalability_mode); } -std::unique_ptr VideoEncoderFactory::CreateVideoEncoder( - const webrtc::SdpVideoFormat& format) { +std::unique_ptr VideoEncoderFactory::Create( + const webrtc::Environment& env, const webrtc::SdpVideoFormat& format) { std::unique_ptr encoder; if (format.IsCodecInList(internal_factory_->GetSupportedFormats())) { encoder = std::make_unique(