diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/third_party/webrtc/pc/test | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/webrtc/pc/test')
14 files changed, 286 insertions, 170 deletions
diff --git a/chromium/third_party/webrtc/pc/test/fake_audio_capture_module.cc b/chromium/third_party/webrtc/pc/test/fake_audio_capture_module.cc index db0886ddad4..1a7efd4ad12 100644 --- a/chromium/third_party/webrtc/pc/test/fake_audio_capture_module.cc +++ b/chromium/third_party/webrtc/pc/test/fake_audio_capture_module.cc @@ -47,7 +47,9 @@ FakeAudioCaptureModule::FakeAudioCaptureModule() current_mic_level_(kMaxVolume), started_(false), next_frame_time_(0), - frames_received_(0) {} + frames_received_(0) { + process_thread_checker_.Detach(); +} FakeAudioCaptureModule::~FakeAudioCaptureModule() { if (process_thread_) { @@ -77,7 +79,7 @@ int32_t FakeAudioCaptureModule::ActiveAudioLayer( int32_t FakeAudioCaptureModule::RegisterAudioCallback( webrtc::AudioTransport* audio_callback) { - rtc::CritScope cs(&crit_callback_); + rtc::CritScope cs(&crit_); audio_callback_ = audio_callback; return 0; } @@ -448,29 +450,34 @@ void FakeAudioCaptureModule::UpdateProcessing(bool start) { if (process_thread_) { process_thread_->Stop(); process_thread_.reset(nullptr); + process_thread_checker_.Detach(); } + rtc::CritScope lock(&crit_); started_ = false; } } void FakeAudioCaptureModule::StartProcessP() { - RTC_CHECK(process_thread_->IsCurrent()); - if (started_) { - // Already started. - return; + RTC_DCHECK_RUN_ON(&process_thread_checker_); + { + rtc::CritScope lock(&crit_); + if (started_) { + // Already started. + return; + } } ProcessFrameP(); } void FakeAudioCaptureModule::ProcessFrameP() { - RTC_CHECK(process_thread_->IsCurrent()); - if (!started_) { - next_frame_time_ = rtc::TimeMillis(); - started_ = true; - } - + RTC_DCHECK_RUN_ON(&process_thread_checker_); { rtc::CritScope cs(&crit_); + if (!started_) { + next_frame_time_ = rtc::TimeMillis(); + started_ = true; + } + // Receive and send frames every kTimePerFrameMs. if (playing_) { ReceiveFrameP(); @@ -488,24 +495,22 @@ void FakeAudioCaptureModule::ProcessFrameP() { } void FakeAudioCaptureModule::ReceiveFrameP() { - RTC_CHECK(process_thread_->IsCurrent()); - { - rtc::CritScope cs(&crit_callback_); - if (!audio_callback_) { - return; - } - ResetRecBuffer(); - size_t nSamplesOut = 0; - int64_t elapsed_time_ms = 0; - int64_t ntp_time_ms = 0; - if (audio_callback_->NeedMorePlayData( - kNumberSamples, kNumberBytesPerSample, kNumberOfChannels, - kSamplesPerSecond, rec_buffer_, nSamplesOut, &elapsed_time_ms, - &ntp_time_ms) != 0) { - RTC_NOTREACHED(); - } - RTC_CHECK(nSamplesOut == kNumberSamples); + RTC_DCHECK_RUN_ON(&process_thread_checker_); + if (!audio_callback_) { + return; + } + ResetRecBuffer(); + size_t nSamplesOut = 0; + int64_t elapsed_time_ms = 0; + int64_t ntp_time_ms = 0; + if (audio_callback_->NeedMorePlayData(kNumberSamples, kNumberBytesPerSample, + kNumberOfChannels, kSamplesPerSecond, + rec_buffer_, nSamplesOut, + &elapsed_time_ms, &ntp_time_ms) != 0) { + RTC_NOTREACHED(); } + RTC_CHECK(nSamplesOut == kNumberSamples); + // The SetBuffer() function ensures that after decoding, the audio buffer // should contain samples of similar magnitude (there is likely to be some // distortion due to the audio pipeline). If one sample is detected to @@ -513,25 +518,22 @@ void FakeAudioCaptureModule::ReceiveFrameP() { // has been received from the remote side (i.e. faked frames are not being // pulled). if (CheckRecBuffer(kHighSampleValue)) { - rtc::CritScope cs(&crit_); ++frames_received_; } } void FakeAudioCaptureModule::SendFrameP() { - RTC_CHECK(process_thread_->IsCurrent()); - rtc::CritScope cs(&crit_callback_); + RTC_DCHECK_RUN_ON(&process_thread_checker_); if (!audio_callback_) { return; } bool key_pressed = false; - uint32_t current_mic_level = 0; - MicrophoneVolume(¤t_mic_level); + uint32_t current_mic_level = current_mic_level_; if (audio_callback_->RecordedDataIsAvailable( send_buffer_, kNumberSamples, kNumberBytesPerSample, kNumberOfChannels, kSamplesPerSecond, kTotalDelayMs, kClockDriftMs, current_mic_level, key_pressed, current_mic_level) != 0) { RTC_NOTREACHED(); } - SetMicrophoneVolume(current_mic_level); + current_mic_level_ = current_mic_level; } diff --git a/chromium/third_party/webrtc/pc/test/fake_audio_capture_module.h b/chromium/third_party/webrtc/pc/test/fake_audio_capture_module.h index 0af38102908..2a5d54c84e4 100644 --- a/chromium/third_party/webrtc/pc/test/fake_audio_capture_module.h +++ b/chromium/third_party/webrtc/pc/test/fake_audio_capture_module.h @@ -26,13 +26,14 @@ #include "modules/audio_device/include/audio_device.h" #include "rtc_base/critical_section.h" #include "rtc_base/message_handler.h" +#include "rtc_base/synchronization/sequence_checker.h" namespace rtc { class Thread; } // namespace rtc class FakeAudioCaptureModule : public webrtc::AudioDeviceModule, - public rtc::MessageHandler { + public rtc::MessageHandlerAutoCleanup { public: typedef uint16_t Sample; @@ -47,13 +48,13 @@ class FakeAudioCaptureModule : public webrtc::AudioDeviceModule, // Returns the number of frames that have been successfully pulled by the // instance. Note that correctly detecting success can only be done if the // pulled frame was generated/pushed from a FakeAudioCaptureModule. - int frames_received() const; + int frames_received() const RTC_LOCKS_EXCLUDED(crit_); int32_t ActiveAudioLayer(AudioLayer* audio_layer) const override; // Note: Calling this method from a callback may result in deadlock. - int32_t RegisterAudioCallback( - webrtc::AudioTransport* audio_callback) override; + int32_t RegisterAudioCallback(webrtc::AudioTransport* audio_callback) override + RTC_LOCKS_EXCLUDED(crit_); int32_t Init() override; int32_t Terminate() override; @@ -80,12 +81,12 @@ class FakeAudioCaptureModule : public webrtc::AudioDeviceModule, int32_t InitRecording() override; bool RecordingIsInitialized() const override; - int32_t StartPlayout() override; - int32_t StopPlayout() override; - bool Playing() const override; - int32_t StartRecording() override; - int32_t StopRecording() override; - bool Recording() const override; + int32_t StartPlayout() RTC_LOCKS_EXCLUDED(crit_) override; + int32_t StopPlayout() RTC_LOCKS_EXCLUDED(crit_) override; + bool Playing() const RTC_LOCKS_EXCLUDED(crit_) override; + int32_t StartRecording() RTC_LOCKS_EXCLUDED(crit_) override; + int32_t StopRecording() RTC_LOCKS_EXCLUDED(crit_) override; + bool Recording() const RTC_LOCKS_EXCLUDED(crit_) override; int32_t InitSpeaker() override; bool SpeakerIsInitialized() const override; @@ -99,8 +100,10 @@ class FakeAudioCaptureModule : public webrtc::AudioDeviceModule, int32_t MinSpeakerVolume(uint32_t* min_volume) const override; int32_t MicrophoneVolumeIsAvailable(bool* available) override; - int32_t SetMicrophoneVolume(uint32_t volume) override; - int32_t MicrophoneVolume(uint32_t* volume) const override; + int32_t SetMicrophoneVolume(uint32_t volume) + RTC_LOCKS_EXCLUDED(crit_) override; + int32_t MicrophoneVolume(uint32_t* volume) const + RTC_LOCKS_EXCLUDED(crit_) override; int32_t MaxMicrophoneVolume(uint32_t* max_volume) const override; int32_t MinMicrophoneVolume(uint32_t* min_volume) const override; @@ -170,26 +173,28 @@ class FakeAudioCaptureModule : public webrtc::AudioDeviceModule, // Returns true/false depending on if recording or playback has been // enabled/started. - bool ShouldStartProcessing(); + bool ShouldStartProcessing() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_); // Starts or stops the pushing and pulling of audio frames. - void UpdateProcessing(bool start); + void UpdateProcessing(bool start) RTC_LOCKS_EXCLUDED(crit_); // Starts the periodic calling of ProcessFrame() in a thread safe way. void StartProcessP(); // Periodcally called function that ensures that frames are pulled and pushed // periodically if enabled/started. - void ProcessFrameP(); + void ProcessFrameP() RTC_LOCKS_EXCLUDED(crit_); // Pulls frames from the registered webrtc::AudioTransport. - void ReceiveFrameP(); + void ReceiveFrameP() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_); // Pushes frames to the registered webrtc::AudioTransport. - void SendFrameP(); + void SendFrameP() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_); // Callback for playout and recording. - webrtc::AudioTransport* audio_callback_; + webrtc::AudioTransport* audio_callback_ RTC_GUARDED_BY(crit_); - bool recording_; // True when audio is being pushed from the instance. - bool playing_; // True when audio is being pulled by the instance. + bool recording_ RTC_GUARDED_BY( + crit_); // True when audio is being pushed from the instance. + bool playing_ RTC_GUARDED_BY( + crit_); // True when audio is being pulled by the instance. bool play_is_initialized_; // True when the instance is ready to pull audio. bool rec_is_initialized_; // True when the instance is ready to push audio. @@ -197,13 +202,13 @@ class FakeAudioCaptureModule : public webrtc::AudioDeviceModule, // Input to and output from RecordedDataIsAvailable(..) makes it possible to // modify the current mic level. The implementation does not care about the // mic level so it just feeds back what it receives. - uint32_t current_mic_level_; + uint32_t current_mic_level_ RTC_GUARDED_BY(crit_); // next_frame_time_ is updated in a non-drifting manner to indicate the next // wall clock time the next frame should be generated and received. started_ // ensures that next_frame_time_ can be initialized properly on first call. - bool started_; - int64_t next_frame_time_; + bool started_ RTC_GUARDED_BY(crit_); + int64_t next_frame_time_ RTC_GUARDED_BY(process_thread_checker_); std::unique_ptr<rtc::Thread> process_thread_; @@ -220,9 +225,7 @@ class FakeAudioCaptureModule : public webrtc::AudioDeviceModule, // Protects variables that are accessed from process_thread_ and // the main thread. rtc::CriticalSection crit_; - // Protects |audio_callback_| that is accessed from process_thread_ and - // the main thread. - rtc::CriticalSection crit_callback_; + webrtc::SequenceChecker process_thread_checker_; }; #endif // PC_TEST_FAKE_AUDIO_CAPTURE_MODULE_H_ diff --git a/chromium/third_party/webrtc/pc/test/fake_peer_connection_base.h b/chromium/third_party/webrtc/pc/test/fake_peer_connection_base.h index f4b27f03e18..e1663e6d9f8 100644 --- a/chromium/third_party/webrtc/pc/test/fake_peer_connection_base.h +++ b/chromium/third_party/webrtc/pc/test/fake_peer_connection_base.h @@ -254,11 +254,6 @@ class FakePeerConnectionBase : public PeerConnectionInternal { cricket::RtpDataChannel* rtp_data_channel() const override { return nullptr; } - std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels() - const override { - return {}; - } - absl::optional<std::string> sctp_transport_name() const override { return absl::nullopt; } diff --git a/chromium/third_party/webrtc/pc/test/fake_peer_connection_for_stats.h b/chromium/third_party/webrtc/pc/test/fake_peer_connection_for_stats.h index c6391583f57..175a1ede153 100644 --- a/chromium/third_party/webrtc/pc/test/fake_peer_connection_for_stats.h +++ b/chromium/third_party/webrtc/pc/test/fake_peer_connection_for_stats.h @@ -174,8 +174,10 @@ class FakePeerConnectionForStats : public FakePeerConnectionBase { void AddSctpDataChannel(const std::string& label, const InternalDataChannelInit& init) { - AddSctpDataChannel(DataChannel::Create(&data_channel_provider_, - cricket::DCT_SCTP, label, init)); + // TODO(bugs.webrtc.org/11547): Supply a separate network thread. + AddSctpDataChannel(DataChannel::Create( + &data_channel_provider_, cricket::DCT_SCTP, label, init, + rtc::Thread::Current(), rtc::Thread::Current())); } void AddSctpDataChannel(rtc::scoped_refptr<DataChannel> data_channel) { @@ -257,9 +259,12 @@ class FakePeerConnectionForStats : public FakePeerConnectionBase { return transceivers_; } - std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels() - const override { - return sctp_data_channels_; + std::vector<DataChannel::Stats> GetDataChannelStats() const override { + RTC_DCHECK_RUN_ON(signaling_thread()); + std::vector<DataChannel::Stats> stats; + for (const auto& channel : sctp_data_channels_) + stats.push_back(channel->GetStats()); + return stats; } cricket::CandidateStatsList GetPooledCandidateStats() const override { diff --git a/chromium/third_party/webrtc/pc/test/fake_periodic_video_source.h b/chromium/third_party/webrtc/pc/test/fake_periodic_video_source.h index 1684ca4adbb..b1cff4e5edc 100644 --- a/chromium/third_party/webrtc/pc/test/fake_periodic_video_source.h +++ b/chromium/third_party/webrtc/pc/test/fake_periodic_video_source.h @@ -16,6 +16,7 @@ #include "api/video/video_source_interface.h" #include "media/base/fake_frame_source.h" #include "media/base/video_broadcaster.h" +#include "rtc_base/critical_section.h" #include "rtc_base/task_queue_for_test.h" #include "rtc_base/task_utils/repeating_task.h" @@ -59,6 +60,11 @@ class FakePeriodicVideoSource final }); } + rtc::VideoSinkWants wants() const { + rtc::CritScope cs(&crit_); + return wants_; + } + void RemoveSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) override { RTC_DCHECK(thread_checker_.IsCurrent()); broadcaster_.RemoveSink(sink); @@ -67,6 +73,10 @@ class FakePeriodicVideoSource final void AddOrUpdateSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink, const rtc::VideoSinkWants& wants) override { RTC_DCHECK(thread_checker_.IsCurrent()); + { + rtc::CritScope cs(&crit_); + wants_ = wants; + } broadcaster_.AddOrUpdateSink(sink, wants); } @@ -80,6 +90,8 @@ class FakePeriodicVideoSource final rtc::VideoBroadcaster broadcaster_; cricket::FakeFrameSource frame_source_; + rtc::CriticalSection crit_; + rtc::VideoSinkWants wants_ RTC_GUARDED_BY(&crit_); std::unique_ptr<TaskQueueForTest> task_queue_; }; diff --git a/chromium/third_party/webrtc/pc/test/fake_periodic_video_track_source.h b/chromium/third_party/webrtc/pc/test/fake_periodic_video_track_source.h index cc406d6d3fc..98a456f2328 100644 --- a/chromium/third_party/webrtc/pc/test/fake_periodic_video_track_source.h +++ b/chromium/third_party/webrtc/pc/test/fake_periodic_video_track_source.h @@ -29,6 +29,10 @@ class FakePeriodicVideoTrackSource : public VideoTrackSource { ~FakePeriodicVideoTrackSource() = default; + const FakePeriodicVideoSource& fake_periodic_source() const { + return source_; + } + protected: rtc::VideoSourceInterface<VideoFrame>* source() override { return &source_; } diff --git a/chromium/third_party/webrtc/pc/test/fake_rtc_certificate_generator.h b/chromium/third_party/webrtc/pc/test/fake_rtc_certificate_generator.h index 9c43ba97262..b726a4c0ba8 100644 --- a/chromium/third_party/webrtc/pc/test/fake_rtc_certificate_generator.h +++ b/chromium/third_party/webrtc/pc/test/fake_rtc_certificate_generator.h @@ -118,7 +118,7 @@ static const rtc::RTCCertificatePEM kEcdsaPems[] = { class FakeRTCCertificateGenerator : public rtc::RTCCertificateGeneratorInterface, - public rtc::MessageHandler { + public rtc::MessageHandlerAutoCleanup { public: typedef rtc::TypedMessageData< rtc::scoped_refptr<rtc::RTCCertificateGeneratorCallback> > diff --git a/chromium/third_party/webrtc/pc/test/mock_channel_interface.h b/chromium/third_party/webrtc/pc/test/mock_channel_interface.h index 255bd2fceec..2df3baee47e 100644 --- a/chromium/third_party/webrtc/pc/test/mock_channel_interface.h +++ b/chromium/third_party/webrtc/pc/test/mock_channel_interface.h @@ -24,25 +24,40 @@ namespace cricket { // implementation of BaseChannel. class MockChannelInterface : public cricket::ChannelInterface { public: - MOCK_CONST_METHOD0(media_type, cricket::MediaType()); - MOCK_CONST_METHOD0(media_channel, MediaChannel*()); - MOCK_CONST_METHOD0(transport_name, const std::string&()); - MOCK_CONST_METHOD0(content_name, const std::string&()); - MOCK_CONST_METHOD0(enabled, bool()); - MOCK_METHOD1(Enable, bool(bool)); - MOCK_METHOD0(SignalFirstPacketReceived, - sigslot::signal1<ChannelInterface*>&()); - MOCK_METHOD3(SetLocalContent, - bool(const cricket::MediaContentDescription*, - webrtc::SdpType, - std::string*)); - MOCK_METHOD3(SetRemoteContent, - bool(const cricket::MediaContentDescription*, - webrtc::SdpType, - std::string*)); - MOCK_CONST_METHOD0(local_streams, const std::vector<StreamParams>&()); - MOCK_CONST_METHOD0(remote_streams, const std::vector<StreamParams>&()); - MOCK_METHOD1(SetRtpTransport, bool(webrtc::RtpTransportInternal*)); + MOCK_METHOD(cricket::MediaType, media_type, (), (const, override)); + MOCK_METHOD(MediaChannel*, media_channel, (), (const, override)); + MOCK_METHOD(const std::string&, transport_name, (), (const, override)); + MOCK_METHOD(const std::string&, content_name, (), (const, override)); + MOCK_METHOD(bool, enabled, (), (const, override)); + MOCK_METHOD(bool, Enable, (bool), (override)); + MOCK_METHOD(sigslot::signal1<ChannelInterface*>&, + SignalFirstPacketReceived, + (), + (override)); + MOCK_METHOD(bool, + SetLocalContent, + (const cricket::MediaContentDescription*, + webrtc::SdpType, + std::string*), + (override)); + MOCK_METHOD(bool, + SetRemoteContent, + (const cricket::MediaContentDescription*, + webrtc::SdpType, + std::string*), + (override)); + MOCK_METHOD(const std::vector<StreamParams>&, + local_streams, + (), + (const, override)); + MOCK_METHOD(const std::vector<StreamParams>&, + remote_streams, + (), + (const, override)); + MOCK_METHOD(bool, + SetRtpTransport, + (webrtc::RtpTransportInternal*), + (override)); }; } // namespace cricket diff --git a/chromium/third_party/webrtc/pc/test/mock_data_channel.h b/chromium/third_party/webrtc/pc/test/mock_data_channel.h index 3385ec2f75c..bc5f94da5f7 100644 --- a/chromium/third_party/webrtc/pc/test/mock_data_channel.h +++ b/chromium/third_party/webrtc/pc/test/mock_data_channel.h @@ -22,15 +22,24 @@ class MockDataChannel : public rtc::RefCountedObject<DataChannel> { public: MockDataChannel(int id, DataState state) : MockDataChannel(id, "MockDataChannel", state, "udp", 0, 0, 0, 0) {} - MockDataChannel(int id, - const std::string& label, - DataState state, - const std::string& protocol, - uint32_t messages_sent, - uint64_t bytes_sent, - uint32_t messages_received, - uint64_t bytes_received) - : rtc::RefCountedObject<DataChannel>(nullptr, cricket::DCT_NONE, label) { + MockDataChannel( + int id, + const std::string& label, + DataState state, + const std::string& protocol, + uint32_t messages_sent, + uint64_t bytes_sent, + uint32_t messages_received, + uint64_t bytes_received, + const InternalDataChannelInit& config = InternalDataChannelInit(), + rtc::Thread* signaling_thread = rtc::Thread::Current(), + rtc::Thread* network_thread = rtc::Thread::Current()) + : rtc::RefCountedObject<DataChannel>(config, + nullptr, + cricket::DCT_NONE, + label, + signaling_thread, + network_thread) { EXPECT_CALL(*this, id()).WillRepeatedly(::testing::Return(id)); EXPECT_CALL(*this, state()).WillRepeatedly(::testing::Return(state)); EXPECT_CALL(*this, protocol()).WillRepeatedly(::testing::Return(protocol)); @@ -43,13 +52,13 @@ class MockDataChannel : public rtc::RefCountedObject<DataChannel> { EXPECT_CALL(*this, bytes_received()) .WillRepeatedly(::testing::Return(bytes_received)); } - MOCK_CONST_METHOD0(id, int()); - MOCK_CONST_METHOD0(state, DataState()); - MOCK_CONST_METHOD0(protocol, std::string()); - MOCK_CONST_METHOD0(messages_sent, uint32_t()); - MOCK_CONST_METHOD0(bytes_sent, uint64_t()); - MOCK_CONST_METHOD0(messages_received, uint32_t()); - MOCK_CONST_METHOD0(bytes_received, uint64_t()); + MOCK_METHOD(int, id, (), (const, override)); + MOCK_METHOD(DataState, state, (), (const, override)); + MOCK_METHOD(std::string, protocol, (), (const, override)); + MOCK_METHOD(uint32_t, messages_sent, (), (const, override)); + MOCK_METHOD(uint64_t, bytes_sent, (), (const, override)); + MOCK_METHOD(uint32_t, messages_received, (), (const, override)); + MOCK_METHOD(uint64_t, bytes_received, (), (const, override)); }; } // namespace webrtc diff --git a/chromium/third_party/webrtc/pc/test/mock_delayable.h b/chromium/third_party/webrtc/pc/test/mock_delayable.h index 548f9f8c0a8..bef07c1970f 100644 --- a/chromium/third_party/webrtc/pc/test/mock_delayable.h +++ b/chromium/third_party/webrtc/pc/test/mock_delayable.h @@ -21,9 +21,14 @@ namespace webrtc { class MockDelayable : public cricket::Delayable { public: - MOCK_METHOD2(SetBaseMinimumPlayoutDelayMs, bool(uint32_t ssrc, int delay_ms)); - MOCK_CONST_METHOD1(GetBaseMinimumPlayoutDelayMs, - absl::optional<int>(uint32_t ssrc)); + MOCK_METHOD(bool, + SetBaseMinimumPlayoutDelayMs, + (uint32_t ssrc, int delay_ms), + (override)); + MOCK_METHOD(absl::optional<int>, + GetBaseMinimumPlayoutDelayMs, + (uint32_t ssrc), + (const, override)); }; } // namespace webrtc diff --git a/chromium/third_party/webrtc/pc/test/mock_rtp_receiver_internal.h b/chromium/third_party/webrtc/pc/test/mock_rtp_receiver_internal.h index ffe78b52304..779dcdcf086 100644 --- a/chromium/third_party/webrtc/pc/test/mock_rtp_receiver_internal.h +++ b/chromium/third_party/webrtc/pc/test/mock_rtp_receiver_internal.h @@ -24,37 +24,54 @@ namespace webrtc { class MockRtpReceiverInternal : public RtpReceiverInternal { public: // RtpReceiverInterface methods. - MOCK_METHOD1(SetTrack, void(MediaStreamTrackInterface*)); - MOCK_CONST_METHOD0(track, rtc::scoped_refptr<MediaStreamTrackInterface>()); - MOCK_CONST_METHOD0(dtls_transport, - rtc::scoped_refptr<DtlsTransportInterface>()); - MOCK_CONST_METHOD0(stream_ids, std::vector<std::string>()); - MOCK_CONST_METHOD0(streams, - std::vector<rtc::scoped_refptr<MediaStreamInterface>>()); - MOCK_CONST_METHOD0(media_type, cricket::MediaType()); - MOCK_CONST_METHOD0(id, std::string()); - MOCK_CONST_METHOD0(GetParameters, RtpParameters()); - MOCK_METHOD1(SetObserver, void(RtpReceiverObserverInterface*)); - MOCK_METHOD1(SetJitterBufferMinimumDelay, void(absl::optional<double>)); - MOCK_CONST_METHOD0(GetSources, std::vector<RtpSource>()); - MOCK_METHOD1(SetFrameDecryptor, - void(rtc::scoped_refptr<FrameDecryptorInterface>)); - MOCK_CONST_METHOD0(GetFrameDecryptor, - rtc::scoped_refptr<FrameDecryptorInterface>()); + MOCK_METHOD(rtc::scoped_refptr<MediaStreamTrackInterface>, + track, + (), + (const, override)); + MOCK_METHOD(rtc::scoped_refptr<DtlsTransportInterface>, + dtls_transport, + (), + (const, override)); + MOCK_METHOD(std::vector<std::string>, stream_ids, (), (const, override)); + MOCK_METHOD(std::vector<rtc::scoped_refptr<MediaStreamInterface>>, + streams, + (), + (const, override)); + MOCK_METHOD(cricket::MediaType, media_type, (), (const, override)); + MOCK_METHOD(std::string, id, (), (const, override)); + MOCK_METHOD(RtpParameters, GetParameters, (), (const, override)); + MOCK_METHOD(void, SetObserver, (RtpReceiverObserverInterface*), (override)); + MOCK_METHOD(void, + SetJitterBufferMinimumDelay, + (absl::optional<double>), + (override)); + MOCK_METHOD(std::vector<RtpSource>, GetSources, (), (const, override)); + MOCK_METHOD(void, + SetFrameDecryptor, + (rtc::scoped_refptr<FrameDecryptorInterface>), + (override)); + MOCK_METHOD(rtc::scoped_refptr<FrameDecryptorInterface>, + GetFrameDecryptor, + (), + (const, override)); // RtpReceiverInternal methods. - MOCK_METHOD0(Stop, void()); - MOCK_METHOD1(SetMediaChannel, void(cricket::MediaChannel*)); - MOCK_METHOD1(SetupMediaChannel, void(uint32_t)); - MOCK_METHOD0(SetupUnsignaledMediaChannel, void()); - MOCK_CONST_METHOD0(ssrc, uint32_t()); - MOCK_METHOD0(NotifyFirstPacketReceived, void()); - MOCK_METHOD1(set_stream_ids, void(std::vector<std::string>)); - MOCK_METHOD1(set_transport, void(rtc::scoped_refptr<DtlsTransportInterface>)); - MOCK_METHOD1( - SetStreams, - void(const std::vector<rtc::scoped_refptr<MediaStreamInterface>>&)); - MOCK_CONST_METHOD0(AttachmentId, int()); + MOCK_METHOD(void, Stop, (), (override)); + MOCK_METHOD(void, SetMediaChannel, (cricket::MediaChannel*), (override)); + MOCK_METHOD(void, SetupMediaChannel, (uint32_t), (override)); + MOCK_METHOD(void, SetupUnsignaledMediaChannel, (), (override)); + MOCK_METHOD(uint32_t, ssrc, (), (const, override)); + MOCK_METHOD(void, NotifyFirstPacketReceived, (), (override)); + MOCK_METHOD(void, set_stream_ids, (std::vector<std::string>), (override)); + MOCK_METHOD(void, + set_transport, + (rtc::scoped_refptr<DtlsTransportInterface>), + (override)); + MOCK_METHOD(void, + SetStreams, + (const std::vector<rtc::scoped_refptr<MediaStreamInterface>>&), + (override)); + MOCK_METHOD(int, AttachmentId, (), (const, override)); }; } // namespace webrtc diff --git a/chromium/third_party/webrtc/pc/test/mock_rtp_sender_internal.h b/chromium/third_party/webrtc/pc/test/mock_rtp_sender_internal.h index 2cf0173bd1c..1a31c5dac69 100644 --- a/chromium/third_party/webrtc/pc/test/mock_rtp_sender_internal.h +++ b/chromium/third_party/webrtc/pc/test/mock_rtp_sender_internal.h @@ -23,37 +23,65 @@ namespace webrtc { class MockRtpSenderInternal : public RtpSenderInternal { public: // RtpSenderInterface methods. - MOCK_METHOD1(SetTrack, bool(MediaStreamTrackInterface*)); - MOCK_CONST_METHOD0(track, rtc::scoped_refptr<MediaStreamTrackInterface>()); - MOCK_CONST_METHOD0(ssrc, uint32_t()); - MOCK_CONST_METHOD0(dtls_transport, - rtc::scoped_refptr<DtlsTransportInterface>()); - MOCK_CONST_METHOD0(media_type, cricket::MediaType()); - MOCK_CONST_METHOD0(id, std::string()); - MOCK_CONST_METHOD0(stream_ids, std::vector<std::string>()); - MOCK_CONST_METHOD0(init_send_encodings, std::vector<RtpEncodingParameters>()); - MOCK_METHOD1(set_transport, void(rtc::scoped_refptr<DtlsTransportInterface>)); - MOCK_CONST_METHOD0(GetParameters, RtpParameters()); - MOCK_CONST_METHOD0(GetParametersInternal, RtpParameters()); - MOCK_METHOD1(SetParameters, RTCError(const RtpParameters&)); - MOCK_METHOD1(SetParametersInternal, RTCError(const RtpParameters&)); - MOCK_CONST_METHOD0(GetDtmfSender, rtc::scoped_refptr<DtmfSenderInterface>()); - MOCK_METHOD1(SetFrameEncryptor, - void(rtc::scoped_refptr<FrameEncryptorInterface>)); - MOCK_CONST_METHOD0(GetFrameEncryptor, - rtc::scoped_refptr<FrameEncryptorInterface>()); + MOCK_METHOD(bool, SetTrack, (MediaStreamTrackInterface*), (override)); + MOCK_METHOD(rtc::scoped_refptr<MediaStreamTrackInterface>, + track, + (), + (const, override)); + MOCK_METHOD(uint32_t, ssrc, (), (const, override)); + MOCK_METHOD(rtc::scoped_refptr<DtlsTransportInterface>, + dtls_transport, + (), + (const, override)); + MOCK_METHOD(cricket::MediaType, media_type, (), (const, override)); + MOCK_METHOD(std::string, id, (), (const, override)); + MOCK_METHOD(std::vector<std::string>, stream_ids, (), (const, override)); + MOCK_METHOD(std::vector<RtpEncodingParameters>, + init_send_encodings, + (), + (const, override)); + MOCK_METHOD(void, + set_transport, + (rtc::scoped_refptr<DtlsTransportInterface>), + (override)); + MOCK_METHOD(RtpParameters, GetParameters, (), (const, override)); + MOCK_METHOD(RtpParameters, GetParametersInternal, (), (const, override)); + MOCK_METHOD(RTCError, SetParameters, (const RtpParameters&), (override)); + MOCK_METHOD(RTCError, + SetParametersInternal, + (const RtpParameters&), + (override)); + MOCK_METHOD(rtc::scoped_refptr<DtmfSenderInterface>, + GetDtmfSender, + (), + (const, override)); + MOCK_METHOD(void, + SetFrameEncryptor, + (rtc::scoped_refptr<FrameEncryptorInterface>), + (override)); + MOCK_METHOD(rtc::scoped_refptr<FrameEncryptorInterface>, + GetFrameEncryptor, + (), + (const, override)); // RtpSenderInternal methods. - MOCK_METHOD1(SetMediaChannel, void(cricket::MediaChannel*)); - MOCK_METHOD1(SetSsrc, void(uint32_t)); - MOCK_METHOD1(set_stream_ids, void(const std::vector<std::string>&)); - MOCK_METHOD1(SetStreams, void(const std::vector<std::string>&)); - MOCK_METHOD1(set_init_send_encodings, - void(const std::vector<RtpEncodingParameters>&)); - MOCK_METHOD0(Stop, void()); - MOCK_CONST_METHOD0(AttachmentId, int()); - MOCK_METHOD1(DisableEncodingLayers, - RTCError(const std::vector<std::string>&)); + MOCK_METHOD(void, SetMediaChannel, (cricket::MediaChannel*), (override)); + MOCK_METHOD(void, SetSsrc, (uint32_t), (override)); + MOCK_METHOD(void, + set_stream_ids, + (const std::vector<std::string>&), + (override)); + MOCK_METHOD(void, SetStreams, (const std::vector<std::string>&), (override)); + MOCK_METHOD(void, + set_init_send_encodings, + (const std::vector<RtpEncodingParameters>&), + (override)); + MOCK_METHOD(void, Stop, (), (override)); + MOCK_METHOD(int, AttachmentId, (), (const, override)); + MOCK_METHOD(RTCError, + DisableEncodingLayers, + (const std::vector<std::string>&), + (override)); }; } // namespace webrtc diff --git a/chromium/third_party/webrtc/pc/test/peer_connection_test_wrapper.cc b/chromium/third_party/webrtc/pc/test/peer_connection_test_wrapper.cc index 4f0d72e6675..946f459f3b7 100644 --- a/chromium/third_party/webrtc/pc/test/peer_connection_test_wrapper.cc +++ b/chromium/third_party/webrtc/pc/test/peer_connection_test_wrapper.cc @@ -80,7 +80,8 @@ PeerConnectionTestWrapper::PeerConnectionTestWrapper( rtc::Thread* worker_thread) : name_(name), network_thread_(network_thread), - worker_thread_(worker_thread) { + worker_thread_(worker_thread), + pending_negotiation_(false) { pc_thread_checker_.Detach(); } @@ -135,6 +136,17 @@ PeerConnectionTestWrapper::CreateDataChannel( return peer_connection_->CreateDataChannel(label, &init); } +void PeerConnectionTestWrapper::WaitForNegotiation() { + EXPECT_TRUE_WAIT(!pending_negotiation_, kMaxWait); +} + +void PeerConnectionTestWrapper::OnSignalingChange( + webrtc::PeerConnectionInterface::SignalingState new_state) { + if (new_state == webrtc::PeerConnectionInterface::SignalingState::kStable) { + pending_negotiation_ = false; + } +} + void PeerConnectionTestWrapper::OnAddTrack( rtc::scoped_refptr<RtpReceiverInterface> receiver, const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams) { @@ -182,6 +194,7 @@ void PeerConnectionTestWrapper::OnSuccess(SessionDescriptionInterface* desc) { void PeerConnectionTestWrapper::CreateOffer( const webrtc::PeerConnectionInterface::RTCOfferAnswerOptions& options) { RTC_LOG(LS_INFO) << "PeerConnectionTestWrapper " << name_ << ": CreateOffer."; + pending_negotiation_ = true; peer_connection_->CreateOffer(this, options); } @@ -189,6 +202,7 @@ void PeerConnectionTestWrapper::CreateAnswer( const webrtc::PeerConnectionInterface::RTCOfferAnswerOptions& options) { RTC_LOG(LS_INFO) << "PeerConnectionTestWrapper " << name_ << ": CreateAnswer."; + pending_negotiation_ = true; peer_connection_->CreateAnswer(this, options); } diff --git a/chromium/third_party/webrtc/pc/test/peer_connection_test_wrapper.h b/chromium/third_party/webrtc/pc/test/peer_connection_test_wrapper.h index 2dc88e93095..92599b78ab9 100644 --- a/chromium/third_party/webrtc/pc/test/peer_connection_test_wrapper.h +++ b/chromium/third_party/webrtc/pc/test/peer_connection_test_wrapper.h @@ -49,15 +49,21 @@ class PeerConnectionTestWrapper rtc::scoped_refptr<webrtc::AudioEncoderFactory> audio_encoder_factory, rtc::scoped_refptr<webrtc::AudioDecoderFactory> audio_decoder_factory); + rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory() + const { + return peer_connection_factory_; + } webrtc::PeerConnectionInterface* pc() { return peer_connection_.get(); } rtc::scoped_refptr<webrtc::DataChannelInterface> CreateDataChannel( const std::string& label, const webrtc::DataChannelInit& init); + void WaitForNegotiation(); + // Implements PeerConnectionObserver. void OnSignalingChange( - webrtc::PeerConnectionInterface::SignalingState new_state) override {} + webrtc::PeerConnectionInterface::SignalingState new_state) override; void OnAddTrack( rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver, const std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>>& @@ -121,6 +127,7 @@ class PeerConnectionTestWrapper rtc::scoped_refptr<FakeAudioCaptureModule> fake_audio_capture_module_; std::unique_ptr<webrtc::FakeVideoTrackRenderer> renderer_; int num_get_user_media_calls_ = 0; + bool pending_negotiation_; }; #endif // PC_TEST_PEER_CONNECTION_TEST_WRAPPER_H_ |