webrtc/sdk/android/api/org/webrtc/VideoEncoderFallback.java
Rasmus Brandt 42a2fc9cba 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}
2018-07-09 12:07:11 +00:00

36 lines
1.1 KiB
Java

/*
* Copyright 2017 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package org.webrtc;
/**
* A combined video encoder that falls back on a secondary encoder if the primary encoder fails.
*/
public class VideoEncoderFallback extends WrappedNativeVideoEncoder {
private final VideoEncoder fallback;
private final VideoEncoder primary;
public VideoEncoderFallback(VideoEncoder fallback, VideoEncoder primary) {
this.fallback = fallback;
this.primary = primary;
}
@Override
public long createNativeVideoEncoder() {
return nativeCreateEncoder(fallback, primary);
}
@Override
public boolean isHardwareEncoder() {
return primary.isHardwareEncoder();
}
private static native long nativeCreateEncoder(VideoEncoder fallback, VideoEncoder primary);
}