summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/pc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /third_party/libwebrtc/pc
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/pc')
-rw-r--r--third_party/libwebrtc/pc/BUILD.gn50
-rw-r--r--third_party/libwebrtc/pc/audio_rtp_receiver.cc2
-rw-r--r--third_party/libwebrtc/pc/audio_rtp_receiver.h3
-rw-r--r--third_party/libwebrtc/pc/audio_rtp_receiver_unittest.cc2
-rw-r--r--third_party/libwebrtc/pc/audio_track.h2
-rw-r--r--third_party/libwebrtc/pc/channel.cc30
-rw-r--r--third_party/libwebrtc/pc/channel_unittest.cc28
-rw-r--r--third_party/libwebrtc/pc/connection_context.cc21
-rw-r--r--third_party/libwebrtc/pc/connection_context.h21
-rw-r--r--third_party/libwebrtc/pc/data_channel_controller_unittest.cc2
-rw-r--r--third_party/libwebrtc/pc/data_channel_integrationtest.cc10
-rw-r--r--third_party/libwebrtc/pc/data_channel_unittest.cc17
-rw-r--r--third_party/libwebrtc/pc/dtls_srtp_transport.h9
-rw-r--r--third_party/libwebrtc/pc/ice_server_parsing_unittest.cc7
-rw-r--r--third_party/libwebrtc/pc/ice_transport_unittest.cc2
-rw-r--r--third_party/libwebrtc/pc/jsep_transport_controller.cc228
-rw-r--r--third_party/libwebrtc/pc/jsep_transport_controller.h52
-rw-r--r--third_party/libwebrtc/pc/jsep_transport_controller_unittest.cc591
-rw-r--r--third_party/libwebrtc/pc/legacy_stats_collector.cc12
-rw-r--r--third_party/libwebrtc/pc/legacy_stats_collector.h6
-rw-r--r--third_party/libwebrtc/pc/media_factory.h45
-rw-r--r--third_party/libwebrtc/pc/media_session.cc865
-rw-r--r--third_party/libwebrtc/pc/media_session.h43
-rw-r--r--third_party/libwebrtc/pc/media_session_unittest.cc852
-rw-r--r--third_party/libwebrtc/pc/media_stream_unittest.cc10
-rw-r--r--third_party/libwebrtc/pc/peer_connection.cc94
-rw-r--r--third_party/libwebrtc/pc/peer_connection.h29
-rw-r--r--third_party/libwebrtc/pc/peer_connection_crypto_unittest.cc2
-rw-r--r--third_party/libwebrtc/pc/peer_connection_data_channel_unittest.cc7
-rw-r--r--third_party/libwebrtc/pc/peer_connection_encodings_integrationtest.cc214
-rw-r--r--third_party/libwebrtc/pc/peer_connection_factory.cc76
-rw-r--r--third_party/libwebrtc/pc/peer_connection_factory.h9
-rw-r--r--third_party/libwebrtc/pc/peer_connection_factory_proxy.h4
-rw-r--r--third_party/libwebrtc/pc/peer_connection_factory_unittest.cc218
-rw-r--r--third_party/libwebrtc/pc/peer_connection_field_trial_tests.cc23
-rw-r--r--third_party/libwebrtc/pc/peer_connection_header_extension_unittest.cc17
-rw-r--r--third_party/libwebrtc/pc/peer_connection_histogram_unittest.cc128
-rw-r--r--third_party/libwebrtc/pc/peer_connection_ice_unittest.cc6
-rw-r--r--third_party/libwebrtc/pc/peer_connection_integrationtest.cc376
-rw-r--r--third_party/libwebrtc/pc/peer_connection_interface_unittest.cc235
-rw-r--r--third_party/libwebrtc/pc/peer_connection_jsep_unittest.cc12
-rw-r--r--third_party/libwebrtc/pc/peer_connection_media_unittest.cc71
-rw-r--r--third_party/libwebrtc/pc/peer_connection_rampup_tests.cc2
-rw-r--r--third_party/libwebrtc/pc/peer_connection_rtp_unittest.cc14
-rw-r--r--third_party/libwebrtc/pc/peer_connection_signaling_unittest.cc32
-rw-r--r--third_party/libwebrtc/pc/peer_connection_simulcast_unittest.cc2
-rw-r--r--third_party/libwebrtc/pc/peer_connection_svc_integrationtest.cc77
-rw-r--r--third_party/libwebrtc/pc/peer_connection_wrapper.cc3
-rw-r--r--third_party/libwebrtc/pc/rtc_stats_collector.cc4
-rw-r--r--third_party/libwebrtc/pc/rtc_stats_collector.h2
-rw-r--r--third_party/libwebrtc/pc/rtc_stats_collector_unittest.cc25
-rw-r--r--third_party/libwebrtc/pc/rtc_stats_traversal_unittest.cc2
-rw-r--r--third_party/libwebrtc/pc/rtp_sender.cc16
-rw-r--r--third_party/libwebrtc/pc/rtp_sender.h4
-rw-r--r--third_party/libwebrtc/pc/rtp_sender_receiver_unittest.cc80
-rw-r--r--third_party/libwebrtc/pc/rtp_transceiver.cc6
-rw-r--r--third_party/libwebrtc/pc/rtp_transceiver.h10
-rw-r--r--third_party/libwebrtc/pc/rtp_transceiver_unittest.cc19
-rw-r--r--third_party/libwebrtc/pc/rtp_transport.cc19
-rw-r--r--third_party/libwebrtc/pc/rtp_transport.h2
-rw-r--r--third_party/libwebrtc/pc/rtp_transport_internal.h4
-rw-r--r--third_party/libwebrtc/pc/rtp_transport_unittest.cc24
-rw-r--r--third_party/libwebrtc/pc/sctp_transport.h2
-rw-r--r--third_party/libwebrtc/pc/sctp_utils.cc2
-rw-r--r--third_party/libwebrtc/pc/sctp_utils_unittest.cc4
-rw-r--r--third_party/libwebrtc/pc/sdp_offer_answer.cc105
-rw-r--r--third_party/libwebrtc/pc/sdp_offer_answer.h4
-rw-r--r--third_party/libwebrtc/pc/sdp_offer_answer_unittest.cc23
-rw-r--r--third_party/libwebrtc/pc/slow_peer_connection_integration_test.cc18
-rw-r--r--third_party/libwebrtc/pc/srtp_session.cc6
-rw-r--r--third_party/libwebrtc/pc/srtp_session.h8
-rw-r--r--third_party/libwebrtc/pc/srtp_session_unittest.cc32
-rw-r--r--third_party/libwebrtc/pc/srtp_transport.cc95
-rw-r--r--third_party/libwebrtc/pc/srtp_transport.h7
-rw-r--r--third_party/libwebrtc/pc/srtp_transport_unittest.cc64
-rw-r--r--third_party/libwebrtc/pc/test/android_test_initializer.cc2
-rw-r--r--third_party/libwebrtc/pc/test/enable_fake_media.cc63
-rw-r--r--third_party/libwebrtc/pc/test/enable_fake_media.h38
-rw-r--r--third_party/libwebrtc/pc/test/fake_peer_connection_base.h2
-rw-r--r--third_party/libwebrtc/pc/test/fake_peer_connection_for_stats.h16
-rw-r--r--third_party/libwebrtc/pc/test/fake_periodic_video_source.h4
-rw-r--r--third_party/libwebrtc/pc/test/integration_test_helpers.cc2
-rw-r--r--third_party/libwebrtc/pc/test/integration_test_helpers.h290
-rw-r--r--third_party/libwebrtc/pc/test/mock_peer_connection_observers.h19
-rw-r--r--third_party/libwebrtc/pc/test/rtp_transport_test_util.h17
-rw-r--r--third_party/libwebrtc/pc/test/svc_e2e_tests.cc42
-rw-r--r--third_party/libwebrtc/pc/video_rtp_receiver_unittest.cc2
-rw-r--r--third_party/libwebrtc/pc/video_rtp_track_source_unittest.cc4
-rw-r--r--third_party/libwebrtc/pc/video_track.h2
-rw-r--r--third_party/libwebrtc/pc/video_track_source_proxy.h2
-rw-r--r--third_party/libwebrtc/pc/webrtc_sdp.cc8
-rw-r--r--third_party/libwebrtc/pc/webrtc_sdp_unittest.cc21
92 files changed, 2813 insertions, 2869 deletions
diff --git a/third_party/libwebrtc/pc/BUILD.gn b/third_party/libwebrtc/pc/BUILD.gn
index 7c22a26d12..e9549cdfd8 100644
--- a/third_party/libwebrtc/pc/BUILD.gn
+++ b/third_party/libwebrtc/pc/BUILD.gn
@@ -314,6 +314,15 @@ rtc_source_set("jsep_transport_controller") {
]
}
+rtc_source_set("media_factory") {
+ sources = [ "media_factory.h" ]
+ deps = [
+ "../api/environment",
+ "../call:call_interfaces",
+ "../media:rtc_media_base",
+ ]
+}
+
rtc_source_set("media_session") {
visibility = [ "*" ] # Used by Chrome
sources = [
@@ -730,6 +739,7 @@ rtc_library("media_protocol_names") {
rtc_source_set("peerconnection") {
# TODO(bugs.webrtc.org/13661): Reduce visibility if possible
visibility = [ "*" ] # Used by Chromium and others
+ allow_poison = [ "environment_construction" ]
cflags = []
sources = []
@@ -919,6 +929,7 @@ rtc_library("connection_context") {
"connection_context.h",
]
deps = [
+ ":media_factory",
"../api:callfactory_api",
"../api:field_trials_view",
"../api:libjingle_peerconnection_api",
@@ -926,6 +937,7 @@ rtc_library("connection_context") {
"../api:refcountedbase",
"../api:scoped_refptr",
"../api:sequence_checker",
+ "../api/environment",
"../api/neteq:neteq_api",
"../api/transport:field_trial_based_config",
"../api/transport:sctp_transport_factory_interface",
@@ -1223,6 +1235,7 @@ rtc_source_set("peer_connection") {
"../api:turn_customizer",
"../api/adaptation:resource_adaptation_api",
"../api/crypto:options",
+ "../api/environment",
"../api/rtc_event_log",
"../api/task_queue:pending_task_safety_flag",
"../api/transport:bitrate_settings",
@@ -1486,6 +1499,7 @@ rtc_library("media_stream_observer") {
rtc_source_set("peer_connection_factory") {
# TODO(bugs.webrtc.org/13661): Reduce visibility if possible
visibility = [ "*" ] # Known to be used externally
+ allow_poison = [ "environment_construction" ]
sources = [
"peer_connection_factory.cc",
"peer_connection_factory.h",
@@ -1510,10 +1524,11 @@ rtc_source_set("peer_connection_factory") {
"../api:rtp_parameters",
"../api:scoped_refptr",
"../api:sequence_checker",
+ "../api/environment",
+ "../api/environment:environment_factory",
"../api/metronome",
"../api/neteq:neteq_api",
"../api/rtc_event_log:rtc_event_log",
- "../api/task_queue:task_queue",
"../api/transport:bitrate_settings",
"../api/transport:network_control",
"../api/transport:sctp_transport_factory_interface",
@@ -1525,6 +1540,7 @@ rtc_source_set("peer_connection_factory") {
"../p2p:rtc_p2p",
"../pc:audio_track",
"../pc:connection_context",
+ "../pc:media_factory",
"../pc:media_stream",
"../pc:rtp_parameters_conversion",
"../pc:session_description",
@@ -2051,6 +2067,7 @@ rtc_source_set("legacy_stats_collector_interface") {
rtc_source_set("libjingle_peerconnection") {
# TODO(bugs.webrtc.org/13661): Reduce visibility if possible
visibility = [ "*" ] # Used by Chrome and others
+ allow_poison = [ "environment_construction" ]
deps = [
":peerconnection",
@@ -2362,6 +2379,7 @@ if (rtc_include_tests && !build_with_chromium) {
":dtls_srtp_transport",
":dtls_transport",
":dtmf_sender",
+ ":enable_fake_media",
":ice_server_parsing",
":integration_test_helpers",
":jitter_buffer_delay",
@@ -2401,10 +2419,13 @@ if (rtc_include_tests && !build_with_chromium) {
":webrtc_sdp",
"../api:array_view",
"../api:audio_options_api",
+ "../api:callfactory_api",
"../api:candidate",
"../api:create_peerconnection_factory",
"../api:dtls_transport_interface",
"../api:dtmf_sender_interface",
+ "../api:enable_media",
+ "../api:enable_media_with_defaults",
"../api:fake_frame_decryptor",
"../api:fake_frame_encryptor",
"../api:field_trials_view",
@@ -2429,6 +2450,7 @@ if (rtc_include_tests && !build_with_chromium) {
"../api/crypto:frame_decryptor_interface",
"../api/crypto:frame_encryptor_interface",
"../api/crypto:options",
+ "../api/environment:environment_factory",
"../api/rtc_event_log",
"../api/rtc_event_log:rtc_event_log_factory",
"../api/task_queue",
@@ -2457,7 +2479,6 @@ if (rtc_include_tests && !build_with_chromium) {
"../media:rid_description",
"../media:rtc_data_sctp_transport_internal",
"../media:rtc_media_config",
- "../media:rtc_media_engine_defaults",
"../media:stream_params",
"../modules/audio_device:audio_device_api",
"../modules/audio_processing:audio_processing_statistics",
@@ -2520,7 +2541,6 @@ if (rtc_include_tests && !build_with_chromium) {
":libjingle_peerconnection",
":pc_test_utils",
":rtc_pc",
- "../api:callfactory_api",
"../api:rtc_event_log_output_file",
"../api:rtc_stats_api",
"../api:rtp_parameters",
@@ -2627,9 +2647,9 @@ if (rtc_include_tests && !build_with_chromium) {
":video_track_source",
"../api:array_view",
"../api:audio_options_api",
- "../api:callfactory_api",
"../api:candidate",
"../api:create_peerconnection_factory",
+ "../api:enable_media_with_defaults",
"../api:fake_frame_decryptor",
"../api:fake_frame_encryptor",
"../api:field_trials_view",
@@ -2665,10 +2685,8 @@ if (rtc_include_tests && !build_with_chromium) {
"../call:call_interfaces",
"../call/adaptation:resource_adaptation_test_utilities",
"../logging:fake_rtc_event_log",
- "../media:rtc_audio_video",
"../media:rtc_media_base",
"../media:rtc_media_config",
- "../media:rtc_media_engine_defaults",
"../media:rtc_media_tests_utils",
"../media:stream_params",
"../modules/audio_device:audio_device_api",
@@ -2719,6 +2737,24 @@ if (rtc_include_tests && !build_with_chromium) {
]
}
+ rtc_library("enable_fake_media") {
+ testonly = true
+ visibility = [ ":*" ]
+ sources = [
+ "test/enable_fake_media.cc",
+ "test/enable_fake_media.h",
+ ]
+ deps = [
+ ":media_factory",
+ "../api:libjingle_peerconnection_api",
+ "../api/environment",
+ "../call:call_interfaces",
+ "../media:rtc_media_tests_utils",
+ "../rtc_base:checks",
+ ]
+ absl_deps = [ "//third_party/abseil-cpp/absl/base:nullability" ]
+ }
+
rtc_library("pc_test_utils") {
testonly = true
sources = [
@@ -2751,6 +2787,7 @@ if (rtc_include_tests && !build_with_chromium) {
deps = [
":channel",
":channel_interface",
+ ":enable_fake_media",
":jitter_buffer_delay",
":libjingle_peerconnection",
":peer_connection_internal",
@@ -2778,6 +2815,7 @@ if (rtc_include_tests && !build_with_chromium) {
"../api:sequence_checker",
"../api/audio:audio_mixer_api",
"../api/audio_codecs:audio_codecs_api",
+ "../api/environment:environment_factory",
"../api/task_queue",
"../api/task_queue:default_task_queue_factory",
"../api/units:time_delta",
diff --git a/third_party/libwebrtc/pc/audio_rtp_receiver.cc b/third_party/libwebrtc/pc/audio_rtp_receiver.cc
index a8659de5f9..6e7ca6d0b5 100644
--- a/third_party/libwebrtc/pc/audio_rtp_receiver.cc
+++ b/third_party/libwebrtc/pc/audio_rtp_receiver.cc
@@ -278,7 +278,7 @@ std::vector<RtpSource> AudioRtpReceiver::GetSources() const {
}
void AudioRtpReceiver::SetDepacketizerToDecoderFrameTransformer(
- rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer) {
+ rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) {
RTC_DCHECK_RUN_ON(worker_thread_);
if (media_channel_) {
media_channel_->SetDepacketizerToDecoderFrameTransformer(
diff --git a/third_party/libwebrtc/pc/audio_rtp_receiver.h b/third_party/libwebrtc/pc/audio_rtp_receiver.h
index 86c42d532a..36cbdffc35 100644
--- a/third_party/libwebrtc/pc/audio_rtp_receiver.h
+++ b/third_party/libwebrtc/pc/audio_rtp_receiver.h
@@ -118,8 +118,7 @@ class AudioRtpReceiver : public ObserverInterface,
std::vector<RtpSource> GetSources() const override;
int AttachmentId() const override { return attachment_id_; }
void SetDepacketizerToDecoderFrameTransformer(
- rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer)
- override;
+ rtc::scoped_refptr<FrameTransformerInterface> frame_transformer) override;
private:
void RestartMediaChannel(absl::optional<uint32_t> ssrc)
diff --git a/third_party/libwebrtc/pc/audio_rtp_receiver_unittest.cc b/third_party/libwebrtc/pc/audio_rtp_receiver_unittest.cc
index 9eb20c982f..e031f90359 100644
--- a/third_party/libwebrtc/pc/audio_rtp_receiver_unittest.cc
+++ b/third_party/libwebrtc/pc/audio_rtp_receiver_unittest.cc
@@ -98,7 +98,7 @@ TEST_F(AudioRtpReceiverTest, VolumesSetBeforeStartingAreRespected) {
// thread when a media channel pointer is passed to the receiver via the
// constructor.
TEST(AudioRtpReceiver, OnChangedNotificationsAfterConstruction) {
- webrtc::test::RunLoop loop;
+ test::RunLoop loop;
auto* thread = rtc::Thread::Current(); // Points to loop's thread.
cricket::MockVoiceMediaReceiveChannelInterface receive_channel;
auto receiver = rtc::make_ref_counted<AudioRtpReceiver>(
diff --git a/third_party/libwebrtc/pc/audio_track.h b/third_party/libwebrtc/pc/audio_track.h
index ae326b304b..92c3141d8a 100644
--- a/third_party/libwebrtc/pc/audio_track.h
+++ b/third_party/libwebrtc/pc/audio_track.h
@@ -58,7 +58,7 @@ class AudioTrack : public MediaStreamTrack<AudioTrackInterface>,
private:
const rtc::scoped_refptr<AudioSourceInterface> audio_source_;
- RTC_NO_UNIQUE_ADDRESS webrtc::SequenceChecker signaling_thread_checker_;
+ RTC_NO_UNIQUE_ADDRESS SequenceChecker signaling_thread_checker_;
};
} // namespace webrtc
diff --git a/third_party/libwebrtc/pc/channel.cc b/third_party/libwebrtc/pc/channel.cc
index 0024ba0e35..7a1f55d9e9 100644
--- a/third_party/libwebrtc/pc/channel.cc
+++ b/third_party/libwebrtc/pc/channel.cc
@@ -79,7 +79,7 @@ struct StreamFinder {
} // namespace
void MediaChannelParametersFromMediaDescription(
- const RtpMediaContentDescription* desc,
+ const MediaContentDescription* desc,
const RtpHeaderExtensions& extensions,
bool is_stream_active,
MediaChannelParameters* params) {
@@ -97,7 +97,7 @@ void MediaChannelParametersFromMediaDescription(
}
void RtpSendParametersFromMediaDescription(
- const RtpMediaContentDescription* desc,
+ const MediaContentDescription* desc,
webrtc::RtpExtension::Filter extensions_filter,
SenderParameters* send_params) {
RtpHeaderExtensions extensions =
@@ -875,7 +875,7 @@ bool VoiceChannel::SetLocalContent_w(const MediaContentDescription* content,
AudioReceiverParameters recv_params = last_recv_params_;
MediaChannelParametersFromMediaDescription(
- content->as_audio(), header_extensions,
+ content, header_extensions,
webrtc::RtpTransceiverDirectionHasRecv(content->direction()),
&recv_params);
@@ -927,8 +927,8 @@ bool VoiceChannel::SetRemoteContent_w(const MediaContentDescription* content,
RTC_LOG(LS_INFO) << "Setting remote voice description for " << ToString();
AudioSenderParameter send_params = last_send_params_;
- RtpSendParametersFromMediaDescription(content->as_audio(),
- extensions_filter(), &send_params);
+ RtpSendParametersFromMediaDescription(content, extensions_filter(),
+ &send_params);
send_params.mid = mid();
bool parameters_applied =
@@ -1016,7 +1016,7 @@ bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content,
VideoReceiverParameters recv_params = last_recv_params_;
MediaChannelParametersFromMediaDescription(
- content->as_video(), header_extensions,
+ content, header_extensions,
webrtc::RtpTransceiverDirectionHasRecv(content->direction()),
&recv_params);
@@ -1100,7 +1100,7 @@ bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content,
last_send_params_ = send_params;
}
- if (!UpdateLocalStreams_w(content->as_video()->streams(), type, error_desc)) {
+ if (!UpdateLocalStreams_w(content->streams(), type, error_desc)) {
RTC_DCHECK(!error_desc.empty());
return false;
}
@@ -1128,13 +1128,11 @@ bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content,
TRACE_EVENT0("webrtc", "VideoChannel::SetRemoteContent_w");
RTC_LOG(LS_INFO) << "Setting remote video description for " << ToString();
- const VideoContentDescription* video = content->as_video();
-
VideoSenderParameters send_params = last_send_params_;
- RtpSendParametersFromMediaDescription(video, extensions_filter(),
+ RtpSendParametersFromMediaDescription(content, extensions_filter(),
&send_params);
send_params.mid = mid();
- send_params.conference_mode = video->conference_mode();
+ send_params.conference_mode = content->conference_mode();
VideoReceiverParameters recv_params = last_recv_params_;
@@ -1145,15 +1143,15 @@ bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content,
// instead.
bool needs_recv_params_update = false;
if (type == SdpType::kAnswer || type == SdpType::kPrAnswer) {
- webrtc::flat_set<const VideoCodec*> matched_codecs;
- for (VideoCodec& recv_codec : recv_params.codecs) {
- if (absl::c_any_of(matched_codecs, [&](const VideoCodec* c) {
+ webrtc::flat_set<const Codec*> matched_codecs;
+ for (Codec& recv_codec : recv_params.codecs) {
+ if (absl::c_any_of(matched_codecs, [&](const Codec* c) {
return recv_codec.Matches(*c);
})) {
continue;
}
- std::vector<const VideoCodec*> send_codecs =
+ std::vector<const Codec*> send_codecs =
FindAllMatchingCodecs(send_params.codecs, recv_codec);
if (send_codecs.empty()) {
continue;
@@ -1161,7 +1159,7 @@ bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content,
bool may_ignore_packetization = false;
bool has_matching_packetization = false;
- for (const VideoCodec* send_codec : send_codecs) {
+ for (const Codec* send_codec : send_codecs) {
if (!send_codec->packetization.has_value() &&
recv_codec.packetization.has_value()) {
may_ignore_packetization = true;
diff --git a/third_party/libwebrtc/pc/channel_unittest.cc b/third_party/libwebrtc/pc/channel_unittest.cc
index c675cd0446..98a61ea673 100644
--- a/third_party/libwebrtc/pc/channel_unittest.cc
+++ b/third_party/libwebrtc/pc/channel_unittest.cc
@@ -2094,12 +2094,12 @@ TEST_F(VideoChannelSingleThreadTest, TestSetLocalOfferWithPacketization) {
EXPECT_TRUE(channel1_->SetLocalContent(&video, SdpType::kOffer, err));
EXPECT_THAT(media_send_channel1_impl()->send_codecs(), testing::IsEmpty());
ASSERT_THAT(media_receive_channel1_impl()->recv_codecs(), testing::SizeIs(2));
- EXPECT_TRUE(media_receive_channel1_impl()->recv_codecs()[0].Matches(
- kVp8Codec, &field_trials_));
+ EXPECT_TRUE(
+ media_receive_channel1_impl()->recv_codecs()[0].Matches(kVp8Codec));
EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[0].packetization,
absl::nullopt);
- EXPECT_TRUE(media_receive_channel1_impl()->recv_codecs()[1].Matches(
- vp9_codec, &field_trials_));
+ EXPECT_TRUE(
+ media_receive_channel1_impl()->recv_codecs()[1].Matches(vp9_codec));
EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[1].packetization,
cricket::kPacketizationParamRaw);
}
@@ -2118,12 +2118,10 @@ TEST_F(VideoChannelSingleThreadTest, TestSetRemoteOfferWithPacketization) {
EXPECT_TRUE(err.empty());
EXPECT_THAT(media_receive_channel1_impl()->recv_codecs(), testing::IsEmpty());
ASSERT_THAT(media_send_channel1_impl()->send_codecs(), testing::SizeIs(2));
- EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[0].Matches(
- kVp8Codec, &field_trials_));
+ EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[0].Matches(kVp8Codec));
EXPECT_EQ(media_send_channel1_impl()->send_codecs()[0].packetization,
absl::nullopt);
- EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[1].Matches(
- vp9_codec, &field_trials_));
+ EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[1].Matches(vp9_codec));
EXPECT_EQ(media_send_channel1_impl()->send_codecs()[1].packetization,
cricket::kPacketizationParamRaw);
}
@@ -2143,21 +2141,19 @@ TEST_F(VideoChannelSingleThreadTest, TestSetAnswerWithPacketization) {
EXPECT_TRUE(channel1_->SetRemoteContent(&video, SdpType::kAnswer, err));
EXPECT_TRUE(err.empty());
ASSERT_THAT(media_receive_channel1_impl()->recv_codecs(), testing::SizeIs(2));
- EXPECT_TRUE(media_receive_channel1_impl()->recv_codecs()[0].Matches(
- kVp8Codec, &field_trials_));
+ EXPECT_TRUE(
+ media_receive_channel1_impl()->recv_codecs()[0].Matches(kVp8Codec));
EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[0].packetization,
absl::nullopt);
- EXPECT_TRUE(media_receive_channel1_impl()->recv_codecs()[1].Matches(
- vp9_codec, &field_trials_));
+ EXPECT_TRUE(
+ media_receive_channel1_impl()->recv_codecs()[1].Matches(vp9_codec));
EXPECT_EQ(media_receive_channel1_impl()->recv_codecs()[1].packetization,
cricket::kPacketizationParamRaw);
EXPECT_THAT(media_send_channel1_impl()->send_codecs(), testing::SizeIs(2));
- EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[0].Matches(
- kVp8Codec, &field_trials_));
+ EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[0].Matches(kVp8Codec));
EXPECT_EQ(media_send_channel1_impl()->send_codecs()[0].packetization,
absl::nullopt);
- EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[1].Matches(
- vp9_codec, &field_trials_));
+ EXPECT_TRUE(media_send_channel1_impl()->send_codecs()[1].Matches(vp9_codec));
EXPECT_EQ(media_send_channel1_impl()->send_codecs()[1].packetization,
cricket::kPacketizationParamRaw);
}
diff --git a/third_party/libwebrtc/pc/connection_context.cc b/third_party/libwebrtc/pc/connection_context.cc
index f436e27c0a..df4522bf13 100644
--- a/third_party/libwebrtc/pc/connection_context.cc
+++ b/third_party/libwebrtc/pc/connection_context.cc
@@ -14,9 +14,11 @@
#include <utility>
#include <vector>
+#include "api/environment/environment.h"
#include "api/transport/field_trial_based_config.h"
#include "media/base/media_engine.h"
#include "media/sctp/sctp_transport_factory.h"
+#include "pc/media_factory.h"
#include "rtc_base/helpers.h"
#include "rtc_base/internal/default_socket_server.h"
#include "rtc_base/socket_server.h"
@@ -77,12 +79,14 @@ std::unique_ptr<SctpTransportFactoryInterface> MaybeCreateSctpFactory(
// Static
rtc::scoped_refptr<ConnectionContext> ConnectionContext::Create(
+ const Environment& env,
PeerConnectionFactoryDependencies* dependencies) {
return rtc::scoped_refptr<ConnectionContext>(
- new ConnectionContext(dependencies));
+ new ConnectionContext(env, dependencies));
}
ConnectionContext::ConnectionContext(
+ const Environment& env,
PeerConnectionFactoryDependencies* dependencies)
: network_thread_(MaybeStartNetworkThread(dependencies->network_thread,
owned_socket_factory_,
@@ -96,18 +100,21 @@ ConnectionContext::ConnectionContext(
}),
signaling_thread_(MaybeWrapThread(dependencies->signaling_thread,
wraps_current_thread_)),
- trials_(dependencies->trials ? std::move(dependencies->trials)
- : std::make_unique<FieldTrialBasedConfig>()),
- media_engine_(std::move(dependencies->media_engine)),
+ env_(env),
+ media_engine_(
+ dependencies->media_factory != nullptr
+ ? dependencies->media_factory->CreateMediaEngine(env_,
+ *dependencies)
+ : nullptr),
network_monitor_factory_(
std::move(dependencies->network_monitor_factory)),
default_network_manager_(std::move(dependencies->network_manager)),
- call_factory_(std::move(dependencies->call_factory)),
+ call_factory_(std::move(dependencies->media_factory)),
default_socket_factory_(std::move(dependencies->packet_socket_factory)),
sctp_factory_(
MaybeCreateSctpFactory(std::move(dependencies->sctp_factory),
network_thread(),
- *trials_.get())),
+ env_.field_trials())),
use_rtx_(true) {
RTC_DCHECK_RUN_ON(signaling_thread_);
RTC_DCHECK(!(default_network_manager_ && network_monitor_factory_))
@@ -150,7 +157,7 @@ ConnectionContext::ConnectionContext(
// If network_monitor_factory_ is non-null, it will be used to create a
// network monitor while on the network thread.
default_network_manager_ = std::make_unique<rtc::BasicNetworkManager>(
- network_monitor_factory_.get(), socket_factory, &field_trials());
+ network_monitor_factory_.get(), socket_factory, &env_.field_trials());
}
if (!default_socket_factory_) {
default_socket_factory_ =
diff --git a/third_party/libwebrtc/pc/connection_context.h b/third_party/libwebrtc/pc/connection_context.h
index 399e7c2b45..893a3b0e52 100644
--- a/third_party/libwebrtc/pc/connection_context.h
+++ b/third_party/libwebrtc/pc/connection_context.h
@@ -15,6 +15,7 @@
#include <string>
#include "api/call/call_factory_interface.h"
+#include "api/environment/environment.h"
#include "api/field_trials_view.h"
#include "api/media_stream_interface.h"
#include "api/peer_connection_interface.h"
@@ -39,8 +40,6 @@ class UniqueRandomIdGenerator;
namespace webrtc {
-class RtcEventLog;
-
// This class contains resources needed by PeerConnection and associated
// objects. A reference to this object is passed to each PeerConnection. The
// methods on this object are assumed not to change the state in any way that
@@ -54,6 +53,7 @@ class ConnectionContext final
// The Dependencies class allows simple management of all new dependencies
// being added to the ConnectionContext.
static rtc::scoped_refptr<ConnectionContext> Create(
+ const Environment& env,
PeerConnectionFactoryDependencies* dependencies);
// This class is not copyable or movable.
@@ -76,11 +76,16 @@ class ConnectionContext final
rtc::Thread* network_thread() { return network_thread_; }
const rtc::Thread* network_thread() const { return network_thread_; }
+ // Environment associated with the PeerConnectionFactory.
+ // Note: environments are different for different PeerConnections,
+ // but they are not supposed to change after creating the PeerConnection.
+ const Environment& env() const { return env_; }
+
// Field trials associated with the PeerConnectionFactory.
// Note: that there can be different field trials for different
// PeerConnections (but they are not supposed change after creating the
// PeerConnection).
- const FieldTrialsView& field_trials() const { return *trials_.get(); }
+ const FieldTrialsView& field_trials() const { return env_.field_trials(); }
// Accessors only used from the PeerConnectionFactory class
rtc::NetworkManager* default_network_manager() {
@@ -91,7 +96,7 @@ class ConnectionContext final
RTC_DCHECK_RUN_ON(signaling_thread_);
return default_socket_factory_.get();
}
- CallFactoryInterface* call_factory() {
+ MediaFactory* call_factory() {
RTC_DCHECK_RUN_ON(worker_thread());
return call_factory_.get();
}
@@ -106,7 +111,8 @@ class ConnectionContext final
void set_use_rtx(bool use_rtx) { use_rtx_ = use_rtx; }
protected:
- explicit ConnectionContext(PeerConnectionFactoryDependencies* dependencies);
+ ConnectionContext(const Environment& env,
+ PeerConnectionFactoryDependencies* dependencies);
friend class rtc::RefCountedNonVirtual<ConnectionContext>;
~ConnectionContext();
@@ -122,8 +128,7 @@ class ConnectionContext final
AlwaysValidPointer<rtc::Thread> const worker_thread_;
rtc::Thread* const signaling_thread_;
- // Accessed both on signaling thread and worker thread.
- std::unique_ptr<FieldTrialsView> const trials_;
+ const Environment env_;
// This object is const over the lifetime of the ConnectionContext, and is
// only altered in the destructor.
@@ -138,7 +143,7 @@ class ConnectionContext final
RTC_GUARDED_BY(signaling_thread_);
std::unique_ptr<rtc::NetworkManager> default_network_manager_
RTC_GUARDED_BY(signaling_thread_);
- std::unique_ptr<webrtc::CallFactoryInterface> const call_factory_
+ std::unique_ptr<MediaFactory> const call_factory_
RTC_GUARDED_BY(worker_thread());
std::unique_ptr<rtc::PacketSocketFactory> default_socket_factory_
diff --git a/third_party/libwebrtc/pc/data_channel_controller_unittest.cc b/third_party/libwebrtc/pc/data_channel_controller_unittest.cc
index 3b8adb6819..7d4e60467e 100644
--- a/third_party/libwebrtc/pc/data_channel_controller_unittest.cc
+++ b/third_party/libwebrtc/pc/data_channel_controller_unittest.cc
@@ -27,7 +27,7 @@ namespace {
using ::testing::NiceMock;
using ::testing::Return;
-class MockDataChannelTransport : public webrtc::DataChannelTransportInterface {
+class MockDataChannelTransport : public DataChannelTransportInterface {
public:
~MockDataChannelTransport() override {}
diff --git a/third_party/libwebrtc/pc/data_channel_integrationtest.cc b/third_party/libwebrtc/pc/data_channel_integrationtest.cc
index faec76d03e..5a8004c72a 100644
--- a/third_party/libwebrtc/pc/data_channel_integrationtest.cc
+++ b/third_party/libwebrtc/pc/data_channel_integrationtest.cc
@@ -90,7 +90,7 @@ class FakeClockForTest : public rtc::ScopedFakeClock {
// Some things use a time of "0" as a special value, so we need to start out
// the fake clock at a nonzero time.
// TODO(deadbeef): Fix this.
- AdvanceTime(webrtc::TimeDelta::Seconds(1));
+ AdvanceTime(TimeDelta::Seconds(1));
}
// Explicit handle.
@@ -422,7 +422,7 @@ TEST_P(DataChannelIntegrationTest, CalleeClosesSctpDataChannel) {
TEST_P(DataChannelIntegrationTest, SctpDataChannelConfigSentToOtherSide) {
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
- webrtc::DataChannelInit init;
+ DataChannelInit init;
init.id = 53;
init.maxRetransmits = 52;
caller()->CreateDataChannel("data-channel", &init);
@@ -453,7 +453,7 @@ TEST_P(DataChannelIntegrationTest, StressTestUnorderedSctpDataChannel) {
// Normal procedure, but with unordered data channel config.
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
- webrtc::DataChannelInit init;
+ DataChannelInit init;
init.ordered = false;
caller()->CreateDataChannel(&init);
caller()->CreateAndSetAndSignalOffer();
@@ -515,7 +515,7 @@ TEST_P(DataChannelIntegrationTest, StressTestOpenCloseChannelNoDelay) {
const size_t kIterations = 10;
bool has_negotiated = false;
- webrtc::DataChannelInit init;
+ DataChannelInit init;
for (size_t repeats = 0; repeats < kIterations; ++repeats) {
RTC_LOG(LS_INFO) << "Iteration " << (repeats + 1) << "/" << kIterations;
@@ -592,7 +592,7 @@ TEST_P(DataChannelIntegrationTest, StressTestOpenCloseChannelWithDelay) {
const size_t kIterations = 10;
bool has_negotiated = false;
- webrtc::DataChannelInit init;
+ DataChannelInit init;
for (size_t repeats = 0; repeats < kIterations; ++repeats) {
RTC_LOG(LS_INFO) << "Iteration " << (repeats + 1) << "/" << kIterations;
diff --git a/third_party/libwebrtc/pc/data_channel_unittest.cc b/third_party/libwebrtc/pc/data_channel_unittest.cc
index 9b84a1be61..a27a66c3de 100644
--- a/third_party/libwebrtc/pc/data_channel_unittest.cc
+++ b/third_party/libwebrtc/pc/data_channel_unittest.cc
@@ -81,8 +81,7 @@ class SctpDataChannelTest : public ::testing::Test {
controller_(new FakeDataChannelController(&network_thread_)) {
network_thread_.Start();
inner_channel_ = controller_->CreateDataChannel("test", init_);
- channel_ =
- webrtc::SctpDataChannel::CreateProxy(inner_channel_, signaling_safety_);
+ channel_ = SctpDataChannel::CreateProxy(inner_channel_, signaling_safety_);
}
~SctpDataChannelTest() override {
run_loop_.Flush();
@@ -510,7 +509,7 @@ TEST_F(SctpDataChannelTest, LateCreatedChannelTransitionToOpen) {
SetChannelReady();
InternalDataChannelInit init;
init.id = 1;
- auto dc = webrtc::SctpDataChannel::CreateProxy(
+ auto dc = SctpDataChannel::CreateProxy(
controller_->CreateDataChannel("test1", init), signaling_safety_);
EXPECT_EQ(DataChannelInterface::kOpen, dc->state());
}
@@ -524,7 +523,7 @@ TEST_F(SctpDataChannelTest, SendUnorderedAfterReceivesOpenAck) {
init.ordered = false;
rtc::scoped_refptr<SctpDataChannel> dc =
controller_->CreateDataChannel("test1", init);
- auto proxy = webrtc::SctpDataChannel::CreateProxy(dc, signaling_safety_);
+ auto proxy = SctpDataChannel::CreateProxy(dc, signaling_safety_);
EXPECT_EQ_WAIT(DataChannelInterface::kOpen, proxy->state(), 1000);
@@ -553,7 +552,7 @@ TEST_F(SctpDataChannelTest, DeprecatedSendUnorderedAfterReceivesOpenAck) {
init.ordered = false;
rtc::scoped_refptr<SctpDataChannel> dc =
controller_->CreateDataChannel("test1", init);
- auto proxy = webrtc::SctpDataChannel::CreateProxy(dc, signaling_safety_);
+ auto proxy = SctpDataChannel::CreateProxy(dc, signaling_safety_);
EXPECT_EQ_WAIT(DataChannelInterface::kOpen, proxy->state(), 1000);
@@ -582,7 +581,7 @@ TEST_F(SctpDataChannelTest, SendUnorderedAfterReceiveData) {
init.ordered = false;
rtc::scoped_refptr<SctpDataChannel> dc =
controller_->CreateDataChannel("test1", init);
- auto proxy = webrtc::SctpDataChannel::CreateProxy(dc, signaling_safety_);
+ auto proxy = SctpDataChannel::CreateProxy(dc, signaling_safety_);
EXPECT_EQ_WAIT(DataChannelInterface::kOpen, proxy->state(), 1000);
@@ -605,7 +604,7 @@ TEST_F(SctpDataChannelTest, DeprecatedSendUnorderedAfterReceiveData) {
init.ordered = false;
rtc::scoped_refptr<SctpDataChannel> dc =
controller_->CreateDataChannel("test1", init);
- auto proxy = webrtc::SctpDataChannel::CreateProxy(dc, signaling_safety_);
+ auto proxy = SctpDataChannel::CreateProxy(dc, signaling_safety_);
EXPECT_EQ_WAIT(DataChannelInterface::kOpen, proxy->state(), 1000);
@@ -714,7 +713,7 @@ TEST_F(SctpDataChannelTest, NoMsgSentIfNegotiatedAndNotFromOpenMsg) {
SetChannelReady();
rtc::scoped_refptr<SctpDataChannel> dc =
controller_->CreateDataChannel("test1", config);
- auto proxy = webrtc::SctpDataChannel::CreateProxy(dc, signaling_safety_);
+ auto proxy = SctpDataChannel::CreateProxy(dc, signaling_safety_);
EXPECT_EQ_WAIT(DataChannelInterface::kOpen, proxy->state(), 1000);
EXPECT_EQ(0, controller_->last_sid());
@@ -779,7 +778,7 @@ TEST_F(SctpDataChannelTest, OpenAckSentIfCreatedFromOpenMessage) {
SetChannelReady();
rtc::scoped_refptr<SctpDataChannel> dc =
controller_->CreateDataChannel("test1", config);
- auto proxy = webrtc::SctpDataChannel::CreateProxy(dc, signaling_safety_);
+ auto proxy = SctpDataChannel::CreateProxy(dc, signaling_safety_);
EXPECT_EQ_WAIT(DataChannelInterface::kOpen, proxy->state(), 1000);
diff --git a/third_party/libwebrtc/pc/dtls_srtp_transport.h b/third_party/libwebrtc/pc/dtls_srtp_transport.h
index 0f8338ca0d..995809ed4b 100644
--- a/third_party/libwebrtc/pc/dtls_srtp_transport.h
+++ b/third_party/libwebrtc/pc/dtls_srtp_transport.h
@@ -49,15 +49,6 @@ class DtlsSrtpTransport : public SrtpTransport {
void SetOnDtlsStateChange(std::function<void(void)> callback);
- RTCError SetSrtpSendKey(const cricket::CryptoParams& params) override {
- return RTCError(RTCErrorType::UNSUPPORTED_OPERATION,
- "Set SRTP keys for DTLS-SRTP is not supported.");
- }
- RTCError SetSrtpReceiveKey(const cricket::CryptoParams& params) override {
- return RTCError(RTCErrorType::UNSUPPORTED_OPERATION,
- "Set SRTP keys for DTLS-SRTP is not supported.");
- }
-
// If `active_reset_srtp_params_` is set to be true, the SRTP parameters will
// be reset whenever the DtlsTransports are reset.
void SetActiveResetSrtpParams(bool active_reset_srtp_params) {
diff --git a/third_party/libwebrtc/pc/ice_server_parsing_unittest.cc b/third_party/libwebrtc/pc/ice_server_parsing_unittest.cc
index 4356b1efb0..a38638e507 100644
--- a/third_party/libwebrtc/pc/ice_server_parsing_unittest.cc
+++ b/third_party/libwebrtc/pc/ice_server_parsing_unittest.cc
@@ -62,9 +62,7 @@ class IceServerParsingTest : public ::testing::Test {
server.tls_cert_policy = tls_certificate_policy;
server.hostname = hostname;
servers.push_back(server);
- return webrtc::ParseIceServersOrError(servers, &stun_servers_,
- &turn_servers_)
- .ok();
+ return ParseIceServersOrError(servers, &stun_servers_, &turn_servers_).ok();
}
protected:
@@ -233,8 +231,7 @@ TEST_F(IceServerParsingTest, ParseMultipleUrls) {
server.password = "bar";
servers.push_back(server);
EXPECT_TRUE(
- webrtc::ParseIceServersOrError(servers, &stun_servers_, &turn_servers_)
- .ok());
+ ParseIceServersOrError(servers, &stun_servers_, &turn_servers_).ok());
EXPECT_EQ(1U, stun_servers_.size());
EXPECT_EQ(1U, turn_servers_.size());
}
diff --git a/third_party/libwebrtc/pc/ice_transport_unittest.cc b/third_party/libwebrtc/pc/ice_transport_unittest.cc
index aaf9f2e57a..a42c107072 100644
--- a/third_party/libwebrtc/pc/ice_transport_unittest.cc
+++ b/third_party/libwebrtc/pc/ice_transport_unittest.cc
@@ -32,7 +32,7 @@ class IceTransportTest : public ::testing::Test {
rtc::SocketServer* socket_server() const { return socket_server_.get(); }
- webrtc::test::ScopedKeyValueConfig field_trials_;
+ test::ScopedKeyValueConfig field_trials_;
private:
std::unique_ptr<rtc::SocketServer> socket_server_;
diff --git a/third_party/libwebrtc/pc/jsep_transport_controller.cc b/third_party/libwebrtc/pc/jsep_transport_controller.cc
index 7c669a5ae3..d5d1cd24a9 100644
--- a/third_party/libwebrtc/pc/jsep_transport_controller.cc
+++ b/third_party/libwebrtc/pc/jsep_transport_controller.cc
@@ -76,14 +76,18 @@ JsepTransportController::~JsepTransportController() {
RTCError JsepTransportController::SetLocalDescription(
SdpType type,
- const cricket::SessionDescription* description) {
+ const cricket::SessionDescription* local_desc,
+ const cricket::SessionDescription* remote_desc) {
+ RTC_DCHECK(local_desc);
TRACE_EVENT0("webrtc", "JsepTransportController::SetLocalDescription");
+
if (!network_thread_->IsCurrent()) {
return network_thread_->BlockingCall(
- [=] { return SetLocalDescription(type, description); });
+ [=] { return SetLocalDescription(type, local_desc, remote_desc); });
}
RTC_DCHECK_RUN_ON(network_thread_);
+
if (!initial_offerer_.has_value()) {
initial_offerer_.emplace(type == SdpType::kOffer);
if (*initial_offerer_) {
@@ -92,20 +96,22 @@ RTCError JsepTransportController::SetLocalDescription(
SetIceRole_n(cricket::ICEROLE_CONTROLLED);
}
}
- return ApplyDescription_n(/*local=*/true, type, description);
+ return ApplyDescription_n(/*local=*/true, type, local_desc, remote_desc);
}
RTCError JsepTransportController::SetRemoteDescription(
SdpType type,
- const cricket::SessionDescription* description) {
+ const cricket::SessionDescription* local_desc,
+ const cricket::SessionDescription* remote_desc) {
+ RTC_DCHECK(remote_desc);
TRACE_EVENT0("webrtc", "JsepTransportController::SetRemoteDescription");
if (!network_thread_->IsCurrent()) {
return network_thread_->BlockingCall(
- [=] { return SetRemoteDescription(type, description); });
+ [=] { return SetRemoteDescription(type, local_desc, remote_desc); });
}
RTC_DCHECK_RUN_ON(network_thread_);
- return ApplyDescription_n(/*local=*/false, type, description);
+ return ApplyDescription_n(/*local=*/false, type, local_desc, remote_desc);
}
RtpTransportInternal* JsepTransportController::GetRtpTransport(
@@ -148,7 +154,7 @@ JsepTransportController::GetRtcpDtlsTransport(const std::string& mid) const {
return jsep_transport->rtcp_dtls_transport();
}
-rtc::scoped_refptr<webrtc::DtlsTransport>
+rtc::scoped_refptr<DtlsTransport>
JsepTransportController::LookupDtlsTransportByMid(const std::string& mid) {
RTC_DCHECK_RUN_ON(network_thread_);
auto jsep_transport = GetJsepTransportForMid(mid);
@@ -383,7 +389,7 @@ RTCError JsepTransportController::RollbackTransports() {
return RTCError::OK();
}
-rtc::scoped_refptr<webrtc::IceTransportInterface>
+rtc::scoped_refptr<IceTransportInterface>
JsepTransportController::CreateIceTransport(const std::string& transport_name,
bool rtcp) {
int component = rtcp ? cricket::ICE_CANDIDATE_COMPONENT_RTCP
@@ -433,29 +439,43 @@ JsepTransportController::CreateDtlsTransport(
this, &JsepTransportController::OnTransportWritableState_n);
dtls->SignalReceivingState.connect(
this, &JsepTransportController::OnTransportReceivingState_n);
- dtls->ice_transport()->SignalGatheringState.connect(
- this, &JsepTransportController::OnTransportGatheringState_n);
+ dtls->ice_transport()->SetGatheringStateCallback(
+ [this](cricket::IceTransportInternal* transport) {
+ RTC_DCHECK_RUN_ON(network_thread_);
+ OnTransportGatheringState_n(transport);
+ });
dtls->ice_transport()->SignalCandidateGathered.connect(
this, &JsepTransportController::OnTransportCandidateGathered_n);
- dtls->ice_transport()->SignalCandidateError.connect(
- this, &JsepTransportController::OnTransportCandidateError_n);
- dtls->ice_transport()->SignalCandidatesRemoved.connect(
- this, &JsepTransportController::OnTransportCandidatesRemoved_n);
+ dtls->ice_transport()->SetCandidateErrorCallback(
+ [this](cricket::IceTransportInternal* transport,
+ const cricket::IceCandidateErrorEvent& error) {
+ RTC_DCHECK_RUN_ON(network_thread_);
+ OnTransportCandidateError_n(transport, error);
+ });
+ dtls->ice_transport()->SetCandidatesRemovedCallback(
+ [this](cricket::IceTransportInternal* transport,
+ const cricket::Candidates& candidates) {
+ RTC_DCHECK_RUN_ON(network_thread_);
+ OnTransportCandidatesRemoved_n(transport, candidates);
+ });
dtls->ice_transport()->SignalRoleConflict.connect(
this, &JsepTransportController::OnTransportRoleConflict_n);
dtls->ice_transport()->SignalStateChanged.connect(
this, &JsepTransportController::OnTransportStateChanged_n);
dtls->ice_transport()->SignalIceTransportStateChanged.connect(
this, &JsepTransportController::OnTransportStateChanged_n);
- dtls->ice_transport()->SignalCandidatePairChanged.connect(
- this, &JsepTransportController::OnTransportCandidatePairChanged_n);
+ dtls->ice_transport()->SetCandidatePairChangeCallback(
+ [this](const cricket::CandidatePairChangeEvent& event) {
+ RTC_DCHECK_RUN_ON(network_thread_);
+ OnTransportCandidatePairChanged_n(event);
+ });
dtls->SubscribeDtlsHandshakeError(
[this](rtc::SSLHandshakeError error) { OnDtlsHandshakeError(error); });
return dtls;
}
-std::unique_ptr<webrtc::RtpTransport>
+std::unique_ptr<RtpTransport>
JsepTransportController::CreateUnencryptedRtpTransport(
const std::string& transport_name,
rtc::PacketTransportInternal* rtp_packet_transport,
@@ -470,13 +490,12 @@ JsepTransportController::CreateUnencryptedRtpTransport(
return unencrypted_rtp_transport;
}
-std::unique_ptr<webrtc::SrtpTransport>
-JsepTransportController::CreateSdesTransport(
+std::unique_ptr<SrtpTransport> JsepTransportController::CreateSdesTransport(
const std::string& transport_name,
cricket::DtlsTransportInternal* rtp_dtls_transport,
cricket::DtlsTransportInternal* rtcp_dtls_transport) {
RTC_DCHECK_RUN_ON(network_thread_);
- auto srtp_transport = std::make_unique<webrtc::SrtpTransport>(
+ auto srtp_transport = std::make_unique<SrtpTransport>(
rtcp_dtls_transport == nullptr, *config_.field_trials);
RTC_DCHECK(rtp_dtls_transport);
srtp_transport->SetRtpPacketTransport(rtp_dtls_transport);
@@ -489,13 +508,13 @@ JsepTransportController::CreateSdesTransport(
return srtp_transport;
}
-std::unique_ptr<webrtc::DtlsSrtpTransport>
+std::unique_ptr<DtlsSrtpTransport>
JsepTransportController::CreateDtlsSrtpTransport(
const std::string& transport_name,
cricket::DtlsTransportInternal* rtp_dtls_transport,
cricket::DtlsTransportInternal* rtcp_dtls_transport) {
RTC_DCHECK_RUN_ON(network_thread_);
- auto dtls_srtp_transport = std::make_unique<webrtc::DtlsSrtpTransport>(
+ auto dtls_srtp_transport = std::make_unique<DtlsSrtpTransport>(
rtcp_dtls_transport == nullptr, *config_.field_trials);
if (config_.enable_external_auth) {
dtls_srtp_transport->EnableExternalAuth();
@@ -550,18 +569,20 @@ JsepTransportController::GetActiveDtlsTransports() {
RTCError JsepTransportController::ApplyDescription_n(
bool local,
SdpType type,
- const cricket::SessionDescription* description) {
+ const cricket::SessionDescription* local_desc,
+ const cricket::SessionDescription* remote_desc) {
TRACE_EVENT0("webrtc", "JsepTransportController::ApplyDescription_n");
- RTC_DCHECK(description);
- if (local) {
- local_desc_ = description;
- } else {
- remote_desc_ = description;
- }
+ // Stash away the description object that we'll be applying (since this
+ // function is used for both local and remote).
+ const cricket::SessionDescription* description =
+ local ? local_desc : remote_desc;
+
+ RTC_DCHECK(description);
RTCError error;
- error = ValidateAndMaybeUpdateBundleGroups(local, type, description);
+ error =
+ ValidateAndMaybeUpdateBundleGroups(local, type, local_desc, remote_desc);
if (!error.ok()) {
return error;
}
@@ -673,7 +694,11 @@ RTCError JsepTransportController::ApplyDescription_n(
RTCError JsepTransportController::ValidateAndMaybeUpdateBundleGroups(
bool local,
SdpType type,
- const cricket::SessionDescription* description) {
+ const cricket::SessionDescription* local_desc,
+ const cricket::SessionDescription* remote_desc) {
+ const cricket::SessionDescription* description =
+ local ? local_desc : remote_desc;
+
RTC_DCHECK(description);
std::vector<const cricket::ContentGroup*> new_bundle_groups =
@@ -739,72 +764,74 @@ RTCError JsepTransportController::ValidateAndMaybeUpdateBundleGroups(
}
}
} else if (type == SdpType::kAnswer) {
- std::vector<const cricket::ContentGroup*> offered_bundle_groups =
- local ? remote_desc_->GetGroupsByName(cricket::GROUP_TYPE_BUNDLE)
- : local_desc_->GetGroupsByName(cricket::GROUP_TYPE_BUNDLE);
-
- std::map<std::string, const cricket::ContentGroup*>
- offered_bundle_groups_by_mid;
- for (const cricket::ContentGroup* offered_bundle_group :
- offered_bundle_groups) {
- for (const std::string& content_name :
- offered_bundle_group->content_names()) {
- offered_bundle_groups_by_mid[content_name] = offered_bundle_group;
+ if ((local && remote_desc) || (!local && local_desc)) {
+ std::vector<const cricket::ContentGroup*> offered_bundle_groups =
+ local ? remote_desc->GetGroupsByName(cricket::GROUP_TYPE_BUNDLE)
+ : local_desc->GetGroupsByName(cricket::GROUP_TYPE_BUNDLE);
+
+ std::map<std::string, const cricket::ContentGroup*>
+ offered_bundle_groups_by_mid;
+ for (const cricket::ContentGroup* offered_bundle_group :
+ offered_bundle_groups) {
+ for (const std::string& content_name :
+ offered_bundle_group->content_names()) {
+ offered_bundle_groups_by_mid[content_name] = offered_bundle_group;
+ }
}
- }
- std::map<const cricket::ContentGroup*, const cricket::ContentGroup*>
- new_bundle_groups_by_offered_bundle_groups;
- for (const cricket::ContentGroup* new_bundle_group : new_bundle_groups) {
- if (!new_bundle_group->FirstContentName()) {
- // Empty groups could be a subset of any group.
- continue;
- }
- // The group in the answer (new_bundle_group) must have a corresponding
- // group in the offer (original_group), because the answer groups may only
- // be subsets of the offer groups.
- auto it = offered_bundle_groups_by_mid.find(
- *new_bundle_group->FirstContentName());
- if (it == offered_bundle_groups_by_mid.end()) {
- return RTCError(RTCErrorType::INVALID_PARAMETER,
- "A BUNDLE group was added in the answer that did not "
- "exist in the offer.");
- }
- const cricket::ContentGroup* offered_bundle_group = it->second;
- if (new_bundle_groups_by_offered_bundle_groups.find(
- offered_bundle_group) !=
- new_bundle_groups_by_offered_bundle_groups.end()) {
- return RTCError(RTCErrorType::INVALID_PARAMETER,
- "A MID in the answer has changed group.");
- }
- new_bundle_groups_by_offered_bundle_groups.insert(
- std::make_pair(offered_bundle_group, new_bundle_group));
- for (const std::string& content_name :
- new_bundle_group->content_names()) {
- it = offered_bundle_groups_by_mid.find(content_name);
- // The BUNDLE group in answer should be a subset of offered group.
- if (it == offered_bundle_groups_by_mid.end() ||
- it->second != offered_bundle_group) {
+ std::map<const cricket::ContentGroup*, const cricket::ContentGroup*>
+ new_bundle_groups_by_offered_bundle_groups;
+ for (const cricket::ContentGroup* new_bundle_group : new_bundle_groups) {
+ if (!new_bundle_group->FirstContentName()) {
+ // Empty groups could be a subset of any group.
+ continue;
+ }
+ // The group in the answer (new_bundle_group) must have a corresponding
+ // group in the offer (original_group), because the answer groups may
+ // only be subsets of the offer groups.
+ auto it = offered_bundle_groups_by_mid.find(
+ *new_bundle_group->FirstContentName());
+ if (it == offered_bundle_groups_by_mid.end()) {
return RTCError(RTCErrorType::INVALID_PARAMETER,
- "A BUNDLE group in answer contains a MID='" +
- content_name +
- "' that was not in the offered group.");
+ "A BUNDLE group was added in the answer that did not "
+ "exist in the offer.");
}
- }
- }
-
- for (const auto& bundle_group : bundles_.bundle_groups()) {
- for (const std::string& content_name : bundle_group->content_names()) {
- // An answer that removes m= sections from pre-negotiated BUNDLE group
- // without rejecting it, is invalid.
- auto it = new_bundle_groups_by_mid.find(content_name);
- if (it == new_bundle_groups_by_mid.end()) {
- auto* content_info = description->GetContentByName(content_name);
- if (!content_info || !content_info->rejected) {
+ const cricket::ContentGroup* offered_bundle_group = it->second;
+ if (new_bundle_groups_by_offered_bundle_groups.find(
+ offered_bundle_group) !=
+ new_bundle_groups_by_offered_bundle_groups.end()) {
+ return RTCError(RTCErrorType::INVALID_PARAMETER,
+ "A MID in the answer has changed group.");
+ }
+ new_bundle_groups_by_offered_bundle_groups.insert(
+ std::make_pair(offered_bundle_group, new_bundle_group));
+ for (const std::string& content_name :
+ new_bundle_group->content_names()) {
+ it = offered_bundle_groups_by_mid.find(content_name);
+ // The BUNDLE group in answer should be a subset of offered group.
+ if (it == offered_bundle_groups_by_mid.end() ||
+ it->second != offered_bundle_group) {
return RTCError(RTCErrorType::INVALID_PARAMETER,
- "Answer cannot remove m= section with mid='" +
+ "A BUNDLE group in answer contains a MID='" +
content_name +
- "' from already-established BUNDLE group.");
+ "' that was not in the offered group.");
+ }
+ }
+ }
+
+ for (const auto& bundle_group : bundles_.bundle_groups()) {
+ for (const std::string& content_name : bundle_group->content_names()) {
+ // An answer that removes m= sections from pre-negotiated BUNDLE group
+ // without rejecting it, is invalid.
+ auto it = new_bundle_groups_by_mid.find(content_name);
+ if (it == new_bundle_groups_by_mid.end()) {
+ auto* content_info = description->GetContentByName(content_name);
+ if (!content_info || !content_info->rejected) {
+ return RTCError(RTCErrorType::INVALID_PARAMETER,
+ "Answer cannot remove m= section with mid='" +
+ content_name +
+ "' from already-established BUNDLE group.");
+ }
}
}
}
@@ -985,13 +1012,12 @@ int JsepTransportController::GetRtpAbsSendTimeHeaderExtensionId(
const cricket::MediaContentDescription* content_desc =
content_info.media_description();
- const webrtc::RtpExtension* send_time_extension =
- webrtc::RtpExtension::FindHeaderExtensionByUri(
- content_desc->rtp_header_extensions(),
- webrtc::RtpExtension::kAbsSendTimeUri,
+ const RtpExtension* send_time_extension =
+ RtpExtension::FindHeaderExtensionByUri(
+ content_desc->rtp_header_extensions(), RtpExtension::kAbsSendTimeUri,
config_.crypto_options.srtp.enable_encrypted_rtp_header_extensions
- ? webrtc::RtpExtension::kPreferEncryptedExtension
- : webrtc::RtpExtension::kDiscardEncryptedExtension);
+ ? RtpExtension::kPreferEncryptedExtension
+ : RtpExtension::kDiscardEncryptedExtension);
return send_time_extension ? send_time_extension->id : -1;
}
@@ -1039,7 +1065,7 @@ RTCError JsepTransportController::MaybeCreateJsepTransport(
"SDES and DTLS-SRTP cannot be enabled at the same time.");
}
- rtc::scoped_refptr<webrtc::IceTransportInterface> ice =
+ rtc::scoped_refptr<IceTransportInterface> ice =
CreateIceTransport(content_info.name, /*rtcp=*/false);
std::unique_ptr<cricket::DtlsTransportInternal> rtp_dtls_transport =
@@ -1050,7 +1076,7 @@ RTCError JsepTransportController::MaybeCreateJsepTransport(
std::unique_ptr<SrtpTransport> sdes_transport;
std::unique_ptr<DtlsSrtpTransport> dtls_srtp_transport;
- rtc::scoped_refptr<webrtc::IceTransportInterface> rtcp_ice;
+ rtc::scoped_refptr<IceTransportInterface> rtcp_ice;
if (config_.rtcp_mux_policy !=
PeerConnectionInterface::kRtcpMuxPolicyRequire &&
content_info.type == cricket::MediaProtocolType::kRtp) {
@@ -1096,7 +1122,7 @@ RTCError JsepTransportController::MaybeCreateJsepTransport(
OnRtcpPacketReceived_n(buffer, packet_time_ms);
});
jsep_transport->rtp_transport()->SetUnDemuxableRtpPacketReceivedHandler(
- [this](webrtc::RtpPacketReceived& packet) {
+ [this](RtpPacketReceived& packet) {
RTC_DCHECK_RUN_ON(network_thread_);
OnUnDemuxableRtpPacketReceived_n(packet);
});
@@ -1421,7 +1447,7 @@ void JsepTransportController::OnRtcpPacketReceived_n(
}
void JsepTransportController::OnUnDemuxableRtpPacketReceived_n(
- const webrtc::RtpPacketReceived& packet) {
+ const RtpPacketReceived& packet) {
RTC_DCHECK(config_.un_demuxable_packet_handler);
config_.un_demuxable_packet_handler(packet);
}
diff --git a/third_party/libwebrtc/pc/jsep_transport_controller.h b/third_party/libwebrtc/pc/jsep_transport_controller.h
index 5880e346cd..448844ac79 100644
--- a/third_party/libwebrtc/pc/jsep_transport_controller.h
+++ b/third_party/libwebrtc/pc/jsep_transport_controller.h
@@ -112,7 +112,7 @@ class JsepTransportController : public sigslot::has_slots<> {
rtc::SSLProtocolVersion ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12;
// `crypto_options` is used to determine if created DTLS transports
// negotiate GCM crypto suites or not.
- webrtc::CryptoOptions crypto_options;
+ CryptoOptions crypto_options;
PeerConnectionInterface::BundlePolicy bundle_policy =
PeerConnectionInterface::kBundlePolicyBalanced;
PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy =
@@ -120,7 +120,7 @@ class JsepTransportController : public sigslot::has_slots<> {
bool disable_encryption = false;
bool enable_external_auth = false;
// Used to inject the ICE/DTLS transports created externally.
- webrtc::IceTransportFactory* ice_transport_factory = nullptr;
+ IceTransportFactory* ice_transport_factory = nullptr;
cricket::DtlsTransportFactory* dtls_transport_factory = nullptr;
Observer* transport_observer = nullptr;
// Must be provided and valid for the lifetime of the
@@ -140,7 +140,7 @@ class JsepTransportController : public sigslot::has_slots<> {
std::function<void(rtc::SSLHandshakeError)> on_dtls_handshake_error_;
// Field trials.
- const webrtc::FieldTrialsView* field_trials;
+ const FieldTrialsView* field_trials;
};
// The ICE related events are fired on the `network_thread`.
@@ -161,11 +161,24 @@ class JsepTransportController : public sigslot::has_slots<> {
// level, creating/destroying transport objects as needed and updating their
// properties. This includes RTP, DTLS, and ICE (but not SCTP). At least not
// yet? May make sense to in the future.
+ //
+ // `local_desc` must always be valid. If a remote description has previously
+ // been set via a call to `SetRemoteDescription()` then `remote_desc` should
+ // point to that description object in order to keep the current local and
+ // remote session descriptions in sync.
RTCError SetLocalDescription(SdpType type,
- const cricket::SessionDescription* description);
-
+ const cricket::SessionDescription* local_desc,
+ const cricket::SessionDescription* remote_desc);
+
+ // Call to apply a remote description (See `SetLocalDescription()` for local).
+ //
+ // `remote_desc` must always be valid. If a local description has previously
+ // been set via a call to `SetLocalDescription()` then `local_desc` should
+ // point to that description object in order to keep the current local and
+ // remote session descriptions in sync.
RTCError SetRemoteDescription(SdpType type,
- const cricket::SessionDescription* description);
+ const cricket::SessionDescription* local_desc,
+ const cricket::SessionDescription* remote_desc);
// Get transports to be used for the provided `mid`. If bundling is enabled,
// calling GetRtpTransport for multiple MIDs may yield the same object.
@@ -174,7 +187,7 @@ class JsepTransportController : public sigslot::has_slots<> {
const cricket::DtlsTransportInternal* GetRtcpDtlsTransport(
const std::string& mid) const;
// Gets the externally sharable version of the DtlsTransport.
- rtc::scoped_refptr<webrtc::DtlsTransport> LookupDtlsTransportByMid(
+ rtc::scoped_refptr<DtlsTransport> LookupDtlsTransportByMid(
const std::string& mid);
rtc::scoped_refptr<SctpTransport> GetSctpTransport(
const std::string& mid) const;
@@ -325,14 +338,23 @@ class JsepTransportController : public sigslot::has_slots<> {
CallbackList<const cricket::CandidatePairChangeEvent&>
signal_ice_candidate_pair_changed_ RTC_GUARDED_BY(network_thread_);
+ // Called from SetLocalDescription and SetRemoteDescription.
+ // When `local` is true, local_desc must be valid. Similarly when
+ // `local` is false, remote_desc must be valid. The description counterpart
+ // to the one that's being applied, may be nullptr but when it's supplied
+ // the counterpart description's content groups will be kept up to date for
+ // `type == SdpType::kAnswer`.
RTCError ApplyDescription_n(bool local,
SdpType type,
- const cricket::SessionDescription* description)
+ const cricket::SessionDescription* local_desc,
+ const cricket::SessionDescription* remote_desc)
RTC_RUN_ON(network_thread_);
RTCError ValidateAndMaybeUpdateBundleGroups(
bool local,
SdpType type,
- const cricket::SessionDescription* description);
+ const cricket::SessionDescription* local_desc,
+ const cricket::SessionDescription* remote_desc)
+ RTC_RUN_ON(network_thread_);
RTCError ValidateContent(const cricket::ContentInfo& content_info);
void HandleRejectedContent(const cricket::ContentInfo& content_info)
@@ -399,19 +421,19 @@ class JsepTransportController : public sigslot::has_slots<> {
std::unique_ptr<cricket::DtlsTransportInternal> CreateDtlsTransport(
const cricket::ContentInfo& content_info,
cricket::IceTransportInternal* ice);
- rtc::scoped_refptr<webrtc::IceTransportInterface> CreateIceTransport(
+ rtc::scoped_refptr<IceTransportInterface> CreateIceTransport(
const std::string& transport_name,
bool rtcp);
- std::unique_ptr<webrtc::RtpTransport> CreateUnencryptedRtpTransport(
+ std::unique_ptr<RtpTransport> CreateUnencryptedRtpTransport(
const std::string& transport_name,
rtc::PacketTransportInternal* rtp_packet_transport,
rtc::PacketTransportInternal* rtcp_packet_transport);
- std::unique_ptr<webrtc::SrtpTransport> CreateSdesTransport(
+ std::unique_ptr<SrtpTransport> CreateSdesTransport(
const std::string& transport_name,
cricket::DtlsTransportInternal* rtp_dtls_transport,
cricket::DtlsTransportInternal* rtcp_dtls_transport);
- std::unique_ptr<webrtc::DtlsSrtpTransport> CreateDtlsSrtpTransport(
+ std::unique_ptr<DtlsSrtpTransport> CreateDtlsSrtpTransport(
const std::string& transport_name,
cricket::DtlsTransportInternal* rtp_dtls_transport,
cricket::DtlsTransportInternal* rtcp_dtls_transport);
@@ -453,7 +475,7 @@ class JsepTransportController : public sigslot::has_slots<> {
void OnRtcpPacketReceived_n(rtc::CopyOnWriteBuffer* packet,
int64_t packet_time_us)
RTC_RUN_ON(network_thread_);
- void OnUnDemuxableRtpPacketReceived_n(const webrtc::RtpPacketReceived& packet)
+ void OnUnDemuxableRtpPacketReceived_n(const RtpPacketReceived& packet)
RTC_RUN_ON(network_thread_);
void OnDtlsHandshakeError(rtc::SSLHandshakeError error);
@@ -481,8 +503,6 @@ class JsepTransportController : public sigslot::has_slots<> {
const Config config_;
bool active_reset_srtp_params_ RTC_GUARDED_BY(network_thread_);
- const cricket::SessionDescription* local_desc_ = nullptr;
- const cricket::SessionDescription* remote_desc_ = nullptr;
absl::optional<bool> initial_offerer_;
cricket::IceConfig ice_config_;
diff --git a/third_party/libwebrtc/pc/jsep_transport_controller_unittest.cc b/third_party/libwebrtc/pc/jsep_transport_controller_unittest.cc
index faa8842e35..7696d82be8 100644
--- a/third_party/libwebrtc/pc/jsep_transport_controller_unittest.cc
+++ b/third_party/libwebrtc/pc/jsep_transport_controller_unittest.cc
@@ -56,7 +56,7 @@ static const char kDataMid1[] = "data1";
namespace webrtc {
-class FakeIceTransportFactory : public webrtc::IceTransportFactory {
+class FakeIceTransportFactory : public IceTransportFactory {
public:
~FakeIceTransportFactory() override = default;
rtc::scoped_refptr<IceTransportInterface> CreateIceTransport(
@@ -72,7 +72,7 @@ class FakeDtlsTransportFactory : public cricket::DtlsTransportFactory {
public:
std::unique_ptr<cricket::DtlsTransportInternal> CreateDtlsTransport(
cricket::IceTransportInternal* ice,
- const webrtc::CryptoOptions& crypto_options,
+ const CryptoOptions& crypto_options,
rtc::SSLProtocolVersion max_version) override {
return std::make_unique<FakeDtlsTransport>(
static_cast<cricket::FakeIceTransport*>(ice));
@@ -265,9 +265,10 @@ class JsepTransportControllerTest : public JsepTransportController::Observer,
}
auto description = CreateSessionDescriptionWithBundleGroup();
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
transport_controller_->MaybeStartGathering();
auto fake_audio_dtls = static_cast<FakeDtlsTransport*>(
@@ -379,15 +380,16 @@ class JsepTransportControllerTest : public JsepTransportController::Observer,
// Transport controller needs to be destroyed first, because it may issue
// callbacks that modify the changed_*_by_mid in the destructor.
std::unique_ptr<JsepTransportController> transport_controller_;
- webrtc::test::ScopedKeyValueConfig field_trials_;
+ test::ScopedKeyValueConfig field_trials_;
};
TEST_F(JsepTransportControllerTest, GetRtpTransport) {
CreateJsepTransportController(JsepTransportController::Config());
auto description = CreateSessionDescriptionWithoutBundle();
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
auto audio_rtp_transport = transport_controller_->GetRtpTransport(kAudioMid1);
auto video_rtp_transport = transport_controller_->GetRtpTransport(kVideoMid1);
EXPECT_NE(nullptr, audio_rtp_transport);
@@ -402,9 +404,10 @@ TEST_F(JsepTransportControllerTest, GetDtlsTransport) {
config.rtcp_mux_policy = PeerConnectionInterface::kRtcpMuxPolicyNegotiate;
CreateJsepTransportController(std::move(config));
auto description = CreateSessionDescriptionWithoutBundle();
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
EXPECT_NE(nullptr, transport_controller_->GetDtlsTransport(kAudioMid1));
EXPECT_NE(nullptr, transport_controller_->GetRtcpDtlsTransport(kAudioMid1));
EXPECT_NE(nullptr,
@@ -425,7 +428,7 @@ TEST_F(JsepTransportControllerTest, GetDtlsTransport) {
// and verify that the resulting container is empty.
auto dtls_transport =
transport_controller_->LookupDtlsTransportByMid(kVideoMid1);
- webrtc::DtlsTransport* my_transport =
+ DtlsTransport* my_transport =
static_cast<DtlsTransport*>(dtls_transport.get());
EXPECT_NE(nullptr, my_transport->internal());
transport_controller_.reset();
@@ -437,9 +440,10 @@ TEST_F(JsepTransportControllerTest, GetDtlsTransportWithRtcpMux) {
config.rtcp_mux_policy = PeerConnectionInterface::kRtcpMuxPolicyRequire;
CreateJsepTransportController(std::move(config));
auto description = CreateSessionDescriptionWithoutBundle();
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
EXPECT_NE(nullptr, transport_controller_->GetDtlsTransport(kAudioMid1));
EXPECT_EQ(nullptr, transport_controller_->GetRtcpDtlsTransport(kAudioMid1));
EXPECT_NE(nullptr, transport_controller_->GetDtlsTransport(kVideoMid1));
@@ -449,9 +453,10 @@ TEST_F(JsepTransportControllerTest, GetDtlsTransportWithRtcpMux) {
TEST_F(JsepTransportControllerTest, SetIceConfig) {
CreateJsepTransportController(JsepTransportController::Config());
auto description = CreateSessionDescriptionWithoutBundle();
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
transport_controller_->SetIceConfig(
CreateIceConfig(kTimeout, cricket::GATHER_CONTINUALLY));
@@ -467,9 +472,10 @@ TEST_F(JsepTransportControllerTest, SetIceConfig) {
cricket::ICEMODE_FULL, cricket::CONNECTIONROLE_ACTPASS,
nullptr);
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
fake_audio_dtls = static_cast<FakeDtlsTransport*>(
transport_controller_->GetDtlsTransport(kAudioMid2));
ASSERT_NE(nullptr, fake_audio_dtls);
@@ -482,11 +488,14 @@ TEST_F(JsepTransportControllerTest, SetIceConfig) {
TEST_F(JsepTransportControllerTest, NeedIceRestart) {
CreateJsepTransportController(JsepTransportController::Config());
auto description = CreateSessionDescriptionWithoutBundle();
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
+ // TODO(tommi): Note that _now_ we set `remote`. (was not set before).
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, description.get())
+ ->SetRemoteDescription(SdpType::kAnswer, description.get(),
+ description.get())
.ok());
// Initially NeedsIceRestart should return false.
@@ -505,7 +514,8 @@ TEST_F(JsepTransportControllerTest, NeedIceRestart) {
audio_transport_info->description.ice_ufrag = kIceUfrag2;
audio_transport_info->description.ice_pwd = kIcePwd2;
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
+ ->SetLocalDescription(SdpType::kOffer, description.get(),
+ description.get())
.ok());
// Because the ICE is only restarted for audio, NeedsIceRestart is expected to
// return false for audio and true for video.
@@ -516,9 +526,10 @@ TEST_F(JsepTransportControllerTest, NeedIceRestart) {
TEST_F(JsepTransportControllerTest, MaybeStartGathering) {
CreateJsepTransportController(JsepTransportController::Config());
auto description = CreateSessionDescriptionWithBundleGroup();
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
// After setting the local description, we should be able to start gathering
// candidates.
transport_controller_->MaybeStartGathering();
@@ -529,10 +540,10 @@ TEST_F(JsepTransportControllerTest, MaybeStartGathering) {
TEST_F(JsepTransportControllerTest, AddRemoveRemoteCandidates) {
CreateJsepTransportController(JsepTransportController::Config());
auto description = CreateSessionDescriptionWithoutBundle();
- transport_controller_->SetLocalDescription(SdpType::kOffer,
- description.get());
- transport_controller_->SetRemoteDescription(SdpType::kAnswer,
- description.get());
+ transport_controller_->SetLocalDescription(SdpType::kOffer, description.get(),
+ nullptr);
+ transport_controller_->SetRemoteDescription(
+ SdpType::kAnswer, description.get(), description.get());
auto fake_audio_dtls = static_cast<FakeDtlsTransport*>(
transport_controller_->GetDtlsTransport(kAudioMid1));
ASSERT_NE(nullptr, fake_audio_dtls);
@@ -565,9 +576,10 @@ TEST_F(JsepTransportControllerTest, SetAndGetLocalCertificate) {
// Apply the local certificate.
EXPECT_TRUE(transport_controller_->SetLocalCertificate(certificate1));
// Apply the local description.
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
returned_certificate = transport_controller_->GetLocalCertificate(kAudioMid1);
EXPECT_TRUE(returned_certificate);
EXPECT_EQ(certificate1->identity()->certificate().ToPEMString(),
@@ -586,9 +598,10 @@ TEST_F(JsepTransportControllerTest, SetAndGetLocalCertificate) {
TEST_F(JsepTransportControllerTest, GetRemoteSSLCertChain) {
CreateJsepTransportController(JsepTransportController::Config());
auto description = CreateSessionDescriptionWithBundleGroup();
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
rtc::FakeSSLCertificate fake_certificate("fake_data");
auto fake_audio_dtls = static_cast<FakeDtlsTransport*>(
@@ -622,16 +635,18 @@ TEST_F(JsepTransportControllerTest, GetDtlsRole) {
cricket::ICEMODE_FULL, cricket::CONNECTIONROLE_PASSIVE,
answer_certificate);
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, offer_desc.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, offer_desc.get(), nullptr)
+ .ok());
absl::optional<rtc::SSLRole> role =
transport_controller_->GetDtlsRole(kAudioMid1);
// The DTLS role is not decided yet.
EXPECT_FALSE(role);
EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, answer_desc.get())
+ ->SetRemoteDescription(SdpType::kAnswer, offer_desc.get(),
+ answer_desc.get())
.ok());
role = transport_controller_->GetDtlsRole(kAudioMid1);
@@ -642,9 +657,10 @@ TEST_F(JsepTransportControllerTest, GetDtlsRole) {
TEST_F(JsepTransportControllerTest, GetStats) {
CreateJsepTransportController(JsepTransportController::Config());
auto description = CreateSessionDescriptionWithBundleGroup();
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
cricket::TransportStats stats;
EXPECT_TRUE(transport_controller_->GetStats(kAudioMid1, &stats));
@@ -657,9 +673,10 @@ TEST_F(JsepTransportControllerTest, GetStats) {
TEST_F(JsepTransportControllerTest, SignalConnectionStateFailed) {
CreateJsepTransportController(JsepTransportController::Config());
auto description = CreateSessionDescriptionWithoutBundle();
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
auto fake_ice = static_cast<cricket::FakeIceTransport*>(
transport_controller_->GetDtlsTransport(kAudioMid1)->ice_transport());
@@ -681,9 +698,10 @@ TEST_F(JsepTransportControllerTest,
SignalConnectionStateConnectedNoMediaTransport) {
CreateJsepTransportController(JsepTransportController::Config());
auto description = CreateSessionDescriptionWithoutBundle();
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
auto fake_audio_dtls = static_cast<FakeDtlsTransport*>(
transport_controller_->GetDtlsTransport(kAudioMid1));
@@ -729,9 +747,10 @@ TEST_F(JsepTransportControllerTest,
TEST_F(JsepTransportControllerTest, SignalConnectionStateComplete) {
CreateJsepTransportController(JsepTransportController::Config());
auto description = CreateSessionDescriptionWithoutBundle();
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
auto fake_audio_dtls = static_cast<FakeDtlsTransport*>(
transport_controller_->GetDtlsTransport(kAudioMid1));
@@ -788,9 +807,10 @@ TEST_F(JsepTransportControllerTest, SignalConnectionStateComplete) {
TEST_F(JsepTransportControllerTest, SignalIceGatheringStateGathering) {
CreateJsepTransportController(JsepTransportController::Config());
auto description = CreateSessionDescriptionWithoutBundle();
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
auto fake_audio_dtls = static_cast<FakeDtlsTransport*>(
transport_controller_->GetDtlsTransport(kAudioMid1));
@@ -803,9 +823,10 @@ TEST_F(JsepTransportControllerTest, SignalIceGatheringStateGathering) {
TEST_F(JsepTransportControllerTest, SignalIceGatheringStateComplete) {
CreateJsepTransportController(JsepTransportController::Config());
auto description = CreateSessionDescriptionWithoutBundle();
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
auto fake_audio_dtls = static_cast<FakeDtlsTransport*>(
transport_controller_->GetDtlsTransport(kAudioMid1));
@@ -838,9 +859,10 @@ TEST_F(JsepTransportControllerTest,
SignalingWhenLastIncompleteTransportDestroyed) {
CreateJsepTransportController(JsepTransportController::Config());
auto description = CreateSessionDescriptionWithBundleGroup();
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
auto fake_audio_dtls = static_cast<FakeDtlsTransport*>(
transport_controller_->GetDtlsTransport(kAudioMid1));
@@ -861,7 +883,8 @@ TEST_F(JsepTransportControllerTest,
// Set the remote description and enable the bundle.
EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, description.get())
+ ->SetRemoteDescription(SdpType::kAnswer, description.get(),
+ description.get())
.ok());
// The BUNDLE should be enabled, the incomplete video transport should be
// deleted and the states should be updated.
@@ -887,11 +910,13 @@ TEST_F(JsepTransportControllerTest,
AddAudioSection(description.get(), kAudioMid1, kIceUfrag1, kIcePwd1,
cricket::ICEMODE_FULL, cricket::CONNECTIONROLE_ACTPASS,
nullptr);
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, description.get())
+ ->SetRemoteDescription(SdpType::kAnswer, description.get(),
+ description.get())
.ok());
// Trigger and verify initial non-new states.
@@ -899,7 +924,7 @@ TEST_F(JsepTransportControllerTest,
transport_controller_->GetDtlsTransport(kAudioMid1));
fake_audio_dtls->fake_ice_transport()->MaybeStartGathering();
fake_audio_dtls->fake_ice_transport()->SetTransportState(
- webrtc::IceTransportState::kChecking,
+ IceTransportState::kChecking,
cricket::IceTransportState::STATE_CONNECTING);
EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionChecking,
ice_connection_state_, kTimeout);
@@ -914,7 +939,8 @@ TEST_F(JsepTransportControllerTest,
// to "new".
description->contents()[0].rejected = true;
EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kOffer, description.get())
+ ->SetRemoteDescription(SdpType::kOffer, description.get(),
+ description.get())
.ok());
EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionNew,
ice_connection_state_, kTimeout);
@@ -941,9 +967,10 @@ TEST_F(JsepTransportControllerTest,
TEST_F(JsepTransportControllerTest, SignalCandidatesGathered) {
CreateJsepTransportController(JsepTransportController::Config());
auto description = CreateSessionDescriptionWithBundleGroup();
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, description.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, description.get(), nullptr)
+ .ok());
transport_controller_->MaybeStartGathering();
auto fake_audio_dtls = static_cast<FakeDtlsTransport*>(
@@ -998,11 +1025,13 @@ TEST_F(JsepTransportControllerTest, IceRoleNotRedetermined) {
cricket::ICEMODE_FULL, cricket::CONNECTIONROLE_PASSIVE,
nullptr);
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetRemoteDescription(SdpType::kOffer, nullptr, remote_offer.get())
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kOffer, remote_offer.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kAnswer, local_answer.get())
+ ->SetLocalDescription(SdpType::kAnswer, local_answer.get(),
+ remote_offer.get())
.ok());
auto fake_dtls = static_cast<FakeDtlsTransport*>(
@@ -1015,10 +1044,11 @@ TEST_F(JsepTransportControllerTest, IceRoleNotRedetermined) {
AddAudioSection(restart_local_offer.get(), kAudioMid1, kIceUfrag3, kIcePwd3,
cricket::ICEMODE_FULL, cricket::CONNECTIONROLE_ACTPASS,
nullptr);
- EXPECT_TRUE(
- transport_controller_
- ->SetLocalDescription(SdpType::kOffer, restart_local_offer.get())
- .ok());
+ EXPECT_TRUE(transport_controller_
+ ->SetLocalDescription(SdpType::kOffer,
+ restart_local_offer.get(),
+ remote_offer.get())
+ .ok());
EXPECT_EQ(cricket::ICEROLE_CONTROLLED,
fake_dtls->fake_ice_transport()->GetIceRole());
}
@@ -1030,9 +1060,10 @@ TEST_F(JsepTransportControllerTest, SetIceRoleWhenIceLiteInRemoteAnswer) {
AddAudioSection(local_offer.get(), kAudioMid1, kIceUfrag1, kIcePwd1,
cricket::ICEMODE_FULL, cricket::CONNECTIONROLE_ACTPASS,
nullptr);
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
auto fake_dtls = static_cast<FakeDtlsTransport*>(
transport_controller_->GetDtlsTransport(kAudioMid1));
EXPECT_EQ(cricket::ICEROLE_CONTROLLING,
@@ -1045,7 +1076,8 @@ TEST_F(JsepTransportControllerTest, SetIceRoleWhenIceLiteInRemoteAnswer) {
cricket::ICEMODE_LITE, cricket::CONNECTIONROLE_PASSIVE,
nullptr);
EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
EXPECT_EQ(cricket::ICEROLE_CONTROLLING,
fake_dtls->fake_ice_transport()->GetIceRole());
@@ -1069,11 +1101,13 @@ TEST_F(JsepTransportControllerTest,
nullptr);
// Initial Offer/Answer exchange. If the remote offerer is ICE-Lite, then the
// local side is the controlling.
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetRemoteDescription(SdpType::kOffer, nullptr, remote_offer.get())
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kOffer, remote_offer.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kAnswer, local_answer.get())
+ ->SetLocalDescription(SdpType::kAnswer, local_answer.get(),
+ remote_offer.get())
.ok());
auto fake_dtls = static_cast<FakeDtlsTransport*>(
transport_controller_->GetDtlsTransport(kAudioMid1));
@@ -1085,15 +1119,17 @@ TEST_F(JsepTransportControllerTest,
AddAudioSection(remote_offer2.get(), kAudioMid1, kIceUfrag2, kIcePwd2,
cricket::ICEMODE_LITE, cricket::CONNECTIONROLE_ACTPASS,
nullptr);
+ EXPECT_TRUE(transport_controller_
+ ->SetRemoteDescription(SdpType::kOffer, local_answer.get(),
+ remote_offer2.get())
+ .ok());
auto local_answer2 = std::make_unique<cricket::SessionDescription>();
AddAudioSection(local_answer2.get(), kAudioMid1, kIceUfrag2, kIcePwd2,
cricket::ICEMODE_FULL, cricket::CONNECTIONROLE_PASSIVE,
nullptr);
EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kOffer, remote_offer2.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kAnswer, local_answer2.get())
+ ->SetLocalDescription(SdpType::kAnswer, local_answer2.get(),
+ remote_offer2.get())
.ok());
fake_dtls = static_cast<FakeDtlsTransport*>(
transport_controller_->GetDtlsTransport(kAudioMid1));
@@ -1145,11 +1181,13 @@ TEST_F(JsepTransportControllerTest, MultipleMediaSectionsOfSameTypeWithBundle) {
local_offer->AddGroup(bundle_group);
remote_answer->AddGroup(bundle_group);
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
// Verify that all the sections are bundled on kAudio1.
auto transport1 = transport_controller_->GetRtpTransport(kAudioMid1);
@@ -1224,11 +1262,13 @@ TEST_F(JsepTransportControllerTest, MultipleBundleGroups) {
remote_answer->AddGroup(bundle_group1);
remote_answer->AddGroup(bundle_group2);
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
// Verify that (kMid1Audio,kMid2Video) and (kMid3Audio,kMid4Video) form two
@@ -1307,11 +1347,13 @@ TEST_F(JsepTransportControllerTest,
// endpoint that does not have support for multiple BUNDLE groups.
remote_answer->AddGroup(bundle_group1);
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
// Verify that (kMid1Audio,kMid2Video) form a bundle group, but that
@@ -1382,12 +1424,14 @@ TEST_F(JsepTransportControllerTest, MultipleBundleGroupsIllegallyChangeGroup) {
remote_answer->AddGroup(answer_bundle_group2);
// Accept offer.
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
// Reject answer!
EXPECT_FALSE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
}
@@ -1445,12 +1489,14 @@ TEST_F(JsepTransportControllerTest, MultipleBundleGroupsInvalidSubsets) {
remote_answer->AddGroup(answer_bundle_group2);
// Accept offer.
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
// Reject answer!
EXPECT_FALSE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
}
@@ -1483,11 +1529,12 @@ TEST_F(JsepTransportControllerTest, MultipleBundleGroupsInvalidOverlap) {
offer->AddGroup(offer_bundle_group2);
// Reject offer, both if set as local or remote.
+ EXPECT_FALSE(transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, offer.get(), nullptr)
+ .ok());
EXPECT_FALSE(
- transport_controller_->SetLocalDescription(SdpType::kOffer, offer.get())
- .ok());
- EXPECT_FALSE(
- transport_controller_->SetRemoteDescription(SdpType::kOffer, offer.get())
+ transport_controller_
+ ->SetRemoteDescription(SdpType::kOffer, offer.get(), offer.get())
.ok());
}
@@ -1563,11 +1610,13 @@ TEST_F(JsepTransportControllerTest, MultipleBundleGroupsUnbundleFirstMid) {
remote_answer->AddGroup(answer_bundle_group1);
remote_answer->AddGroup(answer_bundle_group2);
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
auto mid1_transport = transport_controller_->GetRtpTransport(kMid1Audio);
@@ -1659,9 +1708,10 @@ TEST_F(JsepTransportControllerTest, MultipleBundleGroupsChangeFirstMid) {
remote_answer->AddGroup(answer_bundle_group1);
remote_answer->AddGroup(answer_bundle_group2);
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
// The fact that we accept this answer is actually a bug. If we accept the
// first MID to be in the group, we should also accept that it is the tagged
@@ -1669,7 +1719,8 @@ TEST_F(JsepTransportControllerTest, MultipleBundleGroupsChangeFirstMid) {
// TODO(https://crbug.com/webrtc/12699): When this issue is fixed, change this
// to EXPECT_FALSE and remove the below expectations about transports.
EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
auto mid1_transport = transport_controller_->GetRtpTransport(kMid1Audio);
auto mid2_transport = transport_controller_->GetRtpTransport(kMid2Audio);
@@ -1734,11 +1785,13 @@ TEST_F(JsepTransportControllerTest,
remote_answer->AddGroup(bundle_group1);
remote_answer->AddGroup(bundle_group2);
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
// Add kMid3Audio and kMid6Video to the respective audio/video bundle groups.
@@ -1769,7 +1822,8 @@ TEST_F(JsepTransportControllerTest,
subsequent_offer->AddGroup(bundle_group1);
subsequent_offer->AddGroup(bundle_group2);
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, subsequent_offer.get())
+ ->SetLocalDescription(SdpType::kOffer, subsequent_offer.get(),
+ remote_answer.get())
.ok());
auto mid1_transport = transport_controller_->GetRtpTransport(kMid1Audio);
auto mid2_transport = transport_controller_->GetRtpTransport(kMid2Audio);
@@ -1832,11 +1886,13 @@ TEST_F(JsepTransportControllerTest,
remote_answer->AddGroup(bundle_group1);
remote_answer->AddGroup(bundle_group2);
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
// Switch to grouping (kMid1Audio,kMid2Audio,kMid3Video,kMid4Video).
@@ -1861,10 +1917,11 @@ TEST_F(JsepTransportControllerTest,
cricket::ICEMODE_FULL, cricket::CONNECTIONROLE_ACTPASS,
nullptr);
subsequent_offer->AddGroup(new_bundle_group);
- EXPECT_FALSE(
- transport_controller_
- ->SetLocalDescription(SdpType::kOffer, subsequent_offer.get())
- .ok());
+ EXPECT_FALSE(transport_controller_
+ ->SetLocalDescription(SdpType::kOffer,
+ subsequent_offer.get(),
+ remote_answer.get())
+ .ok());
}
TEST_F(JsepTransportControllerTest,
@@ -1912,11 +1969,13 @@ TEST_F(JsepTransportControllerTest,
nullptr);
remote_answer->AddGroup(bundle_group);
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
// Switch to grouping (kMid1Audio,kMid2Audio) and (kMid3Video,kMid4Video).
@@ -1943,10 +2002,11 @@ TEST_F(JsepTransportControllerTest,
nullptr);
subsequent_offer->AddGroup(new_bundle_group1);
subsequent_offer->AddGroup(new_bundle_group2);
- EXPECT_FALSE(
- transport_controller_
- ->SetLocalDescription(SdpType::kOffer, subsequent_offer.get())
- .ok());
+ EXPECT_FALSE(transport_controller_
+ ->SetLocalDescription(SdpType::kOffer,
+ subsequent_offer.get(),
+ remote_answer.get())
+ .ok());
}
TEST_F(JsepTransportControllerTest,
@@ -1997,11 +2057,13 @@ TEST_F(JsepTransportControllerTest,
remote_answer->AddGroup(bundle_group1);
remote_answer->AddGroup(bundle_group2);
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
// Switch to grouping (kMid1Audio,kMid3Video) and (kMid2Audio,kMid3Video).
@@ -2028,10 +2090,11 @@ TEST_F(JsepTransportControllerTest,
nullptr);
subsequent_offer->AddGroup(new_bundle_group1);
subsequent_offer->AddGroup(new_bundle_group2);
- EXPECT_FALSE(
- transport_controller_
- ->SetLocalDescription(SdpType::kOffer, subsequent_offer.get())
- .ok());
+ EXPECT_FALSE(transport_controller_
+ ->SetLocalDescription(SdpType::kOffer,
+ subsequent_offer.get(),
+ remote_answer.get())
+ .ok());
}
// Tests that only a subset of all the m= sections are bundled.
@@ -2065,11 +2128,13 @@ TEST_F(JsepTransportControllerTest, BundleSubsetOfMediaSections) {
local_offer->AddGroup(bundle_group);
remote_answer->AddGroup(bundle_group);
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
// Verifiy that only `kAudio1` and `kVideo1` are bundled.
@@ -2106,11 +2171,13 @@ TEST_F(JsepTransportControllerTest, BundleOnDataSectionInSubsequentOffer) {
local_offer->AddGroup(bundle_group);
remote_answer->AddGroup(bundle_group);
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
auto data_transport = transport_controller_->GetRtpTransport(kDataMid1);
@@ -2132,15 +2199,17 @@ TEST_F(JsepTransportControllerTest, BundleOnDataSectionInSubsequentOffer) {
bundle_group.AddContentName(kAudioMid1);
bundle_group.AddContentName(kVideoMid1);
local_offer->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE);
- remote_answer->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE);
local_offer->AddGroup(bundle_group);
- remote_answer->AddGroup(bundle_group);
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(),
+ remote_answer.get())
.ok());
+ remote_answer->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE);
+ remote_answer->AddGroup(bundle_group);
EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
auto audio_transport = transport_controller_->GetRtpTransport(kAudioMid1);
@@ -2186,11 +2255,13 @@ TEST_F(JsepTransportControllerTest, VideoDataRejectedInAnswer) {
local_offer->AddGroup(bundle_group);
remote_answer->AddGroup(bundle_group);
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
// Verify the RtpTransport/DtlsTransport is destroyed correctly.
@@ -2233,11 +2304,13 @@ TEST_F(JsepTransportControllerTest, ChangeBundledMidNotSupported) {
local_offer->AddGroup(bundle_group);
remote_answer->AddGroup(bundle_group);
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
EXPECT_EQ(transport_controller_->GetRtpTransport(kAudioMid1),
transport_controller_->GetRtpTransport(kVideoMid1));
@@ -2245,15 +2318,17 @@ TEST_F(JsepTransportControllerTest, ChangeBundledMidNotSupported) {
// Reorder the bundle group.
EXPECT_TRUE(bundle_group.RemoveContentName(kAudioMid1));
bundle_group.AddContentName(kAudioMid1);
+ EXPECT_TRUE(transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(),
+ remote_answer.get())
+ .ok());
// The answerer uses the new bundle group and now the bundle mid is changed to
// `kVideo1`.
remote_answer->RemoveGroupByName(cricket::GROUP_TYPE_BUNDLE);
remote_answer->AddGroup(bundle_group);
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
EXPECT_FALSE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
}
// Test that rejecting only the first m= section of a BUNDLE group is treated as
@@ -2294,18 +2369,21 @@ TEST_F(JsepTransportControllerTest, RejectFirstContentInBundleGroup) {
local_offer->AddGroup(bundle_group);
remote_answer->AddGroup(bundle_group);
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_FALSE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
// Reject all the contents.
remote_answer->contents()[1].rejected = true;
remote_answer->contents()[2].rejected = true;
EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
EXPECT_EQ(nullptr, transport_controller_->GetRtpTransport(kAudioMid1));
EXPECT_EQ(nullptr, transport_controller_->GetRtpTransport(kVideoMid1));
@@ -2325,9 +2403,10 @@ TEST_F(JsepTransportControllerTest, ApplyNonRtcpMuxOfferWhenMuxingRequired) {
local_offer->contents()[0].media_description()->set_rtcp_mux(false);
// Applying a non-RTCP-mux offer is expected to fail.
- EXPECT_FALSE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
+ EXPECT_FALSE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
}
// Tests that applying non-RTCP-mux answer would fail when kRtcpMuxPolicyRequire
@@ -2340,9 +2419,10 @@ TEST_F(JsepTransportControllerTest, ApplyNonRtcpMuxAnswerWhenMuxingRequired) {
AddAudioSection(local_offer.get(), kAudioMid1, kIceUfrag1, kIcePwd1,
cricket::ICEMODE_FULL, cricket::CONNECTIONROLE_ACTPASS,
nullptr);
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
auto remote_answer = std::make_unique<cricket::SessionDescription>();
AddAudioSection(remote_answer.get(), kAudioMid1, kIceUfrag1, kIcePwd1,
@@ -2351,7 +2431,8 @@ TEST_F(JsepTransportControllerTest, ApplyNonRtcpMuxAnswerWhenMuxingRequired) {
// Applying a non-RTCP-mux answer is expected to fail.
remote_answer->contents()[0].media_description()->set_rtcp_mux(false);
EXPECT_FALSE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
}
@@ -2371,11 +2452,13 @@ TEST_F(JsepTransportControllerTest,
answer_bundle_group.AddContentName(kAudioMid1);
answer_bundle_group.AddContentName(kVideoMid1);
remote_answer->AddGroup(answer_bundle_group);
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_FALSE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
}
@@ -2392,11 +2475,13 @@ TEST_F(JsepTransportControllerTest, RejectBundleGroupWithNonExistingMid) {
local_offer->AddGroup(invalid_bundle_group);
remote_answer->AddGroup(invalid_bundle_group);
+ EXPECT_FALSE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_FALSE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
- EXPECT_FALSE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
}
@@ -2407,16 +2492,19 @@ TEST_F(JsepTransportControllerTest, RemoveContentFromBundleGroup) {
auto local_offer = CreateSessionDescriptionWithBundleGroup();
auto remote_answer = CreateSessionDescriptionWithBundleGroup();
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
// Do an re-offer/answer.
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(),
+ remote_answer.get())
.ok());
auto new_answer = CreateSessionDescriptionWithoutBundle();
cricket::ContentGroup new_bundle_group(cricket::GROUP_TYPE_BUNDLE);
@@ -2427,7 +2515,8 @@ TEST_F(JsepTransportControllerTest, RemoveContentFromBundleGroup) {
// Applying invalid answer is expected to fail.
EXPECT_FALSE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, new_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ new_answer.get())
.ok());
// Rejected the video content.
@@ -2435,7 +2524,8 @@ TEST_F(JsepTransportControllerTest, RemoveContentFromBundleGroup) {
ASSERT_TRUE(video_content);
video_content->rejected = true;
EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, new_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ new_answer.get())
.ok());
}
@@ -2453,14 +2543,16 @@ TEST_F(JsepTransportControllerTest, ChangeTaggedMediaSectionMaxBundle) {
cricket::ContentGroup bundle_group(cricket::GROUP_TYPE_BUNDLE);
bundle_group.AddContentName(kAudioMid1);
local_offer->AddGroup(bundle_group);
- EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
std::unique_ptr<cricket::SessionDescription> remote_answer(
local_offer->Clone());
EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
std::unique_ptr<cricket::SessionDescription> local_reoffer(
@@ -2475,14 +2567,15 @@ TEST_F(JsepTransportControllerTest, ChangeTaggedMediaSectionMaxBundle) {
local_reoffer->AddGroup(new_bundle_group);
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_reoffer.get())
+ ->SetLocalDescription(SdpType::kOffer, local_reoffer.get(),
+ remote_answer.get())
.ok());
std::unique_ptr<cricket::SessionDescription> remote_reanswer(
local_reoffer->Clone());
- EXPECT_TRUE(
- transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_reanswer.get())
- .ok());
+ EXPECT_TRUE(transport_controller_
+ ->SetRemoteDescription(SdpType::kAnswer, local_reoffer.get(),
+ remote_reanswer.get())
+ .ok());
}
TEST_F(JsepTransportControllerTest, RollbackRestoresRejectedTransport) {
@@ -2496,11 +2589,13 @@ TEST_F(JsepTransportControllerTest, RollbackRestoresRejectedTransport) {
nullptr);
std::unique_ptr<cricket::SessionDescription> remote_answer(
local_offer->Clone());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
auto mid1_transport = transport_controller_->GetRtpTransport(kMid1Audio);
@@ -2514,7 +2609,8 @@ TEST_F(JsepTransportControllerTest, RollbackRestoresRejectedTransport) {
local_reoffer->contents()[0].rejected = true;
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_reoffer.get())
+ ->SetLocalDescription(SdpType::kOffer, local_reoffer.get(),
+ remote_answer.get())
.ok());
auto old_mid1_transport = mid1_transport;
mid1_transport = transport_controller_->GetRtpTransport(kMid1Audio);
@@ -2556,11 +2652,13 @@ TEST_F(JsepTransportControllerTest, RollbackRestoresPreviousTransportMapping) {
std::unique_ptr<cricket::SessionDescription> remote_answer(
local_offer->Clone());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
auto mid1_transport = transport_controller_->GetRtpTransport(kMid1Audio);
@@ -2585,7 +2683,8 @@ TEST_F(JsepTransportControllerTest, RollbackRestoresPreviousTransportMapping) {
local_reoffer->AddGroup(bundle_group);
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_reoffer.get())
+ ->SetLocalDescription(SdpType::kOffer, local_reoffer.get(),
+ remote_answer.get())
.ok());
// Store the old transport pointer and verify that the offer actually changed
@@ -2633,11 +2732,13 @@ TEST_F(JsepTransportControllerTest, RollbackAndAddToDifferentBundleGroup) {
std::unique_ptr<cricket::SessionDescription> remote_answer(
local_offer->Clone());
+ EXPECT_TRUE(
+ transport_controller_
+ ->SetLocalDescription(SdpType::kOffer, local_offer.get(), nullptr)
+ .ok());
EXPECT_TRUE(transport_controller_
- ->SetLocalDescription(SdpType::kOffer, local_offer.get())
- .ok());
- EXPECT_TRUE(transport_controller_
- ->SetRemoteDescription(SdpType::kAnswer, remote_answer.get())
+ ->SetRemoteDescription(SdpType::kAnswer, local_offer.get(),
+ remote_answer.get())
.ok());
// Apply an offer that adds kMid3Audio to the first BUNDLE group.,
@@ -2657,10 +2758,11 @@ TEST_F(JsepTransportControllerTest, RollbackAndAddToDifferentBundleGroup) {
subsequent_offer_1->AddGroup(modified_bundle_group1);
subsequent_offer_1->AddGroup(bundle_group2);
- EXPECT_TRUE(
- transport_controller_
- ->SetLocalDescription(SdpType::kOffer, subsequent_offer_1.get())
- .ok());
+ EXPECT_TRUE(transport_controller_
+ ->SetLocalDescription(SdpType::kOffer,
+ subsequent_offer_1.get(),
+ remote_answer.get())
+ .ok());
auto mid1_transport = transport_controller_->GetRtpTransport(kMid1Audio);
auto mid2_transport = transport_controller_->GetRtpTransport(kMid2Audio);
@@ -2689,10 +2791,11 @@ TEST_F(JsepTransportControllerTest, RollbackAndAddToDifferentBundleGroup) {
subsequent_offer_2->AddGroup(bundle_group1);
subsequent_offer_2->AddGroup(modified_bundle_group2);
- EXPECT_TRUE(
- transport_controller_
- ->SetLocalDescription(SdpType::kOffer, subsequent_offer_2.get())
- .ok());
+ EXPECT_TRUE(transport_controller_
+ ->SetLocalDescription(SdpType::kOffer,
+ subsequent_offer_2.get(),
+ remote_answer.get())
+ .ok());
mid1_transport = transport_controller_->GetRtpTransport(kMid1Audio);
mid2_transport = transport_controller_->GetRtpTransport(kMid2Audio);
@@ -2722,9 +2825,9 @@ TEST_F(JsepTransportControllerTest, BundleOnlySectionDoesNotNeedRtcpMux) {
offer->contents()[1].media_description()->set_rtcp_mux(false);
offer->contents()[1].bundle_only = true;
- EXPECT_TRUE(
- transport_controller_->SetRemoteDescription(SdpType::kOffer, offer.get())
- .ok());
+ EXPECT_TRUE(transport_controller_
+ ->SetRemoteDescription(SdpType::kOffer, nullptr, offer.get())
+ .ok());
}
// Test that with max-bundle a single unbundled m-line is accepted.
@@ -2738,9 +2841,9 @@ TEST_F(JsepTransportControllerTest,
AddAudioSection(offer.get(), kAudioMid1, kIceUfrag1, kIcePwd1,
cricket::ICEMODE_FULL, cricket::CONNECTIONROLE_ACTPASS,
nullptr);
- EXPECT_TRUE(
- transport_controller_->SetRemoteDescription(SdpType::kOffer, offer.get())
- .ok());
+ EXPECT_TRUE(transport_controller_
+ ->SetRemoteDescription(SdpType::kOffer, nullptr, offer.get())
+ .ok());
}
} // namespace webrtc
diff --git a/third_party/libwebrtc/pc/legacy_stats_collector.cc b/third_party/libwebrtc/pc/legacy_stats_collector.cc
index 3bc65ee3ee..98b7cb9677 100644
--- a/third_party/libwebrtc/pc/legacy_stats_collector.cc
+++ b/third_party/libwebrtc/pc/legacy_stats_collector.cc
@@ -355,9 +355,8 @@ void ExtractStats(const cricket::VideoReceiverInfo& info,
report->AddInt64(StatsReport::kStatsValueNameInterframeDelayMaxMs,
info.interframe_delay_max_ms);
- report->AddString(
- StatsReport::kStatsValueNameContentType,
- webrtc::videocontenttypehelpers::ToString(info.content_type));
+ report->AddString(StatsReport::kStatsValueNameContentType,
+ videocontenttypehelpers::ToString(info.content_type));
}
void ExtractStats(const cricket::VideoSenderInfo& info,
@@ -398,9 +397,8 @@ void ExtractStats(const cricket::VideoSenderInfo& info,
for (const auto& i : ints)
report->AddInt(i.name, i.value);
report->AddString(StatsReport::kStatsValueNameMediaType, "video");
- report->AddString(
- StatsReport::kStatsValueNameContentType,
- webrtc::videocontenttypehelpers::ToString(info.content_type));
+ report->AddString(StatsReport::kStatsValueNameContentType,
+ videocontenttypehelpers::ToString(info.content_type));
}
void ExtractStats(const cricket::BandwidthEstimationInfo& info,
@@ -1033,7 +1031,7 @@ void LegacyStatsCollector::ExtractBweInfo() {
if (pc_->signaling_state() == PeerConnectionInterface::kClosed)
return;
- webrtc::Call::Stats call_stats = pc_->GetCallStats();
+ Call::Stats call_stats = pc_->GetCallStats();
cricket::BandwidthEstimationInfo bwe_info;
bwe_info.available_send_bandwidth = call_stats.send_bandwidth_bps;
bwe_info.available_recv_bandwidth = call_stats.recv_bandwidth_bps;
diff --git a/third_party/libwebrtc/pc/legacy_stats_collector.h b/third_party/libwebrtc/pc/legacy_stats_collector.h
index e905b39d48..1c7aad0636 100644
--- a/third_party/libwebrtc/pc/legacy_stats_collector.h
+++ b/third_party/libwebrtc/pc/legacy_stats_collector.h
@@ -177,9 +177,9 @@ class LegacyStatsCollector : public LegacyStatsCollectorInterface {
void ExtractMediaInfo(
const std::map<std::string, std::string>& transport_names_by_mid);
void ExtractSenderInfo();
- webrtc::StatsReport* GetReport(const StatsReport::StatsType& type,
- const std::string& id,
- StatsReport::Direction direction);
+ StatsReport* GetReport(const StatsReport::StatsType& type,
+ const std::string& id,
+ StatsReport::Direction direction);
// Helper method to get stats from the local audio tracks.
void UpdateStatsFromExistingLocalAudioTracks(bool has_remote_tracks);
diff --git a/third_party/libwebrtc/pc/media_factory.h b/third_party/libwebrtc/pc/media_factory.h
new file mode 100644
index 0000000000..c86784632e
--- /dev/null
+++ b/third_party/libwebrtc/pc/media_factory.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2023 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef PC_MEDIA_FACTORY_H_
+#define PC_MEDIA_FACTORY_H_
+
+#include <memory>
+
+#include "api/environment/environment.h"
+#include "call/call.h"
+#include "call/call_config.h"
+#include "media/base/media_engine.h"
+
+namespace webrtc {
+
+// PeerConnectionFactoryDependencies is forward declared because of circular
+// dependency between MediaFactory and PeerConnectionFactoryDependencies:
+// PeerConnectionFactoryDependencies keeps an instance of MediaFactory and thus
+// needs to know how to destroy it.
+// MediaFactory mentions PeerConnectionFactoryDependencies in api, but does not
+// need its full definition.
+struct PeerConnectionFactoryDependencies;
+
+// Interface repsponsible for constructing media specific classes for
+// PeerConnectionFactory and PeerConnection.
+class MediaFactory {
+ public:
+ virtual ~MediaFactory() = default;
+
+ virtual std::unique_ptr<Call> CreateCall(const CallConfig& config) = 0;
+ virtual std::unique_ptr<cricket::MediaEngineInterface> CreateMediaEngine(
+ const Environment& env,
+ PeerConnectionFactoryDependencies& dependencies) = 0;
+};
+
+} // namespace webrtc
+
+#endif // PC_MEDIA_FACTORY_H_
diff --git a/third_party/libwebrtc/pc/media_session.cc b/third_party/libwebrtc/pc/media_session.cc
index a763919c16..573e35225e 100644
--- a/third_party/libwebrtc/pc/media_session.cc
+++ b/third_party/libwebrtc/pc/media_session.cc
@@ -117,52 +117,38 @@ namespace cricket {
namespace {
-bool IsRtxCodec(const Codec& codec) {
- return absl::EqualsIgnoreCase(codec.name, kRtxCodecName);
-}
-
bool IsRtxCodec(const webrtc::RtpCodecCapability& capability) {
return absl::EqualsIgnoreCase(capability.name, kRtxCodecName);
}
bool ContainsRtxCodec(const std::vector<Codec>& codecs) {
- for (const auto& codec : codecs) {
- if (IsRtxCodec(codec)) {
- return true;
- }
- }
- return false;
-}
-
-bool IsRedCodec(const Codec& codec) {
- return absl::EqualsIgnoreCase(codec.name, kRedCodecName);
+ return absl::c_find_if(codecs, [](const Codec& c) {
+ return c.GetResiliencyType() == Codec::ResiliencyType::kRtx;
+ }) != codecs.end();
}
bool IsRedCodec(const webrtc::RtpCodecCapability& capability) {
return absl::EqualsIgnoreCase(capability.name, kRedCodecName);
}
-bool IsFlexfecCodec(const Codec& codec) {
- return absl::EqualsIgnoreCase(codec.name, kFlexfecCodecName);
-}
-
bool ContainsFlexfecCodec(const std::vector<Codec>& codecs) {
- for (const auto& codec : codecs) {
- if (IsFlexfecCodec(codec)) {
- return true;
- }
- }
- return false;
-}
-
-bool IsUlpfecCodec(const Codec& codec) {
- return absl::EqualsIgnoreCase(codec.name, kUlpfecCodecName);
+ return absl::c_find_if(codecs, [](const Codec& c) {
+ return c.GetResiliencyType() == Codec::ResiliencyType::kFlexfec;
+ }) != codecs.end();
}
bool IsComfortNoiseCodec(const Codec& codec) {
return absl::EqualsIgnoreCase(codec.name, kComfortNoiseCodecName);
}
+void StripCNCodecs(AudioCodecs* audio_codecs) {
+ audio_codecs->erase(std::remove_if(audio_codecs->begin(), audio_codecs->end(),
+ [](const AudioCodec& codec) {
+ return IsComfortNoiseCodec(codec);
+ }),
+ audio_codecs->end());
+}
+
RtpTransceiverDirection NegotiateRtpTransceiverDirection(
RtpTransceiverDirection offer,
RtpTransceiverDirection wants) {
@@ -727,12 +713,10 @@ RTCError CreateMediaContentOffer(
bool ReferencedCodecsMatch(const std::vector<Codec>& codecs1,
const int codec1_id,
const std::vector<Codec>& codecs2,
- const int codec2_id,
- const webrtc::FieldTrialsView* field_trials) {
+ const int codec2_id) {
const Codec* codec1 = FindCodecById(codecs1, codec1_id);
const Codec* codec2 = FindCodecById(codecs2, codec2_id);
- return codec1 != nullptr && codec2 != nullptr &&
- codec1->Matches(*codec2, field_trials);
+ return codec1 != nullptr && codec2 != nullptr && codec1->Matches(*codec2);
}
void NegotiatePacketization(const Codec& local_codec,
@@ -747,11 +731,9 @@ void NegotiatePacketization(const Codec& local_codec,
// Finds a codec in `codecs2` that matches `codec_to_match`, which is
// a member of `codecs1`. If `codec_to_match` is an RED or RTX codec, both
// the codecs themselves and their associated codecs must match.
-absl::optional<Codec> FindMatchingCodec(
- const std::vector<Codec>& codecs1,
- const std::vector<Codec>& codecs2,
- const Codec& codec_to_match,
- const webrtc::FieldTrialsView* field_trials) {
+absl::optional<Codec> FindMatchingCodec(const std::vector<Codec>& codecs1,
+ const std::vector<Codec>& codecs2,
+ const Codec& codec_to_match) {
// `codec_to_match` should be a member of `codecs1`, in order to look up
// RED/RTX codecs' associated codecs correctly. If not, that's a programming
// error.
@@ -759,8 +741,8 @@ absl::optional<Codec> FindMatchingCodec(
return &codec == &codec_to_match;
}));
for (const Codec& potential_match : codecs2) {
- if (potential_match.Matches(codec_to_match, field_trials)) {
- if (IsRtxCodec(codec_to_match)) {
+ if (potential_match.Matches(codec_to_match)) {
+ if (codec_to_match.GetResiliencyType() == Codec::ResiliencyType::kRtx) {
int apt_value_1 = 0;
int apt_value_2 = 0;
if (!codec_to_match.GetParam(kCodecParamAssociatedPayloadType,
@@ -770,11 +752,12 @@ absl::optional<Codec> FindMatchingCodec(
RTC_LOG(LS_WARNING) << "RTX missing associated payload type.";
continue;
}
- if (!ReferencedCodecsMatch(codecs1, apt_value_1, codecs2, apt_value_2,
- field_trials)) {
+ if (!ReferencedCodecsMatch(codecs1, apt_value_1, codecs2,
+ apt_value_2)) {
continue;
}
- } else if (IsRedCodec(codec_to_match)) {
+ } else if (codec_to_match.GetResiliencyType() ==
+ Codec::ResiliencyType::kRed) {
auto red_parameters_1 =
codec_to_match.params.find(kCodecParamNotInNameValueFormat);
auto red_parameters_2 =
@@ -814,7 +797,7 @@ absl::optional<Codec> FindMatchingCodec(
if (rtc::FromString(redundant_payloads_1[0], &red_value_1) &&
rtc::FromString(redundant_payloads_2[0], &red_value_2)) {
if (!ReferencedCodecsMatch(codecs1, red_value_1, codecs2,
- red_value_2, field_trials)) {
+ red_value_2)) {
continue;
}
}
@@ -832,18 +815,17 @@ absl::optional<Codec> FindMatchingCodec(
void NegotiateCodecs(const std::vector<Codec>& local_codecs,
const std::vector<Codec>& offered_codecs,
std::vector<Codec>* negotiated_codecs,
- bool keep_offer_order,
- const webrtc::FieldTrialsView* field_trials) {
+ bool keep_offer_order) {
for (const Codec& ours : local_codecs) {
absl::optional<Codec> theirs =
- FindMatchingCodec(local_codecs, offered_codecs, ours, field_trials);
+ FindMatchingCodec(local_codecs, offered_codecs, ours);
// Note that we intentionally only find one matching codec for each of our
// local codecs, in case the remote offer contains duplicate codecs.
if (theirs) {
Codec negotiated = ours;
NegotiatePacketization(ours, *theirs, &negotiated);
negotiated.IntersectFeedbackParams(*theirs);
- if (IsRtxCodec(negotiated)) {
+ if (negotiated.GetResiliencyType() == Codec::ResiliencyType::kRtx) {
const auto apt_it =
theirs->params.find(kCodecParamAssociatedPayloadType);
// FindMatchingCodec shouldn't return something with no apt value.
@@ -855,7 +837,8 @@ void NegotiateCodecs(const std::vector<Codec>& local_codecs,
if (rtx_time_it != theirs->params.end()) {
negotiated.SetParam(kCodecParamRtxTime, rtx_time_it->second);
}
- } else if (IsRedCodec(negotiated)) {
+ } else if (negotiated.GetResiliencyType() ==
+ Codec::ResiliencyType::kRed) {
const auto red_it =
theirs->params.find(kCodecParamNotInNameValueFormat);
if (red_it != theirs->params.end()) {
@@ -960,15 +943,15 @@ const Codec* GetAssociatedCodecForRed(const std::vector<Codec>& codec_list,
// collide.
void MergeCodecs(const std::vector<Codec>& reference_codecs,
std::vector<Codec>* offered_codecs,
- UsedPayloadTypes* used_pltypes,
- const webrtc::FieldTrialsView* field_trials) {
+ UsedPayloadTypes* used_pltypes) {
// Add all new codecs that are not RTX/RED codecs.
// The two-pass splitting of the loops means preferring payload types
// of actual codecs with respect to collisions.
for (const Codec& reference_codec : reference_codecs) {
- if (!IsRtxCodec(reference_codec) && !IsRedCodec(reference_codec) &&
- !FindMatchingCodec(reference_codecs, *offered_codecs, reference_codec,
- field_trials)) {
+ if (reference_codec.GetResiliencyType() != Codec::ResiliencyType::kRtx &&
+ reference_codec.GetResiliencyType() != Codec::ResiliencyType::kRed &&
+ !FindMatchingCodec(reference_codecs, *offered_codecs,
+ reference_codec)) {
Codec codec = reference_codec;
used_pltypes->FindAndSetIdUsed(&codec);
offered_codecs->push_back(codec);
@@ -977,9 +960,9 @@ void MergeCodecs(const std::vector<Codec>& reference_codecs,
// Add all new RTX or RED codecs.
for (const Codec& reference_codec : reference_codecs) {
- if (IsRtxCodec(reference_codec) &&
- !FindMatchingCodec(reference_codecs, *offered_codecs, reference_codec,
- field_trials)) {
+ if (reference_codec.GetResiliencyType() == Codec::ResiliencyType::kRtx &&
+ !FindMatchingCodec(reference_codecs, *offered_codecs,
+ reference_codec)) {
Codec rtx_codec = reference_codec;
const Codec* associated_codec =
GetAssociatedCodecForRtx(reference_codecs, rtx_codec);
@@ -989,7 +972,7 @@ void MergeCodecs(const std::vector<Codec>& reference_codecs,
// Find a codec in the offered list that matches the reference codec.
// Its payload type may be different than the reference codec.
absl::optional<Codec> matching_codec = FindMatchingCodec(
- reference_codecs, *offered_codecs, *associated_codec, field_trials);
+ reference_codecs, *offered_codecs, *associated_codec);
if (!matching_codec) {
RTC_LOG(LS_WARNING)
<< "Couldn't find matching " << associated_codec->name << " codec.";
@@ -1000,15 +983,16 @@ void MergeCodecs(const std::vector<Codec>& reference_codecs,
rtc::ToString(matching_codec->id);
used_pltypes->FindAndSetIdUsed(&rtx_codec);
offered_codecs->push_back(rtx_codec);
- } else if (IsRedCodec(reference_codec) &&
+ } else if (reference_codec.GetResiliencyType() ==
+ Codec::ResiliencyType::kRed &&
!FindMatchingCodec(reference_codecs, *offered_codecs,
- reference_codec, field_trials)) {
+ reference_codec)) {
Codec red_codec = reference_codec;
const Codec* associated_codec =
GetAssociatedCodecForRed(reference_codecs, red_codec);
if (associated_codec) {
absl::optional<Codec> matching_codec = FindMatchingCodec(
- reference_codecs, *offered_codecs, *associated_codec, field_trials);
+ reference_codecs, *offered_codecs, *associated_codec);
if (!matching_codec) {
RTC_LOG(LS_WARNING) << "Couldn't find matching "
<< associated_codec->name << " codec.";
@@ -1032,8 +1016,7 @@ void MergeCodecs(const std::vector<Codec>& reference_codecs,
std::vector<Codec> MatchCodecPreference(
const std::vector<webrtc::RtpCodecCapability>& codec_preferences,
const std::vector<Codec>& codecs,
- const std::vector<Codec>& supported_codecs,
- const webrtc::FieldTrialsView* field_trials) {
+ const std::vector<Codec>& supported_codecs) {
std::vector<Codec> filtered_codecs;
bool want_rtx = false;
bool want_red = false;
@@ -1060,12 +1043,13 @@ std::vector<Codec> MatchCodecPreference(
});
if (found_codec != supported_codecs.end()) {
- absl::optional<Codec> found_codec_with_correct_pt = FindMatchingCodec(
- supported_codecs, codecs, *found_codec, field_trials);
+ absl::optional<Codec> found_codec_with_correct_pt =
+ FindMatchingCodec(supported_codecs, codecs, *found_codec);
if (found_codec_with_correct_pt) {
// RED may already have been added if its primary codec is before RED
// in the codec list.
- bool is_red_codec = IsRedCodec(*found_codec_with_correct_pt);
+ bool is_red_codec = found_codec_with_correct_pt->GetResiliencyType() ==
+ Codec::ResiliencyType::kRed;
if (!is_red_codec || !red_was_added) {
filtered_codecs.push_back(*found_codec_with_correct_pt);
red_was_added = is_red_codec ? true : red_was_added;
@@ -1074,14 +1058,15 @@ std::vector<Codec> MatchCodecPreference(
// Search for the matching rtx or red codec.
if (want_red || want_rtx) {
for (const auto& codec : codecs) {
- if (IsRtxCodec(codec)) {
+ if (codec.GetResiliencyType() == Codec::ResiliencyType::kRtx) {
const auto apt =
codec.params.find(cricket::kCodecParamAssociatedPayloadType);
if (apt != codec.params.end() && apt->second == id) {
filtered_codecs.push_back(codec);
break;
}
- } else if (IsRedCodec(codec)) {
+ } else if (codec.GetResiliencyType() ==
+ Codec::ResiliencyType::kRed) {
// For RED, do not insert the codec again if it was already
// inserted. audio/red for opus gets enabled by having RED before
// the primary codec.
@@ -1110,10 +1095,8 @@ std::vector<Codec> MatchCodecPreference(
}
// Compute the union of `codecs1` and `codecs2`.
-std::vector<Codec> ComputeCodecsUnion(
- const std::vector<Codec>& codecs1,
- const std::vector<Codec>& codecs2,
- const webrtc::FieldTrialsView* field_trials) {
+std::vector<Codec> ComputeCodecsUnion(const std::vector<Codec>& codecs1,
+ const std::vector<Codec>& codecs2) {
std::vector<Codec> all_codecs;
UsedPayloadTypes used_payload_types;
for (const Codec& codec : codecs1) {
@@ -1124,7 +1107,7 @@ std::vector<Codec> ComputeCodecsUnion(
// Use MergeCodecs to merge the second half of our list as it already checks
// and fixes problems with duplicate payload types.
- MergeCodecs(codecs2, &all_codecs, &used_payload_types, field_trials);
+ MergeCodecs(codecs2, &all_codecs, &used_payload_types);
return all_codecs;
}
@@ -1333,14 +1316,6 @@ void NegotiateRtpHeaderExtensions(const RtpHeaderExtensions& local_extensions,
}
}
-void StripCNCodecs(AudioCodecs* audio_codecs) {
- audio_codecs->erase(std::remove_if(audio_codecs->begin(), audio_codecs->end(),
- [](const AudioCodec& codec) {
- return IsComfortNoiseCodec(codec);
- }),
- audio_codecs->end());
-}
-
bool SetCodecsInAnswer(const MediaContentDescription* offer,
const std::vector<Codec>& local_codecs,
const MediaDescriptionOptions& media_description_options,
@@ -1353,8 +1328,7 @@ bool SetCodecsInAnswer(const MediaContentDescription* offer,
offer->type() == MEDIA_TYPE_VIDEO);
std::vector<Codec> negotiated_codecs;
NegotiateCodecs(local_codecs, offer->codecs(), &negotiated_codecs,
- media_description_options.codec_preferences.empty(),
- &field_trials);
+ media_description_options.codec_preferences.empty());
answer->AddCodecs(negotiated_codecs);
answer->set_protocol(offer->protocol());
if (!AddStreamParams(media_description_options.sender_options,
@@ -1512,6 +1486,145 @@ bool IsDtlsActive(const ContentInfo* content,
.description.secure();
}
+webrtc::RTCErrorOr<AudioCodecs> GetNegotiatedCodecsForOffer(
+ const MediaDescriptionOptions& media_description_options,
+ const MediaSessionOptions& session_options,
+ const ContentInfo* current_content,
+ const std::vector<Codec>& codecs,
+ const std::vector<Codec>& supported_codecs) {
+ std::vector<Codec> filtered_codecs;
+ if (!media_description_options.codec_preferences.empty()) {
+ // Add the codecs from the current transceiver's codec preferences.
+ // They override any existing codecs from previous negotiations.
+ filtered_codecs = MatchCodecPreference(
+ media_description_options.codec_preferences, codecs, supported_codecs);
+ } else {
+ // Add the codecs from current content if it exists and is not rejected nor
+ // recycled.
+ if (current_content && !current_content->rejected &&
+ current_content->name == media_description_options.mid) {
+ if (!IsMediaContentOfType(current_content,
+ media_description_options.type)) {
+ // Can happen if the remote side re-uses a MID while recycling.
+ LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR,
+ "Media type for content with mid='" +
+ current_content->name +
+ "' does not match previous type.");
+ }
+ const MediaContentDescription* mcd = current_content->media_description();
+ for (const Codec& codec : mcd->codecs()) {
+ if (FindMatchingCodec(mcd->codecs(), codecs, codec)) {
+ filtered_codecs.push_back(codec);
+ }
+ }
+ }
+ // Add other supported codecs.
+ for (const Codec& codec : supported_codecs) {
+ absl::optional<Codec> found_codec =
+ FindMatchingCodec(supported_codecs, codecs, codec);
+ if (found_codec &&
+ !FindMatchingCodec(supported_codecs, filtered_codecs, codec)) {
+ // Use the `found_codec` from `codecs` because it has the
+ // correctly mapped payload type.
+ // This is only done for video since we do not yet have rtx for audio.
+ if (media_description_options.type == MEDIA_TYPE_VIDEO &&
+ found_codec->GetResiliencyType() == Codec::ResiliencyType::kRtx) {
+ // For RTX we might need to adjust the apt parameter if we got a
+ // remote offer without RTX for a codec for which we support RTX.
+ auto referenced_codec =
+ GetAssociatedCodecForRtx(supported_codecs, codec);
+ RTC_DCHECK(referenced_codec);
+
+ // Find the codec we should be referencing and point to it.
+ absl::optional<Codec> changed_referenced_codec = FindMatchingCodec(
+ supported_codecs, filtered_codecs, *referenced_codec);
+ if (changed_referenced_codec) {
+ found_codec->SetParam(kCodecParamAssociatedPayloadType,
+ changed_referenced_codec->id);
+ }
+ }
+ filtered_codecs.push_back(*found_codec);
+ }
+ }
+ }
+
+ if (media_description_options.type == MEDIA_TYPE_AUDIO &&
+ !session_options.vad_enabled) {
+ // If application doesn't want CN codecs in offer.
+ StripCNCodecs(&filtered_codecs);
+ } else if (media_description_options.type == MEDIA_TYPE_VIDEO &&
+ session_options.raw_packetization_for_video) {
+ for (Codec& codec : filtered_codecs) {
+ if (codec.IsMediaCodec()) {
+ codec.packetization = kPacketizationParamRaw;
+ }
+ }
+ }
+ return filtered_codecs;
+}
+
+webrtc::RTCErrorOr<AudioCodecs> GetNegotiatedCodecsForAnswer(
+ const MediaDescriptionOptions& media_description_options,
+ const MediaSessionOptions& session_options,
+ const ContentInfo* current_content,
+ const std::vector<Codec>& codecs,
+ const std::vector<Codec>& supported_codecs) {
+ std::vector<Codec> filtered_codecs;
+
+ if (!media_description_options.codec_preferences.empty()) {
+ filtered_codecs = MatchCodecPreference(
+ media_description_options.codec_preferences, codecs, supported_codecs);
+ } else {
+ // Add the codecs from current content if it exists and is not rejected nor
+ // recycled.
+ if (current_content && !current_content->rejected &&
+ current_content->name == media_description_options.mid) {
+ if (!IsMediaContentOfType(current_content,
+ media_description_options.type)) {
+ // Can happen if the remote side re-uses a MID while recycling.
+ LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR,
+ "Media type for content with mid='" +
+ current_content->name +
+ "' does not match previous type.");
+ }
+ const MediaContentDescription* mcd = current_content->media_description();
+ for (const Codec& codec : mcd->codecs()) {
+ if (FindMatchingCodec(mcd->codecs(), codecs, codec)) {
+ filtered_codecs.push_back(codec);
+ }
+ }
+ }
+ // Add other supported video codecs.
+ std::vector<Codec> other_codecs;
+ for (const Codec& codec : supported_codecs) {
+ if (FindMatchingCodec(supported_codecs, codecs, codec) &&
+ !FindMatchingCodec(supported_codecs, filtered_codecs, codec)) {
+ // We should use the local codec with local parameters and the codec id
+ // would be correctly mapped in `NegotiateCodecs`.
+ other_codecs.push_back(codec);
+ }
+ }
+
+ // Use ComputeCodecsUnion to avoid having duplicate payload IDs.
+ // This is a no-op for audio until RTX is added.
+ filtered_codecs = ComputeCodecsUnion(filtered_codecs, other_codecs);
+ }
+
+ if (media_description_options.type == MEDIA_TYPE_AUDIO &&
+ !session_options.vad_enabled) {
+ // If application doesn't want CN codecs in offer.
+ StripCNCodecs(&filtered_codecs);
+ } else if (media_description_options.type == MEDIA_TYPE_VIDEO &&
+ session_options.raw_packetization_for_video) {
+ for (Codec& codec : filtered_codecs) {
+ if (codec.IsMediaCodec()) {
+ codec.packetization = kPacketizationParamRaw;
+ }
+ }
+ }
+ return filtered_codecs;
+}
+
} // namespace
void MediaDescriptionOptions::AddAudioSender(
@@ -1683,15 +1796,16 @@ MediaSessionDescriptionFactory::CreateOfferOrError(
RTCError error;
switch (media_description_options.type) {
case MEDIA_TYPE_AUDIO:
- error = AddAudioContentForOffer(
- media_description_options, session_options, current_content,
- current_description, extensions_with_ids.audio, offer_audio_codecs,
- &current_streams, offer.get(), &ice_credentials);
- break;
case MEDIA_TYPE_VIDEO:
- error = AddVideoContentForOffer(
+ error = AddRtpContentForOffer(
media_description_options, session_options, current_content,
- current_description, extensions_with_ids.video, offer_video_codecs,
+ current_description,
+ media_description_options.type == MEDIA_TYPE_AUDIO
+ ? extensions_with_ids.audio
+ : extensions_with_ids.video,
+ media_description_options.type == MEDIA_TYPE_AUDIO
+ ? offer_audio_codecs
+ : offer_video_codecs,
&current_streams, offer.get(), &ice_credentials);
break;
case MEDIA_TYPE_DATA:
@@ -1852,18 +1966,15 @@ MediaSessionDescriptionFactory::CreateAnswerOrError(
RTCError error;
switch (media_description_options.type) {
case MEDIA_TYPE_AUDIO:
- error = AddAudioContentForAnswer(
- media_description_options, session_options, offer_content, offer,
- current_content, current_description, bundle_transport,
- answer_audio_codecs, header_extensions, &current_streams,
- answer.get(), &ice_credentials);
- break;
case MEDIA_TYPE_VIDEO:
- error = AddVideoContentForAnswer(
+ error = AddRtpContentForAnswer(
media_description_options, session_options, offer_content, offer,
current_content, current_description, bundle_transport,
- answer_video_codecs, header_extensions, &current_streams,
- answer.get(), &ice_credentials);
+ media_description_options.type == MEDIA_TYPE_AUDIO
+ ? answer_audio_codecs
+ : answer_video_codecs,
+ header_extensions, &current_streams, answer.get(),
+ &ice_credentials);
break;
case MEDIA_TYPE_DATA:
error = AddDataContentForAnswer(
@@ -2035,15 +2146,14 @@ void MergeCodecsFromDescription(
const std::vector<const ContentInfo*>& current_active_contents,
AudioCodecs* audio_codecs,
VideoCodecs* video_codecs,
- UsedPayloadTypes* used_pltypes,
- const webrtc::FieldTrialsView* field_trials) {
+ UsedPayloadTypes* used_pltypes) {
for (const ContentInfo* content : current_active_contents) {
if (IsMediaContentOfType(content, MEDIA_TYPE_AUDIO)) {
MergeCodecs(content->media_description()->codecs(), audio_codecs,
- used_pltypes, field_trials);
+ used_pltypes);
} else if (IsMediaContentOfType(content, MEDIA_TYPE_VIDEO)) {
MergeCodecs(content->media_description()->codecs(), video_codecs,
- used_pltypes, field_trials);
+ used_pltypes);
}
}
}
@@ -2058,18 +2168,16 @@ void MediaSessionDescriptionFactory::GetCodecsForOffer(
const std::vector<const ContentInfo*>& current_active_contents,
AudioCodecs* audio_codecs,
VideoCodecs* video_codecs) const {
- const webrtc::FieldTrialsView* field_trials =
- &transport_desc_factory_->trials();
// First - get all codecs from the current description if the media type
// is used. Add them to `used_pltypes` so the payload type is not reused if a
// new media type is added.
UsedPayloadTypes used_pltypes;
MergeCodecsFromDescription(current_active_contents, audio_codecs,
- video_codecs, &used_pltypes, field_trials);
+ video_codecs, &used_pltypes);
// Add our codecs that are not in the current description.
- MergeCodecs(all_audio_codecs_, audio_codecs, &used_pltypes, field_trials);
- MergeCodecs(all_video_codecs_, video_codecs, &used_pltypes, field_trials);
+ MergeCodecs(all_audio_codecs_, audio_codecs, &used_pltypes);
+ MergeCodecs(all_video_codecs_, video_codecs, &used_pltypes);
}
// Getting codecs for an answer involves these steps:
@@ -2084,14 +2192,12 @@ void MediaSessionDescriptionFactory::GetCodecsForAnswer(
const SessionDescription& remote_offer,
AudioCodecs* audio_codecs,
VideoCodecs* video_codecs) const {
- const webrtc::FieldTrialsView* field_trials =
- &transport_desc_factory_->trials();
// First - get all codecs from the current description if the media type
// is used. Add them to `used_pltypes` so the payload type is not reused if a
// new media type is added.
UsedPayloadTypes used_pltypes;
MergeCodecsFromDescription(current_active_contents, audio_codecs,
- video_codecs, &used_pltypes, field_trials);
+ video_codecs, &used_pltypes);
// Second - filter out codecs that we don't support at all and should ignore.
AudioCodecs filtered_offered_audio_codecs;
@@ -2101,9 +2207,9 @@ void MediaSessionDescriptionFactory::GetCodecsForAnswer(
std::vector<Codec> offered_codecs = content.media_description()->codecs();
for (const Codec& offered_audio_codec : offered_codecs) {
if (!FindMatchingCodec(offered_codecs, filtered_offered_audio_codecs,
- offered_audio_codec, field_trials) &&
+ offered_audio_codec) &&
FindMatchingCodec(offered_codecs, all_audio_codecs_,
- offered_audio_codec, field_trials)) {
+ offered_audio_codec)) {
filtered_offered_audio_codecs.push_back(offered_audio_codec);
}
}
@@ -2111,9 +2217,9 @@ void MediaSessionDescriptionFactory::GetCodecsForAnswer(
std::vector<Codec> offered_codecs = content.media_description()->codecs();
for (const Codec& offered_video_codec : offered_codecs) {
if (!FindMatchingCodec(offered_codecs, filtered_offered_video_codecs,
- offered_video_codec, field_trials) &&
+ offered_video_codec) &&
FindMatchingCodec(offered_codecs, all_video_codecs_,
- offered_video_codec, field_trials)) {
+ offered_video_codec)) {
filtered_offered_video_codecs.push_back(offered_video_codec);
}
}
@@ -2122,10 +2228,8 @@ void MediaSessionDescriptionFactory::GetCodecsForAnswer(
// Add codecs that are not in the current description but were in
// `remote_offer`.
- MergeCodecs(filtered_offered_audio_codecs, audio_codecs, &used_pltypes,
- field_trials);
- MergeCodecs(filtered_offered_video_codecs, video_codecs, &used_pltypes,
- field_trials);
+ MergeCodecs(filtered_offered_audio_codecs, audio_codecs, &used_pltypes);
+ MergeCodecs(filtered_offered_video_codecs, video_codecs, &used_pltypes);
}
MediaSessionDescriptionFactory::AudioVideoRtpHeaderExtensions
@@ -2237,228 +2341,85 @@ RTCError MediaSessionDescriptionFactory::AddTransportAnswer(
return RTCError::OK();
}
-// `audio_codecs` = set of all possible codecs that can be used, with correct
+// `codecs` = set of all possible codecs that can be used, with correct
// payload type mappings
//
-// `supported_audio_codecs` = set of codecs that are supported for the direction
+// `supported_codecs` = set of codecs that are supported for the direction
// of this m= section
+// `current_content` = current description, may be null.
+// current_content->codecs() = set of previously negotiated codecs for this m=
+// section
//
-// mcd->codecs() = set of previously negotiated codecs for this m= section
-//
-// The payload types should come from audio_codecs, but the order should come
-// from mcd->codecs() and then supported_codecs, to ensure that re-offers don't
-// change existing codec priority, and that new codecs are added with the right
-// priority.
-RTCError MediaSessionDescriptionFactory::AddAudioContentForOffer(
+// The payload types should come from codecs, but the order should come
+// from current_content->codecs() and then supported_codecs, to ensure that
+// re-offers don't change existing codec priority, and that new codecs are added
+// with the right priority.
+RTCError MediaSessionDescriptionFactory::AddRtpContentForOffer(
const MediaDescriptionOptions& media_description_options,
const MediaSessionOptions& session_options,
const ContentInfo* current_content,
const SessionDescription* current_description,
- const RtpHeaderExtensions& audio_rtp_extensions,
- const AudioCodecs& audio_codecs,
+ const RtpHeaderExtensions& header_extensions,
+ const std::vector<Codec>& codecs,
StreamParamsVec* current_streams,
- SessionDescription* desc,
+ SessionDescription* session_description,
IceCredentialsIterator* ice_credentials) const {
- const webrtc::FieldTrialsView* field_trials =
- &transport_desc_factory_->trials();
- // Filter audio_codecs (which includes all codecs, with correctly remapped
- // payload types) based on transceiver direction.
- const AudioCodecs& supported_audio_codecs =
- GetAudioCodecsForOffer(media_description_options.direction);
-
- AudioCodecs filtered_codecs;
+ RTC_DCHECK(media_description_options.type == MEDIA_TYPE_AUDIO ||
+ media_description_options.type == MEDIA_TYPE_VIDEO);
- if (!media_description_options.codec_preferences.empty()) {
- // Add the codecs from the current transceiver's codec preferences.
- // They override any existing codecs from previous negotiations.
- filtered_codecs = MatchCodecPreference(
- media_description_options.codec_preferences, audio_codecs,
- supported_audio_codecs, field_trials);
- } else {
- // Add the codecs from current content if it exists and is not rejected nor
- // recycled.
- if (current_content && !current_content->rejected &&
- current_content->name == media_description_options.mid) {
- if (!IsMediaContentOfType(current_content, MEDIA_TYPE_AUDIO)) {
- // Can happen if the remote side re-uses a MID while recycling.
- LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR,
- "Media type for content with mid='" +
- current_content->name +
- "' does not match previous type.");
- }
- const MediaContentDescription* mcd = current_content->media_description();
- for (const Codec& codec : mcd->codecs()) {
- if (FindMatchingCodec(mcd->codecs(), audio_codecs, codec,
- field_trials)) {
- filtered_codecs.push_back(codec);
- }
- }
- }
- // Add other supported audio codecs.
- for (const Codec& codec : supported_audio_codecs) {
- absl::optional<Codec> found_codec = FindMatchingCodec(
- supported_audio_codecs, audio_codecs, codec, field_trials);
- if (found_codec &&
- !FindMatchingCodec(supported_audio_codecs, filtered_codecs, codec,
- field_trials)) {
- // Use the `found_codec` from `audio_codecs` because it has the
- // correctly mapped payload type.
- filtered_codecs.push_back(*found_codec);
- }
- }
- }
- if (!session_options.vad_enabled) {
- // If application doesn't want CN codecs in offer.
- StripCNCodecs(&filtered_codecs);
+ const std::vector<Codec>& supported_codecs =
+ media_description_options.type == MEDIA_TYPE_AUDIO
+ ? GetAudioCodecsForOffer(media_description_options.direction)
+ : GetVideoCodecsForOffer(media_description_options.direction);
+ webrtc::RTCErrorOr<std::vector<Codec>> error_or_filtered_codecs =
+ GetNegotiatedCodecsForOffer(media_description_options, session_options,
+ current_content, codecs, supported_codecs);
+ if (!error_or_filtered_codecs.ok()) {
+ return error_or_filtered_codecs.MoveError();
}
cricket::SecurePolicy sdes_policy =
IsDtlsActive(current_content, current_description) ? cricket::SEC_DISABLED
: secure();
- auto audio = std::make_unique<AudioContentDescription>();
std::vector<std::string> crypto_suites;
- GetSupportedAudioSdesCryptoSuiteNames(session_options.crypto_options,
- &crypto_suites);
- auto error = CreateMediaContentOffer(
- media_description_options, session_options, filtered_codecs, sdes_policy,
- GetCryptos(current_content), crypto_suites, audio_rtp_extensions,
- ssrc_generator(), current_streams, audio.get(),
- transport_desc_factory_->trials());
- if (!error.ok()) {
- return error;
- }
-
- bool secure_transport = (transport_desc_factory_->secure() != SEC_DISABLED);
- SetMediaProtocol(secure_transport, audio.get());
-
- audio->set_direction(media_description_options.direction);
-
- desc->AddContent(media_description_options.mid, MediaProtocolType::kRtp,
- media_description_options.stopped, std::move(audio));
- error = AddTransportOffer(media_description_options.mid,
- media_description_options.transport_options,
- current_description, desc, ice_credentials);
- if (!error.ok()) {
- return error;
- }
-
- return RTCError::OK();
-}
-
-// TODO(kron): This function is very similar to AddAudioContentForOffer.
-// Refactor to reuse shared code.
-RTCError MediaSessionDescriptionFactory::AddVideoContentForOffer(
- const MediaDescriptionOptions& media_description_options,
- const MediaSessionOptions& session_options,
- const ContentInfo* current_content,
- const SessionDescription* current_description,
- const RtpHeaderExtensions& video_rtp_extensions,
- const VideoCodecs& video_codecs,
- StreamParamsVec* current_streams,
- SessionDescription* desc,
- IceCredentialsIterator* ice_credentials) const {
- const webrtc::FieldTrialsView* field_trials =
- &transport_desc_factory_->trials();
- // Filter video_codecs (which includes all codecs, with correctly remapped
- // payload types) based on transceiver direction.
- const VideoCodecs& supported_video_codecs =
- GetVideoCodecsForOffer(media_description_options.direction);
-
- VideoCodecs filtered_codecs;
-
- if (!media_description_options.codec_preferences.empty()) {
- // Add the codecs from the current transceiver's codec preferences.
- // They override any existing codecs from previous negotiations.
- filtered_codecs = MatchCodecPreference(
- media_description_options.codec_preferences, video_codecs,
- supported_video_codecs, field_trials);
+ if (media_description_options.type == MEDIA_TYPE_AUDIO) {
+ GetSupportedAudioSdesCryptoSuiteNames(session_options.crypto_options,
+ &crypto_suites);
} else {
- // Add the codecs from current content if it exists and is not rejected nor
- // recycled.
- if (current_content && !current_content->rejected &&
- current_content->name == media_description_options.mid) {
- if (!IsMediaContentOfType(current_content, MEDIA_TYPE_VIDEO)) {
- // Can happen if the remote side re-uses a MID while recycling.
- LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR,
- "Media type for content with mid='" +
- current_content->name +
- "' does not match previous type.");
- }
- const MediaContentDescription* mcd = current_content->media_description();
- for (const Codec& codec : mcd->codecs()) {
- if (FindMatchingCodec(mcd->codecs(), video_codecs, codec,
- field_trials)) {
- filtered_codecs.push_back(codec);
- }
- }
- }
- // Add other supported video codecs.
- for (const Codec& codec : supported_video_codecs) {
- absl::optional<Codec> found_codec = FindMatchingCodec(
- supported_video_codecs, video_codecs, codec, field_trials);
- if (found_codec &&
- !FindMatchingCodec(supported_video_codecs, filtered_codecs, codec,
- field_trials)) {
- // Use the `found_codec` from `video_codecs` because it has the
- // correctly mapped payload type.
- if (IsRtxCodec(codec)) {
- // For RTX we might need to adjust the apt parameter if we got a
- // remote offer without RTX for a codec for which we support RTX.
- auto referenced_codec =
- GetAssociatedCodecForRtx(supported_video_codecs, codec);
- RTC_DCHECK(referenced_codec);
-
- // Find the codec we should be referencing and point to it.
- absl::optional<Codec> changed_referenced_codec =
- FindMatchingCodec(supported_video_codecs, filtered_codecs,
- *referenced_codec, field_trials);
- if (changed_referenced_codec) {
- found_codec->SetParam(kCodecParamAssociatedPayloadType,
- changed_referenced_codec->id);
- }
- }
- filtered_codecs.push_back(*found_codec);
- }
- }
+ GetSupportedVideoSdesCryptoSuiteNames(session_options.crypto_options,
+ &crypto_suites);
}
- if (session_options.raw_packetization_for_video) {
- for (Codec& codec : filtered_codecs) {
- if (codec.IsMediaCodec()) {
- codec.packetization = kPacketizationParamRaw;
- }
- }
+ std::unique_ptr<MediaContentDescription> content_description;
+ if (media_description_options.type == MEDIA_TYPE_AUDIO) {
+ content_description = std::make_unique<AudioContentDescription>();
+ } else {
+ content_description = std::make_unique<VideoContentDescription>();
}
- cricket::SecurePolicy sdes_policy =
- IsDtlsActive(current_content, current_description) ? cricket::SEC_DISABLED
- : secure();
- auto video = std::make_unique<VideoContentDescription>();
- std::vector<std::string> crypto_suites;
- GetSupportedVideoSdesCryptoSuiteNames(session_options.crypto_options,
- &crypto_suites);
auto error = CreateMediaContentOffer(
- media_description_options, session_options, filtered_codecs, sdes_policy,
- GetCryptos(current_content), crypto_suites, video_rtp_extensions,
- ssrc_generator(), current_streams, video.get(),
+ media_description_options, session_options,
+ error_or_filtered_codecs.MoveValue(), sdes_policy,
+ GetCryptos(current_content), crypto_suites, header_extensions,
+ ssrc_generator(), current_streams, content_description.get(),
transport_desc_factory_->trials());
if (!error.ok()) {
return error;
}
- video->set_bandwidth(kAutoBandwidth);
-
- bool secure_transport = (transport_desc_factory_->secure() != SEC_DISABLED);
- SetMediaProtocol(secure_transport, video.get());
+ bool secure_transport = transport_desc_factory_->secure() != SEC_DISABLED;
+ SetMediaProtocol(secure_transport, content_description.get());
- video->set_direction(media_description_options.direction);
+ content_description->set_direction(media_description_options.direction);
- desc->AddContent(media_description_options.mid, MediaProtocolType::kRtp,
- media_description_options.stopped, std::move(video));
+ session_description->AddContent(
+ media_description_options.mid, MediaProtocolType::kRtp,
+ media_description_options.stopped, std::move(content_description));
return AddTransportOffer(media_description_options.mid,
media_description_options.transport_options,
- current_description, desc, ice_credentials);
+ current_description, session_description,
+ ice_credentials);
}
RTCError MediaSessionDescriptionFactory::AddDataContentForOffer(
@@ -2526,19 +2487,19 @@ RTCError MediaSessionDescriptionFactory::AddUnsupportedContentForOffer(
current_description, desc, ice_credentials);
}
-// `audio_codecs` = set of all possible codecs that can be used, with correct
+// `codecs` = set of all possible codecs that can be used, with correct
// payload type mappings
//
-// `supported_audio_codecs` = set of codecs that are supported for the direction
+// `supported_codecs` = set of codecs that are supported for the direction
// of this m= section
//
// mcd->codecs() = set of previously negotiated codecs for this m= section
//
-// The payload types should come from audio_codecs, but the order should come
+// The payload types should come from codecs, but the order should come
// from mcd->codecs() and then supported_codecs, to ensure that re-offers don't
// change existing codec priority, and that new codecs are added with the right
// priority.
-RTCError MediaSessionDescriptionFactory::AddAudioContentForAnswer(
+RTCError MediaSessionDescriptionFactory::AddRtpContentForAnswer(
const MediaDescriptionOptions& media_description_options,
const MediaSessionOptions& session_options,
const ContentInfo* offer_content,
@@ -2546,272 +2507,104 @@ RTCError MediaSessionDescriptionFactory::AddAudioContentForAnswer(
const ContentInfo* current_content,
const SessionDescription* current_description,
const TransportInfo* bundle_transport,
- const AudioCodecs& audio_codecs,
- const RtpHeaderExtensions& rtp_header_extensions,
+ const std::vector<Codec>& codecs,
+ const RtpHeaderExtensions& header_extensions,
StreamParamsVec* current_streams,
SessionDescription* answer,
IceCredentialsIterator* ice_credentials) const {
- const webrtc::FieldTrialsView* field_trials =
- &transport_desc_factory_->trials();
- RTC_CHECK(IsMediaContentOfType(offer_content, MEDIA_TYPE_AUDIO));
- const AudioContentDescription* offer_audio_description =
- offer_content->media_description()->as_audio();
-
- std::unique_ptr<TransportDescription> audio_transport = CreateTransportAnswer(
+ RTC_DCHECK(media_description_options.type == MEDIA_TYPE_AUDIO ||
+ media_description_options.type == MEDIA_TYPE_VIDEO);
+ RTC_CHECK(
+ IsMediaContentOfType(offer_content, media_description_options.type));
+ const RtpMediaContentDescription* offer_content_description;
+ if (media_description_options.type == MEDIA_TYPE_AUDIO) {
+ offer_content_description = offer_content->media_description()->as_audio();
+ } else {
+ offer_content_description = offer_content->media_description()->as_video();
+ }
+ std::unique_ptr<TransportDescription> transport = CreateTransportAnswer(
media_description_options.mid, offer_description,
media_description_options.transport_options, current_description,
bundle_transport != nullptr, ice_credentials);
- if (!audio_transport) {
+ if (!transport) {
LOG_AND_RETURN_ERROR(
RTCErrorType::INTERNAL_ERROR,
- "Failed to create transport answer, audio transport is missing");
+ "Failed to create transport answer, transport is missing");
}
// Pick codecs based on the requested communications direction in the offer
// and the selected direction in the answer.
// Note these will be filtered one final time in CreateMediaContentAnswer.
auto wants_rtd = media_description_options.direction;
- auto offer_rtd = offer_audio_description->direction();
+ auto offer_rtd = offer_content_description->direction();
auto answer_rtd = NegotiateRtpTransceiverDirection(offer_rtd, wants_rtd);
- AudioCodecs supported_audio_codecs =
- GetAudioCodecsForAnswer(offer_rtd, answer_rtd);
- AudioCodecs filtered_codecs;
-
- if (!media_description_options.codec_preferences.empty()) {
- filtered_codecs = MatchCodecPreference(
- media_description_options.codec_preferences, audio_codecs,
- supported_audio_codecs, field_trials);
- } else {
- // Add the codecs from current content if it exists and is not rejected nor
- // recycled.
- if (current_content && !current_content->rejected &&
- current_content->name == media_description_options.mid) {
- if (!IsMediaContentOfType(current_content, MEDIA_TYPE_AUDIO)) {
- // Can happen if the remote side re-uses a MID while recycling.
- LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR,
- "Media type for content with mid='" +
- current_content->name +
- "' does not match previous type.");
- }
- const MediaContentDescription* mcd = current_content->media_description();
- for (const Codec& codec : mcd->codecs()) {
- if (FindMatchingCodec(mcd->codecs(), audio_codecs, codec,
- field_trials)) {
- filtered_codecs.push_back(codec);
- }
- }
- }
- // Add other supported audio codecs.
- for (const Codec& codec : supported_audio_codecs) {
- if (FindMatchingCodec(supported_audio_codecs, audio_codecs, codec,
- field_trials) &&
- !FindMatchingCodec(supported_audio_codecs, filtered_codecs, codec,
- field_trials)) {
- // We should use the local codec with local parameters and the codec id
- // would be correctly mapped in `NegotiateCodecs`.
- filtered_codecs.push_back(codec);
- }
- }
- }
- if (!session_options.vad_enabled) {
- // If application doesn't want CN codecs in answer.
- StripCNCodecs(&filtered_codecs);
+ const std::vector<Codec>& supported_codecs =
+ media_description_options.type == MEDIA_TYPE_AUDIO
+ ? GetAudioCodecsForAnswer(offer_rtd, answer_rtd)
+ : GetVideoCodecsForAnswer(offer_rtd, answer_rtd);
+ webrtc::RTCErrorOr<std::vector<Codec>> error_or_filtered_codecs =
+ GetNegotiatedCodecsForAnswer(media_description_options, session_options,
+ current_content, codecs, supported_codecs);
+ if (!error_or_filtered_codecs.ok()) {
+ return error_or_filtered_codecs.MoveError();
}
+ auto filtered_codecs = error_or_filtered_codecs.MoveValue();
// Determine if we have media codecs in common.
bool has_common_media_codecs =
std::find_if(filtered_codecs.begin(), filtered_codecs.end(),
- [](const AudioCodec& c) {
- return !(IsRedCodec(c) || IsComfortNoiseCodec(c));
+ [](const Codec& c) {
+ return c.IsMediaCodec() && !IsComfortNoiseCodec(c);
}) != filtered_codecs.end();
bool bundle_enabled = offer_description->HasGroup(GROUP_TYPE_BUNDLE) &&
session_options.bundle_enabled;
- auto audio_answer = std::make_unique<AudioContentDescription>();
+ std::unique_ptr<MediaContentDescription> answer_content;
+ if (media_description_options.type == MEDIA_TYPE_AUDIO) {
+ answer_content = std::make_unique<AudioContentDescription>();
+ } else {
+ answer_content = std::make_unique<VideoContentDescription>();
+ }
// Do not require or create SDES cryptos if DTLS is used.
cricket::SecurePolicy sdes_policy =
- audio_transport->secure() ? cricket::SEC_DISABLED : secure();
- if (!SetCodecsInAnswer(offer_audio_description, filtered_codecs,
- media_description_options, session_options,
- ssrc_generator(), current_streams, audio_answer.get(),
- transport_desc_factory_->trials())) {
+ transport->secure() ? cricket::SEC_DISABLED : secure();
+ if (!SetCodecsInAnswer(
+ offer_content_description, filtered_codecs, media_description_options,
+ session_options, ssrc_generator(), current_streams,
+ answer_content.get(), transport_desc_factory_->trials())) {
LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR,
"Failed to set codecs in answer");
}
if (!CreateMediaContentAnswer(
- offer_audio_description, media_description_options, session_options,
+ offer_content_description, media_description_options, session_options,
sdes_policy, GetCryptos(current_content),
- filtered_rtp_header_extensions(rtp_header_extensions),
- ssrc_generator(), enable_encrypted_rtp_header_extensions_,
- current_streams, bundle_enabled, audio_answer.get())) {
+ filtered_rtp_header_extensions(header_extensions), ssrc_generator(),
+ enable_encrypted_rtp_header_extensions_, current_streams,
+ bundle_enabled, answer_content.get())) {
LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR,
"Failed to create answer");
}
bool secure = bundle_transport ? bundle_transport->description.secure()
- : audio_transport->secure();
+ : transport->secure();
bool rejected = media_description_options.stopped ||
offer_content->rejected || !has_common_media_codecs ||
!IsMediaProtocolSupported(MEDIA_TYPE_AUDIO,
- audio_answer->protocol(), secure);
- auto error = AddTransportAnswer(media_description_options.mid,
- *(audio_transport.get()), answer);
- if (!error.ok()) {
- return error;
- }
-
+ answer_content->protocol(), secure);
if (rejected) {
- RTC_LOG(LS_INFO) << "Audio m= section '" << media_description_options.mid
+ RTC_LOG(LS_INFO) << "m= section '" << media_description_options.mid
<< "' being rejected in answer.";
}
- answer->AddContent(media_description_options.mid, offer_content->type,
- rejected, std::move(audio_answer));
- return RTCError::OK();
-}
-
-// TODO(kron): This function is very similar to AddAudioContentForAnswer.
-// Refactor to reuse shared code.
-RTCError MediaSessionDescriptionFactory::AddVideoContentForAnswer(
- const MediaDescriptionOptions& media_description_options,
- const MediaSessionOptions& session_options,
- const ContentInfo* offer_content,
- const SessionDescription* offer_description,
- const ContentInfo* current_content,
- const SessionDescription* current_description,
- const TransportInfo* bundle_transport,
- const VideoCodecs& video_codecs,
- const RtpHeaderExtensions& default_video_rtp_header_extensions,
- StreamParamsVec* current_streams,
- SessionDescription* answer,
- IceCredentialsIterator* ice_credentials) const {
- const webrtc::FieldTrialsView* field_trials =
- &transport_desc_factory_->trials();
- RTC_CHECK(IsMediaContentOfType(offer_content, MEDIA_TYPE_VIDEO));
- const VideoContentDescription* offer_video_description =
- offer_content->media_description()->as_video();
-
- std::unique_ptr<TransportDescription> video_transport = CreateTransportAnswer(
- media_description_options.mid, offer_description,
- media_description_options.transport_options, current_description,
- bundle_transport != nullptr, ice_credentials);
- if (!video_transport) {
- LOG_AND_RETURN_ERROR(
- RTCErrorType::INTERNAL_ERROR,
- "Failed to create transport answer, video transport is missing");
- }
-
- // Pick codecs based on the requested communications direction in the offer
- // and the selected direction in the answer.
- // Note these will be filtered one final time in CreateMediaContentAnswer.
- auto wants_rtd = media_description_options.direction;
- auto offer_rtd = offer_video_description->direction();
- auto answer_rtd = NegotiateRtpTransceiverDirection(offer_rtd, wants_rtd);
- VideoCodecs supported_video_codecs =
- GetVideoCodecsForAnswer(offer_rtd, answer_rtd);
-
- VideoCodecs filtered_codecs;
-
- if (!media_description_options.codec_preferences.empty()) {
- filtered_codecs = MatchCodecPreference(
- media_description_options.codec_preferences, video_codecs,
- supported_video_codecs, field_trials);
- } else {
- // Add the codecs from current content if it exists and is not rejected nor
- // recycled.
- if (current_content && !current_content->rejected &&
- current_content->name == media_description_options.mid) {
- if (!IsMediaContentOfType(current_content, MEDIA_TYPE_VIDEO)) {
- // Can happen if the remote side re-uses a MID while recycling.
- LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR,
- "Media type for content with mid='" +
- current_content->name +
- "' does not match previous type.");
- }
- const MediaContentDescription* mcd = current_content->media_description();
- for (const Codec& codec : mcd->codecs()) {
- if (FindMatchingCodec(mcd->codecs(), video_codecs, codec,
- field_trials)) {
- filtered_codecs.push_back(codec);
- }
- }
- }
-
- // Add other supported video codecs.
- VideoCodecs other_video_codecs;
- for (const Codec& codec : supported_video_codecs) {
- if (FindMatchingCodec(supported_video_codecs, video_codecs, codec,
- field_trials) &&
- !FindMatchingCodec(supported_video_codecs, filtered_codecs, codec,
- field_trials)) {
- // We should use the local codec with local parameters and the codec id
- // would be correctly mapped in `NegotiateCodecs`.
- other_video_codecs.push_back(codec);
- }
- }
-
- // Use ComputeCodecsUnion to avoid having duplicate payload IDs
- filtered_codecs =
- ComputeCodecsUnion(filtered_codecs, other_video_codecs, field_trials);
- }
- // Determine if we have media codecs in common.
- bool has_common_media_codecs =
- std::find_if(
- filtered_codecs.begin(), filtered_codecs.end(), [](const Codec& c) {
- return !(IsRedCodec(c) || IsUlpfecCodec(c) || IsFlexfecCodec(c));
- }) != filtered_codecs.end();
-
- if (session_options.raw_packetization_for_video) {
- for (Codec& codec : filtered_codecs) {
- if (codec.IsMediaCodec()) {
- codec.packetization = kPacketizationParamRaw;
- }
- }
- }
-
- bool bundle_enabled = offer_description->HasGroup(GROUP_TYPE_BUNDLE) &&
- session_options.bundle_enabled;
- auto video_answer = std::make_unique<VideoContentDescription>();
- // Do not require or create SDES cryptos if DTLS is used.
- cricket::SecurePolicy sdes_policy =
- video_transport->secure() ? cricket::SEC_DISABLED : secure();
- if (!SetCodecsInAnswer(offer_video_description, filtered_codecs,
- media_description_options, session_options,
- ssrc_generator(), current_streams, video_answer.get(),
- transport_desc_factory_->trials())) {
- LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR,
- "Failed to set codecs in answer");
- }
- if (!CreateMediaContentAnswer(
- offer_video_description, media_description_options, session_options,
- sdes_policy, GetCryptos(current_content),
- filtered_rtp_header_extensions(default_video_rtp_header_extensions),
- ssrc_generator(), enable_encrypted_rtp_header_extensions_,
- current_streams, bundle_enabled, video_answer.get())) {
- LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR,
- "Failed to create answer");
- }
- bool secure = bundle_transport ? bundle_transport->description.secure()
- : video_transport->secure();
- bool rejected = media_description_options.stopped ||
- offer_content->rejected || !has_common_media_codecs ||
- !IsMediaProtocolSupported(MEDIA_TYPE_VIDEO,
- video_answer->protocol(), secure);
auto error = AddTransportAnswer(media_description_options.mid,
- *(video_transport.get()), answer);
+ *(transport.get()), answer);
if (!error.ok()) {
return error;
}
- if (!rejected) {
- video_answer->set_bandwidth(kAutoBandwidth);
- } else {
- RTC_LOG(LS_INFO) << "Video m= section '" << media_description_options.mid
- << "' being rejected in answer.";
- }
answer->AddContent(media_description_options.mid, offer_content->type,
- rejected, std::move(video_answer));
+ rejected, std::move(answer_content));
return RTCError::OK();
}
@@ -2934,23 +2727,19 @@ RTCError MediaSessionDescriptionFactory::AddUnsupportedContentForAnswer(
}
void MediaSessionDescriptionFactory::ComputeAudioCodecsIntersectionAndUnion() {
- const webrtc::FieldTrialsView* field_trials =
- &transport_desc_factory_->trials();
audio_sendrecv_codecs_.clear();
all_audio_codecs_.clear();
// Compute the audio codecs union.
for (const Codec& send : audio_send_codecs_) {
all_audio_codecs_.push_back(send);
- if (!FindMatchingCodec(audio_send_codecs_, audio_recv_codecs_, send,
- field_trials)) {
+ if (!FindMatchingCodec(audio_send_codecs_, audio_recv_codecs_, send)) {
// It doesn't make sense to have an RTX codec we support sending but not
// receiving.
- RTC_DCHECK(!IsRtxCodec(send));
+ RTC_DCHECK(send.GetResiliencyType() != Codec::ResiliencyType::kRtx);
}
}
for (const Codec& recv : audio_recv_codecs_) {
- if (!FindMatchingCodec(audio_recv_codecs_, audio_send_codecs_, recv,
- field_trials)) {
+ if (!FindMatchingCodec(audio_recv_codecs_, audio_send_codecs_, recv)) {
all_audio_codecs_.push_back(recv);
}
}
@@ -2960,17 +2749,15 @@ void MediaSessionDescriptionFactory::ComputeAudioCodecsIntersectionAndUnion() {
// expensive than decoding, and prioritizing a codec in the send list probably
// means it's a codec we can handle efficiently.
NegotiateCodecs(audio_recv_codecs_, audio_send_codecs_,
- &audio_sendrecv_codecs_, true, field_trials);
+ &audio_sendrecv_codecs_, true);
}
void MediaSessionDescriptionFactory::ComputeVideoCodecsIntersectionAndUnion() {
- const webrtc::FieldTrialsView* field_trials =
- &transport_desc_factory_->trials();
video_sendrecv_codecs_.clear();
// Use ComputeCodecsUnion to avoid having duplicate payload IDs
all_video_codecs_ =
- ComputeCodecsUnion(video_recv_codecs_, video_send_codecs_, field_trials);
+ ComputeCodecsUnion(video_recv_codecs_, video_send_codecs_);
// Use NegotiateCodecs to merge our codec lists, since the operation is
// essentially the same. Put send_codecs as the offered_codecs, which is the
@@ -2978,7 +2765,7 @@ void MediaSessionDescriptionFactory::ComputeVideoCodecsIntersectionAndUnion() {
// expensive than decoding, and prioritizing a codec in the send list probably
// means it's a codec we can handle efficiently.
NegotiateCodecs(video_recv_codecs_, video_send_codecs_,
- &video_sendrecv_codecs_, true, field_trials);
+ &video_sendrecv_codecs_, true);
}
bool IsMediaContent(const ContentInfo* content) {
diff --git a/third_party/libwebrtc/pc/media_session.h b/third_party/libwebrtc/pc/media_session.h
index 3100fb6fdb..0b3cb67c35 100644
--- a/third_party/libwebrtc/pc/media_session.h
+++ b/third_party/libwebrtc/pc/media_session.h
@@ -19,7 +19,6 @@
#include <vector>
#include "api/crypto/crypto_options.h"
-#include "api/field_trials_view.h"
#include "api/media_types.h"
#include "api/rtp_parameters.h"
#include "api/rtp_transceiver_direction.h"
@@ -230,28 +229,14 @@ class MediaSessionDescriptionFactory {
const TransportDescription& transport_desc,
SessionDescription* answer_desc) const;
- // Helpers for adding media contents to the SessionDescription. Returns true
- // it succeeds or the media content is not needed, or false if there is any
- // error.
-
- webrtc::RTCError AddAudioContentForOffer(
- const MediaDescriptionOptions& media_description_options,
- const MediaSessionOptions& session_options,
- const ContentInfo* current_content,
- const SessionDescription* current_description,
- const RtpHeaderExtensions& audio_rtp_extensions,
- const AudioCodecs& audio_codecs,
- StreamParamsVec* current_streams,
- SessionDescription* desc,
- IceCredentialsIterator* ice_credentials) const;
-
- webrtc::RTCError AddVideoContentForOffer(
+ // Helpers for adding media contents to the SessionDescription.
+ webrtc::RTCError AddRtpContentForOffer(
const MediaDescriptionOptions& media_description_options,
const MediaSessionOptions& session_options,
const ContentInfo* current_content,
const SessionDescription* current_description,
- const RtpHeaderExtensions& video_rtp_extensions,
- const VideoCodecs& video_codecs,
+ const RtpHeaderExtensions& header_extensions,
+ const std::vector<Codec>& codecs,
StreamParamsVec* current_streams,
SessionDescription* desc,
IceCredentialsIterator* ice_credentials) const;
@@ -273,21 +258,7 @@ class MediaSessionDescriptionFactory {
SessionDescription* desc,
IceCredentialsIterator* ice_credentials) const;
- webrtc::RTCError AddAudioContentForAnswer(
- const MediaDescriptionOptions& media_description_options,
- const MediaSessionOptions& session_options,
- const ContentInfo* offer_content,
- const SessionDescription* offer_description,
- const ContentInfo* current_content,
- const SessionDescription* current_description,
- const TransportInfo* bundle_transport,
- const AudioCodecs& audio_codecs,
- const RtpHeaderExtensions& rtp_header_extensions,
- StreamParamsVec* current_streams,
- SessionDescription* answer,
- IceCredentialsIterator* ice_credentials) const;
-
- webrtc::RTCError AddVideoContentForAnswer(
+ webrtc::RTCError AddRtpContentForAnswer(
const MediaDescriptionOptions& media_description_options,
const MediaSessionOptions& session_options,
const ContentInfo* offer_content,
@@ -295,8 +266,8 @@ class MediaSessionDescriptionFactory {
const ContentInfo* current_content,
const SessionDescription* current_description,
const TransportInfo* bundle_transport,
- const VideoCodecs& video_codecs,
- const RtpHeaderExtensions& rtp_header_extensions,
+ const std::vector<Codec>& codecs,
+ const RtpHeaderExtensions& header_extensions,
StreamParamsVec* current_streams,
SessionDescription* answer,
IceCredentialsIterator* ice_credentials) const;
diff --git a/third_party/libwebrtc/pc/media_session_unittest.cc b/third_party/libwebrtc/pc/media_session_unittest.cc
index a1770c18c5..641f638e72 100644
--- a/third_party/libwebrtc/pc/media_session_unittest.cc
+++ b/third_party/libwebrtc/pc/media_session_unittest.cc
@@ -54,50 +54,16 @@
ASSERT_EQ(s, cd->cryptos().size()); \
ASSERT_EQ(cs, cd->cryptos()[0].crypto_suite)
-typedef std::vector<cricket::Candidate> Candidates;
-
-using cricket::AudioCodec;
-using cricket::AudioContentDescription;
-using cricket::ContentInfo;
-using cricket::CryptoParamsVec;
-using cricket::GetFirstAudioContent;
-using cricket::GetFirstAudioContentDescription;
-using cricket::GetFirstDataContent;
-using cricket::GetFirstVideoContent;
-using cricket::GetFirstVideoContentDescription;
-using cricket::kAutoBandwidth;
-using cricket::MEDIA_TYPE_AUDIO;
-using cricket::MEDIA_TYPE_DATA;
-using cricket::MEDIA_TYPE_VIDEO;
-using cricket::MediaContentDescription;
-using cricket::MediaDescriptionOptions;
-using cricket::MediaProtocolType;
-using cricket::MediaSessionDescriptionFactory;
-using cricket::MediaSessionOptions;
-using cricket::MediaType;
-using cricket::RidDescription;
-using cricket::RidDirection;
-using cricket::SctpDataContentDescription;
-using cricket::SEC_DISABLED;
-using cricket::SEC_ENABLED;
-using cricket::SEC_REQUIRED;
-using cricket::SessionDescription;
-using cricket::SimulcastDescription;
-using cricket::SimulcastLayer;
-using cricket::SimulcastLayerList;
-using cricket::SsrcGroup;
-using cricket::StreamParams;
-using cricket::StreamParamsVec;
-using cricket::TransportDescription;
-using cricket::TransportDescriptionFactory;
-using cricket::TransportInfo;
-using cricket::VideoCodec;
-using cricket::VideoContentDescription;
-using rtc::kCsAeadAes128Gcm;
-using rtc::kCsAeadAes256Gcm;
-using rtc::kCsAesCm128HmacSha1_32;
-using rtc::kCsAesCm128HmacSha1_80;
-using rtc::UniqueRandomIdGenerator;
+namespace cricket {
+namespace {
+
+using ::rtc::kCsAeadAes128Gcm;
+using ::rtc::kCsAeadAes256Gcm;
+using ::rtc::kCsAesCm128HmacSha1_32;
+using ::rtc::kCsAesCm128HmacSha1_80;
+using ::rtc::UniqueRandomIdGenerator;
+using ::testing::Bool;
+using ::testing::Combine;
using ::testing::Contains;
using ::testing::Each;
using ::testing::ElementsAre;
@@ -110,146 +76,145 @@ using ::testing::Ne;
using ::testing::Not;
using ::testing::Pointwise;
using ::testing::SizeIs;
-using webrtc::RtpExtension;
-using webrtc::RtpTransceiverDirection;
+using ::testing::Values;
+using ::testing::ValuesIn;
+using ::webrtc::RtpExtension;
+using ::webrtc::RtpTransceiverDirection;
+
+using Candidates = std::vector<Candidate>;
-static AudioCodec createRedAudioCodec(absl::string_view encoding_id) {
- AudioCodec red = cricket::CreateAudioCodec(63, "red", 48000, 2);
- red.SetParam(cricket::kCodecParamNotInNameValueFormat,
+AudioCodec CreateRedAudioCodec(absl::string_view encoding_id) {
+ AudioCodec red = CreateAudioCodec(63, "red", 48000, 2);
+ red.SetParam(kCodecParamNotInNameValueFormat,
std::string(encoding_id) + '/' + std::string(encoding_id));
return red;
}
-static const AudioCodec kAudioCodecs1[] = {
- cricket::CreateAudioCodec(111, "opus", 48000, 2),
- createRedAudioCodec("111"),
- cricket::CreateAudioCodec(102, "iLBC", 8000, 1),
- cricket::CreateAudioCodec(0, "PCMU", 8000, 1),
- cricket::CreateAudioCodec(8, "PCMA", 8000, 1),
- cricket::CreateAudioCodec(117, "red", 8000, 1),
- cricket::CreateAudioCodec(107, "CN", 48000, 1)};
+const AudioCodec kAudioCodecs1[] = {CreateAudioCodec(111, "opus", 48000, 2),
+ CreateRedAudioCodec("111"),
+ CreateAudioCodec(102, "iLBC", 8000, 1),
+ CreateAudioCodec(0, "PCMU", 8000, 1),
+ CreateAudioCodec(8, "PCMA", 8000, 1),
+ CreateAudioCodec(117, "red", 8000, 1),
+ CreateAudioCodec(107, "CN", 48000, 1)};
-static const AudioCodec kAudioCodecs2[] = {
- cricket::CreateAudioCodec(126, "foo", 16000, 1),
- cricket::CreateAudioCodec(0, "PCMU", 8000, 1),
- cricket::CreateAudioCodec(127, "iLBC", 8000, 1),
+const AudioCodec kAudioCodecs2[] = {
+ CreateAudioCodec(126, "foo", 16000, 1),
+ CreateAudioCodec(0, "PCMU", 8000, 1),
+ CreateAudioCodec(127, "iLBC", 8000, 1),
};
-static const AudioCodec kAudioCodecsAnswer[] = {
- cricket::CreateAudioCodec(102, "iLBC", 8000, 1),
- cricket::CreateAudioCodec(0, "PCMU", 8000, 1),
+const AudioCodec kAudioCodecsAnswer[] = {
+ CreateAudioCodec(102, "iLBC", 8000, 1),
+ CreateAudioCodec(0, "PCMU", 8000, 1),
};
-static const VideoCodec kVideoCodecs1[] = {
- cricket::CreateVideoCodec(96, "H264-SVC"),
- cricket::CreateVideoCodec(97, "H264")};
+const VideoCodec kVideoCodecs1[] = {CreateVideoCodec(96, "H264-SVC"),
+ CreateVideoCodec(97, "H264")};
-static const VideoCodec kVideoCodecs1Reverse[] = {
- cricket::CreateVideoCodec(97, "H264"),
- cricket::CreateVideoCodec(96, "H264-SVC")};
+const VideoCodec kVideoCodecs1Reverse[] = {CreateVideoCodec(97, "H264"),
+ CreateVideoCodec(96, "H264-SVC")};
-static const VideoCodec kVideoCodecs2[] = {
- cricket::CreateVideoCodec(126, "H264"),
- cricket::CreateVideoCodec(127, "H263")};
+const VideoCodec kVideoCodecs2[] = {CreateVideoCodec(126, "H264"),
+ CreateVideoCodec(127, "H263")};
-static const VideoCodec kVideoCodecsAnswer[] = {
- cricket::CreateVideoCodec(97, "H264")};
+const VideoCodec kVideoCodecsAnswer[] = {CreateVideoCodec(97, "H264")};
-static const RtpExtension kAudioRtpExtension1[] = {
+const RtpExtension kAudioRtpExtension1[] = {
RtpExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 8),
RtpExtension("http://google.com/testing/audio_something", 10),
};
-static const RtpExtension kAudioRtpExtensionEncrypted1[] = {
+const RtpExtension kAudioRtpExtensionEncrypted1[] = {
RtpExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 8),
RtpExtension("http://google.com/testing/audio_something", 10),
RtpExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 12, true),
RtpExtension("http://google.com/testing/audio_something", 11, true),
};
-static const RtpExtension kAudioRtpExtension2[] = {
+const RtpExtension kAudioRtpExtension2[] = {
RtpExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 2),
RtpExtension("http://google.com/testing/audio_something_else", 8),
RtpExtension("http://google.com/testing/both_audio_and_video", 7),
};
-static const RtpExtension kAudioRtpExtension3[] = {
+const RtpExtension kAudioRtpExtension3[] = {
RtpExtension("http://google.com/testing/audio_something", 2),
RtpExtension("http://google.com/testing/both_audio_and_video", 3),
};
-static const RtpExtension kAudioRtpExtension3ForEncryption[] = {
+const RtpExtension kAudioRtpExtension3ForEncryption[] = {
RtpExtension("http://google.com/testing/audio_something", 2),
// Use RTP extension that supports encryption.
RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 3),
};
-static const RtpExtension kAudioRtpExtension3ForEncryptionOffer[] = {
+const RtpExtension kAudioRtpExtension3ForEncryptionOffer[] = {
RtpExtension("http://google.com/testing/audio_something", 2),
RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 3),
RtpExtension("http://google.com/testing/audio_something", 14, true),
RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 13, true),
};
-static const RtpExtension kVideoRtpExtension3ForEncryptionOffer[] = {
+const RtpExtension kVideoRtpExtension3ForEncryptionOffer[] = {
RtpExtension("http://google.com/testing/video_something", 4),
RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 3),
RtpExtension("http://google.com/testing/video_something", 12, true),
RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 13, true),
};
-static const RtpExtension kAudioRtpExtensionAnswer[] = {
+const RtpExtension kAudioRtpExtensionAnswer[] = {
RtpExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 8),
};
-static const RtpExtension kAudioRtpExtensionEncryptedAnswer[] = {
+const RtpExtension kAudioRtpExtensionEncryptedAnswer[] = {
RtpExtension("urn:ietf:params:rtp-hdrext:ssrc-audio-level", 12, true),
};
-static const RtpExtension kVideoRtpExtension1[] = {
+const RtpExtension kVideoRtpExtension1[] = {
RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 14),
RtpExtension("http://google.com/testing/video_something", 13),
};
-static const RtpExtension kVideoRtpExtensionEncrypted1[] = {
+const RtpExtension kVideoRtpExtensionEncrypted1[] = {
RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 14),
RtpExtension("http://google.com/testing/video_something", 13),
RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 9, true),
RtpExtension("http://google.com/testing/video_something", 7, true),
};
-static const RtpExtension kVideoRtpExtension2[] = {
+const RtpExtension kVideoRtpExtension2[] = {
RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 2),
RtpExtension("http://google.com/testing/video_something_else", 14),
RtpExtension("http://google.com/testing/both_audio_and_video", 7),
};
-static const RtpExtension kVideoRtpExtension3[] = {
+const RtpExtension kVideoRtpExtension3[] = {
RtpExtension("http://google.com/testing/video_something", 4),
RtpExtension("http://google.com/testing/both_audio_and_video", 5),
};
-static const RtpExtension kVideoRtpExtension3ForEncryption[] = {
+const RtpExtension kVideoRtpExtension3ForEncryption[] = {
RtpExtension("http://google.com/testing/video_something", 4),
// Use RTP extension that supports encryption.
RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 5),
};
-static const RtpExtension kVideoRtpExtensionAnswer[] = {
+const RtpExtension kVideoRtpExtensionAnswer[] = {
RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 14),
};
-static const RtpExtension kVideoRtpExtensionEncryptedAnswer[] = {
+const RtpExtension kVideoRtpExtensionEncryptedAnswer[] = {
RtpExtension("urn:ietf:params:rtp-hdrext:toffset", 9, true),
};
-static const RtpExtension kRtpExtensionTransportSequenceNumber01[] = {
+const RtpExtension kRtpExtensionTransportSequenceNumber01[] = {
RtpExtension("http://www.ietf.org/id/"
"draft-holmer-rmcat-transport-wide-cc-extensions-01",
1),
};
-static const RtpExtension kRtpExtensionTransportSequenceNumber01And02[] = {
+const RtpExtension kRtpExtensionTransportSequenceNumber01And02[] = {
RtpExtension("http://www.ietf.org/id/"
"draft-holmer-rmcat-transport-wide-cc-extensions-01",
1),
@@ -258,68 +223,64 @@ static const RtpExtension kRtpExtensionTransportSequenceNumber01And02[] = {
2),
};
-static const RtpExtension kRtpExtensionTransportSequenceNumber02[] = {
+const RtpExtension kRtpExtensionTransportSequenceNumber02[] = {
RtpExtension(
"http://www.webrtc.org/experiments/rtp-hdrext/transport-wide-cc-02",
2),
};
-static const RtpExtension kRtpExtensionGenericFrameDescriptorUri00[] = {
+const RtpExtension kRtpExtensionGenericFrameDescriptorUri00[] = {
RtpExtension("http://www.webrtc.org/experiments/rtp-hdrext/"
"generic-frame-descriptor-00",
3),
};
-static const uint32_t kSimulcastParamsSsrc[] = {10, 11, 20, 21, 30, 31};
-static const uint32_t kSimSsrc[] = {10, 20, 30};
-static const uint32_t kFec1Ssrc[] = {10, 11};
-static const uint32_t kFec2Ssrc[] = {20, 21};
-static const uint32_t kFec3Ssrc[] = {30, 31};
-
-static const char kMediaStream1[] = "stream_1";
-static const char kMediaStream2[] = "stream_2";
-static const char kVideoTrack1[] = "video_1";
-static const char kVideoTrack2[] = "video_2";
-static const char kAudioTrack1[] = "audio_1";
-static const char kAudioTrack2[] = "audio_2";
-static const char kAudioTrack3[] = "audio_3";
-
-static const char* kMediaProtocols[] = {"RTP/AVP", "RTP/SAVP", "RTP/AVPF",
- "RTP/SAVPF"};
-static const char* kMediaProtocolsDtls[] = {
- "TCP/TLS/RTP/SAVPF", "TCP/TLS/RTP/SAVP", "UDP/TLS/RTP/SAVPF",
- "UDP/TLS/RTP/SAVP"};
+const uint32_t kSimulcastParamsSsrc[] = {10, 11, 20, 21, 30, 31};
+const uint32_t kSimSsrc[] = {10, 20, 30};
+const uint32_t kFec1Ssrc[] = {10, 11};
+const uint32_t kFec2Ssrc[] = {20, 21};
+const uint32_t kFec3Ssrc[] = {30, 31};
+
+const char kMediaStream1[] = "stream_1";
+const char kMediaStream2[] = "stream_2";
+const char kVideoTrack1[] = "video_1";
+const char kVideoTrack2[] = "video_2";
+const char kAudioTrack1[] = "audio_1";
+const char kAudioTrack2[] = "audio_2";
+const char kAudioTrack3[] = "audio_3";
+
+const char* kMediaProtocols[] = {"RTP/AVP", "RTP/SAVP", "RTP/AVPF",
+ "RTP/SAVPF"};
+const char* kMediaProtocolsDtls[] = {"TCP/TLS/RTP/SAVPF", "TCP/TLS/RTP/SAVP",
+ "UDP/TLS/RTP/SAVPF", "UDP/TLS/RTP/SAVP"};
// SRTP cipher name negotiated by the tests. This must be updated if the
// default changes.
-static const char* kDefaultSrtpCryptoSuite = kCsAesCm128HmacSha1_80;
-static const char* kDefaultSrtpCryptoSuiteGcm = kCsAeadAes256Gcm;
-static const uint8_t kDefaultCryptoSuiteSize = 3U;
+const char* kDefaultSrtpCryptoSuite = kCsAesCm128HmacSha1_80;
+const char* kDefaultSrtpCryptoSuiteGcm = kCsAeadAes256Gcm;
+const uint8_t kDefaultCryptoSuiteSize = 3U;
// These constants are used to make the code using "AddMediaDescriptionOptions"
// more readable.
-static constexpr bool kStopped = true;
-static constexpr bool kActive = false;
+constexpr bool kStopped = true;
+constexpr bool kActive = false;
-static bool IsMediaContentOfType(const ContentInfo* content,
- MediaType media_type) {
+bool IsMediaContentOfType(const ContentInfo* content, MediaType media_type) {
RTC_DCHECK(content);
return content->media_description()->type() == media_type;
}
-static RtpTransceiverDirection GetMediaDirection(const ContentInfo* content) {
+RtpTransceiverDirection GetMediaDirection(const ContentInfo* content) {
RTC_DCHECK(content);
return content->media_description()->direction();
}
-static void AddRtxCodec(const VideoCodec& rtx_codec,
- std::vector<VideoCodec>* codecs) {
- ASSERT_FALSE(cricket::FindCodecById(*codecs, rtx_codec.id));
+void AddRtxCodec(const VideoCodec& rtx_codec, std::vector<VideoCodec>* codecs) {
+ ASSERT_FALSE(FindCodecById(*codecs, rtx_codec.id));
codecs->push_back(rtx_codec);
}
-static std::vector<std::string> GetCodecNames(
- const std::vector<cricket::Codec>& codecs) {
+std::vector<std::string> GetCodecNames(const std::vector<Codec>& codecs) {
std::vector<std::string> codec_names;
codec_names.reserve(codecs.size());
for (const auto& codec : codecs) {
@@ -348,29 +309,29 @@ FindFirstMediaDescriptionByMid(const std::string& mid,
}
// Add a media section to the `session_options`.
-static void AddMediaDescriptionOptions(MediaType type,
- const std::string& mid,
- RtpTransceiverDirection direction,
- bool stopped,
- MediaSessionOptions* opts) {
+void AddMediaDescriptionOptions(MediaType type,
+ const std::string& mid,
+ RtpTransceiverDirection direction,
+ bool stopped,
+ MediaSessionOptions* opts) {
opts->media_description_options.push_back(
MediaDescriptionOptions(type, mid, direction, stopped));
}
-static void AddAudioVideoSections(RtpTransceiverDirection direction,
- MediaSessionOptions* opts) {
+void AddAudioVideoSections(RtpTransceiverDirection direction,
+ MediaSessionOptions* opts) {
AddMediaDescriptionOptions(MEDIA_TYPE_AUDIO, "audio", direction, kActive,
opts);
AddMediaDescriptionOptions(MEDIA_TYPE_VIDEO, "video", direction, kActive,
opts);
}
-static void AddDataSection(RtpTransceiverDirection direction,
- MediaSessionOptions* opts) {
+void AddDataSection(RtpTransceiverDirection direction,
+ MediaSessionOptions* opts) {
AddMediaDescriptionOptions(MEDIA_TYPE_DATA, "data", direction, kActive, opts);
}
-static void AttachSenderToMediaDescriptionOptions(
+void AttachSenderToMediaDescriptionOptions(
const std::string& mid,
MediaType type,
const std::string& track_id,
@@ -393,7 +354,7 @@ static void AttachSenderToMediaDescriptionOptions(
}
}
-static void AttachSenderToMediaDescriptionOptions(
+void AttachSenderToMediaDescriptionOptions(
const std::string& mid,
MediaType type,
const std::string& track_id,
@@ -405,23 +366,21 @@ static void AttachSenderToMediaDescriptionOptions(
session_options);
}
-static void DetachSenderFromMediaSection(const std::string& mid,
- const std::string& track_id,
- MediaSessionOptions* session_options) {
- std::vector<cricket::SenderOptions>& sender_options_list =
+void DetachSenderFromMediaSection(const std::string& mid,
+ const std::string& track_id,
+ MediaSessionOptions* session_options) {
+ std::vector<SenderOptions>& sender_options_list =
FindFirstMediaDescriptionByMid(mid, session_options)->sender_options;
- auto sender_it =
- absl::c_find_if(sender_options_list,
- [track_id](const cricket::SenderOptions& sender_options) {
- return sender_options.track_id == track_id;
- });
+ auto sender_it = absl::c_find_if(
+ sender_options_list, [track_id](const SenderOptions& sender_options) {
+ return sender_options.track_id == track_id;
+ });
RTC_DCHECK(sender_it != sender_options_list.end());
sender_options_list.erase(sender_it);
}
-// Helper function used to create a default MediaSessionOptions for Plan B SDP.
-// (https://tools.ietf.org/html/draft-uberti-rtcweb-plan-00).
-static MediaSessionOptions CreatePlanBMediaSessionOptions() {
+// Helper function used to create recv-only audio MediaSessionOptions.
+MediaSessionOptions CreateAudioMediaSession() {
MediaSessionOptions session_options;
AddMediaDescriptionOptions(MEDIA_TYPE_AUDIO, "audio",
RtpTransceiverDirection::kRecvOnly, kActive,
@@ -433,7 +392,7 @@ static MediaSessionOptions CreatePlanBMediaSessionOptions() {
void PreferGcmCryptoParameters(CryptoParamsVec* cryptos) {
cryptos->erase(
std::remove_if(cryptos->begin(), cryptos->end(),
- [](const cricket::CryptoParams& crypto) {
+ [](const CryptoParams& crypto) {
return crypto.crypto_suite != kCsAeadAes256Gcm &&
crypto.crypto_suite != kCsAeadAes128Gcm;
}),
@@ -444,7 +403,7 @@ void PreferGcmCryptoParameters(CryptoParamsVec* cryptos) {
// was designed for Plan B SDP, where only one audio "m=" section and one video
// "m=" section could be generated, and ordering couldn't be controlled. Many of
// these tests may be obsolete as a result, and should be refactored or removed.
-class MediaSessionDescriptionFactoryTest : public ::testing::Test {
+class MediaSessionDescriptionFactoryTest : public testing::Test {
public:
MediaSessionDescriptionFactoryTest()
: tdf1_(field_trials),
@@ -548,9 +507,9 @@ class MediaSessionDescriptionFactoryTest : public ::testing::Test {
EXPECT_EQ(current_audio_ufrag, ti_audio->description.ice_ufrag);
EXPECT_EQ(current_audio_pwd, ti_audio->description.ice_pwd);
} else {
- EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH),
+ EXPECT_EQ(static_cast<size_t>(ICE_UFRAG_LENGTH),
ti_audio->description.ice_ufrag.size());
- EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH),
+ EXPECT_EQ(static_cast<size_t>(ICE_PWD_LENGTH),
ti_audio->description.ice_pwd.size());
}
auto media_desc_options_it =
@@ -572,9 +531,9 @@ class MediaSessionDescriptionFactoryTest : public ::testing::Test {
EXPECT_EQ(current_video_ufrag, ti_video->description.ice_ufrag);
EXPECT_EQ(current_video_pwd, ti_video->description.ice_pwd);
} else {
- EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH),
+ EXPECT_EQ(static_cast<size_t>(ICE_UFRAG_LENGTH),
ti_video->description.ice_ufrag.size());
- EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH),
+ EXPECT_EQ(static_cast<size_t>(ICE_PWD_LENGTH),
ti_video->description.ice_pwd.size());
}
}
@@ -593,9 +552,9 @@ class MediaSessionDescriptionFactoryTest : public ::testing::Test {
EXPECT_EQ(current_data_ufrag, ti_data->description.ice_ufrag);
EXPECT_EQ(current_data_pwd, ti_data->description.ice_pwd);
} else {
- EXPECT_EQ(static_cast<size_t>(cricket::ICE_UFRAG_LENGTH),
+ EXPECT_EQ(static_cast<size_t>(ICE_UFRAG_LENGTH),
ti_data->description.ice_ufrag.size());
- EXPECT_EQ(static_cast<size_t>(cricket::ICE_PWD_LENGTH),
+ EXPECT_EQ(static_cast<size_t>(ICE_PWD_LENGTH),
ti_data->description.ice_pwd.size());
}
}
@@ -625,10 +584,10 @@ class MediaSessionDescriptionFactoryTest : public ::testing::Test {
f1_.CreateAnswerOrError(ref_desc.get(), options, nullptr).MoveValue();
}
ASSERT_TRUE(desc);
- const cricket::MediaContentDescription* audio_media_desc =
+ const MediaContentDescription* audio_media_desc =
desc->GetContentDescriptionByName("audio");
ASSERT_TRUE(audio_media_desc);
- const cricket::MediaContentDescription* video_media_desc =
+ const MediaContentDescription* video_media_desc =
desc->GetContentDescriptionByName("video");
ASSERT_TRUE(video_media_desc);
EXPECT_TRUE(CompareCryptoParams(audio_media_desc->cryptos(),
@@ -638,7 +597,7 @@ class MediaSessionDescriptionFactoryTest : public ::testing::Test {
// Verify the selected crypto is one from the reference audio
// media content.
- const cricket::MediaContentDescription* ref_audio_media_desc =
+ const MediaContentDescription* ref_audio_media_desc =
ref_desc->GetContentDescriptionByName("audio");
bool found = false;
for (size_t i = 0; i < ref_audio_media_desc->cryptos().size(); ++i) {
@@ -680,10 +639,10 @@ class MediaSessionDescriptionFactoryTest : public ::testing::Test {
EXPECT_EQ(expected_direction_in_answer, vcd_answer->direction());
}
- bool VerifyNoCNCodecs(const cricket::ContentInfo* content) {
+ bool VerifyNoCNCodecs(const ContentInfo* content) {
RTC_DCHECK(content);
RTC_CHECK(content->media_description());
- for (const cricket::Codec& codec : content->media_description()->codecs()) {
+ for (const Codec& codec : content->media_description()->codecs()) {
if (codec.name == "CN") {
return false;
}
@@ -706,7 +665,7 @@ class MediaSessionDescriptionFactoryTest : public ::testing::Test {
f1_.CreateOfferOrError(offer_opts, nullptr).MoveValue();
ASSERT_TRUE(offer.get());
if (gcm_offer && gcm_answer) {
- for (cricket::ContentInfo& content : offer->contents()) {
+ for (ContentInfo& content : offer->contents()) {
auto cryptos = content.media_description()->cryptos();
PreferGcmCryptoParameters(&cryptos);
content.media_description()->set_cryptos(cryptos);
@@ -720,8 +679,8 @@ class MediaSessionDescriptionFactoryTest : public ::testing::Test {
ASSERT_TRUE(vc);
EXPECT_EQ(MediaProtocolType::kRtp, ac->type);
EXPECT_EQ(MediaProtocolType::kRtp, vc->type);
- const AudioContentDescription* acd = ac->media_description()->as_audio();
- const VideoContentDescription* vcd = vc->media_description()->as_video();
+ const MediaContentDescription* acd = ac->media_description();
+ const MediaContentDescription* vcd = vc->media_description();
EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
EXPECT_THAT(acd->codecs(), ElementsAreArray(kAudioCodecsAnswer));
EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw
@@ -741,13 +700,13 @@ class MediaSessionDescriptionFactoryTest : public ::testing::Test {
} else {
ASSERT_CRYPTO(vcd, 1U, kDefaultSrtpCryptoSuite);
}
- EXPECT_EQ(cricket::kMediaProtocolSavpf, vcd->protocol());
+ EXPECT_EQ(kMediaProtocolSavpf, vcd->protocol());
}
void TestTransportSequenceNumberNegotiation(
- const cricket::RtpHeaderExtensions& local,
- const cricket::RtpHeaderExtensions& offered,
- const cricket::RtpHeaderExtensions& expectedAnswer) {
+ const RtpHeaderExtensions& local,
+ const RtpHeaderExtensions& offered,
+ const RtpHeaderExtensions& expectedAnswer) {
MediaSessionOptions opts;
AddAudioVideoSections(RtpTransceiverDirection::kRecvOnly, &opts);
SetAudioVideoRtpHeaderExtensions(offered, offered, &opts);
@@ -767,8 +726,7 @@ class MediaSessionDescriptionFactoryTest : public ::testing::Test {
}
std::vector<webrtc::RtpHeaderExtensionCapability>
- HeaderExtensionCapabilitiesFromRtpExtensions(
- cricket::RtpHeaderExtensions extensions) {
+ HeaderExtensionCapabilitiesFromRtpExtensions(RtpHeaderExtensions extensions) {
std::vector<webrtc::RtpHeaderExtensionCapability> capabilities;
for (const auto& extension : extensions) {
webrtc::RtpHeaderExtensionCapability capability(
@@ -779,8 +737,8 @@ class MediaSessionDescriptionFactoryTest : public ::testing::Test {
return capabilities;
}
- void SetAudioVideoRtpHeaderExtensions(cricket::RtpHeaderExtensions audio_exts,
- cricket::RtpHeaderExtensions video_exts,
+ void SetAudioVideoRtpHeaderExtensions(RtpHeaderExtensions audio_exts,
+ RtpHeaderExtensions video_exts,
MediaSessionOptions* opts) {
auto audio_caps = HeaderExtensionCapabilitiesFromRtpExtensions(audio_exts);
auto video_caps = HeaderExtensionCapabilitiesFromRtpExtensions(video_exts);
@@ -812,22 +770,21 @@ class MediaSessionDescriptionFactoryTest : public ::testing::Test {
TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioOffer) {
f1_.set_secure(SEC_ENABLED);
std::unique_ptr<SessionDescription> offer =
- f1_.CreateOfferOrError(CreatePlanBMediaSessionOptions(), nullptr)
- .MoveValue();
+ f1_.CreateOfferOrError(CreateAudioMediaSession(), nullptr).MoveValue();
ASSERT_TRUE(offer.get());
const ContentInfo* ac = offer->GetContentByName("audio");
const ContentInfo* vc = offer->GetContentByName("video");
ASSERT_TRUE(ac);
EXPECT_FALSE(vc);
EXPECT_EQ(MediaProtocolType::kRtp, ac->type);
- const AudioContentDescription* acd = ac->media_description()->as_audio();
+ const MediaContentDescription* acd = ac->media_description();
EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs());
EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached.
EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto)
EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on
ASSERT_CRYPTO(acd, kDefaultCryptoSuiteSize, kDefaultSrtpCryptoSuite);
- EXPECT_EQ(cricket::kMediaProtocolSavpf, acd->protocol());
+ EXPECT_EQ(kMediaProtocolSavpf, acd->protocol());
}
// Create an offer with just Opus and RED.
@@ -843,7 +800,7 @@ TEST_F(MediaSessionDescriptionFactoryTest,
EXPECT_EQ("opus", preferences[0].name);
EXPECT_EQ("red", preferences[1].name);
- auto opts = CreatePlanBMediaSessionOptions();
+ auto opts = CreateAudioMediaSession();
opts.media_description_options.at(0).codec_preferences = preferences;
std::unique_ptr<SessionDescription> offer =
f1_.CreateOfferOrError(opts, nullptr).MoveValue();
@@ -853,7 +810,7 @@ TEST_F(MediaSessionDescriptionFactoryTest,
ASSERT_TRUE(ac != NULL);
ASSERT_TRUE(vc == NULL);
EXPECT_EQ(MediaProtocolType::kRtp, ac->type);
- const AudioContentDescription* acd = ac->media_description()->as_audio();
+ const MediaContentDescription* acd = ac->media_description();
EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
EXPECT_EQ(2U, acd->codecs().size());
EXPECT_EQ("opus", acd->codecs()[0].name);
@@ -872,7 +829,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioOfferWithRedForOpus) {
EXPECT_EQ("red", preferences[0].name);
EXPECT_EQ("opus", preferences[1].name);
- auto opts = CreatePlanBMediaSessionOptions();
+ auto opts = CreateAudioMediaSession();
opts.media_description_options.at(0).codec_preferences = preferences;
std::unique_ptr<SessionDescription> offer =
f1_.CreateOfferOrError(opts, nullptr).MoveValue();
@@ -882,7 +839,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioOfferWithRedForOpus) {
ASSERT_TRUE(ac != NULL);
ASSERT_TRUE(vc == NULL);
EXPECT_EQ(MediaProtocolType::kRtp, ac->type);
- const AudioContentDescription* acd = ac->media_description()->as_audio();
+ const MediaContentDescription* acd = ac->media_description();
EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
EXPECT_EQ(2U, acd->codecs().size());
EXPECT_EQ("red", acd->codecs()[0].name);
@@ -903,22 +860,22 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoOffer) {
ASSERT_TRUE(vc);
EXPECT_EQ(MediaProtocolType::kRtp, ac->type);
EXPECT_EQ(MediaProtocolType::kRtp, vc->type);
- const AudioContentDescription* acd = ac->media_description()->as_audio();
- const VideoContentDescription* vcd = vc->media_description()->as_video();
+ const MediaContentDescription* acd = ac->media_description();
+ const MediaContentDescription* vcd = vc->media_description();
EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs());
EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached
EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // default bandwidth (auto)
EXPECT_TRUE(acd->rtcp_mux()); // rtcp-mux defaults on
ASSERT_CRYPTO(acd, kDefaultCryptoSuiteSize, kDefaultSrtpCryptoSuite);
- EXPECT_EQ(cricket::kMediaProtocolSavpf, acd->protocol());
+ EXPECT_EQ(kMediaProtocolSavpf, acd->protocol());
EXPECT_EQ(MEDIA_TYPE_VIDEO, vcd->type());
EXPECT_EQ(f1_.video_sendrecv_codecs(), vcd->codecs());
EXPECT_EQ(0U, vcd->first_ssrc()); // no sender is attached
EXPECT_EQ(kAutoBandwidth, vcd->bandwidth()); // default bandwidth (auto)
EXPECT_TRUE(vcd->rtcp_mux()); // rtcp-mux defaults on
ASSERT_CRYPTO(vcd, kDefaultCryptoSuiteSize, kDefaultSrtpCryptoSuite);
- EXPECT_EQ(cricket::kMediaProtocolSavpf, vcd->protocol());
+ EXPECT_EQ(kMediaProtocolSavpf, vcd->protocol());
}
// Test creating an offer with bundle where the Codecs have the same dynamic
@@ -978,9 +935,9 @@ TEST_F(MediaSessionDescriptionFactoryTest,
EXPECT_TRUE(acd);
ASSERT_CRYPTO(acd, 1U, kDefaultSrtpCryptoSuite);
- EXPECT_EQ(cricket::kMediaProtocolSavpf, acd->protocol());
+ EXPECT_EQ(kMediaProtocolSavpf, acd->protocol());
ASSERT_CRYPTO(vcd, 1U, kDefaultSrtpCryptoSuite);
- EXPECT_EQ(cricket::kMediaProtocolSavpf, vcd->protocol());
+ EXPECT_EQ(kMediaProtocolSavpf, vcd->protocol());
}
// Create an SCTP data offer with bundle without error.
@@ -996,7 +953,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSctpDataOffer) {
auto dcd = GetFirstSctpDataContentDescription(offer.get());
ASSERT_TRUE(dcd);
// Since this transport is insecure, the protocol should be "SCTP".
- EXPECT_EQ(cricket::kMediaProtocolSctp, dcd->protocol());
+ EXPECT_EQ(kMediaProtocolSctp, dcd->protocol());
}
// Create an SCTP data offer with bundle without error.
@@ -1013,7 +970,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSecureSctpDataOffer) {
auto dcd = GetFirstSctpDataContentDescription(offer.get());
ASSERT_TRUE(dcd);
// The protocol should now be "UDP/DTLS/SCTP"
- EXPECT_EQ(cricket::kMediaProtocolUdpDtlsSctp, dcd->protocol());
+ EXPECT_EQ(kMediaProtocolUdpDtlsSctp, dcd->protocol());
}
// Test creating an sctp data channel from an already generated offer.
@@ -1027,13 +984,13 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateImplicitSctpDataOffer) {
ASSERT_TRUE(offer1.get());
const ContentInfo* data = offer1->GetContentByName("data");
ASSERT_TRUE(data);
- ASSERT_EQ(cricket::kMediaProtocolSctp, data->media_description()->protocol());
+ ASSERT_EQ(kMediaProtocolSctp, data->media_description()->protocol());
std::unique_ptr<SessionDescription> offer2(
f1_.CreateOfferOrError(opts, offer1.get()).MoveValue());
data = offer2->GetContentByName("data");
ASSERT_TRUE(data);
- EXPECT_EQ(cricket::kMediaProtocolSctp, data->media_description()->protocol());
+ EXPECT_EQ(kMediaProtocolSctp, data->media_description()->protocol());
}
// Test that if BUNDLE is enabled and all media sections are rejected then the
@@ -1051,7 +1008,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, ReOfferNoBundleGroupIfAllRejected) {
std::unique_ptr<SessionDescription> reoffer =
f1_.CreateOfferOrError(opts, offer.get()).MoveValue();
- EXPECT_FALSE(reoffer->GetGroupByName(cricket::GROUP_TYPE_BUNDLE));
+ EXPECT_FALSE(reoffer->GetGroupByName(GROUP_TYPE_BUNDLE));
}
// Test that if BUNDLE is enabled and the remote re-offer does not include a
@@ -1074,7 +1031,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, ReAnswerNoBundleGroupIfAllRejected) {
std::unique_ptr<SessionDescription> reanswer =
f2_.CreateAnswerOrError(reoffer.get(), opts, answer.get()).MoveValue();
- EXPECT_FALSE(reanswer->GetGroupByName(cricket::GROUP_TYPE_BUNDLE));
+ EXPECT_FALSE(reanswer->GetGroupByName(GROUP_TYPE_BUNDLE));
}
// Test that if BUNDLE is enabled and the previous offerer-tagged media section
@@ -1097,8 +1054,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, ReOfferChangeBundleOffererTagged) {
std::unique_ptr<SessionDescription> reoffer =
f1_.CreateOfferOrError(opts, offer.get()).MoveValue();
- const cricket::ContentGroup* bundle_group =
- reoffer->GetGroupByName(cricket::GROUP_TYPE_BUNDLE);
+ const ContentGroup* bundle_group = reoffer->GetGroupByName(GROUP_TYPE_BUNDLE);
ASSERT_TRUE(bundle_group);
EXPECT_FALSE(bundle_group->HasContentName("audio"));
EXPECT_TRUE(bundle_group->HasContentName("video"));
@@ -1128,8 +1084,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, ReAnswerChangedBundleOffererTagged) {
std::unique_ptr<SessionDescription> reanswer =
f2_.CreateAnswerOrError(reoffer.get(), opts, answer.get()).MoveValue();
- const cricket::ContentGroup* bundle_group =
- reanswer->GetGroupByName(cricket::GROUP_TYPE_BUNDLE);
+ const ContentGroup* bundle_group =
+ reanswer->GetGroupByName(GROUP_TYPE_BUNDLE);
ASSERT_TRUE(bundle_group);
EXPECT_FALSE(bundle_group->HasContentName("audio"));
EXPECT_TRUE(bundle_group->HasContentName("video"));
@@ -1159,10 +1115,10 @@ TEST_F(MediaSessionDescriptionFactoryTest,
// Munge the offer to have two groups. Offers like these cannot be generated
// without munging, but it is valid to receive such offers from remote
// endpoints.
- cricket::ContentGroup bundle_group1(cricket::GROUP_TYPE_BUNDLE);
+ ContentGroup bundle_group1(GROUP_TYPE_BUNDLE);
bundle_group1.AddContentName("1");
bundle_group1.AddContentName("2");
- cricket::ContentGroup bundle_group2(cricket::GROUP_TYPE_BUNDLE);
+ ContentGroup bundle_group2(GROUP_TYPE_BUNDLE);
bundle_group2.AddContentName("3");
bundle_group2.AddContentName("4");
offer->AddGroup(bundle_group1);
@@ -1174,8 +1130,8 @@ TEST_F(MediaSessionDescriptionFactoryTest,
std::unique_ptr<SessionDescription> answer =
f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue();
- std::vector<const cricket::ContentGroup*> answer_groups =
- answer->GetGroupsByName(cricket::GROUP_TYPE_BUNDLE);
+ std::vector<const ContentGroup*> answer_groups =
+ answer->GetGroupsByName(GROUP_TYPE_BUNDLE);
ASSERT_EQ(answer_groups.size(), 2u);
EXPECT_EQ(answer_groups[0]->content_names().size(), 2u);
EXPECT_TRUE(answer_groups[0]->HasContentName("1"));
@@ -1189,7 +1145,7 @@ TEST_F(MediaSessionDescriptionFactoryTest,
opts.bundle_enabled = false;
answer = f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue();
- answer_groups = answer->GetGroupsByName(cricket::GROUP_TYPE_BUNDLE);
+ answer_groups = answer->GetGroupsByName(GROUP_TYPE_BUNDLE);
// Rejected groups are still listed, but they are empty.
ASSERT_EQ(answer_groups.size(), 2u);
EXPECT_TRUE(answer_groups[0]->content_names().empty());
@@ -1268,8 +1224,8 @@ TEST_F(MediaSessionDescriptionFactoryTest,
const ContentInfo* vc = offer->GetContentByName("video");
ASSERT_TRUE(ac);
ASSERT_TRUE(vc);
- const AudioContentDescription* acd = ac->media_description()->as_audio();
- const VideoContentDescription* vcd = vc->media_description()->as_video();
+ const MediaContentDescription* acd = ac->media_description();
+ const MediaContentDescription* vcd = vc->media_description();
EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams.
EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams.
@@ -1336,26 +1292,24 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswer) {
f1_.set_secure(SEC_ENABLED);
f2_.set_secure(SEC_ENABLED);
std::unique_ptr<SessionDescription> offer =
- f1_.CreateOfferOrError(CreatePlanBMediaSessionOptions(), nullptr)
- .MoveValue();
+ f1_.CreateOfferOrError(CreateAudioMediaSession(), nullptr).MoveValue();
ASSERT_TRUE(offer.get());
std::unique_ptr<SessionDescription> answer =
- f2_.CreateAnswerOrError(offer.get(), CreatePlanBMediaSessionOptions(),
- nullptr)
+ f2_.CreateAnswerOrError(offer.get(), CreateAudioMediaSession(), nullptr)
.MoveValue();
const ContentInfo* ac = answer->GetContentByName("audio");
const ContentInfo* vc = answer->GetContentByName("video");
ASSERT_TRUE(ac);
EXPECT_FALSE(vc);
EXPECT_EQ(MediaProtocolType::kRtp, ac->type);
- const AudioContentDescription* acd = ac->media_description()->as_audio();
+ const MediaContentDescription* acd = ac->media_description();
EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
EXPECT_THAT(acd->codecs(), ElementsAreArray(kAudioCodecsAnswer));
EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached
EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw
EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux
ASSERT_CRYPTO(acd, 1U, kDefaultSrtpCryptoSuite);
- EXPECT_EQ(cricket::kMediaProtocolSavpf, acd->protocol());
+ EXPECT_EQ(kMediaProtocolSavpf, acd->protocol());
}
// Create a typical audio answer with GCM ciphers enabled, and ensure it
@@ -1363,11 +1317,11 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswer) {
TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerGcm) {
f1_.set_secure(SEC_ENABLED);
f2_.set_secure(SEC_ENABLED);
- MediaSessionOptions opts = CreatePlanBMediaSessionOptions();
+ MediaSessionOptions opts = CreateAudioMediaSession();
std::unique_ptr<SessionDescription> offer =
f1_.CreateOfferOrError(opts, nullptr).MoveValue();
ASSERT_TRUE(offer.get());
- for (cricket::ContentInfo& content : offer->contents()) {
+ for (ContentInfo& content : offer->contents()) {
auto cryptos = content.media_description()->cryptos();
PreferGcmCryptoParameters(&cryptos);
content.media_description()->set_cryptos(cryptos);
@@ -1379,14 +1333,14 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateAudioAnswerGcm) {
ASSERT_TRUE(ac);
EXPECT_FALSE(vc);
EXPECT_EQ(MediaProtocolType::kRtp, ac->type);
- const AudioContentDescription* acd = ac->media_description()->as_audio();
+ const MediaContentDescription* acd = ac->media_description();
EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
EXPECT_THAT(acd->codecs(), ElementsAreArray(kAudioCodecsAnswer));
EXPECT_EQ(0U, acd->first_ssrc()); // no sender is attached
EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw
EXPECT_TRUE(acd->rtcp_mux()); // negotiated rtcp-mux
ASSERT_CRYPTO(acd, 1U, kDefaultSrtpCryptoSuiteGcm);
- EXPECT_EQ(cricket::kMediaProtocolSavpf, acd->protocol());
+ EXPECT_EQ(kMediaProtocolSavpf, acd->protocol());
}
// Create an audio answer with no common codecs, and ensure it is rejected.
@@ -1396,10 +1350,10 @@ TEST_F(MediaSessionDescriptionFactoryTest,
AddMediaDescriptionOptions(MEDIA_TYPE_AUDIO, "audio",
RtpTransceiverDirection::kSendRecv, kActive,
&opts);
- std::vector f1_codecs = {cricket::CreateAudioCodec(96, "opus", 48000, 1)};
+ std::vector f1_codecs = {CreateAudioCodec(96, "opus", 48000, 1)};
f1_.set_audio_codecs(f1_codecs, f1_codecs);
- std::vector f2_codecs = {cricket::CreateAudioCodec(0, "PCMU", 8000, 1)};
+ std::vector f2_codecs = {CreateAudioCodec(0, "PCMU", 8000, 1)};
f2_.set_audio_codecs(f2_codecs, f2_codecs);
std::unique_ptr<SessionDescription> offer =
@@ -1428,8 +1382,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswer) {
ASSERT_TRUE(vc);
EXPECT_EQ(MediaProtocolType::kRtp, ac->type);
EXPECT_EQ(MediaProtocolType::kRtp, vc->type);
- const AudioContentDescription* acd = ac->media_description()->as_audio();
- const VideoContentDescription* vcd = vc->media_description()->as_video();
+ const MediaContentDescription* acd = ac->media_description();
+ const MediaContentDescription* vcd = vc->media_description();
EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
EXPECT_THAT(acd->codecs(), ElementsAreArray(kAudioCodecsAnswer));
EXPECT_EQ(kAutoBandwidth, acd->bandwidth()); // negotiated auto bw
@@ -1441,7 +1395,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateVideoAnswer) {
EXPECT_EQ(0U, vcd->first_ssrc()); // no sender is attached
EXPECT_TRUE(vcd->rtcp_mux()); // negotiated rtcp-mux
ASSERT_CRYPTO(vcd, 1U, kDefaultSrtpCryptoSuite);
- EXPECT_EQ(cricket::kMediaProtocolSavpf, vcd->protocol());
+ EXPECT_EQ(kMediaProtocolSavpf, vcd->protocol());
}
// Create a typical video answer with GCM ciphers enabled, and ensure it
@@ -1469,10 +1423,10 @@ TEST_F(MediaSessionDescriptionFactoryTest,
AddMediaDescriptionOptions(MEDIA_TYPE_VIDEO, "video",
RtpTransceiverDirection::kSendRecv, kActive,
&opts);
- std::vector f1_codecs = {cricket::CreateVideoCodec(96, "H264")};
+ std::vector f1_codecs = {CreateVideoCodec(96, "H264")};
f1_.set_video_codecs(f1_codecs, f1_codecs);
- std::vector f2_codecs = {cricket::CreateVideoCodec(97, "VP8")};
+ std::vector f2_codecs = {CreateVideoCodec(97, "VP8")};
f2_.set_video_codecs(f2_codecs, f2_codecs);
std::unique_ptr<SessionDescription> offer =
@@ -1492,12 +1446,12 @@ TEST_F(MediaSessionDescriptionFactoryTest,
AddMediaDescriptionOptions(MEDIA_TYPE_VIDEO, "video",
RtpTransceiverDirection::kSendRecv, kActive,
&opts);
- std::vector f1_codecs = {cricket::CreateVideoCodec(96, "H264"),
- cricket::CreateVideoCodec(118, "flexfec-03")};
+ std::vector f1_codecs = {CreateVideoCodec(96, "H264"),
+ CreateVideoCodec(118, "flexfec-03")};
f1_.set_video_codecs(f1_codecs, f1_codecs);
- std::vector f2_codecs = {cricket::CreateVideoCodec(97, "VP8"),
- cricket::CreateVideoCodec(118, "flexfec-03")};
+ std::vector f2_codecs = {CreateVideoCodec(97, "VP8"),
+ CreateVideoCodec(118, "flexfec-03")};
f2_.set_video_codecs(f2_codecs, f2_codecs);
std::unique_ptr<SessionDescription> offer =
@@ -1648,7 +1602,7 @@ TEST_F(MediaSessionDescriptionFactoryTest,
const SctpDataContentDescription* dcd_answer =
dc_answer->media_description()->as_sctp();
EXPECT_FALSE(dc_answer->rejected);
- EXPECT_EQ(cricket::kSctpSendBufferSize, dcd_answer->max_message_size());
+ EXPECT_EQ(kSctpSendBufferSize, dcd_answer->max_message_size());
}
// Verifies that the order of the media contents in the offer is preserved in
@@ -1720,7 +1674,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, CreateAnswerToInactiveOffer) {
// Test that the media protocol is RTP/AVPF if DTLS and SDES are disabled.
TEST_F(MediaSessionDescriptionFactoryTest, AudioOfferAnswerWithCryptoDisabled) {
- MediaSessionOptions opts = CreatePlanBMediaSessionOptions();
+ MediaSessionOptions opts = CreateAudioMediaSession();
f1_.set_secure(SEC_DISABLED);
f2_.set_secure(SEC_DISABLED);
tdf1_.set_secure(SEC_DISABLED);
@@ -1731,7 +1685,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, AudioOfferAnswerWithCryptoDisabled) {
const AudioContentDescription* offer_acd =
GetFirstAudioContentDescription(offer.get());
ASSERT_TRUE(offer_acd);
- EXPECT_EQ(cricket::kMediaProtocolAvpf, offer_acd->protocol());
+ EXPECT_EQ(kMediaProtocolAvpf, offer_acd->protocol());
std::unique_ptr<SessionDescription> answer =
f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue();
@@ -1743,7 +1697,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, AudioOfferAnswerWithCryptoDisabled) {
const AudioContentDescription* answer_acd =
GetFirstAudioContentDescription(answer.get());
ASSERT_TRUE(answer_acd);
- EXPECT_EQ(cricket::kMediaProtocolAvpf, answer_acd->protocol());
+ EXPECT_EQ(kMediaProtocolAvpf, answer_acd->protocol());
}
// Create a video offer and answer and ensure the RTP header extensions
@@ -1886,9 +1840,9 @@ TEST_F(MediaSessionDescriptionFactoryTest,
MediaSessionOptions opts;
AddAudioVideoSections(RtpTransceiverDirection::kRecvOnly, &opts);
- const cricket::RtpHeaderExtensions offered_extensions = {
+ const RtpHeaderExtensions offered_extensions = {
RtpExtension(RtpExtension::kAbsoluteCaptureTimeUri, 7)};
- const cricket::RtpHeaderExtensions local_extensions = {
+ const RtpHeaderExtensions local_extensions = {
RtpExtension(RtpExtension::kTransportSequenceNumberUri, 5)};
SetAudioVideoRtpHeaderExtensions(offered_extensions, offered_extensions,
&opts);
@@ -1910,9 +1864,9 @@ TEST_F(MediaSessionDescriptionFactoryTest,
MediaSessionOptions opts;
AddAudioVideoSections(RtpTransceiverDirection::kRecvOnly, &opts);
- const cricket::RtpHeaderExtensions offered_extensions = {
+ const RtpHeaderExtensions offered_extensions = {
RtpExtension(RtpExtension::kAbsoluteCaptureTimeUri, 7)};
- const cricket::RtpHeaderExtensions local_extensions = {
+ const RtpHeaderExtensions local_extensions = {
RtpExtension(RtpExtension::kAbsoluteCaptureTimeUri, 5)};
SetAudioVideoRtpHeaderExtensions(offered_extensions, offered_extensions,
&opts);
@@ -1934,9 +1888,9 @@ TEST_F(MediaSessionDescriptionFactoryTest,
MediaSessionOptions opts;
AddAudioVideoSections(RtpTransceiverDirection::kRecvOnly, &opts);
- const cricket::RtpHeaderExtensions offered_extensions = {
+ const RtpHeaderExtensions offered_extensions = {
RtpExtension(RtpExtension::kTransportSequenceNumberUri, 7)};
- const cricket::RtpHeaderExtensions local_extensions = {
+ const RtpHeaderExtensions local_extensions = {
RtpExtension(RtpExtension::kAbsoluteCaptureTimeUri, 5)};
SetAudioVideoRtpHeaderExtensions(offered_extensions, offered_extensions,
&opts);
@@ -2257,8 +2211,8 @@ TEST_F(MediaSessionDescriptionFactoryTest,
const ContentInfo* vc = answer->GetContentByName("video");
ASSERT_TRUE(ac);
ASSERT_TRUE(vc);
- const AudioContentDescription* acd = ac->media_description()->as_audio();
- const VideoContentDescription* vcd = vc->media_description()->as_video();
+ const MediaContentDescription* acd = ac->media_description();
+ const MediaContentDescription* vcd = vc->media_description();
EXPECT_FALSE(acd->has_ssrcs()); // No StreamParams.
EXPECT_FALSE(vcd->has_ssrcs()); // No StreamParams.
@@ -2523,8 +2477,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) {
const ContentInfo* vc = offer->GetContentByName("video");
ASSERT_TRUE(ac);
ASSERT_TRUE(vc);
- const AudioContentDescription* acd = ac->media_description()->as_audio();
- const VideoContentDescription* vcd = vc->media_description()->as_video();
+ const MediaContentDescription* acd = ac->media_description();
+ const MediaContentDescription* vcd = vc->media_description();
EXPECT_EQ(MEDIA_TYPE_AUDIO, acd->type());
EXPECT_EQ(f1_.audio_sendrecv_codecs(), acd->codecs());
@@ -2568,10 +2522,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoOffer) {
vc = updated_offer->GetContentByName("video");
ASSERT_TRUE(ac);
ASSERT_TRUE(vc);
- const AudioContentDescription* updated_acd =
- ac->media_description()->as_audio();
- const VideoContentDescription* updated_vcd =
- vc->media_description()->as_video();
+ const MediaContentDescription* updated_acd = ac->media_description();
+ const MediaContentDescription* updated_vcd = vc->media_description();
EXPECT_EQ(acd->type(), updated_acd->type());
EXPECT_EQ(acd->codecs(), updated_acd->codecs());
@@ -2616,24 +2568,24 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateSimulcastVideoOffer) {
ASSERT_TRUE(offer.get());
const ContentInfo* vc = offer->GetContentByName("video");
ASSERT_TRUE(vc);
- const VideoContentDescription* vcd = vc->media_description()->as_video();
+ const MediaContentDescription* vcd = vc->media_description();
const StreamParamsVec& video_streams = vcd->streams();
ASSERT_EQ(1U, video_streams.size());
EXPECT_EQ(kVideoTrack1, video_streams[0].id);
const SsrcGroup* sim_ssrc_group =
- video_streams[0].get_ssrc_group(cricket::kSimSsrcGroupSemantics);
+ video_streams[0].get_ssrc_group(kSimSsrcGroupSemantics);
ASSERT_TRUE(sim_ssrc_group);
EXPECT_EQ(static_cast<size_t>(num_sim_layers), sim_ssrc_group->ssrcs.size());
}
MATCHER(RidDescriptionEquals, "Verifies that two RidDescriptions are equal.") {
- const RidDescription& rid1 = ::testing::get<0>(arg);
- const RidDescription& rid2 = ::testing::get<1>(arg);
+ const RidDescription& rid1 = std::get<0>(arg);
+ const RidDescription& rid2 = std::get<1>(arg);
return rid1.rid == rid2.rid && rid1.direction == rid2.direction;
}
-static void CheckSimulcastInSessionDescription(
+void CheckSimulcastInSessionDescription(
const SessionDescription* description,
const std::string& content_name,
const std::vector<RidDescription>& send_rids,
@@ -2828,8 +2780,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) {
const ContentInfo* vc = answer->GetContentByName("video");
ASSERT_TRUE(ac);
ASSERT_TRUE(vc);
- const AudioContentDescription* acd = ac->media_description()->as_audio();
- const VideoContentDescription* vcd = vc->media_description()->as_video();
+ const MediaContentDescription* acd = ac->media_description();
+ const MediaContentDescription* vcd = vc->media_description();
ASSERT_CRYPTO(acd, 1U, kDefaultSrtpCryptoSuite);
ASSERT_CRYPTO(vcd, 1U, kDefaultSrtpCryptoSuite);
@@ -2873,10 +2825,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateMultiStreamVideoAnswer) {
vc = updated_answer->GetContentByName("video");
ASSERT_TRUE(ac);
ASSERT_TRUE(vc);
- const AudioContentDescription* updated_acd =
- ac->media_description()->as_audio();
- const VideoContentDescription* updated_vcd =
- vc->media_description()->as_video();
+ const MediaContentDescription* updated_acd = ac->media_description();
+ const MediaContentDescription* updated_vcd = vc->media_description();
ASSERT_CRYPTO(updated_acd, 1U, kDefaultSrtpCryptoSuite);
EXPECT_TRUE(CompareCryptoParams(acd->cryptos(), updated_acd->cryptos()));
@@ -3082,14 +3032,12 @@ TEST_F(MediaSessionDescriptionFactoryTest,
&opts);
std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1);
// This creates rtx for H264 with the payload type `f1_` uses.
- AddRtxCodec(cricket::CreateVideoRtxCodec(126, kVideoCodecs1[1].id),
- &f1_codecs);
+ AddRtxCodec(CreateVideoRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs);
f1_.set_video_codecs(f1_codecs, f1_codecs);
std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2);
// This creates rtx for H264 with the payload type `f2_` uses.
- AddRtxCodec(cricket::CreateVideoRtxCodec(125, kVideoCodecs2[0].id),
- &f2_codecs);
+ AddRtxCodec(CreateVideoRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs);
f2_.set_video_codecs(f2_codecs, f2_codecs);
std::unique_ptr<SessionDescription> offer =
@@ -3102,8 +3050,7 @@ TEST_F(MediaSessionDescriptionFactoryTest,
GetFirstVideoContentDescription(answer.get());
std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer);
- AddRtxCodec(cricket::CreateVideoRtxCodec(126, kVideoCodecs1[1].id),
- &expected_codecs);
+ AddRtxCodec(CreateVideoRtxCodec(126, kVideoCodecs1[1].id), &expected_codecs);
EXPECT_EQ(expected_codecs, vcd->codecs());
@@ -3136,14 +3083,12 @@ TEST_F(MediaSessionDescriptionFactoryTest,
&opts);
// We specifically choose different preferred payload types for VP8 to
// trigger the issue.
- cricket::VideoCodec vp8_offerer = cricket::CreateVideoCodec(100, "VP8");
- cricket::VideoCodec vp8_offerer_rtx =
- cricket::CreateVideoRtxCodec(101, vp8_offerer.id);
- cricket::VideoCodec vp8_answerer = cricket::CreateVideoCodec(110, "VP8");
- cricket::VideoCodec vp8_answerer_rtx =
- cricket::CreateVideoRtxCodec(111, vp8_answerer.id);
- cricket::VideoCodec vp9 = cricket::CreateVideoCodec(120, "VP9");
- cricket::VideoCodec vp9_rtx = cricket::CreateVideoRtxCodec(121, vp9.id);
+ VideoCodec vp8_offerer = CreateVideoCodec(100, "VP8");
+ VideoCodec vp8_offerer_rtx = CreateVideoRtxCodec(101, vp8_offerer.id);
+ VideoCodec vp8_answerer = CreateVideoCodec(110, "VP8");
+ VideoCodec vp8_answerer_rtx = CreateVideoRtxCodec(111, vp8_answerer.id);
+ VideoCodec vp9 = CreateVideoCodec(120, "VP9");
+ VideoCodec vp9_rtx = CreateVideoRtxCodec(121, vp9.id);
std::vector<VideoCodec> f1_codecs = {vp8_offerer, vp8_offerer_rtx};
// We also specifically cause the answerer to prefer VP9, such that if it
@@ -3171,7 +3116,7 @@ TEST_F(MediaSessionDescriptionFactoryTest,
const VideoContentDescription* vcd =
GetFirstVideoContentDescription(updated_offer.get());
- std::vector<cricket::VideoCodec> codecs = vcd->codecs();
+ std::vector<VideoCodec> codecs = vcd->codecs();
ASSERT_EQ(4u, codecs.size());
EXPECT_EQ(vp8_offerer, codecs[0]);
EXPECT_EQ(vp8_offerer_rtx, codecs[1]);
@@ -3187,8 +3132,7 @@ TEST_F(MediaSessionDescriptionFactoryTest,
RespondentCreatesOfferWithVideoAndRtxAfterCreatingAudioAnswer) {
std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1);
// This creates rtx for H264 with the payload type `f1_` uses.
- AddRtxCodec(cricket::CreateVideoRtxCodec(126, kVideoCodecs1[1].id),
- &f1_codecs);
+ AddRtxCodec(CreateVideoRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs);
f1_.set_video_codecs(f1_codecs, f1_codecs);
MediaSessionOptions opts;
@@ -3214,7 +3158,7 @@ TEST_F(MediaSessionDescriptionFactoryTest,
std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2);
int used_pl_type = acd->codecs()[0].id;
f2_codecs[0].id = used_pl_type; // Set the payload type for H264.
- AddRtxCodec(cricket::CreateVideoRtxCodec(125, used_pl_type), &f2_codecs);
+ AddRtxCodec(CreateVideoRtxCodec(125, used_pl_type), &f2_codecs);
f2_.set_video_codecs(f2_codecs, f2_codecs);
std::unique_ptr<SessionDescription> updated_offer(
@@ -3232,12 +3176,12 @@ TEST_F(MediaSessionDescriptionFactoryTest,
GetFirstVideoContentDescription(updated_answer.get());
ASSERT_EQ("H264", updated_vcd->codecs()[0].name);
- ASSERT_EQ(cricket::kRtxCodecName, updated_vcd->codecs()[1].name);
+ ASSERT_EQ(kRtxCodecName, updated_vcd->codecs()[1].name);
int new_h264_pl_type = updated_vcd->codecs()[0].id;
EXPECT_NE(used_pl_type, new_h264_pl_type);
VideoCodec rtx = updated_vcd->codecs()[1];
- int pt_referenced_by_rtx = rtc::FromString<int>(
- rtx.params[cricket::kCodecParamAssociatedPayloadType]);
+ int pt_referenced_by_rtx =
+ rtc::FromString<int>(rtx.params[kCodecParamAssociatedPayloadType]);
EXPECT_EQ(new_h264_pl_type, pt_referenced_by_rtx);
}
@@ -3251,8 +3195,7 @@ TEST_F(MediaSessionDescriptionFactoryTest,
std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2);
// This creates rtx for H264 with the payload type `f2_` uses.
- AddRtxCodec(cricket::CreateVideoRtxCodec(125, kVideoCodecs2[0].id),
- &f2_codecs);
+ AddRtxCodec(CreateVideoRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs);
f2_.set_video_codecs(f2_codecs, f2_codecs);
std::unique_ptr<SessionDescription> offer =
@@ -3279,8 +3222,7 @@ TEST_F(MediaSessionDescriptionFactoryTest,
// New offer should attempt to add H263, and RTX for H264.
expected_codecs.push_back(kVideoCodecs2[1]);
- AddRtxCodec(cricket::CreateVideoRtxCodec(125, kVideoCodecs1[1].id),
- &expected_codecs);
+ AddRtxCodec(CreateVideoRtxCodec(125, kVideoCodecs1[1].id), &expected_codecs);
EXPECT_EQ(expected_codecs, updated_vcd->codecs());
}
@@ -3292,14 +3234,12 @@ TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) {
&opts);
std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1);
// This creates RTX without associated payload type parameter.
- AddRtxCodec(cricket::CreateVideoCodec(126, cricket::kRtxCodecName),
- &f1_codecs);
+ AddRtxCodec(CreateVideoCodec(126, kRtxCodecName), &f1_codecs);
f1_.set_video_codecs(f1_codecs, f1_codecs);
std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2);
// This creates RTX for H264 with the payload type `f2_` uses.
- AddRtxCodec(cricket::CreateVideoRtxCodec(125, kVideoCodecs2[0].id),
- &f2_codecs);
+ AddRtxCodec(CreateVideoRtxCodec(125, kVideoCodecs2[0].id), &f2_codecs);
f2_.set_video_codecs(f2_codecs, f2_codecs);
std::unique_ptr<SessionDescription> offer =
@@ -3310,23 +3250,22 @@ TEST_F(MediaSessionDescriptionFactoryTest, RtxWithoutApt) {
// is possible to test that that RTX is dropped when
// kCodecParamAssociatedPayloadType is missing in the offer.
MediaContentDescription* media_desc =
- offer->GetContentDescriptionByName(cricket::CN_VIDEO);
+ offer->GetContentDescriptionByName(CN_VIDEO);
ASSERT_TRUE(media_desc);
- VideoContentDescription* desc = media_desc->as_video();
- std::vector<VideoCodec> codecs = desc->codecs();
- for (VideoCodec& codec : codecs) {
- if (absl::StartsWith(codec.name, cricket::kRtxCodecName)) {
+ std::vector<Codec> codecs = media_desc->codecs();
+ for (Codec& codec : codecs) {
+ if (absl::StartsWith(codec.name, kRtxCodecName)) {
codec.params.clear();
}
}
- desc->set_codecs(codecs);
+ media_desc->set_codecs(codecs);
std::unique_ptr<SessionDescription> answer =
f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue();
EXPECT_THAT(
GetCodecNames(GetFirstVideoContentDescription(answer.get())->codecs()),
- Not(Contains(cricket::kRtxCodecName)));
+ Not(Contains(kRtxCodecName)));
}
// Test that RTX will be filtered out in the answer if its associated payload
@@ -3338,14 +3277,12 @@ TEST_F(MediaSessionDescriptionFactoryTest, FilterOutRtxIfAptDoesntMatch) {
&opts);
std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1);
// This creates RTX for H264 in sender.
- AddRtxCodec(cricket::CreateVideoRtxCodec(126, kVideoCodecs1[1].id),
- &f1_codecs);
+ AddRtxCodec(CreateVideoRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs);
f1_.set_video_codecs(f1_codecs, f1_codecs);
std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2);
// This creates RTX for H263 in receiver.
- AddRtxCodec(cricket::CreateVideoRtxCodec(125, kVideoCodecs2[1].id),
- &f2_codecs);
+ AddRtxCodec(CreateVideoRtxCodec(125, kVideoCodecs2[1].id), &f2_codecs);
f2_.set_video_codecs(f2_codecs, f2_codecs);
std::unique_ptr<SessionDescription> offer =
@@ -3358,7 +3295,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, FilterOutRtxIfAptDoesntMatch) {
EXPECT_THAT(
GetCodecNames(GetFirstVideoContentDescription(answer.get())->codecs()),
- Not(Contains(cricket::kRtxCodecName)));
+ Not(Contains(kRtxCodecName)));
}
// Test that when multiple RTX codecs are offered, only the matched RTX codec
@@ -3371,19 +3308,16 @@ TEST_F(MediaSessionDescriptionFactoryTest,
&opts);
std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1);
// This creates RTX for H264-SVC in sender.
- AddRtxCodec(cricket::CreateVideoRtxCodec(125, kVideoCodecs1[0].id),
- &f1_codecs);
+ AddRtxCodec(CreateVideoRtxCodec(125, kVideoCodecs1[0].id), &f1_codecs);
f1_.set_video_codecs(f1_codecs, f1_codecs);
// This creates RTX for H264 in sender.
- AddRtxCodec(cricket::CreateVideoRtxCodec(126, kVideoCodecs1[1].id),
- &f1_codecs);
+ AddRtxCodec(CreateVideoRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs);
f1_.set_video_codecs(f1_codecs, f1_codecs);
std::vector<VideoCodec> f2_codecs = MAKE_VECTOR(kVideoCodecs2);
// This creates RTX for H264 in receiver.
- AddRtxCodec(cricket::CreateVideoRtxCodec(124, kVideoCodecs2[0].id),
- &f2_codecs);
+ AddRtxCodec(CreateVideoRtxCodec(124, kVideoCodecs2[0].id), &f2_codecs);
f2_.set_video_codecs(f2_codecs, f1_codecs);
// H264-SVC codec is removed in the answer, therefore, associated RTX codec
@@ -3396,8 +3330,7 @@ TEST_F(MediaSessionDescriptionFactoryTest,
const VideoContentDescription* vcd =
GetFirstVideoContentDescription(answer.get());
std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecsAnswer);
- AddRtxCodec(cricket::CreateVideoRtxCodec(126, kVideoCodecs1[1].id),
- &expected_codecs);
+ AddRtxCodec(CreateVideoRtxCodec(126, kVideoCodecs1[1].id), &expected_codecs);
EXPECT_EQ(expected_codecs, vcd->codecs());
}
@@ -3411,8 +3344,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, AddSecondRtxInNewOffer) {
&opts);
std::vector<VideoCodec> f1_codecs = MAKE_VECTOR(kVideoCodecs1);
// This creates RTX for H264 for the offerer.
- AddRtxCodec(cricket::CreateVideoRtxCodec(126, kVideoCodecs1[1].id),
- &f1_codecs);
+ AddRtxCodec(CreateVideoRtxCodec(126, kVideoCodecs1[1].id), &f1_codecs);
f1_.set_video_codecs(f1_codecs, f1_codecs);
std::unique_ptr<SessionDescription> offer =
@@ -3422,13 +3354,11 @@ TEST_F(MediaSessionDescriptionFactoryTest, AddSecondRtxInNewOffer) {
GetFirstVideoContentDescription(offer.get());
std::vector<VideoCodec> expected_codecs = MAKE_VECTOR(kVideoCodecs1);
- AddRtxCodec(cricket::CreateVideoRtxCodec(126, kVideoCodecs1[1].id),
- &expected_codecs);
+ AddRtxCodec(CreateVideoRtxCodec(126, kVideoCodecs1[1].id), &expected_codecs);
EXPECT_EQ(expected_codecs, vcd->codecs());
// Now, attempt to add RTX for H264-SVC.
- AddRtxCodec(cricket::CreateVideoRtxCodec(125, kVideoCodecs1[0].id),
- &f1_codecs);
+ AddRtxCodec(CreateVideoRtxCodec(125, kVideoCodecs1[0].id), &f1_codecs);
f1_.set_video_codecs(f1_codecs, f1_codecs);
std::unique_ptr<SessionDescription> updated_offer(
@@ -3436,8 +3366,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, AddSecondRtxInNewOffer) {
ASSERT_TRUE(updated_offer);
vcd = GetFirstVideoContentDescription(updated_offer.get());
- AddRtxCodec(cricket::CreateVideoRtxCodec(125, kVideoCodecs1[0].id),
- &expected_codecs);
+ AddRtxCodec(CreateVideoRtxCodec(125, kVideoCodecs1[0].id), &expected_codecs);
EXPECT_EQ(expected_codecs, vcd->codecs());
}
@@ -3454,8 +3383,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) {
// Use a single real codec, and then add RTX for it.
std::vector<VideoCodec> f1_codecs;
- f1_codecs.push_back(cricket::CreateVideoCodec(97, "H264"));
- AddRtxCodec(cricket::CreateVideoRtxCodec(125, 97), &f1_codecs);
+ f1_codecs.push_back(CreateVideoCodec(97, "H264"));
+ AddRtxCodec(CreateVideoRtxCodec(125, 97), &f1_codecs);
f1_.set_video_codecs(f1_codecs, f1_codecs);
// Ensure that the offer has an RTX ssrc for each regular ssrc, and that there
@@ -3464,10 +3393,9 @@ TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateMultipleRtxSsrcs) {
f1_.CreateOfferOrError(opts, nullptr).MoveValue();
ASSERT_TRUE(offer.get());
MediaContentDescription* media_desc =
- offer->GetContentDescriptionByName(cricket::CN_VIDEO);
+ offer->GetContentDescriptionByName(CN_VIDEO);
ASSERT_TRUE(media_desc);
- VideoContentDescription* desc = media_desc->as_video();
- const StreamParamsVec& streams = desc->streams();
+ const StreamParamsVec& streams = media_desc->streams();
// Single stream.
ASSERT_EQ(1u, streams.size());
// Stream should have 6 ssrcs: 3 for video, 3 for RTX.
@@ -3499,8 +3427,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, GenerateFlexfecSsrc) {
// Use a single real codec, and then add FlexFEC for it.
std::vector<VideoCodec> f1_codecs;
- f1_codecs.push_back(cricket::CreateVideoCodec(97, "H264"));
- f1_codecs.push_back(cricket::CreateVideoCodec(118, "flexfec-03"));
+ f1_codecs.push_back(CreateVideoCodec(97, "H264"));
+ f1_codecs.push_back(CreateVideoCodec(118, "flexfec-03"));
f1_.set_video_codecs(f1_codecs, f1_codecs);
// Ensure that the offer has a single FlexFEC ssrc and that
@@ -3509,10 +3437,9 @@ TEST_F(MediaSessionDescriptionFactoryTest, GenerateFlexfecSsrc) {
f1_.CreateOfferOrError(opts, nullptr).MoveValue();
ASSERT_TRUE(offer.get());
MediaContentDescription* media_desc =
- offer->GetContentDescriptionByName(cricket::CN_VIDEO);
+ offer->GetContentDescriptionByName(CN_VIDEO);
ASSERT_TRUE(media_desc);
- VideoContentDescription* desc = media_desc->as_video();
- const StreamParamsVec& streams = desc->streams();
+ const StreamParamsVec& streams = media_desc->streams();
// Single stream.
ASSERT_EQ(1u, streams.size());
// Stream should have 2 ssrcs: 1 for video, 1 for FlexFEC.
@@ -3543,8 +3470,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateNoFlexfecSsrcs) {
// Use a single real codec, and then add FlexFEC for it.
std::vector<VideoCodec> f1_codecs;
- f1_codecs.push_back(cricket::CreateVideoCodec(97, "H264"));
- f1_codecs.push_back(cricket::CreateVideoCodec(118, "flexfec-03"));
+ f1_codecs.push_back(CreateVideoCodec(97, "H264"));
+ f1_codecs.push_back(CreateVideoCodec(118, "flexfec-03"));
f1_.set_video_codecs(f1_codecs, f1_codecs);
// Ensure that the offer has no FlexFEC ssrcs for each regular ssrc, and that
@@ -3553,10 +3480,9 @@ TEST_F(MediaSessionDescriptionFactoryTest, SimSsrcsGenerateNoFlexfecSsrcs) {
f1_.CreateOfferOrError(opts, nullptr).MoveValue();
ASSERT_TRUE(offer.get());
MediaContentDescription* media_desc =
- offer->GetContentDescriptionByName(cricket::CN_VIDEO);
+ offer->GetContentDescriptionByName(CN_VIDEO);
ASSERT_TRUE(media_desc);
- VideoContentDescription* desc = media_desc->as_video();
- const StreamParamsVec& streams = desc->streams();
+ const StreamParamsVec& streams = media_desc->streams();
// Single stream.
ASSERT_EQ(1u, streams.size());
// Stream should have 3 ssrcs: 3 for video, 0 for FlexFEC.
@@ -3704,33 +3630,33 @@ TEST_F(MediaSessionDescriptionFactoryTest, RtpExtensionIdReusedEncrypted) {
TEST(MediaSessionDescription, CopySessionDescription) {
SessionDescription source;
- cricket::ContentGroup group(cricket::CN_AUDIO);
+ ContentGroup group(CN_AUDIO);
source.AddGroup(group);
std::unique_ptr<AudioContentDescription> acd =
std::make_unique<AudioContentDescription>();
acd->set_codecs(MAKE_VECTOR(kAudioCodecs1));
acd->AddLegacyStream(1);
- source.AddContent(cricket::CN_AUDIO, MediaProtocolType::kRtp, acd->Clone());
+ source.AddContent(CN_AUDIO, MediaProtocolType::kRtp, acd->Clone());
std::unique_ptr<VideoContentDescription> vcd =
std::make_unique<VideoContentDescription>();
vcd->set_codecs(MAKE_VECTOR(kVideoCodecs1));
vcd->AddLegacyStream(2);
- source.AddContent(cricket::CN_VIDEO, MediaProtocolType::kRtp, vcd->Clone());
+ source.AddContent(CN_VIDEO, MediaProtocolType::kRtp, vcd->Clone());
std::unique_ptr<SessionDescription> copy = source.Clone();
ASSERT_TRUE(copy.get());
- EXPECT_TRUE(copy->HasGroup(cricket::CN_AUDIO));
+ EXPECT_TRUE(copy->HasGroup(CN_AUDIO));
const ContentInfo* ac = copy->GetContentByName("audio");
const ContentInfo* vc = copy->GetContentByName("video");
ASSERT_TRUE(ac);
ASSERT_TRUE(vc);
EXPECT_EQ(MediaProtocolType::kRtp, ac->type);
- const AudioContentDescription* acd_copy = ac->media_description()->as_audio();
+ const MediaContentDescription* acd_copy = ac->media_description();
EXPECT_EQ(acd->codecs(), acd_copy->codecs());
EXPECT_EQ(1u, acd->first_ssrc());
EXPECT_EQ(MediaProtocolType::kRtp, vc->type);
- const VideoContentDescription* vcd_copy = vc->media_description()->as_video();
+ const MediaContentDescription* vcd_copy = vc->media_description();
EXPECT_EQ(vcd->codecs(), vcd_copy->codecs());
EXPECT_EQ(2u, vcd->first_ssrc());
}
@@ -3870,18 +3796,16 @@ TEST_F(MediaSessionDescriptionFactoryTest,
tdf2_.set_secure(SEC_DISABLED);
std::unique_ptr<SessionDescription> offer =
- f1_.CreateOfferOrError(CreatePlanBMediaSessionOptions(), nullptr)
- .MoveValue();
+ f1_.CreateOfferOrError(CreateAudioMediaSession(), nullptr).MoveValue();
ASSERT_TRUE(offer.get());
ContentInfo* offer_content = offer->GetContentByName("audio");
ASSERT_TRUE(offer_content);
- AudioContentDescription* offer_audio_desc =
- offer_content->media_description()->as_audio();
- offer_audio_desc->set_protocol(cricket::kMediaProtocolDtlsSavpf);
+ MediaContentDescription* offer_audio_desc =
+ offer_content->media_description();
+ offer_audio_desc->set_protocol(kMediaProtocolDtlsSavpf);
std::unique_ptr<SessionDescription> answer =
- f2_.CreateAnswerOrError(offer.get(), CreatePlanBMediaSessionOptions(),
- nullptr)
+ f2_.CreateAnswerOrError(offer.get(), CreateAudioMediaSession(), nullptr)
.MoveValue();
ASSERT_TRUE(answer);
ContentInfo* answer_content = answer->GetContentByName("audio");
@@ -3899,18 +3823,16 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestOfferDtlsSavpfCreateAnswer) {
tdf2_.set_secure(SEC_ENABLED);
std::unique_ptr<SessionDescription> offer =
- f1_.CreateOfferOrError(CreatePlanBMediaSessionOptions(), nullptr)
- .MoveValue();
+ f1_.CreateOfferOrError(CreateAudioMediaSession(), nullptr).MoveValue();
ASSERT_TRUE(offer.get());
ContentInfo* offer_content = offer->GetContentByName("audio");
ASSERT_TRUE(offer_content);
- AudioContentDescription* offer_audio_desc =
- offer_content->media_description()->as_audio();
- offer_audio_desc->set_protocol(cricket::kMediaProtocolDtlsSavpf);
+ MediaContentDescription* offer_audio_desc =
+ offer_content->media_description();
+ offer_audio_desc->set_protocol(kMediaProtocolDtlsSavpf);
std::unique_ptr<SessionDescription> answer =
- f2_.CreateAnswerOrError(offer.get(), CreatePlanBMediaSessionOptions(),
- nullptr)
+ f2_.CreateAnswerOrError(offer.get(), CreateAudioMediaSession(), nullptr)
.MoveValue();
ASSERT_TRUE(answer);
@@ -3918,9 +3840,9 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestOfferDtlsSavpfCreateAnswer) {
ASSERT_TRUE(answer_content);
ASSERT_FALSE(answer_content->rejected);
- const AudioContentDescription* answer_audio_desc =
- answer_content->media_description()->as_audio();
- EXPECT_EQ(cricket::kMediaProtocolDtlsSavpf, answer_audio_desc->protocol());
+ const MediaContentDescription* answer_audio_desc =
+ answer_content->media_description();
+ EXPECT_EQ(kMediaProtocolDtlsSavpf, answer_audio_desc->protocol());
}
// Test that we include both SDES and DTLS in the offer, but only include SDES
@@ -3933,10 +3855,10 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoDtls) {
MediaSessionOptions options;
AddAudioVideoSections(RtpTransceiverDirection::kRecvOnly, &options);
std::unique_ptr<SessionDescription> offer, answer;
- const cricket::MediaContentDescription* audio_media_desc;
- const cricket::MediaContentDescription* video_media_desc;
- const cricket::TransportDescription* audio_trans_desc;
- const cricket::TransportDescription* video_trans_desc;
+ const MediaContentDescription* audio_media_desc;
+ const MediaContentDescription* video_media_desc;
+ const TransportDescription* audio_trans_desc;
+ const TransportDescription* video_trans_desc;
// Generate an offer with SDES and DTLS support.
offer = f1_.CreateOfferOrError(options, nullptr).MoveValue();
@@ -3985,8 +3907,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoDtls) {
ASSERT_TRUE(video_media_desc);
EXPECT_TRUE(audio_media_desc->cryptos().empty());
EXPECT_TRUE(video_media_desc->cryptos().empty());
- EXPECT_EQ(cricket::kMediaProtocolSavpf, audio_media_desc->protocol());
- EXPECT_EQ(cricket::kMediaProtocolSavpf, video_media_desc->protocol());
+ EXPECT_EQ(kMediaProtocolSavpf, audio_media_desc->protocol());
+ EXPECT_EQ(kMediaProtocolSavpf, video_media_desc->protocol());
audio_trans_desc = answer->GetTransportDescriptionByName("audio");
ASSERT_TRUE(audio_trans_desc);
@@ -4017,7 +3939,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoDtls) {
// Test that an answer can't be created if cryptos are required but the offer is
// unsecure.
TEST_F(MediaSessionDescriptionFactoryTest, TestSecureAnswerToUnsecureOffer) {
- MediaSessionOptions options = CreatePlanBMediaSessionOptions();
+ MediaSessionOptions options = CreateAudioMediaSession();
f1_.set_secure(SEC_DISABLED);
tdf1_.set_secure(SEC_DISABLED);
f2_.set_secure(SEC_REQUIRED);
@@ -4053,10 +3975,10 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoOfferDtlsButNotSdes) {
GetFirstVideoContentDescription(offer.get());
ASSERT_TRUE(video_offer->cryptos().empty());
- const cricket::TransportDescription* audio_offer_trans_desc =
+ const TransportDescription* audio_offer_trans_desc =
offer->GetTransportDescriptionByName("audio");
ASSERT_TRUE(audio_offer_trans_desc->identity_fingerprint.get());
- const cricket::TransportDescription* video_offer_trans_desc =
+ const TransportDescription* video_offer_trans_desc =
offer->GetTransportDescriptionByName("video");
ASSERT_TRUE(video_offer_trans_desc->identity_fingerprint.get());
@@ -4065,10 +3987,10 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCryptoOfferDtlsButNotSdes) {
f2_.CreateAnswerOrError(offer.get(), options, nullptr).MoveValue();
ASSERT_TRUE(answer.get());
- const cricket::TransportDescription* audio_answer_trans_desc =
+ const TransportDescription* audio_answer_trans_desc =
answer->GetTransportDescriptionByName("audio");
EXPECT_TRUE(audio_answer_trans_desc->identity_fingerprint.get());
- const cricket::TransportDescription* video_answer_trans_desc =
+ const TransportDescription* video_answer_trans_desc =
answer->GetTransportDescriptionByName("video");
EXPECT_TRUE(video_answer_trans_desc->identity_fingerprint.get());
}
@@ -4160,27 +4082,25 @@ TEST_F(MediaSessionDescriptionFactoryTest,
ASSERT_EQ(4u, offer->contents().size());
EXPECT_FALSE(offer->contents()[0].rejected);
- const AudioContentDescription* acd =
- offer->contents()[0].media_description()->as_audio();
+ const MediaContentDescription* acd = offer->contents()[0].media_description();
ASSERT_EQ(1u, acd->streams().size());
EXPECT_EQ(kAudioTrack1, acd->streams()[0].id);
EXPECT_EQ(RtpTransceiverDirection::kSendRecv, acd->direction());
EXPECT_FALSE(offer->contents()[1].rejected);
- const VideoContentDescription* vcd =
- offer->contents()[1].media_description()->as_video();
+ const MediaContentDescription* vcd = offer->contents()[1].media_description();
ASSERT_EQ(1u, vcd->streams().size());
EXPECT_EQ(kVideoTrack1, vcd->streams()[0].id);
EXPECT_EQ(RtpTransceiverDirection::kSendRecv, vcd->direction());
EXPECT_FALSE(offer->contents()[2].rejected);
- acd = offer->contents()[2].media_description()->as_audio();
+ acd = offer->contents()[2].media_description();
ASSERT_EQ(1u, acd->streams().size());
EXPECT_EQ(kAudioTrack2, acd->streams()[0].id);
EXPECT_EQ(RtpTransceiverDirection::kSendRecv, acd->direction());
EXPECT_FALSE(offer->contents()[3].rejected);
- vcd = offer->contents()[3].media_description()->as_video();
+ vcd = offer->contents()[3].media_description();
ASSERT_EQ(1u, vcd->streams().size());
EXPECT_EQ(kVideoTrack2, vcd->streams()[0].id);
EXPECT_EQ(RtpTransceiverDirection::kSendRecv, vcd->direction());
@@ -4223,27 +4143,27 @@ TEST_F(MediaSessionDescriptionFactoryTest,
ASSERT_EQ(4u, answer->contents().size());
EXPECT_FALSE(answer->contents()[0].rejected);
- const AudioContentDescription* acd =
- answer->contents()[0].media_description()->as_audio();
+ const MediaContentDescription* acd =
+ answer->contents()[0].media_description();
ASSERT_EQ(1u, acd->streams().size());
EXPECT_EQ(kAudioTrack1, acd->streams()[0].id);
EXPECT_EQ(RtpTransceiverDirection::kSendRecv, acd->direction());
EXPECT_FALSE(answer->contents()[1].rejected);
- const VideoContentDescription* vcd =
- answer->contents()[1].media_description()->as_video();
+ const MediaContentDescription* vcd =
+ answer->contents()[1].media_description();
ASSERT_EQ(1u, vcd->streams().size());
EXPECT_EQ(kVideoTrack1, vcd->streams()[0].id);
EXPECT_EQ(RtpTransceiverDirection::kSendRecv, vcd->direction());
EXPECT_FALSE(answer->contents()[2].rejected);
- acd = answer->contents()[2].media_description()->as_audio();
+ acd = answer->contents()[2].media_description();
ASSERT_EQ(1u, acd->streams().size());
EXPECT_EQ(kAudioTrack2, acd->streams()[0].id);
EXPECT_EQ(RtpTransceiverDirection::kSendRecv, acd->direction());
EXPECT_FALSE(answer->contents()[3].rejected);
- vcd = answer->contents()[3].media_description()->as_video();
+ vcd = answer->contents()[3].media_description();
ASSERT_EQ(1u, vcd->streams().size());
EXPECT_EQ(kVideoTrack2, vcd->streams()[0].id);
EXPECT_EQ(RtpTransceiverDirection::kSendRecv, vcd->direction());
@@ -4379,10 +4299,10 @@ TEST_F(MediaSessionDescriptionFactoryTest,
f1_.CreateOfferOrError(opts, nullptr).MoveValue();
ASSERT_TRUE(offer);
ASSERT_EQ(2u, offer->contents().size());
- const VideoContentDescription* vcd1 =
- offer->contents()[0].media_description()->as_video();
- const VideoContentDescription* vcd2 =
- offer->contents()[1].media_description()->as_video();
+ const MediaContentDescription* vcd1 =
+ offer->contents()[0].media_description();
+ const MediaContentDescription* vcd2 =
+ offer->contents()[1].media_description();
EXPECT_EQ(vcd1->codecs().size(), vcd2->codecs().size());
ASSERT_EQ(2u, vcd1->codecs().size());
EXPECT_EQ(vcd1->codecs()[0].name, vcd2->codecs()[0].name);
@@ -4395,8 +4315,8 @@ TEST_F(MediaSessionDescriptionFactoryTest,
f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue();
ASSERT_TRUE(answer);
ASSERT_EQ(2u, answer->contents().size());
- vcd1 = answer->contents()[0].media_description()->as_video();
- vcd2 = answer->contents()[1].media_description()->as_video();
+ vcd1 = answer->contents()[0].media_description();
+ vcd2 = answer->contents()[1].media_description();
EXPECT_EQ(vcd1->codecs().size(), vcd2->codecs().size());
ASSERT_EQ(1u, vcd1->codecs().size());
EXPECT_EQ(vcd1->codecs()[0].name, vcd2->codecs()[0].name);
@@ -4406,11 +4326,11 @@ TEST_F(MediaSessionDescriptionFactoryTest,
// Test verifying that negotiating codecs with the same packetization retains
// the packetization value.
TEST_F(MediaSessionDescriptionFactoryTest, PacketizationIsEqual) {
- std::vector f1_codecs = {cricket::CreateVideoCodec(96, "H264")};
+ std::vector f1_codecs = {CreateVideoCodec(96, "H264")};
f1_codecs.back().packetization = "raw";
f1_.set_video_codecs(f1_codecs, f1_codecs);
- std::vector f2_codecs = {cricket::CreateVideoCodec(96, "H264")};
+ std::vector f2_codecs = {CreateVideoCodec(96, "H264")};
f2_codecs.back().packetization = "raw";
f2_.set_video_codecs(f2_codecs, f2_codecs);
@@ -4424,8 +4344,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, PacketizationIsEqual) {
f1_.CreateOfferOrError(opts, nullptr).MoveValue();
ASSERT_TRUE(offer);
ASSERT_EQ(1u, offer->contents().size());
- const VideoContentDescription* vcd1 =
- offer->contents()[0].media_description()->as_video();
+ const MediaContentDescription* vcd1 =
+ offer->contents()[0].media_description();
ASSERT_EQ(1u, vcd1->codecs().size());
EXPECT_EQ(vcd1->codecs()[0].packetization, "raw");
@@ -4434,7 +4354,7 @@ TEST_F(MediaSessionDescriptionFactoryTest, PacketizationIsEqual) {
f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue();
ASSERT_TRUE(answer);
ASSERT_EQ(1u, answer->contents().size());
- vcd1 = answer->contents()[0].media_description()->as_video();
+ vcd1 = answer->contents()[0].media_description();
ASSERT_EQ(1u, vcd1->codecs().size());
EXPECT_EQ(vcd1->codecs()[0].packetization, "raw");
}
@@ -4442,11 +4362,11 @@ TEST_F(MediaSessionDescriptionFactoryTest, PacketizationIsEqual) {
// Test verifying that negotiating codecs with different packetization removes
// the packetization value.
TEST_F(MediaSessionDescriptionFactoryTest, PacketizationIsDifferent) {
- std::vector f1_codecs = {cricket::CreateVideoCodec(96, "H264")};
+ std::vector f1_codecs = {CreateVideoCodec(96, "H264")};
f1_codecs.back().packetization = "raw";
f1_.set_video_codecs(f1_codecs, f1_codecs);
- std::vector f2_codecs = {cricket::CreateVideoCodec(96, "H264")};
+ std::vector f2_codecs = {CreateVideoCodec(96, "H264")};
f2_codecs.back().packetization = "notraw";
f2_.set_video_codecs(f2_codecs, f2_codecs);
@@ -4491,10 +4411,9 @@ TEST_F(MediaSessionDescriptionFactoryTest,
f1_.CreateOfferOrError(opts, nullptr).MoveValue();
ASSERT_TRUE(offer);
ASSERT_EQ(2u, offer->contents().size());
- VideoContentDescription* vcd1 =
- offer->contents()[0].media_description()->as_video();
- const VideoContentDescription* vcd2 =
- offer->contents()[1].media_description()->as_video();
+ MediaContentDescription* vcd1 = offer->contents()[0].media_description();
+ const MediaContentDescription* vcd2 =
+ offer->contents()[1].media_description();
auto video_codecs = MAKE_VECTOR(kVideoCodecs1);
EXPECT_EQ(video_codecs, vcd1->codecs());
EXPECT_EQ(video_codecs, vcd2->codecs());
@@ -4505,8 +4424,8 @@ TEST_F(MediaSessionDescriptionFactoryTest,
vcd1->set_codecs(video_codecs_reverse);
std::unique_ptr<SessionDescription> updated_offer(
f1_.CreateOfferOrError(opts, offer.get()).MoveValue());
- vcd1 = updated_offer->contents()[0].media_description()->as_video();
- vcd2 = updated_offer->contents()[1].media_description()->as_video();
+ vcd1 = updated_offer->contents()[0].media_description();
+ vcd2 = updated_offer->contents()[1].media_description();
// The video codec preference order should be respected.
EXPECT_EQ(video_codecs_reverse, vcd1->codecs());
EXPECT_EQ(video_codecs, vcd2->codecs());
@@ -4528,10 +4447,9 @@ TEST_F(MediaSessionDescriptionFactoryTest,
f1_.CreateOfferOrError(opts, nullptr).MoveValue();
ASSERT_TRUE(offer);
ASSERT_EQ(2u, offer->contents().size());
- VideoContentDescription* vcd1 =
- offer->contents()[0].media_description()->as_video();
- const VideoContentDescription* vcd2 =
- offer->contents()[1].media_description()->as_video();
+ MediaContentDescription* vcd1 = offer->contents()[0].media_description();
+ const MediaContentDescription* vcd2 =
+ offer->contents()[1].media_description();
auto video_codecs = MAKE_VECTOR(kVideoCodecs1);
EXPECT_EQ(video_codecs, vcd1->codecs());
EXPECT_EQ(video_codecs, vcd2->codecs());
@@ -4542,8 +4460,8 @@ TEST_F(MediaSessionDescriptionFactoryTest,
vcd1->set_codecs(video_codecs_reverse);
std::unique_ptr<SessionDescription> answer =
f1_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue();
- vcd1 = answer->contents()[0].media_description()->as_video();
- vcd2 = answer->contents()[1].media_description()->as_video();
+ vcd1 = answer->contents()[0].media_description();
+ vcd2 = answer->contents()[1].media_description();
// The video codec preference order should be respected.
EXPECT_EQ(video_codecs_reverse, vcd1->codecs());
EXPECT_EQ(video_codecs, vcd2->codecs());
@@ -4586,8 +4504,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, CreateAnswerWithLocalCodecParams) {
std::unique_ptr<SessionDescription> offer =
f1_.CreateOfferOrError(opts, nullptr).MoveValue();
ASSERT_TRUE(offer);
- auto offer_acd = offer->contents()[0].media_description()->as_audio();
- auto offer_vcd = offer->contents()[1].media_description()->as_video();
+ auto offer_acd = offer->contents()[0].media_description();
+ auto offer_vcd = offer->contents()[1].media_description();
std::string value;
EXPECT_TRUE(offer_acd->codecs()[0].GetParam(audio_param_name, &value));
EXPECT_EQ(audio_value1, value);
@@ -4597,8 +4515,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, CreateAnswerWithLocalCodecParams) {
std::unique_ptr<SessionDescription> answer =
f2_.CreateAnswerOrError(offer.get(), opts, nullptr).MoveValue();
ASSERT_TRUE(answer);
- auto answer_acd = answer->contents()[0].media_description()->as_audio();
- auto answer_vcd = answer->contents()[1].media_description()->as_video();
+ auto answer_acd = answer->contents()[0].media_description();
+ auto answer_vcd = answer->contents()[1].media_description();
// Use the parameters from the local codecs.
EXPECT_TRUE(answer_acd->codecs()[0].GetParam(audio_param_name, &value));
EXPECT_EQ(audio_value2, value);
@@ -4615,12 +4533,12 @@ TEST_F(MediaSessionDescriptionFactoryTest,
H264MatchCriteriaIncludesPacketizationMode) {
// Create two H264 codecs with the same profile level ID and different
// packetization modes.
- VideoCodec h264_pm0 = cricket::CreateVideoCodec(96, "H264");
- h264_pm0.params[cricket::kH264FmtpProfileLevelId] = "42c01f";
- h264_pm0.params[cricket::kH264FmtpPacketizationMode] = "0";
- VideoCodec h264_pm1 = cricket::CreateVideoCodec(97, "H264");
- h264_pm1.params[cricket::kH264FmtpProfileLevelId] = "42c01f";
- h264_pm1.params[cricket::kH264FmtpPacketizationMode] = "1";
+ VideoCodec h264_pm0 = CreateVideoCodec(96, "H264");
+ h264_pm0.params[kH264FmtpProfileLevelId] = "42c01f";
+ h264_pm0.params[kH264FmtpPacketizationMode] = "0";
+ VideoCodec h264_pm1 = CreateVideoCodec(97, "H264");
+ h264_pm1.params[kH264FmtpProfileLevelId] = "42c01f";
+ h264_pm1.params[kH264FmtpPacketizationMode] = "1";
// Offerer will send both codecs, answerer should choose the one with matching
// packetization mode (and not the first one it sees).
@@ -4643,13 +4561,13 @@ TEST_F(MediaSessionDescriptionFactoryTest,
// Answer should have one negotiated codec with packetization-mode=1 using the
// offered payload type.
ASSERT_EQ(1u, answer->contents().size());
- auto answer_vcd = answer->contents()[0].media_description()->as_video();
+ auto answer_vcd = answer->contents()[0].media_description();
ASSERT_EQ(1u, answer_vcd->codecs().size());
auto answer_codec = answer_vcd->codecs()[0];
EXPECT_EQ(h264_pm1.id, answer_codec.id);
}
-class MediaProtocolTest : public ::testing::TestWithParam<const char*> {
+class MediaProtocolTest : public testing::TestWithParam<const char*> {
public:
MediaProtocolTest()
: tdf1_(field_trials_),
@@ -4702,18 +4620,18 @@ TEST_P(MediaProtocolTest, TestAudioVideoAcceptance) {
ASSERT_TRUE(vc);
EXPECT_FALSE(ac->rejected); // the offer is accepted
EXPECT_FALSE(vc->rejected);
- const AudioContentDescription* acd = ac->media_description()->as_audio();
- const VideoContentDescription* vcd = vc->media_description()->as_video();
+ const MediaContentDescription* acd = ac->media_description();
+ const MediaContentDescription* vcd = vc->media_description();
EXPECT_EQ(GetParam(), acd->protocol());
EXPECT_EQ(GetParam(), vcd->protocol());
}
INSTANTIATE_TEST_SUITE_P(MediaProtocolPatternTest,
MediaProtocolTest,
- ::testing::ValuesIn(kMediaProtocols));
+ ValuesIn(kMediaProtocols));
INSTANTIATE_TEST_SUITE_P(MediaProtocolDtlsPatternTest,
MediaProtocolTest,
- ::testing::ValuesIn(kMediaProtocolsDtls));
+ ValuesIn(kMediaProtocolsDtls));
TEST_F(MediaSessionDescriptionFactoryTest, TestSetAudioCodecs) {
webrtc::test::ScopedKeyValueConfig field_trials;
@@ -4769,17 +4687,15 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestSetAudioCodecs) {
EXPECT_EQ(no_codecs, sf.audio_sendrecv_codecs());
}
-namespace {
// Compare the two vectors of codecs ignoring the payload type.
-bool CodecsMatch(const std::vector<cricket::Codec>& codecs1,
- const std::vector<cricket::Codec>& codecs2,
- const webrtc::FieldTrialsView* field_trials) {
+bool CodecsMatch(const std::vector<Codec>& codecs1,
+ const std::vector<Codec>& codecs2) {
if (codecs1.size() != codecs2.size()) {
return false;
}
for (size_t i = 0; i < codecs1.size(); ++i) {
- if (!codecs1[i].Matches(codecs2[i], field_trials)) {
+ if (!codecs1[i].Matches(codecs2[i])) {
return false;
}
}
@@ -4817,29 +4733,29 @@ void TestAudioCodecsOffer(RtpTransceiverDirection direction) {
// send nor receive audio. The checks are still in place if at some point
// we'd instead create an inactive stream.
if (ac) {
- AudioContentDescription* acd = ac->media_description()->as_audio();
+ MediaContentDescription* acd = ac->media_description();
// sendrecv and inactive should both present lists as if the channel was
// to be used for sending and receiving. Inactive essentially means it
// might eventually be used anything, but we don't know more at this
// moment.
if (acd->direction() == RtpTransceiverDirection::kSendOnly) {
- EXPECT_TRUE(CodecsMatch(send_codecs, acd->codecs(), &field_trials));
+ EXPECT_TRUE(CodecsMatch(send_codecs, acd->codecs()));
} else if (acd->direction() == RtpTransceiverDirection::kRecvOnly) {
- EXPECT_TRUE(CodecsMatch(recv_codecs, acd->codecs(), &field_trials));
+ EXPECT_TRUE(CodecsMatch(recv_codecs, acd->codecs()));
} else {
- EXPECT_TRUE(CodecsMatch(sendrecv_codecs, acd->codecs(), &field_trials));
+ EXPECT_TRUE(CodecsMatch(sendrecv_codecs, acd->codecs()));
}
}
}
-static const AudioCodec kOfferAnswerCodecs[] = {
- cricket::CreateAudioCodec(0, "codec0", 16000, 1),
- cricket::CreateAudioCodec(1, "codec1", 8000, 1),
- cricket::CreateAudioCodec(2, "codec2", 8000, 1),
- cricket::CreateAudioCodec(3, "codec3", 8000, 1),
- cricket::CreateAudioCodec(4, "codec4", 8000, 2),
- cricket::CreateAudioCodec(5, "codec5", 32000, 1),
- cricket::CreateAudioCodec(6, "codec6", 48000, 1)};
+const AudioCodec kOfferAnswerCodecs[] = {
+ CreateAudioCodec(0, "codec0", 16000, 1),
+ CreateAudioCodec(1, "codec1", 8000, 1),
+ CreateAudioCodec(2, "codec2", 8000, 1),
+ CreateAudioCodec(3, "codec3", 8000, 1),
+ CreateAudioCodec(4, "codec4", 8000, 2),
+ CreateAudioCodec(5, "codec5", 32000, 1),
+ CreateAudioCodec(6, "codec6", 48000, 1)};
/* The codecs groups below are chosen as per the matrix below. The objective
* is to have different sets of codecs in the inputs, to get unique sets of
@@ -4860,18 +4776,18 @@ static const AudioCodec kOfferAnswerCodecs[] = {
* 6 | x x x | x x x | x x x x x
*/
// Codecs used by offerer in the AudioCodecsAnswerTest
-static const int kOfferSendCodecs[] = {0, 1, 3, 5, 6};
-static const int kOfferRecvCodecs[] = {1, 2, 3, 4, 6};
+const int kOfferSendCodecs[] = {0, 1, 3, 5, 6};
+const int kOfferRecvCodecs[] = {1, 2, 3, 4, 6};
// Codecs used in the answerer in the AudioCodecsAnswerTest. The order is
// jumbled to catch the answer not following the order in the offer.
-static const int kAnswerSendCodecs[] = {6, 5, 2, 3, 4};
-static const int kAnswerRecvCodecs[] = {6, 5, 4, 1, 0};
+const int kAnswerSendCodecs[] = {6, 5, 2, 3, 4};
+const int kAnswerRecvCodecs[] = {6, 5, 4, 1, 0};
// The resulting sets of codecs in the answer in the AudioCodecsAnswerTest
-static const int kResultSend_RecvCodecs[] = {0, 1, 5, 6};
-static const int kResultRecv_SendCodecs[] = {2, 3, 4, 6};
-static const int kResultSendrecv_SendCodecs[] = {3, 6};
-static const int kResultSendrecv_RecvCodecs[] = {1, 6};
-static const int kResultSendrecv_SendrecvCodecs[] = {6};
+const int kResultSend_RecvCodecs[] = {0, 1, 5, 6};
+const int kResultRecv_SendCodecs[] = {2, 3, 4, 6};
+const int kResultSendrecv_SendCodecs[] = {3, 6};
+const int kResultSendrecv_RecvCodecs[] = {1, 6};
+const int kResultSendrecv_SendrecvCodecs[] = {6};
template <typename T, int IDXS>
std::vector<T> VectorFromIndices(const T* array, const int (&indices)[IDXS]) {
@@ -4936,7 +4852,7 @@ void TestAudioCodecsAnswer(RtpTransceiverDirection offer_direction,
// we'd instead create an inactive stream.
if (ac) {
ASSERT_EQ(MEDIA_TYPE_AUDIO, ac->media_description()->type());
- const AudioContentDescription* acd = ac->media_description()->as_audio();
+ const MediaContentDescription* acd = ac->media_description();
std::vector<AudioCodec> target_codecs;
// For offers with sendrecv or inactive, we should never reply with more
@@ -4998,10 +4914,7 @@ void TestAudioCodecsAnswer(RtpTransceiverDirection offer_direction,
}
}
-} // namespace
-
-class AudioCodecsOfferTest
- : public ::testing::TestWithParam<RtpTransceiverDirection> {};
+using AudioCodecsOfferTest = testing::TestWithParam<RtpTransceiverDirection>;
TEST_P(AudioCodecsOfferTest, TestCodecsInOffer) {
TestAudioCodecsOffer(GetParam());
@@ -5009,31 +4922,30 @@ TEST_P(AudioCodecsOfferTest, TestCodecsInOffer) {
INSTANTIATE_TEST_SUITE_P(MediaSessionDescriptionFactoryTest,
AudioCodecsOfferTest,
- ::testing::Values(RtpTransceiverDirection::kSendOnly,
- RtpTransceiverDirection::kRecvOnly,
- RtpTransceiverDirection::kSendRecv,
- RtpTransceiverDirection::kInactive));
+ Values(RtpTransceiverDirection::kSendOnly,
+ RtpTransceiverDirection::kRecvOnly,
+ RtpTransceiverDirection::kSendRecv,
+ RtpTransceiverDirection::kInactive));
-class AudioCodecsAnswerTest
- : public ::testing::TestWithParam<::testing::tuple<RtpTransceiverDirection,
- RtpTransceiverDirection,
- bool>> {};
+using AudioCodecsAnswerTest = testing::TestWithParam<
+ std::tuple<RtpTransceiverDirection, RtpTransceiverDirection, bool>>;
TEST_P(AudioCodecsAnswerTest, TestCodecsInAnswer) {
- TestAudioCodecsAnswer(::testing::get<0>(GetParam()),
- ::testing::get<1>(GetParam()),
- ::testing::get<2>(GetParam()));
-}
-
-INSTANTIATE_TEST_SUITE_P(
- MediaSessionDescriptionFactoryTest,
- AudioCodecsAnswerTest,
- ::testing::Combine(::testing::Values(RtpTransceiverDirection::kSendOnly,
- RtpTransceiverDirection::kRecvOnly,
- RtpTransceiverDirection::kSendRecv,
- RtpTransceiverDirection::kInactive),
- ::testing::Values(RtpTransceiverDirection::kSendOnly,
- RtpTransceiverDirection::kRecvOnly,
- RtpTransceiverDirection::kSendRecv,
- RtpTransceiverDirection::kInactive),
- ::testing::Bool()));
+ TestAudioCodecsAnswer(std::get<0>(GetParam()), std::get<1>(GetParam()),
+ std::get<2>(GetParam()));
+}
+
+INSTANTIATE_TEST_SUITE_P(MediaSessionDescriptionFactoryTest,
+ AudioCodecsAnswerTest,
+ Combine(Values(RtpTransceiverDirection::kSendOnly,
+ RtpTransceiverDirection::kRecvOnly,
+ RtpTransceiverDirection::kSendRecv,
+ RtpTransceiverDirection::kInactive),
+ Values(RtpTransceiverDirection::kSendOnly,
+ RtpTransceiverDirection::kRecvOnly,
+ RtpTransceiverDirection::kSendRecv,
+ RtpTransceiverDirection::kInactive),
+ Bool()));
+
+} // namespace
+} // namespace cricket
diff --git a/third_party/libwebrtc/pc/media_stream_unittest.cc b/third_party/libwebrtc/pc/media_stream_unittest.cc
index f55ea203fb..d6c79efae9 100644
--- a/third_party/libwebrtc/pc/media_stream_unittest.cc
+++ b/third_party/libwebrtc/pc/media_stream_unittest.cc
@@ -91,7 +91,7 @@ TEST_F(MediaStreamTest, GetTrackInfo) {
ASSERT_EQ(1u, stream_->GetAudioTracks().size());
// Verify the video track.
- scoped_refptr<webrtc::MediaStreamTrackInterface> video_track(
+ scoped_refptr<MediaStreamTrackInterface> video_track(
stream_->GetVideoTracks()[0]);
EXPECT_EQ(0, video_track->id().compare(kVideoTrackId));
EXPECT_TRUE(video_track->enabled());
@@ -105,7 +105,7 @@ TEST_F(MediaStreamTest, GetTrackInfo) {
EXPECT_TRUE(video_track->enabled());
// Verify the audio track.
- scoped_refptr<webrtc::MediaStreamTrackInterface> audio_track(
+ scoped_refptr<MediaStreamTrackInterface> audio_track(
stream_->GetAudioTracks()[0]);
EXPECT_EQ(0, audio_track->id().compare(kAudioTrackId));
EXPECT_TRUE(audio_track->enabled());
@@ -139,14 +139,12 @@ TEST_F(MediaStreamTest, RemoveTrack) {
}
TEST_F(MediaStreamTest, ChangeVideoTrack) {
- scoped_refptr<webrtc::VideoTrackInterface> video_track(
- stream_->GetVideoTracks()[0]);
+ scoped_refptr<VideoTrackInterface> video_track(stream_->GetVideoTracks()[0]);
ChangeTrack(video_track.get());
}
TEST_F(MediaStreamTest, ChangeAudioTrack) {
- scoped_refptr<webrtc::AudioTrackInterface> audio_track(
- stream_->GetAudioTracks()[0]);
+ scoped_refptr<AudioTrackInterface> audio_track(stream_->GetAudioTracks()[0]);
ChangeTrack(audio_track.get());
}
diff --git a/third_party/libwebrtc/pc/peer_connection.cc b/third_party/libwebrtc/pc/peer_connection.cc
index 183cbeb7cd..26b70c63db 100644
--- a/third_party/libwebrtc/pc/peer_connection.cc
+++ b/third_party/libwebrtc/pc/peer_connection.cc
@@ -23,6 +23,7 @@
#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
+#include "api/environment/environment.h"
#include "api/jsep_ice_candidate.h"
#include "api/media_types.h"
#include "api/rtp_parameters.h"
@@ -185,7 +186,7 @@ IceCandidatePairType GetIceCandidatePairCounter(
absl::optional<int> RTCConfigurationToIceConfigOptionalInt(
int rtc_configuration_parameter) {
if (rtc_configuration_parameter ==
- webrtc::PeerConnectionInterface::RTCConfiguration::kUndefined) {
+ PeerConnectionInterface::RTCConfiguration::kUndefined) {
return absl::nullopt;
}
return rtc_configuration_parameter;
@@ -449,7 +450,7 @@ bool PeerConnectionInterface::RTCConfiguration::operator==(
absl::optional<int> ice_unwritable_min_checks;
absl::optional<int> ice_inactive_timeout;
absl::optional<int> stun_candidate_keepalive_interval;
- webrtc::TurnCustomizer* turn_customizer;
+ TurnCustomizer* turn_customizer;
SdpSemantics sdp_semantics;
absl::optional<rtc::AdapterType> network_preference;
bool active_reset_srtp_params;
@@ -459,7 +460,7 @@ bool PeerConnectionInterface::RTCConfiguration::operator==(
bool enable_implicit_rollback;
absl::optional<int> report_usage_pattern_delay_ms;
absl::optional<int> stable_writable_connection_ping_interval_ms;
- webrtc::VpnPreference vpn_preference;
+ VpnPreference vpn_preference;
std::vector<rtc::NetworkMask> vpn_list;
PortAllocatorConfig port_allocator_config;
absl::optional<TimeDelta> pacer_burst_interval;
@@ -536,9 +537,9 @@ bool PeerConnectionInterface::RTCConfiguration::operator!=(
}
RTCErrorOr<rtc::scoped_refptr<PeerConnection>> PeerConnection::Create(
+ const Environment& env,
rtc::scoped_refptr<ConnectionContext> context,
const PeerConnectionFactoryInterface::Options& options,
- std::unique_ptr<RtcEventLog> event_log,
std::unique_ptr<Call> call,
const PeerConnectionInterface::RTCConfiguration& configuration,
PeerConnectionDependencies dependencies) {
@@ -577,36 +578,15 @@ RTCErrorOr<rtc::scoped_refptr<PeerConnection>> PeerConnection::Create(
configuration.sdp_semantics == SdpSemantics::kUnifiedPlan;
bool dtls_enabled = DtlsEnabled(configuration, options, dependencies);
- // Interim code: If an AsyncResolverFactory is given, but not an
- // AsyncDnsResolverFactory, wrap it in a WrappingAsyncDnsResolverFactory
- // If neither is given, create a BasicAsyncDnsResolverFactory.
- // TODO(bugs.webrtc.org/12598): Remove code once all callers pass a
- // AsyncDnsResolverFactory.
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- if (dependencies.async_dns_resolver_factory &&
- dependencies.async_resolver_factory) {
- RTC_LOG(LS_ERROR)
- << "Attempt to set both old and new type of DNS resolver factory";
- return RTCError(RTCErrorType::INVALID_PARAMETER,
- "Both old and new type of DNS resolver given");
- }
if (!dependencies.async_dns_resolver_factory) {
- if (dependencies.async_resolver_factory) {
- dependencies.async_dns_resolver_factory =
- std::make_unique<WrappingAsyncDnsResolverFactory>(
- std::move(dependencies.async_resolver_factory));
- } else {
dependencies.async_dns_resolver_factory =
std::make_unique<BasicAsyncDnsResolverFactory>();
- }
}
-#pragma clang diagnostic pop
// The PeerConnection constructor consumes some, but not all, dependencies.
auto pc = rtc::make_ref_counted<PeerConnection>(
- context, options, is_unified_plan, std::move(event_log), std::move(call),
- dependencies, dtls_enabled);
+ env, context, options, is_unified_plan, std::move(call), dependencies,
+ dtls_enabled);
RTCError init_error = pc->Initialize(configuration, std::move(dependencies));
if (!init_error.ok()) {
RTC_LOG(LS_ERROR) << "PeerConnection initialization failed";
@@ -616,20 +596,18 @@ RTCErrorOr<rtc::scoped_refptr<PeerConnection>> PeerConnection::Create(
}
PeerConnection::PeerConnection(
+ const Environment& env,
rtc::scoped_refptr<ConnectionContext> context,
const PeerConnectionFactoryInterface::Options& options,
bool is_unified_plan,
- std::unique_ptr<RtcEventLog> event_log,
std::unique_ptr<Call> call,
PeerConnectionDependencies& dependencies,
bool dtls_enabled)
- : context_(context),
- trials_(std::move(dependencies.trials), &context->field_trials()),
+ : env_(env),
+ context_(context),
options_(options),
observer_(dependencies.observer),
is_unified_plan_(is_unified_plan),
- event_log_(std::move(event_log)),
- event_log_ptr_(event_log_.get()),
async_dns_resolver_factory_(
std::move(dependencies.async_dns_resolver_factory)),
port_allocator_(std::move(dependencies.allocator)),
@@ -648,7 +626,10 @@ PeerConnection::PeerConnection(
dtls_enabled_(dtls_enabled),
data_channel_controller_(this),
message_handler_(signaling_thread()),
- weak_factory_(this) {}
+ weak_factory_(this) {
+ // Field trials specific to the peerconnection should be owned by the `env`,
+ RTC_DCHECK(dependencies.trials == nullptr);
+}
PeerConnection::~PeerConnection() {
TRACE_EVENT0("webrtc", "PeerConnection::~PeerConnection");
@@ -699,13 +680,11 @@ PeerConnection::~PeerConnection() {
sctp_mid_s_.reset();
SetSctpTransportName("");
- // call_ and event_log_ must be destroyed on the worker thread.
+ // call_ must be destroyed on the worker thread.
worker_thread()->BlockingCall([this] {
RTC_DCHECK_RUN_ON(worker_thread());
worker_thread_safety_->SetNotAlive();
call_.reset();
- // The event log must outlive call (and any other object that uses it).
- event_log_.reset();
});
data_channel_controller_.PrepareForShutdown();
@@ -797,7 +776,7 @@ JsepTransportController* PeerConnection::InitializeTransportController_n(
config.transport_observer = this;
config.rtcp_handler = InitializeRtcpCallback();
config.un_demuxable_packet_handler = InitializeUnDemuxablePacketHandler();
- config.event_log = event_log_ptr_;
+ config.event_log = &env_.event_log();
#if defined(ENABLE_EXTERNAL_AUTH)
config.enable_external_auth = true;
#endif
@@ -816,7 +795,7 @@ JsepTransportController* PeerConnection::InitializeTransportController_n(
}
};
- config.field_trials = trials_.get();
+ config.field_trials = &env_.field_trials();
transport_controller_.reset(new JsepTransportController(
network_thread(), port_allocator_.get(),
@@ -1685,7 +1664,7 @@ void PeerConnection::AddIceCandidate(
std::function<void(RTCError)> callback) {
RTC_DCHECK_RUN_ON(signaling_thread());
sdp_handler_->AddIceCandidate(std::move(candidate),
- [this, callback](webrtc::RTCError result) {
+ [this, callback](RTCError result) {
ClearStatsCache();
callback(result);
});
@@ -1789,7 +1768,7 @@ bool PeerConnection::StartRtcEventLog(
std::unique_ptr<RtcEventLogOutput> output) {
int64_t output_period_ms = 5000;
if (trials().IsDisabled("WebRTC-RtcEventLogNewFormat")) {
- output_period_ms = webrtc::RtcEventLog::kImmediateOutput;
+ output_period_ms = RtcEventLog::kImmediateOutput;
}
return StartRtcEventLog(std::move(output), output_period_ms);
}
@@ -1931,8 +1910,7 @@ void PeerConnection::Close() {
RTC_DCHECK_RUN_ON(worker_thread());
worker_thread_safety_->SetNotAlive();
call_.reset();
- // The event log must outlive call (and any other object that uses it).
- event_log_.reset();
+ StopRtcEventLog_w();
});
ReportUsagePattern();
@@ -2029,13 +2007,13 @@ void PeerConnection::ReportFirstConnectUsageMetrics() {
RTC_HISTOGRAM_ENUMERATION("WebRTC.PeerConnection.ProvisionalAnswer", pranswer,
kProvisionalAnswerMax);
- // Record the number of valid / invalid ice-ufrag. We do allow certain
- // non-spec ice-char for backward-compat reasons. At this point we know
- // that the ufrag/pwd consists of a valid ice-char or one of the four
- // not allowed characters since we have passed the IsIceChar check done
- // by the p2p transport description on setRemoteDescription calls.
auto transport_infos = remote_description()->description()->transport_infos();
- if (transport_infos.size() > 0) {
+ if (!transport_infos.empty()) {
+ // Record the number of valid / invalid ice-ufrag. We do allow certain
+ // non-spec ice-char for backward-compat reasons. At this point we know
+ // that the ufrag/pwd consists of a valid ice-char or one of the four
+ // not allowed characters since we have passed the IsIceChar check done
+ // by the p2p transport description on setRemoteDescription calls.
auto ice_parameters = transport_infos[0].description.GetIceParameters();
auto is_invalid_char = [](char c) {
return c == '-' || c == '=' || c == '#' || c == '_';
@@ -2047,6 +2025,16 @@ void PeerConnection::ReportFirstConnectUsageMetrics() {
RTC_HISTOGRAM_BOOLEAN(
"WebRTC.PeerConnection.ValidIceChars",
!(isUsingInvalidIceCharInUfrag || isUsingInvalidIceCharInPwd));
+
+ // Record whether the hash algorithm of the first transport's
+ // DTLS fingerprint is still using SHA-1.
+ if (transport_infos[0].description.identity_fingerprint) {
+ RTC_HISTOGRAM_BOOLEAN(
+ "WebRTC.PeerConnection.DtlsFingerprintLegacySha1",
+ absl::EqualsIgnoreCase(
+ transport_infos[0].description.identity_fingerprint->algorithm,
+ "sha-1"));
+ }
}
// Record RtcpMuxPolicy setting.
@@ -2222,7 +2210,7 @@ bool PeerConnection::ReconfigurePortAllocator_n(
IceTransportsType type,
int candidate_pool_size,
PortPrunePolicy turn_port_prune_policy,
- webrtc::TurnCustomizer* turn_customizer,
+ TurnCustomizer* turn_customizer,
absl::optional<int> stun_candidate_keepalive_interval,
bool have_local_description) {
RTC_DCHECK_RUN_ON(network_thread());
@@ -2245,17 +2233,15 @@ bool PeerConnection::StartRtcEventLog_w(
std::unique_ptr<RtcEventLogOutput> output,
int64_t output_period_ms) {
RTC_DCHECK_RUN_ON(worker_thread());
- if (!event_log_) {
+ if (!worker_thread_safety_->alive()) {
return false;
}
- return event_log_->StartLogging(std::move(output), output_period_ms);
+ return env_.event_log().StartLogging(std::move(output), output_period_ms);
}
void PeerConnection::StopRtcEventLog_w() {
RTC_DCHECK_RUN_ON(worker_thread());
- if (event_log_) {
- event_log_->StopLogging();
- }
+ env_.event_log().StopLogging();
}
absl::optional<rtc::SSLRole> PeerConnection::GetSctpSslRole_n() {
diff --git a/third_party/libwebrtc/pc/peer_connection.h b/third_party/libwebrtc/pc/peer_connection.h
index ea1a9d9d90..e6037a2698 100644
--- a/third_party/libwebrtc/pc/peer_connection.h
+++ b/third_party/libwebrtc/pc/peer_connection.h
@@ -27,6 +27,7 @@
#include "api/crypto/crypto_options.h"
#include "api/data_channel_interface.h"
#include "api/dtls_transport_interface.h"
+#include "api/environment/environment.h"
#include "api/field_trials_view.h"
#include "api/ice_transport_interface.h"
#include "api/jsep.h"
@@ -110,9 +111,9 @@ class PeerConnection : public PeerConnectionInternal,
// Note that the function takes ownership of dependencies, and will
// either use them or release them, whether it succeeds or fails.
static RTCErrorOr<rtc::scoped_refptr<PeerConnection>> Create(
+ const Environment& env,
rtc::scoped_refptr<ConnectionContext> context,
const PeerConnectionFactoryInterface::Options& options,
- std::unique_ptr<RtcEventLog> event_log,
std::unique_ptr<Call> call,
const PeerConnectionInterface::RTCConfiguration& configuration,
PeerConnectionDependencies dependencies);
@@ -163,7 +164,7 @@ class PeerConnection : public PeerConnectionInternal,
const DataChannelInit* config) override;
// WARNING: LEGACY. See peerconnectioninterface.h
bool GetStats(StatsObserver* observer,
- webrtc::MediaStreamTrackInterface* track,
+ MediaStreamTrackInterface* track,
StatsOutputLevel level) override;
// Spec-complaint GetStats(). See peerconnectioninterface.h
void GetStats(RTCStatsCollectorCallback* callback) override;
@@ -428,7 +429,7 @@ class PeerConnection : public PeerConnectionInternal,
void TeardownDataChannelTransport_n(RTCError error)
RTC_RUN_ON(network_thread());
- const FieldTrialsView& trials() const override { return *trials_; }
+ const FieldTrialsView& trials() const override { return env_.field_trials(); }
bool ConfiguredForMedia() const;
@@ -441,10 +442,10 @@ class PeerConnection : public PeerConnectionInternal,
protected:
// Available for rtc::scoped_refptr creation
- PeerConnection(rtc::scoped_refptr<ConnectionContext> context,
+ PeerConnection(const Environment& env,
+ rtc::scoped_refptr<ConnectionContext> context,
const PeerConnectionFactoryInterface::Options& options,
bool is_unified_plan,
- std::unique_ptr<RtcEventLog> event_log,
std::unique_ptr<Call> call,
PeerConnectionDependencies& dependencies,
bool dtls_enabled);
@@ -510,7 +511,7 @@ class PeerConnection : public PeerConnectionInternal,
IceTransportsType type,
int candidate_pool_size,
PortPrunePolicy turn_port_prune_policy,
- webrtc::TurnCustomizer* turn_customizer,
+ TurnCustomizer* turn_customizer,
absl::optional<int> stun_candidate_keepalive_interval,
bool have_local_description);
@@ -597,26 +598,14 @@ class PeerConnection : public PeerConnectionInternal,
std::function<void(const RtpPacketReceived& parsed_packet)>
InitializeUnDemuxablePacketHandler();
+ const Environment env_;
const rtc::scoped_refptr<ConnectionContext> context_;
- // Field trials active for this PeerConnection is the first of:
- // a) Specified in PeerConnectionDependencies (owned).
- // b) Accessed via ConnectionContext (e.g PeerConnectionFactoryDependencies>
- // c) Created as Default (FieldTrialBasedConfig).
- const webrtc::AlwaysValidPointer<const FieldTrialsView, FieldTrialBasedConfig>
- trials_;
const PeerConnectionFactoryInterface::Options options_;
PeerConnectionObserver* observer_ RTC_GUARDED_BY(signaling_thread()) =
nullptr;
const bool is_unified_plan_;
- // The EventLog needs to outlive `call_` (and any other object that uses it).
- std::unique_ptr<RtcEventLog> event_log_ RTC_GUARDED_BY(worker_thread());
-
- // Points to the same thing as `event_log_`. Since it's const, we may read the
- // pointer (but not touch the object) from any thread.
- RtcEventLog* const event_log_ptr_ RTC_PT_GUARDED_BY(worker_thread());
-
IceConnectionState ice_connection_state_ RTC_GUARDED_BY(signaling_thread()) =
kIceConnectionNew;
PeerConnectionInterface::IceConnectionState standardized_ice_connection_state_
@@ -634,7 +623,7 @@ class PeerConnection : public PeerConnectionInternal,
std::unique_ptr<cricket::PortAllocator>
port_allocator_; // TODO(bugs.webrtc.org/9987): Accessed on both
// signaling and network thread.
- const std::unique_ptr<webrtc::IceTransportFactory>
+ const std::unique_ptr<IceTransportFactory>
ice_transport_factory_; // TODO(bugs.webrtc.org/9987): Accessed on the
// signaling thread but the underlying raw
// pointer is given to
diff --git a/third_party/libwebrtc/pc/peer_connection_crypto_unittest.cc b/third_party/libwebrtc/pc/peer_connection_crypto_unittest.cc
index dc350b2be0..a65988ab05 100644
--- a/third_party/libwebrtc/pc/peer_connection_crypto_unittest.cc
+++ b/third_party/libwebrtc/pc/peer_connection_crypto_unittest.cc
@@ -162,7 +162,7 @@ class PeerConnectionCryptoBaseTest : public ::testing::Test {
return transport_info->description.connection_role;
}
- webrtc::test::ScopedKeyValueConfig field_trials_;
+ test::ScopedKeyValueConfig field_trials_;
std::unique_ptr<rtc::VirtualSocketServer> vss_;
rtc::AutoSocketServerThread main_;
rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory_;
diff --git a/third_party/libwebrtc/pc/peer_connection_data_channel_unittest.cc b/third_party/libwebrtc/pc/peer_connection_data_channel_unittest.cc
index 3bb2088866..8682cfa9fb 100644
--- a/third_party/libwebrtc/pc/peer_connection_data_channel_unittest.cc
+++ b/third_party/libwebrtc/pc/peer_connection_data_channel_unittest.cc
@@ -15,7 +15,6 @@
#include <vector>
#include "absl/types/optional.h"
-#include "api/call/call_factory_interface.h"
#include "api/jsep.h"
#include "api/media_types.h"
#include "api/peer_connection_interface.h"
@@ -24,8 +23,6 @@
#include "api/task_queue/default_task_queue_factory.h"
#include "api/task_queue/task_queue_factory.h"
#include "api/transport/sctp_transport_factory_interface.h"
-#include "media/base/fake_media_engine.h"
-#include "media/base/media_engine.h"
#include "p2p/base/p2p_constants.h"
#include "p2p/base/port_allocator.h"
#include "pc/media_session.h"
@@ -35,6 +32,7 @@
#include "pc/sctp_transport.h"
#include "pc/sdp_utils.h"
#include "pc/session_description.h"
+#include "pc/test/enable_fake_media.h"
#include "pc/test/mock_peer_connection_observers.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
@@ -64,8 +62,7 @@ PeerConnectionFactoryDependencies CreatePeerConnectionFactoryDependencies() {
deps.worker_thread = rtc::Thread::Current();
deps.signaling_thread = rtc::Thread::Current();
deps.task_queue_factory = CreateDefaultTaskQueueFactory();
- deps.media_engine = std::make_unique<cricket::FakeMediaEngine>();
- deps.call_factory = CreateCallFactory();
+ EnableFakeMedia(deps);
deps.sctp_factory = std::make_unique<FakeSctpTransportFactory>();
return deps;
}
diff --git a/third_party/libwebrtc/pc/peer_connection_encodings_integrationtest.cc b/third_party/libwebrtc/pc/peer_connection_encodings_integrationtest.cc
index c7181c53ae..ae238671c2 100644
--- a/third_party/libwebrtc/pc/peer_connection_encodings_integrationtest.cc
+++ b/third_party/libwebrtc/pc/peer_connection_encodings_integrationtest.cc
@@ -77,18 +77,17 @@ struct StringParamToString {
// RTX, RED and FEC are reliability mechanisms used in combinations with other
// codecs, but are not themselves a specific codec. Typically you don't want to
// filter these out of the list of codec preferences.
-bool IsReliabilityMechanism(const webrtc::RtpCodecCapability& codec) {
+bool IsReliabilityMechanism(const RtpCodecCapability& codec) {
return absl::EqualsIgnoreCase(codec.name, cricket::kRtxCodecName) ||
absl::EqualsIgnoreCase(codec.name, cricket::kRedCodecName) ||
absl::EqualsIgnoreCase(codec.name, cricket::kUlpfecCodecName);
}
std::string GetCurrentCodecMimeType(
- rtc::scoped_refptr<const webrtc::RTCStatsReport> report,
- const webrtc::RTCOutboundRtpStreamStats& outbound_rtp) {
+ rtc::scoped_refptr<const RTCStatsReport> report,
+ const RTCOutboundRtpStreamStats& outbound_rtp) {
return outbound_rtp.codec_id.is_defined()
- ? *report->GetAs<webrtc::RTCCodecStats>(*outbound_rtp.codec_id)
- ->mime_type
+ ? *report->GetAs<RTCCodecStats>(*outbound_rtp.codec_id)->mime_type
: "";
}
@@ -98,8 +97,8 @@ struct RidAndResolution {
uint32_t height;
};
-const webrtc::RTCOutboundRtpStreamStats* FindOutboundRtpByRid(
- const std::vector<const webrtc::RTCOutboundRtpStreamStats*>& outbound_rtps,
+const RTCOutboundRtpStreamStats* FindOutboundRtpByRid(
+ const std::vector<const RTCOutboundRtpStreamStats*>& outbound_rtps,
const absl::string_view& rid) {
for (const auto* outbound_rtp : outbound_rtps) {
if (outbound_rtp->rid.is_defined() && *outbound_rtp->rid == rid) {
@@ -121,8 +120,8 @@ class PeerConnectionEncodingsIntegrationTest : public ::testing::Test {
rtc::scoped_refptr<PeerConnectionTestWrapper> CreatePc() {
auto pc_wrapper = rtc::make_ref_counted<PeerConnectionTestWrapper>(
"pc", &pss_, background_thread_.get(), background_thread_.get());
- pc_wrapper->CreatePc({}, webrtc::CreateBuiltinAudioEncoderFactory(),
- webrtc::CreateBuiltinAudioDecoderFactory());
+ pc_wrapper->CreatePc({}, CreateBuiltinAudioEncoderFactory(),
+ CreateBuiltinAudioDecoderFactory());
return pc_wrapper;
}
@@ -130,10 +129,9 @@ class PeerConnectionEncodingsIntegrationTest : public ::testing::Test {
rtc::scoped_refptr<PeerConnectionTestWrapper> local,
rtc::scoped_refptr<PeerConnectionTestWrapper> remote,
std::vector<cricket::SimulcastLayer> init_layers) {
- rtc::scoped_refptr<webrtc::MediaStreamInterface> stream =
- local->GetUserMedia(
- /*audio=*/false, cricket::AudioOptions(), /*video=*/true,
- {.width = 1280, .height = 720});
+ rtc::scoped_refptr<MediaStreamInterface> stream = local->GetUserMedia(
+ /*audio=*/false, cricket::AudioOptions(), /*video=*/true,
+ {.width = 1280, .height = 720});
rtc::scoped_refptr<VideoTrackInterface> track = stream->GetVideoTracks()[0];
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>
@@ -973,8 +971,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
local_pc_wrapper->pc()->AddTransceiver(cricket::MEDIA_TYPE_AUDIO);
rtc::scoped_refptr<RtpTransceiverInterface> audio_transceiver =
transceiver_or_error.MoveValue();
- webrtc::RtpParameters parameters =
- audio_transceiver->sender()->GetParameters();
+ RtpParameters parameters = audio_transceiver->sender()->GetParameters();
EXPECT_FALSE(parameters.encodings[0].codec.has_value());
}
@@ -986,8 +983,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
local_pc_wrapper->pc()->AddTransceiver(cricket::MEDIA_TYPE_VIDEO);
rtc::scoped_refptr<RtpTransceiverInterface> video_transceiver =
transceiver_or_error.MoveValue();
- webrtc::RtpParameters parameters =
- video_transceiver->sender()->GetParameters();
+ RtpParameters parameters = video_transceiver->sender()->GetParameters();
EXPECT_FALSE(parameters.encodings[0].codec.has_value());
}
@@ -997,19 +993,19 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
rtc::scoped_refptr<PeerConnectionTestWrapper> remote_pc_wrapper = CreatePc();
ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper);
- rtc::scoped_refptr<webrtc::MediaStreamInterface> stream =
+ rtc::scoped_refptr<MediaStreamInterface> stream =
local_pc_wrapper->GetUserMedia(
/*audio=*/true, {}, /*video=*/false, {});
rtc::scoped_refptr<AudioTrackInterface> track = stream->GetAudioTracks()[0];
- absl::optional<webrtc::RtpCodecCapability> pcmu =
+ absl::optional<RtpCodecCapability> pcmu =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_AUDIO,
"pcmu");
ASSERT_TRUE(pcmu);
- webrtc::RtpTransceiverInit init;
- init.direction = webrtc::RtpTransceiverDirection::kSendOnly;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ init.direction = RtpTransceiverDirection::kSendOnly;
+ RtpEncodingParameters encoding_parameters;
encoding_parameters.codec = pcmu;
init.send_encodings.push_back(encoding_parameters);
@@ -1017,8 +1013,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
local_pc_wrapper->pc()->AddTransceiver(track, init);
rtc::scoped_refptr<RtpTransceiverInterface> audio_transceiver =
transceiver_or_error.MoveValue();
- webrtc::RtpParameters parameters =
- audio_transceiver->sender()->GetParameters();
+ RtpParameters parameters = audio_transceiver->sender()->GetParameters();
EXPECT_EQ(*parameters.encodings[0].codec, *pcmu);
NegotiateWithSimulcastTweaks(local_pc_wrapper, remote_pc_wrapper);
@@ -1039,19 +1034,19 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
rtc::scoped_refptr<PeerConnectionTestWrapper> remote_pc_wrapper = CreatePc();
ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper);
- rtc::scoped_refptr<webrtc::MediaStreamInterface> stream =
+ rtc::scoped_refptr<MediaStreamInterface> stream =
local_pc_wrapper->GetUserMedia(
/*audio=*/false, {}, /*video=*/true, {.width = 1280, .height = 720});
rtc::scoped_refptr<VideoTrackInterface> track = stream->GetVideoTracks()[0];
- absl::optional<webrtc::RtpCodecCapability> vp9 =
+ absl::optional<RtpCodecCapability> vp9 =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO,
"vp9");
ASSERT_TRUE(vp9);
- webrtc::RtpTransceiverInit init;
- init.direction = webrtc::RtpTransceiverDirection::kSendOnly;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ init.direction = RtpTransceiverDirection::kSendOnly;
+ RtpEncodingParameters encoding_parameters;
encoding_parameters.codec = vp9;
encoding_parameters.scalability_mode = "L3T3";
init.send_encodings.push_back(encoding_parameters);
@@ -1060,8 +1055,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
local_pc_wrapper->pc()->AddTransceiver(track, init);
rtc::scoped_refptr<RtpTransceiverInterface> audio_transceiver =
transceiver_or_error.MoveValue();
- webrtc::RtpParameters parameters =
- audio_transceiver->sender()->GetParameters();
+ RtpParameters parameters = audio_transceiver->sender()->GetParameters();
EXPECT_EQ(*parameters.encodings[0].codec, *vp9);
NegotiateWithSimulcastTweaks(local_pc_wrapper, remote_pc_wrapper);
@@ -1087,20 +1081,19 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
rtc::scoped_refptr<PeerConnectionTestWrapper> remote_pc_wrapper = CreatePc();
ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper);
- rtc::scoped_refptr<webrtc::MediaStreamInterface> stream =
+ rtc::scoped_refptr<MediaStreamInterface> stream =
local_pc_wrapper->GetUserMedia(
/*audio=*/true, {}, /*video=*/false, {});
rtc::scoped_refptr<AudioTrackInterface> track = stream->GetAudioTracks()[0];
- absl::optional<webrtc::RtpCodecCapability> pcmu =
+ absl::optional<RtpCodecCapability> pcmu =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_AUDIO,
"pcmu");
auto transceiver_or_error = local_pc_wrapper->pc()->AddTransceiver(track);
rtc::scoped_refptr<RtpTransceiverInterface> audio_transceiver =
transceiver_or_error.MoveValue();
- webrtc::RtpParameters parameters =
- audio_transceiver->sender()->GetParameters();
+ RtpParameters parameters = audio_transceiver->sender()->GetParameters();
parameters.encodings[0].codec = pcmu;
EXPECT_TRUE(audio_transceiver->sender()->SetParameters(parameters).ok());
@@ -1125,12 +1118,12 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
rtc::scoped_refptr<PeerConnectionTestWrapper> remote_pc_wrapper = CreatePc();
ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper);
- rtc::scoped_refptr<webrtc::MediaStreamInterface> stream =
+ rtc::scoped_refptr<MediaStreamInterface> stream =
local_pc_wrapper->GetUserMedia(
/*audio=*/true, {}, /*video=*/false, {});
rtc::scoped_refptr<AudioTrackInterface> track = stream->GetAudioTracks()[0];
- absl::optional<webrtc::RtpCodecCapability> pcmu =
+ absl::optional<RtpCodecCapability> pcmu =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_AUDIO,
"pcmu");
@@ -1150,8 +1143,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
EXPECT_STRCASENE(("audio/" + pcmu->name).c_str(), codec_name.c_str());
std::string last_codec_id = outbound_rtps[0]->codec_id.value();
- webrtc::RtpParameters parameters =
- audio_transceiver->sender()->GetParameters();
+ RtpParameters parameters = audio_transceiver->sender()->GetParameters();
parameters.encodings[0].codec = pcmu;
EXPECT_TRUE(audio_transceiver->sender()->SetParameters(parameters).ok());
@@ -1174,20 +1166,19 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
rtc::scoped_refptr<PeerConnectionTestWrapper> remote_pc_wrapper = CreatePc();
ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper);
- rtc::scoped_refptr<webrtc::MediaStreamInterface> stream =
+ rtc::scoped_refptr<MediaStreamInterface> stream =
local_pc_wrapper->GetUserMedia(
/*audio=*/false, {}, /*video=*/true, {.width = 1280, .height = 720});
rtc::scoped_refptr<VideoTrackInterface> track = stream->GetVideoTracks()[0];
- absl::optional<webrtc::RtpCodecCapability> vp9 =
+ absl::optional<RtpCodecCapability> vp9 =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO,
"vp9");
auto transceiver_or_error = local_pc_wrapper->pc()->AddTransceiver(track);
rtc::scoped_refptr<RtpTransceiverInterface> video_transceiver =
transceiver_or_error.MoveValue();
- webrtc::RtpParameters parameters =
- video_transceiver->sender()->GetParameters();
+ RtpParameters parameters = video_transceiver->sender()->GetParameters();
parameters.encodings[0].codec = vp9;
parameters.encodings[0].scalability_mode = "L3T3";
EXPECT_TRUE(video_transceiver->sender()->SetParameters(parameters).ok());
@@ -1218,12 +1209,12 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
rtc::scoped_refptr<PeerConnectionTestWrapper> remote_pc_wrapper = CreatePc();
ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper);
- rtc::scoped_refptr<webrtc::MediaStreamInterface> stream =
+ rtc::scoped_refptr<MediaStreamInterface> stream =
local_pc_wrapper->GetUserMedia(
/*audio=*/false, {}, /*video=*/true, {.width = 1280, .height = 720});
rtc::scoped_refptr<VideoTrackInterface> track = stream->GetVideoTracks()[0];
- absl::optional<webrtc::RtpCodecCapability> vp9 =
+ absl::optional<RtpCodecCapability> vp9 =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO,
"vp9");
@@ -1243,8 +1234,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
EXPECT_STRCASENE(("audio/" + vp9->name).c_str(), codec_name.c_str());
std::string last_codec_id = outbound_rtps[0]->codec_id.value();
- webrtc::RtpParameters parameters =
- video_transceiver->sender()->GetParameters();
+ RtpParameters parameters = video_transceiver->sender()->GetParameters();
parameters.encodings[0].codec = vp9;
parameters.encodings[0].scalability_mode = "L3T3";
EXPECT_TRUE(video_transceiver->sender()->SetParameters(parameters).ok());
@@ -1269,15 +1259,15 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
AddTransceiverRejectsUnknownCodecParameterAudio) {
rtc::scoped_refptr<PeerConnectionTestWrapper> local_pc_wrapper = CreatePc();
- webrtc::RtpCodec dummy_codec;
+ RtpCodec dummy_codec;
dummy_codec.kind = cricket::MEDIA_TYPE_AUDIO;
dummy_codec.name = "FOOBAR";
dummy_codec.clock_rate = 90000;
dummy_codec.num_channels = 2;
- webrtc::RtpTransceiverInit init;
- init.direction = webrtc::RtpTransceiverDirection::kSendOnly;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ init.direction = RtpTransceiverDirection::kSendOnly;
+ RtpEncodingParameters encoding_parameters;
encoding_parameters.codec = dummy_codec;
init.send_encodings.push_back(encoding_parameters);
@@ -1292,14 +1282,14 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
AddTransceiverRejectsUnknownCodecParameterVideo) {
rtc::scoped_refptr<PeerConnectionTestWrapper> local_pc_wrapper = CreatePc();
- webrtc::RtpCodec dummy_codec;
+ RtpCodec dummy_codec;
dummy_codec.kind = cricket::MEDIA_TYPE_VIDEO;
dummy_codec.name = "FOOBAR";
dummy_codec.clock_rate = 90000;
- webrtc::RtpTransceiverInit init;
- init.direction = webrtc::RtpTransceiverDirection::kSendOnly;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ init.direction = RtpTransceiverDirection::kSendOnly;
+ RtpEncodingParameters encoding_parameters;
encoding_parameters.codec = dummy_codec;
init.send_encodings.push_back(encoding_parameters);
@@ -1314,7 +1304,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
SetParametersRejectsUnknownCodecParameterAudio) {
rtc::scoped_refptr<PeerConnectionTestWrapper> local_pc_wrapper = CreatePc();
- webrtc::RtpCodec dummy_codec;
+ RtpCodec dummy_codec;
dummy_codec.kind = cricket::MEDIA_TYPE_AUDIO;
dummy_codec.name = "FOOBAR";
dummy_codec.clock_rate = 90000;
@@ -1326,8 +1316,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
rtc::scoped_refptr<RtpTransceiverInterface> audio_transceiver =
transceiver_or_error.MoveValue();
- webrtc::RtpParameters parameters =
- audio_transceiver->sender()->GetParameters();
+ RtpParameters parameters = audio_transceiver->sender()->GetParameters();
parameters.encodings[0].codec = dummy_codec;
RTCError error = audio_transceiver->sender()->SetParameters(parameters);
EXPECT_EQ(error.type(), RTCErrorType::INVALID_MODIFICATION);
@@ -1337,7 +1326,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
SetParametersRejectsUnknownCodecParameterVideo) {
rtc::scoped_refptr<PeerConnectionTestWrapper> local_pc_wrapper = CreatePc();
- webrtc::RtpCodec dummy_codec;
+ RtpCodec dummy_codec;
dummy_codec.kind = cricket::MEDIA_TYPE_VIDEO;
dummy_codec.name = "FOOBAR";
dummy_codec.clock_rate = 90000;
@@ -1348,8 +1337,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
rtc::scoped_refptr<RtpTransceiverInterface> video_transceiver =
transceiver_or_error.MoveValue();
- webrtc::RtpParameters parameters =
- video_transceiver->sender()->GetParameters();
+ RtpParameters parameters = video_transceiver->sender()->GetParameters();
parameters.encodings[0].codec = dummy_codec;
RTCError error = video_transceiver->sender()->SetParameters(parameters);
EXPECT_EQ(error.type(), RTCErrorType::INVALID_MODIFICATION);
@@ -1359,12 +1347,12 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
SetParametersRejectsNonPreferredCodecParameterAudio) {
rtc::scoped_refptr<PeerConnectionTestWrapper> local_pc_wrapper = CreatePc();
- absl::optional<webrtc::RtpCodecCapability> opus =
+ absl::optional<RtpCodecCapability> opus =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_AUDIO,
"opus");
ASSERT_TRUE(opus);
- std::vector<webrtc::RtpCodecCapability> not_opus_codecs =
+ std::vector<RtpCodecCapability> not_opus_codecs =
local_pc_wrapper->pc_factory()
->GetRtpSenderCapabilities(cricket::MEDIA_TYPE_AUDIO)
.codecs;
@@ -1382,8 +1370,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
transceiver_or_error.MoveValue();
ASSERT_TRUE(audio_transceiver->SetCodecPreferences(not_opus_codecs).ok());
- webrtc::RtpParameters parameters =
- audio_transceiver->sender()->GetParameters();
+ RtpParameters parameters = audio_transceiver->sender()->GetParameters();
parameters.encodings[0].codec = opus;
RTCError error = audio_transceiver->sender()->SetParameters(parameters);
EXPECT_EQ(error.type(), RTCErrorType::INVALID_MODIFICATION);
@@ -1393,12 +1380,12 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
SetParametersRejectsNonPreferredCodecParameterVideo) {
rtc::scoped_refptr<PeerConnectionTestWrapper> local_pc_wrapper = CreatePc();
- absl::optional<webrtc::RtpCodecCapability> vp8 =
+ absl::optional<RtpCodecCapability> vp8 =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO,
"vp8");
ASSERT_TRUE(vp8);
- std::vector<webrtc::RtpCodecCapability> not_vp8_codecs =
+ std::vector<RtpCodecCapability> not_vp8_codecs =
local_pc_wrapper->pc_factory()
->GetRtpSenderCapabilities(cricket::MEDIA_TYPE_VIDEO)
.codecs;
@@ -1416,8 +1403,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
transceiver_or_error.MoveValue();
ASSERT_TRUE(video_transceiver->SetCodecPreferences(not_vp8_codecs).ok());
- webrtc::RtpParameters parameters =
- video_transceiver->sender()->GetParameters();
+ RtpParameters parameters = video_transceiver->sender()->GetParameters();
parameters.encodings[0].codec = vp8;
RTCError error = video_transceiver->sender()->SetParameters(parameters);
EXPECT_EQ(error.type(), RTCErrorType::INVALID_MODIFICATION);
@@ -1429,12 +1415,12 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
rtc::scoped_refptr<PeerConnectionTestWrapper> remote_pc_wrapper = CreatePc();
ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper);
- absl::optional<webrtc::RtpCodecCapability> opus =
+ absl::optional<RtpCodecCapability> opus =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_AUDIO,
"opus");
ASSERT_TRUE(opus);
- std::vector<webrtc::RtpCodecCapability> not_opus_codecs =
+ std::vector<RtpCodecCapability> not_opus_codecs =
local_pc_wrapper->pc_factory()
->GetRtpSenderCapabilities(cricket::MEDIA_TYPE_AUDIO)
.codecs;
@@ -1456,8 +1442,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
local_pc_wrapper->WaitForConnection();
remote_pc_wrapper->WaitForConnection();
- webrtc::RtpParameters parameters =
- audio_transceiver->sender()->GetParameters();
+ RtpParameters parameters = audio_transceiver->sender()->GetParameters();
parameters.encodings[0].codec = opus;
RTCError error = audio_transceiver->sender()->SetParameters(parameters);
EXPECT_EQ(error.type(), RTCErrorType::INVALID_MODIFICATION);
@@ -1469,12 +1454,12 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
rtc::scoped_refptr<PeerConnectionTestWrapper> remote_pc_wrapper = CreatePc();
ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper);
- absl::optional<webrtc::RtpCodecCapability> opus =
+ absl::optional<RtpCodecCapability> opus =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_AUDIO,
"opus");
ASSERT_TRUE(opus);
- std::vector<webrtc::RtpCodecCapability> not_opus_codecs =
+ std::vector<RtpCodecCapability> not_opus_codecs =
local_pc_wrapper->pc_factory()
->GetRtpSenderCapabilities(cricket::MEDIA_TYPE_AUDIO)
.codecs;
@@ -1519,8 +1504,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
local_pc_wrapper->WaitForConnection();
remote_pc_wrapper->WaitForConnection();
- webrtc::RtpParameters parameters =
- audio_transceiver->sender()->GetParameters();
+ RtpParameters parameters = audio_transceiver->sender()->GetParameters();
parameters.encodings[0].codec = opus;
RTCError error = audio_transceiver->sender()->SetParameters(parameters);
EXPECT_EQ(error.type(), RTCErrorType::INVALID_MODIFICATION);
@@ -1532,12 +1516,12 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
rtc::scoped_refptr<PeerConnectionTestWrapper> remote_pc_wrapper = CreatePc();
ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper);
- absl::optional<webrtc::RtpCodecCapability> vp8 =
+ absl::optional<RtpCodecCapability> vp8 =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO,
"vp8");
ASSERT_TRUE(vp8);
- std::vector<webrtc::RtpCodecCapability> not_vp8_codecs =
+ std::vector<RtpCodecCapability> not_vp8_codecs =
local_pc_wrapper->pc_factory()
->GetRtpSenderCapabilities(cricket::MEDIA_TYPE_VIDEO)
.codecs;
@@ -1559,8 +1543,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
local_pc_wrapper->WaitForConnection();
remote_pc_wrapper->WaitForConnection();
- webrtc::RtpParameters parameters =
- video_transceiver->sender()->GetParameters();
+ RtpParameters parameters = video_transceiver->sender()->GetParameters();
parameters.encodings[0].codec = vp8;
RTCError error = video_transceiver->sender()->SetParameters(parameters);
EXPECT_EQ(error.type(), RTCErrorType::INVALID_MODIFICATION);
@@ -1572,12 +1555,12 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
rtc::scoped_refptr<PeerConnectionTestWrapper> remote_pc_wrapper = CreatePc();
ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper);
- absl::optional<webrtc::RtpCodecCapability> vp8 =
+ absl::optional<RtpCodecCapability> vp8 =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO,
"vp8");
ASSERT_TRUE(vp8);
- std::vector<webrtc::RtpCodecCapability> not_vp8_codecs =
+ std::vector<RtpCodecCapability> not_vp8_codecs =
local_pc_wrapper->pc_factory()
->GetRtpSenderCapabilities(cricket::MEDIA_TYPE_VIDEO)
.codecs;
@@ -1622,8 +1605,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
local_pc_wrapper->WaitForConnection();
remote_pc_wrapper->WaitForConnection();
- webrtc::RtpParameters parameters =
- video_transceiver->sender()->GetParameters();
+ RtpParameters parameters = video_transceiver->sender()->GetParameters();
parameters.encodings[0].codec = vp8;
RTCError error = video_transceiver->sender()->SetParameters(parameters);
EXPECT_EQ(error.type(), RTCErrorType::INVALID_MODIFICATION);
@@ -1635,12 +1617,12 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
rtc::scoped_refptr<PeerConnectionTestWrapper> remote_pc_wrapper = CreatePc();
ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper);
- absl::optional<webrtc::RtpCodecCapability> opus =
+ absl::optional<RtpCodecCapability> opus =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_AUDIO,
"opus");
ASSERT_TRUE(opus);
- std::vector<webrtc::RtpCodecCapability> not_opus_codecs =
+ std::vector<RtpCodecCapability> not_opus_codecs =
local_pc_wrapper->pc_factory()
->GetRtpSenderCapabilities(cricket::MEDIA_TYPE_AUDIO)
.codecs;
@@ -1651,9 +1633,9 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
}),
not_opus_codecs.end());
- webrtc::RtpTransceiverInit init;
- init.direction = webrtc::RtpTransceiverDirection::kSendOnly;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ init.direction = RtpTransceiverDirection::kSendOnly;
+ RtpEncodingParameters encoding_parameters;
encoding_parameters.codec = opus;
init.send_encodings.push_back(encoding_parameters);
@@ -1667,8 +1649,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
local_pc_wrapper->WaitForConnection();
remote_pc_wrapper->WaitForConnection();
- webrtc::RtpParameters parameters =
- audio_transceiver->sender()->GetParameters();
+ RtpParameters parameters = audio_transceiver->sender()->GetParameters();
EXPECT_EQ(parameters.encodings[0].codec, opus);
ASSERT_TRUE(audio_transceiver->SetCodecPreferences(not_opus_codecs).ok());
@@ -1684,24 +1665,24 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
rtc::scoped_refptr<PeerConnectionTestWrapper> remote_pc_wrapper = CreatePc();
ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper);
- std::vector<webrtc::RtpCodecCapability> send_codecs =
+ std::vector<RtpCodecCapability> send_codecs =
local_pc_wrapper->pc_factory()
->GetRtpSenderCapabilities(cricket::MEDIA_TYPE_AUDIO)
.codecs;
- absl::optional<webrtc::RtpCodecCapability> opus =
+ absl::optional<RtpCodecCapability> opus =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_AUDIO,
"opus");
ASSERT_TRUE(opus);
- absl::optional<webrtc::RtpCodecCapability> red =
+ absl::optional<RtpCodecCapability> red =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_AUDIO,
"red");
ASSERT_TRUE(red);
- webrtc::RtpTransceiverInit init;
- init.direction = webrtc::RtpTransceiverDirection::kSendOnly;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ init.direction = RtpTransceiverDirection::kSendOnly;
+ RtpEncodingParameters encoding_parameters;
encoding_parameters.codec = opus;
init.send_encodings.push_back(encoding_parameters);
@@ -1720,8 +1701,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
local_pc_wrapper->WaitForConnection();
remote_pc_wrapper->WaitForConnection();
- webrtc::RtpParameters parameters =
- audio_transceiver->sender()->GetParameters();
+ RtpParameters parameters = audio_transceiver->sender()->GetParameters();
EXPECT_EQ(parameters.encodings[0].codec, opus);
EXPECT_EQ(parameters.codecs[0].payload_type, red->preferred_payload_type);
EXPECT_EQ(parameters.codecs[0].name, red->name);
@@ -1743,14 +1723,14 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
SetParametersRejectsScalabilityModeForSelectedCodec) {
rtc::scoped_refptr<PeerConnectionTestWrapper> local_pc_wrapper = CreatePc();
- absl::optional<webrtc::RtpCodecCapability> vp8 =
+ absl::optional<RtpCodecCapability> vp8 =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO,
"vp8");
ASSERT_TRUE(vp8);
- webrtc::RtpTransceiverInit init;
- init.direction = webrtc::RtpTransceiverDirection::kSendOnly;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ init.direction = RtpTransceiverDirection::kSendOnly;
+ RtpEncodingParameters encoding_parameters;
encoding_parameters.codec = vp8;
encoding_parameters.scalability_mode = "L1T3";
init.send_encodings.push_back(encoding_parameters);
@@ -1761,8 +1741,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
rtc::scoped_refptr<RtpTransceiverInterface> video_transceiver =
transceiver_or_error.MoveValue();
- webrtc::RtpParameters parameters =
- video_transceiver->sender()->GetParameters();
+ RtpParameters parameters = video_transceiver->sender()->GetParameters();
parameters.encodings[0].scalability_mode = "L3T3";
RTCError error = video_transceiver->sender()->SetParameters(parameters);
EXPECT_EQ(error.type(), RTCErrorType::INVALID_MODIFICATION);
@@ -1774,12 +1753,12 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
rtc::scoped_refptr<PeerConnectionTestWrapper> remote_pc_wrapper = CreatePc();
ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper);
- absl::optional<webrtc::RtpCodecCapability> vp8 =
+ absl::optional<RtpCodecCapability> vp8 =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO,
"vp8");
ASSERT_TRUE(vp8);
- std::vector<webrtc::RtpCodecCapability> not_vp8_codecs =
+ std::vector<RtpCodecCapability> not_vp8_codecs =
local_pc_wrapper->pc_factory()
->GetRtpSenderCapabilities(cricket::MEDIA_TYPE_VIDEO)
.codecs;
@@ -1790,9 +1769,9 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
}),
not_vp8_codecs.end());
- webrtc::RtpTransceiverInit init;
- init.direction = webrtc::RtpTransceiverDirection::kSendOnly;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ init.direction = RtpTransceiverDirection::kSendOnly;
+ RtpEncodingParameters encoding_parameters;
encoding_parameters.rid = "h";
encoding_parameters.codec = vp8;
encoding_parameters.scale_resolution_down_by = 2;
@@ -1811,8 +1790,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
local_pc_wrapper->WaitForConnection();
remote_pc_wrapper->WaitForConnection();
- webrtc::RtpParameters parameters =
- video_transceiver->sender()->GetParameters();
+ RtpParameters parameters = video_transceiver->sender()->GetParameters();
ASSERT_EQ(parameters.encodings.size(), 2u);
EXPECT_EQ(parameters.encodings[0].codec, vp8);
EXPECT_EQ(parameters.encodings[1].codec, vp8);
@@ -1833,17 +1811,17 @@ TEST_F(PeerConnectionEncodingsIntegrationTest,
rtc::scoped_refptr<PeerConnectionTestWrapper> remote_pc_wrapper = CreatePc();
ExchangeIceCandidates(local_pc_wrapper, remote_pc_wrapper);
- absl::optional<webrtc::RtpCodecCapability> vp8 =
+ absl::optional<RtpCodecCapability> vp8 =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO,
"vp8");
ASSERT_TRUE(vp8);
- absl::optional<webrtc::RtpCodecCapability> vp9 =
+ absl::optional<RtpCodecCapability> vp9 =
local_pc_wrapper->FindFirstSendCodecWithName(cricket::MEDIA_TYPE_VIDEO,
"vp9");
- webrtc::RtpTransceiverInit init;
- init.direction = webrtc::RtpTransceiverDirection::kSendOnly;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ init.direction = RtpTransceiverDirection::kSendOnly;
+ RtpEncodingParameters encoding_parameters;
encoding_parameters.rid = "h";
encoding_parameters.codec = vp8;
encoding_parameters.scale_resolution_down_by = 2;
diff --git a/third_party/libwebrtc/pc/peer_connection_factory.cc b/third_party/libwebrtc/pc/peer_connection_factory.cc
index 81780cf51e..8ce44d374f 100644
--- a/third_party/libwebrtc/pc/peer_connection_factory.cc
+++ b/third_party/libwebrtc/pc/peer_connection_factory.cc
@@ -14,8 +14,8 @@
#include <utility>
#include "absl/strings/match.h"
-#include "api/async_resolver_factory.h"
-#include "api/call/call_factory_interface.h"
+#include "api/environment/environment.h"
+#include "api/environment/environment_factory.h"
#include "api/fec_controller.h"
#include "api/ice_transport_interface.h"
#include "api/network_state_predictor.h"
@@ -27,13 +27,13 @@
#include "call/audio_state.h"
#include "call/rtp_transport_controller_send_factory.h"
#include "media/base/media_engine.h"
-#include "p2p/base/basic_async_resolver_factory.h"
#include "p2p/base/basic_packet_socket_factory.h"
#include "p2p/base/default_ice_transport_factory.h"
#include "p2p/base/port_allocator.h"
#include "p2p/client/basic_port_allocator.h"
#include "pc/audio_track.h"
#include "pc/local_audio_source.h"
+#include "pc/media_factory.h"
#include "pc/media_stream.h"
#include "pc/media_stream_proxy.h"
#include "pc/media_stream_track_proxy.h"
@@ -78,7 +78,10 @@ CreateModularPeerConnectionFactory(
// Static
rtc::scoped_refptr<PeerConnectionFactory> PeerConnectionFactory::Create(
PeerConnectionFactoryDependencies dependencies) {
- auto context = ConnectionContext::Create(&dependencies);
+ auto context = ConnectionContext::Create(
+ CreateEnvironment(std::move(dependencies.trials),
+ std::move(dependencies.task_queue_factory)),
+ &dependencies);
if (!context) {
return nullptr;
}
@@ -89,7 +92,6 @@ PeerConnectionFactory::PeerConnectionFactory(
rtc::scoped_refptr<ConnectionContext> context,
PeerConnectionFactoryDependencies* dependencies)
: context_(context),
- task_queue_factory_(std::move(dependencies->task_queue_factory)),
event_log_factory_(std::move(dependencies->event_log_factory)),
fec_controller_factory_(std::move(dependencies->fec_controller_factory)),
network_state_predictor_factory_(
@@ -105,8 +107,12 @@ PeerConnectionFactory::PeerConnectionFactory(
PeerConnectionFactory::PeerConnectionFactory(
PeerConnectionFactoryDependencies dependencies)
- : PeerConnectionFactory(ConnectionContext::Create(&dependencies),
- &dependencies) {}
+ : PeerConnectionFactory(
+ ConnectionContext::Create(
+ CreateEnvironment(std::move(dependencies.trials),
+ std::move(dependencies.task_queue_factory)),
+ &dependencies),
+ &dependencies) {}
PeerConnectionFactory::~PeerConnectionFactory() {
RTC_DCHECK_RUN_ON(signaling_thread());
@@ -205,6 +211,23 @@ PeerConnectionFactory::CreatePeerConnectionOrError(
PeerConnectionDependencies dependencies) {
RTC_DCHECK_RUN_ON(signaling_thread());
+ EnvironmentFactory env_factory(context_->env());
+
+ // Field trials active for this PeerConnection is the first of:
+ // a) Specified in the PeerConnectionDependencies
+ // b) Specified in the PeerConnectionFactoryDependencies
+ // c) Created as default by the EnvironmentFactory.
+ env_factory.Set(std::move(dependencies.trials));
+
+ if (event_log_factory_ != nullptr) {
+ worker_thread()->BlockingCall([&] {
+ Environment env_for_rtc_event_log = env_factory.Create();
+ env_factory.Set(event_log_factory_->Create(env_for_rtc_event_log));
+ });
+ }
+
+ const Environment env = env_factory.Create();
+
// Set internal defaults if optional dependencies are not set.
if (!dependencies.cert_generator) {
dependencies.cert_generator =
@@ -212,11 +235,10 @@ PeerConnectionFactory::CreatePeerConnectionOrError(
network_thread());
}
if (!dependencies.allocator) {
- const FieldTrialsView* trials =
- dependencies.trials ? dependencies.trials.get() : &field_trials();
dependencies.allocator = std::make_unique<cricket::BasicPortAllocator>(
context_->default_network_manager(), context_->default_socket_factory(),
- configuration.turn_customizer, /*relay_port_factory=*/nullptr, trials);
+ configuration.turn_customizer, /*relay_port_factory=*/nullptr,
+ &env.field_trials());
dependencies.allocator->SetPortRange(
configuration.port_allocator_config.min_port,
configuration.port_allocator_config.max_port);
@@ -232,19 +254,13 @@ PeerConnectionFactory::CreatePeerConnectionOrError(
dependencies.allocator->SetNetworkIgnoreMask(options().network_ignore_mask);
dependencies.allocator->SetVpnList(configuration.vpn_list);
- std::unique_ptr<RtcEventLog> event_log =
- worker_thread()->BlockingCall([this] { return CreateRtcEventLog_w(); });
-
- const FieldTrialsView* trials =
- dependencies.trials ? dependencies.trials.get() : &field_trials();
std::unique_ptr<Call> call =
- worker_thread()->BlockingCall([this, &event_log, trials, &configuration] {
- return CreateCall_w(event_log.get(), *trials, configuration);
+ worker_thread()->BlockingCall([this, &env, &configuration] {
+ return CreateCall_w(env, configuration);
});
- auto result = PeerConnection::Create(context_, options_, std::move(event_log),
- std::move(call), configuration,
- std::move(dependencies));
+ auto result = PeerConnection::Create(env, context_, options_, std::move(call),
+ configuration, std::move(dependencies));
if (!result.ok()) {
return result.MoveError();
}
@@ -285,23 +301,12 @@ rtc::scoped_refptr<AudioTrackInterface> PeerConnectionFactory::CreateAudioTrack(
return AudioTrackProxy::Create(signaling_thread(), track);
}
-std::unique_ptr<RtcEventLog> PeerConnectionFactory::CreateRtcEventLog_w() {
- RTC_DCHECK_RUN_ON(worker_thread());
-
- auto encoding_type = RtcEventLog::EncodingType::NewFormat;
- if (field_trials().IsDisabled("WebRTC-RtcEventLogNewFormat"))
- encoding_type = RtcEventLog::EncodingType::Legacy;
- return event_log_factory_ ? event_log_factory_->Create(encoding_type)
- : std::make_unique<RtcEventLogNull>();
-}
-
std::unique_ptr<Call> PeerConnectionFactory::CreateCall_w(
- RtcEventLog* event_log,
- const FieldTrialsView& field_trials,
+ const Environment& env,
const PeerConnectionInterface::RTCConfiguration& configuration) {
RTC_DCHECK_RUN_ON(worker_thread());
- CallConfig call_config(event_log, network_thread());
+ CallConfig call_config(env, network_thread());
if (!media_engine() || !context_->call_factory()) {
return nullptr;
}
@@ -314,7 +319,7 @@ std::unique_ptr<Call> PeerConnectionFactory::CreateCall_w(
FieldTrialParameter<DataRate> max_bandwidth("max",
DataRate::KilobitsPerSec(2000));
ParseFieldTrial({&min_bandwidth, &start_bandwidth, &max_bandwidth},
- field_trials.Lookup("WebRTC-PcFactoryDefaultBitrates"));
+ env.field_trials().Lookup("WebRTC-PcFactoryDefaultBitrates"));
call_config.bitrate_config.min_bitrate_bps =
rtc::saturated_cast<int>(min_bandwidth->bps());
@@ -324,7 +329,6 @@ std::unique_ptr<Call> PeerConnectionFactory::CreateCall_w(
rtc::saturated_cast<int>(max_bandwidth->bps());
call_config.fec_controller_factory = fec_controller_factory_.get();
- call_config.task_queue_factory = task_queue_factory_.get();
call_config.network_state_predictor_factory =
network_state_predictor_factory_.get();
call_config.neteq_factory = neteq_factory_.get();
@@ -337,11 +341,9 @@ std::unique_ptr<Call> PeerConnectionFactory::CreateCall_w(
RTC_LOG(LS_INFO) << "Using default network controller factory";
}
- call_config.trials = &field_trials;
call_config.rtp_transport_controller_send_factory =
transport_controller_send_factory_.get();
call_config.metronome = metronome_.get();
- call_config.pacer_burst_interval = configuration.pacer_burst_interval;
return context_->call_factory()->CreateCall(call_config);
}
diff --git a/third_party/libwebrtc/pc/peer_connection_factory.h b/third_party/libwebrtc/pc/peer_connection_factory.h
index f55d09f6d8..c3760c02c9 100644
--- a/third_party/libwebrtc/pc/peer_connection_factory.h
+++ b/third_party/libwebrtc/pc/peer_connection_factory.h
@@ -29,12 +29,10 @@
#include "api/network_state_predictor.h"
#include "api/peer_connection_interface.h"
#include "api/rtc_error.h"
-#include "api/rtc_event_log/rtc_event_log.h"
#include "api/rtc_event_log/rtc_event_log_factory_interface.h"
#include "api/rtp_parameters.h"
#include "api/scoped_refptr.h"
#include "api/sequence_checker.h"
-#include "api/task_queue/task_queue_factory.h"
#include "api/transport/network_control.h"
#include "api/transport/sctp_transport_factory_interface.h"
#include "call/call.h"
@@ -53,8 +51,6 @@ class BasicPacketSocketFactory;
namespace webrtc {
-class RtcEventLog;
-
class PeerConnectionFactory : public PeerConnectionFactoryInterface {
public:
// Creates a PeerConnectionFactory. It returns nullptr on initialization
@@ -135,16 +131,13 @@ class PeerConnectionFactory : public PeerConnectionFactoryInterface {
bool IsTrialEnabled(absl::string_view key) const;
- std::unique_ptr<RtcEventLog> CreateRtcEventLog_w();
std::unique_ptr<Call> CreateCall_w(
- RtcEventLog* event_log,
- const FieldTrialsView& field_trials,
+ const Environment& env,
const PeerConnectionInterface::RTCConfiguration& configuration);
rtc::scoped_refptr<ConnectionContext> context_;
PeerConnectionFactoryInterface::Options options_
RTC_GUARDED_BY(signaling_thread());
- std::unique_ptr<TaskQueueFactory> task_queue_factory_;
std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory_;
std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory_;
std::unique_ptr<NetworkStatePredictorFactoryInterface>
diff --git a/third_party/libwebrtc/pc/peer_connection_factory_proxy.h b/third_party/libwebrtc/pc/peer_connection_factory_proxy.h
index 4781497642..b9bd1cbf0e 100644
--- a/third_party/libwebrtc/pc/peer_connection_factory_proxy.h
+++ b/third_party/libwebrtc/pc/peer_connection_factory_proxy.h
@@ -29,10 +29,10 @@ PROXY_METHOD2(RTCErrorOr<rtc::scoped_refptr<PeerConnectionInterface>>,
CreatePeerConnectionOrError,
const PeerConnectionInterface::RTCConfiguration&,
PeerConnectionDependencies)
-PROXY_CONSTMETHOD1(webrtc::RtpCapabilities,
+PROXY_CONSTMETHOD1(RtpCapabilities,
GetRtpSenderCapabilities,
cricket::MediaType)
-PROXY_CONSTMETHOD1(webrtc::RtpCapabilities,
+PROXY_CONSTMETHOD1(RtpCapabilities,
GetRtpReceiverCapabilities,
cricket::MediaType)
PROXY_METHOD1(rtc::scoped_refptr<MediaStreamInterface>,
diff --git a/third_party/libwebrtc/pc/peer_connection_factory_unittest.cc b/third_party/libwebrtc/pc/peer_connection_factory_unittest.cc
index 11e232c01f..618ac68388 100644
--- a/third_party/libwebrtc/pc/peer_connection_factory_unittest.cc
+++ b/third_party/libwebrtc/pc/peer_connection_factory_unittest.cc
@@ -20,6 +20,8 @@
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/create_peerconnection_factory.h"
#include "api/data_channel_interface.h"
+#include "api/enable_media.h"
+#include "api/environment/environment_factory.h"
#include "api/jsep.h"
#include "api/media_stream_interface.h"
#include "api/task_queue/default_task_queue_factory.h"
@@ -35,7 +37,6 @@
#include "api/video_codecs/video_encoder_factory_template_libvpx_vp9_adapter.h"
#include "api/video_codecs/video_encoder_factory_template_open_h264_adapter.h"
#include "media/base/fake_frame_source.h"
-#include "media/engine/webrtc_media_engine.h"
#include "modules/audio_device/include/audio_device.h"
#include "modules/audio_processing/include/audio_processing.h"
#include "p2p/base/fake_port_allocator.h"
@@ -106,8 +107,7 @@ class NullPeerConnectionObserver : public PeerConnectionObserver {
PeerConnectionInterface::IceConnectionState new_state) override {}
void OnIceGatheringChange(
PeerConnectionInterface::IceGatheringState new_state) override {}
- void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override {
- }
+ void OnIceCandidate(const IceCandidateInterface* candidate) override {}
};
class MockNetworkManager : public rtc::NetworkManager {
@@ -133,17 +133,15 @@ class PeerConnectionFactoryTest : public ::testing::Test {
private:
void SetUp() {
#ifdef WEBRTC_ANDROID
- webrtc::InitializeAndroidObjects();
+ InitializeAndroidObjects();
#endif
// Use fake audio device module since we're only testing the interface
// level, and using a real one could make tests flaky e.g. when run in
// parallel.
- factory_ = webrtc::CreatePeerConnectionFactory(
+ factory_ = CreatePeerConnectionFactory(
rtc::Thread::Current(), rtc::Thread::Current(), rtc::Thread::Current(),
- rtc::scoped_refptr<webrtc::AudioDeviceModule>(
- FakeAudioCaptureModule::Create()),
- webrtc::CreateBuiltinAudioEncoderFactory(),
- webrtc::CreateBuiltinAudioDecoderFactory(),
+ rtc::scoped_refptr<AudioDeviceModule>(FakeAudioCaptureModule::Create()),
+ CreateBuiltinAudioEncoderFactory(), CreateBuiltinAudioDecoderFactory(),
std::make_unique<VideoEncoderFactoryTemplate<
LibvpxVp8EncoderTemplateAdapter, LibvpxVp9EncoderTemplateAdapter,
OpenH264EncoderTemplateAdapter, LibaomAv1EncoderTemplateAdapter>>(),
@@ -182,64 +180,64 @@ class PeerConnectionFactoryTest : public ::testing::Test {
}
}
- void VerifyAudioCodecCapability(const webrtc::RtpCodecCapability& codec) {
+ void VerifyAudioCodecCapability(const RtpCodecCapability& codec) {
EXPECT_EQ(codec.kind, cricket::MEDIA_TYPE_AUDIO);
EXPECT_FALSE(codec.name.empty());
EXPECT_GT(codec.clock_rate, 0);
EXPECT_GT(codec.num_channels, 0);
}
- void VerifyVideoCodecCapability(const webrtc::RtpCodecCapability& codec,
+ void VerifyVideoCodecCapability(const RtpCodecCapability& codec,
bool sender) {
EXPECT_EQ(codec.kind, cricket::MEDIA_TYPE_VIDEO);
EXPECT_FALSE(codec.name.empty());
EXPECT_GT(codec.clock_rate, 0);
if (sender) {
if (codec.name == "VP8" || codec.name == "H264") {
- EXPECT_THAT(codec.scalability_modes,
- UnorderedElementsAre(webrtc::ScalabilityMode::kL1T1,
- webrtc::ScalabilityMode::kL1T2,
- webrtc::ScalabilityMode::kL1T3))
+ EXPECT_THAT(
+ codec.scalability_modes,
+ UnorderedElementsAre(ScalabilityMode::kL1T1, ScalabilityMode::kL1T2,
+ ScalabilityMode::kL1T3))
<< "Codec: " << codec.name;
} else if (codec.name == "VP9" || codec.name == "AV1") {
EXPECT_THAT(
codec.scalability_modes,
UnorderedElementsAre(
// clang-format off
- webrtc::ScalabilityMode::kL1T1,
- webrtc::ScalabilityMode::kL1T2,
- webrtc::ScalabilityMode::kL1T3,
- webrtc::ScalabilityMode::kL2T1,
- webrtc::ScalabilityMode::kL2T1h,
- webrtc::ScalabilityMode::kL2T1_KEY,
- webrtc::ScalabilityMode::kL2T2,
- webrtc::ScalabilityMode::kL2T2h,
- webrtc::ScalabilityMode::kL2T2_KEY,
- webrtc::ScalabilityMode::kL2T2_KEY_SHIFT,
- webrtc::ScalabilityMode::kL2T3,
- webrtc::ScalabilityMode::kL2T3h,
- webrtc::ScalabilityMode::kL2T3_KEY,
- webrtc::ScalabilityMode::kL3T1,
- webrtc::ScalabilityMode::kL3T1h,
- webrtc::ScalabilityMode::kL3T1_KEY,
- webrtc::ScalabilityMode::kL3T2,
- webrtc::ScalabilityMode::kL3T2h,
- webrtc::ScalabilityMode::kL3T2_KEY,
- webrtc::ScalabilityMode::kL3T3,
- webrtc::ScalabilityMode::kL3T3h,
- webrtc::ScalabilityMode::kL3T3_KEY,
- webrtc::ScalabilityMode::kS2T1,
- webrtc::ScalabilityMode::kS2T1h,
- webrtc::ScalabilityMode::kS2T2,
- webrtc::ScalabilityMode::kS2T2h,
- webrtc::ScalabilityMode::kS2T3,
- webrtc::ScalabilityMode::kS2T3h,
- webrtc::ScalabilityMode::kS3T1,
- webrtc::ScalabilityMode::kS3T1h,
- webrtc::ScalabilityMode::kS3T2,
- webrtc::ScalabilityMode::kS3T2h,
- webrtc::ScalabilityMode::kS3T3,
- webrtc::ScalabilityMode::kS3T3h)
+ ScalabilityMode::kL1T1,
+ ScalabilityMode::kL1T2,
+ ScalabilityMode::kL1T3,
+ ScalabilityMode::kL2T1,
+ ScalabilityMode::kL2T1h,
+ ScalabilityMode::kL2T1_KEY,
+ ScalabilityMode::kL2T2,
+ ScalabilityMode::kL2T2h,
+ ScalabilityMode::kL2T2_KEY,
+ ScalabilityMode::kL2T2_KEY_SHIFT,
+ ScalabilityMode::kL2T3,
+ ScalabilityMode::kL2T3h,
+ ScalabilityMode::kL2T3_KEY,
+ ScalabilityMode::kL3T1,
+ ScalabilityMode::kL3T1h,
+ ScalabilityMode::kL3T1_KEY,
+ ScalabilityMode::kL3T2,
+ ScalabilityMode::kL3T2h,
+ ScalabilityMode::kL3T2_KEY,
+ ScalabilityMode::kL3T3,
+ ScalabilityMode::kL3T3h,
+ ScalabilityMode::kL3T3_KEY,
+ ScalabilityMode::kS2T1,
+ ScalabilityMode::kS2T1h,
+ ScalabilityMode::kS2T2,
+ ScalabilityMode::kS2T2h,
+ ScalabilityMode::kS2T3,
+ ScalabilityMode::kS2T3h,
+ ScalabilityMode::kS3T1,
+ ScalabilityMode::kS3T1h,
+ ScalabilityMode::kS3T2,
+ ScalabilityMode::kS3T2h,
+ ScalabilityMode::kS3T3,
+ ScalabilityMode::kS3T3h)
// clang-format on
)
<< "Codec: " << codec.name;
@@ -251,7 +249,7 @@ class PeerConnectionFactoryTest : public ::testing::Test {
}
}
- webrtc::test::ScopedKeyValueConfig field_trials_;
+ test::ScopedKeyValueConfig field_trials_;
std::unique_ptr<rtc::SocketServer> socket_server_;
rtc::AutoSocketServerThread main_thread_;
rtc::scoped_refptr<PeerConnectionFactoryInterface> factory_;
@@ -267,37 +265,27 @@ class PeerConnectionFactoryTest : public ::testing::Test {
// to reconstruct factory with our own ConnectionContext.
rtc::scoped_refptr<PeerConnectionFactoryInterface>
CreatePeerConnectionFactoryWithRtxDisabled() {
- webrtc::PeerConnectionFactoryDependencies pcf_dependencies;
+ PeerConnectionFactoryDependencies pcf_dependencies;
pcf_dependencies.signaling_thread = rtc::Thread::Current();
pcf_dependencies.worker_thread = rtc::Thread::Current();
pcf_dependencies.network_thread = rtc::Thread::Current();
pcf_dependencies.task_queue_factory = CreateDefaultTaskQueueFactory();
- pcf_dependencies.call_factory = CreateCallFactory();
- pcf_dependencies.trials = std::make_unique<webrtc::FieldTrialBasedConfig>();
-
- cricket::MediaEngineDependencies media_dependencies;
- media_dependencies.task_queue_factory =
- pcf_dependencies.task_queue_factory.get();
- media_dependencies.adm = rtc::scoped_refptr<webrtc::AudioDeviceModule>(
- FakeAudioCaptureModule::Create());
- media_dependencies.audio_encoder_factory =
- webrtc::CreateBuiltinAudioEncoderFactory();
- media_dependencies.audio_decoder_factory =
- webrtc::CreateBuiltinAudioDecoderFactory();
- media_dependencies.video_encoder_factory =
+
+ pcf_dependencies.adm = FakeAudioCaptureModule::Create();
+ pcf_dependencies.audio_encoder_factory = CreateBuiltinAudioEncoderFactory();
+ pcf_dependencies.audio_decoder_factory = CreateBuiltinAudioDecoderFactory();
+ pcf_dependencies.video_encoder_factory =
std::make_unique<VideoEncoderFactoryTemplate<
LibvpxVp8EncoderTemplateAdapter, LibvpxVp9EncoderTemplateAdapter,
OpenH264EncoderTemplateAdapter, LibaomAv1EncoderTemplateAdapter>>();
- media_dependencies.video_decoder_factory =
+ pcf_dependencies.video_decoder_factory =
std::make_unique<VideoDecoderFactoryTemplate<
LibvpxVp8DecoderTemplateAdapter, LibvpxVp9DecoderTemplateAdapter,
OpenH264DecoderTemplateAdapter, Dav1dDecoderTemplateAdapter>>(),
- media_dependencies.trials = pcf_dependencies.trials.get();
- pcf_dependencies.media_engine =
- cricket::CreateMediaEngine(std::move(media_dependencies));
+ EnableMedia(pcf_dependencies);
- rtc::scoped_refptr<webrtc::ConnectionContext> context =
- ConnectionContext::Create(&pcf_dependencies);
+ rtc::scoped_refptr<ConnectionContext> context =
+ ConnectionContext::Create(CreateEnvironment(), &pcf_dependencies);
context->set_use_rtx(false);
return rtc::make_ref_counted<PeerConnectionFactory>(context,
&pcf_dependencies);
@@ -311,26 +299,26 @@ CreatePeerConnectionFactoryWithRtxDisabled() {
// See https://bugs.chromium.org/p/webrtc/issues/detail?id=7806 for details.
TEST(PeerConnectionFactoryTestInternal, DISABLED_CreatePCUsingInternalModules) {
#ifdef WEBRTC_ANDROID
- webrtc::InitializeAndroidObjects();
+ InitializeAndroidObjects();
#endif
rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
- webrtc::CreatePeerConnectionFactory(
+ CreatePeerConnectionFactory(
nullptr /* network_thread */, nullptr /* worker_thread */,
nullptr /* signaling_thread */, nullptr /* default_adm */,
- webrtc::CreateBuiltinAudioEncoderFactory(),
- webrtc::CreateBuiltinAudioDecoderFactory(),
+ CreateBuiltinAudioEncoderFactory(),
+ CreateBuiltinAudioDecoderFactory(),
nullptr /* video_encoder_factory */,
nullptr /* video_decoder_factory */, nullptr /* audio_mixer */,
nullptr /* audio_processing */));
NullPeerConnectionObserver observer;
- webrtc::PeerConnectionInterface::RTCConfiguration config;
- config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
+ PeerConnectionInterface::RTCConfiguration config;
+ config.sdp_semantics = SdpSemantics::kUnifiedPlan;
std::unique_ptr<FakeRTCCertificateGenerator> cert_generator(
new FakeRTCCertificateGenerator());
- webrtc::PeerConnectionDependencies pc_dependencies(&observer);
+ PeerConnectionDependencies pc_dependencies(&observer);
pc_dependencies.cert_generator = std::move(cert_generator);
auto result =
factory->CreatePeerConnectionOrError(config, std::move(pc_dependencies));
@@ -339,7 +327,7 @@ TEST(PeerConnectionFactoryTestInternal, DISABLED_CreatePCUsingInternalModules) {
}
TEST_F(PeerConnectionFactoryTest, CheckRtpSenderAudioCapabilities) {
- webrtc::RtpCapabilities audio_capabilities =
+ RtpCapabilities audio_capabilities =
factory_->GetRtpSenderCapabilities(cricket::MEDIA_TYPE_AUDIO);
EXPECT_FALSE(audio_capabilities.codecs.empty());
for (const auto& codec : audio_capabilities.codecs) {
@@ -352,7 +340,7 @@ TEST_F(PeerConnectionFactoryTest, CheckRtpSenderAudioCapabilities) {
}
TEST_F(PeerConnectionFactoryTest, CheckRtpSenderVideoCapabilities) {
- webrtc::RtpCapabilities video_capabilities =
+ RtpCapabilities video_capabilities =
factory_->GetRtpSenderCapabilities(cricket::MEDIA_TYPE_VIDEO);
EXPECT_FALSE(video_capabilities.codecs.empty());
for (const auto& codec : video_capabilities.codecs) {
@@ -365,7 +353,7 @@ TEST_F(PeerConnectionFactoryTest, CheckRtpSenderVideoCapabilities) {
}
TEST_F(PeerConnectionFactoryTest, CheckRtpSenderRtxEnabledCapabilities) {
- webrtc::RtpCapabilities video_capabilities =
+ RtpCapabilities video_capabilities =
factory_->GetRtpSenderCapabilities(cricket::MEDIA_TYPE_VIDEO);
const auto it = std::find_if(
video_capabilities.codecs.begin(), video_capabilities.codecs.end(),
@@ -375,7 +363,7 @@ TEST_F(PeerConnectionFactoryTest, CheckRtpSenderRtxEnabledCapabilities) {
TEST(PeerConnectionFactoryTestInternal, CheckRtpSenderRtxDisabledCapabilities) {
auto factory = CreatePeerConnectionFactoryWithRtxDisabled();
- webrtc::RtpCapabilities video_capabilities =
+ RtpCapabilities video_capabilities =
factory->GetRtpSenderCapabilities(cricket::MEDIA_TYPE_VIDEO);
const auto it = std::find_if(
video_capabilities.codecs.begin(), video_capabilities.codecs.end(),
@@ -384,14 +372,14 @@ TEST(PeerConnectionFactoryTestInternal, CheckRtpSenderRtxDisabledCapabilities) {
}
TEST_F(PeerConnectionFactoryTest, CheckRtpSenderDataCapabilities) {
- webrtc::RtpCapabilities data_capabilities =
+ RtpCapabilities data_capabilities =
factory_->GetRtpSenderCapabilities(cricket::MEDIA_TYPE_DATA);
EXPECT_TRUE(data_capabilities.codecs.empty());
EXPECT_TRUE(data_capabilities.header_extensions.empty());
}
TEST_F(PeerConnectionFactoryTest, CheckRtpReceiverAudioCapabilities) {
- webrtc::RtpCapabilities audio_capabilities =
+ RtpCapabilities audio_capabilities =
factory_->GetRtpReceiverCapabilities(cricket::MEDIA_TYPE_AUDIO);
EXPECT_FALSE(audio_capabilities.codecs.empty());
for (const auto& codec : audio_capabilities.codecs) {
@@ -404,7 +392,7 @@ TEST_F(PeerConnectionFactoryTest, CheckRtpReceiverAudioCapabilities) {
}
TEST_F(PeerConnectionFactoryTest, CheckRtpReceiverVideoCapabilities) {
- webrtc::RtpCapabilities video_capabilities =
+ RtpCapabilities video_capabilities =
factory_->GetRtpReceiverCapabilities(cricket::MEDIA_TYPE_VIDEO);
EXPECT_FALSE(video_capabilities.codecs.empty());
for (const auto& codec : video_capabilities.codecs) {
@@ -417,7 +405,7 @@ TEST_F(PeerConnectionFactoryTest, CheckRtpReceiverVideoCapabilities) {
}
TEST_F(PeerConnectionFactoryTest, CheckRtpReceiverRtxEnabledCapabilities) {
- webrtc::RtpCapabilities video_capabilities =
+ RtpCapabilities video_capabilities =
factory_->GetRtpReceiverCapabilities(cricket::MEDIA_TYPE_VIDEO);
const auto it = std::find_if(
video_capabilities.codecs.begin(), video_capabilities.codecs.end(),
@@ -428,7 +416,7 @@ TEST_F(PeerConnectionFactoryTest, CheckRtpReceiverRtxEnabledCapabilities) {
TEST(PeerConnectionFactoryTestInternal,
CheckRtpReceiverRtxDisabledCapabilities) {
auto factory = CreatePeerConnectionFactoryWithRtxDisabled();
- webrtc::RtpCapabilities video_capabilities =
+ RtpCapabilities video_capabilities =
factory->GetRtpReceiverCapabilities(cricket::MEDIA_TYPE_VIDEO);
const auto it = std::find_if(
video_capabilities.codecs.begin(), video_capabilities.codecs.end(),
@@ -437,7 +425,7 @@ TEST(PeerConnectionFactoryTestInternal,
}
TEST_F(PeerConnectionFactoryTest, CheckRtpReceiverDataCapabilities) {
- webrtc::RtpCapabilities data_capabilities =
+ RtpCapabilities data_capabilities =
factory_->GetRtpReceiverCapabilities(cricket::MEDIA_TYPE_DATA);
EXPECT_TRUE(data_capabilities.codecs.empty());
EXPECT_TRUE(data_capabilities.header_extensions.empty());
@@ -447,8 +435,8 @@ TEST_F(PeerConnectionFactoryTest, CheckRtpReceiverDataCapabilities) {
// configuration. Also verifies the URL's parsed correctly as expected.
TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServers) {
PeerConnectionInterface::RTCConfiguration config;
- config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
- webrtc::PeerConnectionInterface::IceServer ice_server;
+ config.sdp_semantics = SdpSemantics::kUnifiedPlan;
+ PeerConnectionInterface::IceServer ice_server;
ice_server.uri = kStunIceServer;
config.servers.push_back(ice_server);
ice_server.uri = kTurnIceServer;
@@ -459,7 +447,7 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServers) {
ice_server.username = kTurnUsername;
ice_server.password = kTurnPassword;
config.servers.push_back(ice_server);
- webrtc::PeerConnectionDependencies pc_dependencies(&observer_);
+ PeerConnectionDependencies pc_dependencies(&observer_);
pc_dependencies.cert_generator =
std::make_unique<FakeRTCCertificateGenerator>();
pc_dependencies.allocator = std::move(port_allocator_);
@@ -484,15 +472,15 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServers) {
// configuration. Also verifies the list of URL's parsed correctly as expected.
TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServersUrls) {
PeerConnectionInterface::RTCConfiguration config;
- config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
- webrtc::PeerConnectionInterface::IceServer ice_server;
+ config.sdp_semantics = SdpSemantics::kUnifiedPlan;
+ PeerConnectionInterface::IceServer ice_server;
ice_server.urls.push_back(kStunIceServer);
ice_server.urls.push_back(kTurnIceServer);
ice_server.urls.push_back(kTurnIceServerWithTransport);
ice_server.username = kTurnUsername;
ice_server.password = kTurnPassword;
config.servers.push_back(ice_server);
- webrtc::PeerConnectionDependencies pc_dependencies(&observer_);
+ PeerConnectionDependencies pc_dependencies(&observer_);
pc_dependencies.cert_generator =
std::make_unique<FakeRTCCertificateGenerator>();
pc_dependencies.allocator = std::move(port_allocator_);
@@ -515,15 +503,15 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServersUrls) {
TEST_F(PeerConnectionFactoryTest, CreatePCUsingNoUsernameInUri) {
PeerConnectionInterface::RTCConfiguration config;
- config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
- webrtc::PeerConnectionInterface::IceServer ice_server;
+ config.sdp_semantics = SdpSemantics::kUnifiedPlan;
+ PeerConnectionInterface::IceServer ice_server;
ice_server.uri = kStunIceServer;
config.servers.push_back(ice_server);
ice_server.uri = kTurnIceServerWithNoUsernameInUri;
ice_server.username = kTurnUsername;
ice_server.password = kTurnPassword;
config.servers.push_back(ice_server);
- webrtc::PeerConnectionDependencies pc_dependencies(&observer_);
+ PeerConnectionDependencies pc_dependencies(&observer_);
pc_dependencies.cert_generator =
std::make_unique<FakeRTCCertificateGenerator>();
pc_dependencies.allocator = std::move(port_allocator_);
@@ -541,13 +529,13 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingNoUsernameInUri) {
// has transport parameter in it.
TEST_F(PeerConnectionFactoryTest, CreatePCUsingTurnUrlWithTransportParam) {
PeerConnectionInterface::RTCConfiguration config;
- config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
- webrtc::PeerConnectionInterface::IceServer ice_server;
+ config.sdp_semantics = SdpSemantics::kUnifiedPlan;
+ PeerConnectionInterface::IceServer ice_server;
ice_server.uri = kTurnIceServerWithTransport;
ice_server.username = kTurnUsername;
ice_server.password = kTurnPassword;
config.servers.push_back(ice_server);
- webrtc::PeerConnectionDependencies pc_dependencies(&observer_);
+ PeerConnectionDependencies pc_dependencies(&observer_);
pc_dependencies.cert_generator =
std::make_unique<FakeRTCCertificateGenerator>();
pc_dependencies.allocator = std::move(port_allocator_);
@@ -563,8 +551,8 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingTurnUrlWithTransportParam) {
TEST_F(PeerConnectionFactoryTest, CreatePCUsingSecureTurnUrl) {
PeerConnectionInterface::RTCConfiguration config;
- config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
- webrtc::PeerConnectionInterface::IceServer ice_server;
+ config.sdp_semantics = SdpSemantics::kUnifiedPlan;
+ PeerConnectionInterface::IceServer ice_server;
ice_server.uri = kSecureTurnIceServer;
ice_server.username = kTurnUsername;
ice_server.password = kTurnPassword;
@@ -577,7 +565,7 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingSecureTurnUrl) {
ice_server.username = kTurnUsername;
ice_server.password = kTurnPassword;
config.servers.push_back(ice_server);
- webrtc::PeerConnectionDependencies pc_dependencies(&observer_);
+ PeerConnectionDependencies pc_dependencies(&observer_);
pc_dependencies.cert_generator =
std::make_unique<FakeRTCCertificateGenerator>();
pc_dependencies.allocator = std::move(port_allocator_);
@@ -602,8 +590,8 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingSecureTurnUrl) {
TEST_F(PeerConnectionFactoryTest, CreatePCUsingIPLiteralAddress) {
PeerConnectionInterface::RTCConfiguration config;
- config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
- webrtc::PeerConnectionInterface::IceServer ice_server;
+ config.sdp_semantics = SdpSemantics::kUnifiedPlan;
+ PeerConnectionInterface::IceServer ice_server;
ice_server.uri = kStunIceServerWithIPv4Address;
config.servers.push_back(ice_server);
ice_server.uri = kStunIceServerWithIPv4AddressWithoutPort;
@@ -616,7 +604,7 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingIPLiteralAddress) {
ice_server.username = kTurnUsername;
ice_server.password = kTurnPassword;
config.servers.push_back(ice_server);
- webrtc::PeerConnectionDependencies pc_dependencies(&observer_);
+ PeerConnectionDependencies pc_dependencies(&observer_);
pc_dependencies.cert_generator =
std::make_unique<FakeRTCCertificateGenerator>();
pc_dependencies.allocator = std::move(port_allocator_);
@@ -644,8 +632,8 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingIPLiteralAddress) {
// This test verifies the captured stream is rendered locally using a
// local video track.
TEST_F(PeerConnectionFactoryTest, LocalRendering) {
- rtc::scoped_refptr<webrtc::FakeVideoTrackSource> source =
- webrtc::FakeVideoTrackSource::Create(/*is_screencast=*/false);
+ rtc::scoped_refptr<FakeVideoTrackSource> source =
+ FakeVideoTrackSource::Create(/*is_screencast=*/false);
cricket::FakeFrameSource frame_source(1280, 720,
rtc::kNumMicrosecsPerSec / 30);
@@ -673,7 +661,7 @@ TEST_F(PeerConnectionFactoryTest, LocalRendering) {
}
TEST(PeerConnectionFactoryDependenciesTest, UsesNetworkManager) {
- constexpr webrtc::TimeDelta kWaitTimeout = webrtc::TimeDelta::Seconds(10);
+ constexpr TimeDelta kWaitTimeout = TimeDelta::Seconds(10);
auto mock_network_manager = std::make_unique<NiceMock<MockNetworkManager>>();
rtc::Event called;
@@ -681,24 +669,24 @@ TEST(PeerConnectionFactoryDependenciesTest, UsesNetworkManager) {
.Times(AtLeast(1))
.WillRepeatedly(InvokeWithoutArgs([&] { called.Set(); }));
- webrtc::PeerConnectionFactoryDependencies pcf_dependencies;
+ PeerConnectionFactoryDependencies pcf_dependencies;
pcf_dependencies.network_manager = std::move(mock_network_manager);
- rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pcf =
+ rtc::scoped_refptr<PeerConnectionFactoryInterface> pcf =
CreateModularPeerConnectionFactory(std::move(pcf_dependencies));
PeerConnectionInterface::RTCConfiguration config;
config.ice_candidate_pool_size = 2;
NullPeerConnectionObserver observer;
auto pc = pcf->CreatePeerConnectionOrError(
- config, webrtc::PeerConnectionDependencies(&observer));
+ config, PeerConnectionDependencies(&observer));
ASSERT_TRUE(pc.ok());
called.Wait(kWaitTimeout);
}
TEST(PeerConnectionFactoryDependenciesTest, UsesPacketSocketFactory) {
- constexpr webrtc::TimeDelta kWaitTimeout = webrtc::TimeDelta::Seconds(10);
+ constexpr TimeDelta kWaitTimeout = TimeDelta::Seconds(10);
auto mock_socket_factory =
std::make_unique<NiceMock<rtc::MockPacketSocketFactory>>();
@@ -710,10 +698,10 @@ TEST(PeerConnectionFactoryDependenciesTest, UsesPacketSocketFactory) {
}))
.WillRepeatedly(Return(nullptr));
- webrtc::PeerConnectionFactoryDependencies pcf_dependencies;
+ PeerConnectionFactoryDependencies pcf_dependencies;
pcf_dependencies.packet_socket_factory = std::move(mock_socket_factory);
- rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pcf =
+ rtc::scoped_refptr<PeerConnectionFactoryInterface> pcf =
CreateModularPeerConnectionFactory(std::move(pcf_dependencies));
// By default, localhost addresses are ignored, which makes tests fail if test
@@ -726,7 +714,7 @@ TEST(PeerConnectionFactoryDependenciesTest, UsesPacketSocketFactory) {
config.ice_candidate_pool_size = 2;
NullPeerConnectionObserver observer;
auto pc = pcf->CreatePeerConnectionOrError(
- config, webrtc::PeerConnectionDependencies(&observer));
+ config, PeerConnectionDependencies(&observer));
ASSERT_TRUE(pc.ok());
called.Wait(kWaitTimeout);
diff --git a/third_party/libwebrtc/pc/peer_connection_field_trial_tests.cc b/third_party/libwebrtc/pc/peer_connection_field_trial_tests.cc
index 7799c9d6e3..4cbe24986c 100644
--- a/third_party/libwebrtc/pc/peer_connection_field_trial_tests.cc
+++ b/third_party/libwebrtc/pc/peer_connection_field_trial_tests.cc
@@ -16,13 +16,13 @@
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
#include "api/create_peerconnection_factory.h"
+#include "api/enable_media_with_defaults.h"
#include "api/peer_connection_interface.h"
#include "api/stats/rtcstats_objects.h"
#include "api/task_queue/default_task_queue_factory.h"
#include "api/video_codecs/builtin_video_decoder_factory.h"
#include "api/video_codecs/builtin_video_encoder_factory.h"
#include "media/engine/webrtc_media_engine.h"
-#include "media/engine/webrtc_media_engine_defaults.h"
#include "pc/peer_connection_wrapper.h"
#include "pc/session_description.h"
#include "pc/test/fake_audio_capture_module.h"
@@ -68,7 +68,7 @@ class PeerConnectionFieldTrialTest : public ::testing::Test {
#ifdef WEBRTC_ANDROID
InitializeAndroidObjects();
#endif
- webrtc::PeerConnectionInterface::IceServer ice_server;
+ PeerConnectionInterface::IceServer ice_server;
ice_server.uri = "stun:stun.l.google.com:19302";
config_.servers.push_back(ice_server);
config_.sdp_semantics = SdpSemantics::kUnifiedPlan;
@@ -81,13 +81,8 @@ class PeerConnectionFieldTrialTest : public ::testing::Test {
pcf_deps.signaling_thread = rtc::Thread::Current();
pcf_deps.trials = std::move(field_trials);
pcf_deps.task_queue_factory = CreateDefaultTaskQueueFactory();
- pcf_deps.call_factory = webrtc::CreateCallFactory();
- cricket::MediaEngineDependencies media_deps;
- media_deps.task_queue_factory = pcf_deps.task_queue_factory.get();
- media_deps.adm = FakeAudioCaptureModule::Create();
- media_deps.trials = pcf_deps.trials.get();
- webrtc::SetMediaEngineDefaults(&media_deps);
- pcf_deps.media_engine = cricket::CreateMediaEngine(std::move(media_deps));
+ pcf_deps.adm = FakeAudioCaptureModule::Create();
+ EnableMediaWithDefaults(pcf_deps);
pc_factory_ = CreateModularPeerConnectionFactory(std::move(pcf_deps));
// Allow ADAPTER_TYPE_LOOPBACK to create PeerConnections with loopback in
@@ -113,7 +108,7 @@ class PeerConnectionFieldTrialTest : public ::testing::Test {
std::unique_ptr<rtc::SocketServer> socket_server_;
rtc::AutoSocketServerThread main_thread_;
rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory_ = nullptr;
- webrtc::PeerConnectionInterface::RTCConfiguration config_;
+ PeerConnectionInterface::RTCConfiguration config_;
};
// Tests for the dependency descriptor field trial. The dependency descriptor
@@ -138,7 +133,7 @@ TEST_F(PeerConnectionFieldTrialTest, EnableDependencyDescriptorAdvertised) {
media_description1->rtp_header_extensions();
bool found = absl::c_find_if(rtp_header_extensions1,
- [](const webrtc::RtpExtension& rtp_extension) {
+ [](const RtpExtension& rtp_extension) {
return rtp_extension.uri ==
RtpExtension::kDependencyDescriptorUri;
}) != rtp_header_extensions1.end();
@@ -168,14 +163,14 @@ TEST_F(PeerConnectionFieldTrialTest, InjectDependencyDescriptor) {
media_description1->rtp_header_extensions();
bool found1 = absl::c_find_if(rtp_header_extensions1,
- [](const webrtc::RtpExtension& rtp_extension) {
+ [](const RtpExtension& rtp_extension) {
return rtp_extension.uri ==
RtpExtension::kDependencyDescriptorUri;
}) != rtp_header_extensions1.end();
EXPECT_FALSE(found1);
std::set<int> existing_ids;
- for (const webrtc::RtpExtension& rtp_extension : rtp_header_extensions1) {
+ for (const RtpExtension& rtp_extension : rtp_header_extensions1) {
existing_ids.insert(rtp_extension.id);
}
@@ -212,7 +207,7 @@ TEST_F(PeerConnectionFieldTrialTest, InjectDependencyDescriptor) {
media_description2->rtp_header_extensions();
bool found2 = absl::c_find_if(rtp_header_extensions2,
- [](const webrtc::RtpExtension& rtp_extension) {
+ [](const RtpExtension& rtp_extension) {
return rtp_extension.uri ==
RtpExtension::kDependencyDescriptorUri;
}) != rtp_header_extensions2.end();
diff --git a/third_party/libwebrtc/pc/peer_connection_header_extension_unittest.cc b/third_party/libwebrtc/pc/peer_connection_header_extension_unittest.cc
index b1c6c3cfb5..277979b330 100644
--- a/third_party/libwebrtc/pc/peer_connection_header_extension_unittest.cc
+++ b/third_party/libwebrtc/pc/peer_connection_header_extension_unittest.cc
@@ -16,7 +16,6 @@
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
-#include "api/call/call_factory_interface.h"
#include "api/jsep.h"
#include "api/media_types.h"
#include "api/peer_connection_interface.h"
@@ -35,6 +34,7 @@
#include "p2p/base/port_allocator.h"
#include "pc/peer_connection_wrapper.h"
#include "pc/session_description.h"
+#include "pc/test/enable_fake_media.h"
#include "pc/test/mock_peer_connection_observers.h"
#include "rtc_base/internal/default_socket_server.h"
#include "rtc_base/rtc_certificate_generator.h"
@@ -77,21 +77,18 @@ class PeerConnectionHeaderExtensionTest
std::unique_ptr<PeerConnectionWrapper> CreatePeerConnection(
cricket::MediaType media_type,
absl::optional<SdpSemantics> semantics) {
- auto voice = std::make_unique<cricket::FakeVoiceEngine>();
- auto video = std::make_unique<cricket::FakeVideoEngine>();
+ auto media_engine = std::make_unique<cricket::FakeMediaEngine>();
if (media_type == cricket::MediaType::MEDIA_TYPE_AUDIO)
- voice->SetRtpHeaderExtensions(extensions_);
+ media_engine->fake_voice_engine()->SetRtpHeaderExtensions(extensions_);
else
- video->SetRtpHeaderExtensions(extensions_);
- auto media_engine = std::make_unique<cricket::CompositeMediaEngine>(
- std::move(voice), std::move(video));
+ media_engine->fake_video_engine()->SetRtpHeaderExtensions(extensions_);
PeerConnectionFactoryDependencies factory_dependencies;
factory_dependencies.network_thread = rtc::Thread::Current();
factory_dependencies.worker_thread = rtc::Thread::Current();
factory_dependencies.signaling_thread = rtc::Thread::Current();
factory_dependencies.task_queue_factory = CreateDefaultTaskQueueFactory();
- factory_dependencies.media_engine = std::move(media_engine);
- factory_dependencies.call_factory = CreateCallFactory();
+ EnableFakeMedia(factory_dependencies, std::move(media_engine));
+
factory_dependencies.event_log_factory =
std::make_unique<RtcEventLogFactory>(
factory_dependencies.task_queue_factory.get());
@@ -117,7 +114,7 @@ class PeerConnectionHeaderExtensionTest
pc_factory, result.MoveValue(), std::move(observer));
}
- webrtc::test::ScopedKeyValueConfig field_trials_;
+ test::ScopedKeyValueConfig field_trials_;
std::unique_ptr<rtc::SocketServer> socket_server_;
rtc::AutoSocketServerThread main_thread_;
std::vector<RtpHeaderExtensionCapability> extensions_;
diff --git a/third_party/libwebrtc/pc/peer_connection_histogram_unittest.cc b/third_party/libwebrtc/pc/peer_connection_histogram_unittest.cc
index 68a4dbc361..58bd6ebb48 100644
--- a/third_party/libwebrtc/pc/peer_connection_histogram_unittest.cc
+++ b/third_party/libwebrtc/pc/peer_connection_histogram_unittest.cc
@@ -15,7 +15,6 @@
#include <vector>
#include "absl/types/optional.h"
-#include "api/async_resolver_factory.h"
#include "api/call/call_factory_interface.h"
#include "api/jsep.h"
#include "api/jsep_session_description.h"
@@ -25,9 +24,7 @@
#include "api/task_queue/default_task_queue_factory.h"
#include "api/task_queue/task_queue_factory.h"
#include "api/test/mock_async_dns_resolver.h"
-#include "media/base/fake_media_engine.h"
#include "media/base/media_engine.h"
-#include "p2p/base/mock_async_resolver.h"
#include "p2p/base/port_allocator.h"
#include "p2p/client/basic_port_allocator.h"
#include "pc/peer_connection.h"
@@ -35,6 +32,7 @@
#include "pc/peer_connection_proxy.h"
#include "pc/peer_connection_wrapper.h"
#include "pc/sdp_utils.h"
+#include "pc/test/enable_fake_media.h"
#include "pc/test/mock_peer_connection_observers.h"
#include "pc/usage_pattern.h"
#include "pc/webrtc_sdp.h"
@@ -84,9 +82,7 @@ class PeerConnectionFactoryForUsageHistogramTest
dependencies.worker_thread = rtc::Thread::Current();
dependencies.signaling_thread = rtc::Thread::Current();
dependencies.task_queue_factory = CreateDefaultTaskQueueFactory();
- dependencies.media_engine =
- std::make_unique<cricket::FakeMediaEngine>();
- dependencies.call_factory = CreateCallFactory();
+ EnableFakeMedia(dependencies);
return dependencies;
}()) {}
};
@@ -97,7 +93,7 @@ typedef PeerConnectionWrapperForUsageHistogramTest* RawWrapperPtr;
class ObserverForUsageHistogramTest : public MockPeerConnectionObserver {
public:
- void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override;
+ void OnIceCandidate(const IceCandidateInterface* candidate) override;
void OnInterestingUsage(int usage_pattern) override {
interesting_usage_detected_ = usage_pattern;
@@ -160,12 +156,11 @@ class PeerConnectionWrapperForUsageHistogramTest
return static_cast<ObserverForUsageHistogramTest*>(observer())
->HaveDataChannel();
}
- void BufferIceCandidate(const webrtc::IceCandidateInterface* candidate) {
+ void BufferIceCandidate(const IceCandidateInterface* candidate) {
std::string sdp;
EXPECT_TRUE(candidate->ToString(&sdp));
- std::unique_ptr<webrtc::IceCandidateInterface> candidate_copy(
- CreateIceCandidate(candidate->sdp_mid(), candidate->sdp_mline_index(),
- sdp, nullptr));
+ std::unique_ptr<IceCandidateInterface> candidate_copy(CreateIceCandidate(
+ candidate->sdp_mid(), candidate->sdp_mline_index(), sdp, nullptr));
buffered_candidates_.push_back(std::move(candidate_copy));
}
@@ -216,19 +211,18 @@ class PeerConnectionWrapperForUsageHistogramTest
return true;
}
- webrtc::PeerConnectionInterface::IceGatheringState ice_gathering_state() {
+ PeerConnectionInterface::IceGatheringState ice_gathering_state() {
return pc()->ice_gathering_state();
}
private:
// Candidates that have been sent but not yet configured
- std::vector<std::unique_ptr<webrtc::IceCandidateInterface>>
- buffered_candidates_;
+ std::vector<std::unique_ptr<IceCandidateInterface>> buffered_candidates_;
};
// Buffers candidates until we add them via AddBufferedIceCandidates.
void ObserverForUsageHistogramTest::OnIceCandidate(
- const webrtc::IceCandidateInterface* candidate) {
+ const IceCandidateInterface* candidate) {
// If target is not set, ignore. This happens in one-ended unit tests.
if (candidate_target_) {
this->candidate_target_->BufferIceCandidate(candidate);
@@ -245,12 +239,12 @@ class PeerConnectionUsageHistogramTest : public ::testing::Test {
: vss_(new rtc::VirtualSocketServer()),
socket_factory_(new rtc::BasicPacketSocketFactory(vss_.get())),
main_(vss_.get()) {
- webrtc::metrics::Reset();
+ metrics::Reset();
}
WrapperPtr CreatePeerConnection() {
RTCConfiguration config;
- config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
+ config.sdp_semantics = SdpSemantics::kUnifiedPlan;
return CreatePeerConnection(
config, PeerConnectionFactoryInterface::Options(), nullptr);
}
@@ -262,13 +256,13 @@ class PeerConnectionUsageHistogramTest : public ::testing::Test {
WrapperPtr CreatePeerConnectionWithMdns(const RTCConfiguration& config) {
auto resolver_factory =
- std::make_unique<NiceMock<webrtc::MockAsyncDnsResolverFactory>>();
+ std::make_unique<NiceMock<MockAsyncDnsResolverFactory>>();
- webrtc::PeerConnectionDependencies deps(nullptr /* observer_in */);
+ PeerConnectionDependencies deps(nullptr /* observer_in */);
auto fake_network = NewFakeNetwork();
fake_network->set_mdns_responder(
- std::make_unique<webrtc::FakeMdnsResponder>(rtc::Thread::Current()));
+ std::make_unique<FakeMdnsResponder>(rtc::Thread::Current()));
fake_network->AddInterface(NextLocalAddress());
std::unique_ptr<cricket::BasicPortAllocator> port_allocator(
@@ -283,7 +277,7 @@ class PeerConnectionUsageHistogramTest : public ::testing::Test {
WrapperPtr CreatePeerConnectionWithImmediateReport() {
RTCConfiguration configuration;
- configuration.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan;
+ configuration.sdp_semantics = SdpSemantics::kUnifiedPlan;
configuration.report_usage_pattern_delay_ms = 0;
return CreatePeerConnection(
configuration, PeerConnectionFactoryInterface::Options(), nullptr);
@@ -364,7 +358,7 @@ class PeerConnectionUsageHistogramTest : public ::testing::Test {
// This works correctly only if there is only one sample value
// that has been counted.
// Returns -1 for "not found".
- return webrtc::metrics::MinSample(kUsagePatternMetric);
+ return metrics::MinSample(kUsagePatternMetric);
}
// The PeerConnection's port allocator is tied to the PeerConnection's
@@ -393,10 +387,10 @@ TEST_F(PeerConnectionUsageHistogramTest, UsageFingerprintHistogramFromTimeout) {
auto pc = CreatePeerConnectionWithImmediateReport();
int expected_fingerprint = MakeUsageFingerprint({});
- EXPECT_METRIC_EQ_WAIT(1, webrtc::metrics::NumSamples(kUsagePatternMetric),
+ EXPECT_METRIC_EQ_WAIT(1, metrics::NumSamples(kUsagePatternMetric),
kDefaultTimeout);
EXPECT_METRIC_EQ(
- 1, webrtc::metrics::NumEvents(kUsagePatternMetric, expected_fingerprint));
+ 1, metrics::NumEvents(kUsagePatternMetric, expected_fingerprint));
}
#ifndef WEBRTC_ANDROID
@@ -421,11 +415,10 @@ TEST_F(PeerConnectionUsageHistogramTest, FingerprintAudioVideo) {
UsageEvent::DIRECT_CONNECTION_SELECTED, UsageEvent::CLOSE_CALLED});
// In this case, we may or may not have PRIVATE_CANDIDATE_COLLECTED,
// depending on the machine configuration.
- EXPECT_METRIC_EQ(2, webrtc::metrics::NumSamples(kUsagePatternMetric));
+ EXPECT_METRIC_EQ(2, metrics::NumSamples(kUsagePatternMetric));
EXPECT_METRIC_TRUE(
- webrtc::metrics::NumEvents(kUsagePatternMetric, expected_fingerprint) ==
- 2 ||
- webrtc::metrics::NumEvents(
+ metrics::NumEvents(kUsagePatternMetric, expected_fingerprint) == 2 ||
+ metrics::NumEvents(
kUsagePatternMetric,
expected_fingerprint |
static_cast<int>(UsageEvent::PRIVATE_CANDIDATE_COLLECTED)) == 2);
@@ -466,11 +459,11 @@ TEST_F(PeerConnectionUsageHistogramTest, FingerprintWithMdnsCaller) {
UsageEvent::CANDIDATE_COLLECTED, UsageEvent::ADD_ICE_CANDIDATE_SUCCEEDED,
UsageEvent::REMOTE_MDNS_CANDIDATE_ADDED, UsageEvent::ICE_STATE_CONNECTED,
UsageEvent::REMOTE_CANDIDATE_ADDED, UsageEvent::CLOSE_CALLED});
- EXPECT_METRIC_EQ(2, webrtc::metrics::NumSamples(kUsagePatternMetric));
- EXPECT_METRIC_EQ(1, webrtc::metrics::NumEvents(kUsagePatternMetric,
- expected_fingerprint_caller));
- EXPECT_METRIC_EQ(1, webrtc::metrics::NumEvents(kUsagePatternMetric,
- expected_fingerprint_callee));
+ EXPECT_METRIC_EQ(2, metrics::NumSamples(kUsagePatternMetric));
+ EXPECT_METRIC_EQ(
+ 1, metrics::NumEvents(kUsagePatternMetric, expected_fingerprint_caller));
+ EXPECT_METRIC_EQ(
+ 1, metrics::NumEvents(kUsagePatternMetric, expected_fingerprint_callee));
}
// Test getting the usage fingerprint when the callee collects an mDNS
@@ -507,11 +500,11 @@ TEST_F(PeerConnectionUsageHistogramTest, FingerprintWithMdnsCallee) {
UsageEvent::ADD_ICE_CANDIDATE_SUCCEEDED, UsageEvent::ICE_STATE_CONNECTED,
UsageEvent::REMOTE_CANDIDATE_ADDED,
UsageEvent::DIRECT_CONNECTION_SELECTED, UsageEvent::CLOSE_CALLED});
- EXPECT_METRIC_EQ(2, webrtc::metrics::NumSamples(kUsagePatternMetric));
- EXPECT_METRIC_EQ(1, webrtc::metrics::NumEvents(kUsagePatternMetric,
- expected_fingerprint_caller));
- EXPECT_METRIC_EQ(1, webrtc::metrics::NumEvents(kUsagePatternMetric,
- expected_fingerprint_callee));
+ EXPECT_METRIC_EQ(2, metrics::NumSamples(kUsagePatternMetric));
+ EXPECT_METRIC_EQ(
+ 1, metrics::NumEvents(kUsagePatternMetric, expected_fingerprint_caller));
+ EXPECT_METRIC_EQ(
+ 1, metrics::NumEvents(kUsagePatternMetric, expected_fingerprint_callee));
}
#ifdef WEBRTC_HAVE_SCTP
@@ -529,11 +522,10 @@ TEST_F(PeerConnectionUsageHistogramTest, FingerprintDataOnly) {
UsageEvent::CANDIDATE_COLLECTED, UsageEvent::ADD_ICE_CANDIDATE_SUCCEEDED,
UsageEvent::ICE_STATE_CONNECTED, UsageEvent::REMOTE_CANDIDATE_ADDED,
UsageEvent::DIRECT_CONNECTION_SELECTED, UsageEvent::CLOSE_CALLED});
- EXPECT_METRIC_EQ(2, webrtc::metrics::NumSamples(kUsagePatternMetric));
+ EXPECT_METRIC_EQ(2, metrics::NumSamples(kUsagePatternMetric));
EXPECT_METRIC_TRUE(
- webrtc::metrics::NumEvents(kUsagePatternMetric, expected_fingerprint) ==
- 2 ||
- webrtc::metrics::NumEvents(
+ metrics::NumEvents(kUsagePatternMetric, expected_fingerprint) == 2 ||
+ metrics::NumEvents(
kUsagePatternMetric,
expected_fingerprint |
static_cast<int>(UsageEvent::PRIVATE_CANDIDATE_COLLECTED)) == 2);
@@ -557,9 +549,9 @@ TEST_F(PeerConnectionUsageHistogramTest, FingerprintStunTurn) {
int expected_fingerprint = MakeUsageFingerprint(
{UsageEvent::STUN_SERVER_ADDED, UsageEvent::TURN_SERVER_ADDED,
UsageEvent::CLOSE_CALLED});
- EXPECT_METRIC_EQ(1, webrtc::metrics::NumSamples(kUsagePatternMetric));
+ EXPECT_METRIC_EQ(1, metrics::NumSamples(kUsagePatternMetric));
EXPECT_METRIC_EQ(
- 1, webrtc::metrics::NumEvents(kUsagePatternMetric, expected_fingerprint));
+ 1, metrics::NumEvents(kUsagePatternMetric, expected_fingerprint));
}
TEST_F(PeerConnectionUsageHistogramTest, FingerprintStunTurnInReconfiguration) {
@@ -579,9 +571,9 @@ TEST_F(PeerConnectionUsageHistogramTest, FingerprintStunTurnInReconfiguration) {
int expected_fingerprint = MakeUsageFingerprint(
{UsageEvent::STUN_SERVER_ADDED, UsageEvent::TURN_SERVER_ADDED,
UsageEvent::CLOSE_CALLED});
- EXPECT_METRIC_EQ(1, webrtc::metrics::NumSamples(kUsagePatternMetric));
+ EXPECT_METRIC_EQ(1, metrics::NumSamples(kUsagePatternMetric));
EXPECT_METRIC_EQ(
- 1, webrtc::metrics::NumEvents(kUsagePatternMetric, expected_fingerprint));
+ 1, metrics::NumEvents(kUsagePatternMetric, expected_fingerprint));
}
TEST_F(PeerConnectionUsageHistogramTest, FingerprintWithPrivateIPCaller) {
@@ -607,11 +599,11 @@ TEST_F(PeerConnectionUsageHistogramTest, FingerprintWithPrivateIPCaller) {
UsageEvent::REMOTE_PRIVATE_CANDIDATE_ADDED,
UsageEvent::ICE_STATE_CONNECTED, UsageEvent::REMOTE_CANDIDATE_ADDED,
UsageEvent::DIRECT_CONNECTION_SELECTED, UsageEvent::CLOSE_CALLED});
- EXPECT_METRIC_EQ(2, webrtc::metrics::NumSamples(kUsagePatternMetric));
- EXPECT_METRIC_EQ(1, webrtc::metrics::NumEvents(kUsagePatternMetric,
- expected_fingerprint_caller));
- EXPECT_METRIC_EQ(1, webrtc::metrics::NumEvents(kUsagePatternMetric,
- expected_fingerprint_callee));
+ EXPECT_METRIC_EQ(2, metrics::NumSamples(kUsagePatternMetric));
+ EXPECT_METRIC_EQ(
+ 1, metrics::NumEvents(kUsagePatternMetric, expected_fingerprint_caller));
+ EXPECT_METRIC_EQ(
+ 1, metrics::NumEvents(kUsagePatternMetric, expected_fingerprint_callee));
}
TEST_F(PeerConnectionUsageHistogramTest, FingerprintWithPrivateIpv6Callee) {
@@ -639,11 +631,11 @@ TEST_F(PeerConnectionUsageHistogramTest, FingerprintWithPrivateIpv6Callee) {
UsageEvent::ADD_ICE_CANDIDATE_SUCCEEDED,
UsageEvent::REMOTE_CANDIDATE_ADDED, UsageEvent::ICE_STATE_CONNECTED,
UsageEvent::DIRECT_CONNECTION_SELECTED, UsageEvent::CLOSE_CALLED});
- EXPECT_METRIC_EQ(2, webrtc::metrics::NumSamples(kUsagePatternMetric));
- EXPECT_METRIC_EQ(1, webrtc::metrics::NumEvents(kUsagePatternMetric,
- expected_fingerprint_caller));
- EXPECT_METRIC_EQ(1, webrtc::metrics::NumEvents(kUsagePatternMetric,
- expected_fingerprint_callee));
+ EXPECT_METRIC_EQ(2, metrics::NumSamples(kUsagePatternMetric));
+ EXPECT_METRIC_EQ(
+ 1, metrics::NumEvents(kUsagePatternMetric, expected_fingerprint_caller));
+ EXPECT_METRIC_EQ(
+ 1, metrics::NumEvents(kUsagePatternMetric, expected_fingerprint_callee));
}
#ifndef WEBRTC_ANDROID
@@ -667,7 +659,7 @@ TEST_F(PeerConnectionUsageHistogramTest,
ASSERT_TRUE(caller->SetLocalDescription(caller->CreateOffer()));
// Wait until the gathering completes so that the session description would
// have contained ICE candidates.
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceGatheringComplete,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete,
caller->ice_gathering_state(), kDefaultTimeout);
EXPECT_TRUE(caller->observer()->candidate_gathered());
// Get the current offer that contains candidates and pass it to the callee.
@@ -716,11 +708,11 @@ TEST_F(PeerConnectionUsageHistogramTest,
UsageEvent::REMOTE_PRIVATE_CANDIDATE_ADDED,
UsageEvent::REMOTE_IPV6_CANDIDATE_ADDED, UsageEvent::ICE_STATE_CONNECTED,
UsageEvent::DIRECT_CONNECTION_SELECTED, UsageEvent::CLOSE_CALLED});
- EXPECT_METRIC_EQ(2, webrtc::metrics::NumSamples(kUsagePatternMetric));
- EXPECT_METRIC_EQ(1, webrtc::metrics::NumEvents(kUsagePatternMetric,
- expected_fingerprint_caller));
- EXPECT_METRIC_EQ(1, webrtc::metrics::NumEvents(kUsagePatternMetric,
- expected_fingerprint_callee));
+ EXPECT_METRIC_EQ(2, metrics::NumSamples(kUsagePatternMetric));
+ EXPECT_METRIC_EQ(
+ 1, metrics::NumEvents(kUsagePatternMetric, expected_fingerprint_caller));
+ EXPECT_METRIC_EQ(
+ 1, metrics::NumEvents(kUsagePatternMetric, expected_fingerprint_callee));
}
TEST_F(PeerConnectionUsageHistogramTest, NotableUsageNoted) {
@@ -731,7 +723,7 @@ TEST_F(PeerConnectionUsageHistogramTest, NotableUsageNoted) {
int expected_fingerprint = MakeUsageFingerprint(
{UsageEvent::DATA_ADDED, UsageEvent::SET_LOCAL_DESCRIPTION_SUCCEEDED,
UsageEvent::CANDIDATE_COLLECTED, UsageEvent::CLOSE_CALLED});
- EXPECT_METRIC_EQ(1, webrtc::metrics::NumSamples(kUsagePatternMetric));
+ EXPECT_METRIC_EQ(1, metrics::NumSamples(kUsagePatternMetric));
EXPECT_METRIC_TRUE(
expected_fingerprint == ObservedFingerprint() ||
(expected_fingerprint |
@@ -748,9 +740,9 @@ TEST_F(PeerConnectionUsageHistogramTest, NotableUsageOnEventFiring) {
int expected_fingerprint = MakeUsageFingerprint(
{UsageEvent::DATA_ADDED, UsageEvent::SET_LOCAL_DESCRIPTION_SUCCEEDED,
UsageEvent::CANDIDATE_COLLECTED});
- EXPECT_METRIC_EQ(0, webrtc::metrics::NumSamples(kUsagePatternMetric));
+ EXPECT_METRIC_EQ(0, metrics::NumSamples(kUsagePatternMetric));
caller->GetInternalPeerConnection()->RequestUsagePatternReportForTesting();
- EXPECT_METRIC_EQ_WAIT(1, webrtc::metrics::NumSamples(kUsagePatternMetric),
+ EXPECT_METRIC_EQ_WAIT(1, metrics::NumSamples(kUsagePatternMetric),
kDefaultTimeout);
EXPECT_METRIC_TRUE(
expected_fingerprint == ObservedFingerprint() ||
@@ -769,12 +761,12 @@ TEST_F(PeerConnectionUsageHistogramTest,
int expected_fingerprint = MakeUsageFingerprint(
{UsageEvent::DATA_ADDED, UsageEvent::SET_LOCAL_DESCRIPTION_SUCCEEDED,
UsageEvent::CANDIDATE_COLLECTED, UsageEvent::CLOSE_CALLED});
- EXPECT_METRIC_EQ(0, webrtc::metrics::NumSamples(kUsagePatternMetric));
+ EXPECT_METRIC_EQ(0, metrics::NumSamples(kUsagePatternMetric));
caller->pc()->Close();
- EXPECT_METRIC_EQ(1, webrtc::metrics::NumSamples(kUsagePatternMetric));
+ EXPECT_METRIC_EQ(1, metrics::NumSamples(kUsagePatternMetric));
caller->GetInternalPeerConnection()->RequestUsagePatternReportForTesting();
caller->observer()->ClearInterestingUsageDetector();
- EXPECT_METRIC_EQ_WAIT(2, webrtc::metrics::NumSamples(kUsagePatternMetric),
+ EXPECT_METRIC_EQ_WAIT(2, metrics::NumSamples(kUsagePatternMetric),
kDefaultTimeout);
EXPECT_METRIC_TRUE(
expected_fingerprint == ObservedFingerprint() ||
diff --git a/third_party/libwebrtc/pc/peer_connection_ice_unittest.cc b/third_party/libwebrtc/pc/peer_connection_ice_unittest.cc
index 532583f307..492e108cbc 100644
--- a/third_party/libwebrtc/pc/peer_connection_ice_unittest.cc
+++ b/third_party/libwebrtc/pc/peer_connection_ice_unittest.cc
@@ -342,7 +342,7 @@ class PeerConnectionIceTest
public ::testing::WithParamInterface<SdpSemantics> {
protected:
PeerConnectionIceTest() : PeerConnectionIceBaseTest(GetParam()) {
- webrtc::metrics::Reset();
+ metrics::Reset();
}
};
@@ -514,7 +514,7 @@ TEST_P(PeerConnectionIceTest, CannotAddCandidateWhenRemoteDescriptionNotSet) {
EXPECT_FALSE(caller->pc()->AddIceCandidate(jsep_candidate.get()));
EXPECT_METRIC_THAT(
- webrtc::metrics::Samples("WebRTC.PeerConnection.AddIceCandidate"),
+ metrics::Samples("WebRTC.PeerConnection.AddIceCandidate"),
ElementsAre(Pair(kAddIceCandidateFailNoRemoteDescription, 2)));
}
@@ -1457,7 +1457,7 @@ class PeerConnectionIceConfigTest : public ::testing::Test {
pc_ = result.MoveValue();
}
- webrtc::test::ScopedKeyValueConfig field_trials_;
+ test::ScopedKeyValueConfig field_trials_;
std::unique_ptr<rtc::SocketServer> socket_server_;
rtc::AutoSocketServerThread main_thread_;
rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory_ = nullptr;
diff --git a/third_party/libwebrtc/pc/peer_connection_integrationtest.cc b/third_party/libwebrtc/pc/peer_connection_integrationtest.cc
index d76e5e27d5..bfff86ee93 100644
--- a/third_party/libwebrtc/pc/peer_connection_integrationtest.cc
+++ b/third_party/libwebrtc/pc/peer_connection_integrationtest.cc
@@ -28,7 +28,6 @@
#include "absl/memory/memory.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
-#include "api/async_resolver_factory.h"
#include "api/candidate.h"
#include "api/crypto/crypto_options.h"
#include "api/dtmf_sender_interface.h"
@@ -61,7 +60,6 @@
#include "media/base/codec.h"
#include "media/base/media_constants.h"
#include "media/base/stream_params.h"
-#include "p2p/base/mock_async_resolver.h"
#include "p2p/base/port.h"
#include "p2p/base/port_allocator.h"
#include "p2p/base/port_interface.h"
@@ -104,6 +102,12 @@ namespace webrtc {
namespace {
+using ::testing::AtLeast;
+using ::testing::InSequence;
+using ::testing::MockFunction;
+using ::testing::NiceMock;
+using ::testing::Return;
+
class PeerConnectionIntegrationTest
: public PeerConnectionIntegrationBaseTest,
public ::testing::WithParamInterface<SdpSemantics> {
@@ -124,7 +128,7 @@ class FakeClockForTest : public rtc::ScopedFakeClock {
// Some things use a time of "0" as a special value, so we need to start out
// the fake clock at a nonzero time.
// TODO(deadbeef): Fix this.
- AdvanceTime(webrtc::TimeDelta::Seconds(1));
+ AdvanceTime(TimeDelta::Seconds(1));
}
// Explicit handle.
@@ -324,7 +328,7 @@ TEST_P(PeerConnectionIntegrationTest,
ConnectFakeSignaling();
// Add video tracks with 16:9 aspect ratio, size 1280 x 720.
- webrtc::FakePeriodicVideoSource::Config config;
+ FakePeriodicVideoSource::Config config;
config.width = 1280;
config.height = 720;
config.timestamp_offset_ms = rtc::TimeMillis();
@@ -366,7 +370,7 @@ TEST_P(PeerConnectionIntegrationTest, EndToEndCallWithSendOnlyVideo) {
CreateOneDirectionalPeerConnectionWrappers(/*caller_to_callee=*/true));
ConnectFakeSignaling();
// Add one-directional video, from caller to callee.
- rtc::scoped_refptr<webrtc::VideoTrackInterface> caller_track =
+ rtc::scoped_refptr<VideoTrackInterface> caller_track =
caller()->CreateLocalVideoTrack();
caller()->AddTrack(caller_track);
PeerConnectionInterface::RTCOfferAnswerOptions options;
@@ -391,7 +395,7 @@ TEST_P(PeerConnectionIntegrationTest, EndToEndCallWithReceiveOnlyVideo) {
CreateOneDirectionalPeerConnectionWrappers(/*caller_to_callee=*/false));
ConnectFakeSignaling();
// Add one-directional video, from callee to caller.
- rtc::scoped_refptr<webrtc::VideoTrackInterface> callee_track =
+ rtc::scoped_refptr<VideoTrackInterface> callee_track =
callee()->CreateLocalVideoTrack();
callee()->AddTrack(callee_track);
PeerConnectionInterface::RTCOfferAnswerOptions options;
@@ -414,14 +418,14 @@ TEST_P(PeerConnectionIntegrationTest,
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
// Add one-directional video, from caller to callee.
- rtc::scoped_refptr<webrtc::VideoTrackInterface> caller_track =
+ rtc::scoped_refptr<VideoTrackInterface> caller_track =
caller()->CreateLocalVideoTrack();
caller()->AddTrack(caller_track);
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
// Add receive video.
- rtc::scoped_refptr<webrtc::VideoTrackInterface> callee_track =
+ rtc::scoped_refptr<VideoTrackInterface> callee_track =
callee()->CreateLocalVideoTrack();
callee()->AddTrack(callee_track);
caller()->CreateAndSetAndSignalOffer();
@@ -438,14 +442,14 @@ TEST_P(PeerConnectionIntegrationTest,
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
// Add one-directional video, from callee to caller.
- rtc::scoped_refptr<webrtc::VideoTrackInterface> callee_track =
+ rtc::scoped_refptr<VideoTrackInterface> callee_track =
callee()->CreateLocalVideoTrack();
callee()->AddTrack(callee_track);
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
// Add send video.
- rtc::scoped_refptr<webrtc::VideoTrackInterface> caller_track =
+ rtc::scoped_refptr<VideoTrackInterface> caller_track =
caller()->CreateLocalVideoTrack();
caller()->AddTrack(caller_track);
caller()->CreateAndSetAndSignalOffer();
@@ -462,15 +466,15 @@ TEST_P(PeerConnectionIntegrationTest,
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
// Add send video, from caller to callee.
- rtc::scoped_refptr<webrtc::VideoTrackInterface> caller_track =
+ rtc::scoped_refptr<VideoTrackInterface> caller_track =
caller()->CreateLocalVideoTrack();
- rtc::scoped_refptr<webrtc::RtpSenderInterface> caller_sender =
+ rtc::scoped_refptr<RtpSenderInterface> caller_sender =
caller()->AddTrack(caller_track);
// Add receive video, from callee to caller.
- rtc::scoped_refptr<webrtc::VideoTrackInterface> callee_track =
+ rtc::scoped_refptr<VideoTrackInterface> callee_track =
callee()->CreateLocalVideoTrack();
- rtc::scoped_refptr<webrtc::RtpSenderInterface> callee_sender =
+ rtc::scoped_refptr<RtpSenderInterface> callee_sender =
callee()->AddTrack(callee_track);
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
@@ -494,15 +498,15 @@ TEST_P(PeerConnectionIntegrationTest,
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
// Add send video, from caller to callee.
- rtc::scoped_refptr<webrtc::VideoTrackInterface> caller_track =
+ rtc::scoped_refptr<VideoTrackInterface> caller_track =
caller()->CreateLocalVideoTrack();
- rtc::scoped_refptr<webrtc::RtpSenderInterface> caller_sender =
+ rtc::scoped_refptr<RtpSenderInterface> caller_sender =
caller()->AddTrack(caller_track);
// Add receive video, from callee to caller.
- rtc::scoped_refptr<webrtc::VideoTrackInterface> callee_track =
+ rtc::scoped_refptr<VideoTrackInterface> callee_track =
callee()->CreateLocalVideoTrack();
- rtc::scoped_refptr<webrtc::RtpSenderInterface> callee_sender =
+ rtc::scoped_refptr<RtpSenderInterface> callee_sender =
callee()->AddTrack(callee_track);
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
@@ -654,9 +658,9 @@ TEST_P(PeerConnectionIntegrationTest, RotatedVideoWithCVOExtension) {
ConnectFakeSignaling();
// Add rotated video tracks.
caller()->AddTrack(
- caller()->CreateLocalVideoTrackWithRotation(webrtc::kVideoRotation_90));
+ caller()->CreateLocalVideoTrackWithRotation(kVideoRotation_90));
callee()->AddTrack(
- callee()->CreateLocalVideoTrackWithRotation(webrtc::kVideoRotation_270));
+ callee()->CreateLocalVideoTrackWithRotation(kVideoRotation_270));
// Wait for video frames to be received by both sides.
caller()->CreateAndSetAndSignalOffer();
@@ -673,8 +677,8 @@ TEST_P(PeerConnectionIntegrationTest, RotatedVideoWithCVOExtension) {
EXPECT_EQ(4.0 / 3, callee()->local_rendered_aspect_ratio());
EXPECT_EQ(4.0 / 3, callee()->rendered_aspect_ratio());
// Ensure that the CVO bits were surfaced to the renderer.
- EXPECT_EQ(webrtc::kVideoRotation_270, caller()->rendered_rotation());
- EXPECT_EQ(webrtc::kVideoRotation_90, callee()->rendered_rotation());
+ EXPECT_EQ(kVideoRotation_270, caller()->rendered_rotation());
+ EXPECT_EQ(kVideoRotation_90, callee()->rendered_rotation());
}
// Test that when the CVO extension isn't supported, video is rotated the
@@ -684,9 +688,9 @@ TEST_P(PeerConnectionIntegrationTest, RotatedVideoWithoutCVOExtension) {
ConnectFakeSignaling();
// Add rotated video tracks.
caller()->AddTrack(
- caller()->CreateLocalVideoTrackWithRotation(webrtc::kVideoRotation_90));
+ caller()->CreateLocalVideoTrackWithRotation(kVideoRotation_90));
callee()->AddTrack(
- callee()->CreateLocalVideoTrackWithRotation(webrtc::kVideoRotation_270));
+ callee()->CreateLocalVideoTrackWithRotation(kVideoRotation_270));
// Remove the CVO extension from the offered SDP.
callee()->SetReceivedSdpMunger([](cricket::SessionDescription* desc) {
@@ -710,8 +714,8 @@ TEST_P(PeerConnectionIntegrationTest, RotatedVideoWithoutCVOExtension) {
EXPECT_EQ(3.0 / 4, callee()->local_rendered_aspect_ratio());
EXPECT_EQ(3.0 / 4, callee()->rendered_aspect_ratio());
// Expect that each endpoint is unaware of the rotation of the other endpoint.
- EXPECT_EQ(webrtc::kVideoRotation_0, caller()->rendered_rotation());
- EXPECT_EQ(webrtc::kVideoRotation_0, callee()->rendered_rotation());
+ EXPECT_EQ(kVideoRotation_0, caller()->rendered_rotation());
+ EXPECT_EQ(kVideoRotation_0, callee()->rendered_rotation());
}
// Test that if the answerer rejects the audio m= section, no audio is sent or
@@ -899,9 +903,9 @@ TEST_F(PeerConnectionIntegrationTestPlanB, EnableAudioAfterRejecting) {
ConnectFakeSignaling();
// Add audio track, do normal offer/answer.
- rtc::scoped_refptr<webrtc::AudioTrackInterface> track =
+ rtc::scoped_refptr<AudioTrackInterface> track =
caller()->CreateLocalAudioTrack();
- rtc::scoped_refptr<webrtc::RtpSenderInterface> sender =
+ rtc::scoped_refptr<RtpSenderInterface> sender =
caller()->pc()->AddTrack(track, {"stream"}).MoveValue();
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
@@ -974,7 +978,7 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan,
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
// Add one-directional video, from caller to callee.
- rtc::scoped_refptr<webrtc::VideoTrackInterface> track =
+ rtc::scoped_refptr<VideoTrackInterface> track =
caller()->CreateLocalVideoTrack();
RtpTransceiverInit video_transceiver_init;
@@ -988,7 +992,7 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan,
// Add receive direction.
video_sender->SetDirectionWithError(RtpTransceiverDirection::kSendRecv);
- rtc::scoped_refptr<webrtc::VideoTrackInterface> callee_track =
+ rtc::scoped_refptr<VideoTrackInterface> callee_track =
callee()->CreateLocalVideoTrack();
callee()->AddTrack(callee_track);
@@ -1086,11 +1090,7 @@ void ModifyPayloadTypesAndRemoveMidExtension(
}),
extensions.end());
media->set_rtp_header_extensions(extensions);
- cricket::VideoContentDescription* video = media->as_video();
- ASSERT_TRUE(video != nullptr);
- std::vector<cricket::VideoCodec> codecs = {
- cricket::CreateVideoCodec(pt++, "VP8")};
- video->set_codecs(codecs);
+ media->set_codecs({cricket::CreateVideoCodec(pt++, "VP8")});
}
}
@@ -1348,11 +1348,11 @@ TEST_P(PeerConnectionIntegrationTest, NewGetStatsManyAudioAndManyVideoStreams) {
audio_sender_1->track()->id(), video_sender_1->track()->id(),
audio_sender_2->track()->id(), video_sender_2->track()->id()};
- rtc::scoped_refptr<const webrtc::RTCStatsReport> caller_report =
+ rtc::scoped_refptr<const RTCStatsReport> caller_report =
caller()->NewGetStats();
ASSERT_TRUE(caller_report);
auto outbound_stream_stats =
- caller_report->GetStatsOfType<webrtc::RTCOutboundRtpStreamStats>();
+ caller_report->GetStatsOfType<RTCOutboundRtpStreamStats>();
ASSERT_EQ(outbound_stream_stats.size(), 4u);
std::vector<std::string> outbound_track_ids;
for (const auto& stat : outbound_stream_stats) {
@@ -1373,11 +1373,11 @@ TEST_P(PeerConnectionIntegrationTest, NewGetStatsManyAudioAndManyVideoStreams) {
}
EXPECT_THAT(outbound_track_ids, UnorderedElementsAreArray(track_ids));
- rtc::scoped_refptr<const webrtc::RTCStatsReport> callee_report =
+ rtc::scoped_refptr<const RTCStatsReport> callee_report =
callee()->NewGetStats();
ASSERT_TRUE(callee_report);
auto inbound_stream_stats =
- callee_report->GetStatsOfType<webrtc::RTCInboundRtpStreamStats>();
+ callee_report->GetStatsOfType<RTCInboundRtpStreamStats>();
ASSERT_EQ(4u, inbound_stream_stats.size());
std::vector<std::string> inbound_track_ids;
for (const auto& stat : inbound_stream_stats) {
@@ -1412,11 +1412,10 @@ TEST_P(PeerConnectionIntegrationTest,
// We received a frame, so we should have nonzero "bytes received" stats for
// the unsignaled stream, if stats are working for it.
- rtc::scoped_refptr<const webrtc::RTCStatsReport> report =
- callee()->NewGetStats();
+ rtc::scoped_refptr<const RTCStatsReport> report = callee()->NewGetStats();
ASSERT_NE(nullptr, report);
auto inbound_stream_stats =
- report->GetStatsOfType<webrtc::RTCInboundRtpStreamStats>();
+ report->GetStatsOfType<RTCInboundRtpStreamStats>();
ASSERT_EQ(1U, inbound_stream_stats.size());
ASSERT_TRUE(inbound_stream_stats[0]->bytes_received.is_defined());
ASSERT_GT(*inbound_stream_stats[0]->bytes_received, 0U);
@@ -1459,12 +1458,10 @@ TEST_P(PeerConnectionIntegrationTest,
media_expectations.CalleeExpectsSomeVideo(1);
ASSERT_TRUE(ExpectNewFrames(media_expectations));
- rtc::scoped_refptr<const webrtc::RTCStatsReport> report =
- callee()->NewGetStats();
+ rtc::scoped_refptr<const RTCStatsReport> report = callee()->NewGetStats();
ASSERT_NE(nullptr, report);
- auto inbound_rtps =
- report->GetStatsOfType<webrtc::RTCInboundRtpStreamStats>();
+ auto inbound_rtps = report->GetStatsOfType<RTCInboundRtpStreamStats>();
auto index = FindFirstMediaStatsIndexByKind("audio", inbound_rtps);
ASSERT_GE(index, 0);
EXPECT_TRUE(inbound_rtps[index]->audio_level.is_defined());
@@ -1655,18 +1652,18 @@ TEST_P(PeerConnectionIntegrationTest, IceStatesReachCompletion) {
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceGatheringComplete,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete,
caller()->ice_gathering_state(), kMaxWaitForFramesMs);
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceGatheringComplete,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceGatheringComplete,
callee()->ice_gathering_state(), kMaxWaitForFramesMs);
// After the best candidate pair is selected and all candidates are signaled,
// the ICE connection state should reach "complete".
// TODO(deadbeef): Currently, the ICE "controlled" agent (the
// answerer/"callee" by default) only reaches "connected". When this is
// fixed, this test should be updated.
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionCompleted,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
caller()->ice_connection_state(), kDefaultTimeout);
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionConnected,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
callee()->ice_connection_state(), kDefaultTimeout);
}
@@ -1679,9 +1676,9 @@ constexpr int kOnlyLocalPorts = cricket::PORTALLOCATOR_DISABLE_STUN |
TEST_P(PeerConnectionIntegrationTest,
IceStatesReachCompletionWithRemoteHostname) {
auto caller_resolver_factory =
- std::make_unique<NiceMock<webrtc::MockAsyncDnsResolverFactory>>();
+ std::make_unique<NiceMock<MockAsyncDnsResolverFactory>>();
auto callee_resolver_factory =
- std::make_unique<NiceMock<webrtc::MockAsyncDnsResolverFactory>>();
+ std::make_unique<NiceMock<MockAsyncDnsResolverFactory>>();
auto callee_async_resolver =
std::make_unique<NiceMock<MockAsyncDnsResolver>>();
auto caller_async_resolver =
@@ -1695,12 +1692,12 @@ TEST_P(PeerConnectionIntegrationTest,
// P2PTransportChannel.
EXPECT_CALL(*caller_resolver_factory, Create())
.WillOnce(Return(ByMove(std::move(caller_async_resolver))));
- webrtc::PeerConnectionDependencies caller_deps(nullptr);
+ PeerConnectionDependencies caller_deps(nullptr);
caller_deps.async_dns_resolver_factory = std::move(caller_resolver_factory);
EXPECT_CALL(*callee_resolver_factory, Create())
.WillOnce(Return(ByMove(std::move(callee_async_resolver))));
- webrtc::PeerConnectionDependencies callee_deps(nullptr);
+ PeerConnectionDependencies callee_deps(nullptr);
callee_deps.async_dns_resolver_factory = std::move(callee_resolver_factory);
PeerConnectionInterface::RTCConfiguration config;
@@ -1719,9 +1716,9 @@ TEST_P(PeerConnectionIntegrationTest,
// Enable hostname candidates with mDNS names.
caller()->SetMdnsResponder(
- std::make_unique<webrtc::FakeMdnsResponder>(network_thread()));
+ std::make_unique<FakeMdnsResponder>(network_thread()));
callee()->SetMdnsResponder(
- std::make_unique<webrtc::FakeMdnsResponder>(network_thread()));
+ std::make_unique<FakeMdnsResponder>(network_thread()));
SetPortAllocatorFlags(kOnlyLocalPorts, kOnlyLocalPorts);
@@ -1730,18 +1727,18 @@ TEST_P(PeerConnectionIntegrationTest,
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionCompleted,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
caller()->ice_connection_state(), kDefaultTimeout);
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionConnected,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
callee()->ice_connection_state(), kDefaultTimeout);
// Part of reporting the stats will occur on the network thread, so flush it
// before checking NumEvents.
SendTask(network_thread(), [] {});
- EXPECT_METRIC_EQ(1, webrtc::metrics::NumEvents(
- "WebRTC.PeerConnection.CandidatePairType_UDP",
- webrtc::kIceCandidatePairHostNameHostName));
+ EXPECT_METRIC_EQ(
+ 1, metrics::NumEvents("WebRTC.PeerConnection.CandidatePairType_UDP",
+ kIceCandidatePairHostNameHostName));
DestroyPeerConnections();
}
@@ -1758,8 +1755,8 @@ class PeerConnectionIntegrationIceStatesTest
}
void StartStunServer(const SocketAddress& server_address) {
- stun_server_.reset(
- cricket::TestStunServer::Create(firewall(), server_address));
+ stun_server_ = cricket::TestStunServer::Create(firewall(), server_address,
+ *network_thread());
}
bool TestIPv6() {
@@ -1805,7 +1802,7 @@ class PeerConnectionIntegrationIceStatesTest
private:
uint32_t port_allocator_flags_;
- std::unique_ptr<cricket::TestStunServer> stun_server_;
+ cricket::TestStunServer::StunServerPtr stun_server_;
};
// Ensure FakeClockForTest is constructed first (see class for rationale).
@@ -1862,9 +1859,9 @@ TEST_P(PeerConnectionIntegrationIceStatesTest, MAYBE_VerifyBestConnection) {
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionCompleted,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
caller()->ice_connection_state(), kDefaultTimeout);
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionConnected,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
callee()->ice_connection_state(), kDefaultTimeout);
// Part of reporting the stats will occur on the network thread, so flush it
@@ -1872,10 +1869,10 @@ TEST_P(PeerConnectionIntegrationIceStatesTest, MAYBE_VerifyBestConnection) {
SendTask(network_thread(), [] {});
// TODO(bugs.webrtc.org/9456): Fix it.
- const int num_best_ipv4 = webrtc::metrics::NumEvents(
- "WebRTC.PeerConnection.IPMetrics", webrtc::kBestConnections_IPv4);
- const int num_best_ipv6 = webrtc::metrics::NumEvents(
- "WebRTC.PeerConnection.IPMetrics", webrtc::kBestConnections_IPv6);
+ const int num_best_ipv4 = metrics::NumEvents(
+ "WebRTC.PeerConnection.IPMetrics", kBestConnections_IPv4);
+ const int num_best_ipv6 = metrics::NumEvents(
+ "WebRTC.PeerConnection.IPMetrics", kBestConnections_IPv6);
if (TestIPv6()) {
// When IPv6 is enabled, we should prefer an IPv6 connection over an IPv4
// connection.
@@ -1886,12 +1883,12 @@ TEST_P(PeerConnectionIntegrationIceStatesTest, MAYBE_VerifyBestConnection) {
EXPECT_METRIC_EQ(0, num_best_ipv6);
}
- EXPECT_METRIC_EQ(0, webrtc::metrics::NumEvents(
- "WebRTC.PeerConnection.CandidatePairType_UDP",
- webrtc::kIceCandidatePairHostHost));
- EXPECT_METRIC_EQ(1, webrtc::metrics::NumEvents(
- "WebRTC.PeerConnection.CandidatePairType_UDP",
- webrtc::kIceCandidatePairHostPublicHostPublic));
+ EXPECT_METRIC_EQ(
+ 0, metrics::NumEvents("WebRTC.PeerConnection.CandidatePairType_UDP",
+ kIceCandidatePairHostHost));
+ EXPECT_METRIC_EQ(
+ 1, metrics::NumEvents("WebRTC.PeerConnection.CandidatePairType_UDP",
+ kIceCandidatePairHostPublicHostPublic));
}
constexpr uint32_t kFlagsIPv4NoStun = cricket::PORTALLOCATOR_DISABLE_TCP |
@@ -1931,17 +1928,17 @@ TEST_P(PeerConnectionIntegrationTest, MediaContinuesFlowingAfterIceRestart) {
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionCompleted,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
caller()->ice_connection_state(), kMaxWaitForFramesMs);
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionConnected,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
callee()->ice_connection_state(), kMaxWaitForFramesMs);
// To verify that the ICE restart actually occurs, get
// ufrag/password/candidates before and after restart.
// Create an SDP string of the first audio candidate for both clients.
- const webrtc::IceCandidateCollection* audio_candidates_caller =
+ const IceCandidateCollection* audio_candidates_caller =
caller()->pc()->local_description()->candidates(0);
- const webrtc::IceCandidateCollection* audio_candidates_callee =
+ const IceCandidateCollection* audio_candidates_callee =
callee()->pc()->local_description()->candidates(0);
ASSERT_GT(audio_candidates_caller->count(), 0u);
ASSERT_GT(audio_candidates_callee->count(), 0u);
@@ -1964,9 +1961,9 @@ TEST_P(PeerConnectionIntegrationTest, MediaContinuesFlowingAfterIceRestart) {
caller()->SetOfferAnswerOptions(IceRestartOfferAnswerOptions());
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionCompleted,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
caller()->ice_connection_state(), kMaxWaitForFramesMs);
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionConnected,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
callee()->ice_connection_state(), kMaxWaitForFramesMs);
// Grab the ufrags/candidates again.
@@ -2141,9 +2138,9 @@ TEST_F(PeerConnectionIntegrationTestPlanB,
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kMaxWaitForActivationMs);
// Wait for ICE to complete, without any tracks being set.
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionCompleted,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
caller()->ice_connection_state(), kMaxWaitForFramesMs);
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionConnected,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
callee()->ice_connection_state(), kMaxWaitForFramesMs);
// Now set the tracks, and expect frames to immediately start flowing.
EXPECT_TRUE(
@@ -2182,9 +2179,9 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan,
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kMaxWaitForActivationMs);
// Wait for ICE to complete, without any tracks being set.
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionCompleted,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
caller()->ice_connection_state(), kMaxWaitForFramesMs);
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionConnected,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
callee()->ice_connection_state(), kMaxWaitForFramesMs);
// Now set the tracks, and expect frames to immediately start flowing.
auto callee_audio_sender = callee()->pc()->GetSenders()[0];
@@ -2279,21 +2276,21 @@ TEST_P(PeerConnectionIntegrationTestWithFakeClock,
});
PeerConnectionInterface::RTCConfiguration client_1_config;
- webrtc::PeerConnectionInterface::IceServer ice_server_1;
+ PeerConnectionInterface::IceServer ice_server_1;
ice_server_1.urls.push_back("turn:88.88.88.0:3478");
ice_server_1.username = "test";
ice_server_1.password = "test";
client_1_config.servers.push_back(ice_server_1);
- client_1_config.type = webrtc::PeerConnectionInterface::kRelay;
+ client_1_config.type = PeerConnectionInterface::kRelay;
client_1_config.presume_writable_when_fully_relayed = true;
PeerConnectionInterface::RTCConfiguration client_2_config;
- webrtc::PeerConnectionInterface::IceServer ice_server_2;
+ PeerConnectionInterface::IceServer ice_server_2;
ice_server_2.urls.push_back("turn:99.99.99.0:3478");
ice_server_2.username = "test";
ice_server_2.password = "test";
client_2_config.servers.push_back(ice_server_2);
- client_2_config.type = webrtc::PeerConnectionInterface::kRelay;
+ client_2_config.type = PeerConnectionInterface::kRelay;
client_2_config.presume_writable_when_fully_relayed = true;
ASSERT_TRUE(
@@ -2326,22 +2323,22 @@ TEST_P(PeerConnectionIntegrationTestWithFakeClock,
caller()->AddAudioTrack();
// Call getStats, assert there are no candidates.
- rtc::scoped_refptr<const webrtc::RTCStatsReport> first_report =
+ rtc::scoped_refptr<const RTCStatsReport> first_report =
caller()->NewGetStats();
ASSERT_TRUE(first_report);
auto first_candidate_stats =
- first_report->GetStatsOfType<webrtc::RTCLocalIceCandidateStats>();
+ first_report->GetStatsOfType<RTCLocalIceCandidateStats>();
ASSERT_EQ(first_candidate_stats.size(), 0u);
// Create an offer at the caller and set it as remote description on the
// callee.
caller()->CreateAndSetAndSignalOffer();
// Call getStats again, assert there are candidates now.
- rtc::scoped_refptr<const webrtc::RTCStatsReport> second_report =
+ rtc::scoped_refptr<const RTCStatsReport> second_report =
caller()->NewGetStats();
ASSERT_TRUE(second_report);
auto second_candidate_stats =
- second_report->GetStatsOfType<webrtc::RTCLocalIceCandidateStats>();
+ second_report->GetStatsOfType<RTCLocalIceCandidateStats>();
ASSERT_NE(second_candidate_stats.size(), 0u);
// The fake clock ensures that no time has passed so the cache must have been
@@ -2362,17 +2359,17 @@ TEST_P(PeerConnectionIntegrationTestWithFakeClock,
kDefaultTimeout, FakeClock());
// Call getStats, assert there are no candidates.
- rtc::scoped_refptr<const webrtc::RTCStatsReport> first_report =
+ rtc::scoped_refptr<const RTCStatsReport> first_report =
caller()->NewGetStats();
ASSERT_TRUE(first_report);
auto first_candidate_stats =
- first_report->GetStatsOfType<webrtc::RTCRemoteIceCandidateStats>();
+ first_report->GetStatsOfType<RTCRemoteIceCandidateStats>();
ASSERT_EQ(first_candidate_stats.size(), 0u);
// Add a "fake" candidate.
absl::optional<RTCError> result;
caller()->pc()->AddIceCandidate(
- absl::WrapUnique(webrtc::CreateIceCandidate(
+ absl::WrapUnique(CreateIceCandidate(
"", 0,
"candidate:2214029314 1 udp 2122260223 127.0.0.1 49152 typ host",
nullptr)),
@@ -2381,11 +2378,11 @@ TEST_P(PeerConnectionIntegrationTestWithFakeClock,
ASSERT_TRUE(result.value().ok());
// Call getStats again, assert there is a remote candidate now.
- rtc::scoped_refptr<const webrtc::RTCStatsReport> second_report =
+ rtc::scoped_refptr<const RTCStatsReport> second_report =
caller()->NewGetStats();
ASSERT_TRUE(second_report);
auto second_candidate_stats =
- second_report->GetStatsOfType<webrtc::RTCRemoteIceCandidateStats>();
+ second_report->GetStatsOfType<RTCRemoteIceCandidateStats>();
ASSERT_EQ(second_candidate_stats.size(), 1u);
// The fake clock ensures that no time has passed so the cache must have been
@@ -2413,22 +2410,22 @@ TEST_P(PeerConnectionIntegrationTest, TurnCustomizerUsedForTurnConnections) {
turn_server_2_external_address);
PeerConnectionInterface::RTCConfiguration client_1_config;
- webrtc::PeerConnectionInterface::IceServer ice_server_1;
+ PeerConnectionInterface::IceServer ice_server_1;
ice_server_1.urls.push_back("turn:88.88.88.0:3478");
ice_server_1.username = "test";
ice_server_1.password = "test";
client_1_config.servers.push_back(ice_server_1);
- client_1_config.type = webrtc::PeerConnectionInterface::kRelay;
+ client_1_config.type = PeerConnectionInterface::kRelay;
auto* customizer1 = CreateTurnCustomizer();
client_1_config.turn_customizer = customizer1;
PeerConnectionInterface::RTCConfiguration client_2_config;
- webrtc::PeerConnectionInterface::IceServer ice_server_2;
+ PeerConnectionInterface::IceServer ice_server_2;
ice_server_2.urls.push_back("turn:99.99.99.0:3478");
ice_server_2.username = "test";
ice_server_2.password = "test";
client_2_config.servers.push_back(ice_server_2);
- client_2_config.type = webrtc::PeerConnectionInterface::kRelay;
+ client_2_config.type = PeerConnectionInterface::kRelay;
auto* customizer2 = CreateTurnCustomizer();
client_2_config.turn_customizer = customizer2;
@@ -2460,18 +2457,18 @@ TEST_P(PeerConnectionIntegrationTest, TCPUsedForTurnConnections) {
CreateTurnServer(turn_server_internal_address, turn_server_external_address,
cricket::PROTO_TCP);
- webrtc::PeerConnectionInterface::IceServer ice_server;
+ PeerConnectionInterface::IceServer ice_server;
ice_server.urls.push_back("turn:88.88.88.0:3478?transport=tcp");
ice_server.username = "test";
ice_server.password = "test";
PeerConnectionInterface::RTCConfiguration client_1_config;
client_1_config.servers.push_back(ice_server);
- client_1_config.type = webrtc::PeerConnectionInterface::kRelay;
+ client_1_config.type = PeerConnectionInterface::kRelay;
PeerConnectionInterface::RTCConfiguration client_2_config;
client_2_config.servers.push_back(ice_server);
- client_2_config.type = webrtc::PeerConnectionInterface::kRelay;
+ client_2_config.type = PeerConnectionInterface::kRelay;
ASSERT_TRUE(
CreatePeerConnectionWrappersWithConfig(client_1_config, client_2_config));
@@ -2482,7 +2479,7 @@ TEST_P(PeerConnectionIntegrationTest, TCPUsedForTurnConnections) {
callee()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionConnected,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
callee()->ice_connection_state(), kMaxWaitForFramesMs);
MediaExpectations media_expectations;
@@ -2506,20 +2503,20 @@ TEST_P(PeerConnectionIntegrationTest,
CreateTurnServer(turn_server_internal_address, turn_server_external_address,
cricket::PROTO_TLS, "88.88.88.0");
- webrtc::PeerConnectionInterface::IceServer ice_server;
+ PeerConnectionInterface::IceServer ice_server;
ice_server.urls.push_back("turns:88.88.88.0:3478?transport=tcp");
ice_server.username = "test";
ice_server.password = "test";
PeerConnectionInterface::RTCConfiguration client_1_config;
client_1_config.servers.push_back(ice_server);
- client_1_config.type = webrtc::PeerConnectionInterface::kRelay;
+ client_1_config.type = PeerConnectionInterface::kRelay;
PeerConnectionInterface::RTCConfiguration client_2_config;
client_2_config.servers.push_back(ice_server);
// Setting the type to kRelay forces the connection to go through a TURN
// server.
- client_2_config.type = webrtc::PeerConnectionInterface::kRelay;
+ client_2_config.type = PeerConnectionInterface::kRelay;
// Get a copy to the pointer so we can verify calls later.
rtc::TestCertificateVerifier* client_1_cert_verifier =
@@ -2530,10 +2527,10 @@ TEST_P(PeerConnectionIntegrationTest,
client_2_cert_verifier->verify_certificate_ = true;
// Create the dependencies with the test certificate verifier.
- webrtc::PeerConnectionDependencies client_1_deps(nullptr);
+ PeerConnectionDependencies client_1_deps(nullptr);
client_1_deps.tls_cert_verifier =
std::unique_ptr<rtc::TestCertificateVerifier>(client_1_cert_verifier);
- webrtc::PeerConnectionDependencies client_2_deps(nullptr);
+ PeerConnectionDependencies client_2_deps(nullptr);
client_2_deps.tls_cert_verifier =
std::unique_ptr<rtc::TestCertificateVerifier>(client_2_cert_verifier);
@@ -2644,7 +2641,7 @@ TEST_P(PeerConnectionIntegrationTest, GetSourcesAudio) {
ASSERT_GT(receiver->GetParameters().encodings.size(), 0u);
EXPECT_EQ(receiver->GetParameters().encodings[0].ssrc,
sources[0].source_id());
- EXPECT_EQ(webrtc::RtpSourceType::SSRC, sources[0].source_type());
+ EXPECT_EQ(RtpSourceType::SSRC, sources[0].source_type());
}
TEST_P(PeerConnectionIntegrationTest, GetSourcesVideo) {
@@ -2665,7 +2662,7 @@ TEST_P(PeerConnectionIntegrationTest, GetSourcesVideo) {
ASSERT_GT(sources.size(), 0u);
EXPECT_EQ(receiver->GetParameters().encodings[0].ssrc,
sources[0].source_id());
- EXPECT_EQ(webrtc::RtpSourceType::SSRC, sources[0].source_type());
+ EXPECT_EQ(RtpSourceType::SSRC, sources[0].source_type());
}
TEST_P(PeerConnectionIntegrationTest, UnsignaledSsrcGetSourcesAudio) {
@@ -2684,7 +2681,7 @@ TEST_P(PeerConnectionIntegrationTest, UnsignaledSsrcGetSourcesAudio) {
})(),
kDefaultTimeout);
ASSERT_GT(sources.size(), 0u);
- EXPECT_EQ(webrtc::RtpSourceType::SSRC, sources[0].source_type());
+ EXPECT_EQ(RtpSourceType::SSRC, sources[0].source_type());
}
TEST_P(PeerConnectionIntegrationTest, UnsignaledSsrcGetSourcesVideo) {
@@ -2703,7 +2700,7 @@ TEST_P(PeerConnectionIntegrationTest, UnsignaledSsrcGetSourcesVideo) {
})(),
kDefaultTimeout);
ASSERT_GT(sources.size(), 0u);
- EXPECT_EQ(webrtc::RtpSourceType::SSRC, sources[0].source_type());
+ EXPECT_EQ(RtpSourceType::SSRC, sources[0].source_type());
}
// Similar to the above test, except instead of waiting until GetSources() is
@@ -2728,7 +2725,7 @@ TEST_P(PeerConnectionIntegrationTest,
std::vector<RtpSource> sources = receiver->GetSources();
// SSRC history must not be cleared since the reception of the first frame.
ASSERT_GT(sources.size(), 0u);
- EXPECT_EQ(webrtc::RtpSourceType::SSRC, sources[0].source_type());
+ EXPECT_EQ(RtpSourceType::SSRC, sources[0].source_type());
}
TEST_P(PeerConnectionIntegrationTest, UnsignaledSsrcGetParametersAudio) {
@@ -2791,9 +2788,9 @@ TEST_F(PeerConnectionIntegrationTestPlanB, RemoveAndAddTrackWithNewStreamId) {
ConnectFakeSignaling();
// Add track using stream 1, do offer/answer.
- rtc::scoped_refptr<webrtc::AudioTrackInterface> track =
+ rtc::scoped_refptr<AudioTrackInterface> track =
caller()->CreateLocalAudioTrack();
- rtc::scoped_refptr<webrtc::RtpSenderInterface> sender =
+ rtc::scoped_refptr<RtpSenderInterface> sender =
caller()->AddTrack(track, {"stream_1"});
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
@@ -2819,18 +2816,70 @@ TEST_P(PeerConnectionIntegrationTest, RtcEventLogOutputWriteCalled) {
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
- auto output = std::make_unique<testing::NiceMock<MockRtcEventLogOutput>>();
- ON_CALL(*output, IsActive()).WillByDefault(::testing::Return(true));
- ON_CALL(*output, Write(::testing::A<absl::string_view>()))
- .WillByDefault(::testing::Return(true));
- EXPECT_CALL(*output, Write(::testing::A<absl::string_view>()))
- .Times(::testing::AtLeast(1));
- EXPECT_TRUE(caller()->pc()->StartRtcEventLog(
- std::move(output), webrtc::RtcEventLog::kImmediateOutput));
+ auto output = std::make_unique<NiceMock<MockRtcEventLogOutput>>();
+ ON_CALL(*output, IsActive).WillByDefault(Return(true));
+ ON_CALL(*output, Write).WillByDefault(Return(true));
+ EXPECT_CALL(*output, Write).Times(AtLeast(1));
+ EXPECT_TRUE(caller()->pc()->StartRtcEventLog(std::move(output),
+ RtcEventLog::kImmediateOutput));
+
+ caller()->AddAudioVideoTracks();
+ caller()->CreateAndSetAndSignalOffer();
+ ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+}
+
+TEST_P(PeerConnectionIntegrationTest, RtcEventLogOutputWriteCalledOnStop) {
+ // This test uses check point to ensure log is written before peer connection
+ // is destroyed.
+ // https://google.github.io/googletest/gmock_cook_book.html#UsingCheckPoints
+ MockFunction<void()> test_is_complete;
+ ASSERT_TRUE(CreatePeerConnectionWrappers());
+ ConnectFakeSignaling();
+
+ auto output = std::make_unique<NiceMock<MockRtcEventLogOutput>>();
+ ON_CALL(*output, IsActive).WillByDefault(Return(true));
+ ON_CALL(*output, Write).WillByDefault(Return(true));
+ InSequence s;
+ EXPECT_CALL(*output, Write).Times(AtLeast(1));
+ EXPECT_CALL(test_is_complete, Call);
+
+ // Use large output period to prevent this test pass for the wrong reason.
+ EXPECT_TRUE(caller()->pc()->StartRtcEventLog(std::move(output),
+ /*output_period_ms=*/100'000));
caller()->AddAudioVideoTracks();
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+
+ caller()->pc()->StopRtcEventLog();
+ test_is_complete.Call();
+}
+
+TEST_P(PeerConnectionIntegrationTest, RtcEventLogOutputWriteCalledOnClose) {
+ // This test uses check point to ensure log is written before peer connection
+ // is destroyed.
+ // https://google.github.io/googletest/gmock_cook_book.html#UsingCheckPoints
+ MockFunction<void()> test_is_complete;
+ ASSERT_TRUE(CreatePeerConnectionWrappers());
+ ConnectFakeSignaling();
+
+ auto output = std::make_unique<NiceMock<MockRtcEventLogOutput>>();
+ ON_CALL(*output, IsActive).WillByDefault(Return(true));
+ ON_CALL(*output, Write).WillByDefault(Return(true));
+ InSequence s;
+ EXPECT_CALL(*output, Write).Times(AtLeast(1));
+ EXPECT_CALL(test_is_complete, Call);
+
+ // Use large output period to prevent this test pass for the wrong reason.
+ EXPECT_TRUE(caller()->pc()->StartRtcEventLog(std::move(output),
+ /*output_period_ms=*/100'000));
+
+ caller()->AddAudioVideoTracks();
+ caller()->CreateAndSetAndSignalOffer();
+ ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
+
+ caller()->pc()->Close();
+ test_is_complete.Call();
}
// Test that if candidates are only signaled by applying full session
@@ -2900,8 +2949,7 @@ TEST_P(PeerConnectionIntegrationTest, DisableAndEnableAudioPlayout) {
double GetAudioEnergyStat(PeerConnectionIntegrationWrapper* pc) {
auto report = pc->NewGetStats();
- auto inbound_rtps =
- report->GetStatsOfType<webrtc::RTCInboundRtpStreamStats>();
+ auto inbound_rtps = report->GetStatsOfType<RTCInboundRtpStreamStats>();
RTC_CHECK(!inbound_rtps.empty());
auto* inbound_rtp = inbound_rtps[0];
if (!inbound_rtp->total_audio_energy.is_defined()) {
@@ -2974,20 +3022,20 @@ TEST_P(PeerConnectionIntegrationTest,
ASSERT_TRUE_WAIT(DtlsConnected(), kDefaultTimeout);
ASSERT_NE(nullptr, caller()->event_log_factory());
ASSERT_NE(nullptr, callee()->event_log_factory());
- webrtc::FakeRtcEventLog* caller_event_log =
+ FakeRtcEventLog* caller_event_log =
caller()->event_log_factory()->last_log_created();
- webrtc::FakeRtcEventLog* callee_event_log =
+ FakeRtcEventLog* callee_event_log =
callee()->event_log_factory()->last_log_created();
ASSERT_NE(nullptr, caller_event_log);
ASSERT_NE(nullptr, callee_event_log);
- int caller_ice_config_count = caller_event_log->GetEventCount(
- webrtc::RtcEvent::Type::IceCandidatePairConfig);
- int caller_ice_event_count = caller_event_log->GetEventCount(
- webrtc::RtcEvent::Type::IceCandidatePairEvent);
- int callee_ice_config_count = callee_event_log->GetEventCount(
- webrtc::RtcEvent::Type::IceCandidatePairConfig);
- int callee_ice_event_count = callee_event_log->GetEventCount(
- webrtc::RtcEvent::Type::IceCandidatePairEvent);
+ int caller_ice_config_count =
+ caller_event_log->GetEventCount(RtcEvent::Type::IceCandidatePairConfig);
+ int caller_ice_event_count =
+ caller_event_log->GetEventCount(RtcEvent::Type::IceCandidatePairEvent);
+ int callee_ice_config_count =
+ callee_event_log->GetEventCount(RtcEvent::Type::IceCandidatePairConfig);
+ int callee_ice_event_count =
+ callee_event_log->GetEventCount(RtcEvent::Type::IceCandidatePairEvent);
EXPECT_LT(0, caller_ice_config_count);
EXPECT_LT(0, caller_ice_event_count);
EXPECT_LT(0, callee_ice_config_count);
@@ -3001,20 +3049,20 @@ TEST_P(PeerConnectionIntegrationTest, RegatherAfterChangingIceTransportType) {
CreateTurnServer(turn_server_internal_address, turn_server_external_address);
- webrtc::PeerConnectionInterface::IceServer ice_server;
+ PeerConnectionInterface::IceServer ice_server;
ice_server.urls.push_back("turn:88.88.88.0:3478");
ice_server.username = "test";
ice_server.password = "test";
PeerConnectionInterface::RTCConfiguration caller_config;
caller_config.servers.push_back(ice_server);
- caller_config.type = webrtc::PeerConnectionInterface::kRelay;
+ caller_config.type = PeerConnectionInterface::kRelay;
caller_config.continual_gathering_policy = PeerConnection::GATHER_CONTINUALLY;
caller_config.surface_ice_candidates_on_ice_transport_type_changed = true;
PeerConnectionInterface::RTCConfiguration callee_config;
callee_config.servers.push_back(ice_server);
- callee_config.type = webrtc::PeerConnectionInterface::kRelay;
+ callee_config.type = PeerConnectionInterface::kRelay;
callee_config.continual_gathering_policy = PeerConnection::GATHER_CONTINUALLY;
callee_config.surface_ice_candidates_on_ice_transport_type_changed = true;
@@ -3031,9 +3079,9 @@ TEST_P(PeerConnectionIntegrationTest, RegatherAfterChangingIceTransportType) {
// kIceGatheringComplete (see
// P2PTransportChannel::OnCandidatesAllocationDone), and consequently not
// kIceConnectionComplete.
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionConnected,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
caller()->ice_connection_state(), kDefaultTimeout);
- EXPECT_EQ_WAIT(webrtc::PeerConnectionInterface::kIceConnectionConnected,
+ EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
callee()->ice_connection_state(), kDefaultTimeout);
// Note that we cannot use the metric
// `WebRTC.PeerConnection.CandidatePairType_UDP` in this test since this
@@ -3046,7 +3094,7 @@ TEST_P(PeerConnectionIntegrationTest, RegatherAfterChangingIceTransportType) {
// Loosen the caller's candidate filter.
caller_config = caller()->pc()->GetConfiguration();
- caller_config.type = webrtc::PeerConnectionInterface::kAll;
+ caller_config.type = PeerConnectionInterface::kAll;
caller()->pc()->SetConfiguration(caller_config);
// We should have gathered a new host candidate.
EXPECT_EQ_WAIT(cricket::LOCAL_PORT_TYPE,
@@ -3054,7 +3102,7 @@ TEST_P(PeerConnectionIntegrationTest, RegatherAfterChangingIceTransportType) {
// Loosen the callee's candidate filter.
callee_config = callee()->pc()->GetConfiguration();
- callee_config.type = webrtc::PeerConnectionInterface::kAll;
+ callee_config.type = PeerConnectionInterface::kAll;
callee()->pc()->SetConfiguration(callee_config);
EXPECT_EQ_WAIT(cricket::LOCAL_PORT_TYPE,
callee()->last_candidate_gathered().type(), kDefaultTimeout);
@@ -3084,19 +3132,19 @@ TEST_P(PeerConnectionIntegrationTest, OnIceCandidateError) {
CreateTurnServer(turn_server_internal_address, turn_server_external_address);
- webrtc::PeerConnectionInterface::IceServer ice_server;
+ PeerConnectionInterface::IceServer ice_server;
ice_server.urls.push_back("turn:88.88.88.0:3478");
ice_server.username = "test";
ice_server.password = "123";
PeerConnectionInterface::RTCConfiguration caller_config;
caller_config.servers.push_back(ice_server);
- caller_config.type = webrtc::PeerConnectionInterface::kRelay;
+ caller_config.type = PeerConnectionInterface::kRelay;
caller_config.continual_gathering_policy = PeerConnection::GATHER_CONTINUALLY;
PeerConnectionInterface::RTCConfiguration callee_config;
callee_config.servers.push_back(ice_server);
- callee_config.type = webrtc::PeerConnectionInterface::kRelay;
+ callee_config.type = PeerConnectionInterface::kRelay;
callee_config.continual_gathering_policy = PeerConnection::GATHER_CONTINUALLY;
ASSERT_TRUE(
@@ -3115,19 +3163,19 @@ TEST_P(PeerConnectionIntegrationTest, OnIceCandidateError) {
}
TEST_P(PeerConnectionIntegrationTest, OnIceCandidateErrorWithEmptyAddress) {
- webrtc::PeerConnectionInterface::IceServer ice_server;
+ PeerConnectionInterface::IceServer ice_server;
ice_server.urls.push_back("turn:127.0.0.1:3478?transport=tcp");
ice_server.username = "test";
ice_server.password = "test";
PeerConnectionInterface::RTCConfiguration caller_config;
caller_config.servers.push_back(ice_server);
- caller_config.type = webrtc::PeerConnectionInterface::kRelay;
+ caller_config.type = PeerConnectionInterface::kRelay;
caller_config.continual_gathering_policy = PeerConnection::GATHER_CONTINUALLY;
PeerConnectionInterface::RTCConfiguration callee_config;
callee_config.servers.push_back(ice_server);
- callee_config.type = webrtc::PeerConnectionInterface::kRelay;
+ callee_config.type = PeerConnectionInterface::kRelay;
callee_config.continual_gathering_policy = PeerConnection::GATHER_CONTINUALLY;
ASSERT_TRUE(
@@ -3697,7 +3745,7 @@ TEST_P(PeerConnectionIntegrationTest, EndToEndRtpSenderVideoEncoderSelector) {
CreateOneDirectionalPeerConnectionWrappers(/*caller_to_callee=*/true));
ConnectFakeSignaling();
// Add one-directional video, from caller to callee.
- rtc::scoped_refptr<webrtc::VideoTrackInterface> caller_track =
+ rtc::scoped_refptr<VideoTrackInterface> caller_track =
caller()->CreateLocalVideoTrack();
auto sender = caller()->AddTrack(caller_track);
PeerConnectionInterface::RTCOfferAnswerOptions options;
@@ -3722,7 +3770,7 @@ TEST_P(PeerConnectionIntegrationTest, EndToEndRtpSenderVideoEncoderSelector) {
}
int NacksReceivedCount(PeerConnectionIntegrationWrapper& pc) {
- rtc::scoped_refptr<const webrtc::RTCStatsReport> report = pc.NewGetStats();
+ rtc::scoped_refptr<const RTCStatsReport> report = pc.NewGetStats();
auto sender_stats = report->GetStatsOfType<RTCOutboundRtpStreamStats>();
if (sender_stats.size() != 1) {
ADD_FAILURE();
@@ -3735,7 +3783,7 @@ int NacksReceivedCount(PeerConnectionIntegrationWrapper& pc) {
}
int NacksSentCount(PeerConnectionIntegrationWrapper& pc) {
- rtc::scoped_refptr<const webrtc::RTCStatsReport> report = pc.NewGetStats();
+ rtc::scoped_refptr<const RTCStatsReport> report = pc.NewGetStats();
auto receiver_stats = report->GetStatsOfType<RTCInboundRtpStreamStats>();
if (receiver_stats.size() != 1) {
ADD_FAILURE();
@@ -3761,11 +3809,10 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan,
// codecs.
caller()->SetGeneratedSdpMunger([](cricket::SessionDescription* desc) {
for (ContentInfo& content : desc->contents()) {
- cricket::AudioContentDescription* media =
- content.media_description()->as_audio();
- std::vector<cricket::AudioCodec> codecs = media->codecs();
- std::vector<cricket::AudioCodec> codecs_out;
- for (cricket::AudioCodec codec : codecs) {
+ cricket::MediaContentDescription* media = content.media_description();
+ std::vector<cricket::Codec> codecs = media->codecs();
+ std::vector<cricket::Codec> codecs_out;
+ for (cricket::Codec codec : codecs) {
if (codec.name == "opus") {
codec.AddFeedbackParam(cricket::FeedbackParam(
cricket::kRtcpFbParamNack, cricket::kParamValueEmpty));
@@ -3812,11 +3859,10 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, VideoPacketLossCausesNack) {
// codecs.
caller()->SetGeneratedSdpMunger([](cricket::SessionDescription* desc) {
for (ContentInfo& content : desc->contents()) {
- cricket::VideoContentDescription* media =
- content.media_description()->as_video();
- std::vector<cricket::VideoCodec> codecs = media->codecs();
- std::vector<cricket::VideoCodec> codecs_out;
- for (cricket::VideoCodec codec : codecs) {
+ cricket::MediaContentDescription* media = content.media_description();
+ std::vector<cricket::Codec> codecs = media->codecs();
+ std::vector<cricket::Codec> codecs_out;
+ for (cricket::Codec codec : codecs) {
if (codec.name == "VP8") {
ASSERT_TRUE(codec.HasFeedbackParam(cricket::FeedbackParam(
cricket::kRtcpFbParamNack, cricket::kParamValueEmpty)));
diff --git a/third_party/libwebrtc/pc/peer_connection_interface_unittest.cc b/third_party/libwebrtc/pc/peer_connection_interface_unittest.cc
index 1f5ab2f449..5ee9881b84 100644
--- a/third_party/libwebrtc/pc/peer_connection_interface_unittest.cc
+++ b/third_party/libwebrtc/pc/peer_connection_interface_unittest.cc
@@ -22,9 +22,9 @@
#include "api/audio/audio_mixer.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
-#include "api/call/call_factory_interface.h"
#include "api/create_peerconnection_factory.h"
#include "api/data_channel_interface.h"
+#include "api/enable_media_with_defaults.h"
#include "api/jsep.h"
#include "api/media_stream_interface.h"
#include "api/media_types.h"
@@ -53,7 +53,6 @@
#include "media/base/media_engine.h"
#include "media/base/stream_params.h"
#include "media/engine/webrtc_media_engine.h"
-#include "media/engine/webrtc_media_engine_defaults.h"
#include "media/sctp/sctp_transport_internal.h"
#include "modules/audio_device/include/audio_device.h"
#include "modules/audio_processing/include/audio_processing.h"
@@ -475,8 +474,7 @@ bool GetFirstSsrc(const cricket::ContentInfo* content_info, int* ssrc) {
// Get the ufrags out of an SDP blob. Useful for testing ICE restart
// behavior.
-std::vector<std::string> GetUfrags(
- const webrtc::SessionDescriptionInterface* desc) {
+std::vector<std::string> GetUfrags(const SessionDescriptionInterface* desc) {
std::vector<std::string> ufrags;
for (const cricket::TransportInfo& info :
desc->description()->transport_infos()) {
@@ -545,21 +543,19 @@ rtc::scoped_refptr<StreamCollection> CreateStreamCollection(
StreamCollection::Create());
for (int i = 0; i < number_of_streams; ++i) {
- rtc::scoped_refptr<webrtc::MediaStreamInterface> stream(
- webrtc::MediaStream::Create(kStreams[i]));
+ rtc::scoped_refptr<MediaStreamInterface> stream(
+ MediaStream::Create(kStreams[i]));
for (int j = 0; j < tracks_per_stream; ++j) {
// Add a local audio track.
- rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track(
- webrtc::AudioTrack::Create(kAudioTracks[i * tracks_per_stream + j],
- nullptr));
+ rtc::scoped_refptr<AudioTrackInterface> audio_track(
+ AudioTrack::Create(kAudioTracks[i * tracks_per_stream + j], nullptr));
stream->AddTrack(audio_track);
// Add a local video track.
- rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track(
- webrtc::VideoTrack::Create(kVideoTracks[i * tracks_per_stream + j],
- webrtc::FakeVideoTrackSource::Create(),
- rtc::Thread::Current()));
+ rtc::scoped_refptr<VideoTrackInterface> video_track(VideoTrack::Create(
+ kVideoTracks[i * tracks_per_stream + j],
+ FakeVideoTrackSource::Create(), rtc::Thread::Current()));
stream->AddTrack(video_track);
}
@@ -579,10 +575,10 @@ bool CompareStreamCollections(StreamCollectionInterface* s1,
if (s1->at(i)->id() != s2->at(i)->id()) {
return false;
}
- webrtc::AudioTrackVector audio_tracks1 = s1->at(i)->GetAudioTracks();
- webrtc::AudioTrackVector audio_tracks2 = s2->at(i)->GetAudioTracks();
- webrtc::VideoTrackVector video_tracks1 = s1->at(i)->GetVideoTracks();
- webrtc::VideoTrackVector video_tracks2 = s2->at(i)->GetVideoTracks();
+ AudioTrackVector audio_tracks1 = s1->at(i)->GetAudioTracks();
+ AudioTrackVector audio_tracks2 = s2->at(i)->GetAudioTracks();
+ VideoTrackVector video_tracks1 = s1->at(i)->GetVideoTracks();
+ VideoTrackVector video_tracks2 = s2->at(i)->GetVideoTracks();
if (audio_tracks1.size() != audio_tracks2.size()) {
return false;
@@ -631,7 +627,7 @@ class MockTrackObserver : public ObserverInterface {
// constraints are propagated into the PeerConnection's MediaConfig. These
// settings are intended for MediaChannel constructors, but that is not
// exercised by these unittest.
-class PeerConnectionFactoryForTest : public webrtc::PeerConnectionFactory {
+class PeerConnectionFactoryForTest : public PeerConnectionFactory {
public:
static rtc::scoped_refptr<PeerConnectionFactoryForTest>
CreatePeerConnectionFactoryForTest() {
@@ -641,16 +637,10 @@ class PeerConnectionFactoryForTest : public webrtc::PeerConnectionFactory {
dependencies.signaling_thread = rtc::Thread::Current();
dependencies.task_queue_factory = CreateDefaultTaskQueueFactory();
dependencies.trials = std::make_unique<FieldTrialBasedConfig>();
- cricket::MediaEngineDependencies media_deps;
- media_deps.task_queue_factory = dependencies.task_queue_factory.get();
// Use fake audio device module since we're only testing the interface
// level, and using a real one could make tests flaky when run in parallel.
- media_deps.adm = FakeAudioCaptureModule::Create();
- SetMediaEngineDefaults(&media_deps);
- media_deps.trials = dependencies.trials.get();
- dependencies.media_engine =
- cricket::CreateMediaEngine(std::move(media_deps));
- dependencies.call_factory = webrtc::CreateCallFactory();
+ dependencies.adm = FakeAudioCaptureModule::Create();
+ EnableMediaWithDefaults(dependencies);
dependencies.event_log_factory = std::make_unique<RtcEventLogFactory>(
dependencies.task_queue_factory.get());
@@ -672,7 +662,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test {
main_(vss_.get()),
sdp_semantics_(sdp_semantics) {
#ifdef WEBRTC_ANDROID
- webrtc::InitializeAndroidObjects();
+ InitializeAndroidObjects();
#endif
}
@@ -680,22 +670,16 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test {
// Use fake audio capture module since we're only testing the interface
// level, and using a real one could make tests flaky when run in parallel.
fake_audio_capture_module_ = FakeAudioCaptureModule::Create();
- pc_factory_ = webrtc::CreatePeerConnectionFactory(
+ pc_factory_ = CreatePeerConnectionFactory(
rtc::Thread::Current(), rtc::Thread::Current(), rtc::Thread::Current(),
- rtc::scoped_refptr<webrtc::AudioDeviceModule>(
- fake_audio_capture_module_),
- webrtc::CreateBuiltinAudioEncoderFactory(),
- webrtc::CreateBuiltinAudioDecoderFactory(),
- std::make_unique<webrtc::VideoEncoderFactoryTemplate<
- webrtc::LibvpxVp8EncoderTemplateAdapter,
- webrtc::LibvpxVp9EncoderTemplateAdapter,
- webrtc::OpenH264EncoderTemplateAdapter,
- webrtc::LibaomAv1EncoderTemplateAdapter>>(),
- std::make_unique<webrtc::VideoDecoderFactoryTemplate<
- webrtc::LibvpxVp8DecoderTemplateAdapter,
- webrtc::LibvpxVp9DecoderTemplateAdapter,
- webrtc::OpenH264DecoderTemplateAdapter,
- webrtc::Dav1dDecoderTemplateAdapter>>(),
+ rtc::scoped_refptr<AudioDeviceModule>(fake_audio_capture_module_),
+ CreateBuiltinAudioEncoderFactory(), CreateBuiltinAudioDecoderFactory(),
+ std::make_unique<VideoEncoderFactoryTemplate<
+ LibvpxVp8EncoderTemplateAdapter, LibvpxVp9EncoderTemplateAdapter,
+ OpenH264EncoderTemplateAdapter, LibaomAv1EncoderTemplateAdapter>>(),
+ std::make_unique<VideoDecoderFactoryTemplate<
+ LibvpxVp8DecoderTemplateAdapter, LibvpxVp9DecoderTemplateAdapter,
+ OpenH264DecoderTemplateAdapter, Dav1dDecoderTemplateAdapter>>(),
nullptr /* audio_mixer */, nullptr /* audio_processing */);
ASSERT_TRUE(pc_factory_);
}
@@ -953,8 +937,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test {
// Call the standards-compliant GetStats function.
bool DoGetRTCStats() {
- auto callback =
- rtc::make_ref_counted<webrtc::MockRTCStatsCollectorCallback>();
+ auto callback = rtc::make_ref_counted<MockRTCStatsCollectorCallback>();
pc_->GetStats(callback.get());
EXPECT_TRUE_WAIT(callback->called(), kTimeout);
return callback->called();
@@ -994,14 +977,14 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test {
std::string sdp;
EXPECT_TRUE(offer->ToString(&sdp));
std::unique_ptr<SessionDescriptionInterface> remote_offer(
- webrtc::CreateSessionDescription(SdpType::kOffer, sdp));
+ CreateSessionDescription(SdpType::kOffer, sdp));
EXPECT_TRUE(DoSetRemoteDescription(std::move(remote_offer)));
EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_);
}
void CreateAndSetRemoteOffer(const std::string& sdp) {
std::unique_ptr<SessionDescriptionInterface> remote_offer(
- webrtc::CreateSessionDescription(SdpType::kOffer, sdp));
+ CreateSessionDescription(SdpType::kOffer, sdp));
EXPECT_TRUE(DoSetRemoteDescription(std::move(remote_offer)));
EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_);
}
@@ -1020,7 +1003,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test {
std::string sdp;
EXPECT_TRUE(answer->ToString(&sdp));
std::unique_ptr<SessionDescriptionInterface> new_answer(
- webrtc::CreateSessionDescription(SdpType::kAnswer, sdp));
+ CreateSessionDescription(SdpType::kAnswer, sdp));
EXPECT_TRUE(DoSetLocalDescription(std::move(new_answer)));
EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_);
}
@@ -1032,7 +1015,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test {
std::string sdp;
EXPECT_TRUE(answer->ToString(&sdp));
std::unique_ptr<SessionDescriptionInterface> pr_answer(
- webrtc::CreateSessionDescription(SdpType::kPrAnswer, sdp));
+ CreateSessionDescription(SdpType::kPrAnswer, sdp));
EXPECT_TRUE(DoSetLocalDescription(std::move(pr_answer)));
EXPECT_EQ(PeerConnectionInterface::kHaveLocalPrAnswer, observer_.state_);
}
@@ -1057,7 +1040,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test {
std::string sdp;
EXPECT_TRUE(offer->ToString(&sdp));
std::unique_ptr<SessionDescriptionInterface> new_offer(
- webrtc::CreateSessionDescription(SdpType::kOffer, sdp));
+ CreateSessionDescription(SdpType::kOffer, sdp));
EXPECT_TRUE(DoSetLocalDescription(std::move(new_offer)));
EXPECT_EQ(PeerConnectionInterface::kHaveLocalOffer, observer_.state_);
@@ -1067,7 +1050,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test {
void CreateAnswerAsRemoteDescription(const std::string& sdp) {
std::unique_ptr<SessionDescriptionInterface> answer(
- webrtc::CreateSessionDescription(SdpType::kAnswer, sdp));
+ CreateSessionDescription(SdpType::kAnswer, sdp));
ASSERT_TRUE(answer);
EXPECT_TRUE(DoSetRemoteDescription(std::move(answer)));
EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_);
@@ -1075,12 +1058,12 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test {
void CreatePrAnswerAndAnswerAsRemoteDescription(const std::string& sdp) {
std::unique_ptr<SessionDescriptionInterface> pr_answer(
- webrtc::CreateSessionDescription(SdpType::kPrAnswer, sdp));
+ CreateSessionDescription(SdpType::kPrAnswer, sdp));
ASSERT_TRUE(pr_answer);
EXPECT_TRUE(DoSetRemoteDescription(std::move(pr_answer)));
EXPECT_EQ(PeerConnectionInterface::kHaveRemotePrAnswer, observer_.state_);
std::unique_ptr<SessionDescriptionInterface> answer(
- webrtc::CreateSessionDescription(SdpType::kAnswer, sdp));
+ CreateSessionDescription(SdpType::kAnswer, sdp));
ASSERT_TRUE(answer);
EXPECT_TRUE(DoSetRemoteDescription(std::move(answer)));
EXPECT_EQ(PeerConnectionInterface::kStable, observer_.state_);
@@ -1124,8 +1107,8 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test {
std::string mediastream_id = kStreams[0];
- rtc::scoped_refptr<webrtc::MediaStreamInterface> stream(
- webrtc::MediaStream::Create(mediastream_id));
+ rtc::scoped_refptr<MediaStreamInterface> stream(
+ MediaStream::Create(mediastream_id));
reference_collection_->AddStream(stream);
if (number_of_audio_tracks > 0) {
@@ -1149,22 +1132,20 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test {
}
return std::unique_ptr<SessionDescriptionInterface>(
- webrtc::CreateSessionDescription(SdpType::kOffer, sdp_ms1));
+ CreateSessionDescription(SdpType::kOffer, sdp_ms1));
}
void AddAudioTrack(const std::string& track_id,
MediaStreamInterface* stream) {
- rtc::scoped_refptr<webrtc::AudioTrackInterface> audio_track(
- webrtc::AudioTrack::Create(track_id, nullptr));
+ rtc::scoped_refptr<AudioTrackInterface> audio_track(
+ AudioTrack::Create(track_id, nullptr));
ASSERT_TRUE(stream->AddTrack(audio_track));
}
void AddVideoTrack(const std::string& track_id,
MediaStreamInterface* stream) {
- rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track(
- webrtc::VideoTrack::Create(track_id,
- webrtc::FakeVideoTrackSource::Create(),
- rtc::Thread::Current()));
+ rtc::scoped_refptr<VideoTrackInterface> video_track(VideoTrack::Create(
+ track_id, FakeVideoTrackSource::Create(), rtc::Thread::Current()));
ASSERT_TRUE(stream->AddTrack(video_track));
}
@@ -1224,7 +1205,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test {
std::string sdp;
EXPECT_TRUE((*desc)->ToString(&sdp));
std::unique_ptr<SessionDescriptionInterface> remote_offer(
- webrtc::CreateSessionDescription(SdpType::kOffer, sdp));
+ CreateSessionDescription(SdpType::kOffer, sdp));
EXPECT_TRUE(DoSetRemoteDescription(std::move(remote_offer)));
EXPECT_EQ(PeerConnectionInterface::kHaveRemoteOffer, observer_.state_);
}
@@ -1237,7 +1218,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test {
std::string sdp;
EXPECT_TRUE((*desc)->ToString(&sdp));
std::unique_ptr<SessionDescriptionInterface> new_offer(
- webrtc::CreateSessionDescription(SdpType::kOffer, sdp));
+ CreateSessionDescription(SdpType::kOffer, sdp));
EXPECT_TRUE(DoSetLocalDescription(std::move(new_offer)));
EXPECT_EQ(PeerConnectionInterface::kHaveLocalOffer, observer_.state_);
@@ -1246,8 +1227,7 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test {
bool HasCNCodecs(const cricket::ContentInfo* content) {
RTC_DCHECK(content);
RTC_DCHECK(content->media_description());
- for (const cricket::AudioCodec& codec :
- content->media_description()->as_audio()->codecs()) {
+ for (const cricket::Codec& codec : content->media_description()->codecs()) {
if (codec.name == "CN") {
return true;
}
@@ -1273,13 +1253,13 @@ class PeerConnectionInterfaceBaseTest : public ::testing::Test {
rtc::SocketServer* socket_server() const { return vss_.get(); }
- webrtc::test::ScopedKeyValueConfig field_trials_;
+ test::ScopedKeyValueConfig field_trials_;
std::unique_ptr<rtc::VirtualSocketServer> vss_;
rtc::AutoSocketServerThread main_;
rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_;
cricket::FakePortAllocator* port_allocator_ = nullptr;
FakeRTCCertificateGenerator* fake_certificate_generator_ = nullptr;
- rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory_;
+ rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory_;
rtc::scoped_refptr<PeerConnectionInterface> pc_;
MockPeerConnectionObserver observer_;
rtc::scoped_refptr<StreamCollection> reference_collection_;
@@ -1399,22 +1379,19 @@ TEST_P(PeerConnectionInterfaceTest,
config.prune_turn_ports = true;
// Create the PC factory and PC with the above config.
- rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory(
- webrtc::CreatePeerConnectionFactory(
+ rtc::scoped_refptr<PeerConnectionFactoryInterface> pc_factory(
+ CreatePeerConnectionFactory(
rtc::Thread::Current(), rtc::Thread::Current(),
rtc::Thread::Current(), fake_audio_capture_module_,
- webrtc::CreateBuiltinAudioEncoderFactory(),
- webrtc::CreateBuiltinAudioDecoderFactory(),
- std::make_unique<webrtc::VideoEncoderFactoryTemplate<
- webrtc::LibvpxVp8EncoderTemplateAdapter,
- webrtc::LibvpxVp9EncoderTemplateAdapter,
- webrtc::OpenH264EncoderTemplateAdapter,
- webrtc::LibaomAv1EncoderTemplateAdapter>>(),
- std::make_unique<webrtc::VideoDecoderFactoryTemplate<
- webrtc::LibvpxVp8DecoderTemplateAdapter,
- webrtc::LibvpxVp9DecoderTemplateAdapter,
- webrtc::OpenH264DecoderTemplateAdapter,
- webrtc::Dav1dDecoderTemplateAdapter>>(),
+ CreateBuiltinAudioEncoderFactory(),
+ CreateBuiltinAudioDecoderFactory(),
+ std::make_unique<VideoEncoderFactoryTemplate<
+ LibvpxVp8EncoderTemplateAdapter, LibvpxVp9EncoderTemplateAdapter,
+ OpenH264EncoderTemplateAdapter,
+ LibaomAv1EncoderTemplateAdapter>>(),
+ std::make_unique<VideoDecoderFactoryTemplate<
+ LibvpxVp8DecoderTemplateAdapter, LibvpxVp9DecoderTemplateAdapter,
+ OpenH264DecoderTemplateAdapter, Dav1dDecoderTemplateAdapter>>(),
nullptr /* audio_mixer */, nullptr /* audio_processing */));
PeerConnectionDependencies pc_dependencies(&observer_);
pc_dependencies.allocator = std::move(port_allocator);
@@ -1431,7 +1408,7 @@ TEST_P(PeerConnectionInterfaceTest,
EXPECT_TRUE(raw_port_allocator->flags() & cricket::PORTALLOCATOR_DISABLE_TCP);
EXPECT_TRUE(raw_port_allocator->flags() &
cricket::PORTALLOCATOR_DISABLE_COSTLY_NETWORKS);
- EXPECT_EQ(webrtc::PRUNE_BASED_ON_PRIORITY,
+ EXPECT_EQ(PRUNE_BASED_ON_PRIORITY,
raw_port_allocator->turn_port_prune_policy());
}
@@ -1453,8 +1430,7 @@ TEST_P(PeerConnectionInterfaceTest, GetConfigurationAfterCreatePeerConnection) {
TEST_P(PeerConnectionInterfaceTest, GetConfigurationAfterSetConfiguration) {
PeerConnectionInterface::RTCConfiguration starting_config;
starting_config.sdp_semantics = sdp_semantics_;
- starting_config.bundle_policy =
- webrtc::PeerConnection::kBundlePolicyMaxBundle;
+ starting_config.bundle_policy = PeerConnection::kBundlePolicyMaxBundle;
CreatePeerConnection(starting_config);
PeerConnectionInterface::RTCConfiguration config = pc_->GetConfiguration();
@@ -1985,7 +1961,7 @@ TEST_P(PeerConnectionInterfaceTest, CreateSctpDataChannel) {
RTCConfiguration rtc_config;
CreatePeerConnection(rtc_config);
- webrtc::DataChannelInit config;
+ DataChannelInit config;
auto channel = pc_->CreateDataChannelOrError("1", &config);
EXPECT_TRUE(channel.ok());
EXPECT_TRUE(channel.value()->reliable());
@@ -2017,7 +1993,7 @@ TEST_P(PeerConnectionInterfaceTest, CreateSctpDataChannelWhenClosed) {
RTCConfiguration rtc_config;
CreatePeerConnection(rtc_config);
pc_->Close();
- webrtc::DataChannelInit config;
+ DataChannelInit config;
auto ret = pc_->CreateDataChannelOrError("1", &config);
ASSERT_FALSE(ret.ok());
EXPECT_EQ(ret.error().type(), RTCErrorType::INVALID_STATE);
@@ -2029,7 +2005,7 @@ TEST_P(PeerConnectionInterfaceTest, CreateSctpDataChannelWithMinusOne) {
RTCConfiguration rtc_config;
CreatePeerConnection(rtc_config);
- webrtc::DataChannelInit config;
+ DataChannelInit config;
config.maxRetransmitTime = -1;
config.maxRetransmits = -1;
auto channel = pc_->CreateDataChannelOrError("1", &config);
@@ -2044,7 +2020,7 @@ TEST_P(PeerConnectionInterfaceTest,
CreatePeerConnection(rtc_config);
std::string label = "test";
- webrtc::DataChannelInit config;
+ DataChannelInit config;
config.maxRetransmits = 0;
config.maxRetransmitTime = 0;
@@ -2059,7 +2035,7 @@ TEST_P(PeerConnectionInterfaceTest,
RTCConfiguration rtc_config;
CreatePeerConnection(rtc_config);
- webrtc::DataChannelInit config;
+ DataChannelInit config;
config.id = 1;
config.negotiated = true;
@@ -2113,7 +2089,7 @@ TEST_P(PeerConnectionInterfaceTest, DISABLED_TestRejectSctpDataChannelInAnswer)
std::string sdp;
EXPECT_TRUE(pc_->local_description()->ToString(&sdp));
std::unique_ptr<SessionDescriptionInterface> answer(
- webrtc::CreateSessionDescription(SdpType::kAnswer, sdp));
+ CreateSessionDescription(SdpType::kAnswer, sdp));
ASSERT_TRUE(answer);
cricket::ContentInfo* data_info =
cricket::GetFirstDataContent(answer->description());
@@ -2132,8 +2108,7 @@ TEST_P(PeerConnectionInterfaceTest, ReceiveFireFoxOffer) {
AddAudioTrack("audio_label");
AddVideoTrack("video_label");
std::unique_ptr<SessionDescriptionInterface> desc(
- webrtc::CreateSessionDescription(SdpType::kOffer,
- webrtc::kFireFoxSdpOffer, nullptr));
+ CreateSessionDescription(SdpType::kOffer, kFireFoxSdpOffer, nullptr));
EXPECT_TRUE(DoSetSessionDescription(std::move(desc), false));
CreateAnswerAsLocalDescription();
ASSERT_TRUE(pc_->local_description() != nullptr);
@@ -2170,8 +2145,7 @@ TEST_P(PeerConnectionInterfaceTest, DtlsSdesFallbackNotSupported) {
EXPECT_EQ_WAIT(1, fake_certificate_generator_->generated_certificates(),
kTimeout);
std::unique_ptr<SessionDescriptionInterface> desc(
- webrtc::CreateSessionDescription(SdpType::kOffer, kDtlsSdesFallbackSdp,
- nullptr));
+ CreateSessionDescription(SdpType::kOffer, kDtlsSdesFallbackSdp, nullptr));
EXPECT_FALSE(DoSetSessionDescription(std::move(desc), /*local=*/false));
}
@@ -2184,18 +2158,17 @@ TEST_P(PeerConnectionInterfaceTest, ReceiveUpdatedAudioOfferWithBadCodecs) {
CreateOfferAsLocalDescription();
const char* answer_sdp = (sdp_semantics_ == SdpSemantics::kPlanB_DEPRECATED
- ? webrtc::kAudioSdpPlanB
- : webrtc::kAudioSdpUnifiedPlan);
+ ? kAudioSdpPlanB
+ : kAudioSdpUnifiedPlan);
std::unique_ptr<SessionDescriptionInterface> answer(
- webrtc::CreateSessionDescription(SdpType::kAnswer, answer_sdp, nullptr));
+ CreateSessionDescription(SdpType::kAnswer, answer_sdp, nullptr));
EXPECT_TRUE(DoSetSessionDescription(std::move(answer), false));
- const char* reoffer_sdp =
- (sdp_semantics_ == SdpSemantics::kPlanB_DEPRECATED
- ? webrtc::kAudioSdpWithUnsupportedCodecsPlanB
- : webrtc::kAudioSdpWithUnsupportedCodecsUnifiedPlan);
+ const char* reoffer_sdp = (sdp_semantics_ == SdpSemantics::kPlanB_DEPRECATED
+ ? kAudioSdpWithUnsupportedCodecsPlanB
+ : kAudioSdpWithUnsupportedCodecsUnifiedPlan);
std::unique_ptr<SessionDescriptionInterface> updated_offer(
- webrtc::CreateSessionDescription(SdpType::kOffer, reoffer_sdp, nullptr));
+ CreateSessionDescription(SdpType::kOffer, reoffer_sdp, nullptr));
EXPECT_TRUE(DoSetSessionDescription(std::move(updated_offer), false));
CreateAnswerAsLocalDescription();
}
@@ -2282,12 +2255,11 @@ TEST_P(PeerConnectionInterfaceTest, SetConfigurationChangesPruneTurnPortsFlag) {
config.prune_turn_ports = false;
CreatePeerConnection(config);
config = pc_->GetConfiguration();
- EXPECT_EQ(webrtc::NO_PRUNE, port_allocator_->turn_port_prune_policy());
+ EXPECT_EQ(NO_PRUNE, port_allocator_->turn_port_prune_policy());
config.prune_turn_ports = true;
EXPECT_TRUE(pc_->SetConfiguration(config).ok());
- EXPECT_EQ(webrtc::PRUNE_BASED_ON_PRIORITY,
- port_allocator_->turn_port_prune_policy());
+ EXPECT_EQ(PRUNE_BASED_ON_PRIORITY, port_allocator_->turn_port_prune_policy());
}
// Test that the ice check interval can be changed. This does not verify that
@@ -2556,12 +2528,12 @@ TEST_F(PeerConnectionInterfaceTestPlanB, CloseAndTestMethods) {
std::string sdp;
ASSERT_TRUE(pc_->remote_description()->ToString(&sdp));
std::unique_ptr<SessionDescriptionInterface> remote_offer(
- webrtc::CreateSessionDescription(SdpType::kOffer, sdp));
+ CreateSessionDescription(SdpType::kOffer, sdp));
EXPECT_FALSE(DoSetRemoteDescription(std::move(remote_offer)));
ASSERT_TRUE(pc_->local_description()->ToString(&sdp));
std::unique_ptr<SessionDescriptionInterface> local_offer(
- webrtc::CreateSessionDescription(SdpType::kOffer, sdp));
+ CreateSessionDescription(SdpType::kOffer, sdp));
EXPECT_FALSE(DoSetLocalDescription(std::move(local_offer)));
}
@@ -2621,10 +2593,10 @@ TEST_F(PeerConnectionInterfaceTestPlanB,
reference_collection_.get()));
rtc::scoped_refptr<AudioTrackInterface> audio_track2 =
observer_.remote_streams()->at(0)->GetAudioTracks()[1];
- EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, audio_track2->state());
+ EXPECT_EQ(MediaStreamTrackInterface::kLive, audio_track2->state());
rtc::scoped_refptr<VideoTrackInterface> video_track2 =
observer_.remote_streams()->at(0)->GetVideoTracks()[1];
- EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, video_track2->state());
+ EXPECT_EQ(MediaStreamTrackInterface::kLive, video_track2->state());
// Remove the extra audio and video tracks.
std::unique_ptr<SessionDescriptionInterface> desc_ms2 =
@@ -2638,10 +2610,10 @@ TEST_F(PeerConnectionInterfaceTestPlanB,
EXPECT_TRUE(CompareStreamCollections(observer_.remote_streams(),
reference_collection_.get()));
// Track state may be updated asynchronously.
- EXPECT_EQ_WAIT(webrtc::MediaStreamTrackInterface::kEnded,
- audio_track2->state(), kTimeout);
- EXPECT_EQ_WAIT(webrtc::MediaStreamTrackInterface::kEnded,
- video_track2->state(), kTimeout);
+ EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded, audio_track2->state(),
+ kTimeout);
+ EXPECT_EQ_WAIT(MediaStreamTrackInterface::kEnded, video_track2->state(),
+ kTimeout);
}
// This tests that remote tracks are ended if a local session description is set
@@ -2659,7 +2631,7 @@ TEST_P(PeerConnectionInterfaceTest, RejectMediaContent) {
rtc::scoped_refptr<MediaStreamTrackInterface> remote_audio =
audio_receiver->track();
- EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, remote_audio->state());
+ EXPECT_EQ(MediaStreamTrackInterface::kLive, remote_audio->state());
rtc::scoped_refptr<MediaStreamTrackInterface> remote_video =
video_receiver->track();
EXPECT_EQ(MediaStreamTrackInterface::kLive, remote_video->state());
@@ -2703,8 +2675,8 @@ TEST_F(PeerConnectionInterfaceTestPlanB, RemoveTrackThenRejectMediaContent) {
remote_stream->RemoveTrack(remote_stream->GetAudioTracks()[0]);
std::unique_ptr<SessionDescriptionInterface> local_answer(
- webrtc::CreateSessionDescription(SdpType::kAnswer,
- GetSdpStringWithStream1(), nullptr));
+ CreateSessionDescription(SdpType::kAnswer, GetSdpStringWithStream1(),
+ nullptr));
cricket::ContentInfo* video_info =
local_answer->description()->GetContentByName("video");
video_info->rejected = true;
@@ -2993,9 +2965,9 @@ TEST_P(PeerConnectionInterfaceTest,
ASSERT_TRUE(DoCreateOffer(&offer, nullptr));
// Grab a copy of the offer before it gets passed into the PC.
std::unique_ptr<SessionDescriptionInterface> modified_offer =
- webrtc::CreateSessionDescription(
- webrtc::SdpType::kOffer, offer->session_id(),
- offer->session_version(), offer->description()->Clone());
+ CreateSessionDescription(SdpType::kOffer, offer->session_id(),
+ offer->session_version(),
+ offer->description()->Clone());
EXPECT_TRUE(DoSetLocalDescription(std::move(offer)));
auto senders = pc_->GetSenders();
@@ -3051,8 +3023,8 @@ TEST_F(PeerConnectionInterfaceTestPlanB,
EXPECT_TRUE(ContainsSender(senders, kVideoTracks[0], kStreams[0]));
// Add a new MediaStream but with the same tracks as in the first stream.
- rtc::scoped_refptr<webrtc::MediaStreamInterface> stream_1(
- webrtc::MediaStream::Create(kStreams[1]));
+ rtc::scoped_refptr<MediaStreamInterface> stream_1(
+ MediaStream::Create(kStreams[1]));
stream_1->AddTrack(stream_collection->at(0)->GetVideoTracks()[0]);
stream_1->AddTrack(stream_collection->at(0)->GetAudioTracks()[0]);
pc_->AddStream(stream_1.get());
@@ -3173,9 +3145,9 @@ TEST_P(PeerConnectionInterfaceTest, SetConfigurationCausingPartialIceRestart) {
EXPECT_TRUE(pc_->SetConfiguration(config).ok());
// Do ICE restart for the first m= section, initiated by remote peer.
- std::unique_ptr<webrtc::SessionDescriptionInterface> remote_offer(
- webrtc::CreateSessionDescription(SdpType::kOffer,
- GetSdpStringWithStream1(), nullptr));
+ std::unique_ptr<SessionDescriptionInterface> remote_offer(
+ CreateSessionDescription(SdpType::kOffer, GetSdpStringWithStream1(),
+ nullptr));
ASSERT_TRUE(remote_offer);
remote_offer->description()->transport_infos()[0].description.ice_ufrag =
"modified";
@@ -3221,7 +3193,7 @@ TEST_P(PeerConnectionInterfaceTest, CurrentAndPendingDescriptions) {
// Set remote pranswer.
std::unique_ptr<SessionDescriptionInterface> remote_pranswer(
- webrtc::CreateSessionDescription(SdpType::kPrAnswer, sdp));
+ CreateSessionDescription(SdpType::kPrAnswer, sdp));
SessionDescriptionInterface* remote_pranswer_ptr = remote_pranswer.get();
EXPECT_TRUE(DoSetRemoteDescription(std::move(remote_pranswer)));
EXPECT_EQ(local_offer_ptr, pc_->pending_local_description());
@@ -3231,7 +3203,7 @@ TEST_P(PeerConnectionInterfaceTest, CurrentAndPendingDescriptions) {
// Set remote answer.
std::unique_ptr<SessionDescriptionInterface> remote_answer(
- webrtc::CreateSessionDescription(SdpType::kAnswer, sdp));
+ CreateSessionDescription(SdpType::kAnswer, sdp));
SessionDescriptionInterface* remote_answer_ptr = remote_answer.get();
EXPECT_TRUE(DoSetRemoteDescription(std::move(remote_answer)));
EXPECT_EQ(nullptr, pc_->pending_local_description());
@@ -3241,7 +3213,7 @@ TEST_P(PeerConnectionInterfaceTest, CurrentAndPendingDescriptions) {
// Set remote offer.
std::unique_ptr<SessionDescriptionInterface> remote_offer(
- webrtc::CreateSessionDescription(SdpType::kOffer, sdp));
+ CreateSessionDescription(SdpType::kOffer, sdp));
SessionDescriptionInterface* remote_offer_ptr = remote_offer.get();
EXPECT_TRUE(DoSetRemoteDescription(std::move(remote_offer)));
EXPECT_EQ(remote_offer_ptr, pc_->pending_remote_description());
@@ -3251,7 +3223,7 @@ TEST_P(PeerConnectionInterfaceTest, CurrentAndPendingDescriptions) {
// Set local pranswer.
std::unique_ptr<SessionDescriptionInterface> local_pranswer(
- webrtc::CreateSessionDescription(SdpType::kPrAnswer, sdp));
+ CreateSessionDescription(SdpType::kPrAnswer, sdp));
SessionDescriptionInterface* local_pranswer_ptr = local_pranswer.get();
EXPECT_TRUE(DoSetLocalDescription(std::move(local_pranswer)));
EXPECT_EQ(remote_offer_ptr, pc_->pending_remote_description());
@@ -3261,7 +3233,7 @@ TEST_P(PeerConnectionInterfaceTest, CurrentAndPendingDescriptions) {
// Set local answer.
std::unique_ptr<SessionDescriptionInterface> local_answer(
- webrtc::CreateSessionDescription(SdpType::kAnswer, sdp));
+ CreateSessionDescription(SdpType::kAnswer, sdp));
SessionDescriptionInterface* local_answer_ptr = local_answer.get();
EXPECT_TRUE(DoSetLocalDescription(std::move(local_answer)));
EXPECT_EQ(nullptr, pc_->pending_remote_description());
@@ -3280,9 +3252,8 @@ TEST_P(PeerConnectionInterfaceTest,
// The RtcEventLog will be reset when the PeerConnection is closed.
pc_->Close();
- EXPECT_FALSE(
- pc_->StartRtcEventLog(std::make_unique<webrtc::RtcEventLogOutputNull>(),
- webrtc::RtcEventLog::kImmediateOutput));
+ EXPECT_FALSE(pc_->StartRtcEventLog(std::make_unique<RtcEventLogOutputNull>(),
+ RtcEventLog::kImmediateOutput));
pc_->StopRtcEventLog();
}
diff --git a/third_party/libwebrtc/pc/peer_connection_jsep_unittest.cc b/third_party/libwebrtc/pc/peer_connection_jsep_unittest.cc
index 1369253ad6..786b519a93 100644
--- a/third_party/libwebrtc/pc/peer_connection_jsep_unittest.cc
+++ b/third_party/libwebrtc/pc/peer_connection_jsep_unittest.cc
@@ -20,7 +20,7 @@
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
-#include "api/call/call_factory_interface.h"
+#include "api/enable_media_with_defaults.h"
#include "api/field_trials_view.h"
#include "api/jsep.h"
#include "api/media_stream_interface.h"
@@ -40,7 +40,6 @@
#include "media/base/media_engine.h"
#include "media/base/stream_params.h"
#include "media/engine/webrtc_media_engine.h"
-#include "media/engine/webrtc_media_engine_defaults.h"
#include "modules/audio_device/include/audio_device.h"
#include "p2p/base/p2p_constants.h"
#include "p2p/base/port_allocator.h"
@@ -84,13 +83,8 @@ PeerConnectionFactoryDependencies CreatePeerConnectionFactoryDependencies() {
dependencies.signaling_thread = rtc::Thread::Current();
dependencies.task_queue_factory = CreateDefaultTaskQueueFactory();
dependencies.trials = std::make_unique<FieldTrialBasedConfig>();
- cricket::MediaEngineDependencies media_deps;
- media_deps.task_queue_factory = dependencies.task_queue_factory.get();
- media_deps.adm = FakeAudioCaptureModule::Create();
- media_deps.trials = dependencies.trials.get();
- SetMediaEngineDefaults(&media_deps);
- dependencies.media_engine = cricket::CreateMediaEngine(std::move(media_deps));
- dependencies.call_factory = CreateCallFactory();
+ dependencies.adm = FakeAudioCaptureModule::Create();
+ EnableMediaWithDefaults(dependencies);
dependencies.sctp_factory = std::make_unique<FakeSctpTransportFactory>();
return dependencies;
}
diff --git a/third_party/libwebrtc/pc/peer_connection_media_unittest.cc b/third_party/libwebrtc/pc/peer_connection_media_unittest.cc
index 485541981e..387094cc4f 100644
--- a/third_party/libwebrtc/pc/peer_connection_media_unittest.cc
+++ b/third_party/libwebrtc/pc/peer_connection_media_unittest.cc
@@ -27,7 +27,6 @@
#include "absl/algorithm/container.h"
#include "absl/types/optional.h"
#include "api/audio_options.h"
-#include "api/call/call_factory_interface.h"
#include "api/jsep.h"
#include "api/media_types.h"
#include "api/peer_connection_interface.h"
@@ -57,6 +56,7 @@
#include "pc/rtp_media_utils.h"
#include "pc/rtp_transceiver.h"
#include "pc/session_description.h"
+#include "pc/test/enable_fake_media.h"
#include "pc/test/mock_peer_connection_observers.h"
#include "rtc_base/checks.h"
#include "rtc_base/rtc_certificate_generator.h"
@@ -82,9 +82,9 @@ using ::testing::NotNull;
using ::testing::Values;
cricket::MediaSendChannelInterface* SendChannelInternal(
- rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver) {
- auto transceiver_with_internal = static_cast<rtc::RefCountedObject<
- webrtc::RtpTransceiverProxyWithInternal<webrtc::RtpTransceiver>>*>(
+ rtc::scoped_refptr<RtpTransceiverInterface> transceiver) {
+ auto transceiver_with_internal = static_cast<
+ rtc::RefCountedObject<RtpTransceiverProxyWithInternal<RtpTransceiver>>*>(
transceiver.get());
auto transceiver_internal =
static_cast<RtpTransceiver*>(transceiver_with_internal->internal());
@@ -92,9 +92,9 @@ cricket::MediaSendChannelInterface* SendChannelInternal(
}
cricket::MediaReceiveChannelInterface* ReceiveChannelInternal(
- rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver) {
- auto transceiver_with_internal = static_cast<rtc::RefCountedObject<
- webrtc::RtpTransceiverProxyWithInternal<webrtc::RtpTransceiver>>*>(
+ rtc::scoped_refptr<RtpTransceiverInterface> transceiver) {
+ auto transceiver_with_internal = static_cast<
+ rtc::RefCountedObject<RtpTransceiverProxyWithInternal<RtpTransceiver>>*>(
transceiver.get());
auto transceiver_internal =
static_cast<RtpTransceiver*>(transceiver_with_internal->internal());
@@ -102,22 +102,22 @@ cricket::MediaReceiveChannelInterface* ReceiveChannelInternal(
}
cricket::FakeVideoMediaSendChannel* VideoMediaSendChannel(
- rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver) {
+ rtc::scoped_refptr<RtpTransceiverInterface> transceiver) {
return static_cast<cricket::FakeVideoMediaSendChannel*>(
SendChannelInternal(transceiver));
}
cricket::FakeVideoMediaReceiveChannel* VideoMediaReceiveChannel(
- rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver) {
+ rtc::scoped_refptr<RtpTransceiverInterface> transceiver) {
return static_cast<cricket::FakeVideoMediaReceiveChannel*>(
ReceiveChannelInternal(transceiver));
}
cricket::FakeVoiceMediaSendChannel* VoiceMediaSendChannel(
- rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver) {
+ rtc::scoped_refptr<RtpTransceiverInterface> transceiver) {
return static_cast<cricket::FakeVoiceMediaSendChannel*>(
SendChannelInternal(transceiver));
}
cricket::FakeVoiceMediaReceiveChannel* VoiceMediaReceiveChannel(
- rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver) {
+ rtc::scoped_refptr<RtpTransceiverInterface> transceiver) {
return static_cast<cricket::FakeVoiceMediaReceiveChannel*>(
ReceiveChannelInternal(transceiver));
}
@@ -173,8 +173,7 @@ class PeerConnectionMediaBaseTest : public ::testing::Test {
factory_dependencies.worker_thread = rtc::Thread::Current();
factory_dependencies.signaling_thread = rtc::Thread::Current();
factory_dependencies.task_queue_factory = CreateDefaultTaskQueueFactory();
- factory_dependencies.media_engine = std::move(media_engine);
- factory_dependencies.call_factory = CreateCallFactory();
+ EnableFakeMedia(factory_dependencies, std::move(media_engine));
factory_dependencies.event_log_factory =
std::make_unique<RtcEventLogFactory>(
factory_dependencies.task_queue_factory.get());
@@ -255,7 +254,7 @@ class PeerConnectionMediaBaseTest : public ::testing::Test {
return sdp_semantics_ == SdpSemantics::kUnifiedPlan;
}
- webrtc::test::ScopedKeyValueConfig field_trials_;
+ test::ScopedKeyValueConfig field_trials_;
std::unique_ptr<rtc::VirtualSocketServer> vss_;
rtc::AutoSocketServerThread main_;
const SdpSemantics sdp_semantics_;
@@ -1496,10 +1495,10 @@ TEST_P(PeerConnectionMediaTest, RedFmtpPayloadDifferentRedundancy) {
}
template <typename C>
-bool CompareCodecs(const std::vector<webrtc::RtpCodecCapability>& capabilities,
+bool CompareCodecs(const std::vector<RtpCodecCapability>& capabilities,
const std::vector<C>& codecs) {
bool capability_has_rtx =
- absl::c_any_of(capabilities, [](const webrtc::RtpCodecCapability& codec) {
+ absl::c_any_of(capabilities, [](const RtpCodecCapability& codec) {
return codec.name == cricket::kRtxCodecName;
});
bool codecs_has_rtx = absl::c_any_of(codecs, [](const C& codec) {
@@ -1511,16 +1510,16 @@ bool CompareCodecs(const std::vector<webrtc::RtpCodecCapability>& capabilities,
codecs, std::back_inserter(codecs_no_rtx),
[](const C& codec) { return codec.name != cricket::kRtxCodecName; });
- std::vector<webrtc::RtpCodecCapability> capabilities_no_rtx;
+ std::vector<RtpCodecCapability> capabilities_no_rtx;
absl::c_copy_if(capabilities, std::back_inserter(capabilities_no_rtx),
- [](const webrtc::RtpCodecCapability& codec) {
+ [](const RtpCodecCapability& codec) {
return codec.name != cricket::kRtxCodecName;
});
return capability_has_rtx == codecs_has_rtx &&
absl::c_equal(
capabilities_no_rtx, codecs_no_rtx,
- [](const webrtc::RtpCodecCapability& capability, const C& codec) {
+ [](const RtpCodecCapability& capability, const C& codec) {
return codec.MatchesRtpCodec(capability);
});
}
@@ -1539,9 +1538,9 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
auto capabilities = caller->pc_factory()->GetRtpSenderCapabilities(
cricket::MediaType::MEDIA_TYPE_AUDIO);
- std::vector<webrtc::RtpCodecCapability> codecs;
+ std::vector<RtpCodecCapability> codecs;
absl::c_copy_if(capabilities.codecs, std::back_inserter(codecs),
- [](const webrtc::RtpCodecCapability& codec) {
+ [](const RtpCodecCapability& codec) {
return codec.name.find("_only_") != std::string::npos;
});
@@ -1562,9 +1561,9 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
auto capabilities = caller->pc_factory()->GetRtpReceiverCapabilities(
cricket::MediaType::MEDIA_TYPE_AUDIO);
- std::vector<webrtc::RtpCodecCapability> codecs;
+ std::vector<RtpCodecCapability> codecs;
absl::c_copy_if(capabilities.codecs, std::back_inserter(codecs),
- [](const webrtc::RtpCodecCapability& codec) {
+ [](const RtpCodecCapability& codec) {
return codec.name.find("_only_") != std::string::npos;
});
@@ -1612,7 +1611,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
auto codecs_only_rtx_red_fec = codecs;
auto it = std::remove_if(codecs_only_rtx_red_fec.begin(),
codecs_only_rtx_red_fec.end(),
- [](const webrtc::RtpCodecCapability& codec) {
+ [](const RtpCodecCapability& codec) {
return !(codec.name == cricket::kRtxCodecName ||
codec.name == cricket::kRedCodecName ||
codec.name == cricket::kUlpfecCodecName);
@@ -1639,7 +1638,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, SetCodecPreferencesAllAudioCodecs) {
auto codecs = offer->description()
->contents()[0]
.media_description()
- ->as_audio()
->codecs();
EXPECT_TRUE(CompareCodecs(sender_audio_codecs, codecs));
}
@@ -1652,7 +1650,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
caller->pc_factory()
->GetRtpSenderCapabilities(cricket::MEDIA_TYPE_AUDIO)
.codecs;
- std::vector<webrtc::RtpCodecCapability> empty_codecs = {};
+ std::vector<RtpCodecCapability> empty_codecs = {};
auto audio_transceiver = caller->pc()->GetTransceivers().front();
@@ -1662,7 +1660,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
auto codecs = offer->description()
->contents()[0]
.media_description()
- ->as_audio()
->codecs();
EXPECT_TRUE(CompareCodecs(sender_audio_codecs, codecs));
}
@@ -1707,7 +1704,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
auto codecs_only_rtx_red_fec = codecs;
auto it = std::remove_if(codecs_only_rtx_red_fec.begin(),
codecs_only_rtx_red_fec.end(),
- [](const webrtc::RtpCodecCapability& codec) {
+ [](const RtpCodecCapability& codec) {
return !(codec.name == cricket::kRtxCodecName ||
codec.name == cricket::kRedCodecName ||
codec.name == cricket::kUlpfecCodecName);
@@ -1734,7 +1731,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, SetCodecPreferencesAllVideoCodecs) {
auto codecs = offer->description()
->contents()[0]
.media_description()
- ->as_video()
->codecs();
EXPECT_TRUE(CompareCodecs(sender_video_codecs, codecs));
}
@@ -1748,7 +1744,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
->GetRtpSenderCapabilities(cricket::MEDIA_TYPE_VIDEO)
.codecs;
- std::vector<webrtc::RtpCodecCapability> empty_codecs = {};
+ std::vector<RtpCodecCapability> empty_codecs = {};
auto video_transceiver = caller->pc()->GetTransceivers().front();
@@ -1758,7 +1754,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
auto codecs = offer->description()
->contents()[0]
.media_description()
- ->as_video()
->codecs();
EXPECT_TRUE(CompareCodecs(sender_video_codecs, codecs));
}
@@ -1787,7 +1782,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
auto codecs = offer->description()
->contents()[0]
.media_description()
- ->as_video()
->codecs();
EXPECT_TRUE(CompareCodecs(single_codec, codecs));
}
@@ -1818,7 +1812,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, SetCodecPreferencesVideoWithRtx) {
auto video_codecs_vpx_rtx = sender_video_codecs;
auto it =
std::remove_if(video_codecs_vpx_rtx.begin(), video_codecs_vpx_rtx.end(),
- [](const webrtc::RtpCodecCapability& codec) {
+ [](const RtpCodecCapability& codec) {
return codec.name != cricket::kRtxCodecName &&
codec.name != cricket::kVp8CodecName &&
codec.name != cricket::kVp9CodecName;
@@ -1832,7 +1826,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan, SetCodecPreferencesVideoWithRtx) {
auto codecs = offer->description()
->contents()[0]
.media_description()
- ->as_video()
->codecs();
EXPECT_TRUE(CompareCodecs(video_codecs_vpx_rtx, codecs));
@@ -1867,7 +1860,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
auto video_codecs_vpx = video_codecs;
auto it = std::remove_if(video_codecs_vpx.begin(), video_codecs_vpx.end(),
- [](const webrtc::RtpCodecCapability& codec) {
+ [](const RtpCodecCapability& codec) {
return codec.name != cricket::kVp8CodecName &&
codec.name != cricket::kVp9CodecName;
});
@@ -1879,7 +1872,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
auto codecs = offer->description()
->contents()[0]
.media_description()
- ->as_video()
->codecs();
EXPECT_EQ(codecs.size(), 2u); // VP8, VP9
@@ -1890,7 +1882,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
auto recv_transceiver = callee->pc()->GetTransceivers().front();
auto video_codecs_vp8_rtx = video_codecs;
it = std::remove_if(video_codecs_vp8_rtx.begin(), video_codecs_vp8_rtx.end(),
- [](const webrtc::RtpCodecCapability& codec) {
+ [](const RtpCodecCapability& codec) {
bool r = codec.name != cricket::kVp8CodecName &&
codec.name != cricket::kRtxCodecName;
return r;
@@ -1904,7 +1896,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
auto recv_codecs = answer->description()
->contents()[0]
.media_description()
- ->as_video()
->codecs();
EXPECT_EQ(recv_codecs.size(), 1u); // VP8
}
@@ -1937,7 +1928,7 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
auto video_codecs_vpx = video_codecs;
auto it = std::remove_if(video_codecs_vpx.begin(), video_codecs_vpx.end(),
- [](const webrtc::RtpCodecCapability& codec) {
+ [](const RtpCodecCapability& codec) {
return codec.name != cricket::kVp8CodecName &&
codec.name != cricket::kVp9CodecName;
});
@@ -1952,7 +1943,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
auto codecs = offer->description()
->contents()[0]
.media_description()
- ->as_video()
->codecs();
EXPECT_EQ(codecs.size(), 2u); // VP9, VP8
EXPECT_TRUE(CompareCodecs(video_codecs_vpx, codecs));
@@ -1967,7 +1957,6 @@ TEST_F(PeerConnectionMediaTestUnifiedPlan,
auto recv_codecs = answer->description()
->contents()[0]
.media_description()
- ->as_video()
->codecs();
EXPECT_TRUE(CompareCodecs(video_codecs_vpx_reverse, recv_codecs));
diff --git a/third_party/libwebrtc/pc/peer_connection_rampup_tests.cc b/third_party/libwebrtc/pc/peer_connection_rampup_tests.cc
index 545a1d53d0..0fd3c27f7d 100644
--- a/third_party/libwebrtc/pc/peer_connection_rampup_tests.cc
+++ b/third_party/libwebrtc/pc/peer_connection_rampup_tests.cc
@@ -201,7 +201,7 @@ class PeerConnectionRampUpTest : public ::testing::Test {
fake_network_managers_.emplace_back(fake_network_manager);
auto observer = std::make_unique<MockPeerConnectionObserver>();
- webrtc::PeerConnectionDependencies dependencies(observer.get());
+ PeerConnectionDependencies dependencies(observer.get());
cricket::BasicPortAllocator* port_allocator =
new cricket::BasicPortAllocator(fake_network_manager,
firewall_socket_factory_.get());
diff --git a/third_party/libwebrtc/pc/peer_connection_rtp_unittest.cc b/third_party/libwebrtc/pc/peer_connection_rtp_unittest.cc
index b93e5923bb..1a97a4bb44 100644
--- a/third_party/libwebrtc/pc/peer_connection_rtp_unittest.cc
+++ b/third_party/libwebrtc/pc/peer_connection_rtp_unittest.cc
@@ -75,13 +75,13 @@ using ::testing::UnorderedElementsAre;
using ::testing::Values;
template <typename MethodFunctor>
-class OnSuccessObserver : public webrtc::SetRemoteDescriptionObserverInterface {
+class OnSuccessObserver : public SetRemoteDescriptionObserverInterface {
public:
explicit OnSuccessObserver(MethodFunctor on_success)
: on_success_(std::move(on_success)) {}
- // webrtc::SetRemoteDescriptionObserverInterface implementation.
- void OnSetRemoteDescriptionComplete(webrtc::RTCError error) override {
+ // SetRemoteDescriptionObserverInterface implementation.
+ void OnSetRemoteDescriptionComplete(RTCError error) override {
RTC_CHECK(error.ok());
on_success_();
}
@@ -113,7 +113,7 @@ class PeerConnectionRtpBaseTest : public ::testing::Test {
Dav1dDecoderTemplateAdapter>>(),
nullptr /* audio_mixer */,
nullptr /* audio_processing */)) {
- webrtc::metrics::Reset();
+ metrics::Reset();
}
std::unique_ptr<PeerConnectionWrapper> CreatePeerConnection() {
@@ -201,7 +201,7 @@ class PeerConnectionRtpTestUnifiedPlan : public PeerConnectionRtpBaseTest {
}
};
-// These tests cover `webrtc::PeerConnectionObserver` callbacks firing upon
+// These tests cover `PeerConnectionObserver` callbacks firing upon
// setting the remote description.
TEST_P(PeerConnectionRtpTest, AddTrackWithoutStreamFiresOnAddTrack) {
@@ -934,8 +934,8 @@ TEST_P(PeerConnectionRtpTest,
auto caller = CreatePeerConnection();
auto callee = CreatePeerConnection();
- rtc::scoped_refptr<webrtc::MockSetSessionDescriptionObserver> observer =
- rtc::make_ref_counted<webrtc::MockSetSessionDescriptionObserver>();
+ rtc::scoped_refptr<MockSetSessionDescriptionObserver> observer =
+ rtc::make_ref_counted<MockSetSessionDescriptionObserver>();
auto offer = caller->CreateOfferAndSetAsLocal();
callee->pc()->SetRemoteDescription(observer.get(), offer.release());
diff --git a/third_party/libwebrtc/pc/peer_connection_signaling_unittest.cc b/third_party/libwebrtc/pc/peer_connection_signaling_unittest.cc
index 8ca59fc20c..190fb38b43 100644
--- a/third_party/libwebrtc/pc/peer_connection_signaling_unittest.cc
+++ b/third_party/libwebrtc/pc/peer_connection_signaling_unittest.cc
@@ -896,8 +896,8 @@ TEST_P(PeerConnectionSignalingTest, UnsupportedContentType) {
"m=bogus 9 FOO 0 8\r\n"
"c=IN IP4 0.0.0.0\r\n"
"a=mid:bogusmid\r\n";
- std::unique_ptr<webrtc::SessionDescriptionInterface> remote_description =
- webrtc::CreateSessionDescription(SdpType::kOffer, sdp, nullptr);
+ std::unique_ptr<SessionDescriptionInterface> remote_description =
+ CreateSessionDescription(SdpType::kOffer, sdp, nullptr);
EXPECT_TRUE(caller->SetRemoteDescription(std::move(remote_description)));
@@ -977,20 +977,17 @@ TEST_P(PeerConnectionSignalingTest, ReceiveFlexFec) {
"a=ssrc-group:FEC-FR 1224551896 1953032773\r\n"
"a=ssrc:1224551896 cname:/exJcmhSLpyu9FgV\r\n"
"a=ssrc:1953032773 cname:/exJcmhSLpyu9FgV\r\n";
- std::unique_ptr<webrtc::SessionDescriptionInterface> remote_description =
- webrtc::CreateSessionDescription(SdpType::kOffer, sdp, nullptr);
+ std::unique_ptr<SessionDescriptionInterface> remote_description =
+ CreateSessionDescription(SdpType::kOffer, sdp, nullptr);
EXPECT_TRUE(caller->SetRemoteDescription(std::move(remote_description)));
auto answer = caller->CreateAnswer();
ASSERT_EQ(answer->description()->contents().size(), 1u);
- ASSERT_NE(
- answer->description()->contents()[0].media_description()->as_video(),
- nullptr);
+ ASSERT_NE(answer->description()->contents()[0].media_description(), nullptr);
auto codecs = answer->description()
->contents()[0]
.media_description()
- ->as_video()
->codecs();
ASSERT_EQ(codecs.size(), 2u);
EXPECT_EQ(codecs[1].name, "flexfec-03");
@@ -1033,20 +1030,17 @@ TEST_P(PeerConnectionSignalingTest, ReceiveFlexFecReoffer) {
"a=ssrc-group:FEC-FR 1224551896 1953032773\r\n"
"a=ssrc:1224551896 cname:/exJcmhSLpyu9FgV\r\n"
"a=ssrc:1953032773 cname:/exJcmhSLpyu9FgV\r\n";
- std::unique_ptr<webrtc::SessionDescriptionInterface> remote_description =
- webrtc::CreateSessionDescription(SdpType::kOffer, sdp, nullptr);
+ std::unique_ptr<SessionDescriptionInterface> remote_description =
+ CreateSessionDescription(SdpType::kOffer, sdp, nullptr);
EXPECT_TRUE(caller->SetRemoteDescription(std::move(remote_description)));
auto answer = caller->CreateAnswer();
ASSERT_EQ(answer->description()->contents().size(), 1u);
- ASSERT_NE(
- answer->description()->contents()[0].media_description()->as_video(),
- nullptr);
+ ASSERT_NE(answer->description()->contents()[0].media_description(), nullptr);
auto codecs = answer->description()
->contents()[0]
.media_description()
- ->as_video()
->codecs();
ASSERT_EQ(codecs.size(), 2u);
EXPECT_EQ(codecs[1].name, "flexfec-03");
@@ -1059,7 +1053,6 @@ TEST_P(PeerConnectionSignalingTest, ReceiveFlexFecReoffer) {
auto offer_codecs = offer->description()
->contents()[0]
.media_description()
- ->as_video()
->codecs();
auto flexfec_it = std::find_if(
offer_codecs.begin(), offer_codecs.end(),
@@ -1104,8 +1097,8 @@ TEST_P(PeerConnectionSignalingTest, MidAttributeMaxLength) {
"a=rtcp-fb:102 nack\r\n"
"a=rtcp-fb:102 nack pli\r\n"
"a=ssrc:1224551896 cname:/exJcmhSLpyu9FgV\r\n";
- std::unique_ptr<webrtc::SessionDescriptionInterface> remote_description =
- webrtc::CreateSessionDescription(SdpType::kOffer, sdp, nullptr);
+ std::unique_ptr<SessionDescriptionInterface> remote_description =
+ CreateSessionDescription(SdpType::kOffer, sdp, nullptr);
EXPECT_FALSE(caller->SetRemoteDescription(std::move(remote_description)));
}
@@ -1339,8 +1332,8 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest, RtxReofferApt) {
"a=rtcp-fb:102 nack\r\n"
"a=rtcp-fb:102 nack pli\r\n"
"a=ssrc:1224551896 cname:/exJcmhSLpyu9FgV\r\n";
- std::unique_ptr<webrtc::SessionDescriptionInterface> remote_description =
- webrtc::CreateSessionDescription(SdpType::kOffer, sdp, nullptr);
+ std::unique_ptr<SessionDescriptionInterface> remote_description =
+ CreateSessionDescription(SdpType::kOffer, sdp, nullptr);
EXPECT_TRUE(callee->SetRemoteDescription(std::move(remote_description)));
@@ -1353,7 +1346,6 @@ TEST_F(PeerConnectionSignalingUnifiedPlanTest, RtxReofferApt) {
auto codecs = reoffer->description()
->contents()[0]
.media_description()
- ->as_video()
->codecs();
ASSERT_GT(codecs.size(), 2u);
EXPECT_EQ(codecs[0].name, "VP8");
diff --git a/third_party/libwebrtc/pc/peer_connection_simulcast_unittest.cc b/third_party/libwebrtc/pc/peer_connection_simulcast_unittest.cc
index 6b6a96c473..bffb5d9e9f 100644
--- a/third_party/libwebrtc/pc/peer_connection_simulcast_unittest.cc
+++ b/third_party/libwebrtc/pc/peer_connection_simulcast_unittest.cc
@@ -220,7 +220,7 @@ class PeerConnectionSimulcastMetricsTests
: public PeerConnectionSimulcastTests,
public ::testing::WithParamInterface<int> {
protected:
- PeerConnectionSimulcastMetricsTests() { webrtc::metrics::Reset(); }
+ PeerConnectionSimulcastMetricsTests() { metrics::Reset(); }
};
#endif
diff --git a/third_party/libwebrtc/pc/peer_connection_svc_integrationtest.cc b/third_party/libwebrtc/pc/peer_connection_svc_integrationtest.cc
index 672f3eef99..32ca451866 100644
--- a/third_party/libwebrtc/pc/peer_connection_svc_integrationtest.cc
+++ b/third_party/libwebrtc/pc/peer_connection_svc_integrationtest.cc
@@ -37,14 +37,13 @@ class PeerConnectionSVCIntegrationTest
: PeerConnectionIntegrationBaseTest(SdpSemantics::kUnifiedPlan) {}
RTCError SetCodecPreferences(
- rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver,
+ rtc::scoped_refptr<RtpTransceiverInterface> transceiver,
absl::string_view codec_name) {
- webrtc::RtpCapabilities capabilities =
+ RtpCapabilities capabilities =
caller()->pc_factory()->GetRtpSenderCapabilities(
cricket::MEDIA_TYPE_VIDEO);
std::vector<RtpCodecCapability> codecs;
- for (const webrtc::RtpCodecCapability& codec_capability :
- capabilities.codecs) {
+ for (const RtpCodecCapability& codec_capability : capabilities.codecs) {
if (codec_capability.name == codec_name)
codecs.push_back(codec_capability);
}
@@ -55,8 +54,8 @@ class PeerConnectionSVCIntegrationTest
TEST_F(PeerConnectionSVCIntegrationTest, AddTransceiverAcceptsL1T1) {
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
- webrtc::RtpTransceiverInit init;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ RtpEncodingParameters encoding_parameters;
encoding_parameters.scalability_mode = "L1T1";
init.send_encodings.push_back(encoding_parameters);
auto transceiver_or_error =
@@ -67,8 +66,8 @@ TEST_F(PeerConnectionSVCIntegrationTest, AddTransceiverAcceptsL1T1) {
TEST_F(PeerConnectionSVCIntegrationTest, AddTransceiverAcceptsL3T3) {
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
- webrtc::RtpTransceiverInit init;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ RtpEncodingParameters encoding_parameters;
encoding_parameters.scalability_mode = "L3T3";
init.send_encodings.push_back(encoding_parameters);
auto transceiver_or_error =
@@ -80,33 +79,32 @@ TEST_F(PeerConnectionSVCIntegrationTest,
AddTransceiverRejectsUnknownScalabilityMode) {
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
- webrtc::RtpTransceiverInit init;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ RtpEncodingParameters encoding_parameters;
encoding_parameters.scalability_mode = "FOOBAR";
init.send_encodings.push_back(encoding_parameters);
auto transceiver_or_error =
caller()->pc()->AddTransceiver(caller()->CreateLocalVideoTrack(), init);
EXPECT_FALSE(transceiver_or_error.ok());
EXPECT_EQ(transceiver_or_error.error().type(),
- webrtc::RTCErrorType::UNSUPPORTED_OPERATION);
+ RTCErrorType::UNSUPPORTED_OPERATION);
}
TEST_F(PeerConnectionSVCIntegrationTest, SetParametersAcceptsL1T3WithVP8) {
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
- webrtc::RtpCapabilities capabilities =
+ RtpCapabilities capabilities =
caller()->pc_factory()->GetRtpSenderCapabilities(
cricket::MEDIA_TYPE_VIDEO);
std::vector<RtpCodecCapability> vp8_codec;
- for (const webrtc::RtpCodecCapability& codec_capability :
- capabilities.codecs) {
+ for (const RtpCodecCapability& codec_capability : capabilities.codecs) {
if (codec_capability.name == cricket::kVp8CodecName)
vp8_codec.push_back(codec_capability);
}
- webrtc::RtpTransceiverInit init;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ RtpEncodingParameters encoding_parameters;
init.send_encodings.push_back(encoding_parameters);
auto transceiver_or_error =
caller()->pc()->AddTransceiver(caller()->CreateLocalVideoTrack(), init);
@@ -114,7 +112,7 @@ TEST_F(PeerConnectionSVCIntegrationTest, SetParametersAcceptsL1T3WithVP8) {
auto transceiver = transceiver_or_error.MoveValue();
EXPECT_TRUE(transceiver->SetCodecPreferences(vp8_codec).ok());
- webrtc::RtpParameters parameters = transceiver->sender()->GetParameters();
+ RtpParameters parameters = transceiver->sender()->GetParameters();
ASSERT_EQ(parameters.encodings.size(), 1u);
parameters.encodings[0].scalability_mode = "L1T3";
auto result = transceiver->sender()->SetParameters(parameters);
@@ -125,8 +123,8 @@ TEST_F(PeerConnectionSVCIntegrationTest, SetParametersRejectsL3T3WithVP8) {
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
- webrtc::RtpTransceiverInit init;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ RtpEncodingParameters encoding_parameters;
init.send_encodings.push_back(encoding_parameters);
auto transceiver_or_error =
caller()->pc()->AddTransceiver(caller()->CreateLocalVideoTrack(), init);
@@ -134,12 +132,12 @@ TEST_F(PeerConnectionSVCIntegrationTest, SetParametersRejectsL3T3WithVP8) {
auto transceiver = transceiver_or_error.MoveValue();
EXPECT_TRUE(SetCodecPreferences(transceiver, cricket::kVp8CodecName).ok());
- webrtc::RtpParameters parameters = transceiver->sender()->GetParameters();
+ RtpParameters parameters = transceiver->sender()->GetParameters();
ASSERT_EQ(parameters.encodings.size(), 1u);
parameters.encodings[0].scalability_mode = "L3T3";
auto result = transceiver->sender()->SetParameters(parameters);
EXPECT_FALSE(result.ok());
- EXPECT_EQ(result.type(), webrtc::RTCErrorType::INVALID_MODIFICATION);
+ EXPECT_EQ(result.type(), RTCErrorType::INVALID_MODIFICATION);
}
TEST_F(PeerConnectionSVCIntegrationTest,
@@ -147,8 +145,8 @@ TEST_F(PeerConnectionSVCIntegrationTest,
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
- webrtc::RtpTransceiverInit init;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ RtpEncodingParameters encoding_parameters;
init.send_encodings.push_back(encoding_parameters);
auto transceiver_or_error =
caller()->pc()->AddTransceiver(caller()->CreateLocalVideoTrack(), init);
@@ -159,7 +157,7 @@ TEST_F(PeerConnectionSVCIntegrationTest,
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- webrtc::RtpParameters parameters = transceiver->sender()->GetParameters();
+ RtpParameters parameters = transceiver->sender()->GetParameters();
ASSERT_EQ(parameters.encodings.size(), 1u);
parameters.encodings[0].scalability_mode = "L1T3";
auto result = transceiver->sender()->SetParameters(parameters);
@@ -171,8 +169,8 @@ TEST_F(PeerConnectionSVCIntegrationTest,
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
- webrtc::RtpTransceiverInit init;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ RtpEncodingParameters encoding_parameters;
init.send_encodings.push_back(encoding_parameters);
auto transceiver_or_error =
caller()->pc()->AddTransceiver(caller()->CreateLocalVideoTrack(), init);
@@ -183,7 +181,7 @@ TEST_F(PeerConnectionSVCIntegrationTest,
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- webrtc::RtpParameters parameters = transceiver->sender()->GetParameters();
+ RtpParameters parameters = transceiver->sender()->GetParameters();
ASSERT_EQ(parameters.encodings.size(), 1u);
parameters.encodings[0].scalability_mode = "L3T3";
auto result = transceiver->sender()->SetParameters(parameters);
@@ -195,8 +193,8 @@ TEST_F(PeerConnectionSVCIntegrationTest,
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
- webrtc::RtpTransceiverInit init;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ RtpEncodingParameters encoding_parameters;
init.send_encodings.push_back(encoding_parameters);
auto transceiver_or_error =
caller()->pc()->AddTransceiver(caller()->CreateLocalVideoTrack(), init);
@@ -207,12 +205,12 @@ TEST_F(PeerConnectionSVCIntegrationTest,
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- webrtc::RtpParameters parameters = transceiver->sender()->GetParameters();
+ RtpParameters parameters = transceiver->sender()->GetParameters();
ASSERT_EQ(parameters.encodings.size(), 1u);
parameters.encodings[0].scalability_mode = "L3T3";
auto result = transceiver->sender()->SetParameters(parameters);
EXPECT_FALSE(result.ok());
- EXPECT_EQ(result.type(), webrtc::RTCErrorType::INVALID_MODIFICATION);
+ EXPECT_EQ(result.type(), RTCErrorType::INVALID_MODIFICATION);
}
TEST_F(PeerConnectionSVCIntegrationTest,
@@ -220,8 +218,8 @@ TEST_F(PeerConnectionSVCIntegrationTest,
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
- webrtc::RtpTransceiverInit init;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ RtpEncodingParameters encoding_parameters;
init.send_encodings.push_back(encoding_parameters);
auto transceiver_or_error =
caller()->pc()->AddTransceiver(caller()->CreateLocalVideoTrack(), init);
@@ -232,27 +230,27 @@ TEST_F(PeerConnectionSVCIntegrationTest,
caller()->CreateAndSetAndSignalOffer();
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
- webrtc::RtpParameters parameters = transceiver->sender()->GetParameters();
+ RtpParameters parameters = transceiver->sender()->GetParameters();
ASSERT_EQ(parameters.encodings.size(), 1u);
parameters.encodings[0].scalability_mode = "FOOBAR";
auto result = transceiver->sender()->SetParameters(parameters);
EXPECT_FALSE(result.ok());
- EXPECT_EQ(result.type(), webrtc::RTCErrorType::INVALID_MODIFICATION);
+ EXPECT_EQ(result.type(), RTCErrorType::INVALID_MODIFICATION);
}
TEST_F(PeerConnectionSVCIntegrationTest, FallbackToL1Tx) {
ASSERT_TRUE(CreatePeerConnectionWrappers());
ConnectFakeSignaling();
- webrtc::RtpTransceiverInit init;
- webrtc::RtpEncodingParameters encoding_parameters;
+ RtpTransceiverInit init;
+ RtpEncodingParameters encoding_parameters;
init.send_encodings.push_back(encoding_parameters);
auto transceiver_or_error =
caller()->pc()->AddTransceiver(caller()->CreateLocalVideoTrack(), init);
ASSERT_TRUE(transceiver_or_error.ok());
auto caller_transceiver = transceiver_or_error.MoveValue();
- webrtc::RtpCapabilities capabilities =
+ RtpCapabilities capabilities =
caller()->pc_factory()->GetRtpSenderCapabilities(
cricket::MEDIA_TYPE_VIDEO);
std::vector<RtpCodecCapability> send_codecs = capabilities.codecs;
@@ -267,8 +265,7 @@ TEST_F(PeerConnectionSVCIntegrationTest, FallbackToL1Tx) {
caller_transceiver->SetCodecPreferences(send_codecs);
// L3T3 should be supported by VP9
- webrtc::RtpParameters parameters =
- caller_transceiver->sender()->GetParameters();
+ RtpParameters parameters = caller_transceiver->sender()->GetParameters();
ASSERT_EQ(parameters.encodings.size(), 1u);
parameters.encodings[0].scalability_mode = "L3T3";
auto result = caller_transceiver->sender()->SetParameters(parameters);
diff --git a/third_party/libwebrtc/pc/peer_connection_wrapper.cc b/third_party/libwebrtc/pc/peer_connection_wrapper.cc
index 44f4256b10..557d0c8422 100644
--- a/third_party/libwebrtc/pc/peer_connection_wrapper.cc
+++ b/third_party/libwebrtc/pc/peer_connection_wrapper.cc
@@ -339,8 +339,7 @@ bool PeerConnectionWrapper::IsIceConnected() {
return observer()->ice_connected_;
}
-rtc::scoped_refptr<const webrtc::RTCStatsReport>
-PeerConnectionWrapper::GetStats() {
+rtc::scoped_refptr<const RTCStatsReport> PeerConnectionWrapper::GetStats() {
auto callback = rtc::make_ref_counted<MockRTCStatsCollectorCallback>();
pc()->GetStats(callback.get());
EXPECT_TRUE_WAIT(callback->called(), kDefaultTimeout);
diff --git a/third_party/libwebrtc/pc/rtc_stats_collector.cc b/third_party/libwebrtc/pc/rtc_stats_collector.cc
index 0797ba2a76..2bac176aac 100644
--- a/third_party/libwebrtc/pc/rtc_stats_collector.cc
+++ b/third_party/libwebrtc/pc/rtc_stats_collector.cc
@@ -336,7 +336,7 @@ const char* QualityLimitationReasonToRTCQualityLimitationReason(
std::map<std::string, double>
QualityLimitationDurationToRTCQualityLimitationDuration(
- std::map<webrtc::QualityLimitationReason, int64_t> durations_ms) {
+ std::map<QualityLimitationReason, int64_t> durations_ms) {
std::map<std::string, double> result;
// The internal duration is defined in milliseconds while the spec defines
// the value in seconds:
@@ -513,7 +513,7 @@ std::unique_ptr<RTCInboundRtpStreamStats> CreateInboundAudioStreamStats(
std::unique_ptr<RTCAudioPlayoutStats> CreateAudioPlayoutStats(
const AudioDeviceModule::Stats& audio_device_stats,
- webrtc::Timestamp timestamp) {
+ Timestamp timestamp) {
auto stats = std::make_unique<RTCAudioPlayoutStats>(
/*id=*/kAudioPlayoutSingletonId, timestamp);
stats->synthesized_samples_duration =
diff --git a/third_party/libwebrtc/pc/rtc_stats_collector.h b/third_party/libwebrtc/pc/rtc_stats_collector.h
index e94d23944c..4c68e77086 100644
--- a/third_party/libwebrtc/pc/rtc_stats_collector.h
+++ b/third_party/libwebrtc/pc/rtc_stats_collector.h
@@ -317,7 +317,7 @@ class RTCStatsCollector : public rtc::RefCountInterface {
uint32_t data_channels_closed;
// Identifies channels that have been opened, whose internal id is stored in
// the set until they have been fully closed.
- webrtc::flat_set<int> opened_data_channels;
+ flat_set<int> opened_data_channels;
};
InternalRecord internal_record_;
};
diff --git a/third_party/libwebrtc/pc/rtc_stats_collector_unittest.cc b/third_party/libwebrtc/pc/rtc_stats_collector_unittest.cc
index 37821ac829..055be6fe99 100644
--- a/third_party/libwebrtc/pc/rtc_stats_collector_unittest.cc
+++ b/third_party/libwebrtc/pc/rtc_stats_collector_unittest.cc
@@ -263,9 +263,9 @@ class FakeAudioTrackForStats : public MediaStreamTrack<AudioTrackInterface> {
std::string kind() const override {
return MediaStreamTrackInterface::kAudioKind;
}
- webrtc::AudioSourceInterface* GetSource() const override { return nullptr; }
- void AddSink(webrtc::AudioTrackSinkInterface* sink) override {}
- void RemoveSink(webrtc::AudioTrackSinkInterface* sink) override {}
+ AudioSourceInterface* GetSource() const override { return nullptr; }
+ void AddSink(AudioTrackSinkInterface* sink) override {}
+ void RemoveSink(AudioTrackSinkInterface* sink) override {}
bool GetSignalLevel(int* level) override { return false; }
rtc::scoped_refptr<AudioProcessorInterface> GetAudioProcessor() override {
return processor_;
@@ -2030,7 +2030,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCIceCandidatePairStats) {
EXPECT_TRUE(report->Get(*expected_pair.transport_id));
// Set bandwidth and "GetStats" again.
- webrtc::Call::Stats call_stats;
+ Call::Stats call_stats;
const int kSendBandwidth = 888;
call_stats.send_bandwidth_bps = kSendBandwidth;
const int kRecvBandwidth = 999;
@@ -2339,12 +2339,9 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRtpStreamStats_Video) {
video_media_info.receivers[0].key_frames_decoded = 3;
video_media_info.receivers[0].frames_dropped = 13;
video_media_info.receivers[0].qp_sum = absl::nullopt;
- video_media_info.receivers[0].total_decode_time =
- webrtc::TimeDelta::Seconds(9);
- video_media_info.receivers[0].total_processing_delay =
- webrtc::TimeDelta::Millis(600);
- video_media_info.receivers[0].total_assembly_time =
- webrtc::TimeDelta::Millis(500);
+ video_media_info.receivers[0].total_decode_time = TimeDelta::Seconds(9);
+ video_media_info.receivers[0].total_processing_delay = TimeDelta::Millis(600);
+ video_media_info.receivers[0].total_assembly_time = TimeDelta::Millis(500);
video_media_info.receivers[0].frames_assembled_from_multiple_packets = 23;
video_media_info.receivers[0].total_inter_frame_delay = 0.123;
video_media_info.receivers[0].total_squared_inter_frame_delay = 0.00456;
@@ -2617,12 +2614,12 @@ TEST_F(RTCStatsCollectorTest, CollectRTCOutboundRtpStreamStats_Video) {
video_media_info.senders[0].key_frames_encoded = 3;
video_media_info.senders[0].total_encode_time_ms = 9000;
video_media_info.senders[0].total_encoded_bytes_target = 1234;
- video_media_info.senders[0].total_packet_send_delay =
- webrtc::TimeDelta::Seconds(10);
+ video_media_info.senders[0].total_packet_send_delay = TimeDelta::Seconds(10);
video_media_info.senders[0].quality_limitation_reason =
QualityLimitationReason::kBandwidth;
- video_media_info.senders[0].quality_limitation_durations_ms
- [webrtc::QualityLimitationReason::kBandwidth] = 300;
+ video_media_info.senders[0]
+ .quality_limitation_durations_ms[QualityLimitationReason::kBandwidth] =
+ 300;
video_media_info.senders[0].quality_limitation_resolution_changes = 56u;
video_media_info.senders[0].qp_sum = absl::nullopt;
video_media_info.senders[0].content_type = VideoContentType::UNSPECIFIED;
diff --git a/third_party/libwebrtc/pc/rtc_stats_traversal_unittest.cc b/third_party/libwebrtc/pc/rtc_stats_traversal_unittest.cc
index 72ad255564..8205ebedc0 100644
--- a/third_party/libwebrtc/pc/rtc_stats_traversal_unittest.cc
+++ b/third_party/libwebrtc/pc/rtc_stats_traversal_unittest.cc
@@ -47,7 +47,7 @@ class RTCStatsTraversalTest : public ::testing::Test {
for (const RTCStats* start_node : start_nodes) {
start_ids.push_back(start_node->id());
}
- result_ = webrtc::TakeReferencedStats(initial_report_, start_ids);
+ result_ = ::webrtc::TakeReferencedStats(initial_report_, start_ids);
}
void EXPECT_VISITED(const RTCStats* stats) {
diff --git a/third_party/libwebrtc/pc/rtp_sender.cc b/third_party/libwebrtc/pc/rtp_sender.cc
index cdae1595b3..b0c32eff85 100644
--- a/third_party/libwebrtc/pc/rtp_sender.cc
+++ b/third_party/libwebrtc/pc/rtp_sender.cc
@@ -115,13 +115,13 @@ class SignalingThreadCallback {
if (!signaling_thread_->IsCurrent()) {
signaling_thread_->PostTask(
[callback = std::move(callback_), error]() mutable {
- webrtc::InvokeSetParametersCallback(callback, error);
+ InvokeSetParametersCallback(callback, error);
});
callback_ = nullptr;
return;
}
- webrtc::InvokeSetParametersCallback(callback_, error);
+ InvokeSetParametersCallback(callback_, error);
callback_ = nullptr;
}
@@ -243,7 +243,7 @@ void RtpSenderBase::SetParametersInternal(const RtpParameters& parameters,
"Attempted to set an unimplemented parameter of RtpParameters.");
RTC_LOG(LS_ERROR) << error.message() << " ("
<< ::webrtc::ToString(error.type()) << ")";
- webrtc::InvokeSetParametersCallback(callback, error);
+ InvokeSetParametersCallback(callback, error);
return;
}
if (!media_channel_ || !ssrc_) {
@@ -252,7 +252,7 @@ void RtpSenderBase::SetParametersInternal(const RtpParameters& parameters,
if (result.ok()) {
init_parameters_ = parameters;
}
- webrtc::InvokeSetParametersCallback(callback, result);
+ InvokeSetParametersCallback(callback, result);
return;
}
auto task = [&, callback = std::move(callback),
@@ -268,13 +268,13 @@ void RtpSenderBase::SetParametersInternal(const RtpParameters& parameters,
RTCError result = cricket::CheckRtpParametersInvalidModificationAndValues(
old_parameters, rtp_parameters);
if (!result.ok()) {
- webrtc::InvokeSetParametersCallback(callback, result);
+ InvokeSetParametersCallback(callback, result);
return;
}
result = CheckCodecParameters(rtp_parameters);
if (!result.ok()) {
- webrtc::InvokeSetParametersCallback(callback, result);
+ InvokeSetParametersCallback(callback, result);
return;
}
@@ -389,7 +389,7 @@ void RtpSenderBase::SetParametersAsync(const RtpParameters& parameters,
TRACE_EVENT0("webrtc", "RtpSenderBase::SetParametersAsync");
RTCError result = CheckSetParameters(parameters);
if (!result.ok()) {
- webrtc::InvokeSetParametersCallback(callback, result);
+ InvokeSetParametersCallback(callback, result);
return;
}
@@ -399,7 +399,7 @@ void RtpSenderBase::SetParametersAsync(const RtpParameters& parameters,
signaling_thread_,
[this, callback = std::move(callback)](RTCError error) mutable {
last_transaction_id_.reset();
- webrtc::InvokeSetParametersCallback(callback, error);
+ InvokeSetParametersCallback(callback, error);
}),
false);
}
diff --git a/third_party/libwebrtc/pc/rtp_sender.h b/third_party/libwebrtc/pc/rtp_sender.h
index d29c3760e6..8925230636 100644
--- a/third_party/libwebrtc/pc/rtp_sender.h
+++ b/third_party/libwebrtc/pc/rtp_sender.h
@@ -86,9 +86,7 @@ class RtpSenderInternal : public RtpSenderInterface {
const RtpParameters& parameters) = 0;
// Additional checks that are specific to the current codec settings
- virtual RTCError CheckCodecParameters(const RtpParameters& parameters) {
- return webrtc::RTCError::OK();
- }
+ virtual RTCError CheckCodecParameters(const RtpParameters& parameters) = 0;
// Returns an ID that changes every time SetTrack() is called, but
// otherwise remains constant. Used to generate IDs for stats.
diff --git a/third_party/libwebrtc/pc/rtp_sender_receiver_unittest.cc b/third_party/libwebrtc/pc/rtp_sender_receiver_unittest.cc
index 3092e53c2d..4387aedf53 100644
--- a/third_party/libwebrtc/pc/rtp_sender_receiver_unittest.cc
+++ b/third_party/libwebrtc/pc/rtp_sender_receiver_unittest.cc
@@ -105,7 +105,7 @@ class RtpSenderReceiverTest
: network_thread_(rtc::Thread::Current()),
worker_thread_(rtc::Thread::Current()),
video_bitrate_allocator_factory_(
- webrtc::CreateBuiltinVideoBitrateAllocatorFactory()),
+ CreateBuiltinVideoBitrateAllocatorFactory()),
// Create fake media engine/etc. so we can create channels to use to
// test RtpSenders/RtpReceivers.
media_engine_(std::make_unique<cricket::FakeMediaEngine>()),
@@ -119,16 +119,16 @@ class RtpSenderReceiverTest
// Fake media channels are owned by the media engine.
voice_media_send_channel_ = media_engine_->voice().CreateSendChannel(
&fake_call_, cricket::MediaConfig(), cricket::AudioOptions(),
- webrtc::CryptoOptions(), webrtc::AudioCodecPairId::Create());
+ CryptoOptions(), AudioCodecPairId::Create());
video_media_send_channel_ = media_engine_->video().CreateSendChannel(
&fake_call_, cricket::MediaConfig(), cricket::VideoOptions(),
- webrtc::CryptoOptions(), video_bitrate_allocator_factory_.get());
+ CryptoOptions(), video_bitrate_allocator_factory_.get());
voice_media_receive_channel_ = media_engine_->voice().CreateReceiveChannel(
&fake_call_, cricket::MediaConfig(), cricket::AudioOptions(),
- webrtc::CryptoOptions(), webrtc::AudioCodecPairId::Create());
+ CryptoOptions(), AudioCodecPairId::Create());
video_media_receive_channel_ = media_engine_->video().CreateReceiveChannel(
&fake_call_, cricket::MediaConfig(), cricket::VideoOptions(),
- webrtc::CryptoOptions());
+ CryptoOptions());
// Create streams for predefined SSRCs. Streams need to exist in order
// for the senders and receievers to apply parameters to them.
@@ -162,8 +162,8 @@ class RtpSenderReceiverTest
audio_track_ = nullptr;
}
- std::unique_ptr<webrtc::RtpTransportInternal> CreateDtlsSrtpTransport() {
- auto dtls_srtp_transport = std::make_unique<webrtc::DtlsSrtpTransport>(
+ std::unique_ptr<RtpTransportInternal> CreateDtlsSrtpTransport() {
+ auto dtls_srtp_transport = std::make_unique<DtlsSrtpTransport>(
/*rtcp_mux_required=*/true, field_trials_);
dtls_srtp_transport->SetDtlsTransports(rtp_dtls_transport_.get(),
/*rtcp_dtls_transport=*/nullptr);
@@ -515,12 +515,12 @@ class RtpSenderReceiverTest
test::RunLoop run_loop_;
rtc::Thread* const network_thread_;
rtc::Thread* const worker_thread_;
- webrtc::RtcEventLogNull event_log_;
+ RtcEventLogNull event_log_;
// The `rtp_dtls_transport_` and `rtp_transport_` should be destroyed after
// the `channel_manager`.
std::unique_ptr<cricket::DtlsTransportInternal> rtp_dtls_transport_;
- std::unique_ptr<webrtc::RtpTransportInternal> rtp_transport_;
- std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
+ std::unique_ptr<RtpTransportInternal> rtp_transport_;
+ std::unique_ptr<VideoBitrateAllocatorFactory>
video_bitrate_allocator_factory_;
std::unique_ptr<cricket::FakeMediaEngine> media_engine_;
rtc::UniqueRandomIdGenerator ssrc_generator_;
@@ -540,7 +540,7 @@ class RtpSenderReceiverTest
rtc::scoped_refptr<MediaStreamInterface> local_stream_;
rtc::scoped_refptr<VideoTrackInterface> video_track_;
rtc::scoped_refptr<AudioTrackInterface> audio_track_;
- webrtc::test::ScopedKeyValueConfig field_trials_;
+ test::ScopedKeyValueConfig field_trials_;
};
// Test that `voice_channel_` is updated when an audio track is associated
@@ -651,15 +651,13 @@ TEST_F(RtpSenderReceiverTest, LocalVideoTrackDisable) {
TEST_F(RtpSenderReceiverTest, RemoteVideoTrackState) {
CreateVideoRtpReceiver();
- EXPECT_EQ(webrtc::MediaStreamTrackInterface::kLive, video_track_->state());
- EXPECT_EQ(webrtc::MediaSourceInterface::kLive,
- video_track_->GetSource()->state());
+ EXPECT_EQ(MediaStreamTrackInterface::kLive, video_track_->state());
+ EXPECT_EQ(MediaSourceInterface::kLive, video_track_->GetSource()->state());
DestroyVideoRtpReceiver();
- EXPECT_EQ(webrtc::MediaStreamTrackInterface::kEnded, video_track_->state());
- EXPECT_EQ(webrtc::MediaSourceInterface::kEnded,
- video_track_->GetSource()->state());
+ EXPECT_EQ(MediaStreamTrackInterface::kEnded, video_track_->state());
+ EXPECT_EQ(MediaSourceInterface::kEnded, video_track_->GetSource()->state());
DestroyVideoRtpReceiver();
}
@@ -888,9 +886,9 @@ TEST_F(RtpSenderReceiverTest, AudioSenderCanSetParametersAsync) {
RtpParameters params = audio_rtp_sender_->GetParameters();
EXPECT_EQ(1u, params.encodings.size());
- absl::optional<webrtc::RTCError> result;
+ absl::optional<RTCError> result;
audio_rtp_sender_->SetParametersAsync(
- params, [&result](webrtc::RTCError error) { result = error; });
+ params, [&result](RTCError error) { result = error; });
run_loop_.Flush();
EXPECT_TRUE(result->ok());
@@ -918,13 +916,13 @@ TEST_F(RtpSenderReceiverTest,
audio_rtp_sender_ =
AudioRtpSender::Create(worker_thread_, /*id=*/"", nullptr, nullptr);
- absl::optional<webrtc::RTCError> result;
+ absl::optional<RTCError> result;
RtpParameters params = audio_rtp_sender_->GetParameters();
ASSERT_EQ(1u, params.encodings.size());
params.encodings[0].max_bitrate_bps = 90000;
audio_rtp_sender_->SetParametersAsync(
- params, [&result](webrtc::RTCError error) { result = error; });
+ params, [&result](RTCError error) { result = error; });
run_loop_.Flush();
EXPECT_TRUE(result->ok());
@@ -932,7 +930,7 @@ TEST_F(RtpSenderReceiverTest,
EXPECT_EQ(params.encodings[0].max_bitrate_bps, 90000);
audio_rtp_sender_->SetParametersAsync(
- params, [&result](webrtc::RTCError error) { result = error; });
+ params, [&result](RTCError error) { result = error; });
run_loop_.Flush();
EXPECT_TRUE(result->ok());
@@ -1016,13 +1014,13 @@ TEST_F(RtpSenderReceiverTest,
RtpParameters params = audio_rtp_sender_->GetParameters();
EXPECT_EQ(1u, params.encodings.size());
- absl::optional<webrtc::RTCError> result;
+ absl::optional<RTCError> result;
audio_rtp_sender_->SetParametersAsync(
- params, [&result](webrtc::RTCError error) { result = error; });
+ params, [&result](RTCError error) { result = error; });
run_loop_.Flush();
EXPECT_TRUE(result->ok());
audio_rtp_sender_->SetParametersAsync(
- params, [&result](webrtc::RTCError error) { result = error; });
+ params, [&result](RTCError error) { result = error; });
run_loop_.Flush();
EXPECT_EQ(RTCErrorType::INVALID_STATE, result->type());
@@ -1081,7 +1079,7 @@ TEST_F(RtpSenderReceiverTest, SetAudioMaxSendBitrate) {
CreateAudioRtpSender();
EXPECT_EQ(-1, voice_media_send_channel()->max_bps());
- webrtc::RtpParameters params = audio_rtp_sender_->GetParameters();
+ RtpParameters params = audio_rtp_sender_->GetParameters();
EXPECT_EQ(1U, params.encodings.size());
EXPECT_FALSE(params.encodings[0].max_bitrate_bps);
params.encodings[0].max_bitrate_bps = 1000;
@@ -1106,10 +1104,9 @@ TEST_F(RtpSenderReceiverTest, SetAudioMaxSendBitrate) {
TEST_F(RtpSenderReceiverTest, SetAudioBitratePriority) {
CreateAudioRtpSender();
- webrtc::RtpParameters params = audio_rtp_sender_->GetParameters();
+ RtpParameters params = audio_rtp_sender_->GetParameters();
EXPECT_EQ(1U, params.encodings.size());
- EXPECT_EQ(webrtc::kDefaultBitratePriority,
- params.encodings[0].bitrate_priority);
+ EXPECT_EQ(kDefaultBitratePriority, params.encodings[0].bitrate_priority);
double new_bitrate_priority = 2.0;
params.encodings[0].bitrate_priority = new_bitrate_priority;
EXPECT_TRUE(audio_rtp_sender_->SetParameters(params).ok());
@@ -1140,9 +1137,9 @@ TEST_F(RtpSenderReceiverTest, VideoSenderCanSetParametersAsync) {
RtpParameters params = video_rtp_sender_->GetParameters();
EXPECT_EQ(1u, params.encodings.size());
- absl::optional<webrtc::RTCError> result;
+ absl::optional<RTCError> result;
video_rtp_sender_->SetParametersAsync(
- params, [&result](webrtc::RTCError error) { result = error; });
+ params, [&result](RTCError error) { result = error; });
run_loop_.Flush();
EXPECT_TRUE(result->ok());
@@ -1170,19 +1167,19 @@ TEST_F(RtpSenderReceiverTest,
video_rtp_sender_ =
VideoRtpSender::Create(worker_thread_, /*id=*/"", nullptr);
- absl::optional<webrtc::RTCError> result;
+ absl::optional<RTCError> result;
RtpParameters params = video_rtp_sender_->GetParameters();
ASSERT_EQ(1u, params.encodings.size());
params.encodings[0].max_bitrate_bps = 90000;
video_rtp_sender_->SetParametersAsync(
- params, [&result](webrtc::RTCError error) { result = error; });
+ params, [&result](RTCError error) { result = error; });
run_loop_.Flush();
EXPECT_TRUE(result->ok());
params = video_rtp_sender_->GetParameters();
EXPECT_EQ(params.encodings[0].max_bitrate_bps, 90000);
video_rtp_sender_->SetParametersAsync(
- params, [&result](webrtc::RTCError error) { result = error; });
+ params, [&result](RTCError error) { result = error; });
run_loop_.Flush();
EXPECT_TRUE(result->ok());
@@ -1350,13 +1347,13 @@ TEST_F(RtpSenderReceiverTest,
RtpParameters params = video_rtp_sender_->GetParameters();
EXPECT_EQ(1u, params.encodings.size());
- absl::optional<webrtc::RTCError> result;
+ absl::optional<RTCError> result;
video_rtp_sender_->SetParametersAsync(
- params, [&result](webrtc::RTCError error) { result = error; });
+ params, [&result](RTCError error) { result = error; });
run_loop_.Flush();
EXPECT_TRUE(result->ok());
video_rtp_sender_->SetParametersAsync(
- params, [&result](webrtc::RTCError error) { result = error; });
+ params, [&result](RTCError error) { result = error; });
run_loop_.Flush();
EXPECT_EQ(RTCErrorType::INVALID_STATE, result->type());
@@ -1453,7 +1450,7 @@ TEST_F(RtpSenderReceiverTest, VideoSenderDetectInvalidNumTemporalLayers) {
CreateVideoRtpSender();
RtpParameters params = video_rtp_sender_->GetParameters();
- params.encodings[0].num_temporal_layers = webrtc::kMaxTemporalStreams + 1;
+ params.encodings[0].num_temporal_layers = kMaxTemporalStreams + 1;
RTCError result = video_rtp_sender_->SetParameters(params);
EXPECT_EQ(RTCErrorType::INVALID_RANGE, result.type());
@@ -1536,7 +1533,7 @@ TEST_F(RtpSenderReceiverTest, SetVideoMinMaxSendBitrate) {
CreateVideoRtpSender();
EXPECT_EQ(-1, video_media_send_channel()->max_bps());
- webrtc::RtpParameters params = video_rtp_sender_->GetParameters();
+ RtpParameters params = video_rtp_sender_->GetParameters();
EXPECT_EQ(1U, params.encodings.size());
EXPECT_FALSE(params.encodings[0].min_bitrate_bps);
EXPECT_FALSE(params.encodings[0].max_bitrate_bps);
@@ -1589,10 +1586,9 @@ TEST_F(RtpSenderReceiverTest, SetVideoMinMaxSendBitrateSimulcast) {
TEST_F(RtpSenderReceiverTest, SetVideoBitratePriority) {
CreateVideoRtpSender();
- webrtc::RtpParameters params = video_rtp_sender_->GetParameters();
+ RtpParameters params = video_rtp_sender_->GetParameters();
EXPECT_EQ(1U, params.encodings.size());
- EXPECT_EQ(webrtc::kDefaultBitratePriority,
- params.encodings[0].bitrate_priority);
+ EXPECT_EQ(kDefaultBitratePriority, params.encodings[0].bitrate_priority);
double new_bitrate_priority = 2.0;
params.encodings[0].bitrate_priority = new_bitrate_priority;
EXPECT_TRUE(video_rtp_sender_->SetParameters(params).ok());
diff --git a/third_party/libwebrtc/pc/rtp_transceiver.cc b/third_party/libwebrtc/pc/rtp_transceiver.cc
index 815ec9dece..ca626cc94b 100644
--- a/third_party/libwebrtc/pc/rtp_transceiver.cc
+++ b/third_party/libwebrtc/pc/rtp_transceiver.cc
@@ -542,7 +542,7 @@ bool RtpTransceiver::stopping() const {
RtpTransceiverDirection RtpTransceiver::direction() const {
if (unified_plan_ && stopping())
- return webrtc::RtpTransceiverDirection::kStopped;
+ return RtpTransceiverDirection::kStopped;
return direction_;
}
@@ -570,7 +570,7 @@ RTCError RtpTransceiver::SetDirectionWithError(
absl::optional<RtpTransceiverDirection> RtpTransceiver::current_direction()
const {
if (unified_plan_ && stopped())
- return webrtc::RtpTransceiverDirection::kStopped;
+ return RtpTransceiverDirection::kStopped;
return current_direction_;
}
@@ -604,7 +604,7 @@ void RtpTransceiver::StopSendingAndReceiving() {
});
stopping_ = true;
- direction_ = webrtc::RtpTransceiverDirection::kInactive;
+ direction_ = RtpTransceiverDirection::kInactive;
}
RTCError RtpTransceiver::StopStandard() {
diff --git a/third_party/libwebrtc/pc/rtp_transceiver.h b/third_party/libwebrtc/pc/rtp_transceiver.h
index deda5d7d61..88febb9429 100644
--- a/third_party/libwebrtc/pc/rtp_transceiver.h
+++ b/third_party/libwebrtc/pc/rtp_transceiver.h
@@ -358,20 +358,18 @@ PROXY_CONSTMETHOD0(rtc::scoped_refptr<RtpReceiverInterface>, receiver)
PROXY_CONSTMETHOD0(bool, stopped)
PROXY_CONSTMETHOD0(bool, stopping)
PROXY_CONSTMETHOD0(RtpTransceiverDirection, direction)
-PROXY_METHOD1(webrtc::RTCError, SetDirectionWithError, RtpTransceiverDirection)
+PROXY_METHOD1(RTCError, SetDirectionWithError, RtpTransceiverDirection)
PROXY_CONSTMETHOD0(absl::optional<RtpTransceiverDirection>, current_direction)
PROXY_CONSTMETHOD0(absl::optional<RtpTransceiverDirection>, fired_direction)
-PROXY_METHOD0(webrtc::RTCError, StopStandard)
+PROXY_METHOD0(RTCError, StopStandard)
PROXY_METHOD0(void, StopInternal)
-PROXY_METHOD1(webrtc::RTCError,
- SetCodecPreferences,
- rtc::ArrayView<RtpCodecCapability>)
+PROXY_METHOD1(RTCError, SetCodecPreferences, rtc::ArrayView<RtpCodecCapability>)
PROXY_CONSTMETHOD0(std::vector<RtpCodecCapability>, codec_preferences)
PROXY_CONSTMETHOD0(std::vector<RtpHeaderExtensionCapability>,
GetHeaderExtensionsToNegotiate)
PROXY_CONSTMETHOD0(std::vector<RtpHeaderExtensionCapability>,
GetNegotiatedHeaderExtensions)
-PROXY_METHOD1(webrtc::RTCError,
+PROXY_METHOD1(RTCError,
SetHeaderExtensionsToNegotiate,
rtc::ArrayView<const RtpHeaderExtensionCapability>)
END_PROXY_MAP(RtpTransceiver)
diff --git a/third_party/libwebrtc/pc/rtp_transceiver_unittest.cc b/third_party/libwebrtc/pc/rtp_transceiver_unittest.cc
index 8b4a2389ce..d75e964509 100644
--- a/third_party/libwebrtc/pc/rtp_transceiver_unittest.cc
+++ b/third_party/libwebrtc/pc/rtp_transceiver_unittest.cc
@@ -17,10 +17,11 @@
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
+#include "api/environment/environment_factory.h"
#include "api/peer_connection_interface.h"
#include "api/rtp_parameters.h"
-#include "media/base/fake_media_engine.h"
#include "media/base/media_engine.h"
+#include "pc/test/enable_fake_media.h"
#include "pc/test/mock_channel_interface.h"
#include "pc/test/mock_rtp_receiver_internal.h"
#include "pc/test/mock_rtp_sender_internal.h"
@@ -44,7 +45,8 @@ class RtpTransceiverTest : public testing::Test {
public:
RtpTransceiverTest()
: dependencies_(MakeDependencies()),
- context_(ConnectionContext::Create(&dependencies_)) {}
+ context_(
+ ConnectionContext::Create(CreateEnvironment(), &dependencies_)) {}
protected:
cricket::MediaEngineInterface* media_engine() {
@@ -60,7 +62,7 @@ class RtpTransceiverTest : public testing::Test {
d.network_thread = rtc::Thread::Current();
d.worker_thread = rtc::Thread::Current();
d.signaling_thread = rtc::Thread::Current();
- d.media_engine = std::make_unique<cricket::FakeMediaEngine>();
+ EnableFakeMedia(d);
return d;
}
@@ -420,8 +422,8 @@ TEST_F(RtpTransceiverTestForHeaderExtensions, ReturnsNegotiatedHdrExts) {
EXPECT_CALL(*mock_channel, mid()).WillRepeatedly(ReturnRef(content_name));
EXPECT_CALL(*mock_channel, SetRtpTransport(_)).WillRepeatedly(Return(true));
- cricket::RtpHeaderExtensions extensions = {webrtc::RtpExtension("uri1", 1),
- webrtc::RtpExtension("uri2", 2)};
+ cricket::RtpHeaderExtensions extensions = {RtpExtension("uri1", 1),
+ RtpExtension("uri2", 2)};
cricket::AudioContentDescription description;
description.set_rtp_header_extensions(extensions);
transceiver_->OnNegotiationUpdate(SdpType::kAnswer, &description);
@@ -449,8 +451,8 @@ TEST_F(RtpTransceiverTestForHeaderExtensions,
EXPECT_CALL(*sender_.get(), SetTransceiverAsStopped());
EXPECT_CALL(*sender_.get(), Stop());
- cricket::RtpHeaderExtensions extensions = {webrtc::RtpExtension("uri1", 1),
- webrtc::RtpExtension("uri2", 2)};
+ cricket::RtpHeaderExtensions extensions = {RtpExtension("uri1", 1),
+ RtpExtension("uri2", 2)};
cricket::AudioContentDescription description;
description.set_rtp_header_extensions(extensions);
transceiver_->OnNegotiationUpdate(SdpType::kAnswer, &description);
@@ -464,8 +466,7 @@ TEST_F(RtpTransceiverTestForHeaderExtensions,
RtpTransceiverDirection::kStopped),
Field(&RtpHeaderExtensionCapability::direction,
RtpTransceiverDirection::kStopped)));
- extensions = {webrtc::RtpExtension("uri3", 4),
- webrtc::RtpExtension("uri5", 6)};
+ extensions = {RtpExtension("uri3", 4), RtpExtension("uri5", 6)};
description.set_rtp_header_extensions(extensions);
transceiver_->OnNegotiationUpdate(SdpType::kAnswer, &description);
diff --git a/third_party/libwebrtc/pc/rtp_transport.cc b/third_party/libwebrtc/pc/rtp_transport.cc
index 653b51fd9e..7cf9fe0ace 100644
--- a/third_party/libwebrtc/pc/rtp_transport.cc
+++ b/third_party/libwebrtc/pc/rtp_transport.cc
@@ -180,12 +180,16 @@ bool RtpTransport::UnregisterRtpDemuxerSink(RtpPacketSinkInterface* sink) {
return true;
}
+flat_set<uint32_t> RtpTransport::GetSsrcsForSink(RtpPacketSinkInterface* sink) {
+ return rtp_demuxer_.GetSsrcsForSink(sink);
+}
+
void RtpTransport::DemuxPacket(rtc::CopyOnWriteBuffer packet,
int64_t packet_time_us) {
- webrtc::RtpPacketReceived parsed_packet(
- &header_extension_map_, packet_time_us == -1
- ? Timestamp::MinusInfinity()
- : Timestamp::Micros(packet_time_us));
+ RtpPacketReceived parsed_packet(&header_extension_map_,
+ packet_time_us == -1
+ ? Timestamp::MinusInfinity()
+ : Timestamp::Micros(packet_time_us));
if (!parsed_packet.Parse(std::move(packet))) {
RTC_LOG(LS_ERROR)
<< "Failed to parse the incoming RTP packet before demuxing. Drop it.";
@@ -226,7 +230,14 @@ void RtpTransport::OnSentPacket(rtc::PacketTransportInternal* packet_transport,
const rtc::SentPacket& sent_packet) {
RTC_DCHECK(packet_transport == rtp_packet_transport_ ||
packet_transport == rtcp_packet_transport_);
+ if (processing_sent_packet_) {
+ TaskQueueBase::Current()->PostTask(SafeTask(
+ safety_.flag(), [this, sent_packet] { SendSentPacket(sent_packet); }));
+ return;
+ }
+ processing_sent_packet_ = true;
SendSentPacket(sent_packet);
+ processing_sent_packet_ = false;
}
void RtpTransport::OnRtpPacketReceived(rtc::CopyOnWriteBuffer packet,
diff --git a/third_party/libwebrtc/pc/rtp_transport.h b/third_party/libwebrtc/pc/rtp_transport.h
index 456c91c370..6d5d4bff57 100644
--- a/third_party/libwebrtc/pc/rtp_transport.h
+++ b/third_party/libwebrtc/pc/rtp_transport.h
@@ -96,6 +96,7 @@ class RtpTransport : public RtpTransportInternal {
rtc::CopyOnWriteBuffer* packet,
const rtc::PacketOptions& options,
int flags);
+ flat_set<uint32_t> GetSsrcsForSink(RtpPacketSinkInterface* sink);
// Overridden by SrtpTransport.
virtual void OnNetworkRouteChanged(
@@ -140,6 +141,7 @@ class RtpTransport : public RtpTransportInternal {
RtpHeaderExtensionMap header_extension_map_;
// Guard against recursive "ready to send" signals
bool processing_ready_to_send_ = false;
+ bool processing_sent_packet_ = false;
ScopedTaskSafety safety_;
};
diff --git a/third_party/libwebrtc/pc/rtp_transport_internal.h b/third_party/libwebrtc/pc/rtp_transport_internal.h
index 4114fa9340..483a1cee38 100644
--- a/third_party/libwebrtc/pc/rtp_transport_internal.h
+++ b/third_party/libwebrtc/pc/rtp_transport_internal.h
@@ -72,7 +72,7 @@ class RtpTransportInternal : public sigslot::has_slots<> {
// Called whenever a RTP packet that can not be demuxed by the transport is
// received.
void SetUnDemuxableRtpPacketReceivedHandler(
- absl::AnyInvocable<void(webrtc::RtpPacketReceived&)> callback) {
+ absl::AnyInvocable<void(RtpPacketReceived&)> callback) {
callback_undemuxable_rtp_packet_received_ = std::move(callback);
}
@@ -160,7 +160,7 @@ class RtpTransportInternal : public sigslot::has_slots<> {
CallbackList<bool> callback_list_ready_to_send_;
CallbackList<rtc::CopyOnWriteBuffer*, int64_t>
callback_list_rtcp_packet_received_;
- absl::AnyInvocable<void(webrtc::RtpPacketReceived&)>
+ absl::AnyInvocable<void(RtpPacketReceived&)>
callback_undemuxable_rtp_packet_received_ =
[](RtpPacketReceived& packet) {};
CallbackList<absl::optional<rtc::NetworkRoute>>
diff --git a/third_party/libwebrtc/pc/rtp_transport_unittest.cc b/third_party/libwebrtc/pc/rtp_transport_unittest.cc
index 5b6a8309e0..6b8e616799 100644
--- a/third_party/libwebrtc/pc/rtp_transport_unittest.cc
+++ b/third_party/libwebrtc/pc/rtp_transport_unittest.cc
@@ -349,4 +349,28 @@ TEST(RtpTransportTest, RecursiveSetSendDoesNotCrash) {
EXPECT_FALSE(observer.ready_to_send());
}
+TEST(RtpTransportTest, RecursiveOnSentPacketDoesNotCrash) {
+ const int kShortTimeout = 100;
+ test::RunLoop loop;
+ RtpTransport transport(kMuxEnabled);
+ rtc::FakePacketTransport fake_rtp("fake_rtp");
+ transport.SetRtpPacketTransport(&fake_rtp);
+ fake_rtp.SetDestination(&fake_rtp, true);
+ TransportObserver observer(&transport);
+ const rtc::PacketOptions options;
+ const int flags = 0;
+
+ fake_rtp.SetWritable(true);
+ observer.SetActionOnSentPacket([&]() {
+ rtc::CopyOnWriteBuffer rtp_data(kRtpData, kRtpLen);
+ if (observer.sent_packet_count() < 2) {
+ transport.SendRtpPacket(&rtp_data, options, flags);
+ }
+ });
+ rtc::CopyOnWriteBuffer rtp_data(kRtpData, kRtpLen);
+ transport.SendRtpPacket(&rtp_data, options, flags);
+ EXPECT_EQ(observer.sent_packet_count(), 1);
+ EXPECT_EQ_WAIT(observer.sent_packet_count(), 2, kShortTimeout);
+}
+
} // namespace webrtc
diff --git a/third_party/libwebrtc/pc/sctp_transport.h b/third_party/libwebrtc/pc/sctp_transport.h
index 35e7656100..076dee5318 100644
--- a/third_party/libwebrtc/pc/sctp_transport.h
+++ b/third_party/libwebrtc/pc/sctp_transport.h
@@ -61,7 +61,7 @@ class SctpTransport : public SctpTransportInterface,
void Start(int local_port, int remote_port, int max_message_size);
// TODO(https://bugs.webrtc.org/10629): Move functions that need
- // internal() to be functions on the webrtc::SctpTransport interface,
+ // internal() to be functions on the SctpTransport interface,
// and make the internal() function private.
cricket::SctpTransportInternal* internal() {
RTC_DCHECK_RUN_ON(owner_thread_);
diff --git a/third_party/libwebrtc/pc/sctp_utils.cc b/third_party/libwebrtc/pc/sctp_utils.cc
index 54742c27a7..60ffdc7919 100644
--- a/third_party/libwebrtc/pc/sctp_utils.cc
+++ b/third_party/libwebrtc/pc/sctp_utils.cc
@@ -64,7 +64,7 @@ bool ParseDataChannelOpenMessage(const rtc::CopyOnWriteBuffer& payload,
// Format defined at
// http://tools.ietf.org/html/draft-jesup-rtcweb-data-protocol-04
- rtc::ByteBufferReader buffer(payload.data<char>(), payload.size());
+ rtc::ByteBufferReader buffer(payload);
uint8_t message_type;
if (!buffer.ReadUInt8(&message_type)) {
RTC_LOG(LS_WARNING) << "Could not read OPEN message type.";
diff --git a/third_party/libwebrtc/pc/sctp_utils_unittest.cc b/third_party/libwebrtc/pc/sctp_utils_unittest.cc
index 3e49824b45..9ef2068a05 100644
--- a/third_party/libwebrtc/pc/sctp_utils_unittest.cc
+++ b/third_party/libwebrtc/pc/sctp_utils_unittest.cc
@@ -35,7 +35,7 @@ class SctpUtilsTest : public ::testing::Test {
uint16_t label_length;
uint16_t protocol_length;
- rtc::ByteBufferReader buffer(packet.data<char>(), packet.size());
+ rtc::ByteBufferReader buffer(packet);
ASSERT_TRUE(buffer.ReadUInt8(&message_type));
EXPECT_EQ(0x03, message_type);
@@ -176,7 +176,7 @@ TEST_F(SctpUtilsTest, WriteParseAckMessage) {
webrtc::WriteDataChannelOpenAckMessage(&packet);
uint8_t message_type;
- rtc::ByteBufferReader buffer(packet.data<char>(), packet.size());
+ rtc::ByteBufferReader buffer(packet);
ASSERT_TRUE(buffer.ReadUInt8(&message_type));
EXPECT_EQ(0x02, message_type);
diff --git a/third_party/libwebrtc/pc/sdp_offer_answer.cc b/third_party/libwebrtc/pc/sdp_offer_answer.cc
index 0261195bb0..1e43833a0b 100644
--- a/third_party/libwebrtc/pc/sdp_offer_answer.cc
+++ b/third_party/libwebrtc/pc/sdp_offer_answer.cc
@@ -86,8 +86,7 @@ namespace webrtc {
namespace {
-typedef webrtc::PeerConnectionInterface::RTCOfferAnswerOptions
- RTCOfferAnswerOptions;
+typedef PeerConnectionInterface::RTCOfferAnswerOptions RTCOfferAnswerOptions;
// Error messages
const char kInvalidSdp[] = "Invalid session description.";
@@ -566,22 +565,9 @@ RTCError ValidatePayloadTypes(const cricket::SessionDescription& description) {
continue;
}
const auto type = media_description->type();
- if (type == cricket::MEDIA_TYPE_AUDIO) {
- RTC_DCHECK(media_description->as_audio());
- for (const auto& codec : media_description->as_audio()->codecs()) {
- if (!cricket::UsedPayloadTypes::IsIdValid(
- codec, media_description->rtcp_mux())) {
- LOG_AND_RETURN_ERROR(
- RTCErrorType::INVALID_PARAMETER,
- "The media section with MID='" + content.mid() +
- "' used an invalid payload type " + rtc::ToString(codec.id) +
- " for codec '" + codec.name + ", rtcp-mux:" +
- (media_description->rtcp_mux() ? "enabled" : "disabled"));
- }
- }
- } else if (type == cricket::MEDIA_TYPE_VIDEO) {
- RTC_DCHECK(media_description->as_video());
- for (const auto& codec : media_description->as_video()->codecs()) {
+ if (type == cricket::MEDIA_TYPE_AUDIO ||
+ type == cricket::MEDIA_TYPE_VIDEO) {
+ for (const auto& codec : media_description->codecs()) {
if (!cricket::UsedPayloadTypes::IsIdValid(
codec, media_description->rtcp_mux())) {
LOG_AND_RETURN_ERROR(
@@ -834,8 +820,8 @@ std::string GenerateRtcpCname() {
}
// Check if we can send `new_stream` on a PeerConnection.
-bool CanAddLocalMediaStream(webrtc::StreamCollectionInterface* current_streams,
- webrtc::MediaStreamInterface* new_stream) {
+bool CanAddLocalMediaStream(StreamCollectionInterface* current_streams,
+ MediaStreamInterface* new_stream) {
if (!new_stream || !current_streams) {
return false;
}
@@ -847,7 +833,7 @@ bool CanAddLocalMediaStream(webrtc::StreamCollectionInterface* current_streams,
return true;
}
-rtc::scoped_refptr<webrtc::DtlsTransport> LookupDtlsTransportByMid(
+rtc::scoped_refptr<DtlsTransport> LookupDtlsTransportByMid(
rtc::Thread* network_thread,
JsepTransportController* controller,
const std::string& mid) {
@@ -1888,8 +1874,8 @@ RTCError SdpOfferAnswerHandler::ApplyLocalDescription(
if (audio_content->rejected) {
RemoveSenders(cricket::MEDIA_TYPE_AUDIO);
} else {
- const cricket::AudioContentDescription* audio_desc =
- audio_content->media_description()->as_audio();
+ const cricket::MediaContentDescription* audio_desc =
+ audio_content->media_description();
UpdateLocalSenders(audio_desc->streams(), audio_desc->type());
}
}
@@ -1900,8 +1886,8 @@ RTCError SdpOfferAnswerHandler::ApplyLocalDescription(
if (video_content->rejected) {
RemoveSenders(cricket::MEDIA_TYPE_VIDEO);
} else {
- const cricket::VideoContentDescription* video_desc =
- video_content->media_description()->as_video();
+ const cricket::MediaContentDescription* video_desc =
+ video_content->media_description();
UpdateLocalSenders(video_desc->streams(), video_desc->type());
}
}
@@ -2010,8 +1996,11 @@ RTCError SdpOfferAnswerHandler::ReplaceRemoteDescription(
const cricket::SessionDescription* session_desc =
remote_description()->description();
+ const auto* local = local_description();
+
// NOTE: This will perform a BlockingCall() to the network thread.
- return transport_controller_s()->SetRemoteDescription(sdp_type, session_desc);
+ return transport_controller_s()->SetRemoteDescription(
+ sdp_type, local ? local->description() : nullptr, session_desc);
}
void SdpOfferAnswerHandler::ApplyRemoteDescription(
@@ -4932,13 +4921,15 @@ RTCError SdpOfferAnswerHandler::PushdownTransportDescription(
if (source == cricket::CS_LOCAL) {
const SessionDescriptionInterface* sdesc = local_description();
RTC_DCHECK(sdesc);
- return transport_controller_s()->SetLocalDescription(type,
- sdesc->description());
+ const auto* remote = remote_description();
+ return transport_controller_s()->SetLocalDescription(
+ type, sdesc->description(), remote ? remote->description() : nullptr);
} else {
const SessionDescriptionInterface* sdesc = remote_description();
RTC_DCHECK(sdesc);
- return transport_controller_s()->SetRemoteDescription(type,
- sdesc->description());
+ const auto* local = local_description();
+ return transport_controller_s()->SetRemoteDescription(
+ type, local ? local->description() : nullptr, sdesc->description());
}
}
@@ -5366,44 +5357,40 @@ bool SdpOfferAnswerHandler::UpdatePayloadTypeDemuxingState(
// Ignore transceivers that are not receiving.
continue;
}
- switch (content_info.media_description()->type()) {
- case cricket::MediaType::MEDIA_TYPE_AUDIO: {
- if (!mid_header_extension_missing_audio) {
- mid_header_extension_missing_audio =
- !ContentHasHeaderExtension(content_info, RtpExtension::kMidUri);
- }
- const cricket::AudioContentDescription* audio_desc =
- content_info.media_description()->as_audio();
- for (const cricket::AudioCodec& audio : audio_desc->codecs()) {
- if (payload_types->audio_payload_types.count(audio.id)) {
+ const cricket::MediaType media_type =
+ content_info.media_description()->type();
+ if (media_type == cricket::MediaType::MEDIA_TYPE_AUDIO ||
+ media_type == cricket::MediaType::MEDIA_TYPE_VIDEO) {
+ if (media_type == cricket::MediaType::MEDIA_TYPE_AUDIO &&
+ !mid_header_extension_missing_audio) {
+ mid_header_extension_missing_audio =
+ !ContentHasHeaderExtension(content_info, RtpExtension::kMidUri);
+ } else if (media_type == cricket::MEDIA_TYPE_VIDEO &&
+ !mid_header_extension_missing_video) {
+ mid_header_extension_missing_video =
+ !ContentHasHeaderExtension(content_info, RtpExtension::kMidUri);
+ }
+ const cricket::MediaContentDescription* media_desc =
+ content_info.media_description();
+ for (const cricket::Codec& codec : media_desc->codecs()) {
+ if (media_type == cricket::MediaType::MEDIA_TYPE_AUDIO) {
+ if (payload_types->audio_payload_types.count(codec.id)) {
// Two m= sections are using the same payload type, thus demuxing
// by payload type is not possible.
- payload_types->pt_demuxing_possible_audio = false;
+ if (media_type == cricket::MediaType::MEDIA_TYPE_AUDIO) {
+ payload_types->pt_demuxing_possible_audio = false;
+ }
}
- payload_types->audio_payload_types.insert(audio.id);
- }
- break;
- }
- case cricket::MediaType::MEDIA_TYPE_VIDEO: {
- if (!mid_header_extension_missing_video) {
- mid_header_extension_missing_video =
- !ContentHasHeaderExtension(content_info, RtpExtension::kMidUri);
- }
- const cricket::VideoContentDescription* video_desc =
- content_info.media_description()->as_video();
- for (const cricket::VideoCodec& video : video_desc->codecs()) {
- if (payload_types->video_payload_types.count(video.id)) {
+ payload_types->audio_payload_types.insert(codec.id);
+ } else if (media_type == cricket::MEDIA_TYPE_VIDEO) {
+ if (payload_types->video_payload_types.count(codec.id)) {
// Two m= sections are using the same payload type, thus demuxing
// by payload type is not possible.
payload_types->pt_demuxing_possible_video = false;
}
- payload_types->video_payload_types.insert(video.id);
+ payload_types->video_payload_types.insert(codec.id);
}
- break;
}
- default:
- // Ignore data channels.
- continue;
}
}
diff --git a/third_party/libwebrtc/pc/sdp_offer_answer.h b/third_party/libwebrtc/pc/sdp_offer_answer.h
index 8aa7040b16..88ddfe0332 100644
--- a/third_party/libwebrtc/pc/sdp_offer_answer.h
+++ b/third_party/libwebrtc/pc/sdp_offer_answer.h
@@ -674,8 +674,8 @@ class SdpOfferAnswerHandler : public SdpStateProvider {
// or else the CreateBuiltinVideoBitrateAllocatorFactory() will be called.
// Note that one can still choose to override this in a MediaEngine
// if one wants too.
- std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
- video_bitrate_allocator_factory_ RTC_GUARDED_BY(signaling_thread());
+ std::unique_ptr<VideoBitrateAllocatorFactory> video_bitrate_allocator_factory_
+ RTC_GUARDED_BY(signaling_thread());
// Whether we are the initial offerer on the association. This
// determines the SSL role.
diff --git a/third_party/libwebrtc/pc/sdp_offer_answer_unittest.cc b/third_party/libwebrtc/pc/sdp_offer_answer_unittest.cc
index 94ceff10ac..f158febac7 100644
--- a/third_party/libwebrtc/pc/sdp_offer_answer_unittest.cc
+++ b/third_party/libwebrtc/pc/sdp_offer_answer_unittest.cc
@@ -88,7 +88,7 @@ class SdpOfferAnswerTest : public ::testing::Test {
Dav1dDecoderTemplateAdapter>>(),
nullptr /* audio_mixer */,
nullptr /* audio_processing */)) {
- webrtc::metrics::Reset();
+ metrics::Reset();
}
std::unique_ptr<PeerConnectionWrapper> CreatePeerConnection() {
@@ -168,8 +168,8 @@ TEST_F(SdpOfferAnswerTest, BundleRejectsCodecCollisionsAudioVideo) {
// There is no error yet but the metrics counter will increase.
EXPECT_TRUE(error.ok());
EXPECT_METRIC_EQ(
- 1, webrtc::metrics::NumEvents(
- "WebRTC.PeerConnection.ValidBundledPayloadTypes", false));
+ 1, metrics::NumEvents("WebRTC.PeerConnection.ValidBundledPayloadTypes",
+ false));
// Tolerate codec collisions in rejected m-lines.
pc = CreatePeerConnection();
@@ -178,9 +178,9 @@ TEST_F(SdpOfferAnswerTest, BundleRejectsCodecCollisionsAudioVideo) {
absl::StrReplaceAll(sdp, {{"m=video 9 ", "m=video 0 "}}));
pc->SetRemoteDescription(std::move(rejected_offer), &error);
EXPECT_TRUE(error.ok());
- EXPECT_METRIC_EQ(1,
- webrtc::metrics::NumEvents(
- "WebRTC.PeerConnection.ValidBundledPayloadTypes", true));
+ EXPECT_METRIC_EQ(
+ 1, metrics::NumEvents("WebRTC.PeerConnection.ValidBundledPayloadTypes",
+ true));
}
TEST_F(SdpOfferAnswerTest, BundleRejectsCodecCollisionsVideoFmtp) {
@@ -221,8 +221,8 @@ TEST_F(SdpOfferAnswerTest, BundleRejectsCodecCollisionsVideoFmtp) {
pc->SetRemoteDescription(std::move(desc), &error);
EXPECT_TRUE(error.ok());
EXPECT_METRIC_EQ(
- 1, webrtc::metrics::NumEvents(
- "WebRTC.PeerConnection.ValidBundledPayloadTypes", false));
+ 1, metrics::NumEvents("WebRTC.PeerConnection.ValidBundledPayloadTypes",
+ false));
}
TEST_F(SdpOfferAnswerTest, BundleCodecCollisionInDifferentBundlesAllowed) {
@@ -264,8 +264,8 @@ TEST_F(SdpOfferAnswerTest, BundleCodecCollisionInDifferentBundlesAllowed) {
pc->SetRemoteDescription(std::move(desc), &error);
EXPECT_TRUE(error.ok());
EXPECT_METRIC_EQ(
- 0, webrtc::metrics::NumEvents(
- "WebRTC.PeerConnection.ValidBundledPayloadTypes", false));
+ 0, metrics::NumEvents("WebRTC.PeerConnection.ValidBundledPayloadTypes",
+ false));
}
TEST_F(SdpOfferAnswerTest, BundleMeasuresHeaderExtensionIdCollision) {
@@ -990,8 +990,7 @@ TEST_F(SdpOfferAnswerTest, SdpMungingWithInvalidPayloadTypeIsRejected) {
auto offer = pc->CreateOffer();
ASSERT_EQ(offer->description()->contents().size(), 1u);
- auto* audio =
- offer->description()->contents()[0].media_description()->as_audio();
+ auto* audio = offer->description()->contents()[0].media_description();
ASSERT_GT(audio->codecs().size(), 0u);
EXPECT_TRUE(audio->rtcp_mux());
auto codecs = audio->codecs();
diff --git a/third_party/libwebrtc/pc/slow_peer_connection_integration_test.cc b/third_party/libwebrtc/pc/slow_peer_connection_integration_test.cc
index fd9d3417df..9e49291d94 100644
--- a/third_party/libwebrtc/pc/slow_peer_connection_integration_test.cc
+++ b/third_party/libwebrtc/pc/slow_peer_connection_integration_test.cc
@@ -67,7 +67,7 @@ class FakeClockForTest : public rtc::ScopedFakeClock {
// Some things use a time of "0" as a special value, so we need to start out
// the fake clock at a nonzero time.
// TODO(deadbeef): Fix this.
- AdvanceTime(webrtc::TimeDelta::Seconds(1000));
+ AdvanceTime(TimeDelta::Seconds(1000));
}
// Explicit handle.
@@ -170,20 +170,20 @@ TEST_P(PeerConnectionIntegrationTest,
CreateTurnServer(turn_server_internal_address, turn_server_external_address,
cricket::PROTO_TLS, "88.88.88.0");
- webrtc::PeerConnectionInterface::IceServer ice_server;
+ PeerConnectionInterface::IceServer ice_server;
ice_server.urls.push_back("turns:88.88.88.0:3478?transport=tcp");
ice_server.username = "test";
ice_server.password = "test";
PeerConnectionInterface::RTCConfiguration client_1_config;
client_1_config.servers.push_back(ice_server);
- client_1_config.type = webrtc::PeerConnectionInterface::kRelay;
+ client_1_config.type = PeerConnectionInterface::kRelay;
PeerConnectionInterface::RTCConfiguration client_2_config;
client_2_config.servers.push_back(ice_server);
// Setting the type to kRelay forces the connection to go through a TURN
// server.
- client_2_config.type = webrtc::PeerConnectionInterface::kRelay;
+ client_2_config.type = PeerConnectionInterface::kRelay;
// Get a copy to the pointer so we can verify calls later.
rtc::TestCertificateVerifier* client_1_cert_verifier =
@@ -194,10 +194,10 @@ TEST_P(PeerConnectionIntegrationTest,
client_2_cert_verifier->verify_certificate_ = false;
// Create the dependencies with the test certificate verifier.
- webrtc::PeerConnectionDependencies client_1_deps(nullptr);
+ PeerConnectionDependencies client_1_deps(nullptr);
client_1_deps.tls_cert_verifier =
std::unique_ptr<rtc::TestCertificateVerifier>(client_1_cert_verifier);
- webrtc::PeerConnectionDependencies client_2_deps(nullptr);
+ PeerConnectionDependencies client_2_deps(nullptr);
client_2_deps.tls_cert_verifier =
std::unique_ptr<rtc::TestCertificateVerifier>(client_2_cert_verifier);
@@ -262,8 +262,8 @@ class PeerConnectionIntegrationIceStatesTest
}
void StartStunServer(const SocketAddress& server_address) {
- stun_server_.reset(
- cricket::TestStunServer::Create(firewall(), server_address));
+ stun_server_ = cricket::TestStunServer::Create(firewall(), server_address,
+ *network_thread());
}
bool TestIPv6() {
@@ -309,7 +309,7 @@ class PeerConnectionIntegrationIceStatesTest
private:
uint32_t port_allocator_flags_;
- std::unique_ptr<cricket::TestStunServer> stun_server_;
+ cricket::TestStunServer::StunServerPtr stun_server_;
};
// Ensure FakeClockForTest is constructed first (see class for rationale).
diff --git a/third_party/libwebrtc/pc/srtp_session.cc b/third_party/libwebrtc/pc/srtp_session.cc
index 5408d3e0da..f16679cef1 100644
--- a/third_party/libwebrtc/pc/srtp_session.cc
+++ b/third_party/libwebrtc/pc/srtp_session.cc
@@ -332,6 +332,12 @@ bool SrtpSession::IsExternalAuthActive() const {
return external_auth_active_;
}
+bool SrtpSession::RemoveSsrcFromSession(uint32_t ssrc) {
+ RTC_DCHECK(session_);
+ // libSRTP expects the SSRC to be in network byte order.
+ return srtp_remove_stream(session_, htonl(ssrc)) == srtp_err_status_ok;
+}
+
bool SrtpSession::GetSendStreamPacketIndex(void* p,
int in_len,
int64_t* index) {
diff --git a/third_party/libwebrtc/pc/srtp_session.h b/third_party/libwebrtc/pc/srtp_session.h
index 60f1860ada..f8fd3e3123 100644
--- a/third_party/libwebrtc/pc/srtp_session.h
+++ b/third_party/libwebrtc/pc/srtp_session.h
@@ -97,6 +97,14 @@ class SrtpSession {
// been set.
bool IsExternalAuthActive() const;
+ // Removes a SSRC from the underlying libSRTP session.
+ // Note: this should only be done for SSRCs that are received.
+ // Removing SSRCs that were sent and then reusing them leads to
+ // cryptographic weaknesses described in
+ // https://www.rfc-editor.org/rfc/rfc3711#section-8
+ // https://www.rfc-editor.org/rfc/rfc7714#section-8.4
+ bool RemoveSsrcFromSession(uint32_t ssrc);
+
private:
bool DoSetKey(int type,
int crypto_suite,
diff --git a/third_party/libwebrtc/pc/srtp_session_unittest.cc b/third_party/libwebrtc/pc/srtp_session_unittest.cc
index 16a840a307..7adfee86fd 100644
--- a/third_party/libwebrtc/pc/srtp_session_unittest.cc
+++ b/third_party/libwebrtc/pc/srtp_session_unittest.cc
@@ -251,4 +251,36 @@ TEST_F(SrtpSessionTest, TestReplay) {
s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), &out_len));
}
+TEST_F(SrtpSessionTest, RemoveSsrc) {
+ EXPECT_TRUE(s1_.SetSend(kSrtpAes128CmSha1_80, kTestKey1, kTestKeyLen,
+ kEncryptedHeaderExtensionIds));
+ EXPECT_TRUE(s2_.SetRecv(kSrtpAes128CmSha1_80, kTestKey1, kTestKeyLen,
+ kEncryptedHeaderExtensionIds));
+ int out_len;
+ // Encrypt and decrypt the packet once.
+ EXPECT_TRUE(
+ s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), &out_len));
+ EXPECT_TRUE(s2_.UnprotectRtp(rtp_packet_, out_len, &out_len));
+ EXPECT_EQ(rtp_len_, out_len);
+ EXPECT_EQ(0, memcmp(rtp_packet_, kPcmuFrame, out_len));
+
+ // Recreate the original packet and encrypt again.
+ memcpy(rtp_packet_, kPcmuFrame, rtp_len_);
+ EXPECT_TRUE(
+ s1_.ProtectRtp(rtp_packet_, rtp_len_, sizeof(rtp_packet_), &out_len));
+ // Attempting to decrypt will fail as a replay attack.
+ // (srtp_err_status_replay_fail) since the sequence number was already seen.
+ EXPECT_FALSE(s2_.UnprotectRtp(rtp_packet_, out_len, &out_len));
+
+ // Remove the fake packet SSRC 1 from the session.
+ EXPECT_TRUE(s2_.RemoveSsrcFromSession(1));
+ EXPECT_FALSE(s2_.RemoveSsrcFromSession(1));
+
+ // Since the SRTP state was discarded, this is no longer a replay attack.
+ EXPECT_TRUE(s2_.UnprotectRtp(rtp_packet_, out_len, &out_len));
+ EXPECT_EQ(rtp_len_, out_len);
+ EXPECT_EQ(0, memcmp(rtp_packet_, kPcmuFrame, out_len));
+ EXPECT_TRUE(s2_.RemoveSsrcFromSession(1));
+}
+
} // namespace rtc
diff --git a/third_party/libwebrtc/pc/srtp_transport.cc b/third_party/libwebrtc/pc/srtp_transport.cc
index cc20216672..c82839ca82 100644
--- a/third_party/libwebrtc/pc/srtp_transport.cc
+++ b/third_party/libwebrtc/pc/srtp_transport.cc
@@ -37,86 +37,6 @@ SrtpTransport::SrtpTransport(bool rtcp_mux_enabled,
const FieldTrialsView& field_trials)
: RtpTransport(rtcp_mux_enabled), field_trials_(field_trials) {}
-RTCError SrtpTransport::SetSrtpSendKey(const cricket::CryptoParams& params) {
- if (send_params_) {
- LOG_AND_RETURN_ERROR(
- webrtc::RTCErrorType::UNSUPPORTED_OPERATION,
- "Setting the SRTP send key twice is currently unsupported.");
- }
- if (recv_params_ && recv_params_->crypto_suite != params.crypto_suite) {
- LOG_AND_RETURN_ERROR(
- webrtc::RTCErrorType::UNSUPPORTED_OPERATION,
- "The send key and receive key must have the same cipher suite.");
- }
-
- send_crypto_suite_ = rtc::SrtpCryptoSuiteFromName(params.crypto_suite);
- if (*send_crypto_suite_ == rtc::kSrtpInvalidCryptoSuite) {
- return RTCError(RTCErrorType::INVALID_PARAMETER,
- "Invalid SRTP crypto suite");
- }
-
- int send_key_len, send_salt_len;
- if (!rtc::GetSrtpKeyAndSaltLengths(*send_crypto_suite_, &send_key_len,
- &send_salt_len)) {
- return RTCError(RTCErrorType::INVALID_PARAMETER,
- "Could not get lengths for crypto suite(s):"
- " send crypto_suite ");
- }
-
- send_key_ = rtc::ZeroOnFreeBuffer<uint8_t>(send_key_len + send_salt_len);
- if (!ParseKeyParams(params.key_params, send_key_.data(), send_key_.size())) {
- return RTCError(RTCErrorType::INVALID_PARAMETER,
- "Failed to parse the crypto key params");
- }
-
- if (!MaybeSetKeyParams()) {
- return RTCError(RTCErrorType::INVALID_PARAMETER,
- "Failed to set the crypto key params");
- }
- send_params_ = params;
- return RTCError::OK();
-}
-
-RTCError SrtpTransport::SetSrtpReceiveKey(const cricket::CryptoParams& params) {
- if (recv_params_) {
- LOG_AND_RETURN_ERROR(
- webrtc::RTCErrorType::UNSUPPORTED_OPERATION,
- "Setting the SRTP send key twice is currently unsupported.");
- }
- if (send_params_ && send_params_->crypto_suite != params.crypto_suite) {
- LOG_AND_RETURN_ERROR(
- webrtc::RTCErrorType::UNSUPPORTED_OPERATION,
- "The send key and receive key must have the same cipher suite.");
- }
-
- recv_crypto_suite_ = rtc::SrtpCryptoSuiteFromName(params.crypto_suite);
- if (*recv_crypto_suite_ == rtc::kSrtpInvalidCryptoSuite) {
- return RTCError(RTCErrorType::INVALID_PARAMETER,
- "Invalid SRTP crypto suite");
- }
-
- int recv_key_len, recv_salt_len;
- if (!rtc::GetSrtpKeyAndSaltLengths(*recv_crypto_suite_, &recv_key_len,
- &recv_salt_len)) {
- return RTCError(RTCErrorType::INVALID_PARAMETER,
- "Could not get lengths for crypto suite(s):"
- " recv crypto_suite ");
- }
-
- recv_key_ = rtc::ZeroOnFreeBuffer<uint8_t>(recv_key_len + recv_salt_len);
- if (!ParseKeyParams(params.key_params, recv_key_.data(), recv_key_.size())) {
- return RTCError(RTCErrorType::INVALID_PARAMETER,
- "Failed to parse the crypto key params");
- }
-
- if (!MaybeSetKeyParams()) {
- return RTCError(RTCErrorType::INVALID_PARAMETER,
- "Failed to set the crypto key params");
- }
- recv_params_ = params;
- return RTCError::OK();
-}
-
bool SrtpTransport::SendRtpPacket(rtc::CopyOnWriteBuffer* packet,
const rtc::PacketOptions& options,
int flags) {
@@ -519,4 +439,19 @@ void SrtpTransport::MaybeUpdateWritableState() {
}
}
+bool SrtpTransport::UnregisterRtpDemuxerSink(RtpPacketSinkInterface* sink) {
+ if (recv_session_ &&
+ field_trials_.IsEnabled("WebRTC-SrtpRemoveReceiveStream")) {
+ // Remove the SSRCs explicitly registered with the demuxer
+ // (via SDP negotiation) from the SRTP session.
+ for (const auto ssrc : GetSsrcsForSink(sink)) {
+ if (!recv_session_->RemoveSsrcFromSession(ssrc)) {
+ RTC_LOG(LS_WARNING)
+ << "Could not remove SSRC " << ssrc << " from SRTP session.";
+ }
+ }
+ }
+ return RtpTransport::UnregisterRtpDemuxerSink(sink);
+}
+
} // namespace webrtc
diff --git a/third_party/libwebrtc/pc/srtp_transport.h b/third_party/libwebrtc/pc/srtp_transport.h
index 46c11ed56d..29721f3b68 100644
--- a/third_party/libwebrtc/pc/srtp_transport.h
+++ b/third_party/libwebrtc/pc/srtp_transport.h
@@ -41,9 +41,6 @@ class SrtpTransport : public RtpTransport {
virtual ~SrtpTransport() = default;
- virtual RTCError SetSrtpSendKey(const cricket::CryptoParams& params);
- virtual RTCError SetSrtpReceiveKey(const cricket::CryptoParams& params);
-
bool SendRtpPacket(rtc::CopyOnWriteBuffer* packet,
const rtc::PacketOptions& options,
int flags) override;
@@ -109,6 +106,10 @@ class SrtpTransport : public RtpTransport {
rtp_abs_sendtime_extn_id_ = rtp_abs_sendtime_extn_id;
}
+ // In addition to unregistering the sink, the SRTP transport
+ // disassociates all SSRCs of the sink from libSRTP.
+ bool UnregisterRtpDemuxerSink(RtpPacketSinkInterface* sink) override;
+
protected:
// If the writable state changed, fire the SignalWritableState.
void MaybeUpdateWritableState();
diff --git a/third_party/libwebrtc/pc/srtp_transport_unittest.cc b/third_party/libwebrtc/pc/srtp_transport_unittest.cc
index ac8be8762b..de4ff03179 100644
--- a/third_party/libwebrtc/pc/srtp_transport_unittest.cc
+++ b/third_party/libwebrtc/pc/srtp_transport_unittest.cc
@@ -342,7 +342,7 @@ class SrtpTransportTest : public ::testing::Test, public sigslot::has_slots<> {
TransportObserver rtp_sink2_;
int sequence_number_ = 0;
- webrtc::test::ScopedKeyValueConfig field_trials_;
+ test::ScopedKeyValueConfig field_trials_;
};
class SrtpTransportTestWithExternalAuth
@@ -425,4 +425,66 @@ TEST_F(SrtpTransportTest, TestSetParamsKeyTooShort) {
rtc::kSrtpAes128CmSha1_80, kTestKey1, kTestKeyLen - 1, extension_ids));
}
+TEST_F(SrtpTransportTest, RemoveSrtpReceiveStream) {
+ test::ScopedKeyValueConfig field_trials(
+ "WebRTC-SrtpRemoveReceiveStream/Enabled/");
+ auto srtp_transport =
+ std::make_unique<SrtpTransport>(/*rtcp_mux_enabled=*/true, field_trials);
+ auto rtp_packet_transport = std::make_unique<rtc::FakePacketTransport>(
+ "fake_packet_transport_loopback");
+
+ bool asymmetric = false;
+ rtp_packet_transport->SetDestination(rtp_packet_transport.get(), asymmetric);
+ srtp_transport->SetRtpPacketTransport(rtp_packet_transport.get());
+
+ TransportObserver rtp_sink;
+
+ std::vector<int> extension_ids;
+ EXPECT_TRUE(srtp_transport->SetRtpParams(
+ rtc::kSrtpAeadAes128Gcm, kTestKeyGcm128_1, kTestKeyGcm128Len,
+ extension_ids, rtc::kSrtpAeadAes128Gcm, kTestKeyGcm128_1,
+ kTestKeyGcm128Len, extension_ids));
+
+ RtpDemuxerCriteria demuxer_criteria;
+ uint32_t ssrc = 0x1; // SSRC of kPcmuFrame
+ demuxer_criteria.ssrcs().insert(ssrc);
+ EXPECT_TRUE(
+ srtp_transport->RegisterRtpDemuxerSink(demuxer_criteria, &rtp_sink));
+
+ // Create a packet and try to send it three times.
+ size_t rtp_len = sizeof(kPcmuFrame);
+ size_t packet_size = rtp_len + rtc::rtp_auth_tag_len(rtc::kCsAeadAes128Gcm);
+ rtc::Buffer rtp_packet_buffer(packet_size);
+ char* rtp_packet_data = rtp_packet_buffer.data<char>();
+ memcpy(rtp_packet_data, kPcmuFrame, rtp_len);
+
+ // First attempt will succeed.
+ rtc::CopyOnWriteBuffer first_try(rtp_packet_data, rtp_len, packet_size);
+ EXPECT_TRUE(srtp_transport->SendRtpPacket(&first_try, rtc::PacketOptions(),
+ cricket::PF_SRTP_BYPASS));
+ EXPECT_EQ(rtp_sink.rtp_count(), 1);
+
+ // Second attempt will be rejected by libSRTP as a replay attack
+ // (srtp_err_status_replay_fail) since the sequence number was already seen.
+ // Hence the packet never reaches the sink.
+ rtc::CopyOnWriteBuffer second_try(rtp_packet_data, rtp_len, packet_size);
+ EXPECT_TRUE(srtp_transport->SendRtpPacket(&second_try, rtc::PacketOptions(),
+ cricket::PF_SRTP_BYPASS));
+ EXPECT_EQ(rtp_sink.rtp_count(), 1);
+
+ // Reset the sink.
+ EXPECT_TRUE(srtp_transport->UnregisterRtpDemuxerSink(&rtp_sink));
+ EXPECT_TRUE(
+ srtp_transport->RegisterRtpDemuxerSink(demuxer_criteria, &rtp_sink));
+
+ // Third attempt will succeed again since libSRTP does not remember seeing
+ // the sequence number after the reset.
+ rtc::CopyOnWriteBuffer third_try(rtp_packet_data, rtp_len, packet_size);
+ EXPECT_TRUE(srtp_transport->SendRtpPacket(&third_try, rtc::PacketOptions(),
+ cricket::PF_SRTP_BYPASS));
+ EXPECT_EQ(rtp_sink.rtp_count(), 2);
+ // Clear the sink to clean up.
+ srtp_transport->UnregisterRtpDemuxerSink(&rtp_sink);
+}
+
} // namespace webrtc
diff --git a/third_party/libwebrtc/pc/test/android_test_initializer.cc b/third_party/libwebrtc/pc/test/android_test_initializer.cc
index 963544cb4b..88b4587789 100644
--- a/third_party/libwebrtc/pc/test/android_test_initializer.cc
+++ b/third_party/libwebrtc/pc/test/android_test_initializer.cc
@@ -39,7 +39,7 @@ void EnsureInitializedOnce() {
RTC_CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()";
- webrtc::JVM::Initialize(jvm);
+ JVM::Initialize(jvm);
}
} // anonymous namespace
diff --git a/third_party/libwebrtc/pc/test/enable_fake_media.cc b/third_party/libwebrtc/pc/test/enable_fake_media.cc
new file mode 100644
index 0000000000..5497c60724
--- /dev/null
+++ b/third_party/libwebrtc/pc/test/enable_fake_media.cc
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2023 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "pc/test/enable_fake_media.h"
+
+#include <memory>
+#include <utility>
+
+#include "absl/base/nullability.h"
+#include "api/environment/environment.h"
+#include "api/peer_connection_interface.h"
+#include "call/call.h"
+#include "call/call_config.h"
+#include "media/base/fake_media_engine.h"
+#include "pc/media_factory.h"
+#include "rtc_base/checks.h"
+
+namespace webrtc {
+
+using ::cricket::FakeMediaEngine;
+using ::cricket::MediaEngineInterface;
+
+void EnableFakeMedia(
+ PeerConnectionFactoryDependencies& deps,
+ absl::Nonnull<std::unique_ptr<FakeMediaEngine>> fake_media_engine) {
+ class FakeMediaFactory : public MediaFactory {
+ public:
+ explicit FakeMediaFactory(
+ absl::Nonnull<std::unique_ptr<FakeMediaEngine>> fake)
+ : fake_(std::move(fake)) {}
+
+ std::unique_ptr<Call> CreateCall(const CallConfig& config) override {
+ return Call::Create(config);
+ }
+
+ std::unique_ptr<MediaEngineInterface> CreateMediaEngine(
+ const Environment& /*env*/,
+ PeerConnectionFactoryDependencies& /*dependencies*/) {
+ RTC_CHECK(fake_ != nullptr)
+ << "CreateMediaEngine can be called at most once.";
+ return std::move(fake_);
+ }
+
+ private:
+ absl::Nullable<std::unique_ptr<FakeMediaEngine>> fake_;
+ };
+
+ deps.media_factory =
+ std::make_unique<FakeMediaFactory>(std::move(fake_media_engine));
+}
+
+void EnableFakeMedia(PeerConnectionFactoryDependencies& deps) {
+ EnableFakeMedia(deps, std::make_unique<cricket::FakeMediaEngine>());
+}
+
+} // namespace webrtc
diff --git a/third_party/libwebrtc/pc/test/enable_fake_media.h b/third_party/libwebrtc/pc/test/enable_fake_media.h
new file mode 100644
index 0000000000..82c55ad08b
--- /dev/null
+++ b/third_party/libwebrtc/pc/test/enable_fake_media.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2023 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+// Enables fake media support for PeerConnnectionFactory created from `deps` for
+// testing purposes. Such fake media support ignores media dependencies in the
+// `PeerConnectionFactoryDependencies`. Allows to test PeerConnection and
+// PeerConnectionFactory in the presence of the media, but doesn't test media
+// support itself.
+
+#ifndef PC_TEST_ENABLE_FAKE_MEDIA_H_
+#define PC_TEST_ENABLE_FAKE_MEDIA_H_
+
+#include <memory>
+
+#include "absl/base/nullability.h"
+#include "api/peer_connection_interface.h"
+#include "media/base/fake_media_engine.h"
+
+namespace webrtc {
+
+// Enables media support backed by the 'fake_media_engine'.
+void EnableFakeMedia(
+ PeerConnectionFactoryDependencies& deps,
+ absl::Nonnull<std::unique_ptr<cricket::FakeMediaEngine>> fake_media_engine);
+
+// Enables media support backed by unspecified lightweight fake implementation.
+void EnableFakeMedia(PeerConnectionFactoryDependencies& deps);
+
+} // namespace webrtc
+
+#endif // PC_TEST_ENABLE_FAKE_MEDIA_H_
diff --git a/third_party/libwebrtc/pc/test/fake_peer_connection_base.h b/third_party/libwebrtc/pc/test/fake_peer_connection_base.h
index a1c8dca12e..1615088e99 100644
--- a/third_party/libwebrtc/pc/test/fake_peer_connection_base.h
+++ b/third_party/libwebrtc/pc/test/fake_peer_connection_base.h
@@ -363,7 +363,7 @@ class FakePeerConnectionBase : public PeerConnectionInternal {
const FieldTrialsView& trials() const override { return field_trials_; }
protected:
- webrtc::test::ScopedKeyValueConfig field_trials_;
+ test::ScopedKeyValueConfig field_trials_;
};
} // namespace webrtc
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
index 7302182912..2883c86b58 100644
--- a/third_party/libwebrtc/pc/test/fake_peer_connection_for_stats.h
+++ b/third_party/libwebrtc/pc/test/fake_peer_connection_for_stats.h
@@ -18,10 +18,11 @@
#include <utility>
#include <vector>
-#include "media/base/fake_media_engine.h"
+#include "api/environment/environment_factory.h"
#include "media/base/media_channel.h"
#include "pc/channel.h"
#include "pc/stream_collection.h"
+#include "pc/test/enable_fake_media.h"
#include "pc/test/fake_data_channel_controller.h"
#include "pc/test/fake_peer_connection_base.h"
@@ -150,7 +151,7 @@ class VoiceChannelForTesting : public cricket::VoiceChannel {
receive_channel,
const std::string& content_name,
bool srtp_required,
- webrtc::CryptoOptions crypto_options,
+ CryptoOptions crypto_options,
rtc::UniqueRandomIdGenerator* ssrc_generator,
std::string transport_name)
: VoiceChannel(worker_thread,
@@ -183,7 +184,7 @@ class VideoChannelForTesting : public cricket::VideoChannel {
receive_channel,
const std::string& content_name,
bool srtp_required,
- webrtc::CryptoOptions crypto_options,
+ CryptoOptions crypto_options,
rtc::UniqueRandomIdGenerator* ssrc_generator,
std::string transport_name)
: VideoChannel(worker_thread,
@@ -219,7 +220,8 @@ class FakePeerConnectionForStats : public FakePeerConnectionBase {
signaling_thread_(rtc::Thread::Current()),
// TODO(hta): remove separate thread variables and use context.
dependencies_(MakeDependencies()),
- context_(ConnectionContext::Create(&dependencies_)),
+ context_(
+ ConnectionContext::Create(CreateEnvironment(), &dependencies_)),
local_streams_(StreamCollection::Create()),
remote_streams_(StreamCollection::Create()),
data_channel_controller_(network_thread_) {}
@@ -235,7 +237,7 @@ class FakePeerConnectionForStats : public FakePeerConnectionBase {
dependencies.network_thread = rtc::Thread::Current();
dependencies.worker_thread = rtc::Thread::Current();
dependencies.signaling_thread = rtc::Thread::Current();
- dependencies.media_engine = std::make_unique<cricket::FakeMediaEngine>();
+ EnableFakeMedia(dependencies);
return dependencies;
}
@@ -298,7 +300,7 @@ class FakePeerConnectionForStats : public FakePeerConnectionBase {
worker_thread_, network_thread_, signaling_thread_,
std::move(voice_media_send_channel),
std::move(voice_media_receive_channel), mid, kDefaultSrtpRequired,
- webrtc::CryptoOptions(), context_->ssrc_generator(), transport_name);
+ CryptoOptions(), context_->ssrc_generator(), transport_name);
auto transceiver =
GetOrCreateFirstTransceiverOfType(cricket::MEDIA_TYPE_AUDIO)
->internal();
@@ -332,7 +334,7 @@ class FakePeerConnectionForStats : public FakePeerConnectionBase {
worker_thread_, network_thread_, signaling_thread_,
std::move(video_media_send_channel),
std::move(video_media_receive_channel), mid, kDefaultSrtpRequired,
- webrtc::CryptoOptions(), context_->ssrc_generator(), transport_name);
+ CryptoOptions(), context_->ssrc_generator(), transport_name);
auto transceiver =
GetOrCreateFirstTransceiverOfType(cricket::MEDIA_TYPE_VIDEO)
->internal();
diff --git a/third_party/libwebrtc/pc/test/fake_periodic_video_source.h b/third_party/libwebrtc/pc/test/fake_periodic_video_source.h
index 452a8f6c30..65652bdf0d 100644
--- a/third_party/libwebrtc/pc/test/fake_periodic_video_source.h
+++ b/third_party/libwebrtc/pc/test/fake_periodic_video_source.h
@@ -65,12 +65,12 @@ class FakePeriodicVideoSource final
return wants_;
}
- void RemoveSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) override {
+ void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override {
RTC_DCHECK(thread_checker_.IsCurrent());
broadcaster_.RemoveSink(sink);
}
- void AddOrUpdateSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink,
+ void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
const rtc::VideoSinkWants& wants) override {
RTC_DCHECK(thread_checker_.IsCurrent());
{
diff --git a/third_party/libwebrtc/pc/test/integration_test_helpers.cc b/third_party/libwebrtc/pc/test/integration_test_helpers.cc
index ede159d744..64d8debc09 100644
--- a/third_party/libwebrtc/pc/test/integration_test_helpers.cc
+++ b/third_party/libwebrtc/pc/test/integration_test_helpers.cc
@@ -46,7 +46,7 @@ void RemoveSsrcsAndKeepMsids(cricket::SessionDescription* desc) {
int FindFirstMediaStatsIndexByKind(
const std::string& kind,
- const std::vector<const webrtc::RTCInboundRtpStreamStats*>& inbound_rtps) {
+ const std::vector<const RTCInboundRtpStreamStats*>& inbound_rtps) {
for (size_t i = 0; i < inbound_rtps.size(); i++) {
if (*inbound_rtps[i]->kind == kind) {
return i;
diff --git a/third_party/libwebrtc/pc/test/integration_test_helpers.h b/third_party/libwebrtc/pc/test/integration_test_helpers.h
index 36b2111324..fb719e7ddd 100644
--- a/third_party/libwebrtc/pc/test/integration_test_helpers.h
+++ b/third_party/libwebrtc/pc/test/integration_test_helpers.h
@@ -31,10 +31,10 @@
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "api/audio_options.h"
-#include "api/call/call_factory_interface.h"
#include "api/candidate.h"
#include "api/crypto/crypto_options.h"
#include "api/data_channel_interface.h"
+#include "api/enable_media_with_defaults.h"
#include "api/field_trials_view.h"
#include "api/ice_transport_interface.h"
#include "api/jsep.h"
@@ -68,14 +68,11 @@
#include "media/base/media_engine.h"
#include "media/base/stream_params.h"
#include "media/engine/fake_webrtc_video_engine.h"
-#include "media/engine/webrtc_media_engine.h"
-#include "media/engine/webrtc_media_engine_defaults.h"
#include "modules/audio_device/include/audio_device.h"
#include "modules/audio_processing/include/audio_processing.h"
#include "modules/audio_processing/test/audio_processing_builder_for_testing.h"
#include "p2p/base/fake_ice_transport.h"
#include "p2p/base/ice_transport_internal.h"
-#include "p2p/base/mock_async_resolver.h"
#include "p2p/base/p2p_constants.h"
#include "p2p/base/port.h"
#include "p2p/base/port_allocator.h"
@@ -179,14 +176,14 @@ void ReplaceFirstSsrc(StreamParams& stream, uint32_t ssrc);
int FindFirstMediaStatsIndexByKind(
const std::string& kind,
- const std::vector<const webrtc::RTCInboundRtpStreamStats*>& inbound_rtps);
+ const std::vector<const RTCInboundRtpStreamStats*>& inbound_rtps);
-class TaskQueueMetronome : public webrtc::Metronome {
+class TaskQueueMetronome : public Metronome {
public:
explicit TaskQueueMetronome(TimeDelta tick_period);
~TaskQueueMetronome() override;
- // webrtc::Metronome implementation.
+ // Metronome implementation.
void RequestCallOnNextTick(absl::AnyInvocable<void() &&> callback) override;
TimeDelta TickPeriod() const override;
@@ -209,7 +206,7 @@ class SignalingMessageReceiver {
virtual ~SignalingMessageReceiver() {}
};
-class MockRtpReceiverObserver : public webrtc::RtpReceiverObserverInterface {
+class MockRtpReceiverObserver : public RtpReceiverObserverInterface {
public:
explicit MockRtpReceiverObserver(cricket::MediaType media_type)
: expected_media_type_(media_type) {}
@@ -236,14 +233,14 @@ class MockRtpReceiverObserver : public webrtc::RtpReceiverObserverInterface {
// advertise support of any codecs.
// TODO(steveanton): See how this could become a subclass of
// PeerConnectionWrapper defined in peerconnectionwrapper.h.
-class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
+class PeerConnectionIntegrationWrapper : public PeerConnectionObserver,
public SignalingMessageReceiver {
public:
- webrtc::PeerConnectionFactoryInterface* pc_factory() const {
+ PeerConnectionFactoryInterface* pc_factory() const {
return peer_connection_factory_.get();
}
- webrtc::PeerConnectionInterface* pc() const { return peer_connection_.get(); }
+ PeerConnectionInterface* pc() const { return peer_connection_.get(); }
// If a signaling message receiver is set (via ConnectFakeSignaling), this
// will set the whole offer/answer exchange in motion. Just need to wait for
@@ -341,11 +338,11 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
return AddTrack(CreateLocalVideoTrack());
}
- rtc::scoped_refptr<webrtc::AudioTrackInterface> CreateLocalAudioTrack() {
+ rtc::scoped_refptr<AudioTrackInterface> CreateLocalAudioTrack() {
cricket::AudioOptions options;
// Disable highpass filter so that we can get all the test audio frames.
options.highpass_filter = false;
- rtc::scoped_refptr<webrtc::AudioSourceInterface> source =
+ rtc::scoped_refptr<AudioSourceInterface> source =
peer_connection_factory_->CreateAudioSource(options);
// TODO(perkj): Test audio source when it is implemented. Currently audio
// always use the default input.
@@ -353,21 +350,20 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
source.get());
}
- rtc::scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrack() {
- webrtc::FakePeriodicVideoSource::Config config;
+ rtc::scoped_refptr<VideoTrackInterface> CreateLocalVideoTrack() {
+ FakePeriodicVideoSource::Config config;
config.timestamp_offset_ms = rtc::TimeMillis();
return CreateLocalVideoTrackInternal(config);
}
- rtc::scoped_refptr<webrtc::VideoTrackInterface>
- CreateLocalVideoTrackWithConfig(
- webrtc::FakePeriodicVideoSource::Config config) {
+ rtc::scoped_refptr<VideoTrackInterface> CreateLocalVideoTrackWithConfig(
+ FakePeriodicVideoSource::Config config) {
return CreateLocalVideoTrackInternal(config);
}
- rtc::scoped_refptr<webrtc::VideoTrackInterface>
- CreateLocalVideoTrackWithRotation(webrtc::VideoRotation rotation) {
- webrtc::FakePeriodicVideoSource::Config config;
+ rtc::scoped_refptr<VideoTrackInterface> CreateLocalVideoTrackWithRotation(
+ VideoRotation rotation) {
+ FakePeriodicVideoSource::Config config;
config.rotation = rotation;
config.timestamp_offset_ms = rtc::TimeMillis();
return CreateLocalVideoTrackInternal(config);
@@ -411,22 +407,22 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
}
bool SignalingStateStable() {
- return pc()->signaling_state() == webrtc::PeerConnectionInterface::kStable;
+ return pc()->signaling_state() == PeerConnectionInterface::kStable;
}
bool IceGatheringStateComplete() {
return pc()->ice_gathering_state() ==
- webrtc::PeerConnectionInterface::kIceGatheringComplete;
+ PeerConnectionInterface::kIceGatheringComplete;
}
void CreateDataChannel() { CreateDataChannel(nullptr); }
- void CreateDataChannel(const webrtc::DataChannelInit* init) {
+ void CreateDataChannel(const DataChannelInit* init) {
CreateDataChannel(kDataChannelLabel, init);
}
void CreateDataChannel(const std::string& label,
- const webrtc::DataChannelInit* init) {
+ const DataChannelInit* init) {
auto data_channel_or_error = pc()->CreateDataChannelOrError(label, init);
ASSERT_TRUE(data_channel_or_error.ok());
data_channels_.push_back(data_channel_or_error.MoveValue());
@@ -484,7 +480,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
// Returns a MockStatsObserver in a state after stats gathering finished,
// which can be used to access the gathered stats.
rtc::scoped_refptr<MockStatsObserver> OldGetStatsForTrack(
- webrtc::MediaStreamTrackInterface* track) {
+ MediaStreamTrackInterface* track) {
auto observer = rtc::make_ref_counted<MockStatsObserver>();
EXPECT_TRUE(peer_connection_->GetStats(
observer.get(), nullptr,
@@ -500,9 +496,8 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
// Synchronously gets stats and returns them. If it times out, fails the test
// and returns null.
- rtc::scoped_refptr<const webrtc::RTCStatsReport> NewGetStats() {
- auto callback =
- rtc::make_ref_counted<webrtc::MockRTCStatsCollectorCallback>();
+ rtc::scoped_refptr<const RTCStatsReport> NewGetStats() {
+ auto callback = rtc::make_ref_counted<MockRTCStatsCollectorCallback>();
peer_connection_->GetStats(callback.get());
EXPECT_TRUE_WAIT(callback->called(), kDefaultTimeout);
return callback->report();
@@ -529,10 +524,10 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
return static_cast<double>(rendered_width()) / rendered_height();
}
- webrtc::VideoRotation rendered_rotation() {
+ VideoRotation rendered_rotation() {
EXPECT_FALSE(fake_video_renderers_.empty());
return fake_video_renderers_.empty()
- ? webrtc::kVideoRotation_0
+ ? kVideoRotation_0
: fake_video_renderers_.begin()->second->rotation();
}
@@ -575,20 +570,20 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
return pc()->local_streams().get();
}
- webrtc::PeerConnectionInterface::SignalingState signaling_state() {
+ PeerConnectionInterface::SignalingState signaling_state() {
return pc()->signaling_state();
}
- webrtc::PeerConnectionInterface::IceConnectionState ice_connection_state() {
+ PeerConnectionInterface::IceConnectionState ice_connection_state() {
return pc()->ice_connection_state();
}
- webrtc::PeerConnectionInterface::IceConnectionState
+ PeerConnectionInterface::IceConnectionState
standardized_ice_connection_state() {
return pc()->standardized_ice_connection_state();
}
- webrtc::PeerConnectionInterface::IceGatheringState ice_gathering_state() {
+ PeerConnectionInterface::IceGatheringState ice_gathering_state() {
return pc()->ice_gathering_state();
}
@@ -617,7 +612,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
}
cricket::PortAllocator* port_allocator() const { return port_allocator_; }
- webrtc::FakeRtcEventLogFactory* event_log_factory() const {
+ FakeRtcEventLogFactory* event_log_factory() const {
return event_log_factory_;
}
@@ -630,8 +625,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
// Sets the mDNS responder for the owned fake network manager and keeps a
// reference to the responder.
- void SetMdnsResponder(
- std::unique_ptr<webrtc::FakeMdnsResponder> mdns_responder) {
+ void SetMdnsResponder(std::unique_ptr<FakeMdnsResponder> mdns_responder) {
RTC_DCHECK(mdns_responder != nullptr);
mdns_responder_ = mdns_responder.get();
network_manager()->set_mdns_responder(std::move(mdns_responder));
@@ -646,7 +640,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
}
bool Rollback() {
return SetRemoteDescription(
- webrtc::CreateSessionDescription(SdpType::kRollback, ""));
+ CreateSessionDescription(SdpType::kRollback, ""));
}
// Functions for querying stats.
@@ -654,7 +648,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
// Get the baseline numbers for audio_packets and audio_delay.
auto received_stats = NewGetStats();
auto rtp_stats =
- received_stats->GetStatsOfType<webrtc::RTCInboundRtpStreamStats>()[0];
+ received_stats->GetStatsOfType<RTCInboundRtpStreamStats>()[0];
ASSERT_TRUE(rtp_stats->relative_packet_arrival_delay.is_defined());
ASSERT_TRUE(rtp_stats->packets_received.is_defined());
rtp_stats_id_ = rtp_stats->id();
@@ -666,8 +660,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
void UpdateDelayStats(std::string tag, int desc_size) {
auto report = NewGetStats();
- auto rtp_stats =
- report->GetAs<webrtc::RTCInboundRtpStreamStats>(rtp_stats_id_);
+ auto rtp_stats = report->GetAs<RTCInboundRtpStreamStats>(rtp_stats_id_);
ASSERT_TRUE(rtp_stats);
auto delta_packets = *rtp_stats->packets_received - audio_packets_stat_;
auto delta_rpad =
@@ -746,11 +739,11 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
bool Init(const PeerConnectionFactory::Options* options,
const PeerConnectionInterface::RTCConfiguration* config,
- webrtc::PeerConnectionDependencies dependencies,
+ PeerConnectionDependencies dependencies,
rtc::SocketServer* socket_server,
rtc::Thread* network_thread,
rtc::Thread* worker_thread,
- std::unique_ptr<webrtc::FakeRtcEventLogFactory> event_log_factory,
+ std::unique_ptr<FakeRtcEventLogFactory> event_log_factory,
bool reset_encoder_factory,
bool reset_decoder_factory,
bool create_media_engine) {
@@ -773,51 +766,45 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
}
rtc::Thread* const signaling_thread = rtc::Thread::Current();
- webrtc::PeerConnectionFactoryDependencies pc_factory_dependencies;
+ PeerConnectionFactoryDependencies pc_factory_dependencies;
pc_factory_dependencies.network_thread = network_thread;
pc_factory_dependencies.worker_thread = worker_thread;
pc_factory_dependencies.signaling_thread = signaling_thread;
pc_factory_dependencies.task_queue_factory =
- webrtc::CreateDefaultTaskQueueFactory();
+ CreateDefaultTaskQueueFactory();
pc_factory_dependencies.trials = std::make_unique<FieldTrialBasedConfig>();
pc_factory_dependencies.metronome =
std::make_unique<TaskQueueMetronome>(TimeDelta::Millis(8));
- cricket::MediaEngineDependencies media_deps;
- media_deps.task_queue_factory =
- pc_factory_dependencies.task_queue_factory.get();
- media_deps.adm = fake_audio_capture_module_;
- webrtc::SetMediaEngineDefaults(&media_deps);
+
+ pc_factory_dependencies.adm = fake_audio_capture_module_;
+ if (create_media_engine) {
+ EnableMediaWithDefaults(pc_factory_dependencies);
+ }
if (reset_encoder_factory) {
- media_deps.video_encoder_factory.reset();
+ pc_factory_dependencies.video_encoder_factory.reset();
}
if (reset_decoder_factory) {
- media_deps.video_decoder_factory.reset();
+ pc_factory_dependencies.video_decoder_factory.reset();
}
- if (!media_deps.audio_processing) {
+ if (!pc_factory_dependencies.audio_processing) {
// If the standard Creation method for APM returns a null pointer, instead
// use the builder for testing to create an APM object.
- media_deps.audio_processing = AudioProcessingBuilderForTesting().Create();
+ pc_factory_dependencies.audio_processing =
+ AudioProcessingBuilderForTesting().Create();
}
- media_deps.trials = pc_factory_dependencies.trials.get();
-
- if (create_media_engine) {
- pc_factory_dependencies.media_engine =
- cricket::CreateMediaEngine(std::move(media_deps));
- }
- pc_factory_dependencies.call_factory = webrtc::CreateCallFactory();
if (event_log_factory) {
event_log_factory_ = event_log_factory.get();
pc_factory_dependencies.event_log_factory = std::move(event_log_factory);
} else {
pc_factory_dependencies.event_log_factory =
- std::make_unique<webrtc::RtcEventLogFactory>(
+ std::make_unique<RtcEventLogFactory>(
pc_factory_dependencies.task_queue_factory.get());
}
- peer_connection_factory_ = webrtc::CreateModularPeerConnectionFactory(
- std::move(pc_factory_dependencies));
+ peer_connection_factory_ =
+ CreateModularPeerConnectionFactory(std::move(pc_factory_dependencies));
if (!peer_connection_factory_) {
return false;
@@ -834,9 +821,9 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
return peer_connection_.get() != nullptr;
}
- rtc::scoped_refptr<webrtc::PeerConnectionInterface> CreatePeerConnection(
+ rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
const PeerConnectionInterface::RTCConfiguration* config,
- webrtc::PeerConnectionDependencies dependencies) {
+ PeerConnectionDependencies dependencies) {
PeerConnectionInterface::RTCConfiguration modified_config;
modified_config.sdp_semantics = sdp_semantics_;
// If `config` is null, this will result in a default configuration being
@@ -869,21 +856,20 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
signal_ice_candidates_ = signal;
}
- rtc::scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrackInternal(
- webrtc::FakePeriodicVideoSource::Config config) {
+ rtc::scoped_refptr<VideoTrackInterface> CreateLocalVideoTrackInternal(
+ FakePeriodicVideoSource::Config config) {
// Set max frame rate to 10fps to reduce the risk of test flakiness.
// TODO(deadbeef): Do something more robust.
config.frame_interval_ms = 100;
video_track_sources_.emplace_back(
- rtc::make_ref_counted<webrtc::FakePeriodicVideoTrackSource>(
+ rtc::make_ref_counted<FakePeriodicVideoTrackSource>(
config, false /* remote */));
- rtc::scoped_refptr<webrtc::VideoTrackInterface> track =
+ rtc::scoped_refptr<VideoTrackInterface> track =
peer_connection_factory_->CreateVideoTrack(video_track_sources_.back(),
rtc::CreateRandomUuid());
if (!local_video_renderer_) {
- local_video_renderer_.reset(
- new webrtc::FakeVideoTrackRenderer(track.get()));
+ local_video_renderer_.reset(new FakeVideoTrackRenderer(track.get()));
}
return track;
}
@@ -891,7 +877,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
void HandleIncomingOffer(const std::string& msg) {
RTC_LOG(LS_INFO) << debug_name_ << ": HandleIncomingOffer";
std::unique_ptr<SessionDescriptionInterface> desc =
- webrtc::CreateSessionDescription(SdpType::kOffer, msg);
+ CreateSessionDescription(SdpType::kOffer, msg);
if (received_sdp_munger_) {
received_sdp_munger_(desc->description());
}
@@ -911,7 +897,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
void HandleIncomingAnswer(const std::string& msg) {
RTC_LOG(LS_INFO) << debug_name_ << ": HandleIncomingAnswer";
std::unique_ptr<SessionDescriptionInterface> desc =
- webrtc::CreateSessionDescription(SdpType::kAnswer, msg);
+ CreateSessionDescription(SdpType::kAnswer, msg);
if (received_sdp_munger_) {
received_sdp_munger_(desc->description());
}
@@ -1062,7 +1048,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
const std::string& msg) override {
RTC_LOG(LS_INFO) << debug_name_ << ": ReceiveIceMessage";
absl::optional<RTCError> result;
- pc()->AddIceCandidate(absl::WrapUnique(webrtc::CreateIceCandidate(
+ pc()->AddIceCandidate(absl::WrapUnique(CreateIceCandidate(
sdp_mid, sdp_mline_index, msg, nullptr)),
[&result](RTCError r) { result = r; });
EXPECT_TRUE_WAIT(result.has_value(), kDefaultTimeout);
@@ -1071,7 +1057,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
// PeerConnectionObserver callbacks.
void OnSignalingChange(
- webrtc::PeerConnectionInterface::SignalingState new_state) override {
+ PeerConnectionInterface::SignalingState new_state) override {
EXPECT_EQ(pc()->signaling_state(), new_state);
peer_connection_signaling_state_history_.push_back(new_state);
}
@@ -1100,21 +1086,21 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
}
void OnRenegotiationNeeded() override {}
void OnIceConnectionChange(
- webrtc::PeerConnectionInterface::IceConnectionState new_state) override {
+ PeerConnectionInterface::IceConnectionState new_state) override {
EXPECT_EQ(pc()->ice_connection_state(), new_state);
ice_connection_state_history_.push_back(new_state);
}
void OnStandardizedIceConnectionChange(
- webrtc::PeerConnectionInterface::IceConnectionState new_state) override {
+ PeerConnectionInterface::IceConnectionState new_state) override {
standardized_ice_connection_state_history_.push_back(new_state);
}
void OnConnectionChange(
- webrtc::PeerConnectionInterface::PeerConnectionState new_state) override {
+ PeerConnectionInterface::PeerConnectionState new_state) override {
peer_connection_state_history_.push_back(new_state);
}
void OnIceGatheringChange(
- webrtc::PeerConnectionInterface::IceGatheringState new_state) override {
+ PeerConnectionInterface::IceGatheringState new_state) override {
EXPECT_EQ(pc()->ice_gathering_state(), new_state);
ice_gathering_state_history_.push_back(new_state);
}
@@ -1124,7 +1110,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
ice_candidate_pair_change_history_.push_back(event);
}
- void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override {
+ void OnIceCandidate(const IceCandidateInterface* candidate) override {
RTC_LOG(LS_INFO) << debug_name_ << ": OnIceCandidate";
if (remote_async_dns_resolver_) {
@@ -1180,20 +1166,19 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
std::unique_ptr<rtc::FakeNetworkManager> fake_network_manager_;
std::unique_ptr<rtc::BasicPacketSocketFactory> socket_factory_;
// Reference to the mDNS responder owned by `fake_network_manager_` after set.
- webrtc::FakeMdnsResponder* mdns_responder_ = nullptr;
+ FakeMdnsResponder* mdns_responder_ = nullptr;
- rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
- rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface>
- peer_connection_factory_;
+ rtc::scoped_refptr<PeerConnectionInterface> peer_connection_;
+ rtc::scoped_refptr<PeerConnectionFactoryInterface> peer_connection_factory_;
cricket::PortAllocator* port_allocator_;
// Needed to keep track of number of frames sent.
rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_;
// Needed to keep track of number of frames received.
- std::map<std::string, std::unique_ptr<webrtc::FakeVideoTrackRenderer>>
+ std::map<std::string, std::unique_ptr<FakeVideoTrackRenderer>>
fake_video_renderers_;
// Needed to ensure frames aren't received for removed tracks.
- std::vector<std::unique_ptr<webrtc::FakeVideoTrackRenderer>>
+ std::vector<std::unique_ptr<FakeVideoTrackRenderer>>
removed_fake_video_renderers_;
// For remote peer communication.
@@ -1205,10 +1190,9 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
// Store references to the video sources we've created, so that we can stop
// them, if required.
- std::vector<rtc::scoped_refptr<webrtc::VideoTrackSource>>
- video_track_sources_;
+ std::vector<rtc::scoped_refptr<VideoTrackSource>> video_track_sources_;
// `local_video_renderer_` attached to the first created local video track.
- std::unique_ptr<webrtc::FakeVideoTrackRenderer> local_video_renderer_;
+ std::unique_ptr<FakeVideoTrackRenderer> local_video_renderer_;
SdpSemantics sdp_semantics_;
PeerConnectionInterface::RTCOfferAnswerOptions offer_answer_options_;
@@ -1238,7 +1222,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
ice_candidate_pair_change_history_;
std::vector<PeerConnectionInterface::SignalingState>
peer_connection_signaling_state_history_;
- webrtc::FakeRtcEventLogFactory* event_log_factory_;
+ FakeRtcEventLogFactory* event_log_factory_;
// Number of ICE candidates expected. The default is no limit.
int candidates_expected_ = std::numeric_limits<int>::max();
@@ -1255,7 +1239,7 @@ class PeerConnectionIntegrationWrapper : public webrtc::PeerConnectionObserver,
friend class PeerConnectionIntegrationBaseTest;
};
-class MockRtcEventLogOutput : public webrtc::RtcEventLogOutput {
+class MockRtcEventLogOutput : public RtcEventLogOutput {
public:
virtual ~MockRtcEventLogOutput() = default;
MOCK_METHOD(bool, IsActive, (), (const, override));
@@ -1367,7 +1351,7 @@ class MediaExpectations {
int callee_video_frames_expected_ = 0;
};
-class MockIceTransport : public webrtc::IceTransportInterface {
+class MockIceTransport : public IceTransportInterface {
public:
MockIceTransport(const std::string& name, int component)
: internal_(std::make_unique<cricket::FakeIceTransport>(
@@ -1415,7 +1399,7 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test {
worker_thread_->SetName("PCWorkerThread", this);
RTC_CHECK(network_thread_->Start());
RTC_CHECK(worker_thread_->Start());
- webrtc::metrics::Reset();
+ metrics::Reset();
}
~PeerConnectionIntegrationBaseTest() {
@@ -1452,13 +1436,13 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test {
// are connected. This is an important distinction. Once we have separate
// ICE and DTLS state, this check needs to use the DTLS state.
return (callee()->ice_connection_state() ==
- webrtc::PeerConnectionInterface::kIceConnectionConnected ||
+ PeerConnectionInterface::kIceConnectionConnected ||
callee()->ice_connection_state() ==
- webrtc::PeerConnectionInterface::kIceConnectionCompleted) &&
+ PeerConnectionInterface::kIceConnectionCompleted) &&
(caller()->ice_connection_state() ==
- webrtc::PeerConnectionInterface::kIceConnectionConnected ||
+ PeerConnectionInterface::kIceConnectionConnected ||
caller()->ice_connection_state() ==
- webrtc::PeerConnectionInterface::kIceConnectionCompleted);
+ PeerConnectionInterface::kIceConnectionCompleted);
}
// When `event_log_factory` is null, the default implementation of the event
@@ -1467,8 +1451,8 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test {
const std::string& debug_name,
const PeerConnectionFactory::Options* options,
const RTCConfiguration* config,
- webrtc::PeerConnectionDependencies dependencies,
- std::unique_ptr<webrtc::FakeRtcEventLogFactory> event_log_factory,
+ PeerConnectionDependencies dependencies,
+ std::unique_ptr<FakeRtcEventLogFactory> event_log_factory,
bool reset_encoder_factory,
bool reset_decoder_factory,
bool create_media_engine = true) {
@@ -1498,10 +1482,10 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test {
const std::string& debug_name,
const PeerConnectionFactory::Options* options,
const RTCConfiguration* config,
- webrtc::PeerConnectionDependencies dependencies) {
+ PeerConnectionDependencies dependencies) {
return CreatePeerConnectionWrapper(
debug_name, options, config, std::move(dependencies),
- std::make_unique<webrtc::FakeRtcEventLogFactory>(),
+ std::make_unique<FakeRtcEventLogFactory>(),
/*reset_encoder_factory=*/false,
/*reset_decoder_factory=*/false);
}
@@ -1522,17 +1506,17 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test {
// callee PeerConnections.
SdpSemantics original_semantics = sdp_semantics_;
sdp_semantics_ = caller_semantics;
- caller_ = CreatePeerConnectionWrapper(
- "Caller", nullptr, nullptr, webrtc::PeerConnectionDependencies(nullptr),
- nullptr,
- /*reset_encoder_factory=*/false,
- /*reset_decoder_factory=*/false);
+ caller_ = CreatePeerConnectionWrapper("Caller", nullptr, nullptr,
+ PeerConnectionDependencies(nullptr),
+ nullptr,
+ /*reset_encoder_factory=*/false,
+ /*reset_decoder_factory=*/false);
sdp_semantics_ = callee_semantics;
- callee_ = CreatePeerConnectionWrapper(
- "Callee", nullptr, nullptr, webrtc::PeerConnectionDependencies(nullptr),
- nullptr,
- /*reset_encoder_factory=*/false,
- /*reset_decoder_factory=*/false);
+ callee_ = CreatePeerConnectionWrapper("Callee", nullptr, nullptr,
+ PeerConnectionDependencies(nullptr),
+ nullptr,
+ /*reset_encoder_factory=*/false,
+ /*reset_decoder_factory=*/false);
sdp_semantics_ = original_semantics;
return caller_ && callee_;
}
@@ -1540,24 +1524,24 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test {
bool CreatePeerConnectionWrappersWithConfig(
const PeerConnectionInterface::RTCConfiguration& caller_config,
const PeerConnectionInterface::RTCConfiguration& callee_config) {
- caller_ = CreatePeerConnectionWrapper(
- "Caller", nullptr, &caller_config,
- webrtc::PeerConnectionDependencies(nullptr), nullptr,
- /*reset_encoder_factory=*/false,
- /*reset_decoder_factory=*/false);
- callee_ = CreatePeerConnectionWrapper(
- "Callee", nullptr, &callee_config,
- webrtc::PeerConnectionDependencies(nullptr), nullptr,
- /*reset_encoder_factory=*/false,
- /*reset_decoder_factory=*/false);
+ caller_ = CreatePeerConnectionWrapper("Caller", nullptr, &caller_config,
+ PeerConnectionDependencies(nullptr),
+ nullptr,
+ /*reset_encoder_factory=*/false,
+ /*reset_decoder_factory=*/false);
+ callee_ = CreatePeerConnectionWrapper("Callee", nullptr, &callee_config,
+ PeerConnectionDependencies(nullptr),
+ nullptr,
+ /*reset_encoder_factory=*/false,
+ /*reset_decoder_factory=*/false);
return caller_ && callee_;
}
bool CreatePeerConnectionWrappersWithConfigAndDeps(
const PeerConnectionInterface::RTCConfiguration& caller_config,
- webrtc::PeerConnectionDependencies caller_dependencies,
+ PeerConnectionDependencies caller_dependencies,
const PeerConnectionInterface::RTCConfiguration& callee_config,
- webrtc::PeerConnectionDependencies callee_dependencies) {
+ PeerConnectionDependencies callee_dependencies) {
caller_ =
CreatePeerConnectionWrapper("Caller", nullptr, &caller_config,
std::move(caller_dependencies), nullptr,
@@ -1574,16 +1558,16 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test {
bool CreatePeerConnectionWrappersWithOptions(
const PeerConnectionFactory::Options& caller_options,
const PeerConnectionFactory::Options& callee_options) {
- caller_ = CreatePeerConnectionWrapper(
- "Caller", &caller_options, nullptr,
- webrtc::PeerConnectionDependencies(nullptr), nullptr,
- /*reset_encoder_factory=*/false,
- /*reset_decoder_factory=*/false);
- callee_ = CreatePeerConnectionWrapper(
- "Callee", &callee_options, nullptr,
- webrtc::PeerConnectionDependencies(nullptr), nullptr,
- /*reset_encoder_factory=*/false,
- /*reset_decoder_factory=*/false);
+ caller_ = CreatePeerConnectionWrapper("Caller", &caller_options, nullptr,
+ PeerConnectionDependencies(nullptr),
+ nullptr,
+ /*reset_encoder_factory=*/false,
+ /*reset_decoder_factory=*/false);
+ callee_ = CreatePeerConnectionWrapper("Callee", &callee_options, nullptr,
+ PeerConnectionDependencies(nullptr),
+ nullptr,
+ /*reset_encoder_factory=*/false,
+ /*reset_decoder_factory=*/false);
return caller_ && callee_;
}
@@ -1591,10 +1575,10 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test {
PeerConnectionInterface::RTCConfiguration default_config;
caller_ = CreatePeerConnectionWrapperWithFakeRtcEventLog(
"Caller", nullptr, &default_config,
- webrtc::PeerConnectionDependencies(nullptr));
+ PeerConnectionDependencies(nullptr));
callee_ = CreatePeerConnectionWrapperWithFakeRtcEventLog(
"Callee", nullptr, &default_config,
- webrtc::PeerConnectionDependencies(nullptr));
+ PeerConnectionDependencies(nullptr));
return caller_ && callee_;
}
@@ -1604,7 +1588,7 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test {
new FakeRTCCertificateGenerator());
cert_generator->use_alternate_key();
- webrtc::PeerConnectionDependencies dependencies(nullptr);
+ PeerConnectionDependencies dependencies(nullptr);
dependencies.cert_generator = std::move(cert_generator);
return CreatePeerConnectionWrapper("New Peer", nullptr, nullptr,
std::move(dependencies), nullptr,
@@ -1614,12 +1598,12 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test {
bool CreateOneDirectionalPeerConnectionWrappers(bool caller_to_callee) {
caller_ = CreatePeerConnectionWrapper(
- "Caller", nullptr, nullptr, webrtc::PeerConnectionDependencies(nullptr),
+ "Caller", nullptr, nullptr, PeerConnectionDependencies(nullptr),
nullptr,
/*reset_encoder_factory=*/!caller_to_callee,
/*reset_decoder_factory=*/caller_to_callee);
callee_ = CreatePeerConnectionWrapper(
- "Callee", nullptr, nullptr, webrtc::PeerConnectionDependencies(nullptr),
+ "Callee", nullptr, nullptr, PeerConnectionDependencies(nullptr),
nullptr,
/*reset_encoder_factory=*/caller_to_callee,
/*reset_decoder_factory=*/!caller_to_callee);
@@ -1627,18 +1611,18 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test {
}
bool CreatePeerConnectionWrappersWithoutMediaEngine() {
- caller_ = CreatePeerConnectionWrapper(
- "Caller", nullptr, nullptr, webrtc::PeerConnectionDependencies(nullptr),
- nullptr,
- /*reset_encoder_factory=*/false,
- /*reset_decoder_factory=*/false,
- /*create_media_engine=*/false);
- callee_ = CreatePeerConnectionWrapper(
- "Callee", nullptr, nullptr, webrtc::PeerConnectionDependencies(nullptr),
- nullptr,
- /*reset_encoder_factory=*/false,
- /*reset_decoder_factory=*/false,
- /*create_media_engine=*/false);
+ caller_ = CreatePeerConnectionWrapper("Caller", nullptr, nullptr,
+ PeerConnectionDependencies(nullptr),
+ nullptr,
+ /*reset_encoder_factory=*/false,
+ /*reset_decoder_factory=*/false,
+ /*create_media_engine=*/false);
+ callee_ = CreatePeerConnectionWrapper("Callee", nullptr, nullptr,
+ PeerConnectionDependencies(nullptr),
+ nullptr,
+ /*reset_encoder_factory=*/false,
+ /*reset_decoder_factory=*/false,
+ /*create_media_engine=*/false);
return caller_ && callee_;
}
@@ -1708,7 +1692,7 @@ class PeerConnectionIntegrationBaseTest : public ::testing::Test {
// Messages may get lost on the unreliable DataChannel, so we send multiple
// times to avoid test flakiness.
- void SendRtpDataWithRetries(webrtc::DataChannelInterface* dc,
+ void SendRtpDataWithRetries(DataChannelInterface* dc,
const std::string& data,
int retries) {
for (int i = 0; i < retries; ++i) {
diff --git a/third_party/libwebrtc/pc/test/mock_peer_connection_observers.h b/third_party/libwebrtc/pc/test/mock_peer_connection_observers.h
index e9d97a97f6..6222ef7719 100644
--- a/third_party/libwebrtc/pc/test/mock_peer_connection_observers.h
+++ b/third_party/libwebrtc/pc/test/mock_peer_connection_observers.h
@@ -254,7 +254,7 @@ class MockPeerConnectionObserver : public PeerConnectionObserver {
};
class MockCreateSessionDescriptionObserver
- : public webrtc::CreateSessionDescriptionObserver {
+ : public CreateSessionDescriptionObserver {
public:
MockCreateSessionDescriptionObserver()
: called_(false),
@@ -266,7 +266,7 @@ class MockCreateSessionDescriptionObserver
error_ = "";
desc_.reset(desc);
}
- void OnFailure(webrtc::RTCError error) override {
+ void OnFailure(RTCError error) override {
MutexLock lock(&mutex_);
called_ = true;
error_ = error.message();
@@ -295,8 +295,7 @@ class MockCreateSessionDescriptionObserver
std::unique_ptr<SessionDescriptionInterface> desc_ RTC_GUARDED_BY(mutex_);
};
-class MockSetSessionDescriptionObserver
- : public webrtc::SetSessionDescriptionObserver {
+class MockSetSessionDescriptionObserver : public SetSessionDescriptionObserver {
public:
static rtc::scoped_refptr<MockSetSessionDescriptionObserver> Create() {
return rtc::make_ref_counted<MockSetSessionDescriptionObserver>();
@@ -312,7 +311,7 @@ class MockSetSessionDescriptionObserver
called_ = true;
error_ = "";
}
- void OnFailure(webrtc::RTCError error) override {
+ void OnFailure(RTCError error) override {
MutexLock lock(&mutex_);
called_ = true;
error_ = error.message();
@@ -375,14 +374,14 @@ class FakeSetRemoteDescriptionObserver
absl::optional<RTCError> error_;
};
-class MockDataChannelObserver : public webrtc::DataChannelObserver {
+class MockDataChannelObserver : public DataChannelObserver {
public:
struct Message {
std::string data;
bool binary;
};
- explicit MockDataChannelObserver(webrtc::DataChannelInterface* channel)
+ explicit MockDataChannelObserver(DataChannelInterface* channel)
: channel_(channel) {
channel_->RegisterObserver(this);
states_.push_back(channel_->state());
@@ -419,12 +418,12 @@ class MockDataChannelObserver : public webrtc::DataChannelObserver {
}
private:
- rtc::scoped_refptr<webrtc::DataChannelInterface> channel_;
+ rtc::scoped_refptr<DataChannelInterface> channel_;
std::vector<DataChannelInterface::DataState> states_;
std::vector<Message> messages_;
};
-class MockStatsObserver : public webrtc::StatsObserver {
+class MockStatsObserver : public StatsObserver {
public:
MockStatsObserver() : called_(false), stats_() {}
virtual ~MockStatsObserver() {}
@@ -576,7 +575,7 @@ class MockStatsObserver : public webrtc::StatsObserver {
};
// Helper class that just stores the report from the callback.
-class MockRTCStatsCollectorCallback : public webrtc::RTCStatsCollectorCallback {
+class MockRTCStatsCollectorCallback : public RTCStatsCollectorCallback {
public:
rtc::scoped_refptr<const RTCStatsReport> report() { return report_; }
diff --git a/third_party/libwebrtc/pc/test/rtp_transport_test_util.h b/third_party/libwebrtc/pc/test/rtp_transport_test_util.h
index 593ee002c9..563014f94a 100644
--- a/third_party/libwebrtc/pc/test/rtp_transport_test_util.h
+++ b/third_party/libwebrtc/pc/test/rtp_transport_test_util.h
@@ -33,9 +33,14 @@ class TransportObserver : public RtpPacketSinkInterface {
rtp_transport->SubscribeReadyToSend(
this, [this](bool arg) { OnReadyToSend(arg); });
rtp_transport->SetUnDemuxableRtpPacketReceivedHandler(
- [this](webrtc::RtpPacketReceived& packet) {
- OnUndemuxableRtpPacket(packet);
- });
+ [this](RtpPacketReceived& packet) { OnUndemuxableRtpPacket(packet); });
+ rtp_transport->SubscribeSentPacket(this,
+ [this](const rtc::SentPacket& packet) {
+ sent_packet_count_++;
+ if (action_on_sent_packet_) {
+ action_on_sent_packet_();
+ }
+ });
}
// RtpPacketInterface override.
@@ -57,6 +62,7 @@ class TransportObserver : public RtpPacketSinkInterface {
int rtp_count() const { return rtp_count_; }
int un_demuxable_rtp_count() const { return un_demuxable_rtp_count_; }
int rtcp_count() const { return rtcp_count_; }
+ int sent_packet_count() const { return sent_packet_count_; }
rtc::CopyOnWriteBuffer last_recv_rtp_packet() {
return last_recv_rtp_packet_;
@@ -81,16 +87,21 @@ class TransportObserver : public RtpPacketSinkInterface {
void SetActionOnReadyToSend(absl::AnyInvocable<void(bool)> action) {
action_on_ready_to_send_ = std::move(action);
}
+ void SetActionOnSentPacket(absl::AnyInvocable<void()> action) {
+ action_on_sent_packet_ = std::move(action);
+ }
private:
bool ready_to_send_ = false;
int rtp_count_ = 0;
int un_demuxable_rtp_count_ = 0;
int rtcp_count_ = 0;
+ int sent_packet_count_ = 0;
int ready_to_send_signal_count_ = 0;
rtc::CopyOnWriteBuffer last_recv_rtp_packet_;
rtc::CopyOnWriteBuffer last_recv_rtcp_packet_;
absl::AnyInvocable<void(bool)> action_on_ready_to_send_;
+ absl::AnyInvocable<void()> action_on_sent_packet_;
};
} // namespace webrtc
diff --git a/third_party/libwebrtc/pc/test/svc_e2e_tests.cc b/third_party/libwebrtc/pc/test/svc_e2e_tests.cc
index ae35c7f676..3fde5a44e0 100644
--- a/third_party/libwebrtc/pc/test/svc_e2e_tests.cc
+++ b/third_party/libwebrtc/pc/test/svc_e2e_tests.cc
@@ -160,10 +160,9 @@ std::string SvcTestNameGenerator(
// encoder and decoder level.
class SvcVideoQualityAnalyzer : public DefaultVideoQualityAnalyzer {
public:
- using SpatialTemporalLayerCounts =
- webrtc::flat_map<int, webrtc::flat_map<int, int>>;
+ using SpatialTemporalLayerCounts = flat_map<int, flat_map<int, int>>;
- explicit SvcVideoQualityAnalyzer(webrtc::Clock* clock)
+ explicit SvcVideoQualityAnalyzer(Clock* clock)
: DefaultVideoQualityAnalyzer(clock,
test::GetGlobalMetricsLogger(),
DefaultVideoQualityAnalyzerOptions{
@@ -315,9 +314,9 @@ TEST_P(SvcTest, ScalabilityModeSupported) {
if (UseDependencyDescriptor()) {
trials += "WebRTC-DependencyDescriptorAdvertised/Enabled/";
}
- webrtc::test::ScopedFieldTrials override_trials(AppendFieldTrials(trials));
+ test::ScopedFieldTrials override_trials(AppendFieldTrials(trials));
std::unique_ptr<NetworkEmulationManager> network_emulation_manager =
- CreateNetworkEmulationManager(webrtc::TimeMode::kSimulated);
+ CreateNetworkEmulationManager(TimeMode::kSimulated);
auto analyzer = std::make_unique<SvcVideoQualityAnalyzer>(
network_emulation_manager->time_controller()->GetClock());
SvcVideoQualityAnalyzer* analyzer_ptr = analyzer.get();
@@ -475,16 +474,17 @@ INSTANTIATE_TEST_SUITE_P(
SvcTestParameters::Create(kAv1CodecName, "L2T3h"),
SvcTestParameters::Create(kAv1CodecName, "L2T3_KEY"),
// SvcTestParameters::Create(kAv1CodecName, "L2T3_KEY_SHIFT"),
- SvcTestParameters::Create(kAv1CodecName, "L3T1"),
- SvcTestParameters::Create(kAv1CodecName, "L3T1h"),
- SvcTestParameters::Create(kAv1CodecName, "L3T1_KEY"),
- SvcTestParameters::Create(kAv1CodecName, "L3T2"),
- SvcTestParameters::Create(kAv1CodecName, "L3T2h"),
- SvcTestParameters::Create(kAv1CodecName, "L3T2_KEY"),
+ // TODO(bugs.webrtc.org/15666): Investigate and reenable AV1
+ // L3 tests. SvcTestParameters::Create(kAv1CodecName, "L3T1"),
+ // SvcTestParameters::Create(kAv1CodecName, "L3T1h"),
+ // SvcTestParameters::Create(kAv1CodecName, "L3T1_KEY"),
+ // SvcTestParameters::Create(kAv1CodecName, "L3T2"),
+ // SvcTestParameters::Create(kAv1CodecName, "L3T2h"),
+ // SvcTestParameters::Create(kAv1CodecName, "L3T2_KEY"),
// SvcTestParameters::Create(kAv1CodecName, "L3T2_KEY_SHIFT"),
- SvcTestParameters::Create(kAv1CodecName, "L3T3"),
- SvcTestParameters::Create(kAv1CodecName, "L3T3h"),
- SvcTestParameters::Create(kAv1CodecName, "L3T3_KEY"),
+ // SvcTestParameters::Create(kAv1CodecName, "L3T3"),
+ // SvcTestParameters::Create(kAv1CodecName, "L3T3h"),
+ // SvcTestParameters::Create(kAv1CodecName, "L3T3_KEY"),
// SvcTestParameters::Create(kAv1CodecName, "L3T3_KEY_SHIFT"),
SvcTestParameters::Create(kAv1CodecName, "S2T1"),
SvcTestParameters::Create(kAv1CodecName, "S2T1h"),
@@ -492,12 +492,14 @@ INSTANTIATE_TEST_SUITE_P(
SvcTestParameters::Create(kAv1CodecName, "S2T2h"),
SvcTestParameters::Create(kAv1CodecName, "S2T3"),
SvcTestParameters::Create(kAv1CodecName, "S2T3h"),
- SvcTestParameters::Create(kAv1CodecName, "S3T1"),
- SvcTestParameters::Create(kAv1CodecName, "S3T1h"),
- SvcTestParameters::Create(kAv1CodecName, "S3T2"),
- SvcTestParameters::Create(kAv1CodecName, "S3T2h"),
- SvcTestParameters::Create(kAv1CodecName, "S3T3"),
- SvcTestParameters::Create(kAv1CodecName, "S3T3h"),
+ // TODO(bugs.webrtc.org/15666): Investigate and reenable AV1
+ // S3 tests.
+ // SvcTestParameters::Create(kAv1CodecName, "S3T1"),
+ // SvcTestParameters::Create(kAv1CodecName, "S3T1h"),
+ // SvcTestParameters::Create(kAv1CodecName, "S3T2"),
+ // SvcTestParameters::Create(kAv1CodecName, "S3T2h"),
+ // SvcTestParameters::Create(kAv1CodecName, "S3T3"),
+ // SvcTestParameters::Create(kAv1CodecName, "S3T3h"),
}),
Values(UseDependencyDescriptor::Enabled)),
SvcTestNameGenerator);
diff --git a/third_party/libwebrtc/pc/video_rtp_receiver_unittest.cc b/third_party/libwebrtc/pc/video_rtp_receiver_unittest.cc
index 5ff736084f..e9729170b7 100644
--- a/third_party/libwebrtc/pc/video_rtp_receiver_unittest.cc
+++ b/third_party/libwebrtc/pc/video_rtp_receiver_unittest.cc
@@ -94,7 +94,7 @@ class VideoRtpReceiverTest : public testing::Test {
[&]() { receiver_->SetMediaChannel(media_channel); });
}
- webrtc::VideoTrackSourceInterface* Source() {
+ VideoTrackSourceInterface* Source() {
return receiver_->streams()[0]->FindVideoTrack("receiver")->GetSource();
}
diff --git a/third_party/libwebrtc/pc/video_rtp_track_source_unittest.cc b/third_party/libwebrtc/pc/video_rtp_track_source_unittest.cc
index 13728c7eff..55632cea42 100644
--- a/third_party/libwebrtc/pc/video_rtp_track_source_unittest.cc
+++ b/third_party/libwebrtc/pc/video_rtp_track_source_unittest.cc
@@ -109,11 +109,11 @@ TEST(VideoRtpTrackSourceTest, NoCallbacksAfterClearedCallback) {
class TestFrame : public RecordableEncodedFrame {
public:
- rtc::scoped_refptr<const webrtc::EncodedImageBufferInterface> encoded_buffer()
+ rtc::scoped_refptr<const EncodedImageBufferInterface> encoded_buffer()
const override {
return nullptr;
}
- absl::optional<webrtc::ColorSpace> color_space() const override {
+ absl::optional<ColorSpace> color_space() const override {
return absl::nullopt;
}
VideoCodecType codec() const override { return kVideoCodecGeneric; }
diff --git a/third_party/libwebrtc/pc/video_track.h b/third_party/libwebrtc/pc/video_track.h
index 13a51c454b..e504182c82 100644
--- a/third_party/libwebrtc/pc/video_track.h
+++ b/third_party/libwebrtc/pc/video_track.h
@@ -70,7 +70,7 @@ class VideoTrack : public MediaStreamTrack<VideoTrackInterface>,
// Implements ObserverInterface. Observes `video_source_` state.
void OnChanged() override;
- RTC_NO_UNIQUE_ADDRESS webrtc::SequenceChecker signaling_thread_;
+ RTC_NO_UNIQUE_ADDRESS SequenceChecker signaling_thread_;
rtc::Thread* const worker_thread_;
const rtc::scoped_refptr<
VideoTrackSourceProxyWithInternal<VideoTrackSourceInterface>>
diff --git a/third_party/libwebrtc/pc/video_track_source_proxy.h b/third_party/libwebrtc/pc/video_track_source_proxy.h
index 8500a98766..40d24234ad 100644
--- a/third_party/libwebrtc/pc/video_track_source_proxy.h
+++ b/third_party/libwebrtc/pc/video_track_source_proxy.h
@@ -52,7 +52,7 @@ PROXY_SECONDARY_METHOD1(void,
rtc::VideoSinkInterface<RecordableEncodedFrame>*)
PROXY_SECONDARY_METHOD1(void,
ProcessConstraints,
- const webrtc::VideoTrackSourceConstraints&)
+ const VideoTrackSourceConstraints&)
END_PROXY_MAP(VideoTrackSource)
} // namespace webrtc
diff --git a/third_party/libwebrtc/pc/webrtc_sdp.cc b/third_party/libwebrtc/pc/webrtc_sdp.cc
index 2a3173cb02..da024eab81 100644
--- a/third_party/libwebrtc/pc/webrtc_sdp.cc
+++ b/third_party/libwebrtc/pc/webrtc_sdp.cc
@@ -267,11 +267,9 @@ struct SsrcInfo {
std::string stream_id;
std::string track_id;
};
-typedef std::vector<SsrcInfo> SsrcInfoVec;
-typedef std::vector<SsrcGroup> SsrcGroupVec;
+using SsrcInfoVec = std::vector<SsrcInfo>;
+using SsrcGroupVec = std::vector<SsrcGroup>;
-template <class T>
-static void AddFmtpLine(const T& codec, std::string* message);
static void BuildMediaDescription(const ContentInfo* content_info,
const TransportInfo* transport_info,
const cricket::MediaType media_type,
@@ -2628,7 +2626,7 @@ static std::unique_ptr<MediaContentDescription> ParseContentDescription(
int* msid_signaling,
TransportDescription* transport,
std::vector<std::unique_ptr<JsepIceCandidate>>* candidates,
- webrtc::SdpParseError* error) {
+ SdpParseError* error) {
std::unique_ptr<MediaContentDescription> media_desc;
if (media_type == cricket::MediaType::MEDIA_TYPE_AUDIO) {
media_desc = std::make_unique<AudioContentDescription>();
diff --git a/third_party/libwebrtc/pc/webrtc_sdp_unittest.cc b/third_party/libwebrtc/pc/webrtc_sdp_unittest.cc
index 2c43c35d15..ae26ba0ce2 100644
--- a/third_party/libwebrtc/pc/webrtc_sdp_unittest.cc
+++ b/third_party/libwebrtc/pc/webrtc_sdp_unittest.cc
@@ -1316,8 +1316,9 @@ class WebRtcSdpTest : public ::testing::Test {
return video;
}
- template <class MCD>
- void CompareMediaContentDescription(const MCD* cd1, const MCD* cd2) {
+ void CompareMediaContentDescription(
+ const cricket::MediaContentDescription* cd1,
+ const cricket::MediaContentDescription* cd2) {
// type
EXPECT_EQ(cd1->type(), cd2->type());
@@ -1427,20 +1428,14 @@ class WebRtcSdpTest : public ::testing::Test {
ASSERT_EQ(IsAudioContent(&c1), IsAudioContent(&c2));
if (IsAudioContent(&c1)) {
- const AudioContentDescription* acd1 =
- c1.media_description()->as_audio();
- const AudioContentDescription* acd2 =
- c2.media_description()->as_audio();
- CompareMediaContentDescription<AudioContentDescription>(acd1, acd2);
+ CompareMediaContentDescription(c1.media_description(),
+ c2.media_description());
}
ASSERT_EQ(IsVideoContent(&c1), IsVideoContent(&c2));
if (IsVideoContent(&c1)) {
- const VideoContentDescription* vcd1 =
- c1.media_description()->as_video();
- const VideoContentDescription* vcd2 =
- c2.media_description()->as_video();
- CompareMediaContentDescription<VideoContentDescription>(vcd1, vcd2);
+ CompareMediaContentDescription(c1.media_description(),
+ c2.media_description());
}
ASSERT_EQ(IsDataContent(&c1), IsDataContent(&c2));
@@ -5015,7 +5010,7 @@ TEST_F(WebRtcSdpTest, ParseSessionLevelExtmapAttributes) {
EXPECT_TRUE(SdpDeserialize(sdp, &jdesc));
ASSERT_EQ(1u, jdesc.description()->contents().size());
const auto content = jdesc.description()->contents()[0];
- const auto* audio_description = content.media_description()->as_audio();
+ const auto* audio_description = content.media_description();
ASSERT_NE(audio_description, nullptr);
const auto& extensions = audio_description->rtp_header_extensions();
ASSERT_EQ(1u, extensions.size());