Chromium Code Reviews| Index: media/base/android/java/src/org/chromium/media/MediaCodecBridge.java |
| diff --git a/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java b/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java |
| index 23167ac726dcc526e1057135c6b418a5949e5e4d..b9ec28c162df991a33ce4618535b7306706374cd 100644 |
| --- a/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java |
| +++ b/media/base/android/java/src/org/chromium/media/MediaCodecBridge.java |
| @@ -455,9 +455,25 @@ class MediaCodecBridge { |
| private boolean configureVideo(MediaFormat format, Surface surface, MediaCrypto crypto, |
| int flags, boolean allowAdaptivePlayback) { |
| try { |
| - if (mAdaptivePlaybackSupported && allowAdaptivePlayback) { |
| - format.setInteger(MediaFormat.KEY_MAX_WIDTH, MAX_ADAPTIVE_PLAYBACK_WIDTH); |
| - format.setInteger(MediaFormat.KEY_MAX_HEIGHT, MAX_ADAPTIVE_PLAYBACK_HEIGHT); |
| + // If adaptive playback is turned off by request, then treat it as |
| + // not supported. Note that configureVideo is only called once |
| + // during creation, else this would prevent re-enabling adaptive |
| + // playback later. |
| + if (!allowAdaptivePlayback) mAdaptivePlaybackSupported = false; |
| + |
| + if (mAdaptivePlaybackSupported) { |
| + // The max size is a hint to the codec, and causes it to |
| + // allocate more memory up front. It still supports higher |
| + // resolutions if they arrive. So, we try to ask only for |
| + // the initial size now, if it's known. |
| + final int max_width = format.containsKey(MediaFormat.KEY_WIDTH) |
|
Tima Vaisburd
2016/04/07 18:50:01
I think KEY_WITH and KEY_HEIGHT are mandatory keys
liberato (no reviews please)
2016/04/07 20:46:29
Done.
|
| + ? format.getInteger(MediaFormat.KEY_WIDTH) |
| + : MAX_ADAPTIVE_PLAYBACK_WIDTH; |
| + final int max_height = format.containsKey(MediaFormat.KEY_HEIGHT) |
| + ? format.getInteger(MediaFormat.KEY_HEIGHT) |
| + : MAX_ADAPTIVE_PLAYBACK_HEIGHT; |
| + format.setInteger(MediaFormat.KEY_MAX_WIDTH, max_width); |
| + format.setInteger(MediaFormat.KEY_MAX_HEIGHT, max_height); |
| } |
| mMediaCodec.configure(format, surface, crypto, flags); |
| return true; |
| @@ -496,8 +512,9 @@ class MediaCodecBridge { |
| @CalledByNative |
| private boolean isAdaptivePlaybackSupported(int width, int height) { |
| - if (!mAdaptivePlaybackSupported) return false; |
| - return width <= MAX_ADAPTIVE_PLAYBACK_WIDTH && height <= MAX_ADAPTIVE_PLAYBACK_HEIGHT; |
| + // If media codec has adaptive playback supported, then the max sizes |
| + // used during creation are only hints. |
| + return mAdaptivePlaybackSupported; |
| } |
| @CalledByNative |