Conclude VideoFrame emit fieldtrial.

Concludes VideoFrame emit fieldtrial and start producing VideoFrames
by default. Deprecates old onByteBufferFrameCaptured and
onTextureFrameCaptured methods.

Bug: webrtc:8776
Change-Id: Icc224e9f8d89a30f04cf95dd46a498d69cffe9d0
Reviewed-on: https://webrtc-review.googlesource.com/43022
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Reviewed-by: Anders Carlsson <andersc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21866}
diff --git a/sdk/android/api/org/webrtc/PeerConnectionFactory.java b/sdk/android/api/org/webrtc/PeerConnectionFactory.java
index 71e4b6c..79eca7e 100644
--- a/sdk/android/api/org/webrtc/PeerConnectionFactory.java
+++ b/sdk/android/api/org/webrtc/PeerConnectionFactory.java
@@ -20,7 +20,7 @@
 @JNINamespace("webrtc::jni")
 public class PeerConnectionFactory {
   public static final String TRIAL_ENABLED = "Enabled";
-  public static final String VIDEO_FRAME_EMIT_TRIAL = "VideoFrameEmit";
+  @Deprecated public static final String VIDEO_FRAME_EMIT_TRIAL = "VideoFrameEmit";
 
   private static final String TAG = "PeerConnectionFactory";
   private static final String VIDEO_CAPTURER_THREAD_NAME = "VideoCapturerThread";
diff --git a/sdk/android/api/org/webrtc/ScreenCapturerAndroid.java b/sdk/android/api/org/webrtc/ScreenCapturerAndroid.java
index 0279dfe..260d7a3 100644
--- a/sdk/android/api/org/webrtc/ScreenCapturerAndroid.java
+++ b/sdk/android/api/org/webrtc/ScreenCapturerAndroid.java
@@ -195,8 +195,11 @@
   @Override
   public void onTextureFrameAvailable(int oesTextureId, float[] transformMatrix, long timestampNs) {
     numCapturedFrames++;
-    capturerObserver.onTextureFrameCaptured(
-        width, height, oesTextureId, transformMatrix, 0 /* rotation */, timestampNs);
+    final VideoFrame.Buffer buffer = surfaceTextureHelper.createTextureBuffer(
+        width, height, RendererCommon.convertMatrixToAndroidGraphicsMatrix(transformMatrix));
+    final VideoFrame frame = new VideoFrame(buffer, 0 /* rotation */, timestampNs);
+    capturerObserver.onFrameCaptured(frame);
+    frame.release();
   }
 
   @Override
diff --git a/sdk/android/api/org/webrtc/VideoCapturer.java b/sdk/android/api/org/webrtc/VideoCapturer.java
index 804560a..e0c16b7 100644
--- a/sdk/android/api/org/webrtc/VideoCapturer.java
+++ b/sdk/android/api/org/webrtc/VideoCapturer.java
@@ -23,13 +23,19 @@
     void onCapturerStopped();
 
     // Delivers a captured frame. Called on a Java thread owned by VideoCapturer.
-    void onByteBufferFrameCaptured(
-        byte[] data, int width, int height, int rotation, long timeStamp);
+    @Deprecated
+    default void onByteBufferFrameCaptured(
+        byte[] data, int width, int height, int rotation, long timeStamp) {
+      throw new UnsupportedOperationException("Deprecated and not implemented.");
+    }
 
     // Delivers a captured frame in a texture with id |oesTextureId|. Called on a Java thread
     // owned by VideoCapturer.
-    void onTextureFrameCaptured(int width, int height, int oesTextureId, float[] transformMatrix,
-        int rotation, long timestamp);
+    @Deprecated
+    default void onTextureFrameCaptured(int width, int height, int oesTextureId,
+        float[] transformMatrix, int rotation, long timestamp) {
+      throw new UnsupportedOperationException("Deprecated and not implemented.");
+    }
 
     // Delivers a captured frame. Called on a Java thread owned by VideoCapturer.
     void onFrameCaptured(VideoFrame frame);