-
-
Save JamesWCCheng/2a1ebf3c13c6d2ad4b26fe2d7b2373b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/mobile/android/base/java/org/mozilla/gecko/media/Codec.java b/mobile/android/base/java/org/mozilla/gecko/media/Codec.java | |
index 0f53c19..5e42968 100644 | |
--- a/mobile/android/base/java/org/mozilla/gecko/media/Codec.java | |
+++ b/mobile/android/base/java/org/mozilla/gecko/media/Codec.java | |
@@ -203,6 +203,8 @@ import java.util.concurrent.ConcurrentLinkedQueue; | |
private volatile boolean mFlushing = false; | |
private SamplePool mSamplePool; | |
private Queue<Sample> mSentOutputs = new ConcurrentLinkedQueue<>(); | |
+ // Value will be updated after configure called. | |
+ private volatile boolean mIsAdaptivePlaybackSupported = false; | |
public synchronized void setCallbacks(ICodecCallbacks callbacks) throws RemoteException { | |
mCallbacks = callbacks; | |
@@ -254,6 +256,17 @@ import java.util.concurrent.ConcurrentLinkedQueue; | |
} | |
codec.setCallbacks(new Callbacks(mCallbacks), null); | |
+ mIsAdaptivePlaybackSupported | |
+ // Video decoder should config with adaptive playback capability. | |
+ if (surface != null) { | |
+ mIsAdaptivePlaybackSupported | |
+ = codec.isAdaptivePlaybackSupported(); | |
+ if (mIsAdaptivePlaybackSupported) { | |
+ // TODO: may need to find a way to not use hard code to decide the max w/h. | |
+ fmt.setInteger(MediaFormat.KEY_MAX_WIDTH, 1920); | |
+ fmt.setInteger(MediaFormat.KEY_MAX_HEIGHT, 1080); | |
+ } | |
+ } | |
codec.configure(fmt, surface, crypto, flags); | |
mCodec = codec; | |
mInputProcessor = new InputProcessor(); | |
@@ -269,13 +282,7 @@ import java.util.concurrent.ConcurrentLinkedQueue; | |
@Override | |
public synchronized boolean isAdaptivePlaybackSupported() { | |
- if (DEBUG) Log.d(LOGTAG, "isAdaptivePlaybackSupported " + this); | |
- try { | |
- return mCodec.isAdaptivePlaybackSupported(); | |
- } catch (Exception e) { | |
- Log.e(LOGTAG, "failed to check isAdaptivePlaybackSupported", e); | |
- return false; | |
- } | |
+ return mIsAdaptivePlaybackSupported; | |
} | |
private void releaseCodec() { | |
diff --git a/mobile/android/base/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java b/mobile/android/base/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java | |
index 2500afb..a358b0b 100644 | |
--- a/mobile/android/base/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java | |
+++ b/mobile/android/base/java/org/mozilla/gecko/media/JellyBeanAsyncCodec.java | |
@@ -249,6 +249,7 @@ final class JellyBeanAsyncCodec implements AsyncCodec { | |
} | |
private MediaCodec mCodec; | |
+ private MediaFormat mFormat; | |
private ByteBuffer[] mInputBuffers; | |
private ByteBuffer[] mOutputBuffers; | |
private AsyncCodec.Callbacks mCallbacks; | |
@@ -257,8 +258,6 @@ final class JellyBeanAsyncCodec implements AsyncCodec { | |
private BufferPoller mBufferPoller; | |
private volatile boolean mInputEnded; | |
private volatile boolean mOutputEnded; | |
- // Value will be updated after configure called. | |
- private volatile boolean mIsAdaptivePlaybackSupported = false; | |
// Must be called on a thread with looper. | |
/* package */ JellyBeanAsyncCodec(String name) throws IOException { | |
@@ -300,22 +299,15 @@ final class JellyBeanAsyncCodec implements AsyncCodec { | |
public void configure(MediaFormat format, Surface surface, MediaCrypto crypto, int flags) { | |
assertCallbacks(); | |
- // Video decoder should config with adaptive playback capability. | |
- if (surface != null) { | |
- mIsAdaptivePlaybackSupported = | |
- HardwareCodecCapabilityUtils.checkSupportsAdaptivePlayback( | |
- mCodec, format.getString(MediaFormat.KEY_MIME)); | |
- if (mIsAdaptivePlaybackSupported) { | |
- // TODO: may need to find a way to not use hard code to decide the max w/h. | |
- format.setInteger(MediaFormat.KEY_MAX_WIDTH, 1920); | |
- format.setInteger(MediaFormat.KEY_MAX_HEIGHT, 1080); | |
- } | |
- } | |
+ mFormat = format; // Need mFormat to know the mimetype! But isAdaptivePlaybackSupported will be called before configure.... | |
mCodec.configure(format, surface, crypto, flags); | |
} | |
@Override | |
public boolean isAdaptivePlaybackSupported() { | |
+ // mFormat will be null since configure is not called at this stage. | |
+ HardwareCodecCapabilityUtils.checkSupportsAdaptivePlayback( | |
+ mCodec, mFormat.getString(MediaFormat.KEY_MIME)); | |
if (DEBUG) Log.d(LOGTAG, "isAdaptivePlaybackSupported=" + mIsAdaptivePlaybackSupported); | |
return mIsAdaptivePlaybackSupported; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment