diff --git a/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/ICodec.aidl b/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/ICodec.aidl index 29854c2f4edc..d48eb47d0a57 100644 --- a/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/ICodec.aidl +++ b/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/ICodec.aidl @@ -15,6 +15,7 @@ interface ICodec { void setCallbacks(in ICodecCallbacks callbacks); boolean configure(in FormatParam format, in GeckoSurface surface, in int flags, in String drmStubId); boolean isAdaptivePlaybackSupported(); + boolean isTunneledPlaybackSupported(); void start(); void stop(); void flush(); diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/AsyncCodec.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/AsyncCodec.java index c7fa70569e05..5eb2a293feb0 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/AsyncCodec.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/AsyncCodec.java @@ -26,6 +26,7 @@ public interface AsyncCodec { public abstract void setCallbacks(Callbacks callbacks, Handler handler); public abstract void configure(MediaFormat format, Surface surface, MediaCrypto crypto, int flags); public abstract boolean isAdaptivePlaybackSupported(String mimeType); + public abstract boolean isTunneledPlaybackSupported(final String mimeType); public abstract void start(); public abstract void stop(); public abstract void flush(); diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Codec.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Codec.java index 0ab2911ce8cb..92b1164f7935 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Codec.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Codec.java @@ -348,8 +348,9 @@ import org.mozilla.gecko.gfx.GeckoSurface; private InputProcessor mInputProcessor; private OutputProcessor mOutputProcessor; private SamplePool mSamplePool; - // Value will be updated after configure called. + // Values will be updated after configure called. private volatile boolean mIsAdaptivePlaybackSupported = false; + private boolean mIsTunneledPlaybackSupported = false; public synchronized void setCallbacks(ICodecCallbacks callbacks) throws RemoteException { mCallbacks = callbacks; @@ -403,6 +404,9 @@ import org.mozilla.gecko.gfx.GeckoSurface; final boolean renderToSurface = surface != null; mOutputProcessor = new OutputProcessor(renderToSurface); mSamplePool = new SamplePool(name, renderToSurface); + if (renderToSurface) { + mIsTunneledPlaybackSupported = mCodec.isTunneledPlaybackSupported(mime); + } if (DEBUG) { Log.d(LOGTAG, codec.toString() + " created. Render to surface?" + renderToSurface); } return true; } @@ -473,6 +477,11 @@ import org.mozilla.gecko.gfx.GeckoSurface; return mIsAdaptivePlaybackSupported; } + @Override + public synchronized boolean isTunneledPlaybackSupported() { + return mIsTunneledPlaybackSupported; + } + @Override public synchronized void start() throws RemoteException { if (DEBUG) { Log.d(LOGTAG, "start " + this); } diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java index 67492db813c5..5ab2a6ef5490 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java @@ -7,6 +7,7 @@ package org.mozilla.gecko.media; import org.mozilla.gecko.util.HardwareCodecCapabilityUtils; import android.media.MediaCodec; +import android.media.MediaCodecInfo.CodecCapabilities; import android.media.MediaCrypto; import android.media.MediaFormat; import android.os.Handler; @@ -308,6 +309,14 @@ final class JellyBeanAsyncCodec implements AsyncCodec { return HardwareCodecCapabilityUtils.checkSupportsAdaptivePlayback(mCodec, mimeType); } + @Override + public boolean isTunneledPlaybackSupported(final String mimeType) { + return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP + && mCodec.getCodecInfo() + .getCapabilitiesForType(mimeType) + .isFeatureSupported(CodecCapabilities.FEATURE_TunneledPlayback); + } + private void assertCallbacks() { if (mCallbackSender == null) { throw new IllegalStateException(LOGTAG + ": callback must be supplied with setCallbacks()."); diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/LollipopAsyncCodec.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/LollipopAsyncCodec.java index b57d70b8c87c..519e5adb2fb6 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/LollipopAsyncCodec.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/LollipopAsyncCodec.java @@ -7,6 +7,7 @@ package org.mozilla.gecko.media; import org.mozilla.gecko.util.HardwareCodecCapabilityUtils; import android.media.MediaCodec; +import android.media.MediaCodecInfo.CodecCapabilities; import android.media.MediaCrypto; import android.media.MediaFormat; import android.os.Bundle; @@ -151,6 +152,13 @@ import java.nio.ByteBuffer; return HardwareCodecCapabilityUtils.checkSupportsAdaptivePlayback(mCodec, mimeType); } + @Override + public boolean isTunneledPlaybackSupported(final String mimeType) { + return mCodec.getCodecInfo() + .getCapabilitiesForType(mimeType) + .isFeatureSupported(CodecCapabilities.FEATURE_TunneledPlayback); + } + @Override public void start() { mCodec.start();