Move VideoCapturer to video_api and cleanup.

This should only be landed after clients have been given time to
upgrade to the new interface.

Bug: webrtc:9496, webrtc:9181
Change-Id: Ideb37637d9f0b9a3a9748811879c263c64f81d11
Reviewed-on: https://webrtc-review.googlesource.com/87308
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Reviewed-by: Paulina Hensman <phensman@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24080}
diff --git a/examples/BUILD.gn b/examples/BUILD.gn
index b1f5114..471424b 100644
--- a/examples/BUILD.gn
+++ b/examples/BUILD.gn
@@ -124,6 +124,7 @@
       "../sdk/android:surfaceviewrenderer_java",
       "../sdk/android:swcodecs_java",
       "../sdk/android:video_api_java",
+      "../sdk/android:video_java",
       "androidapp/third_party/autobanh:autobanh_java",
       "//third_party/jsr-305:jsr_305_javalib",
     ]
@@ -148,6 +149,7 @@
     deps = [
       ":AppRTCMobile_javalib",
       "../sdk/android:libjingle_peerconnection_java",
+      "../sdk/android:video_java",
       "//third_party/android_support_test_runner:runner_java",
       "//third_party/junit",
     ]
diff --git a/sdk/android/BUILD.gn b/sdk/android/BUILD.gn
index 900ab22..4ba9cdd 100644
--- a/sdk/android/BUILD.gn
+++ b/sdk/android/BUILD.gn
@@ -755,7 +755,6 @@
   rtc_android_library("video_api_java") {
     java_files = [
       "api/org/webrtc/EncodedImage.java",
-      "api/org/webrtc/VideoCapturer.java",
       "api/org/webrtc/VideoCodecInfo.java",
       "api/org/webrtc/CapturerObserver.java",
       "api/org/webrtc/VideoCodecStatus.java",
@@ -768,22 +767,7 @@
     ]
 
     # TODO(sakal): These should be moved to video_java but cannot because of dependencies.
-    java_files += [
-      "api/org/webrtc/EglBase.java",
-      "api/org/webrtc/GlShader.java",
-      "api/org/webrtc/GlTextureFrameBuffer.java",
-      "api/org/webrtc/GlUtil.java",
-      "api/org/webrtc/JavaI420Buffer.java",
-      "api/org/webrtc/RendererCommon.java",
-      "api/org/webrtc/SurfaceTextureHelper.java",
-      "api/org/webrtc/TextureBufferImpl.java",
-      "api/org/webrtc/YuvConverter.java",
-      "api/org/webrtc/VideoFrameDrawer.java",
-      "src/java/org/webrtc/GlGenericDrawer.java",
-      "api/org/webrtc/YuvHelper.java",
-      "src/java/org/webrtc/EglBase10.java",
-      "src/java/org/webrtc/EglBase14.java",
-    ]
+    java_files += [ "api/org/webrtc/JavaI420Buffer.java" ]
 
     deps = [
       ":base_java",
@@ -842,12 +826,26 @@
 
   rtc_android_library("video_java") {
     java_files = [
+      "api/org/webrtc/EglBase.java",
       "api/org/webrtc/EglRenderer.java",
       "api/org/webrtc/GlRectDrawer.java",
+      "api/org/webrtc/GlShader.java",
+      "api/org/webrtc/GlTextureFrameBuffer.java",
+      "api/org/webrtc/GlUtil.java",
+      "api/org/webrtc/RendererCommon.java",
+      "api/org/webrtc/SurfaceTextureHelper.java",
+      "api/org/webrtc/TextureBufferImpl.java",
+      "api/org/webrtc/VideoCapturer.java",
       "api/org/webrtc/VideoDecoderFallback.java",
       "api/org/webrtc/VideoEncoderFallback.java",
-      "src/java/org/webrtc/NV21Buffer.java",
+      "api/org/webrtc/VideoFrameDrawer.java",
+      "api/org/webrtc/YuvConverter.java",
+      "api/org/webrtc/YuvHelper.java",
+      "src/java/org/webrtc/EglBase10.java",
+      "src/java/org/webrtc/EglBase14.java",
+      "src/java/org/webrtc/GlGenericDrawer.java",
       "src/java/org/webrtc/H264Utils.java",
+      "src/java/org/webrtc/NV21Buffer.java",
       "src/java/org/webrtc/VideoDecoderWrapper.java",
       "src/java/org/webrtc/VideoEncoderWrapper.java",
       "src/java/org/webrtc/WrappedNativeI420Buffer.java",
@@ -1106,6 +1104,7 @@
         ":libjingle_peerconnection_java",
         ":libjingle_peerconnection_metrics_default_java",
         ":video_api_java",
+        ":video_java",
         "//base:base_java",
         "//base:base_java_test_support",
         "//rtc_base:base_java",
diff --git a/sdk/android/api/org/webrtc/CapturerObserver.java b/sdk/android/api/org/webrtc/CapturerObserver.java
index 4edab9a..382dc15 100644
--- a/sdk/android/api/org/webrtc/CapturerObserver.java
+++ b/sdk/android/api/org/webrtc/CapturerObserver.java
@@ -15,15 +15,13 @@
  * {@link VideoSource#getCapturerObserver}.
  *
  * All callbacks must be executed on a single thread.
- *
- * @note This will replace the deprecated VideoCapturer.CapturerObserver interface.
  */
-public interface CapturerObserver extends VideoCapturer.CapturerObserver {
+public interface CapturerObserver {
   /** Notify if the capturer have been started successfully or not. */
-  @Override void onCapturerStarted(boolean success);
+  void onCapturerStarted(boolean success);
   /** Notify that the capturer has been stopped. */
-  @Override void onCapturerStopped();
+  void onCapturerStopped();
 
   /** Delivers a captured frame. */
-  @Override void onFrameCaptured(VideoFrame frame);
+  void onFrameCaptured(VideoFrame frame);
 }
diff --git a/sdk/android/api/org/webrtc/PeerConnectionFactory.java b/sdk/android/api/org/webrtc/PeerConnectionFactory.java
index 3a76d7c..acf3a71 100644
--- a/sdk/android/api/org/webrtc/PeerConnectionFactory.java
+++ b/sdk/android/api/org/webrtc/PeerConnectionFactory.java
@@ -399,17 +399,6 @@
     return new VideoSource(nativeCreateVideoSource(nativeFactory, isScreencast));
   }
 
-  @Deprecated
-  public VideoSource createVideoSource(VideoCapturer capturer) {
-    final SurfaceTextureHelper surfaceTextureHelper = SurfaceTextureHelper.create(
-        VIDEO_CAPTURER_THREAD_NAME, MediaCodecVideoEncoder.getEglContext());
-    final VideoSource videoSource = new VideoSource(
-        nativeCreateVideoSource(nativeFactory, capturer.isScreencast()), surfaceTextureHelper);
-    capturer.initialize(surfaceTextureHelper, ContextUtils.getApplicationContext(),
-        videoSource.getCapturerObserver());
-    return videoSource;
-  }
-
   public VideoTrack createVideoTrack(String id, VideoSource source) {
     return new VideoTrack(nativeCreateVideoTrack(nativeFactory, id, source.nativeSource));
   }
diff --git a/sdk/android/api/org/webrtc/VideoCapturer.java b/sdk/android/api/org/webrtc/VideoCapturer.java
index 8292fbd..f5684fc 100644
--- a/sdk/android/api/org/webrtc/VideoCapturer.java
+++ b/sdk/android/api/org/webrtc/VideoCapturer.java
@@ -15,25 +15,6 @@
 
 // Base interface for all VideoCapturers to implement.
 public interface VideoCapturer {
-  // Interface used for providing callbacks to an observer.
-  @Deprecated
-  public interface CapturerObserver {
-    // Notify if the camera have been started successfully or not.
-    // Called on a Java thread owned by VideoCapturer.
-    void onCapturerStarted(boolean success);
-    void onCapturerStopped();
-
-    // Delivers a captured frame. Called on a Java thread owned by VideoCapturer.
-    void onFrameCaptured(VideoFrame frame);
-  }
-
-  /** Deprecated, implementations should be update to implement the version below. */
-  @Deprecated
-  default void initialize(SurfaceTextureHelper surfaceTextureHelper, Context applicationContext,
-      CapturerObserver capturerObserver) {
-    throw new UnsupportedOperationException("Not implemented.");
-  }
-
   /**
    * This function is used to initialize the camera thread, the android application context, and the
    * capture observer. It will be called only once and before any startCapture() request. The
@@ -45,12 +26,8 @@
    * called. This also means that the caller can reuse the SurfaceTextureHelper to initialize a new
    * VideoCapturer once the previous VideoCapturer has been disposed.
    */
-  // Our version of clang format doesn't understand default and messes up.
-  // clang-format off
-  default void initialize(SurfaceTextureHelper surfaceTextureHelper, Context applicationContext,
-      org.webrtc.CapturerObserver capturerObserver) {
-    initialize(surfaceTextureHelper, applicationContext, (CapturerObserver) capturerObserver);
-  }
+  void initialize(SurfaceTextureHelper surfaceTextureHelper, Context applicationContext,
+      CapturerObserver capturerObserver);
 
   /**
    * Start capturing frames in a format that is as close as possible to {@code width x height} and
diff --git a/sdk/android/api/org/webrtc/VideoSource.java b/sdk/android/api/org/webrtc/VideoSource.java
index fb0ad1a..e0c6167 100644
--- a/sdk/android/api/org/webrtc/VideoSource.java
+++ b/sdk/android/api/org/webrtc/VideoSource.java
@@ -23,13 +23,6 @@
     this.capturerObserver = new NativeCapturerObserver(nativeGetInternalSource(nativeSource));
   }
 
-  // TODO(bugs.webrtc.org/9181): Remove.
-  VideoSource(long nativeSource, SurfaceTextureHelper surfaceTextureHelper) {
-    super(nativeSource);
-    this.capturerObserver =
-        new NativeCapturerObserver(nativeGetInternalSource(nativeSource), surfaceTextureHelper);
-  }
-
   /**
    * Calling this function will cause frames to be scaled down to the requested resolution. Also,
    * frames will be cropped to match the requested aspect ratio, and frames will be dropped to match
@@ -44,12 +37,6 @@
     return capturerObserver;
   }
 
-  @Override
-  public void dispose() {
-    capturerObserver.dispose();
-    super.dispose();
-  }
-
   // Returns source->internal() from webrtc::VideoTrackSourceProxy.
   private static native long nativeGetInternalSource(long source);
   private static native void nativeAdaptOutputFormat(long source, int width, int height, int fps);
diff --git a/sdk/android/src/java/org/webrtc/NativeCapturerObserver.java b/sdk/android/src/java/org/webrtc/NativeCapturerObserver.java
index bbef277..2486981 100644
--- a/sdk/android/src/java/org/webrtc/NativeCapturerObserver.java
+++ b/sdk/android/src/java/org/webrtc/NativeCapturerObserver.java
@@ -19,19 +19,10 @@
 class NativeCapturerObserver implements CapturerObserver {
   // Pointer to webrtc::jni::AndroidVideoTrackSource.
   private final long nativeSource;
-  // TODO(bugs.webrtc.org/9181): Remove.
-  @Nullable private final SurfaceTextureHelper surfaceTextureHelper;
 
   @CalledByNative
   public NativeCapturerObserver(long nativeSource) {
     this.nativeSource = nativeSource;
-    this.surfaceTextureHelper = null;
-  }
-
-  // TODO(bugs.webrtc.org/9181): Remove.
-  public NativeCapturerObserver(long nativeSource, SurfaceTextureHelper surfaceTextureHelper) {
-    this.nativeSource = nativeSource;
-    this.surfaceTextureHelper = surfaceTextureHelper;
   }
 
   @Override
@@ -50,12 +41,6 @@
         frame.getRotation(), frame.getTimestampNs(), frame.getBuffer());
   }
 
-  public void dispose() {
-    if (surfaceTextureHelper != null) {
-      surfaceTextureHelper.dispose();
-    }
-  }
-
   private static native void nativeCapturerStarted(long source, boolean success);
   private static native void nativeCapturerStopped(long source);
   private static native void nativeOnFrameCaptured(