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:
committed by
Commit Bot
parent
c75a5e8dd6
commit
42a2fc9cba
@ -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.
|
||||
|
||||
@ -23,7 +23,7 @@ public class VideoDecoderFallback extends WrappedNativeVideoDecoder {
|
||||
}
|
||||
|
||||
@Override
|
||||
long createNativeDecoder() {
|
||||
public long createNativeVideoDecoder() {
|
||||
return nativeCreateDecoder(fallback, primary);
|
||||
}
|
||||
|
||||
|
||||
@ -163,6 +163,36 @@ public interface VideoEncoder {
|
||||
void onEncodedFrame(EncodedImage frame, CodecSpecificInfo info);
|
||||
}
|
||||
|
||||
/**
|
||||
* The encoder implementation backing this interface is either 1) a Java
|
||||
* encoder (e.g., an Android platform encoder), or alternatively 2) a native
|
||||
* encoder (e.g., a software encoder or a C++ encoder adapter).
|
||||
*
|
||||
* For case 1), createNativeVideoEncoder() should return zero.
|
||||
* In this case, we expect the native library to call the encoder through
|
||||
* JNI using the Java interface declared below.
|
||||
*
|
||||
* For case 2), createNativeVideoEncoder() 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::VideoEncoder* (ownership is transferred to
|
||||
* the caller). The native library should then directly call the
|
||||
* webrtc::VideoEncoder interface without going through JNI. All calls to
|
||||
* the Java interface methods declared below should thus throw an
|
||||
* UnsupportedOperationException.
|
||||
*/
|
||||
@CalledByNative
|
||||
default long createNativeVideoEncoder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the encoder is backed by hardware.
|
||||
*/
|
||||
@CalledByNative
|
||||
default boolean isHardwareEncoder() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the encoding process. Call before any calls to encode.
|
||||
*/
|
||||
|
||||
@ -23,13 +23,13 @@ public class VideoEncoderFallback extends WrappedNativeVideoEncoder {
|
||||
}
|
||||
|
||||
@Override
|
||||
long createNativeEncoder() {
|
||||
public long createNativeVideoEncoder() {
|
||||
return nativeCreateEncoder(fallback, primary);
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isSoftwareEncoder() {
|
||||
return isWrappedSoftwareEncoder(primary);
|
||||
public boolean isHardwareEncoder() {
|
||||
return primary.isHardwareEncoder();
|
||||
}
|
||||
|
||||
private static native long nativeCreateEncoder(VideoEncoder fallback, VideoEncoder primary);
|
||||
|
||||
Reference in New Issue
Block a user