diff --git a/library/src/main/java/com/google/android/exoplayer/DecoderInfo.java b/library/src/main/java/com/google/android/exoplayer/DecoderInfo.java index 440148a556..9d8bf0e43e 100644 --- a/library/src/main/java/com/google/android/exoplayer/DecoderInfo.java +++ b/library/src/main/java/com/google/android/exoplayer/DecoderInfo.java @@ -15,9 +15,17 @@ */ package com.google.android.exoplayer; +import com.google.android.exoplayer.util.Util; + +import android.annotation.TargetApi; +import android.media.MediaCodecInfo; +import android.media.MediaCodecInfo.CodecCapabilities; +import android.media.MediaCodecInfo.CodecProfileLevel; + /** * Contains information about a media decoder. */ +@TargetApi(16) public final class DecoderInfo { /** @@ -36,13 +44,120 @@ public final class DecoderInfo { */ public final boolean adaptive; + private final CodecCapabilities capabilities; + /** * @param name The name of the decoder. - * @param adaptive Whether the decoder is adaptive. */ - /* package */ DecoderInfo(String name, boolean adaptive) { + /* package */ DecoderInfo(String name) { this.name = name; - this.adaptive = adaptive; + this.adaptive = false; + this.capabilities = null; + } + + /** + * @param name The name of the decoder. + * @param capabilities The capabilities of the decoder. + */ + /* package */ DecoderInfo(String name, CodecCapabilities capabilities) { + this.name = name; + this.capabilities = capabilities; + adaptive = isAdaptive(capabilities); + } + + /** + * The profile levels supported by the decoder. + * + * @return The profile levels supported by the decoder. + */ + public CodecProfileLevel[] getProfileLevels() { + return capabilities == null || capabilities.profileLevels == null ? new CodecProfileLevel[0] + : capabilities.profileLevels; + } + + /** + * Whether the decoder supports video with a specified width and height. + *
+ * Must not be called if the device SDK version is less than 21. + * + * @param width Width in pixels. + * @param height Height in pixels. + * @return Whether the decoder supports video with the given width and height. + */ + @TargetApi(21) + public boolean isVideoSizeSupportedV21(int width, int height) { + if (capabilities == null) { + return false; + } + MediaCodecInfo.VideoCapabilities videoCapabilities = capabilities.getVideoCapabilities(); + return videoCapabilities != null && videoCapabilities.isSizeSupported(width, height); + } + + /** + * Whether the decoder supports video with a given width, height and frame rate. + *
+ * Must not be called if the device SDK version is less than 21. + * + * @param width Width in pixels. + * @param height Height in pixels. + * @param frameRate Frame rate in frames per second. + * @return Whether the decoder supports video with the given width, height and frame rate. + */ + @TargetApi(21) + public boolean isVideoSizeAndRateSupportedV21(int width, int height, double frameRate) { + if (capabilities == null) { + return false; + } + MediaCodecInfo.VideoCapabilities videoCapabilities = capabilities.getVideoCapabilities(); + return videoCapabilities != null && videoCapabilities.areSizeAndRateSupported(width, height, + frameRate); + } + + /** + * Whether the decoder supports audio with a given sample rate. + *
+ * Must not be called if the device SDK version is less than 21. + * + * @param sampleRate The sample rate in Hz. + * @return Whether the decoder supports audio with the given sample rate. + */ + @TargetApi(21) + public boolean isAudioSampleRateSupportedV21(int sampleRate) { + if (capabilities == null) { + return false; + } + MediaCodecInfo.AudioCapabilities audioCapabilities = capabilities.getAudioCapabilities(); + return audioCapabilities != null && audioCapabilities.isSampleRateSupported(sampleRate); + } + + /** + * Whether the decoder supports audio with a given channel count. + *
+ * Must not be called if the device SDK version is less than 21.
+ *
+ * @param channelCount The channel count.
+ * @return Whether the decoder supports audio with the given channel count.
+ */
+ @TargetApi(21)
+ public boolean isAudioChannelCountSupportedV21(int channelCount) {
+ if (capabilities == null) {
+ return false;
+ }
+ MediaCodecInfo.AudioCapabilities audioCapabilities = capabilities.getAudioCapabilities();
+ return audioCapabilities != null && audioCapabilities.getMaxInputChannelCount() >= channelCount;
+ }
+
+ private static boolean isAdaptive(CodecCapabilities capabilities) {
+ if (Util.SDK_INT >= 19) {
+ return isAdaptiveV19(capabilities);
+ } else {
+ return false;
+ }
+ }
+
+ @TargetApi(19)
+ private static boolean isAdaptiveV19(CodecCapabilities capabilities) {
+ return capabilities.isFeatureSupported(CodecCapabilities.FEATURE_AdaptivePlayback);
}
}
diff --git a/library/src/main/java/com/google/android/exoplayer/DummyTrackRenderer.java b/library/src/main/java/com/google/android/exoplayer/DummyTrackRenderer.java
index 311764f0ac..7b01c82d28 100644
--- a/library/src/main/java/com/google/android/exoplayer/DummyTrackRenderer.java
+++ b/library/src/main/java/com/google/android/exoplayer/DummyTrackRenderer.java
@@ -21,8 +21,8 @@ package com.google.android.exoplayer;
public final class DummyTrackRenderer extends TrackRenderer {
@Override
- protected boolean handlesTrack(MediaFormat mediaFormat) throws ExoPlaybackException {
- return false;
+ protected int supportsFormat(MediaFormat mediaFormat) throws ExoPlaybackException {
+ return TrackRenderer.FORMAT_UNSUPPORTED_TYPE;
}
@Override
diff --git a/library/src/main/java/com/google/android/exoplayer/ExoPlayerImplInternal.java b/library/src/main/java/com/google/android/exoplayer/ExoPlayerImplInternal.java
index 03c842a59d..546473427e 100644
--- a/library/src/main/java/com/google/android/exoplayer/ExoPlayerImplInternal.java
+++ b/library/src/main/java/com/google/android/exoplayer/ExoPlayerImplInternal.java
@@ -328,7 +328,7 @@ import java.util.concurrent.atomic.AtomicInteger;
MediaFormat adaptiveTrackFormat = null;
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
MediaFormat trackFormat = source.getTrackGroup(groupIndex).getFormat(trackIndex);
- if (renderer.handlesTrack(trackFormat)) {
+ if (renderer.supportsFormat(trackFormat) == TrackRenderer.FORMAT_HANDLED) {
adaptiveTrackIndices[adaptiveTrackIndexCount++] = trackIndex;
if (adaptiveTrackFormat == null) {
adaptiveTrackFormat = trackFormat.copyAsAdaptive("auto");
@@ -345,7 +345,7 @@ import java.util.concurrent.atomic.AtomicInteger;
}
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
MediaFormat trackFormat = source.getTrackGroup(groupIndex).getFormat(trackIndex);
- if (renderer.handlesTrack(trackFormat)) {
+ if (renderer.supportsFormat(trackFormat) == TrackRenderer.FORMAT_HANDLED) {
rendererTrackGroups[rendererTrackCount] = groupIndex;
rendererTrackIndices[rendererTrackCount] = new int[] {trackIndex};
rendererTrackFormats[rendererTrackCount++] = trackFormat;
diff --git a/library/src/main/java/com/google/android/exoplayer/MediaCodecAudioTrackRenderer.java b/library/src/main/java/com/google/android/exoplayer/MediaCodecAudioTrackRenderer.java
index fbef69b660..44ecc38082 100644
--- a/library/src/main/java/com/google/android/exoplayer/MediaCodecAudioTrackRenderer.java
+++ b/library/src/main/java/com/google/android/exoplayer/MediaCodecAudioTrackRenderer.java
@@ -20,6 +20,7 @@ import com.google.android.exoplayer.audio.AudioCapabilities;
import com.google.android.exoplayer.audio.AudioTrack;
import com.google.android.exoplayer.drm.DrmSessionManager;
import com.google.android.exoplayer.util.MimeTypes;
+import com.google.android.exoplayer.util.Util;
import android.annotation.TargetApi;
import android.media.AudioManager;
@@ -179,12 +180,34 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem
}
@Override
- protected boolean handlesTrack(MediaCodecSelector mediaCodecSelector, MediaFormat mediaFormat)
+ protected int supportsFormat(MediaCodecSelector mediaCodecSelector, MediaFormat mediaFormat)
throws DecoderQueryException {
String mimeType = mediaFormat.mimeType;
- return MimeTypes.isAudio(mimeType) && (MimeTypes.AUDIO_UNKNOWN.equals(mimeType)
- || (allowPassthrough(mimeType) && mediaCodecSelector.getPassthroughDecoderName() != null)
- || mediaCodecSelector.getDecoderInfo(mediaFormat, false) != null);
+ if (!MimeTypes.isAudio(mimeType)) {
+ return TrackRenderer.FORMAT_UNSUPPORTED_TYPE;
+ }
+ if (allowPassthrough(mimeType) && mediaCodecSelector.getPassthroughDecoderName() != null) {
+ return TrackRenderer.FORMAT_HANDLED;
+ }
+ // TODO[REFACTOR]: Propagate requiresSecureDecoder to this point. Note that we need to check
+ // that the drm session can make use of a secure decoder, as well as that a secure decoder
+ // exists.
+ DecoderInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mediaFormat.mimeType, false);
+ if (decoderInfo == null) {
+ return TrackRenderer.FORMAT_UNSUPPORTED_TYPE;
+ }
+ if (Util.SDK_INT >= 21) {
+ // Note: We assume support in the case that the sampleRate or channelCount is unknown.
+ if (mediaFormat.sampleRate != MediaFormat.NO_VALUE
+ && !decoderInfo.isAudioSampleRateSupportedV21(mediaFormat.sampleRate)) {
+ return TrackRenderer.FORMAT_EXCEEDS_CAPABILITIES;
+ }
+ if (mediaFormat.channelCount != MediaFormat.NO_VALUE
+ && !decoderInfo.isAudioChannelCountSupportedV21(mediaFormat.channelCount)) {
+ return TrackRenderer.FORMAT_EXCEEDS_CAPABILITIES;
+ }
+ }
+ return TrackRenderer.FORMAT_HANDLED;
}
@Override
@@ -194,7 +217,7 @@ public class MediaCodecAudioTrackRenderer extends MediaCodecTrackRenderer implem
String passthroughDecoderName = mediaCodecSelector.getPassthroughDecoderName();
if (passthroughDecoderName != null) {
passthroughEnabled = true;
- return new DecoderInfo(passthroughDecoderName, false);
+ return new DecoderInfo(passthroughDecoderName);
}
}
passthroughEnabled = false;
diff --git a/library/src/main/java/com/google/android/exoplayer/MediaCodecSelector.java b/library/src/main/java/com/google/android/exoplayer/MediaCodecSelector.java
index 40378b40fd..e1f073c97e 100644
--- a/library/src/main/java/com/google/android/exoplayer/MediaCodecSelector.java
+++ b/library/src/main/java/com/google/android/exoplayer/MediaCodecSelector.java
@@ -27,7 +27,7 @@ public interface MediaCodecSelector {
/**
* Default implementation of {@link MediaCodecSelector}.
*/
- public static final MediaCodecSelector DEFAULT = new MediaCodecSelector() {
+ MediaCodecSelector DEFAULT = new MediaCodecSelector() {
/**
* The name for the raw (passthrough) decoder OMX component.
@@ -35,9 +35,9 @@ public interface MediaCodecSelector {
private static final String RAW_DECODER_NAME = "OMX.google.raw.decoder";
@Override
- public DecoderInfo getDecoderInfo(MediaFormat format, boolean requiresSecureDecoder)
+ public DecoderInfo getDecoderInfo(String mimeType, boolean requiresSecureDecoder)
throws DecoderQueryException {
- return MediaCodecUtil.getDecoderInfo(format.mimeType, requiresSecureDecoder);
+ return MediaCodecUtil.getDecoderInfo(mimeType, requiresSecureDecoder);
}
@Override
@@ -49,15 +49,15 @@ public interface MediaCodecSelector {
};
/**
- * Selects a decoder to instantiate for a given format.
+ * Selects a decoder to instantiate for a given mime type.
*
- * @param format The format for which a decoder is required.
+ * @param mimeType The mime type for which a decoder is required.
* @param requiresSecureDecoder Whether a secure decoder is required.
* @return A {@link DecoderInfo} describing the decoder to instantiate, or null if no suitable
* decoder exists.
* @throws DecoderQueryException Thrown if there was an error querying decoders.
*/
- DecoderInfo getDecoderInfo(MediaFormat format, boolean requiresSecureDecoder)
+ DecoderInfo getDecoderInfo(String mimeType, boolean requiresSecureDecoder)
throws DecoderQueryException;
/**
diff --git a/library/src/main/java/com/google/android/exoplayer/MediaCodecTrackRenderer.java b/library/src/main/java/com/google/android/exoplayer/MediaCodecTrackRenderer.java
index 34279f1493..25aa68d309 100644
--- a/library/src/main/java/com/google/android/exoplayer/MediaCodecTrackRenderer.java
+++ b/library/src/main/java/com/google/android/exoplayer/MediaCodecTrackRenderer.java
@@ -262,23 +262,40 @@ public abstract class MediaCodecTrackRenderer extends SampleSourceTrackRenderer
}
@Override
- protected final boolean handlesTrack(MediaFormat mediaFormat) throws ExoPlaybackException {
+ protected final int supportsAdaptive(String mimeType) throws ExoPlaybackException {
+ if (mimeType == null) {
+ return TrackRenderer.ADAPTIVE_NOT_SEAMLESS;
+ }
try {
- return handlesTrack(mediaCodecSelector, mediaFormat);
+ // TODO[REFACTOR]: Propagate requiresSecureDecoder to this point.
+ DecoderInfo decoderInfo = mediaCodecSelector.getDecoderInfo(mimeType, false);
+ return decoderInfo != null && decoderInfo.adaptive ? TrackRenderer.ADAPTIVE_SEAMLESS
+ : TrackRenderer.ADAPTIVE_NOT_SEAMLESS;
+ } catch (DecoderQueryException e) {
+ throw new ExoPlaybackException(e);
+ }
+ }
+
+ @Override
+ protected final int supportsFormat(MediaFormat mediaFormat) throws ExoPlaybackException {
+ try {
+ return supportsFormat(mediaCodecSelector, mediaFormat);
} catch (DecoderQueryException e) {
throw new ExoPlaybackException(e);
}
}
/**
- * Returns whether this renderer is capable of handling the provided track.
+ * Returns the extent to which the renderer is capable of rendering a given format.
*
* @param mediaCodecSelector The decoder selector.
- * @param mediaFormat The format of the track.
- * @return True if the renderer can handle the track, false otherwise.
- * @throws DecoderQueryException Thrown if there was an error querying decoders.
+ * @param mediaFormat The format.
+ * @return The extent to which the renderer is capable of rendering the given format. One of
+ * {@link #FORMAT_HANDLED}, {@link #FORMAT_EXCEEDS_CAPABILITIES} and
+ * {@link #FORMAT_UNSUPPORTED_TYPE}.
+ * @throws DecoderQueryException If there was an error querying decoders.
*/
- protected abstract boolean handlesTrack(MediaCodecSelector mediaCodecSelector,
+ protected abstract int supportsFormat(MediaCodecSelector mediaCodecSelector,
MediaFormat mediaFormat) throws DecoderQueryException;
/**
@@ -293,7 +310,7 @@ public abstract class MediaCodecTrackRenderer extends SampleSourceTrackRenderer
*/
protected DecoderInfo getDecoderInfo(MediaCodecSelector mediaCodecSelector,
MediaFormat mediaFormat, boolean requiresSecureDecoder) throws DecoderQueryException {
- return mediaCodecSelector.getDecoderInfo(format, requiresSecureDecoder);
+ return mediaCodecSelector.getDecoderInfo(format.mimeType, requiresSecureDecoder);
}
/**
diff --git a/library/src/main/java/com/google/android/exoplayer/MediaCodecUtil.java b/library/src/main/java/com/google/android/exoplayer/MediaCodecUtil.java
index 69efa88c22..8ad988447b 100644
--- a/library/src/main/java/com/google/android/exoplayer/MediaCodecUtil.java
+++ b/library/src/main/java/com/google/android/exoplayer/MediaCodecUtil.java
@@ -15,7 +15,6 @@
*/
package com.google.android.exoplayer;
-import com.google.android.exoplayer.util.Assertions;
import com.google.android.exoplayer.util.MimeTypes;
import com.google.android.exoplayer.util.Util;
@@ -26,7 +25,6 @@ import android.media.MediaCodecInfo.CodecProfileLevel;
import android.media.MediaCodecList;
import android.text.TextUtils;
import android.util.Log;
-import android.util.Pair;
import java.util.HashMap;
@@ -52,29 +50,12 @@ public final class MediaCodecUtil {
private static final String TAG = "MediaCodecUtil";
- private static final HashMap
* Calling this method may speed up subsequent calls to {@link #getDecoderInfo(String, boolean)}.
*
@@ -82,9 +63,9 @@ public final class MediaCodecUtil {
* @param secure Whether the decoder is required to support secure decryption. Always pass false
* unless secure decryption really is required.
*/
- public static synchronized void warmCodec(String mimeType, boolean secure) {
+ public static synchronized void warmDecoderInfoCache(String mimeType, boolean secure) {
try {
- getMediaCodecInfo(mimeType, secure);
+ getDecoderInfo(mimeType, secure);
} catch (DecoderQueryException e) {
// Codec warming is best effort, so we can swallow the exception.
Log.e(TAG, "Codec warming failed", e);
@@ -92,42 +73,41 @@ public final class MediaCodecUtil {
}
/**
- * Returns the name of the best decoder and its capabilities for the given mimeType.
+ * Returns a {@link DecoderInfo} describing the most suitable decoder for a given mime type.
*
* @param mimeType The mime type.
* @param secure Whether the decoder is required to support secure decryption. Always pass false
* unless secure decryption really is required.
- * @return The name of the best decoder and its capabilities for the given mimeType, or null if
- * no decoder exists.
+ * @return Information about the decoder, or null if no suitable decoder exists.
*/
- public static synchronized Pair
- * Must not be called if the device SDK version is less than 21.
+ * Whether the default H264 decoder supports the specified profile at the specified level.
*
- * @param mimeType The mime type.
- * @param secure Whether the decoder is required to support secure decryption. Always pass false
- * unless secure decryption really is required.
- * @param width Width in pixels.
- * @param height Height in pixels.
- * @return Whether the decoder advertises support of the given size.
- */
- @TargetApi(21)
- public static boolean isSizeSupportedV21(String mimeType, boolean secure, int width,
- int height) throws DecoderQueryException {
- Assertions.checkState(Util.SDK_INT >= 21);
- MediaCodecInfo.VideoCapabilities videoCapabilities = getVideoCapabilitiesV21(mimeType, secure);
- return videoCapabilities != null && videoCapabilities.isSizeSupported(width, height);
- }
-
- /**
- * Tests whether the device advertises it can decode video of a given type at a specified
- * width, height, and frame rate.
- *
- * Must not be called if the device SDK version is less than 21.
- *
- * @param mimeType The mime type.
- * @param secure Whether the decoder is required to support secure decryption. Always pass false
- * unless secure decryption really is required.
- * @param width Width in pixels.
- * @param height Height in pixels.
- * @param frameRate Frame rate in frames per second.
- * @return Whether the decoder advertises support of the given size and frame rate.
- */
- @TargetApi(21)
- public static boolean isSizeAndRateSupportedV21(String mimeType, boolean secure,
- int width, int height, double frameRate) throws DecoderQueryException {
- Assertions.checkState(Util.SDK_INT >= 21);
- MediaCodecInfo.VideoCapabilities videoCapabilities = getVideoCapabilitiesV21(mimeType, secure);
- return videoCapabilities != null
- && videoCapabilities.areSizeAndRateSupported(width, height, frameRate);
- }
-
- /**
- * @param profile An AVC profile constant from {@link CodecProfileLevel}.
- * @param level An AVC profile level from {@link CodecProfileLevel}.
+ * @param profile A profile constant from {@link CodecProfileLevel}.
+ * @param level A profile level from {@link CodecProfileLevel}.
* @return Whether the specified profile is supported at the specified level.
*/
public static boolean isH264ProfileSupported(int profile, int level)
throws DecoderQueryException {
- Pair
+ * Example: The {@link TrackRenderer} is capable of rendering H264 and the format's mimeType is
+ * {@link MimeTypes#VIDEO_H264}, but the format's resolution exceeds the maximum limit supported
+ * by the underlying H264 decoder.
+ */
+ public static final int FORMAT_EXCEEDS_CAPABILITIES = 1;
+ /**
+ * The {@link TrackRenderer} is not capable of rendering the format, or any other format with the
+ * same mimeType.
+ *
+ * Example: The {@link TrackRenderer} is only capable of rendering video and the track has an
+ * audio mimeType.
+ */
+ public static final int FORMAT_UNSUPPORTED_TYPE = 2;
+
/**
* The renderer is idle.
*/
@@ -75,13 +112,31 @@ public abstract class TrackRenderer implements ExoPlayerComponent {
}
/**
- * Returns whether this renderer is capable of handling the provided track.
+ * Returns the extent to which the renderer is capable of consuming from a {@link TrackStream}
+ * that adapts between multiple supported formats of a given mimeType, or of differing mimeTypes
+ * if {@code mimeType == null} is passed.
*
- * @param mediaFormat The format of the track.
- * @return True if the renderer can handle the track, false otherwise.
+ * @param mimeType The mimeType, or null to query the extent to which the renderer is capable of
+ * adapting between formats with different mimeTypes.
+ * @return The extent to which the renderer supports the adaptation. One of
+ * {@link #ADAPTIVE_SEAMLESS}, {@link #ADAPTIVE_NOT_SEAMLESS} and
+ * {@link #ADAPTIVE_NOT_SUPPORTED}.
* @throws ExoPlaybackException If an error occurs.
*/
- protected abstract boolean handlesTrack(MediaFormat mediaFormat) throws ExoPlaybackException;
+ protected int supportsAdaptive(String mimeType) throws ExoPlaybackException {
+ return ADAPTIVE_NOT_SUPPORTED;
+ }
+
+ /**
+ * Returns the extent to which the renderer is capable of rendering a given format.
+ *
+ * @param mediaFormat The format.
+ * @return The extent to which the renderer is capable of rendering the given format. One of
+ * {@link #FORMAT_HANDLED}, {@link #FORMAT_EXCEEDS_CAPABILITIES} and
+ * {@link #FORMAT_UNSUPPORTED_TYPE}.
+ * @throws ExoPlaybackException If an error occurs.
+ */
+ protected abstract int supportsFormat(MediaFormat mediaFormat) throws ExoPlaybackException;
/**
* Enable the renderer to consume from the specified {@link TrackStream}.
diff --git a/library/src/main/java/com/google/android/exoplayer/chunk/VideoFormatSelectorUtil.java b/library/src/main/java/com/google/android/exoplayer/chunk/VideoFormatSelectorUtil.java
deleted file mode 100644
index 84717b9c79..0000000000
--- a/library/src/main/java/com/google/android/exoplayer/chunk/VideoFormatSelectorUtil.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.google.android.exoplayer.chunk;
-
-import com.google.android.exoplayer.MediaCodecUtil;
-import com.google.android.exoplayer.MediaCodecUtil.DecoderQueryException;
-import com.google.android.exoplayer.util.MimeTypes;
-import com.google.android.exoplayer.util.Util;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.graphics.Point;
-import android.view.Display;
-import android.view.WindowManager;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Selects from possible video formats.
- */
-public final class VideoFormatSelectorUtil {
-
- /**
- * If a dimension (i.e. width or height) of a video is greater or equal to this fraction of the
- * corresponding viewport dimension, then the video is considered as filling the viewport (in that
- * dimension).
- */
- private static final float FRACTION_TO_CONSIDER_FULLSCREEN = 0.98f;
-
- /**
- * Chooses a suitable subset from a number of video formats, to be rendered on the device's
- * default display.
- *
- * @param context A context.
- * @param formatWrappers Wrapped formats from which to select.
- * @param allowedContainerMimeTypes An array of allowed container mime types. Null allows all
- * mime types.
- * @param filterHdFormats True to filter HD formats. False otherwise.
- * @return An array holding the indices of the selected formats.
- * @throws DecoderQueryException Thrown if there was an error querying decoders.
- */
- public static int[] selectVideoFormatsForDefaultDisplay(Context context,
- List extends FormatWrapper> formatWrappers, String[] allowedContainerMimeTypes,
- boolean filterHdFormats) throws DecoderQueryException {
- Point viewportSize = getViewportSize(context);
- return selectVideoFormats(formatWrappers, allowedContainerMimeTypes, filterHdFormats, true,
- viewportSize.x, viewportSize.y);
- }
-
- /**
- * Chooses a suitable subset from a number of video formats.
- *
- * A format is filtered (i.e. not selected) if:
- *
- *
- *
- * @param formatWrappers Wrapped formats from which to select.
- * @param allowedContainerMimeTypes An array of allowed container mime types. Null allows all
- * mime types.
- * @param filterHdFormats True to filter HD formats. False otherwise.
- * @param orientationMayChange True if the video's orientation may change with respect to the
- * viewport during playback.
- * @param viewportWidth The width in pixels of the viewport within which the video will be
- * displayed. If the viewport size may change, this should be set to the maximum possible
- * width. -1 if selection should not be constrained by a viewport.
- * @param viewportHeight The height in pixels of the viewport within which the video will be
- * displayed. If the viewport size may change, this should be set to the maximum possible
- * height. -1 if selection should not be constrained by a viewport.
- * @return An array holding the indices of the selected formats.
- * @throws DecoderQueryException
- */
- public static int[] selectVideoFormats(List extends FormatWrapper> formatWrappers,
- String[] allowedContainerMimeTypes, boolean filterHdFormats, boolean orientationMayChange,
- int viewportWidth, int viewportHeight) throws DecoderQueryException {
- int maxVideoPixelsToRetain = Integer.MAX_VALUE;
- ArrayList