Android: Don't create VP9 encoder/decoder when not supported.

In the SoftwareVideoCodecFactories, don't try to create VP9 encoder or
decoder if WebRTC was built without support for it.

Bug: None
Change-Id: I09b87fdcf798c763310af4998dbea8011843010d
Reviewed-on: https://webrtc-review.googlesource.com/22924
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Commit-Queue: Anders Carlsson <andersc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20672}
This commit is contained in:
Anders Carlsson
2017-11-14 13:09:12 +01:00
committed by Commit Bot
parent ee92d626bd
commit 6cb76506fe
5 changed files with 30 additions and 6 deletions

View File

@ -16,7 +16,7 @@ public class SoftwareVideoDecoderFactory implements VideoDecoderFactory {
if (codecType.equalsIgnoreCase("VP8")) {
return new VP8Decoder();
}
if (codecType.equalsIgnoreCase("VP9")) {
if (codecType.equalsIgnoreCase("VP9") && VP9Decoder.isSupported()) {
return new VP9Decoder();
}

View File

@ -10,7 +10,9 @@
package org.webrtc;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class SoftwareVideoEncoderFactory implements VideoEncoderFactory {
@Override
@ -18,7 +20,7 @@ public class SoftwareVideoEncoderFactory implements VideoEncoderFactory {
if (info.name.equalsIgnoreCase("VP8")) {
return new VP8Encoder();
}
if (info.name.equalsIgnoreCase("VP9")) {
if (info.name.equalsIgnoreCase("VP9") && VP9Encoder.isSupported()) {
return new VP9Encoder();
}
@ -30,10 +32,14 @@ public class SoftwareVideoEncoderFactory implements VideoEncoderFactory {
return supportedCodecs();
}
public static VideoCodecInfo[] supportedCodecs() {
VideoCodecInfo vp8Info = new VideoCodecInfo("VP8", new HashMap<>());
VideoCodecInfo vp9Info = new VideoCodecInfo("VP9", new HashMap<>());
static VideoCodecInfo[] supportedCodecs() {
List<VideoCodecInfo> codecs = new ArrayList<VideoCodecInfo>();
return new VideoCodecInfo[] {vp8Info, vp9Info};
codecs.add(new VideoCodecInfo("VP8", new HashMap<>()));
if (VP9Encoder.isSupported()) {
codecs.add(new VideoCodecInfo("VP9", new HashMap<>()));
}
return codecs.toArray(new VideoCodecInfo[codecs.size()]);
}
}

View File

@ -15,5 +15,7 @@ class VP9Decoder extends WrappedNativeVideoDecoder {
super(createNativeDecoder());
}
static native boolean isSupported();
private static native long createNativeDecoder();
}

View File

@ -15,5 +15,7 @@ class VP9Encoder extends WrappedNativeVideoEncoder {
super(createNativeEncoder());
}
static native boolean isSupported();
private static native long createNativeEncoder();
}

View File

@ -23,6 +23,13 @@ JNI_FUNCTION_DECLARATION(jlong,
return jlongFromPointer(VP9Encoder::Create().release());
}
JNI_FUNCTION_DECLARATION(jboolean,
VP9Encoder_isSupported,
JNIEnv* jni,
jclass) {
return VP9Encoder::IsSupported();
}
JNI_FUNCTION_DECLARATION(jlong,
VP9Decoder_createNativeDecoder,
JNIEnv* jni,
@ -30,5 +37,12 @@ JNI_FUNCTION_DECLARATION(jlong,
return jlongFromPointer(VP9Decoder::Create().release());
}
JNI_FUNCTION_DECLARATION(jboolean,
VP9Decoder_isSupported,
JNIEnv* jni,
jclass) {
return VP9Decoder::IsSupported();
}
} // namespace jni
} // namespace webrtc