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}
This commit is contained in:
Rasmus Brandt
2018-07-09 13:38:01 +02:00
committed by Commit Bot
parent c75a5e8dd6
commit 42a2fc9cba
21 changed files with 120 additions and 143 deletions

View File

@ -51,6 +51,28 @@ public interface VideoDecoder {
void onDecodedFrame(VideoFrame frame, Integer decodeTimeMs, Integer qp);
}
/**
* 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.