Support injecting custom native codecs from Java.

This CL extends our support for injecting native codecs such that
downstream users can create Java codecs that are backed by custom
native codecs.

After this CL, the Java codec interfaces expose
createNativeVideo{En,Decoder}() methods that may return a value
representing a pointer to the backing native codec. Previously,
a similar mechanism was used for the special case of non-public
Java codecs extending from the internal
WrappedNativeVideo{En,De}coder classes.

Tested: AppRTCMobile on Pixel XL and Pixel 2.
Bug: webrtc:9495
Change-Id: I079ff744afc7bf9873ff983e775c136a6667266d
Reviewed-on: https://webrtc-review.googlesource.com/87264
Commit-Queue: Rasmus Brandt <brandtr@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23883}
diff --git a/sdk/android/api/org/webrtc/VideoDecoder.java b/sdk/android/api/org/webrtc/VideoDecoder.java
index 7bf9ac5..879b694 100644
--- a/sdk/android/api/org/webrtc/VideoDecoder.java
+++ b/sdk/android/api/org/webrtc/VideoDecoder.java
@@ -52,6 +52,28 @@
   }
 
   /**
+   * The decoder implementation backing this interface is either 1) a Java
+   * decoder (e.g., an Android platform decoder), or alternatively 2) a native
+   * decoder (e.g., a software decoder or a C++ decoder adapter).
+   *
+   * For case 1), createNativeVideoDecoder() should return zero.
+   * In this case, we expect the native library to call the decoder through
+   * JNI using the Java interface declared below.
+   *
+   * For case 2), createNativeVideoDecoder() should return a non-zero value.
+   * In this case, we expect the native library to treat the returned value as
+   * a raw pointer of type webrtc::VideoDecoder* (ownership is transferred to
+   * the caller). The native library should then directly call the
+   * webrtc::VideoDecoder interface without going through JNI. All calls to
+   * the Java interface methods declared below should thus throw an
+   * UnsupportedOperationException.
+   */
+  @CalledByNative
+  default long createNativeVideoDecoder() {
+    return 0;
+  }
+
+  /**
    * Initializes the decoding process with specified settings. Will be called on the decoding thread
    * before any decode calls.
    */