From 8581877121f58435d683c2a39a73e72e5dcd558a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Tue, 9 Apr 2019 08:24:58 +0200 Subject: [PATCH] Delete interface class VideoCaptureExternal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also delete corresponding and unused create method VideoCaptureFactory::Create(VideoCaptureExternal...), the code under modules/video_capture/external, and the build target modules/video_capture:video_capture. Bug: None Change-Id: I5ec6139e9ecf460f93ede847868f7f80dbc019f5 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/131385 Reviewed-by: Magnus Flodman Reviewed-by: Kári Helgason Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/master@{#27506} --- BUILD.gn | 1 - common_video/BUILD.gn | 1 - media/BUILD.gn | 4 +- modules/BUILD.gn | 4 - modules/video_capture/BUILD.gn | 15 ---- .../external/device_info_external.cc | 54 ------------ .../external/video_capture_external.cc | 27 ------ .../test/video_capture_unittest.cc | 82 +------------------ modules/video_capture/video_capture_defines.h | 15 ---- .../video_capture/video_capture_factory.cc | 5 -- modules/video_capture/video_capture_factory.h | 6 -- modules/video_capture/video_capture_impl.cc | 7 -- modules/video_capture/video_capture_impl.h | 17 +--- .../video_capture/windows/sink_filter_ds.cc | 2 +- .../video_capture/windows/sink_filter_ds.h | 6 +- test/BUILD.gn | 1 - video/DEPS | 1 - 17 files changed, 10 insertions(+), 238 deletions(-) delete mode 100644 modules/video_capture/external/device_info_external.cc delete mode 100644 modules/video_capture/external/video_capture_external.cc diff --git a/BUILD.gn b/BUILD.gn index f299446d45..0c2096b516 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -555,7 +555,6 @@ if (rtc_include_tests) { # TODO(eladalon): call_tests aren't actually video-specific, so we # should move them to a more appropriate test suite. "call:call_tests", - "modules/video_capture", "test:test_common", "test:test_main", "test:video_test_common", diff --git a/common_video/BUILD.gn b/common_video/BUILD.gn index 86b660487b..53bdea07f8 100644 --- a/common_video/BUILD.gn +++ b/common_video/BUILD.gn @@ -95,7 +95,6 @@ if (rtc_include_tests) { "../api/video:video_frame_i010", "../api/video:video_frame_i420", "../media:rtc_h264_profile_id", - "../modules/video_capture", "../rtc_base", "../rtc_base:checks", "../rtc_base:rtc_base_approved", diff --git a/media/BUILD.gn b/media/BUILD.gn index c90cc47888..3afaf35ca5 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -299,9 +299,7 @@ rtc_static_library("rtc_audio_video") { include_dirs = [] public_configs = [] - if (build_with_chromium) { - deps += [ "../modules/video_capture" ] - } else { + if (!build_with_chromium) { public_configs += [ ":rtc_media_defines_config" ] deps += [ "../modules/video_capture:video_capture_internal_impl" ] } diff --git a/modules/BUILD.gn b/modules/BUILD.gn index 38310367be..b4c88b706f 100644 --- a/modules/BUILD.gn +++ b/modules/BUILD.gn @@ -261,10 +261,6 @@ if (rtc_include_tests) { deps += [ "desktop_capture:desktop_capture_unittests" ] } - if (!build_with_mozilla) { - deps += [ "video_capture" ] - } - data = modules_unittests_resources if (is_android) { diff --git a/modules/video_capture/BUILD.gn b/modules/video_capture/BUILD.gn index a098d39b50..af6f22e53f 100644 --- a/modules/video_capture/BUILD.gn +++ b/modules/video_capture/BUILD.gn @@ -42,21 +42,6 @@ rtc_static_library("video_capture_module") { ] } -rtc_static_library("video_capture") { - visibility = [ "*" ] - sources = [ - "external/device_info_external.cc", - "external/video_capture_external.cc", - ] - - deps = [ - ":video_capture_module", - "../../api:scoped_refptr", - "../../rtc_base:rtc_base_approved", - "../../system_wrappers", - ] -} - if (!build_with_chromium) { rtc_source_set("video_capture_internal_impl") { deps = [ diff --git a/modules/video_capture/external/device_info_external.cc b/modules/video_capture/external/device_info_external.cc deleted file mode 100644 index 9d4142f395..0000000000 --- a/modules/video_capture/external/device_info_external.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 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. - */ - -#include - -#include "modules/video_capture/device_info_impl.h" -#include "modules/video_capture/video_capture.h" -#include "modules/video_capture/video_capture_impl.h" - -namespace webrtc { - -namespace videocapturemodule { - -class ExternalDeviceInfo : public DeviceInfoImpl { - public: - ExternalDeviceInfo() {} - ~ExternalDeviceInfo() override {} - uint32_t NumberOfDevices() override { return 0; } - int32_t DisplayCaptureSettingsDialogBox(const char* /*deviceUniqueIdUTF8*/, - const char* /*dialogTitleUTF8*/, - void* /*parentWindow*/, - uint32_t /*positionX*/, - uint32_t /*positionY*/) override { - return -1; - } - int32_t GetDeviceName(uint32_t deviceNumber, - char* deviceNameUTF8, - uint32_t deviceNameLength, - char* deviceUniqueIdUTF8, - uint32_t deviceUniqueIdUTF8Length, - char* productUniqueIdUTF8 = 0, - uint32_t productUniqueIdUTF8Length = 0) override { - return -1; - } - int32_t CreateCapabilityMap(const char* deviceUniqueIdUTF8) override { - return 0; - } - int32_t Init() override { return 0; } -}; - -VideoCaptureModule::DeviceInfo* VideoCaptureImpl::CreateDeviceInfo() { - return new ExternalDeviceInfo(); -} - -} // namespace videocapturemodule - -} // namespace webrtc diff --git a/modules/video_capture/external/video_capture_external.cc b/modules/video_capture/external/video_capture_external.cc deleted file mode 100644 index f61e73effd..0000000000 --- a/modules/video_capture/external/video_capture_external.cc +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 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. - */ - -#include "api/scoped_refptr.h" -#include "modules/video_capture/video_capture.h" -#include "modules/video_capture/video_capture_impl.h" -#include "rtc_base/ref_counted_object.h" - -namespace webrtc { - -namespace videocapturemodule { - -rtc::scoped_refptr VideoCaptureImpl::Create( - const char* deviceUniqueIdUTF8) { - return new rtc::RefCountedObject(); -} - -} // namespace videocapturemodule - -} // namespace webrtc diff --git a/modules/video_capture/test/video_capture_unittest.cc b/modules/video_capture/test/video_capture_unittest.cc index 4bc68664c0..283c13ff40 100644 --- a/modules/video_capture/test/video_capture_unittest.cc +++ b/modules/video_capture/test/video_capture_unittest.cc @@ -52,9 +52,11 @@ using webrtc::VideoCaptureModule; } while (0) static const int kTimeOut = 5000; +#ifdef WEBRTC_MAC static const int kTestHeight = 288; static const int kTestWidth = 352; static const int kTestFramerate = 30; +#endif class TestVideoCaptureCallback : public rtc::VideoSinkInterface { @@ -344,83 +346,3 @@ TEST_F(VideoCaptureTest, DISABLED_TestTwoCameras) { EXPECT_EQ(0, module2->StopCapture()); EXPECT_EQ(0, module1->StopCapture()); } - -// Test class for testing external capture and capture feedback information -// such as frame rate and picture alarm. -class VideoCaptureExternalTest : public testing::Test { - public: - void SetUp() override { - capture_module_ = VideoCaptureFactory::Create(capture_input_interface_); - - VideoCaptureCapability capability; - capability.width = kTestWidth; - capability.height = kTestHeight; - capability.videoType = webrtc::VideoType::kYV12; - capability.maxFPS = kTestFramerate; - capture_callback_.SetExpectedCapability(capability); - - rtc::scoped_refptr buffer = - webrtc::I420Buffer::Create(kTestWidth, kTestHeight); - - memset(buffer->MutableDataY(), 127, buffer->height() * buffer->StrideY()); - memset(buffer->MutableDataU(), 127, - buffer->ChromaHeight() * buffer->StrideU()); - memset(buffer->MutableDataV(), 127, - buffer->ChromaHeight() * buffer->StrideV()); - test_frame_ = absl::make_unique( - webrtc::VideoFrame::Builder() - .set_video_frame_buffer(buffer) - .set_rotation(webrtc::kVideoRotation_0) - .set_timestamp_us(0) - .build()); - - SleepMs(1); // Wait 1ms so that two tests can't have the same timestamp. - - capture_module_->RegisterCaptureDataCallback(&capture_callback_); - } - - void TearDown() override {} - - webrtc::VideoCaptureExternal* capture_input_interface_; - rtc::scoped_refptr capture_module_; - std::unique_ptr test_frame_; - TestVideoCaptureCallback capture_callback_; -}; - -// Test input of external video frames. -TEST_F(VideoCaptureExternalTest, TestExternalCapture) { - size_t length = webrtc::CalcBufferSize( - webrtc::VideoType::kI420, test_frame_->width(), test_frame_->height()); - std::unique_ptr test_buffer(new uint8_t[length]); - webrtc::ExtractBuffer(*test_frame_, length, test_buffer.get()); - EXPECT_EQ(0, - capture_input_interface_->IncomingFrame( - test_buffer.get(), length, capture_callback_.capability(), 0)); - EXPECT_TRUE(capture_callback_.CompareLastFrame(*test_frame_)); -} - -TEST_F(VideoCaptureExternalTest, Rotation) { - EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_0)); - size_t length = webrtc::CalcBufferSize( - webrtc::VideoType::kI420, test_frame_->width(), test_frame_->height()); - std::unique_ptr test_buffer(new uint8_t[length]); - webrtc::ExtractBuffer(*test_frame_, length, test_buffer.get()); - EXPECT_EQ(0, - capture_input_interface_->IncomingFrame( - test_buffer.get(), length, capture_callback_.capability(), 0)); - EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_90)); - capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_90); - EXPECT_EQ(0, - capture_input_interface_->IncomingFrame( - test_buffer.get(), length, capture_callback_.capability(), 0)); - EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_180)); - capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_180); - EXPECT_EQ(0, - capture_input_interface_->IncomingFrame( - test_buffer.get(), length, capture_callback_.capability(), 0)); - EXPECT_EQ(0, capture_module_->SetCaptureRotation(webrtc::kVideoRotation_270)); - capture_callback_.SetExpectedCaptureRotation(webrtc::kVideoRotation_270); - EXPECT_EQ(0, - capture_input_interface_->IncomingFrame( - test_buffer.get(), length, capture_callback_.capability(), 0)); -} diff --git a/modules/video_capture/video_capture_defines.h b/modules/video_capture/video_capture_defines.h index 95747a4e43..bdd74d51d7 100644 --- a/modules/video_capture/video_capture_defines.h +++ b/modules/video_capture/video_capture_defines.h @@ -55,21 +55,6 @@ struct VideoCaptureCapability { } }; -/* External Capture interface. Returned by Create - and implemented by the capture module. - */ -class VideoCaptureExternal { - public: - // |capture_time| must be specified in the NTP time format in milliseconds. - virtual int32_t IncomingFrame(uint8_t* videoFrame, - size_t videoFrameLength, - const VideoCaptureCapability& frameInfo, - int64_t captureTime = 0) = 0; - - protected: - ~VideoCaptureExternal() {} -}; - } // namespace webrtc #endif // MODULES_VIDEO_CAPTURE_VIDEO_CAPTURE_DEFINES_H_ diff --git a/modules/video_capture/video_capture_factory.cc b/modules/video_capture/video_capture_factory.cc index 1119853856..c0e1479caf 100644 --- a/modules/video_capture/video_capture_factory.cc +++ b/modules/video_capture/video_capture_factory.cc @@ -23,11 +23,6 @@ rtc::scoped_refptr VideoCaptureFactory::Create( #endif } -rtc::scoped_refptr VideoCaptureFactory::Create( - VideoCaptureExternal*& externalCapture) { - return videocapturemodule::VideoCaptureImpl::Create(externalCapture); -} - VideoCaptureModule::DeviceInfo* VideoCaptureFactory::CreateDeviceInfo() { #if defined(WEBRTC_ANDROID) || defined(WEBRTC_MAC) return nullptr; diff --git a/modules/video_capture/video_capture_factory.h b/modules/video_capture/video_capture_factory.h index 1901958e31..1fe47d9fab 100644 --- a/modules/video_capture/video_capture_factory.h +++ b/modules/video_capture/video_capture_factory.h @@ -29,12 +29,6 @@ class VideoCaptureFactory { static rtc::scoped_refptr Create( const char* deviceUniqueIdUTF8); - // Create a video capture module object used for external capture. - // id - unique identifier of this video capture module object - // externalCapture - [out] interface to call when a new frame is captured. - static rtc::scoped_refptr Create( - VideoCaptureExternal*& externalCapture); - static VideoCaptureModule::DeviceInfo* CreateDeviceInfo(); private: diff --git a/modules/video_capture/video_capture_impl.cc b/modules/video_capture/video_capture_impl.cc index 410a4793ac..cd99e2be4f 100644 --- a/modules/video_capture/video_capture_impl.cc +++ b/modules/video_capture/video_capture_impl.cc @@ -24,13 +24,6 @@ namespace webrtc { namespace videocapturemodule { -rtc::scoped_refptr VideoCaptureImpl::Create( - VideoCaptureExternal*& externalCapture) { - rtc::scoped_refptr implementation( - new rtc::RefCountedObject()); - externalCapture = implementation.get(); - return implementation; -} const char* VideoCaptureImpl::CurrentDeviceName() const { return _deviceUniqueId; diff --git a/modules/video_capture/video_capture_impl.h b/modules/video_capture/video_capture_impl.h index 516446dd6c..197bfd387c 100644 --- a/modules/video_capture/video_capture_impl.h +++ b/modules/video_capture/video_capture_impl.h @@ -31,8 +31,7 @@ namespace webrtc { namespace videocapturemodule { // Class definitions -class VideoCaptureImpl : public VideoCaptureModule, - public VideoCaptureExternal { +class VideoCaptureImpl : public VideoCaptureModule { public: /* * Create a video capture module object @@ -44,15 +43,6 @@ class VideoCaptureImpl : public VideoCaptureModule, static rtc::scoped_refptr Create( const char* deviceUniqueIdUTF8); - /* - * Create a video capture module object used for external capture. - * - * id - unique identifier of this video capture module object - * externalCapture - [out] interface to call when a new frame is captured. - */ - static rtc::scoped_refptr Create( - VideoCaptureExternal*& externalCapture); - static DeviceInfo* CreateDeviceInfo(); // Helpers for converting between (integral) degrees and @@ -71,12 +61,11 @@ class VideoCaptureImpl : public VideoCaptureModule, const char* CurrentDeviceName() const override; - // Implement VideoCaptureExternal // |capture_time| must be specified in NTP time format in milliseconds. int32_t IncomingFrame(uint8_t* videoFrame, size_t videoFrameLength, const VideoCaptureCapability& frameInfo, - int64_t captureTime = 0) override; + int64_t captureTime = 0); // Platform dependent int32_t StartCapture(const VideoCaptureCapability& capability) override; @@ -87,7 +76,6 @@ class VideoCaptureImpl : public VideoCaptureModule, protected: VideoCaptureImpl(); ~VideoCaptureImpl() override; - int32_t DeliverCapturedFrame(VideoFrame& captureFrame); char* _deviceUniqueId; // current Device unique name; rtc::CriticalSection _apiCs; @@ -97,6 +85,7 @@ class VideoCaptureImpl : public VideoCaptureModule, private: void UpdateFrameCount(); uint32_t CalculateFrameRate(int64_t now_ns); + int32_t DeliverCapturedFrame(VideoFrame& captureFrame); // last time the module process function was called. int64_t _lastProcessTimeNanos; diff --git a/modules/video_capture/windows/sink_filter_ds.cc b/modules/video_capture/windows/sink_filter_ds.cc index c33a8f3454..15d3750715 100644 --- a/modules/video_capture/windows/sink_filter_ds.cc +++ b/modules/video_capture/windows/sink_filter_ds.cc @@ -784,7 +784,7 @@ STDMETHODIMP CaptureInputPin::ReceiveCanBlock() { // ---------------------------------------------------------------------------- -CaptureSinkFilter::CaptureSinkFilter(VideoCaptureExternal* capture_observer) +CaptureSinkFilter::CaptureSinkFilter(VideoCaptureImpl* capture_observer) : input_pin_(new ComRefCount(this)), capture_observer_(capture_observer) {} diff --git a/modules/video_capture/windows/sink_filter_ds.h b/modules/video_capture/windows/sink_filter_ds.h index d9896f1c36..af264a937a 100644 --- a/modules/video_capture/windows/sink_filter_ds.h +++ b/modules/video_capture/windows/sink_filter_ds.h @@ -17,7 +17,7 @@ #include #include -#include "modules/video_capture/video_capture_defines.h" +#include "modules/video_capture/video_capture_impl.h" #include "modules/video_capture/windows/help_functions_ds.h" #include "rtc_base/thread_annotations.h" #include "rtc_base/thread_checker.h" @@ -110,7 +110,7 @@ class CaptureInputPin : public IMemInputPin, public IPin { // Implement IBaseFilter (including IPersist and IMediaFilter). class CaptureSinkFilter : public IBaseFilter { public: - CaptureSinkFilter(VideoCaptureExternal* capture_observer); + CaptureSinkFilter(VideoCaptureImpl* capture_observer); HRESULT SetRequestedCapability(const VideoCaptureCapability& capability); @@ -149,7 +149,7 @@ class CaptureSinkFilter : public IBaseFilter { private: rtc::ThreadChecker main_checker_; const rtc::scoped_refptr> input_pin_; - VideoCaptureExternal* const capture_observer_; + VideoCaptureImpl* const capture_observer_; FILTER_INFO info_ RTC_GUARDED_BY(main_checker_) = {}; // Set/cleared in JoinFilterGraph. The filter must be stopped (no capture) // at that time, so no lock is required. While the state is not stopped, diff --git a/test/BUILD.gn b/test/BUILD.gn index c64713d9db..6486780e84 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -379,7 +379,6 @@ if (rtc_include_tests) { "../api/video:video_frame_i420", "../call:video_stream_api", "../modules/rtp_rtcp", - "../modules/video_capture", "../modules/video_coding:simulcast_test_fixture_impl", "../rtc_base:rtc_base_approved", "../rtc_base/system:file_wrapper", diff --git a/video/DEPS b/video/DEPS index 94a394b2dd..2a7dfb9592 100644 --- a/video/DEPS +++ b/video/DEPS @@ -13,7 +13,6 @@ include_rules = [ "+modules/rtp_rtcp", "+modules/utility", "+modules/video_coding", - "+modules/video_capture", "+modules/video_processing", "+system_wrappers", ]