Android: Pass VideoCodecInfo instead of String to createDecoder()
This is in line with the new C++ VideoCodecFactory interface. Bug: webrtc:7925 Change-Id: Ice51cab61b6498fef1b0483ce1bd4835ef550231 Reviewed-on: https://webrtc-review.googlesource.com/88368 Commit-Queue: Magnus Jedvert <magjed@webrtc.org> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23966}
This commit is contained in:
committed by
Commit Bot
parent
e6d7c3e32a
commit
026f27fac1
@ -31,7 +31,7 @@ public class DefaultVideoDecoderFactory implements VideoDecoderFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable VideoDecoder createDecoder(String codecType) {
|
public @Nullable VideoDecoder createDecoder(VideoCodecInfo codecType) {
|
||||||
final VideoDecoder softwareDecoder = softwareVideoDecoderFactory.createDecoder(codecType);
|
final VideoDecoder softwareDecoder = softwareVideoDecoderFactory.createDecoder(codecType);
|
||||||
final VideoDecoder hardwareDecoder = hardwareVideoDecoderFactory.createDecoder(codecType);
|
final VideoDecoder hardwareDecoder = hardwareVideoDecoderFactory.createDecoder(codecType);
|
||||||
if (hardwareDecoder != null && softwareDecoder != null) {
|
if (hardwareDecoder != null && softwareDecoder != null) {
|
||||||
|
|||||||
@ -46,8 +46,8 @@ public class HardwareVideoDecoderFactory implements VideoDecoderFactory {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public VideoDecoder createDecoder(String codecType) {
|
public VideoDecoder createDecoder(VideoCodecInfo codecType) {
|
||||||
VideoCodecType type = VideoCodecType.valueOf(codecType);
|
VideoCodecType type = VideoCodecType.valueOf(codecType.getName());
|
||||||
MediaCodecInfo info = findCodecForType(type);
|
MediaCodecInfo info = findCodecForType(type);
|
||||||
|
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
|
|||||||
@ -18,11 +18,11 @@ import javax.annotation.Nullable;
|
|||||||
public class SoftwareVideoDecoderFactory implements VideoDecoderFactory {
|
public class SoftwareVideoDecoderFactory implements VideoDecoderFactory {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public VideoDecoder createDecoder(String codecType) {
|
public VideoDecoder createDecoder(VideoCodecInfo codecType) {
|
||||||
if (codecType.equalsIgnoreCase("VP8")) {
|
if (codecType.getName().equalsIgnoreCase("VP8")) {
|
||||||
return new VP8Decoder();
|
return new VP8Decoder();
|
||||||
}
|
}
|
||||||
if (codecType.equalsIgnoreCase("VP9") && VP9Decoder.nativeIsSupported()) {
|
if (codecType.getName().equalsIgnoreCase("VP9") && VP9Decoder.nativeIsSupported()) {
|
||||||
return new VP9Decoder();
|
return new VP9Decoder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,18 @@ public interface VideoDecoderFactory {
|
|||||||
* Creates a VideoDecoder for the given codec. Supports the same codecs supported by
|
* Creates a VideoDecoder for the given codec. Supports the same codecs supported by
|
||||||
* VideoEncoderFactory.
|
* VideoEncoderFactory.
|
||||||
*/
|
*/
|
||||||
@Nullable @CalledByNative VideoDecoder createDecoder(String codecType);
|
@Deprecated
|
||||||
|
@Nullable
|
||||||
|
default VideoDecoder createDecoder(String codecType) {
|
||||||
|
throw new UnsupportedOperationException("Deprecated and not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Creates a decoder for the given video codec. */
|
||||||
|
@Nullable
|
||||||
|
@CalledByNative
|
||||||
|
default VideoDecoder createDecoder(VideoCodecInfo info) {
|
||||||
|
return createDecoder(info.getName());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enumerates the list of supported video codecs.
|
* Enumerates the list of supported video codecs.
|
||||||
|
|||||||
@ -40,24 +40,28 @@ public final class HardwareVideoDecoderTest {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
CLASS_PARAMS.add(new ParameterSet()
|
CLASS_PARAMS.add(new ParameterSet()
|
||||||
.value("VP8" /* codecType */, false /* useEglContext */)
|
.value(/* codecName= */ "VP8", false /* useEglContext */)
|
||||||
.name("VP8WithoutEglContext"));
|
.name("VP8WithoutEglContext"));
|
||||||
CLASS_PARAMS.add(new ParameterSet()
|
CLASS_PARAMS.add(new ParameterSet()
|
||||||
.value("VP8" /* codecType */, true /* useEglContext */)
|
.value(/* codecName= */ "VP8", true /* useEglContext */)
|
||||||
.name("VP8WithEglContext"));
|
.name("VP8WithEglContext"));
|
||||||
CLASS_PARAMS.add(new ParameterSet()
|
CLASS_PARAMS.add(new ParameterSet()
|
||||||
.value("H264" /* codecType */, false /* useEglContext */)
|
.value(/* codecName= */ "H264", false /* useEglContext */)
|
||||||
.name("H264WithoutEglContext"));
|
.name("H264WithoutEglContext"));
|
||||||
CLASS_PARAMS.add(new ParameterSet()
|
CLASS_PARAMS.add(new ParameterSet()
|
||||||
.value("H264" /* codecType */, true /* useEglContext */)
|
.value(/* codecName= */ "H264", true /* useEglContext */)
|
||||||
.name("H264WithEglContext"));
|
.name("H264WithEglContext"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String codecType;
|
private final VideoCodecInfo codecType;
|
||||||
private final boolean useEglContext;
|
private final boolean useEglContext;
|
||||||
|
|
||||||
public HardwareVideoDecoderTest(String codecType, boolean useEglContext) {
|
public HardwareVideoDecoderTest(String codecName, boolean useEglContext) {
|
||||||
this.codecType = codecType;
|
if (codecName.equals("H264")) {
|
||||||
|
this.codecType = H264Utils.DEFAULT_H264_BASELINE_PROFILE_CODEC;
|
||||||
|
} else {
|
||||||
|
this.codecType = new VideoCodecInfo(codecName, new HashMap<>());
|
||||||
|
}
|
||||||
this.useEglContext = useEglContext;
|
this.useEglContext = useEglContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,8 +138,7 @@ public final class HardwareVideoDecoderTest {
|
|||||||
private void encodeTestFrames() {
|
private void encodeTestFrames() {
|
||||||
VideoEncoderFactory encoderFactory = new HardwareVideoEncoderFactory(
|
VideoEncoderFactory encoderFactory = new HardwareVideoEncoderFactory(
|
||||||
eglBase.getEglBaseContext(), ENABLE_INTEL_VP8_ENCODER, ENABLE_H264_HIGH_PROFILE);
|
eglBase.getEglBaseContext(), ENABLE_INTEL_VP8_ENCODER, ENABLE_H264_HIGH_PROFILE);
|
||||||
VideoEncoder encoder =
|
VideoEncoder encoder = encoderFactory.createEncoder(codecType);
|
||||||
encoderFactory.createEncoder(new VideoCodecInfo(codecType, new HashMap<>()));
|
|
||||||
HardwareVideoEncoderTest.MockEncoderCallback encodeCallback =
|
HardwareVideoEncoderTest.MockEncoderCallback encodeCallback =
|
||||||
new HardwareVideoEncoderTest.MockEncoderCallback();
|
new HardwareVideoEncoderTest.MockEncoderCallback();
|
||||||
assertEquals(VideoCodecStatus.OK, encoder.initEncode(ENCODER_SETTINGS, encodeCallback));
|
assertEquals(VideoCodecStatus.OK, encoder.initEncode(ENCODER_SETTINGS, encodeCallback));
|
||||||
|
|||||||
@ -31,8 +31,10 @@ VideoDecoderFactoryWrapper::~VideoDecoderFactoryWrapper() = default;
|
|||||||
std::unique_ptr<VideoDecoder> VideoDecoderFactoryWrapper::CreateVideoDecoder(
|
std::unique_ptr<VideoDecoder> VideoDecoderFactoryWrapper::CreateVideoDecoder(
|
||||||
const SdpVideoFormat& format) {
|
const SdpVideoFormat& format) {
|
||||||
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
JNIEnv* jni = AttachCurrentThreadIfNeeded();
|
||||||
|
ScopedJavaLocalRef<jobject> j_codec_info =
|
||||||
|
SdpVideoFormatToVideoCodecInfo(jni, format);
|
||||||
ScopedJavaLocalRef<jobject> decoder = Java_VideoDecoderFactory_createDecoder(
|
ScopedJavaLocalRef<jobject> decoder = Java_VideoDecoderFactory_createDecoder(
|
||||||
jni, decoder_factory_, NativeToJavaString(jni, format.name));
|
jni, decoder_factory_, j_codec_info);
|
||||||
if (!decoder.obj())
|
if (!decoder.obj())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return JavaToNativeVideoDecoder(jni, decoder);
|
return JavaToNativeVideoDecoder(jni, decoder);
|
||||||
|
|||||||
Reference in New Issue
Block a user