diff --git a/call/BUILD.gn b/call/BUILD.gn index 6ce4327475..7637f4f969 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -734,13 +734,19 @@ if (rtc_include_tests) { ] deps = [ ":rtp_interfaces", + "../api:fec_controller_api", "../api:frame_transformer_interface", "../api:libjingle_peerconnection_api", + "../api:scoped_refptr", "../api/crypto:frame_encryptor_interface", "../api/crypto:options", + "../api/transport:bandwidth_estimation_settings", "../api/transport:bitrate_settings", + "../api/transport:network_control", + "../api/units:timestamp", "../modules/pacing", "../modules/rtp_rtcp", + "../modules/rtp_rtcp:rtp_rtcp_format", "../rtc_base:network_route", "../rtc_base:rate_limiter", "../rtc_base/network:sent_packet", diff --git a/call/call.cc b/call/call.cc index 2b7751742f..d2e8764c8c 100644 --- a/call/call.cc +++ b/call/call.cc @@ -278,6 +278,9 @@ class Call final : public webrtc::Call, Stats GetStats() const override; + void EnableSendCongestionControlFeedbackAccordingToRfc8888() override; + int FeedbackAccordingToRfc8888Count() override; + const FieldTrialsView& trials() const override; TaskQueueBase* network_thread() const override; @@ -1189,6 +1192,14 @@ Call::Stats Call::GetStats() const { return stats; } +void Call::EnableSendCongestionControlFeedbackAccordingToRfc8888() { + receive_side_cc_.EnableSendCongestionControlFeedbackAccordingToRfc8888(); +} + +int Call::FeedbackAccordingToRfc8888Count() { + return transport_send_->ReceivedCongestionControlFeedbackCount(); +} + const FieldTrialsView& Call::trials() const { return env_.field_trials(); } diff --git a/call/call.h b/call/call.h index 341d55d52b..c69e37416f 100644 --- a/call/call.h +++ b/call/call.h @@ -153,6 +153,9 @@ class Call { virtual void SetClientBitratePreferences( const BitrateSettings& preferences) = 0; + virtual void EnableSendCongestionControlFeedbackAccordingToRfc8888() = 0; + virtual int FeedbackAccordingToRfc8888Count() = 0; + virtual const FieldTrialsView& trials() const = 0; virtual TaskQueueBase* network_thread() const = 0; diff --git a/call/rtp_transport_controller_send.cc b/call/rtp_transport_controller_send.cc index 81754f9666..8232d3c741 100644 --- a/call/rtp_transport_controller_send.cc +++ b/call/rtp_transport_controller_send.cc @@ -656,6 +656,7 @@ void RtpTransportControllerSend::OnCongestionControlFeedback( Timestamp receive_time, const rtcp::CongestionControlFeedback& feedback) { RTC_DCHECK_RUN_ON(&sequence_checker_); + ++feedback_count_; // TODO: bugs.webrtc.org/42225697 - update feedback demuxer for RFC 8888. // Suggest feedback_demuxer_.OnTransportFeedback use TransportPacketFeedback // instead. See usage in OnTransportFeedback. diff --git a/call/rtp_transport_controller_send.h b/call/rtp_transport_controller_send.h index 51f8faee04..f4f29b06a8 100644 --- a/call/rtp_transport_controller_send.h +++ b/call/rtp_transport_controller_send.h @@ -142,6 +142,11 @@ class RtpTransportControllerSend final return controller_.get(); } + int ReceivedCongestionControlFeedbackCount() const override { + RTC_DCHECK_RUN_ON(&sequence_checker_); + return feedback_count_; + } + private: void MaybeCreateControllers() RTC_RUN_ON(sequence_checker_); void UpdateNetworkAvailability() RTC_RUN_ON(sequence_checker_); @@ -228,6 +233,8 @@ class RtpTransportControllerSend final DataSize congestion_window_size_ RTC_GUARDED_BY(sequence_checker_); bool is_congested_ RTC_GUARDED_BY(sequence_checker_); + // Count of feedback messages received. + int feedback_count_ RTC_GUARDED_BY(sequence_checker_) = 0; // Protected by internal locks. RateLimiter retransmission_rate_limiter_; diff --git a/call/rtp_transport_controller_send_interface.h b/call/rtp_transport_controller_send_interface.h index a80dd83bc5..dc2e072254 100644 --- a/call/rtp_transport_controller_send_interface.h +++ b/call/rtp_transport_controller_send_interface.h @@ -161,6 +161,8 @@ class RtpTransportControllerSendInterface { virtual void EnsureStarted() = 0; virtual NetworkControllerInterface* GetNetworkController() = 0; + // Count of RFC8888 feedback reports received + virtual int ReceivedCongestionControlFeedbackCount() const = 0; }; } // namespace webrtc diff --git a/call/test/mock_rtp_transport_controller_send.h b/call/test/mock_rtp_transport_controller_send.h index 84caccf8f2..cfdcb91e79 100644 --- a/call/test/mock_rtp_transport_controller_send.h +++ b/call/test/mock_rtp_transport_controller_send.h @@ -11,22 +11,28 @@ #ifndef CALL_TEST_MOCK_RTP_TRANSPORT_CONTROLLER_SEND_H_ #define CALL_TEST_MOCK_RTP_TRANSPORT_CONTROLLER_SEND_H_ +#include +#include #include #include -#include -#include +#include #include "absl/strings/string_view.h" -#include "api/crypto/crypto_options.h" -#include "api/crypto/frame_encryptor_interface.h" +#include "api/fec_controller.h" #include "api/frame_transformer_interface.h" +#include "api/scoped_refptr.h" +#include "api/transport/bandwidth_estimation_settings.h" #include "api/transport/bitrate_settings.h" +#include "api/transport/network_control.h" +#include "api/transport/network_types.h" +#include "api/units/timestamp.h" +#include "call/rtp_config.h" #include "call/rtp_transport_controller_send_interface.h" #include "modules/pacing/packet_router.h" +#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/source/rtp_rtcp_interface.h" #include "rtc_base/network/sent_packet.h" #include "rtc_base/network_route.h" -#include "rtc_base/rate_limiter.h" #include "test/gmock.h" namespace webrtc { @@ -109,6 +115,10 @@ class MockRtpTransportControllerSend GetNetworkController, (), (override)); + MOCK_METHOD(int, + ReceivedCongestionControlFeedbackCount, + (), + (const, override)); }; } // namespace webrtc #endif // CALL_TEST_MOCK_RTP_TRANSPORT_CONTROLLER_SEND_H_ diff --git a/media/engine/fake_webrtc_call.h b/media/engine/fake_webrtc_call.h index 0029b1d23c..ce2ec2057c 100644 --- a/media/engine/fake_webrtc_call.h +++ b/media/engine/fake_webrtc_call.h @@ -469,6 +469,8 @@ class FakeCall final : public webrtc::Call, public webrtc::PacketReceiver { const webrtc::FieldTrialsView& trials() const override { return env_.field_trials(); } + void EnableSendCongestionControlFeedbackAccordingToRfc8888() override {} + int FeedbackAccordingToRfc8888Count() { return 0; } private: webrtc::AudioSendStream* CreateAudioSendStream( diff --git a/modules/congestion_controller/BUILD.gn b/modules/congestion_controller/BUILD.gn index 2c00735235..bc1810e9bc 100644 --- a/modules/congestion_controller/BUILD.gn +++ b/modules/congestion_controller/BUILD.gn @@ -18,6 +18,7 @@ rtc_library("congestion_controller") { ] deps = [ + "..:module_api", "../../api:rtp_parameters", "../../api:sequence_checker", "../../api/environment", @@ -28,6 +29,7 @@ rtc_library("congestion_controller") { "../../api/units:timestamp", "../../rtc_base:logging", "../../rtc_base:macromagic", + "../../rtc_base/experiments:field_trial_parser", "../../rtc_base/synchronization:mutex", "../pacing", "../remote_bitrate_estimator", @@ -56,6 +58,7 @@ if (rtc_include_tests && !build_with_chromium) { "../../api/units:data_size", "../../api/units:time_delta", "../../api/units:timestamp", + "../../rtc_base:buffer", "../../system_wrappers", "../../test:explicit_key_value_config", "../../test:test_support", diff --git a/modules/congestion_controller/include/receive_side_congestion_controller.h b/modules/congestion_controller/include/receive_side_congestion_controller.h index 7dec287660..b23ea4c86c 100644 --- a/modules/congestion_controller/include/receive_side_congestion_controller.h +++ b/modules/congestion_controller/include/receive_side_congestion_controller.h @@ -11,15 +11,19 @@ #ifndef MODULES_CONGESTION_CONTROLLER_INCLUDE_RECEIVE_SIDE_CONGESTION_CONTROLLER_H_ #define MODULES_CONGESTION_CONTROLLER_INCLUDE_RECEIVE_SIDE_CONGESTION_CONTROLLER_H_ +#include #include #include "absl/base/nullability.h" #include "api/environment/environment.h" +#include "api/media_types.h" #include "api/sequence_checker.h" #include "api/transport/network_control.h" #include "api/units/data_rate.h" +#include "api/units/data_size.h" #include "api/units/time_delta.h" #include "modules/congestion_controller/remb_throttler.h" +#include "modules/include/module_common_types.h" #include "modules/remote_bitrate_estimator/congestion_control_feedback_generator.h" #include "modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" @@ -44,7 +48,7 @@ class ReceiveSideCongestionController : public CallStatsObserver { ~ReceiveSideCongestionController() override = default; - void EnablSendCongestionControlFeedbackAccordingToRfc8888(); + void EnableSendCongestionControlFeedbackAccordingToRfc8888(); void OnReceivedPacket(const RtpPacketReceived& packet, MediaType media_type); diff --git a/modules/congestion_controller/receive_side_congestion_controller.cc b/modules/congestion_controller/receive_side_congestion_controller.cc index a3d0e38867..df3a9a3b57 100644 --- a/modules/congestion_controller/receive_side_congestion_controller.cc +++ b/modules/congestion_controller/receive_side_congestion_controller.cc @@ -11,6 +11,7 @@ #include "modules/congestion_controller/include/receive_side_congestion_controller.h" #include +#include #include #include @@ -18,13 +19,21 @@ #include "api/environment/environment.h" #include "api/media_types.h" #include "api/sequence_checker.h" +#include "api/transport/network_control.h" #include "api/units/data_rate.h" +#include "api/units/data_size.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" +#include "modules/congestion_controller/remb_throttler.h" #include "modules/remote_bitrate_estimator/congestion_control_feedback_generator.h" #include "modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h" #include "modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h" #include "modules/remote_bitrate_estimator/transport_sequence_number_feedback_generator.h" #include "modules/rtp_rtcp/source/rtp_header_extensions.h" +#include "modules/rtp_rtcp/source/rtp_packet_received.h" +#include "rtc_base/experiments/field_trial_parser.h" #include "rtc_base/logging.h" +#include "rtc_base/synchronization/mutex.h" namespace webrtc { @@ -96,12 +105,12 @@ ReceiveSideCongestionController::ReceiveSideCongestionController( {&force_send_rfc8888_feedback}, env.field_trials().Lookup("WebRTC-RFC8888CongestionControlFeedback")); if (force_send_rfc8888_feedback) { - EnablSendCongestionControlFeedbackAccordingToRfc8888(); + EnableSendCongestionControlFeedbackAccordingToRfc8888(); } } void ReceiveSideCongestionController:: - EnablSendCongestionControlFeedbackAccordingToRfc8888() { + EnableSendCongestionControlFeedbackAccordingToRfc8888() { RTC_DCHECK_RUN_ON(&sequence_checker_); send_rfc8888_congestion_feedback_ = true; } diff --git a/modules/congestion_controller/receive_side_congestion_controller_unittest.cc b/modules/congestion_controller/receive_side_congestion_controller_unittest.cc index 385a6b446c..e954011a09 100644 --- a/modules/congestion_controller/receive_side_congestion_controller_unittest.cc +++ b/modules/congestion_controller/receive_side_congestion_controller_unittest.cc @@ -10,6 +10,7 @@ #include "modules/congestion_controller/include/receive_side_congestion_controller.h" +#include #include #include @@ -22,13 +23,18 @@ #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "modules/rtp_rtcp/include/rtp_header_extension_map.h" +#include "modules/rtp_rtcp/source/rtcp_packet.h" +#include "modules/rtp_rtcp/source/rtcp_packet/common_header.h" +#include "modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback.h" #include "modules/rtp_rtcp/source/rtp_header_extensions.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" +#include "rtc_base/buffer.h" #include "system_wrappers/include/clock.h" #include "test/explicit_key_value_config.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/scenario/scenario.h" +#include "test/scenario/scenario_config.h" namespace webrtc { namespace test { @@ -133,7 +139,7 @@ TEST(ReceiveSideCongestionControllerTest, SendsRfc8888FeedbackIfEnabled) { ReceiveSideCongestionController controller( CreateEnvironment(&clock), rtcp_sender.AsStdFunction(), remb_sender.AsStdFunction(), nullptr); - controller.EnablSendCongestionControlFeedbackAccordingToRfc8888(); + controller.EnableSendCongestionControlFeedbackAccordingToRfc8888(); // Expect that RTCP feedback is sent. EXPECT_CALL(rtcp_sender, Call) diff --git a/pc/BUILD.gn b/pc/BUILD.gn index 9b41ba32ca..058fd37b72 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -1128,6 +1128,7 @@ rtc_source_set("peer_connection") { "../api/transport:bitrate_settings", "../api/transport:datagram_transport_interface", "../api/transport:enums", + "../api/transport:network_control", "../api/units:time_delta", "../api/video:video_codec_constants", "../call:call_interfaces", @@ -2567,6 +2568,7 @@ if (rtc_include_tests && !build_with_chromium) { "../api:ice_transport_interface", "../api:libjingle_logging_api", "../api:libjingle_peerconnection_api", + "../api:make_ref_counted", "../api:media_stream_interface", "../api:mock_async_dns_resolver", "../api:mock_rtp", @@ -2577,6 +2579,7 @@ if (rtc_include_tests && !build_with_chromium) { "../api:rtp_sender_interface", "../api:rtp_transceiver_direction", "../api:scoped_refptr", + "../api:sequence_checker", "../api/audio:audio_device", "../api/audio:audio_mixer_api", "../api/audio:audio_processing", @@ -2584,6 +2587,7 @@ if (rtc_include_tests && !build_with_chromium) { "../api/crypto:frame_decryptor_interface", "../api/crypto:frame_encryptor_interface", "../api/crypto:options", + "../api/metronome", "../api/rtc_event_log", "../api/rtc_event_log:rtc_event_log_factory", "../api/task_queue", @@ -2630,6 +2634,8 @@ if (rtc_include_tests && !build_with_chromium) { "../rtc_base:rtc_json", "../rtc_base:safe_conversions", "../rtc_base:socket_address", + "../rtc_base:socket_factory", + "../rtc_base:socket_server", "../rtc_base:ssl", "../rtc_base:ssl_adapter", "../rtc_base:task_queue_for_test", @@ -2647,6 +2653,7 @@ if (rtc_include_tests && !build_with_chromium) { "../test/pc/sctp:fake_sctp_transport", "../test/time_controller", "//third_party/abseil-cpp/absl/algorithm:container", + "//third_party/abseil-cpp/absl/functional:any_invocable", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", ] diff --git a/pc/congestion_control_integrationtest.cc b/pc/congestion_control_integrationtest.cc index a60553fb5e..634c52b629 100644 --- a/pc/congestion_control_integrationtest.cc +++ b/pc/congestion_control_integrationtest.cc @@ -66,4 +66,21 @@ TEST_F(PeerConnectionCongestionControlTest, ReceiveOfferSetsCcfbFlag) { } } +TEST_F(PeerConnectionCongestionControlTest, CcfbGetsUsed) { + test::ScopedFieldTrials trials( + "WebRTC-RFC8888CongestionControlFeedback/Enabled/"); + ASSERT_TRUE(CreatePeerConnectionWrappers()); + ConnectFakeSignaling(); + caller()->AddAudioVideoTracks(); + caller()->CreateAndSetAndSignalOffer(); + ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); + MediaExpectations media_expectations; + media_expectations.CalleeExpectsSomeAudio(); + media_expectations.CalleeExpectsSomeVideo(); + ASSERT_TRUE(ExpectNewFrames(media_expectations)); + auto pc_internal = caller()->pc_internal(); + EXPECT_TRUE_WAIT(pc_internal->FeedbackAccordingToRfc8888CountForTesting() > 0, + kDefaultTimeout); +} + } // namespace webrtc diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index 1171bc8929..a9559c3a6f 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -3031,6 +3031,13 @@ void PeerConnection::RequestUsagePatternReportForTesting() { /* delay_ms= */ 0); } +int PeerConnection::FeedbackAccordingToRfc8888CountForTesting() const { + return worker_thread()->BlockingCall([this]() { + RTC_DCHECK_RUN_ON(worker_thread()); + return call_->FeedbackAccordingToRfc8888Count(); + }); +} + std::function PeerConnection::InitializeRtcpCallback() { diff --git a/pc/peer_connection.h b/pc/peer_connection.h index 16e43c75d4..923b9be4ba 100644 --- a/pc/peer_connection.h +++ b/pc/peer_connection.h @@ -21,8 +21,10 @@ #include #include +#include "absl/strings/string_view.h" #include "api/adaptation/resource.h" #include "api/async_dns_resolver.h" +#include "api/audio/audio_device.h" #include "api/candidate.h" #include "api/crypto/crypto_options.h" #include "api/data_channel_interface.h" @@ -35,8 +37,8 @@ #include "api/media_types.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_output.h" +#include "api/rtp_parameters.h" #include "api/rtp_receiver_interface.h" #include "api/rtp_sender_interface.h" #include "api/rtp_transceiver_interface.h" @@ -47,11 +49,14 @@ #include "api/set_remote_description_observer_interface.h" #include "api/stats/rtc_stats_collector_callback.h" #include "api/task_queue/pending_task_safety_flag.h" +#include "api/transport/bandwidth_estimation_settings.h" #include "api/transport/bitrate_settings.h" #include "api/transport/data_channel_transport_interface.h" #include "api/transport/enums.h" +#include "api/transport/network_control.h" #include "api/turn_customizer.h" #include "call/call.h" +#include "call/payload_type_picker.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "p2p/base/ice_transport_internal.h" #include "p2p/base/port.h" @@ -70,7 +75,6 @@ #include "pc/rtp_transceiver.h" #include "pc/rtp_transmission_manager.h" #include "pc/rtp_transport_internal.h" -#include "pc/sctp_data_channel.h" #include "pc/sdp_offer_answer.h" #include "pc/session_description.h" #include "pc/transceiver_list.h" @@ -438,6 +442,7 @@ class PeerConnection : public PeerConnectionInternal, return_histogram_very_quickly_ = true; } void RequestUsagePatternReportForTesting(); + int FeedbackAccordingToRfc8888CountForTesting() const; NetworkControllerInterface* GetNetworkController() override { if (!worker_thread()->IsCurrent()) { diff --git a/pc/sdp_offer_answer.cc b/pc/sdp_offer_answer.cc index 0542910941..3f7e74bb1e 100644 --- a/pc/sdp_offer_answer.cc +++ b/pc/sdp_offer_answer.cc @@ -4892,6 +4892,8 @@ RTCError SdpOfferAnswerHandler::PushdownMediaDescription( std::vector< std::pair> channels; + bool use_ccfb = false; + bool seen_ccfb = false; for (const auto& transceiver : rtp_transceivers) { const ContentInfo* content_info = FindMediaSectionForTransceiver(transceiver, sdesc); @@ -4904,6 +4906,17 @@ RTCError SdpOfferAnswerHandler::PushdownMediaDescription( if (!content_desc) { continue; } + // RFC 8888 says that the ccfb must be consistent across the description. + if (seen_ccfb) { + if (use_ccfb != content_desc->rtcp_fb_ack_ccfb()) { + RTC_LOG(LS_ERROR) + << "Warning: Inconsistent CCFB flag - CCFB turned off"; + use_ccfb = false; + } + } else { + use_ccfb = content_desc->rtcp_fb_ack_ccfb(); + seen_ccfb = true; + } transceiver->OnNegotiationUpdate(type, content_desc); channels.push_back(std::make_pair(channel, content_desc)); @@ -4930,6 +4943,17 @@ RTCError SdpOfferAnswerHandler::PushdownMediaDescription( LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, error); } } + // If local and remote are both set, we assume that it's safe to trigger + // CCFB. + if (context_->env().field_trials().IsEnabled( + "WebRTC-RFC8888CongestionControlFeedback")) { + if (use_ccfb && local_description() && remote_description()) { + // The call and the congestion controller live on the worker thread. + context_->worker_thread()->PostTask([call = pc_->call_ptr()] { + call->EnableSendCongestionControlFeedbackAccordingToRfc8888(); + }); + } + } } // Need complete offer/answer with an SCTP m= section before starting SCTP, // according to https://tools.ietf.org/html/draft-ietf-mmusic-sctp-sdp-19 diff --git a/pc/test/integration_test_helpers.cc b/pc/test/integration_test_helpers.cc index 9033e65e29..332f084747 100644 --- a/pc/test/integration_test_helpers.cc +++ b/pc/test/integration_test_helpers.cc @@ -10,7 +10,37 @@ #include "pc/test/integration_test_helpers.h" +#include +#include +#include +#include +#include +#include + +#include "absl/functional/any_invocable.h" #include "api/audio/builtin_audio_processing_builder.h" +#include "api/enable_media_with_defaults.h" +#include "api/jsep.h" +#include "api/peer_connection_interface.h" +#include "api/rtc_event_log/rtc_event_log_factory.h" +#include "api/sequence_checker.h" +#include "api/stats/rtcstats_objects.h" +#include "api/task_queue/default_task_queue_factory.h" +#include "api/task_queue/pending_task_safety_flag.h" +#include "api/task_queue/task_queue_base.h" +#include "api/transport/field_trial_based_config.h" +#include "api/units/time_delta.h" +#include "logging/rtc_event_log/fake_rtc_event_log_factory.h" +#include "p2p/base/basic_packet_socket_factory.h" +#include "p2p/base/port_allocator.h" +#include "p2p/client/basic_port_allocator.h" +#include "pc/peer_connection_factory.h" +#include "pc/test/fake_audio_capture_module.h" +#include "rtc_base/checks.h" +#include "rtc_base/fake_network.h" +#include "rtc_base/socket_server.h" +#include "rtc_base/thread.h" +#include "test/gtest.h" namespace webrtc { diff --git a/pc/test/integration_test_helpers.h b/pc/test/integration_test_helpers.h index 6dbbd0b1ee..7d9216e752 100644 --- a/pc/test/integration_test_helpers.h +++ b/pc/test/integration_test_helpers.h @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -27,66 +26,47 @@ #include #include -#include "absl/algorithm/container.h" +#include "absl/functional/any_invocable.h" #include "absl/memory/memory.h" #include "absl/strings/string_view.h" -#include "api/audio/audio_device.h" -#include "api/audio/audio_processing.h" #include "api/audio_options.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" +#include "api/make_ref_counted.h" #include "api/media_stream_interface.h" #include "api/media_types.h" +#include "api/metronome/metronome.h" #include "api/peer_connection_interface.h" #include "api/rtc_error.h" -#include "api/rtc_event_log/rtc_event_log_factory.h" -#include "api/rtc_event_log/rtc_event_log_factory_interface.h" #include "api/rtc_event_log_output.h" +#include "api/rtp_parameters.h" #include "api/rtp_receiver_interface.h" #include "api/rtp_sender_interface.h" #include "api/rtp_transceiver_interface.h" #include "api/scoped_refptr.h" -#include "api/stats/rtc_stats.h" +#include "api/sequence_checker.h" #include "api/stats/rtc_stats_report.h" #include "api/stats/rtcstats_objects.h" -#include "api/task_queue/default_task_queue_factory.h" #include "api/task_queue/pending_task_safety_flag.h" -#include "api/task_queue/task_queue_factory.h" #include "api/test/mock_async_dns_resolver.h" -#include "api/transport/field_trial_based_config.h" -#include "api/uma_metrics.h" #include "api/units/time_delta.h" #include "api/video/video_rotation.h" -#include "api/video_codecs/sdp_video_format.h" -#include "api/video_codecs/video_decoder_factory.h" -#include "api/video_codecs/video_encoder_factory.h" -#include "call/call.h" #include "logging/rtc_event_log/fake_rtc_event_log_factory.h" -#include "media/base/media_engine.h" #include "media/base/stream_params.h" -#include "media/engine/fake_webrtc_video_engine.h" #include "p2p/base/fake_ice_transport.h" #include "p2p/base/ice_transport_internal.h" -#include "p2p/base/p2p_constants.h" #include "p2p/base/port.h" #include "p2p/base/port_allocator.h" #include "p2p/base/port_interface.h" -#include "p2p/base/test_stun_server.h" #include "p2p/base/test_turn_customizer.h" #include "p2p/base/test_turn_server.h" -#include "p2p/client/basic_port_allocator.h" -#include "pc/dtmf_sender.h" -#include "pc/local_audio_source.h" -#include "pc/media_session.h" #include "pc/peer_connection.h" #include "pc/peer_connection_factory.h" #include "pc/peer_connection_proxy.h" -#include "pc/rtp_media_utils.h" #include "pc/session_description.h" #include "pc/test/fake_audio_capture_module.h" #include "pc/test/fake_periodic_video_source.h" @@ -97,28 +77,23 @@ #include "pc/video_track_source.h" #include "rtc_base/checks.h" #include "rtc_base/crypto_random.h" -#include "rtc_base/event.h" -#include "rtc_base/fake_clock.h" #include "rtc_base/fake_mdns_responder.h" #include "rtc_base/fake_network.h" #include "rtc_base/firewall_socket_server.h" #include "rtc_base/gunit.h" #include "rtc_base/ip_address.h" #include "rtc_base/logging.h" -#include "rtc_base/mdns_responder_interface.h" -#include "rtc_base/numerics/safe_conversions.h" -#include "rtc_base/rtc_certificate_generator.h" #include "rtc_base/socket_address.h" +#include "rtc_base/socket_factory.h" +#include "rtc_base/socket_server.h" #include "rtc_base/ssl_stream_adapter.h" #include "rtc_base/task_queue_for_test.h" -#include "rtc_base/task_utils/repeating_task.h" -#include "rtc_base/test_certificate_verifier.h" #include "rtc_base/thread.h" -#include "rtc_base/thread_annotations.h" #include "rtc_base/time_utils.h" #include "rtc_base/virtual_socket_server.h" #include "system_wrappers/include/metrics.h" #include "test/gmock.h" +#include "test/gtest.h" #include "test/scoped_key_value_config.h" namespace webrtc { @@ -266,6 +241,15 @@ class PeerConnectionIntegrationWrapper : public PeerConnectionObserver, PeerConnectionInterface* pc() const { return peer_connection_.get(); } + // Return the PC implementation, so that non-public interfaces + // can be used in tests. + PeerConnection* pc_internal() const { + auto* pci = + static_cast*>( + pc()); + return static_cast(pci->internal()); + } + // If a signaling message receiver is set (via ConnectFakeSignaling), this // will set the whole offer/answer exchange in motion. Just need to wait for // the signaling state to reach "stable".