From a1cc73f2f9a50c8a905f2a513a15d2c9082099b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Mon, 28 May 2018 16:20:42 +0200 Subject: [PATCH] Delete class FakePeriodicVideoCapturer. Only use replaced with FakePeriodicVideoTrackSource. Bug: webrtc:6353 Change-Id: Iee38b98a5242a292a848738bde05de18d96de7f4 Reviewed-on: https://webrtc-review.googlesource.com/79441 Reviewed-by: Steve Anton Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/master@{#23441} --- pc/BUILD.gn | 1 - pc/test/fakeperiodicvideocapturer.h | 99 ---------------------------- pc/test/peerconnectiontestwrapper.cc | 13 ++-- 3 files changed, 6 insertions(+), 107 deletions(-) delete mode 100644 pc/test/fakeperiodicvideocapturer.h diff --git a/pc/BUILD.gn b/pc/BUILD.gn index e117bb3f04..e0b701da35 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -348,7 +348,6 @@ if (rtc_include_tests) { "test/fakedatachannelprovider.h", "test/fakepeerconnectionbase.h", "test/fakepeerconnectionforstats.h", - "test/fakeperiodicvideocapturer.h", "test/fakeperiodicvideosource.h", "test/fakeperiodicvideotracksource.h", "test/fakertccertificategenerator.h", diff --git a/pc/test/fakeperiodicvideocapturer.h b/pc/test/fakeperiodicvideocapturer.h deleted file mode 100644 index e9eb47587c..0000000000 --- a/pc/test/fakeperiodicvideocapturer.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2012 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. - */ - -// FakePeriodicVideoCapturer implements a fake cricket::VideoCapturer that -// creates video frames periodically after it has been started. - -#ifndef PC_TEST_FAKEPERIODICVIDEOCAPTURER_H_ -#define PC_TEST_FAKEPERIODICVIDEOCAPTURER_H_ - -#include -#include - -#include "media/base/fakevideocapturer.h" -#include "rtc_base/arraysize.h" -#include "rtc_base/thread_checker.h" - -namespace webrtc { - -class FakePeriodicVideoCapturer - : public cricket::FakeVideoCapturerWithTaskQueue { - public: - FakePeriodicVideoCapturer() { - worker_thread_checker_.DetachFromThread(); - using cricket::VideoFormat; - static const VideoFormat formats[] = { - {1280, 720, VideoFormat::FpsToInterval(30), cricket::FOURCC_I420}, - {640, 480, VideoFormat::FpsToInterval(30), cricket::FOURCC_I420}, - {640, 360, VideoFormat::FpsToInterval(30), cricket::FOURCC_I420}, - {320, 240, VideoFormat::FpsToInterval(30), cricket::FOURCC_I420}, - {160, 120, VideoFormat::FpsToInterval(30), cricket::FOURCC_I420}, - }; - - ResetSupportedFormats({&formats[0], &formats[arraysize(formats)]}); - } - - ~FakePeriodicVideoCapturer() override { - RTC_DCHECK(main_thread_checker_.CalledOnValidThread()); - StopFrameDelivery(); - } - - // Workaround method for tests to allow stopping frame delivery directly. - // The |Start()| method expects to be called from the "worker thread" that - // is owned by the factory (think OrtcFactoryInterface or - // PeerConnectionFactoryInterface). That thread is not directly exposed, - // which can make it tricky for tests to inject calls on. - // So, in order to allow tests to stop frame delivery directly from the - // test thread, we expose this method publicly. - void StopFrameDelivery() { - task_queue_.SendTask([this]() { - RTC_DCHECK_RUN_ON(&task_queue_); - deliver_frames_ = false; - }); - } - - private: - cricket::CaptureState Start(const cricket::VideoFormat& format) override { - RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - cricket::CaptureState state = FakeVideoCapturer::Start(format); - if (state != cricket::CS_FAILED) { - task_queue_.PostTask([this]() { - RTC_DCHECK_RUN_ON(&task_queue_); - deliver_frames_ = true; - DeliverFrame(); - }); - } - return state; - } - - void Stop() override { - RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - StopFrameDelivery(); - } - - void DeliverFrame() { - RTC_DCHECK_RUN_ON(&task_queue_); - if (IsRunning() && deliver_frames_) { - CaptureFrame(); - task_queue_.PostDelayedTask( - [this]() { DeliverFrame(); }, - static_cast(GetCaptureFormat()->interval / - rtc::kNumNanosecsPerMillisec)); - } - } - - rtc::ThreadChecker main_thread_checker_; - rtc::ThreadChecker worker_thread_checker_; - bool deliver_frames_ RTC_GUARDED_BY(task_queue_) = false; -}; - -} // namespace webrtc - -#endif // PC_TEST_FAKEPERIODICVIDEOCAPTURER_H_ diff --git a/pc/test/peerconnectiontestwrapper.cc b/pc/test/peerconnectiontestwrapper.cc index a3ee5ab300..569a9cc161 100644 --- a/pc/test/peerconnectiontestwrapper.cc +++ b/pc/test/peerconnectiontestwrapper.cc @@ -17,7 +17,7 @@ #include "modules/audio_processing/include/audio_processing.h" #include "p2p/base/fakeportallocator.h" #include "pc/sdputils.h" -#include "pc/test/fakeperiodicvideocapturer.h" +#include "pc/test/fakeperiodicvideotracksource.h" #include "pc/test/fakertccertificategenerator.h" #include "pc/test/mockpeerconnectionobservers.h" #include "pc/test/peerconnectiontestwrapper.h" @@ -287,14 +287,13 @@ rtc::scoped_refptr if (video) { // Set max frame rate to 10fps to reduce the risk of the tests to be flaky. - FakeConstraints constraints = video_constraints; - constraints.SetMandatoryMaxFrameRate(10); + webrtc::FakePeriodicVideoSource::Config config; + config.frame_interval_ms = 100; rtc::scoped_refptr source = - peer_connection_factory_->CreateVideoSource( - std::unique_ptr( - new webrtc::FakePeriodicVideoCapturer()), - &constraints); + new rtc::RefCountedObject( + config, /* remote */ false); + std::string videotrack_label = stream_id + kVideoTrackLabelBase; rtc::scoped_refptr video_track( peer_connection_factory_->CreateVideoTrack(videotrack_label, source));