Add support for platform software video decoder implementations.

Also enables support for all hardware implementations. Renames
HardwareVideoDecoderFactory to MediaCodecVideoDecoderFactory. Renames
HardwareVideoDecoder to AndroidVideoDecoder.

Bug: webrtc:8538
Change-Id: I9b351f387526af4da61fb07c07fb4285bd833e19
Reviewed-on: https://webrtc-review.googlesource.com/97680
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24586}
This commit is contained in:
Sami Kalliomäki
2018-09-05 16:38:57 +02:00
committed by Commit Bot
parent 906add4b25
commit 389d2261c3
13 changed files with 258 additions and 184 deletions

View File

@ -15,25 +15,37 @@ import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
/** Helper class that combines HW and SW decoders. */
/**
* Helper class that combines HW and SW decoders.
*/
public class DefaultVideoDecoderFactory implements VideoDecoderFactory {
private final VideoDecoderFactory hardwareVideoDecoderFactory;
private final VideoDecoderFactory softwareVideoDecoderFactory = new SoftwareVideoDecoderFactory();
private final @Nullable VideoDecoderFactory platformSoftwareVideoDecoderFactory;
/** Create decoder factory using default hardware decoder factory. */
public DefaultVideoDecoderFactory(EglBase.Context eglContext) {
/**
* Create decoder factory using default hardware decoder factory.
*/
public DefaultVideoDecoderFactory(@Nullable EglBase.Context eglContext) {
this.hardwareVideoDecoderFactory = new HardwareVideoDecoderFactory(eglContext);
this.platformSoftwareVideoDecoderFactory = new PlatformSoftwareVideoDecoderFactory(eglContext);
}
/** Create decoder factory using explicit hardware decoder factory. */
/**
* Create decoder factory using explicit hardware decoder factory.
*/
DefaultVideoDecoderFactory(VideoDecoderFactory hardwareVideoDecoderFactory) {
this.hardwareVideoDecoderFactory = hardwareVideoDecoderFactory;
this.platformSoftwareVideoDecoderFactory = null;
}
@Override
public @Nullable VideoDecoder createDecoder(VideoCodecInfo codecType) {
final VideoDecoder softwareDecoder = softwareVideoDecoderFactory.createDecoder(codecType);
VideoDecoder softwareDecoder = softwareVideoDecoderFactory.createDecoder(codecType);
final VideoDecoder hardwareDecoder = hardwareVideoDecoderFactory.createDecoder(codecType);
if (softwareDecoder == null && platformSoftwareVideoDecoderFactory != null) {
softwareDecoder = platformSoftwareVideoDecoderFactory.createDecoder(codecType);
}
if (hardwareDecoder != null && softwareDecoder != null) {
// Both hardware and software supported, wrap it in a software fallback
return new VideoDecoderFallback(
@ -48,6 +60,10 @@ public class DefaultVideoDecoderFactory implements VideoDecoderFactory {
supportedCodecInfos.addAll(Arrays.asList(softwareVideoDecoderFactory.getSupportedCodecs()));
supportedCodecInfos.addAll(Arrays.asList(hardwareVideoDecoderFactory.getSupportedCodecs()));
if (platformSoftwareVideoDecoderFactory != null) {
supportedCodecInfos.addAll(
Arrays.asList(platformSoftwareVideoDecoderFactory.getSupportedCodecs()));
}
return supportedCodecInfos.toArray(new VideoCodecInfo[supportedCodecInfos.size()]);
}