Delete interface class VideoCaptureExternal

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 <mflodman@webrtc.org>
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27506}
diff --git a/BUILD.gn b/BUILD.gn
index f299446..0c2096b 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -555,7 +555,6 @@
       # 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 86b6604..53bdea0 100644
--- a/common_video/BUILD.gn
+++ b/common_video/BUILD.gn
@@ -95,7 +95,6 @@
       "../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 c90cc47..3afaf35 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -299,9 +299,7 @@
   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 3831036..b4c88b7 100644
--- a/modules/BUILD.gn
+++ b/modules/BUILD.gn
@@ -261,10 +261,6 @@
       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 a098d39..af6f22e 100644
--- a/modules/video_capture/BUILD.gn
+++ b/modules/video_capture/BUILD.gn
@@ -42,21 +42,6 @@
   ]
 }
 
-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 9d4142f..0000000
--- 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 <stdint.h>
-
-#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 f61e73e..0000000
--- 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<VideoCaptureModule> VideoCaptureImpl::Create(
-    const char* deviceUniqueIdUTF8) {
-  return new rtc::RefCountedObject<VideoCaptureImpl>();
-}
-
-}  // 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 4bc6866..283c13f 100644
--- a/modules/video_capture/test/video_capture_unittest.cc
+++ b/modules/video_capture/test/video_capture_unittest.cc
@@ -52,9 +52,11 @@
   } 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<webrtc::VideoFrame> {
@@ -344,83 +346,3 @@
   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<webrtc::I420Buffer> 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>(
-        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<VideoCaptureModule> capture_module_;
-  std::unique_ptr<webrtc::VideoFrame> 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<uint8_t[]> 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<uint8_t[]> 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 95747a4..bdd74d5 100644
--- a/modules/video_capture/video_capture_defines.h
+++ b/modules/video_capture/video_capture_defines.h
@@ -55,21 +55,6 @@
   }
 };
 
-/* 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 1119853..c0e1479 100644
--- a/modules/video_capture/video_capture_factory.cc
+++ b/modules/video_capture/video_capture_factory.cc
@@ -23,11 +23,6 @@
 #endif
 }
 
-rtc::scoped_refptr<VideoCaptureModule> 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 1901958..1fe47d9 100644
--- a/modules/video_capture/video_capture_factory.h
+++ b/modules/video_capture/video_capture_factory.h
@@ -29,12 +29,6 @@
   static rtc::scoped_refptr<VideoCaptureModule> 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<VideoCaptureModule> 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 410a479..cd99e2b 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<VideoCaptureModule> VideoCaptureImpl::Create(
-    VideoCaptureExternal*& externalCapture) {
-  rtc::scoped_refptr<VideoCaptureImpl> implementation(
-      new rtc::RefCountedObject<VideoCaptureImpl>());
-  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 516446d..197bfd38 100644
--- a/modules/video_capture/video_capture_impl.h
+++ b/modules/video_capture/video_capture_impl.h
@@ -31,8 +31,7 @@
 
 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 @@
   static rtc::scoped_refptr<VideoCaptureModule> 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<VideoCaptureModule> Create(
-      VideoCaptureExternal*& externalCapture);
-
   static DeviceInfo* CreateDeviceInfo();
 
   // Helpers for converting between (integral) degrees and
@@ -71,12 +61,11 @@
 
   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 @@
  protected:
   VideoCaptureImpl();
   ~VideoCaptureImpl() override;
-  int32_t DeliverCapturedFrame(VideoFrame& captureFrame);
 
   char* _deviceUniqueId;  // current Device unique name;
   rtc::CriticalSection _apiCs;
@@ -97,6 +85,7 @@
  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 c33a8f3..15d3750 100644
--- a/modules/video_capture/windows/sink_filter_ds.cc
+++ b/modules/video_capture/windows/sink_filter_ds.cc
@@ -784,7 +784,7 @@
 
 //  ----------------------------------------------------------------------------
 
-CaptureSinkFilter::CaptureSinkFilter(VideoCaptureExternal* capture_observer)
+CaptureSinkFilter::CaptureSinkFilter(VideoCaptureImpl* capture_observer)
     : input_pin_(new ComRefCount<CaptureInputPin>(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 d9896f1..af264a9 100644
--- a/modules/video_capture/windows/sink_filter_ds.h
+++ b/modules/video_capture/windows/sink_filter_ds.h
@@ -17,7 +17,7 @@
 #include <memory>
 #include <vector>
 
-#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 @@
 // 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 @@
  private:
   rtc::ThreadChecker main_checker_;
   const rtc::scoped_refptr<ComRefCount<CaptureInputPin>> 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 c64713d..6486780 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -379,7 +379,6 @@
       "../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 94a394b..2a7dfb9 100644
--- a/video/DEPS
+++ b/video/DEPS
@@ -13,7 +13,6 @@
   "+modules/rtp_rtcp",
   "+modules/utility",
   "+modules/video_coding",
-  "+modules/video_capture",
   "+modules/video_processing",
   "+system_wrappers",
 ]