Bug 1403849 - p1: introduce IPC method to query tunneled playback support. r=esawin
authorJohn Lin <jolin@mozilla.com>
Fri, 29 Sep 2017 18:01:15 +0800
changeset 384904 466da7f626efe5434b06a16c85498519979a4418
parent 384903 174a7ea87cc552a5a8d4862033b96b9aba103641
child 384905 a7328d336d7249582112bbd6bbffad43c910fdfe
push id95880
push userarchaeopteryx@coole-files.de
push dateSat, 07 Oct 2017 08:58:44 +0000
treeherdermozilla-inbound@156942799371 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersesawin
bugs1403849
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1403849 - p1: introduce IPC method to query tunneled playback support. r=esawin MozReview-Commit-ID: 3wiKC46ZjvY
mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/ICodec.aidl
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/AsyncCodec.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/Codec.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/LollipopAsyncCodec.java
--- 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
@@ -10,16 +10,17 @@ import org.mozilla.gecko.gfx.GeckoSurfac
 import org.mozilla.gecko.media.FormatParam;
 import org.mozilla.gecko.media.ICodecCallbacks;
 import org.mozilla.gecko.media.Sample;
 
 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();
     void release();
 
     Sample dequeueInput(int size);
     oneway void queueInput(in Sample sample);
 
--- 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
@@ -21,16 +21,17 @@ public interface AsyncCodec {
         void onOutputBufferAvailable(AsyncCodec codec, int index, BufferInfo info);
         void onError(AsyncCodec codec, int error);
         void onOutputFormatChanged(AsyncCodec codec, MediaFormat format);
     }
 
     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();
     // Must be called after flush().
     public abstract void resumeReceivingInputs();
     public abstract void release();
     public abstract ByteBuffer getInputBuffer(int index);
     public abstract ByteBuffer getOutputBuffer(int index);
--- 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
@@ -343,18 +343,19 @@ import org.mozilla.gecko.gfx.GeckoSurfac
         }
     }
 
     private volatile ICodecCallbacks mCallbacks;
     private AsyncCodec mCodec;
     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;
         callbacks.asBinder().linkToDeath(this, 0);
     }
 
     // IBinder.DeathRecipient
     @Override
@@ -398,16 +399,19 @@ import org.mozilla.gecko.gfx.GeckoSurfac
                 Log.w(LOGTAG, "unable to configure " + name + ". Try next.");
                 continue;
             }
             mCodec = codec;
             mInputProcessor = new InputProcessor();
             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;
         }
 
         return false;
     }
 
     private List<String> findMatchingCodecNames(final String mimeType, final boolean isEncoder) {
@@ -469,16 +473,21 @@ import org.mozilla.gecko.gfx.GeckoSurfac
     }
 
     @Override
     public synchronized boolean isAdaptivePlaybackSupported() {
         return mIsAdaptivePlaybackSupported;
     }
 
     @Override
+    public synchronized boolean isTunneledPlaybackSupported() {
+        return mIsTunneledPlaybackSupported;
+    }
+
+    @Override
     public synchronized void start() throws RemoteException {
         if (DEBUG) { Log.d(LOGTAG, "start " + this); }
         mInputProcessor.start();
         mOutputProcessor.start();
         try {
             mCodec.start();
         } catch (Exception e) {
             reportError(Error.FATAL, e);
--- 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
@@ -2,16 +2,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 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;
 import android.os.HandlerThread;
 import android.os.Looper;
 import android.os.Message;
 import android.os.Bundle;
 import android.util.Log;
@@ -303,16 +304,24 @@ final class JellyBeanAsyncCodec implemen
         mCodec.configure(format, surface, crypto, flags);
     }
 
     @Override
     public boolean isAdaptivePlaybackSupported(String mimeType) {
         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().");
         }
     }
 
     @Override
     public void start() {
--- 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
@@ -2,16 +2,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 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;
 import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
 import android.support.annotation.NonNull;
 import android.util.Log;
@@ -147,16 +148,23 @@ import java.nio.ByteBuffer;
     }
 
     @Override
     public boolean isAdaptivePlaybackSupported(final String mimeType) {
         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();
     }
 
     @Override
     public void stop() {
         mCodec.stop();
     }