tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 9e275bc2ba12cec95899067c9f132bfc6bf385be
parent 6d4c064f419fe58625921af303863d73a1b02f6b
Author: Dan Baker <dbaker@mozilla.com>
Date:   Mon, 27 Oct 2025 12:50:40 -0600

Bug 1995393 - Vendor libwebrtc from f9af67ca78

Upstream commit: https://webrtc.googlesource.com/src/+/f9af67ca783cb88b38fa75c4758f2054c4159c1a
    Propagate Environment into video engine channels

    This way these channels do not need to rely on call to expose field
    trials or environment

    Bug: webrtc:440271885
    Change-Id: Iec382e0e2f86236fd3109cef441f643dff13b2f9
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/406122
    Reviewed-by: Harald Alvestrand <hta@webrtc.org>
    Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#45438}

Diffstat:
Mthird_party/libwebrtc/README.mozilla.last-vendor | 4++--
Mthird_party/libwebrtc/media/BUILD.gn | 2++
Mthird_party/libwebrtc/media/base/fake_media_engine.cc | 3+++
Mthird_party/libwebrtc/media/base/fake_media_engine.h | 2++
Mthird_party/libwebrtc/media/base/media_engine.h | 22++++++++++++----------
Mthird_party/libwebrtc/media/engine/webrtc_video_engine.cc | 80++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Mthird_party/libwebrtc/media/engine/webrtc_video_engine.h | 16+++++++++++++---
Mthird_party/libwebrtc/media/engine/webrtc_video_engine_unittest.cc | 121++++++++++++++++++++++++++++++++++++++++---------------------------------------
Mthird_party/libwebrtc/moz-patch-stack/s0027.patch | 20++++++++++----------
Mthird_party/libwebrtc/moz-patch-stack/s0087.patch | 2+-
Mthird_party/libwebrtc/moz-patch-stack/s0100.patch | 2+-
Mthird_party/libwebrtc/moz-patch-stack/s0102.patch | 4++--
Mthird_party/libwebrtc/moz-patch-stack/s0107.patch | 12++++++------
Mthird_party/libwebrtc/moz-patch-stack/s0109.patch | 2+-
Mthird_party/libwebrtc/pc/BUILD.gn | 2++
Mthird_party/libwebrtc/pc/peer_connection.cc | 4++--
Mthird_party/libwebrtc/pc/rtp_sender_receiver_unittest.cc | 4++--
Mthird_party/libwebrtc/pc/rtp_transceiver.cc | 15++++++++++-----
Mthird_party/libwebrtc/pc/rtp_transceiver.h | 10+++++++---
Mthird_party/libwebrtc/pc/rtp_transceiver_unittest.cc | 19+++++++++++++++----
Mthird_party/libwebrtc/pc/rtp_transmission_manager.cc | 2+-
Mthird_party/libwebrtc/pc/test/fake_peer_connection_for_stats.h | 10+++++-----
22 files changed, 205 insertions(+), 153 deletions(-)

diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor @@ -1,4 +1,4 @@ # ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc -libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-27T18:48:02.669091+00:00. +libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-27T18:50:25.655029+00:00. # base of lastest vendoring -3f16dcd95a +f9af67ca78 diff --git a/third_party/libwebrtc/media/BUILD.gn b/third_party/libwebrtc/media/BUILD.gn @@ -253,6 +253,7 @@ rtc_library("media_engine") { "../api/audio:audio_device", "../api/audio_codecs:audio_codecs_api", "../api/crypto:options", + "../api/environment", "../api/video:video_bitrate_allocation", "../api/video:video_bitrate_allocator_factory", "../api/video:video_codec_constants", @@ -1081,6 +1082,7 @@ if (rtc_include_tests) { "../rtc_base/system:file_wrapper", "../system_wrappers", "../test:audio_codec_mocks", + "../test:create_test_environment", "../test:create_test_field_trials", "../test:fake_video_codecs", "../test:rtp_test_utils", diff --git a/third_party/libwebrtc/media/base/fake_media_engine.cc b/third_party/libwebrtc/media/base/fake_media_engine.cc @@ -26,6 +26,7 @@ #include "api/audio_options.h" #include "api/call/audio_sink.h" #include "api/crypto/crypto_options.h" +#include "api/environment/environment.h" #include "api/make_ref_counted.h" #include "api/rtp_parameters.h" #include "api/scoped_refptr.h" @@ -642,6 +643,7 @@ bool FakeVideoEngine::SetOptions(const VideoOptions& options) { } std::unique_ptr<VideoMediaSendChannelInterface> FakeVideoEngine::CreateSendChannel( + const Environment& /* env */, Call* call, const MediaConfig& /* config */, const VideoOptions& options, @@ -654,6 +656,7 @@ FakeVideoEngine::CreateSendChannel( } std::unique_ptr<VideoMediaReceiveChannelInterface> FakeVideoEngine::CreateReceiveChannel( + const Environment& /* env */, Call* call, const MediaConfig& /* config */, const VideoOptions& options, diff --git a/third_party/libwebrtc/media/base/fake_media_engine.h b/third_party/libwebrtc/media/base/fake_media_engine.h @@ -896,12 +896,14 @@ class FakeVideoEngine : public VideoEngineInterface { FakeVideoEngine(); bool SetOptions(const VideoOptions& options); std::unique_ptr<VideoMediaSendChannelInterface> CreateSendChannel( + const Environment& env, Call* call, const MediaConfig& config, const VideoOptions& options, const CryptoOptions& crypto_options, VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) override; std::unique_ptr<VideoMediaReceiveChannelInterface> CreateReceiveChannel( + const Environment& env, Call* call, const MediaConfig& config, const VideoOptions& options, diff --git a/third_party/libwebrtc/media/base/media_engine.h b/third_party/libwebrtc/media/base/media_engine.h @@ -23,6 +23,7 @@ #include "api/audio_codecs/audio_encoder_factory.h" #include "api/audio_options.h" #include "api/crypto/crypto_options.h" +#include "api/environment/environment.h" #include "api/field_trials_view.h" #include "api/rtc_error.h" #include "api/rtp_parameters.h" @@ -146,18 +147,19 @@ class VideoEngineInterface : public RtpHeaderExtensionQueryInterface { VideoEngineInterface& operator=(const VideoEngineInterface&) = delete; virtual std::unique_ptr<VideoMediaSendChannelInterface> CreateSendChannel( - Call* /* call */, - const MediaConfig& /* config */, - const VideoOptions& /* options */, - const CryptoOptions& /* crypto_options */, - VideoBitrateAllocatorFactory* - /* video_bitrate_allocator_factory */) = 0; + const Environment& env, + Call* call, + const MediaConfig& config, + const VideoOptions& options, + const CryptoOptions& crypto_options, + VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) = 0; virtual std::unique_ptr<VideoMediaReceiveChannelInterface> - CreateReceiveChannel(Call* /* call */, - const MediaConfig& /* config */, - const VideoOptions& /* options */, - const CryptoOptions& /* crypto_options */) = 0; + CreateReceiveChannel(const Environment& env, + Call* call, + const MediaConfig& config, + const VideoOptions& options, + const CryptoOptions& crypto_options) = 0; // Legacy: Retrieve list of supported codecs. // + protection codecs, and assigns PT numbers that may have to be diff --git a/third_party/libwebrtc/media/engine/webrtc_video_engine.cc b/third_party/libwebrtc/media/engine/webrtc_video_engine.cc @@ -31,6 +31,7 @@ #include "api/array_view.h" #include "api/crypto/crypto_options.h" #include "api/crypto/frame_decryptor_interface.h" +#include "api/environment/environment.h" #include "api/field_trials_view.h" #include "api/frame_transformer_interface.h" #include "api/make_ref_counted.h" @@ -824,22 +825,24 @@ WebRtcVideoEngine::~WebRtcVideoEngine() { std::unique_ptr<VideoMediaSendChannelInterface> WebRtcVideoEngine::CreateSendChannel( + const Environment& env, Call* call, const MediaConfig& config, const VideoOptions& options, const CryptoOptions& crypto_options, VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) { return std::make_unique<WebRtcVideoSendChannel>( - call, config, options, crypto_options, encoder_factory_.get(), + env, call, config, options, crypto_options, encoder_factory_.get(), video_bitrate_allocator_factory); } std::unique_ptr<VideoMediaReceiveChannelInterface> -WebRtcVideoEngine::CreateReceiveChannel(Call* call, +WebRtcVideoEngine::CreateReceiveChannel(const Environment& env, + Call* call, const MediaConfig& config, const VideoOptions& options, const CryptoOptions& crypto_options) { return std::make_unique<WebRtcVideoReceiveChannel>( - call, config, options, crypto_options, decoder_factory_.get()); + env, call, config, options, crypto_options, decoder_factory_.get()); } std::vector<Codec> WebRtcVideoEngine::LegacySendCodecs(bool include_rtx) const { @@ -907,6 +910,7 @@ MergeInfoAboutOutboundRtpSubstreamsForTesting( // --------------- WebRtcVideoSendChannel ---------------------- WebRtcVideoSendChannel::WebRtcVideoSendChannel( + const Environment& env, Call* call, const MediaConfig& config, const VideoOptions& options, @@ -914,6 +918,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendChannel( VideoEncoderFactory* encoder_factory, VideoBitrateAllocatorFactory* bitrate_allocator_factory) : MediaChannelUtil(call->network_thread(), config.enable_dscp), + env_(env), worker_thread_(call->worker_thread()), sending_(false), receiving_(false), @@ -925,7 +930,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendChannel( default_send_options_(options), last_send_stats_log_ms_(-1), last_receive_stats_log_ms_(-1), - discard_unknown_ssrc_packets_(call_->trials().IsEnabled( + discard_unknown_ssrc_packets_(env_.field_trials().IsEnabled( "WebRTC-Video-DiscardPacketsWithUnknownSsrc")), crypto_options_(crypto_options) { RTC_DCHECK_RUN_ON(&thread_checker_); @@ -999,7 +1004,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::ConfigureVideoEncoderSettings( {"onkeypic", InterLayerPredMode::kOnKeyPic}}); ParseFieldTrial( {&interlayer_pred_experiment_enabled, &inter_layer_pred_mode}, - call_->trials().Lookup("WebRTC-Vp9InterLayerPred")); + env_.field_trials().Lookup("WebRTC-Vp9InterLayerPred")); if (interlayer_pred_experiment_enabled) { vp9_settings.interLayerPred = inter_layer_pred_mode; } else { @@ -1009,7 +1014,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::ConfigureVideoEncoderSettings( // TODO(webrtc:329396373): Remove after flexible mode is fully deployed. vp9_settings.flexibleMode = - !call_->trials().IsDisabled("WebRTC-Video-Vp9FlexibleMode"); + !env_.field_trials().IsDisabled("WebRTC-Video-Vp9FlexibleMode"); } else { // Multiple spatial layers vp9 screenshare needs flexible mode. vp9_settings.flexibleMode = vp9_settings.numberOfSpatialLayers > 1; @@ -1093,7 +1098,7 @@ bool WebRtcVideoSendChannel::GetChangedSenderParameters( } // Never enable sending FlexFEC, unless we are in the experiment. - if (!call_->trials().IsEnabled("WebRTC-FlexFEC-03")) { + if (!env_.field_trials().IsEnabled("WebRTC-FlexFEC-03")) { for (VideoCodecSettings& codec : negotiated_codecs) codec.flexfec_payload_type = -1; } @@ -1174,7 +1179,7 @@ bool WebRtcVideoSendChannel::GetChangedSenderParameters( } std::vector<RtpExtension> filtered_extensions = FilterRtpExtensions(params.extensions, RtpExtension::IsSupportedForVideo, - true, call_->trials()); + true, env_.field_trials()); if (send_rtp_extensions_ != filtered_extensions) { changed_params->rtp_header_extensions = std::optional<std::vector<RtpExtension>>(filtered_extensions); @@ -1553,7 +1558,7 @@ bool WebRtcVideoSendChannel::AddSendStream(const StreamParams& sp) { video_config_.enable_send_packet_batching; WebRtcVideoSendStream* stream = new WebRtcVideoSendStream( - call_, sp, std::move(config), default_send_options_, + env_, call_, sp, std::move(config), default_send_options_, video_config_.enable_cpu_adaptation, bitrate_config_.max_bitrate_bps, send_codec(), send_codecs_, send_rtp_extensions_, send_params_); @@ -1609,7 +1614,7 @@ bool WebRtcVideoSendChannel::GetStats(VideoMediaSendInfo* info) { // Log stats periodically. bool log_stats = false; - int64_t now_ms = call_->env().clock().TimeInMilliseconds(); + int64_t now_ms = env_.clock().TimeInMilliseconds(); if (last_send_stats_log_ms_ == -1 || now_ms - last_send_stats_log_ms_ > kStatsLogIntervalMs) { last_send_stats_log_ms_ = now_ms; @@ -1716,7 +1721,7 @@ void WebRtcVideoSendChannel::SetInterface(MediaChannelNetworkInterface* iface) { // due to lack of socket buffer space, although it's not yet clear what the // ideal value should be. const std::string group_name_send_buf_size = - call_->trials().Lookup("WebRTC-SendBufferSizeBytes"); + env_.field_trials().Lookup("WebRTC-SendBufferSizeBytes"); int send_buffer_size = kVideoRtpSendBufferSize; if (!group_name_send_buf_size.empty() && (sscanf(group_name_send_buf_size.c_str(), "%d", &send_buffer_size) != 1 || @@ -1769,6 +1774,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::VideoSendStreamParameters:: codec_settings_list(codec_settings_list) {} WebRtcVideoSendChannel::WebRtcVideoSendStream::WebRtcVideoSendStream( + const Environment& env, Call* call, const StreamParams& sp, VideoSendStream::Config config, @@ -1781,11 +1787,11 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::WebRtcVideoSendStream( // TODO(deadbeef): Don't duplicate information between send_params, // rtp_extensions, options, etc. const VideoSenderParameters& send_params) - : worker_thread_(call->worker_thread()), + : env_(env), + worker_thread_(call->worker_thread()), ssrcs_(sp.ssrcs), ssrc_groups_(sp.ssrc_groups), call_(call), - clock_(&call_->env().clock()), enable_cpu_overuse_detection_(enable_cpu_overuse_detection), source_(nullptr), stream_(nullptr), @@ -1818,7 +1824,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::WebRtcVideoSendStream( // FlexFEC SSRCs. // TODO(brandtr): This code needs to be generalized when we add support for // multistream protection. - if (call_->trials().IsEnabled("WebRTC-FlexFEC-03")) { + if (env_.field_trials().IsEnabled("WebRTC-FlexFEC-03")) { uint32_t flexfec_ssrc; bool flexfec_enabled = false; for (uint32_t primary_ssrc : parameters_.config.rtp.ssrcs) { @@ -1931,7 +1937,8 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::GetDegradationPreference() parameters_.options.content_hint == VideoTrackInterface::ContentHint::kText) { degradation_preference = DegradationPreference::MAINTAIN_RESOLUTION; - } else if (call_->trials().IsEnabled("WebRTC-Video-BalancedDegradation")) { + } else if (env_.field_trials().IsEnabled( + "WebRTC-Video-BalancedDegradation")) { // Standard wants balanced by default, but it needs to be tuned first. degradation_preference = DegradationPreference::BALANCED; } else { @@ -2092,7 +2099,7 @@ RTCError WebRtcVideoSendChannel::WebRtcVideoSendStream::SetRtpParameters( // conformance. // TODO(orphis): Migrate tests to later make this a DCHECK only RTCError error = CheckRtpParametersInvalidModificationAndValues( - rtp_parameters_, new_parameters, call_->trials()); + rtp_parameters_, new_parameters, env_.field_trials()); if (!error.ok()) { return InvokeSetParametersCallback(callback, error); } @@ -2427,7 +2434,7 @@ WebRtcVideoSendChannel::WebRtcVideoSendStream::GetPerLayerVideoSenderInfos( } else { stats = stream_->GetStats(); if (log_stats) - RTC_LOG(LS_INFO) << stats.ToString(clock_->TimeInMilliseconds()); + RTC_LOG(LS_INFO) << stats.ToString(env_.clock().TimeInMilliseconds()); // Metrics that are in common for all substreams. common_info.adapt_changes = stats.number_of_cpu_adapt_changes; @@ -2731,12 +2738,14 @@ void WebRtcVideoSendChannel::SetEncoderToPacketizerFrameTransformer( // ------------------------ WebRtcVideoReceiveChannel --------------------- WebRtcVideoReceiveChannel::WebRtcVideoReceiveChannel( + const Environment& env, Call* call, const MediaConfig& config, const VideoOptions& options, const CryptoOptions& crypto_options, VideoDecoderFactory* decoder_factory) : MediaChannelUtil(call->network_thread(), config.enable_dscp), + env_(env), worker_thread_(call->worker_thread()), receiving_(false), call_(call), @@ -2745,16 +2754,16 @@ WebRtcVideoReceiveChannel::WebRtcVideoReceiveChannel( decoder_factory_(decoder_factory), default_send_options_(options), last_receive_stats_log_ms_(-1), - discard_unknown_ssrc_packets_(call_->trials().IsEnabled( + discard_unknown_ssrc_packets_(env_.field_trials().IsEnabled( "WebRTC-Video-DiscardPacketsWithUnknownSsrc")), crypto_options_(crypto_options), - receive_buffer_size_(ParseReceiveBufferSize(call_->trials())) { + receive_buffer_size_(ParseReceiveBufferSize(env_.field_trials())) { RTC_DCHECK_RUN_ON(&thread_checker_); rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; // Crash if MapCodecs fails. recv_codecs_ = MapCodecs(GetPayloadTypesAndDefaultCodecs( decoder_factory_, /*is_decoder_factory=*/true, - /*include_rtx=*/true, call_->trials())) + /*include_rtx=*/true, env_.field_trials())) .value(); recv_flexfec_payload_type_ = recv_codecs_.empty() ? 0 : recv_codecs_.front().flexfec_payload_type; @@ -2855,7 +2864,8 @@ bool WebRtcVideoReceiveChannel::GetChangedReceiverParameters( const std::vector<Codec> local_supported_codecs = GetPayloadTypesAndDefaultCodecs(decoder_factory_, /*is_decoder_factory=*/true, - /*include_rtx=*/true, call_->trials()); + /*include_rtx=*/true, + env_.field_trials()); for (const VideoCodecSettings& mapped_codec : mapped_codecs) { if (!FindMatchingVideoCodec(local_supported_codecs, mapped_codec.codec)) { RTC_LOG(LS_ERROR) << "GetChangedReceiverParameters called with " @@ -2874,7 +2884,7 @@ bool WebRtcVideoReceiveChannel::GetChangedReceiverParameters( // Handle RTP header extensions. std::vector<RtpExtension> filtered_extensions = FilterRtpExtensions(params.extensions, RtpExtension::IsSupportedForVideo, - false, call_->trials()); + false, env_.field_trials()); if (filtered_extensions != recv_rtp_extensions_) { changed_params->rtp_header_extensions = std::optional<std::vector<RtpExtension>>(filtered_extensions); @@ -3036,9 +3046,9 @@ bool WebRtcVideoReceiveChannel::AddRecvStream(const StreamParams& sp, if (unsignaled_frame_transformer_ && !config.frame_transformer) config.frame_transformer = unsignaled_frame_transformer_; - auto receive_stream = - new WebRtcVideoReceiveStream(call_, sp, std::move(config), default_stream, - recv_codecs_, flexfec_config); + auto receive_stream = new WebRtcVideoReceiveStream( + env_, call_, sp, std::move(config), default_stream, recv_codecs_, + flexfec_config); if (receiving_) { receive_stream->StartReceiveStream(); } @@ -3075,7 +3085,7 @@ void WebRtcVideoReceiveChannel::ConfigureReceiverRtp( // TODO(brandtr): Generalize when we add support for multistream protection. flexfec_config->payload_type = recv_flexfec_payload_type_; - if (!call_->trials().IsDisabled("WebRTC-FlexFEC-03-Advertised") && + if (!env_.field_trials().IsDisabled("WebRTC-FlexFEC-03-Advertised") && sp.GetFecFrSsrc(ssrc, &flexfec_config->rtp.remote_ssrc)) { flexfec_config->protected_media_ssrcs = {ssrc}; flexfec_config->rtp.local_ssrc = config->rtp.local_ssrc; @@ -3174,7 +3184,7 @@ bool WebRtcVideoReceiveChannel::GetStats(VideoMediaReceiveInfo* info) { // Log stats periodically. bool log_stats = false; - int64_t now_ms = call_->env().clock().TimeInMilliseconds(); + int64_t now_ms = env_.clock().TimeInMilliseconds(); if (last_receive_stats_log_ms_ == -1 || now_ms - last_receive_stats_log_ms_ > kStatsLogIntervalMs) { last_receive_stats_log_ms_ = now_ms; @@ -3285,7 +3295,7 @@ bool WebRtcVideoReceiveChannel::MaybeCreateDefaultReceiveStream( // of creating decoders on every packet eats up processing time (e.g. // https://crbug.com/1069603) and this cooldown prevents that. if (last_unsignalled_ssrc_creation_time_ms_.has_value()) { - int64_t now_ms = call_->env().clock().TimeInMilliseconds(); + int64_t now_ms = env_.clock().TimeInMilliseconds(); if (now_ms - last_unsignalled_ssrc_creation_time_ms_.value() < kUnsignaledSsrcCooldownMs) { // We've already created an unsignalled ssrc stream within the last @@ -3299,8 +3309,7 @@ bool WebRtcVideoReceiveChannel::MaybeCreateDefaultReceiveStream( // RTX SSRC not yet known. ReCreateDefaultReceiveStream(packet.Ssrc(), std::nullopt); - last_unsignalled_ssrc_creation_time_ms_ = - call_->env().clock().TimeInMilliseconds(); + last_unsignalled_ssrc_creation_time_ms_ = env_.clock().TimeInMilliseconds(); return true; } @@ -3416,13 +3425,15 @@ std::vector<RtpSource> WebRtcVideoReceiveChannel::GetSources( } WebRtcVideoReceiveChannel::WebRtcVideoReceiveStream::WebRtcVideoReceiveStream( + const Environment& env, Call* call, const StreamParams& sp, VideoReceiveStreamInterface::Config config, bool default_stream, const std::vector<VideoCodecSettings>& recv_codecs, const FlexfecReceiveStream::Config& flexfec_config) - : call_(call), + : env_(env), + call_(call), stream_params_(sp), stream_(nullptr), default_stream_(default_stream), @@ -3726,7 +3737,7 @@ void WebRtcVideoReceiveChannel::WebRtcVideoReceiveStream::OnFrame( const VideoFrame& frame) { MutexLock lock(&sink_lock_); - int64_t time_now_ms = call_->env().clock().TimeInMilliseconds(); + int64_t time_now_ms = env_.clock().TimeInMilliseconds(); if (first_frame_timestamp_ < 0) first_frame_timestamp_ = time_now_ms; int64_t elapsed_time_ms = time_now_ms - first_frame_timestamp_; @@ -3916,8 +3927,7 @@ WebRtcVideoReceiveChannel::WebRtcVideoReceiveStream::GetVideoReceiverInfo( // present if DLRR is enabled. if (log_stats) - RTC_LOG(LS_INFO) << stats.ToString( - call_->env().clock().TimeInMilliseconds()); + RTC_LOG(LS_INFO) << stats.ToString(env_.clock().TimeInMilliseconds()); return info; } @@ -4009,7 +4019,7 @@ void WebRtcVideoReceiveChannel::ProcessReceivedPacket( packet.IdentifyExtensions(recv_rtp_extension_map_); packet.set_payload_type_frequency(kVideoPayloadTypeFrequency); if (!packet.arrival_time().IsFinite()) { - packet.set_arrival_time(call_->env().clock().CurrentTime()); + packet.set_arrival_time(env_.clock().CurrentTime()); } call_->Receiver()->DeliverRtpPacket( diff --git a/third_party/libwebrtc/media/engine/webrtc_video_engine.h b/third_party/libwebrtc/media/engine/webrtc_video_engine.h @@ -28,6 +28,7 @@ #include "api/crypto/crypto_options.h" #include "api/crypto/frame_decryptor_interface.h" #include "api/crypto/frame_encryptor_interface.h" +#include "api/environment/environment.h" #include "api/field_trials_view.h" #include "api/frame_transformer_interface.h" #include "api/media_types.h" @@ -68,7 +69,6 @@ #include "rtc_base/synchronization/mutex.h" #include "rtc_base/system/no_unique_address.h" #include "rtc_base/thread_annotations.h" -#include "system_wrappers/include/clock.h" #include "video/config/video_encoder_config.h" namespace webrtc { @@ -103,12 +103,14 @@ class WebRtcVideoEngine : public VideoEngineInterface { ~WebRtcVideoEngine() override; std::unique_ptr<VideoMediaSendChannelInterface> CreateSendChannel( + const Environment& env, Call* call, const MediaConfig& config, const VideoOptions& options, const CryptoOptions& crypto_options, VideoBitrateAllocatorFactory* video_bitrate_allocator_factory) override; std::unique_ptr<VideoMediaReceiveChannelInterface> CreateReceiveChannel( + const Environment& env, Call* call, const MediaConfig& config, const VideoOptions& options, @@ -159,6 +161,7 @@ class WebRtcVideoSendChannel : public MediaChannelUtil, public EncoderSwitchRequestCallback { public: WebRtcVideoSendChannel( + const Environment& env, Call* call, const MediaConfig& config, const VideoOptions& options, @@ -311,6 +314,7 @@ class WebRtcVideoSendChannel : public MediaChannelUtil, class WebRtcVideoSendStream { public: WebRtcVideoSendStream( + const Environment& env, Call* call, const StreamParams& sp, VideoSendStream::Config config, @@ -392,12 +396,12 @@ class WebRtcVideoSendChannel : public MediaChannelUtil, DegradationPreference GetDegradationPreference() const RTC_EXCLUSIVE_LOCKS_REQUIRED(&thread_checker_); + const Environment env_; RTC_NO_UNIQUE_ADDRESS SequenceChecker thread_checker_; TaskQueueBase* const worker_thread_; const std::vector<uint32_t> ssrcs_ RTC_GUARDED_BY(&thread_checker_); const std::vector<SsrcGroup> ssrc_groups_ RTC_GUARDED_BY(&thread_checker_); Call* const call_; - Clock* const clock_; const bool enable_cpu_overuse_detection_; VideoSourceInterface<VideoFrame>* source_ RTC_GUARDED_BY(&thread_checker_); @@ -445,6 +449,8 @@ class WebRtcVideoSendChannel : public MediaChannelUtil, const std::optional<VideoCodecSettings>& send_codec() const { return send_codec_; } + + const Environment env_; TaskQueueBase* const worker_thread_; ScopedTaskSafety task_safety_; RTC_NO_UNIQUE_ADDRESS SequenceChecker network_thread_checker_{ @@ -539,7 +545,8 @@ class WebRtcVideoSendChannel : public MediaChannelUtil, class WebRtcVideoReceiveChannel : public MediaChannelUtil, public VideoMediaReceiveChannelInterface { public: - WebRtcVideoReceiveChannel(Call* call, + WebRtcVideoReceiveChannel(const Environment& env, + Call* call, const MediaConfig& config, const VideoOptions& options, const CryptoOptions& crypto_options, @@ -655,6 +662,7 @@ class WebRtcVideoReceiveChannel : public MediaChannelUtil, class WebRtcVideoReceiveStream : public VideoSinkInterface<VideoFrame> { public: WebRtcVideoReceiveStream( + const Environment& env, Call* call, const StreamParams& sp, VideoReceiveStreamInterface::Config config, @@ -723,6 +731,7 @@ class WebRtcVideoReceiveChannel : public MediaChannelUtil, // were applied. bool ReconfigureCodecs(const std::vector<VideoCodecSettings>& recv_codecs); + const Environment env_; Call* const call_; const StreamParams stream_params_; @@ -761,6 +770,7 @@ class WebRtcVideoReceiveChannel : public MediaChannelUtil, return unsignaled_stream_params_; } // Variables. + const Environment env_; TaskQueueBase* const worker_thread_; ScopedTaskSafety task_safety_; RTC_NO_UNIQUE_ADDRESS SequenceChecker network_thread_checker_{ diff --git a/third_party/libwebrtc/media/engine/webrtc_video_engine_unittest.cc b/third_party/libwebrtc/media/engine/webrtc_video_engine_unittest.cc @@ -115,6 +115,7 @@ #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/socket.h" #include "rtc_base/time_utils.h" +#include "test/create_test_environment.h" #include "test/create_test_field_trials.h" #include "test/fake_decoder.h" #include "test/frame_forwarder.h" @@ -710,8 +711,8 @@ TEST_F(WebRtcVideoEngineTest, SetSendFailsBeforeSettingCodecs) { AddSupportedVideoCodecType("VP8"); std::unique_ptr<VideoMediaSendChannelInterface> send_channel = - engine_.CreateSendChannel(call_.get(), GetMediaConfig(), VideoOptions(), - CryptoOptions(), + engine_.CreateSendChannel(env_, call_.get(), GetMediaConfig(), + VideoOptions(), CryptoOptions(), video_bitrate_allocator_factory_.get()); EXPECT_TRUE(send_channel->AddSendStream(StreamParams::CreateLegacy(123))); @@ -726,15 +727,15 @@ TEST_F(WebRtcVideoEngineTest, GetStatsWithoutCodecsSetDoesNotCrash) { AddSupportedVideoCodecType("VP8"); std::unique_ptr<VideoMediaSendChannelInterface> send_channel = - engine_.CreateSendChannel(call_.get(), GetMediaConfig(), VideoOptions(), - CryptoOptions(), + engine_.CreateSendChannel(env_, call_.get(), GetMediaConfig(), + VideoOptions(), CryptoOptions(), video_bitrate_allocator_factory_.get()); EXPECT_TRUE(send_channel->AddSendStream(StreamParams::CreateLegacy(123))); VideoMediaSendInfo send_info; send_channel->GetStats(&send_info); std::unique_ptr<VideoMediaReceiveChannelInterface> receive_channel = - engine_.CreateReceiveChannel(call_.get(), GetMediaConfig(), + engine_.CreateReceiveChannel(env_, call_.get(), GetMediaConfig(), VideoOptions(), CryptoOptions()); EXPECT_TRUE(receive_channel->AddRecvStream(StreamParams::CreateLegacy(123))); VideoMediaReceiveInfo receive_info; @@ -944,8 +945,8 @@ void WebRtcVideoEngineTest::AddSupportedVideoCodec(SdpVideoFormat format) { std::unique_ptr<VideoMediaSendChannelInterface> WebRtcVideoEngineTest::SetSendParamsWithAllSupportedCodecs() { std::unique_ptr<VideoMediaSendChannelInterface> channel = - engine_.CreateSendChannel(call_.get(), GetMediaConfig(), VideoOptions(), - CryptoOptions(), + engine_.CreateSendChannel(env_, call_.get(), GetMediaConfig(), + VideoOptions(), CryptoOptions(), video_bitrate_allocator_factory_.get()); VideoSenderParameters parameters; // We need to look up the codec in the engine to get the correct payload type. @@ -965,7 +966,7 @@ std::unique_ptr<VideoMediaReceiveChannelInterface> WebRtcVideoEngineTest::SetRecvParamsWithSupportedCodecs( const std::vector<Codec>& codecs) { std::unique_ptr<VideoMediaReceiveChannelInterface> channel = - engine_.CreateReceiveChannel(call_.get(), GetMediaConfig(), + engine_.CreateReceiveChannel(env_, call_.get(), GetMediaConfig(), VideoOptions(), CryptoOptions()); VideoReceiverParameters parameters; parameters.codecs = codecs; @@ -1001,7 +1002,7 @@ void WebRtcVideoEngineTest::ExpectRtpCapabilitySupport(const char* uri, TEST_F(WebRtcVideoEngineTest, ReceiveBufferSizeViaFieldTrial) { field_trials_.Set("WebRTC-ReceiveBufferSize", "size_bytes:10000"); std::unique_ptr<VideoMediaReceiveChannelInterface> receive_channel = - engine_.CreateReceiveChannel(call_.get(), GetMediaConfig(), + engine_.CreateReceiveChannel(env_, call_.get(), GetMediaConfig(), VideoOptions(), CryptoOptions()); FakeNetworkInterface network; receive_channel->SetInterface(&network); @@ -1014,7 +1015,7 @@ TEST_F(WebRtcVideoEngineTest, TooLowReceiveBufferSizeViaFieldTrial) { // kVideoRtpRecvBufferSize. field_trials_.Set("WebRTC-ReceiveBufferSize", "size_bytes:10000001"); std::unique_ptr<VideoMediaReceiveChannelInterface> receive_channel = - engine_.CreateReceiveChannel(call_.get(), GetMediaConfig(), + engine_.CreateReceiveChannel(env_, call_.get(), GetMediaConfig(), VideoOptions(), CryptoOptions()); FakeNetworkInterface network; receive_channel->SetInterface(&network); @@ -1026,7 +1027,7 @@ TEST_F(WebRtcVideoEngineTest, TooHighReceiveBufferSizeViaFieldTrial) { // 9999 is too low, it will revert to the default kVideoRtpRecvBufferSize. field_trials_.Set("WebRTC-ReceiveBufferSize", "size_bytes:9999"); std::unique_ptr<VideoMediaReceiveChannelInterface> receive_channel = - engine_.CreateReceiveChannel(call_.get(), GetMediaConfig(), + engine_.CreateReceiveChannel(env_, call_.get(), GetMediaConfig(), VideoOptions(), CryptoOptions()); FakeNetworkInterface network; receive_channel->SetInterface(&network); @@ -1044,7 +1045,7 @@ TEST_F(WebRtcVideoEngineTest, UpdatesUnsignaledRtxSsrcAndRecoversPayload) { int rtx_payload_type = supported_codecs[1].id; std::unique_ptr<VideoMediaReceiveChannelInterface> receive_channel = - engine_.CreateReceiveChannel(call_.get(), GetMediaConfig(), + engine_.CreateReceiveChannel(env_, call_.get(), GetMediaConfig(), VideoOptions(), CryptoOptions()); VideoReceiverParameters parameters; parameters.codecs = supported_codecs; @@ -1124,8 +1125,8 @@ TEST_F(WebRtcVideoEngineTest, ChannelWithH264CanChangeToVp8) { FakeFrameSource frame_source(1280, 720, kNumMicrosecsPerSec / 30); std::unique_ptr<VideoMediaSendChannelInterface> send_channel = - engine_.CreateSendChannel(call_.get(), GetMediaConfig(), VideoOptions(), - CryptoOptions(), + engine_.CreateSendChannel(env_, call_.get(), GetMediaConfig(), + VideoOptions(), CryptoOptions(), video_bitrate_allocator_factory_.get()); VideoSenderParameters parameters; parameters.codecs.push_back(GetEngineCodec("H264")); @@ -1156,8 +1157,8 @@ TEST_F(WebRtcVideoEngineTest, AddSupportedVideoCodecType("H264"); std::unique_ptr<VideoMediaSendChannelInterface> send_channel = - engine_.CreateSendChannel(call_.get(), GetMediaConfig(), VideoOptions(), - CryptoOptions(), + engine_.CreateSendChannel(env_, call_.get(), GetMediaConfig(), + VideoOptions(), CryptoOptions(), video_bitrate_allocator_factory_.get()); VideoSenderParameters parameters; parameters.codecs.push_back(GetEngineCodec("VP8")); @@ -1195,8 +1196,8 @@ TEST_F(WebRtcVideoEngineTest, AddSupportedVideoCodecType("H264"); std::unique_ptr<VideoMediaSendChannelInterface> send_channel = - engine_.CreateSendChannel(call_.get(), GetMediaConfig(), VideoOptions(), - CryptoOptions(), + engine_.CreateSendChannel(env_, call_.get(), GetMediaConfig(), + VideoOptions(), CryptoOptions(), video_bitrate_allocator_factory_.get()); VideoSenderParameters parameters; parameters.codecs.push_back(GetEngineCodec("H264")); @@ -1225,8 +1226,8 @@ TEST_F(WebRtcVideoEngineTest, SimulcastEnabledForH264) { AddSupportedVideoCodecType("H264"); std::unique_ptr<VideoMediaSendChannelInterface> send_channel = - engine_.CreateSendChannel(call_.get(), GetMediaConfig(), VideoOptions(), - CryptoOptions(), + engine_.CreateSendChannel(env_, call_.get(), GetMediaConfig(), + VideoOptions(), CryptoOptions(), video_bitrate_allocator_factory_.get()); VideoSenderParameters parameters; @@ -1480,15 +1481,16 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, Vp8) { // Create a call. GlobalSimulatedTimeController time_controller(Timestamp::Millis(4711)); - CallConfig call_config(CreateEnvironment( - time_controller.CreateTaskQueueFactory(), time_controller.GetClock())); + const Environment env = CreateTestEnvironment({.time = &time_controller}); + CallConfig call_config(env); const std::unique_ptr<Call> call = Call::Create(std::move(call_config)); // Create send channel. const int send_ssrc = 123; std::unique_ptr<VideoMediaSendChannelInterface> send_channel = - engine.CreateSendChannel(call.get(), GetMediaConfig(), VideoOptions(), - CryptoOptions(), rate_allocator_factory.get()); + engine.CreateSendChannel(env, call.get(), GetMediaConfig(), + VideoOptions(), CryptoOptions(), + rate_allocator_factory.get()); VideoSenderParameters send_parameters; send_parameters.codecs.push_back(engine_codecs.at(0)); @@ -1509,8 +1511,8 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, Vp8) { // Create recv channel. const int recv_ssrc = 321; std::unique_ptr<VideoMediaReceiveChannelInterface> receive_channel = - engine.CreateReceiveChannel(call.get(), GetMediaConfig(), VideoOptions(), - CryptoOptions()); + engine.CreateReceiveChannel(env, call.get(), GetMediaConfig(), + VideoOptions(), CryptoOptions()); VideoReceiverParameters recv_parameters; recv_parameters.codecs.push_back(engine_codecs.at(0)); @@ -1606,9 +1608,8 @@ class WebRtcVideoChannelEncodedFrameCallbackTest : public ::testing::Test { protected: WebRtcVideoChannelEncodedFrameCallbackTest() : field_trials_(CreateTestFieldTrials()), - env_(CreateEnvironment(&field_trials_, - time_controller_.CreateTaskQueueFactory(), - time_controller_.GetClock())), + env_(CreateTestEnvironment( + {.field_trials = &field_trials_, .time = &time_controller_})), call_(Call::Create(CallConfig(env_))), video_bitrate_allocator_factory_( CreateBuiltinVideoBitrateAllocatorFactory()), @@ -1623,10 +1624,10 @@ class WebRtcVideoChannelEncodedFrameCallbackTest : public ::testing::Test { kSdpVideoFormats), field_trials_) { send_channel_ = engine_.CreateSendChannel( - call_.get(), MediaConfig(), VideoOptions(), CryptoOptions(), + env_, call_.get(), MediaConfig(), VideoOptions(), CryptoOptions(), video_bitrate_allocator_factory_.get()); receive_channel_ = engine_.CreateReceiveChannel( - call_.get(), MediaConfig(), VideoOptions(), CryptoOptions()); + env_, call_.get(), MediaConfig(), VideoOptions(), CryptoOptions()); network_interface_.SetDestination(receive_channel_.get()); send_channel_->SetInterface(&network_interface_); @@ -1777,9 +1778,8 @@ class WebRtcVideoChannelBaseTest : public ::testing::Test { protected: WebRtcVideoChannelBaseTest() : field_trials_(CreateTestFieldTrials()), - env_(CreateEnvironment(&field_trials_, - time_controller_.CreateTaskQueueFactory(), - time_controller_.GetClock())), + env_(CreateTestEnvironment( + {.field_trials = &field_trials_, .time = &time_controller_})), video_bitrate_allocator_factory_( CreateBuiltinVideoBitrateAllocatorFactory()), engine_( @@ -1808,10 +1808,10 @@ class WebRtcVideoChannelBaseTest : public ::testing::Test { // frames become flaky. media_config.video.enable_cpu_adaptation = false; send_channel_ = engine_.CreateSendChannel( - call_.get(), media_config, VideoOptions(), CryptoOptions(), + env_, call_.get(), media_config, VideoOptions(), CryptoOptions(), video_bitrate_allocator_factory_.get()); receive_channel_ = engine_.CreateReceiveChannel( - call_.get(), media_config, VideoOptions(), CryptoOptions()); + env_, call_.get(), media_config, VideoOptions(), CryptoOptions()); send_channel_->OnReadyToSend(true); receive_channel_->SetReceive(true); network_interface_.SetDestination(receive_channel_.get()); @@ -2705,10 +2705,11 @@ class WebRtcVideoChannelTest : public WebRtcVideoEngineTest { fake_call_ = std::make_unique<FakeCall>(env_); send_channel_ = engine_.CreateSendChannel( - fake_call_.get(), GetMediaConfig(), VideoOptions(), CryptoOptions(), - video_bitrate_allocator_factory_.get()); - receive_channel_ = engine_.CreateReceiveChannel( - fake_call_.get(), GetMediaConfig(), VideoOptions(), CryptoOptions()); + env_, fake_call_.get(), GetMediaConfig(), VideoOptions(), + CryptoOptions(), video_bitrate_allocator_factory_.get()); + receive_channel_ = + engine_.CreateReceiveChannel(env_, fake_call_.get(), GetMediaConfig(), + VideoOptions(), CryptoOptions()); send_channel_->SetSsrcListChangedCallback( [receive_channel = receive_channel_.get()](const std::set<uint32_t>& choices) { @@ -3638,10 +3639,10 @@ TEST_F(WebRtcVideoChannelTest, SetMediaConfigSuspendBelowMinBitrate) { media_config.video.suspend_below_min_bitrate = true; send_channel_ = engine_.CreateSendChannel( - fake_call_.get(), media_config, VideoOptions(), CryptoOptions(), + env_, fake_call_.get(), media_config, VideoOptions(), CryptoOptions(), video_bitrate_allocator_factory_.get()); receive_channel_ = engine_.CreateReceiveChannel( - fake_call_.get(), media_config, VideoOptions(), CryptoOptions()); + env_, fake_call_.get(), media_config, VideoOptions(), CryptoOptions()); send_channel_->OnReadyToSend(true); send_channel_->SetSenderParameters(send_parameters_); @@ -3651,10 +3652,10 @@ TEST_F(WebRtcVideoChannelTest, SetMediaConfigSuspendBelowMinBitrate) { media_config.video.suspend_below_min_bitrate = false; send_channel_ = engine_.CreateSendChannel( - fake_call_.get(), media_config, VideoOptions(), CryptoOptions(), + env_, fake_call_.get(), media_config, VideoOptions(), CryptoOptions(), video_bitrate_allocator_factory_.get()); receive_channel_ = engine_.CreateReceiveChannel( - fake_call_.get(), media_config, VideoOptions(), CryptoOptions()); + env_, fake_call_.get(), media_config, VideoOptions(), CryptoOptions()); send_channel_->OnReadyToSend(true); send_channel_->SetSenderParameters(send_parameters_); @@ -4264,10 +4265,10 @@ TEST_F(WebRtcVideoChannelTest, PreviousAdaptationDoesNotApplyToScreenshare) { MediaConfig media_config = GetMediaConfig(); media_config.video.enable_cpu_adaptation = true; send_channel_ = engine_.CreateSendChannel( - fake_call_.get(), media_config, VideoOptions(), CryptoOptions(), + env_, fake_call_.get(), media_config, VideoOptions(), CryptoOptions(), video_bitrate_allocator_factory_.get()); receive_channel_ = engine_.CreateReceiveChannel( - fake_call_.get(), media_config, VideoOptions(), CryptoOptions()); + env_, fake_call_.get(), media_config, VideoOptions(), CryptoOptions()); send_channel_->OnReadyToSend(true); ASSERT_TRUE(send_channel_->SetSenderParameters(parameters)); @@ -4318,10 +4319,10 @@ void WebRtcVideoChannelTest::TestDegradationPreference( MediaConfig media_config = GetMediaConfig(); media_config.video.enable_cpu_adaptation = true; send_channel_ = engine_.CreateSendChannel( - fake_call_.get(), media_config, VideoOptions(), CryptoOptions(), + env_, fake_call_.get(), media_config, VideoOptions(), CryptoOptions(), video_bitrate_allocator_factory_.get()); receive_channel_ = engine_.CreateReceiveChannel( - fake_call_.get(), media_config, VideoOptions(), CryptoOptions()); + env_, fake_call_.get(), media_config, VideoOptions(), CryptoOptions()); send_channel_->OnReadyToSend(true); EXPECT_TRUE(send_channel_->SetSenderParameters(parameters)); @@ -4354,10 +4355,10 @@ void WebRtcVideoChannelTest::TestCpuAdaptation(bool enable_overuse, media_config.video.enable_cpu_adaptation = true; } send_channel_ = engine_.CreateSendChannel( - fake_call_.get(), media_config, VideoOptions(), CryptoOptions(), + env_, fake_call_.get(), media_config, VideoOptions(), CryptoOptions(), video_bitrate_allocator_factory_.get()); receive_channel_ = engine_.CreateReceiveChannel( - fake_call_.get(), media_config, VideoOptions(), CryptoOptions()); + env_, fake_call_.get(), media_config, VideoOptions(), CryptoOptions()); send_channel_->OnReadyToSend(true); EXPECT_TRUE(send_channel_->SetSenderParameters(parameters)); @@ -5712,7 +5713,7 @@ TEST_F(WebRtcVideoChannelTest, TestSetDscpOptions) { RtpParameters parameters; send_channel = engine_.CreateSendChannel( - call_.get(), config, VideoOptions(), CryptoOptions(), + env_, call_.get(), config, VideoOptions(), CryptoOptions(), video_bitrate_allocator_factory_.get()); send_channel->SetInterface(network_interface.get()); @@ -5724,7 +5725,7 @@ TEST_F(WebRtcVideoChannelTest, TestSetDscpOptions) { // through rtp parameters. config.enable_dscp = true; send_channel = engine_.CreateSendChannel( - call_.get(), config, VideoOptions(), CryptoOptions(), + env_, call_.get(), config, VideoOptions(), CryptoOptions(), video_bitrate_allocator_factory_.get()); send_channel->SetInterface(network_interface.get()); EXPECT_EQ(DSCP_DEFAULT, network_interface->dscp()); @@ -5755,7 +5756,7 @@ TEST_F(WebRtcVideoChannelTest, TestSetDscpOptions) { // DiffServCodePoint. config.enable_dscp = false; send_channel = engine_.CreateSendChannel( - call_.get(), config, VideoOptions(), CryptoOptions(), + env_, call_.get(), config, VideoOptions(), CryptoOptions(), video_bitrate_allocator_factory_.get()); send_channel->SetInterface(network_interface.get()); EXPECT_EQ(DSCP_DEFAULT, network_interface->dscp()); @@ -9684,8 +9685,8 @@ TEST_F(WebRtcVideoChannelTest, GenerateKeyFrameSimulcast) { class WebRtcVideoChannelSimulcastTest : public ::testing::Test { public: WebRtcVideoChannelSimulcastTest() - : field_trials_(CreateTestFieldTrials()), - fake_call_(CreateEnvironment(&field_trials_)), + : env_(CreateTestEnvironment()), + fake_call_(env_), encoder_factory_(new FakeWebRtcVideoEncoderFactory), decoder_factory_(new FakeWebRtcVideoDecoderFactory), mock_rate_allocator_factory_( @@ -9693,17 +9694,17 @@ class WebRtcVideoChannelSimulcastTest : public ::testing::Test { engine_( std::unique_ptr<FakeWebRtcVideoEncoderFactory>(encoder_factory_), std::unique_ptr<FakeWebRtcVideoDecoderFactory>(decoder_factory_), - field_trials_), + env_.field_trials()), last_ssrc_(0) {} void SetUp() override { encoder_factory_->AddSupportedVideoCodecType("VP8"); decoder_factory_->AddSupportedVideoCodecType("VP8"); send_channel_ = engine_.CreateSendChannel( - &fake_call_, GetMediaConfig(), VideoOptions(), CryptoOptions(), + env_, &fake_call_, GetMediaConfig(), VideoOptions(), CryptoOptions(), mock_rate_allocator_factory_.get()); receive_channel_ = engine_.CreateReceiveChannel( - &fake_call_, GetMediaConfig(), VideoOptions(), CryptoOptions()); + env_, &fake_call_, GetMediaConfig(), VideoOptions(), CryptoOptions()); send_channel_->OnReadyToSend(true); receive_channel_->SetReceive(true); last_ssrc_ = 123; @@ -9760,7 +9761,7 @@ class WebRtcVideoChannelSimulcastTest : public ::testing::Test { VideoEncoder::EncoderInfo encoder_info; auto factory = make_ref_counted<EncoderStreamFactory>(encoder_info); expected_streams = factory->CreateEncoderStreams( - field_trials_, capture_width, capture_height, encoder_config); + env_.field_trials(), capture_width, capture_height, encoder_config); if (screenshare && conference_mode) { for (const VideoStream& expected_stream : expected_streams) { // Never scale screen content. @@ -9849,7 +9850,7 @@ class WebRtcVideoChannelSimulcastTest : public ::testing::Test { return streams[streams.size() - 1]; } - FieldTrials field_trials_; + Environment env_; FakeCall fake_call_; FakeWebRtcVideoEncoderFactory* encoder_factory_; FakeWebRtcVideoDecoderFactory* decoder_factory_; diff --git a/third_party/libwebrtc/moz-patch-stack/s0027.patch b/third_party/libwebrtc/moz-patch-stack/s0027.patch @@ -549,7 +549,7 @@ index 88890be798..c9aefc297b 100644 #include "rtc_base/memory/aligned_malloc.h" diff --git a/media/BUILD.gn b/media/BUILD.gn -index e2ac486036..f1da17d4fc 100644 +index 0221c2b573..0f58959926 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -77,7 +77,7 @@ rtc_library("rtc_media_base") { @@ -584,7 +584,7 @@ index e2ac486036..f1da17d4fc 100644 } rtc_library("video_adapter") { -@@ -262,9 +271,16 @@ rtc_library("media_engine") { +@@ -263,9 +272,16 @@ rtc_library("media_engine") { "../rtc_base/system:file_wrapper", "//third_party/abseil-cpp/absl/algorithm:container", ] @@ -601,7 +601,7 @@ index e2ac486036..f1da17d4fc 100644 sources = [ "base/media_channel_impl.cc", "base/media_channel_impl.h", -@@ -312,6 +328,7 @@ rtc_library("media_channel_impl") { +@@ -313,6 +329,7 @@ rtc_library("media_channel_impl") { "//third_party/abseil-cpp/absl/strings:string_view", ] } @@ -609,7 +609,7 @@ index e2ac486036..f1da17d4fc 100644 rtc_source_set("media_channel") { sources = [ "base/media_channel.h" ] -@@ -411,6 +428,7 @@ rtc_library("codec_list") { +@@ -412,6 +429,7 @@ rtc_library("codec_list") { } rtc_library("rtp_utils") { @@ -617,7 +617,7 @@ index e2ac486036..f1da17d4fc 100644 sources = [ "base/rtp_utils.cc", "base/rtp_utils.h", -@@ -427,8 +445,10 @@ rtc_library("rtp_utils") { +@@ -428,8 +446,10 @@ rtc_library("rtp_utils") { "//third_party/abseil-cpp/absl/strings:string_view", ] } @@ -628,7 +628,7 @@ index e2ac486036..f1da17d4fc 100644 sources = [ "base/stream_params.cc", "base/stream_params.h", -@@ -442,6 +462,7 @@ rtc_library("stream_params") { +@@ -443,6 +463,7 @@ rtc_library("stream_params") { "//third_party/abseil-cpp/absl/algorithm:container", ] } @@ -636,7 +636,7 @@ index e2ac486036..f1da17d4fc 100644 rtc_library("media_constants") { sources = [ -@@ -452,6 +473,7 @@ rtc_library("media_constants") { +@@ -453,6 +474,7 @@ rtc_library("media_constants") { } rtc_library("turn_utils") { @@ -644,7 +644,7 @@ index e2ac486036..f1da17d4fc 100644 sources = [ "base/turn_utils.cc", "base/turn_utils.h", -@@ -462,14 +484,17 @@ rtc_library("turn_utils") { +@@ -463,14 +485,17 @@ rtc_library("turn_utils") { "../rtc_base/system:rtc_export", ] } @@ -662,7 +662,7 @@ index e2ac486036..f1da17d4fc 100644 rtc_library("rtc_simulcast_encoder_adapter") { visibility = [ "*" ] -@@ -550,6 +575,11 @@ rtc_library("rtc_internal_video_codecs") { +@@ -551,6 +576,11 @@ rtc_library("rtc_internal_video_codecs") { "//third_party/abseil-cpp/absl/container:inlined_vector", "//third_party/abseil-cpp/absl/strings", ] @@ -674,7 +674,7 @@ index e2ac486036..f1da17d4fc 100644 if (enable_libaom) { defines += [ "RTC_USE_LIBAOM_AV1_ENCODER" ] -@@ -569,6 +599,13 @@ rtc_library("rtc_internal_video_codecs") { +@@ -570,6 +600,13 @@ rtc_library("rtc_internal_video_codecs") { "engine/internal_encoder_factory.cc", "engine/internal_encoder_factory.h", ] diff --git a/third_party/libwebrtc/moz-patch-stack/s0087.patch b/third_party/libwebrtc/moz-patch-stack/s0087.patch @@ -9,7 +9,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/60304c5d8a86fdecf 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/media/BUILD.gn b/media/BUILD.gn -index f1da17d4fc..53d8f777c7 100644 +index 0f58959926..6dcbc2bb33 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -56,6 +56,11 @@ rtc_library("rtc_media_base") { diff --git a/third_party/libwebrtc/moz-patch-stack/s0100.patch b/third_party/libwebrtc/moz-patch-stack/s0100.patch @@ -26,7 +26,7 @@ index 26080d9abc..4df8681a9b 100644 # These are the targets to skip header checking by default. The files in targets # matching these patterns (see "gn help label_pattern" for format) will not have diff --git a/media/BUILD.gn b/media/BUILD.gn -index 53d8f777c7..33d14980ea 100644 +index 6dcbc2bb33..6896edbc34 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -7,7 +7,7 @@ diff --git a/third_party/libwebrtc/moz-patch-stack/s0102.patch b/third_party/libwebrtc/moz-patch-stack/s0102.patch @@ -427,7 +427,7 @@ index 401dca948a..cadd4bab1b 100644 group("logging") { diff --git a/media/BUILD.gn b/media/BUILD.gn -index 33d14980ea..12c65b29f3 100644 +index 6896edbc34..ecbb7eae7e 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -6,7 +6,7 @@ @@ -601,7 +601,7 @@ index b7561e53b6..fe7eb57423 100644 import("../../webrtc.gni") diff --git a/pc/BUILD.gn b/pc/BUILD.gn -index 94314bbb3d..bfdf444763 100644 +index 7ed0ded7e6..d9750bebeb 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -30,8 +30,8 @@ diff --git a/third_party/libwebrtc/moz-patch-stack/s0107.patch b/third_party/libwebrtc/moz-patch-stack/s0107.patch @@ -38,7 +38,7 @@ index 6bfae033a3..2a6c14f35b 100644 ] # Added when we removed deps in other places to avoid building diff --git a/media/BUILD.gn b/media/BUILD.gn -index 12c65b29f3..22057def53 100644 +index ecbb7eae7e..a13fe19324 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -12,12 +12,10 @@ import("../webrtc.gni") @@ -58,7 +58,7 @@ index 12c65b29f3..22057def53 100644 } config("rtc_media_defines_config") { -@@ -281,6 +279,9 @@ rtc_library("media_engine") { +@@ -282,6 +280,9 @@ rtc_library("media_engine") { "base/media_engine.cc", "base/media_engine.h", ] @@ -68,7 +68,7 @@ index 12c65b29f3..22057def53 100644 } } -@@ -432,6 +433,7 @@ rtc_library("codec_list") { +@@ -433,6 +434,7 @@ rtc_library("codec_list") { ] } @@ -76,7 +76,7 @@ index 12c65b29f3..22057def53 100644 rtc_library("rtp_utils") { if (!build_with_mozilla) { sources = [ -@@ -478,7 +480,6 @@ rtc_library("media_constants") { +@@ -479,7 +481,6 @@ rtc_library("media_constants") { } rtc_library("turn_utils") { @@ -84,7 +84,7 @@ index 12c65b29f3..22057def53 100644 sources = [ "base/turn_utils.cc", "base/turn_utils.h", -@@ -489,17 +490,14 @@ if (!build_with_mozilla) { +@@ -490,17 +491,14 @@ if (!build_with_mozilla) { "../rtc_base/system:rtc_export", ] } @@ -102,7 +102,7 @@ index 12c65b29f3..22057def53 100644 rtc_library("rtc_simulcast_encoder_adapter") { visibility = [ "*" ] -@@ -718,6 +716,12 @@ rtc_library("rtc_audio_video") { +@@ -719,6 +717,12 @@ rtc_library("rtc_audio_video") { "engine/webrtc_voice_engine.cc", "engine/webrtc_voice_engine.h", ] diff --git a/third_party/libwebrtc/moz-patch-stack/s0109.patch b/third_party/libwebrtc/moz-patch-stack/s0109.patch @@ -10,7 +10,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/b6dd815fc9d2df718 1 file changed, 11 deletions(-) diff --git a/media/BUILD.gn b/media/BUILD.gn -index 22057def53..f970d910d3 100644 +index a13fe19324..b709209b06 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -54,11 +54,6 @@ rtc_library("rtc_media_base") { diff --git a/third_party/libwebrtc/pc/BUILD.gn b/third_party/libwebrtc/pc/BUILD.gn @@ -1663,6 +1663,7 @@ rtc_library("rtp_transceiver") { "../api:sequence_checker", "../api/audio_codecs:audio_codecs_api", "../api/crypto:options", + "../api/environment", "../api/task_queue", "../api/task_queue:pending_task_safety_flag", "../api/video:video_bitrate_allocator_factory", @@ -2620,6 +2621,7 @@ if (rtc_include_tests && !build_with_chromium) { "../system_wrappers", "../system_wrappers:metrics", "../test:audio_codec_mocks", + "../test:create_test_environment", "../test:create_test_field_trials", "../test:rtc_expect_death", "../test:run_loop", diff --git a/third_party/libwebrtc/pc/peer_connection.cc b/third_party/libwebrtc/pc/peer_connection.cc @@ -579,12 +579,12 @@ PeerConnection::PeerConnection( rtp_manager_->transceivers()->Add( RtpTransceiverProxyWithInternal<RtpTransceiver>::Create( signaling_thread(), make_ref_counted<RtpTransceiver>( - webrtc::MediaType::AUDIO, context_.get(), + env_, MediaType::AUDIO, context_.get(), codec_lookup_helper_.get()))); rtp_manager_->transceivers()->Add( RtpTransceiverProxyWithInternal<RtpTransceiver>::Create( signaling_thread(), make_ref_counted<RtpTransceiver>( - webrtc::MediaType::VIDEO, context_.get(), + env_, MediaType::VIDEO, context_.get(), codec_lookup_helper_.get()))); } diff --git a/third_party/libwebrtc/pc/rtp_sender_receiver_unittest.cc b/third_party/libwebrtc/pc/rtp_sender_receiver_unittest.cc @@ -117,13 +117,13 @@ class RtpSenderReceiverTest &fake_call_, MediaConfig(), AudioOptions(), CryptoOptions(), AudioCodecPairId::Create()); video_media_send_channel_ = media_engine_->video().CreateSendChannel( - &fake_call_, MediaConfig(), VideoOptions(), CryptoOptions(), + env_, &fake_call_, MediaConfig(), VideoOptions(), CryptoOptions(), video_bitrate_allocator_factory_.get()); voice_media_receive_channel_ = media_engine_->voice().CreateReceiveChannel( &fake_call_, MediaConfig(), AudioOptions(), CryptoOptions(), AudioCodecPairId::Create()); video_media_receive_channel_ = media_engine_->video().CreateReceiveChannel( - &fake_call_, MediaConfig(), VideoOptions(), CryptoOptions()); + env_, &fake_call_, MediaConfig(), VideoOptions(), CryptoOptions()); // Create streams for predefined SSRCs. Streams need to exist in order // for the senders and receievers to apply parameters to them. diff --git a/third_party/libwebrtc/pc/rtp_transceiver.cc b/third_party/libwebrtc/pc/rtp_transceiver.cc @@ -27,6 +27,7 @@ #include "api/audio_codecs/audio_codec_pair_id.h" #include "api/audio_options.h" #include "api/crypto/crypto_options.h" +#include "api/environment/environment.h" #include "api/jsep.h" #include "api/media_types.h" #include "api/rtc_error.h" @@ -113,10 +114,12 @@ TaskQueueBase* GetCurrentTaskQueueOrThread() { } // namespace -RtpTransceiver::RtpTransceiver(MediaType media_type, +RtpTransceiver::RtpTransceiver(const Environment& env, + MediaType media_type, ConnectionContext* context, CodecLookupHelper* codec_lookup_helper) - : thread_(GetCurrentTaskQueueOrThread()), + : env_(env), + thread_(GetCurrentTaskQueueOrThread()), unified_plan_(false), media_type_(media_type), context_(context), @@ -127,13 +130,15 @@ RtpTransceiver::RtpTransceiver(MediaType media_type, } RtpTransceiver::RtpTransceiver( + const Environment& env, scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> sender, scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>> receiver, ConnectionContext* context, CodecLookupHelper* codec_lookup_helper, std::vector<RtpHeaderExtensionCapability> header_extensions_to_negotiate, std::function<void()> on_negotiation_needed) - : thread_(GetCurrentTaskQueueOrThread()), + : env_(env), + thread_(GetCurrentTaskQueueOrThread()), unified_plan_(true), media_type_(sender->media_type()), context_(context), @@ -260,11 +265,11 @@ RTCError RtpTransceiver::CreateChannel( std::unique_ptr<VideoMediaSendChannelInterface> media_send_channel = media_engine()->video().CreateSendChannel( - call_ptr, media_config, video_options, crypto_options, + env_, call_ptr, media_config, video_options, crypto_options, video_bitrate_allocator_factory); std::unique_ptr<VideoMediaReceiveChannelInterface> media_receive_channel = media_engine()->video().CreateReceiveChannel( - call_ptr, media_config, video_options, crypto_options); + env_, call_ptr, media_config, video_options, crypto_options); // Note that this is safe because both sending and // receiving channels will be deleted at the same time. media_send_channel->SetSsrcListChangedCallback( diff --git a/third_party/libwebrtc/pc/rtp_transceiver.h b/third_party/libwebrtc/pc/rtp_transceiver.h @@ -23,6 +23,7 @@ #include "api/array_view.h" #include "api/audio_options.h" #include "api/crypto/crypto_options.h" +#include "api/environment/environment.h" #include "api/jsep.h" #include "api/media_types.h" #include "api/rtc_error.h" @@ -88,7 +89,8 @@ class RtpTransceiver : public RtpTransceiverInterface { // channel set. // `media_type` specifies the type of RtpTransceiver (and, by transitivity, // the type of senders, receivers, and channel). Can either by audio or video. - RtpTransceiver(webrtc::MediaType media_type, + RtpTransceiver(const Environment& env, + MediaType media_type, ConnectionContext* context, CodecLookupHelper* codec_lookup_helper); // Construct a Unified Plan-style RtpTransceiver with the given sender and @@ -97,6 +99,7 @@ class RtpTransceiver : public RtpTransceiverInterface { // `HeaderExtensionsToNegotiate` is used for initializing the return value of // HeaderExtensionsToNegotiate(). RtpTransceiver( + const Environment& env, scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> sender, scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>> receiver, ConnectionContext* context, @@ -258,7 +261,7 @@ class RtpTransceiver : public RtpTransceiverInterface { void StopTransceiverProcedure(); // RtpTransceiverInterface implementation. - webrtc::MediaType media_type() const override; + MediaType media_type() const override; std::optional<std::string> mid() const override; scoped_refptr<RtpSenderInterface> sender() const override; scoped_refptr<RtpReceiverInterface> receiver() const override; @@ -317,10 +320,11 @@ class RtpTransceiver : public RtpTransceiverInterface { RTCError UpdateCodecPreferencesCaches( const std::vector<RtpCodecCapability>& codecs); + const Environment env_; // Enforce that this object is created, used and destroyed on one thread. TaskQueueBase* const thread_; const bool unified_plan_; - const webrtc::MediaType media_type_; + const MediaType media_type_; scoped_refptr<PendingTaskSafetyFlag> signaling_thread_safety_; std::vector<scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>> senders_; diff --git a/third_party/libwebrtc/pc/rtp_transceiver_unittest.cc b/third_party/libwebrtc/pc/rtp_transceiver_unittest.cc @@ -19,7 +19,7 @@ #include <vector> #include "absl/strings/string_view.h" -#include "api/environment/environment_factory.h" +#include "api/environment/environment.h" #include "api/jsep.h" #include "api/make_ref_counted.h" #include "api/media_types.h" @@ -48,6 +48,7 @@ #include "pc/test/mock_rtp_receiver_internal.h" #include "pc/test/mock_rtp_sender_internal.h" #include "rtc_base/thread.h" +#include "test/create_test_environment.h" #include "test/gmock.h" #include "test/gtest.h" @@ -70,10 +71,14 @@ class RtpTransceiverTest : public testing::Test { RtpTransceiverTest() : dependencies_(MakeDependencies()), context_( - ConnectionContext::Create(CreateEnvironment(), &dependencies_)), + ConnectionContext::Create(CreateTestEnvironment(), &dependencies_)), codec_lookup_helper_(context_.get()) {} protected: + // For the test purpose reuse environment from the Connection Context. + // Note that in prod code such environment is per PeerConnectionFactory, + // while RtpTransceiver expects PeerConnection specific environment. + const Environment& env() const { return context_->env(); } FakeMediaEngine* media_engine() { // We know this cast is safe because we supplied the fake implementation // in MakeDependencies(). @@ -106,7 +111,7 @@ class RtpTransceiverTest : public testing::Test { TEST_F(RtpTransceiverTest, CannotSetChannelOnStoppedTransceiver) { const std::string content_name("my_mid"); auto transceiver = make_ref_counted<RtpTransceiver>( - MediaType::AUDIO, context(), codec_lookup_helper()); + env(), MediaType::AUDIO, context(), codec_lookup_helper()); auto channel1 = std::make_unique<NiceMock<MockChannelInterface>>(); EXPECT_CALL(*channel1, media_type()).WillRepeatedly(Return(MediaType::AUDIO)); EXPECT_CALL(*channel1, mid()).WillRepeatedly(ReturnRef(content_name)); @@ -140,7 +145,7 @@ TEST_F(RtpTransceiverTest, CannotSetChannelOnStoppedTransceiver) { TEST_F(RtpTransceiverTest, CanUnsetChannelOnStoppedTransceiver) { const std::string content_name("my_mid"); auto transceiver = make_ref_counted<RtpTransceiver>( - MediaType::VIDEO, context(), codec_lookup_helper()); + env(), MediaType::VIDEO, context(), codec_lookup_helper()); auto channel = std::make_unique<NiceMock<MockChannelInterface>>(); EXPECT_CALL(*channel, media_type()).WillRepeatedly(Return(MediaType::VIDEO)); EXPECT_CALL(*channel, mid()).WillRepeatedly(ReturnRef(content_name)); @@ -184,6 +189,7 @@ class RtpTransceiverUnifiedPlanTest : public RtpTransceiverTest { scoped_refptr<RtpSenderInternal> sender, scoped_refptr<RtpReceiverInternal> receiver) { return make_ref_counted<RtpTransceiver>( + env(), RtpSenderProxyWithInternal<RtpSenderInternal>::Create( Thread::Current(), std::move(sender)), RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create( @@ -572,6 +578,7 @@ class RtpTransceiverTestForHeaderExtensions 4, RtpTransceiverDirection::kSendRecv)}), transceiver_(make_ref_counted<RtpTransceiver>( + env(), RtpSenderProxyWithInternal<RtpSenderInternal>::Create( Thread::Current(), sender_), @@ -589,6 +596,7 @@ class RtpTransceiverTestForHeaderExtensions transceiver_->ClearChannel(); } + protected: scoped_refptr<MockRtpReceiverInternal> receiver_ = MockReceiver(MediaType::AUDIO); scoped_refptr<MockRtpSenderInternal> sender_ = MockSender(MediaType::AUDIO); @@ -847,6 +855,7 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, // Default is stopped. auto sender = make_ref_counted<NiceMock<MockRtpSenderInternal>>(); auto transceiver = make_ref_counted<RtpTransceiver>( + env(), RtpSenderProxyWithInternal<RtpSenderInternal>::Create(Thread::Current(), sender), RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create( @@ -868,6 +877,7 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, EXPECT_CALL(*simulcast_sender, GetParametersInternal()) .WillRepeatedly(Return(simulcast_parameters)); auto simulcast_transceiver = make_ref_counted<RtpTransceiver>( + env(), RtpSenderProxyWithInternal<RtpSenderInternal>::Create(Thread::Current(), simulcast_sender), RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create( @@ -895,6 +905,7 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, EXPECT_CALL(*svc_sender, GetParametersInternal()) .WillRepeatedly(Return(svc_parameters)); auto svc_transceiver = make_ref_counted<RtpTransceiver>( + env(), RtpSenderProxyWithInternal<RtpSenderInternal>::Create(Thread::Current(), svc_sender), RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create( diff --git a/third_party/libwebrtc/pc/rtp_transmission_manager.cc b/third_party/libwebrtc/pc/rtp_transmission_manager.cc @@ -325,7 +325,7 @@ RtpTransmissionManager::CreateAndAddTransceiver( auto transceiver = RtpTransceiverProxyWithInternal<RtpTransceiver>::Create( signaling_thread(), make_ref_counted<RtpTransceiver>( - sender, receiver, context_, codec_lookup_helper_, + env_, sender, receiver, context_, codec_lookup_helper_, sender->media_type() == MediaType::AUDIO ? media_engine()->voice().GetRtpHeaderExtensions() : media_engine()->video().GetRtpHeaderExtensions(), diff --git a/third_party/libwebrtc/pc/test/fake_peer_connection_for_stats.h b/third_party/libwebrtc/pc/test/fake_peer_connection_for_stats.h @@ -533,7 +533,7 @@ class FakePeerConnectionForStats : public FakePeerConnectionBase { } scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> - GetOrCreateFirstTransceiverOfType(webrtc::MediaType media_type) { + GetOrCreateFirstTransceiverOfType(MediaType media_type) { for (auto transceiver : transceivers_) { if (transceiver->internal()->media_type() == media_type) { return transceiver; @@ -543,11 +543,11 @@ class FakePeerConnectionForStats : public FakePeerConnectionBase { } scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> - CreateTransceiverOfType(webrtc::MediaType media_type) { + CreateTransceiverOfType(MediaType media_type) { auto transceiver = RtpTransceiverProxyWithInternal<RtpTransceiver>::Create( - signaling_thread_, - make_ref_counted<RtpTransceiver>(media_type, context_.get(), - &codec_lookup_helper_)); + signaling_thread_, make_ref_counted<RtpTransceiver>( + context_->env(), media_type, context_.get(), + &codec_lookup_helper_)); transceivers_.push_back(transceiver); return transceiver; }