Injectable software codecs for Android.
This is similar to https://webrtc-review.googlesource.com/c/src/+/3620 for iOS. Using the new WebRtcMediaEngineFactory::Create API, the built-in software video codecs are no longer appended to the injected codecs. To be able to use the software codecs, they are exposed as Java classes through SoftwareVideoEncoderFactory etc. There is also a new DefaultVideoEncoderFactory used by AppRTCMobile. This factory tries to use hardware implementations where available, but falls back to using the injected software codecs. The HardwareVideoEncoderFactory is temporarily also falling back on the software codecs in its default configuration in order to maintain backwards compatibility. Bug: webrtc:7925 Change-Id: I3e8c5ed492ccd160aca968986ad217d7978a951c Reviewed-on: https://webrtc-review.googlesource.com/17480 Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Commit-Queue: Anders Carlsson <andersc@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20647}
This commit is contained in:

committed by
Commit Bot

parent
45bbc8ac19
commit
dc1b9f179a
@ -15,7 +15,6 @@ import static org.webrtc.MediaCodecUtils.INTEL_PREFIX;
|
||||
import static org.webrtc.MediaCodecUtils.NVIDIA_PREFIX;
|
||||
import static org.webrtc.MediaCodecUtils.QCOM_PREFIX;
|
||||
|
||||
import android.media.MediaCodec;
|
||||
import android.media.MediaCodecInfo;
|
||||
import android.media.MediaCodecInfo.CodecCapabilities;
|
||||
import android.media.MediaCodecList;
|
||||
@ -27,6 +26,7 @@ public class HardwareVideoDecoderFactory implements VideoDecoderFactory {
|
||||
private static final String TAG = "HardwareVideoDecoderFactory";
|
||||
|
||||
private final EglBase.Context sharedContext;
|
||||
private final boolean fallbackToSoftware;
|
||||
|
||||
/** Creates a HardwareVideoDecoderFactory that does not use surface textures. */
|
||||
@Deprecated // Not removed yet to avoid breaking callers.
|
||||
@ -39,7 +39,12 @@ public class HardwareVideoDecoderFactory implements VideoDecoderFactory {
|
||||
* shared context. The context may be null. If it is null, then surface support is disabled.
|
||||
*/
|
||||
public HardwareVideoDecoderFactory(EglBase.Context sharedContext) {
|
||||
this(sharedContext, true /* fallbackToSoftware */);
|
||||
}
|
||||
|
||||
HardwareVideoDecoderFactory(EglBase.Context sharedContext, boolean fallbackToSoftware) {
|
||||
this.sharedContext = sharedContext;
|
||||
this.fallbackToSoftware = fallbackToSoftware;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -48,7 +53,15 @@ public class HardwareVideoDecoderFactory implements VideoDecoderFactory {
|
||||
MediaCodecInfo info = findCodecForType(type);
|
||||
|
||||
if (info == null) {
|
||||
return null; // No support for this codec type.
|
||||
// No hardware support for this type.
|
||||
// TODO(andersc): This is for backwards compatibility. Remove when clients have migrated to
|
||||
// new DefaultVideoEncoderFactory.
|
||||
if (fallbackToSoftware) {
|
||||
SoftwareVideoDecoderFactory softwareVideoDecoderFactory = new SoftwareVideoDecoderFactory();
|
||||
return softwareVideoDecoderFactory.createDecoder(codecType);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
CodecCapabilities capabilities = info.getCapabilitiesForType(type.mimeType());
|
||||
|
Reference in New Issue
Block a user