diff --git a/extensions/flac/src/androidTest/assets/bear.flac.0.dump b/extensions/flac/src/androidTest/assets/bear.flac.0.dump
index 2a17cbdea6..21a4bcb13b 100644
--- a/extensions/flac/src/androidTest/assets/bear.flac.0.dump
+++ b/extensions/flac/src/androidTest/assets/bear.flac.0.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = 2
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/extensions/flac/src/androidTest/assets/bear.flac.1.dump b/extensions/flac/src/androidTest/assets/bear.flac.1.dump
index 412e4a1b8f..b7a7d3ffb9 100644
--- a/extensions/flac/src/androidTest/assets/bear.flac.1.dump
+++ b/extensions/flac/src/androidTest/assets/bear.flac.1.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = 2
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/extensions/flac/src/androidTest/assets/bear.flac.2.dump b/extensions/flac/src/androidTest/assets/bear.flac.2.dump
index 42ebb125d1..44e2eefcb0 100644
--- a/extensions/flac/src/androidTest/assets/bear.flac.2.dump
+++ b/extensions/flac/src/androidTest/assets/bear.flac.2.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = 2
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/extensions/flac/src/androidTest/assets/bear.flac.3.dump b/extensions/flac/src/androidTest/assets/bear.flac.3.dump
index 958cb0d418..41920528c1 100644
--- a/extensions/flac/src/androidTest/assets/bear.flac.3.dump
+++ b/extensions/flac/src/androidTest/assets/bear.flac.3.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = 2
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/BaseRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/BaseRenderer.java
index 8ee9a13c55..cb917b9b79 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/BaseRenderer.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/BaseRenderer.java
@@ -35,6 +35,7 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
private int index;
private int state;
private SampleStream stream;
+ private Format[] streamFormats;
private long streamOffsetUs;
private boolean readEndOfStream;
private boolean streamIsFinal;
@@ -98,6 +99,7 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
Assertions.checkState(!streamIsFinal);
this.stream = stream;
readEndOfStream = false;
+ streamFormats = formats;
streamOffsetUs = offsetUs;
onStreamChanged(formats, offsetUs);
}
@@ -146,6 +148,7 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
Assertions.checkState(state == STATE_ENABLED);
state = STATE_DISABLED;
stream = null;
+ streamFormats = null;
streamIsFinal = false;
onDisabled();
}
@@ -246,6 +249,11 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
// Methods to be called by subclasses.
+ /** Returns the formats of the currently enabled stream. */
+ protected final Format[] getStreamFormats() {
+ return streamFormats;
+ }
+
/**
* Returns the configuration set when the renderer was most recently enabled.
*/
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/Format.java b/library/core/src/main/java/com/google/android/exoplayer2/Format.java
index c830a246ae..2c4c75a630 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/Format.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/Format.java
@@ -15,9 +15,6 @@
*/
package com.google.android.exoplayer2;
-import android.annotation.SuppressLint;
-import android.annotation.TargetApi;
-import android.media.MediaFormat;
import android.os.Parcel;
import android.os.Parcelable;
import com.google.android.exoplayer2.drm.DrmInitData;
@@ -25,7 +22,6 @@ import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.ColorInfo;
-import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -109,14 +105,10 @@ public final class Format implements Parcelable {
public final float frameRate;
/**
* The clockwise rotation that should be applied to the video for it to be rendered in the correct
- * orientation, or {@link #NO_VALUE} if unknown or not applicable. Only 0, 90, 180 and 270 are
- * supported.
+ * orientation, or 0 if unknown or not applicable. Only 0, 90, 180 and 270 are supported.
*/
public final int rotationDegrees;
- /**
- * The width to height ratio of pixels in the video, or {@link #NO_VALUE} if unknown or not
- * applicable.
- */
+ /** The width to height ratio of pixels in the video, or 1.0 if unknown or not applicable. */
public final float pixelWidthHeightRatio;
/**
* The stereo layout for 360/3D/VR video, or {@link #NO_VALUE} if not applicable. Valid stereo
@@ -153,11 +145,12 @@ public final class Format implements Parcelable {
@C.PcmEncoding
public final int pcmEncoding;
/**
- * The number of samples to trim from the start of the decoded audio stream.
+ * The number of samples to trim from the start of the decoded audio stream, or 0 if not
+ * applicable.
*/
public final int encoderDelay;
/**
- * The number of samples to trim from the end of the decoded audio stream.
+ * The number of samples to trim from the end of the decoded audio stream, or 0 if not applicable.
*/
public final int encoderPadding;
@@ -402,16 +395,17 @@ public final class Format implements Parcelable {
this.width = width;
this.height = height;
this.frameRate = frameRate;
- this.rotationDegrees = rotationDegrees;
- this.pixelWidthHeightRatio = pixelWidthHeightRatio;
+ this.rotationDegrees = rotationDegrees == Format.NO_VALUE ? 0 : rotationDegrees;
+ this.pixelWidthHeightRatio =
+ pixelWidthHeightRatio == Format.NO_VALUE ? 1 : pixelWidthHeightRatio;
this.projectionData = projectionData;
this.stereoMode = stereoMode;
this.colorInfo = colorInfo;
this.channelCount = channelCount;
this.sampleRate = sampleRate;
this.pcmEncoding = pcmEncoding;
- this.encoderDelay = encoderDelay;
- this.encoderPadding = encoderPadding;
+ this.encoderDelay = encoderDelay == Format.NO_VALUE ? 0 : encoderDelay;
+ this.encoderPadding = encoderPadding == Format.NO_VALUE ? 0 : encoderPadding;
this.selectionFlags = selectionFlags;
this.language = language;
this.accessibilityChannel = accessibilityChannel;
@@ -550,29 +544,6 @@ public final class Format implements Parcelable {
return width == NO_VALUE || height == NO_VALUE ? NO_VALUE : (width * height);
}
- /**
- * Returns a {@link MediaFormat} representation of this format.
- */
- @SuppressLint("InlinedApi")
- @TargetApi(16)
- public final MediaFormat getFrameworkMediaFormatV16() {
- MediaFormat format = new MediaFormat();
- format.setString(MediaFormat.KEY_MIME, sampleMimeType);
- maybeSetStringV16(format, MediaFormat.KEY_LANGUAGE, language);
- maybeSetIntegerV16(format, MediaFormat.KEY_MAX_INPUT_SIZE, maxInputSize);
- maybeSetIntegerV16(format, MediaFormat.KEY_WIDTH, width);
- maybeSetIntegerV16(format, MediaFormat.KEY_HEIGHT, height);
- maybeSetFloatV16(format, MediaFormat.KEY_FRAME_RATE, frameRate);
- maybeSetIntegerV16(format, "rotation-degrees", rotationDegrees);
- maybeSetIntegerV16(format, MediaFormat.KEY_CHANNEL_COUNT, channelCount);
- maybeSetIntegerV16(format, MediaFormat.KEY_SAMPLE_RATE, sampleRate);
- for (int i = 0; i < initializationData.size(); i++) {
- format.setByteBuffer("csd-" + i, ByteBuffer.wrap(initializationData.get(i)));
- }
- maybeSetColorInfoV24(format, colorInfo);
- return format;
- }
-
@Override
public String toString() {
return "Format(" + id + ", " + containerMimeType + ", " + sampleMimeType + ", " + bitrate + ", "
@@ -611,24 +582,44 @@ public final class Format implements Parcelable {
return false;
}
Format other = (Format) obj;
- if (bitrate != other.bitrate || maxInputSize != other.maxInputSize
- || width != other.width || height != other.height || frameRate != other.frameRate
- || rotationDegrees != other.rotationDegrees
- || pixelWidthHeightRatio != other.pixelWidthHeightRatio || stereoMode != other.stereoMode
- || channelCount != other.channelCount || sampleRate != other.sampleRate
- || pcmEncoding != other.pcmEncoding || encoderDelay != other.encoderDelay
- || encoderPadding != other.encoderPadding || subsampleOffsetUs != other.subsampleOffsetUs
- || selectionFlags != other.selectionFlags || !Util.areEqual(id, other.id)
- || !Util.areEqual(language, other.language)
- || accessibilityChannel != other.accessibilityChannel
- || !Util.areEqual(containerMimeType, other.containerMimeType)
- || !Util.areEqual(sampleMimeType, other.sampleMimeType)
- || !Util.areEqual(codecs, other.codecs)
- || !Util.areEqual(drmInitData, other.drmInitData)
- || !Util.areEqual(metadata, other.metadata)
- || !Util.areEqual(colorInfo, other.colorInfo)
- || !Arrays.equals(projectionData, other.projectionData)
- || initializationData.size() != other.initializationData.size()) {
+ return bitrate == other.bitrate
+ && maxInputSize == other.maxInputSize
+ && width == other.width
+ && height == other.height
+ && frameRate == other.frameRate
+ && rotationDegrees == other.rotationDegrees
+ && pixelWidthHeightRatio == other.pixelWidthHeightRatio
+ && stereoMode == other.stereoMode
+ && channelCount == other.channelCount
+ && sampleRate == other.sampleRate
+ && pcmEncoding == other.pcmEncoding
+ && encoderDelay == other.encoderDelay
+ && encoderPadding == other.encoderPadding
+ && subsampleOffsetUs == other.subsampleOffsetUs
+ && selectionFlags == other.selectionFlags
+ && Util.areEqual(id, other.id)
+ && Util.areEqual(language, other.language)
+ && accessibilityChannel == other.accessibilityChannel
+ && Util.areEqual(containerMimeType, other.containerMimeType)
+ && Util.areEqual(sampleMimeType, other.sampleMimeType)
+ && Util.areEqual(codecs, other.codecs)
+ && Util.areEqual(drmInitData, other.drmInitData)
+ && Util.areEqual(metadata, other.metadata)
+ && Util.areEqual(colorInfo, other.colorInfo)
+ && Arrays.equals(projectionData, other.projectionData)
+ && initializationDataEquals(other);
+ }
+
+ /**
+ * Returns whether the {@link #initializationData}s belonging to this format and {@code other} are
+ * equal.
+ *
+ * @param other The other format whose {@link #initializationData} is being compared.
+ * @return Whether the {@link #initializationData}s belonging to this format and {@code other} are
+ * equal.
+ */
+ public boolean initializationDataEquals(Format other) {
+ if (initializationData.size() != other.initializationData.size()) {
return false;
}
for (int i = 0; i < initializationData.size(); i++) {
@@ -639,45 +630,6 @@ public final class Format implements Parcelable {
return true;
}
- @TargetApi(24)
- private static void maybeSetColorInfoV24(MediaFormat format, ColorInfo colorInfo) {
- if (colorInfo == null) {
- return;
- }
- maybeSetIntegerV16(format, MediaFormat.KEY_COLOR_TRANSFER, colorInfo.colorTransfer);
- maybeSetIntegerV16(format, MediaFormat.KEY_COLOR_STANDARD, colorInfo.colorSpace);
- maybeSetIntegerV16(format, MediaFormat.KEY_COLOR_RANGE, colorInfo.colorRange);
- maybeSetByteBufferV16(format, MediaFormat.KEY_HDR_STATIC_INFO, colorInfo.hdrStaticInfo);
- }
-
- @TargetApi(16)
- private static void maybeSetStringV16(MediaFormat format, String key, String value) {
- if (value != null) {
- format.setString(key, value);
- }
- }
-
- @TargetApi(16)
- private static void maybeSetIntegerV16(MediaFormat format, String key, int value) {
- if (value != NO_VALUE) {
- format.setInteger(key, value);
- }
- }
-
- @TargetApi(16)
- private static void maybeSetFloatV16(MediaFormat format, String key, float value) {
- if (value != NO_VALUE) {
- format.setFloat(key, value);
- }
- }
-
- @TargetApi(16)
- private static void maybeSetByteBufferV16(MediaFormat format, String key, byte[] value) {
- if (value != null) {
- format.setByteBuffer(key, ByteBuffer.wrap(value));
- }
- }
-
// Utility methods
/**
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/MediaCodecAudioRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/MediaCodecAudioRenderer.java
index 33a67554a5..54a8257083 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/audio/MediaCodecAudioRenderer.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/MediaCodecAudioRenderer.java
@@ -15,6 +15,7 @@
*/
package com.google.android.exoplayer2.audio;
+import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.media.MediaCodec;
import android.media.MediaCrypto;
@@ -37,6 +38,7 @@ import com.google.android.exoplayer2.mediacodec.MediaCodecInfo;
import com.google.android.exoplayer2.mediacodec.MediaCodecRenderer;
import com.google.android.exoplayer2.mediacodec.MediaCodecSelector;
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil.DecoderQueryException;
+import com.google.android.exoplayer2.mediacodec.MediaFormatUtil;
import com.google.android.exoplayer2.util.MediaClock;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util;
@@ -62,6 +64,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
private final EventDispatcher eventDispatcher;
private final AudioSink audioSink;
+ private int codecMaxInputSize;
private boolean passthroughEnabled;
private boolean codecNeedsDiscardChannelsWorkaround;
private android.media.MediaFormat passthroughMediaFormat;
@@ -254,8 +257,9 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
@Override
protected void configureCodec(MediaCodecInfo codecInfo, MediaCodec codec, Format format,
MediaCrypto crypto) {
+ codecMaxInputSize = getCodecMaxInputSize(format, getStreamFormats());
codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name);
- MediaFormat mediaFormat = getMediaFormatForPlayback(format);
+ MediaFormat mediaFormat = getMediaFormat(format, codecMaxInputSize);
if (passthroughEnabled) {
// Override the MIME type used to configure the codec if we are using a passthrough decoder.
passthroughMediaFormat = mediaFormat;
@@ -268,6 +272,15 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
}
}
+ @Override
+ protected @KeepCodecResult int canKeepCodec(
+ MediaCodec codec, boolean codecIsAdaptive, Format oldFormat, Format newFormat) {
+ return newFormat.maxInputSize <= codecMaxInputSize
+ && areAdaptationCompatible(oldFormat, newFormat)
+ ? KEEP_CODEC_RESULT_YES_WITHOUT_RECONFIGURATION
+ : KEEP_CODEC_RESULT_NO;
+ }
+
@Override
public MediaClock getMediaClock() {
return this;
@@ -288,8 +301,8 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
pcmEncoding = MimeTypes.AUDIO_RAW.equals(newFormat.sampleMimeType) ? newFormat.pcmEncoding
: C.ENCODING_PCM_16BIT;
channelCount = newFormat.channelCount;
- encoderDelay = newFormat.encoderDelay != Format.NO_VALUE ? newFormat.encoderDelay : 0;
- encoderPadding = newFormat.encoderPadding != Format.NO_VALUE ? newFormat.encoderPadding : 0;
+ encoderDelay = newFormat.encoderDelay;
+ encoderPadding = newFormat.encoderPadding;
}
@Override
@@ -494,6 +507,53 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
}
}
+ /**
+ * Returns a maximum input size suitable for configuring a codec for {@code format} in a way that
+ * will allow possible adaptation to other compatible formats in {@code streamFormats}.
+ *
+ * @param format The format for which the codec is being configured.
+ * @param streamFormats The possible stream formats.
+ * @return A suitable maximum input size.
+ */
+ protected int getCodecMaxInputSize(Format format, Format[] streamFormats) {
+ int maxInputSize = format.maxInputSize;
+ if (streamFormats.length == 1) {
+ // The single entry in streamFormats must correspond to the format for which the codec is
+ // being configured.
+ return maxInputSize;
+ }
+ for (Format streamFormat : streamFormats) {
+ if (areAdaptationCompatible(format, streamFormat)) {
+ maxInputSize = Math.max(maxInputSize, streamFormat.maxInputSize);
+ }
+ }
+ return maxInputSize;
+ }
+
+ /**
+ * Returns the framework {@link MediaFormat} that can be used to configure a {@link MediaCodec}
+ * for decoding the given {@link Format} for playback.
+ *
+ * @param format The format of the media.
+ * @return The framework media format.
+ */
+ @SuppressLint("InlinedApi")
+ protected MediaFormat getMediaFormat(Format format, int codecMaxInputSize) {
+ MediaFormat mediaFormat = new MediaFormat();
+ // Set format parameters that should always be set.
+ mediaFormat.setString(MediaFormat.KEY_MIME, format.sampleMimeType);
+ mediaFormat.setInteger(MediaFormat.KEY_CHANNEL_COUNT, format.channelCount);
+ mediaFormat.setInteger(MediaFormat.KEY_SAMPLE_RATE, format.sampleRate);
+ MediaFormatUtil.setCsdBuffers(mediaFormat, format.initializationData);
+ // Set codec max values.
+ MediaFormatUtil.maybeSetInteger(mediaFormat, MediaFormat.KEY_MAX_INPUT_SIZE, codecMaxInputSize);
+ // Set codec configuration values.
+ if (Util.SDK_INT >= 23) {
+ mediaFormat.setInteger(MediaFormat.KEY_PRIORITY, 0 /* realtime priority */);
+ }
+ return mediaFormat;
+ }
+
private void updateCurrentPosition() {
long newCurrentPositionUs = audioSink.getCurrentPositionUs(isEnded());
if (newCurrentPositionUs != AudioSink.CURRENT_POSITION_NOT_SET) {
@@ -505,6 +565,25 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
}
}
+ /**
+ * Returns whether a codec with suitable maximum input size will support adaptation between two
+ * {@link Format}s.
+ *
+ * @param first The first format.
+ * @param second The second format.
+ * @return Whether the codec will support adaptation between the two {@link Format}s.
+ */
+ private static boolean areAdaptationCompatible(Format first, Format second) {
+ return first.sampleMimeType.equals(second.sampleMimeType)
+ && first.channelCount == second.channelCount
+ && first.sampleRate == second.sampleRate
+ && first.encoderDelay == 0
+ && first.encoderPadding == 0
+ && second.encoderDelay == 0
+ && second.encoderPadding == 0
+ && first.initializationDataEquals(second);
+ }
+
/**
* Returns whether the decoder is known to output six audio channels when provided with input with
* fewer than six channels.
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/SimpleDecoderAudioRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/SimpleDecoderAudioRenderer.java
index 83c33ee6d7..1a23c41262 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/audio/SimpleDecoderAudioRenderer.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/SimpleDecoderAudioRenderer.java
@@ -651,8 +651,8 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
audioTrackNeedsConfigure = true;
}
- encoderDelay = newFormat.encoderDelay == Format.NO_VALUE ? 0 : newFormat.encoderDelay;
- encoderPadding = newFormat.encoderPadding == Format.NO_VALUE ? 0 : newFormat.encoderPadding;
+ encoderDelay = newFormat.encoderDelay;
+ encoderPadding = newFormat.encoderPadding;
eventDispatcher.inputFormatChanged(newFormat);
}
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
index 2e8fc602a2..dce3f72302 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
@@ -129,6 +129,24 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
*/
private static final long MAX_CODEC_HOTSWAP_TIME_MS = 1000;
+ /** The possible return values for {@link #canKeepCodec(MediaCodec, boolean, Format, Format)}. */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef({
+ KEEP_CODEC_RESULT_NO,
+ KEEP_CODEC_RESULT_YES_WITHOUT_RECONFIGURATION,
+ KEEP_CODEC_RESULT_YES_WITH_RECONFIGURATION
+ })
+ protected @interface KeepCodecResult {}
+ /** The codec cannot be kept. */
+ protected static final int KEEP_CODEC_RESULT_NO = 0;
+ /** The codec can be kept. No reconfiguration is required. */
+ protected static final int KEEP_CODEC_RESULT_YES_WITHOUT_RECONFIGURATION = 1;
+ /**
+ * The codec can be kept, but must be reconfigured by prefixing the next input buffer with the new
+ * format's configuration data.
+ */
+ protected static final int KEEP_CODEC_RESULT_YES_WITH_RECONFIGURATION = 3;
+
@Retention(RetentionPolicy.SOURCE)
@IntDef({RECONFIGURATION_STATE_NONE, RECONFIGURATION_STATE_WRITE_PENDING,
RECONFIGURATION_STATE_QUEUE_PENDING})
@@ -432,21 +450,6 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
return codecInfo;
}
- /**
- * Returns the framework {@link MediaFormat} that can be used to configure a {@link MediaCodec}
- * for decoding the given {@link Format} for playback.
- *
- * @param format The format of the media.
- * @return The framework media format.
- */
- protected final MediaFormat getMediaFormatForPlayback(Format format) {
- MediaFormat mediaFormat = format.getFrameworkMediaFormatV16();
- if (Util.SDK_INT >= 23) {
- configureMediaFormatForPlaybackV23(mediaFormat);
- }
- return mediaFormat;
- }
-
@Override
protected void onEnabled(boolean joining) throws ExoPlaybackException {
decoderCounters = new DecoderCounters();
@@ -863,8 +866,8 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
Format oldFormat = format;
format = newFormat;
- boolean drmInitDataChanged = !Util.areEqual(format.drmInitData, oldFormat == null ? null
- : oldFormat.drmInitData);
+ boolean drmInitDataChanged =
+ !Util.areEqual(format.drmInitData, oldFormat == null ? null : oldFormat.drmInitData);
if (drmInitDataChanged) {
if (format.drmInitData != null) {
if (drmSessionManager == null) {
@@ -880,15 +883,31 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
}
}
- if (pendingDrmSession == drmSession && codec != null
- && canReconfigureCodec(codec, codecInfo.adaptive, oldFormat, format)) {
- codecReconfigured = true;
- codecReconfigurationState = RECONFIGURATION_STATE_WRITE_PENDING;
- codecNeedsAdaptationWorkaroundBuffer =
- codecAdaptationWorkaroundMode == ADAPTATION_WORKAROUND_MODE_ALWAYS
- || (codecAdaptationWorkaroundMode == ADAPTATION_WORKAROUND_MODE_SAME_RESOLUTION
- && format.width == oldFormat.width && format.height == oldFormat.height);
- } else {
+ boolean keepingCodec = false;
+ if (pendingDrmSession == drmSession && codec != null) {
+ switch (canKeepCodec(codec, codecInfo.adaptive, oldFormat, format)) {
+ case KEEP_CODEC_RESULT_NO:
+ // Do nothing.
+ break;
+ case KEEP_CODEC_RESULT_YES_WITHOUT_RECONFIGURATION:
+ keepingCodec = true;
+ break;
+ case KEEP_CODEC_RESULT_YES_WITH_RECONFIGURATION:
+ keepingCodec = true;
+ codecReconfigured = true;
+ codecReconfigurationState = RECONFIGURATION_STATE_WRITE_PENDING;
+ codecNeedsAdaptationWorkaroundBuffer =
+ codecAdaptationWorkaroundMode == ADAPTATION_WORKAROUND_MODE_ALWAYS
+ || (codecAdaptationWorkaroundMode == ADAPTATION_WORKAROUND_MODE_SAME_RESOLUTION
+ && format.width == oldFormat.width
+ && format.height == oldFormat.height);
+ break;
+ default:
+ throw new IllegalStateException(); // Never happens.
+ }
+ }
+
+ if (!keepingCodec) {
if (codecReceivedBuffers) {
// Signal end of stream and wait for any final output buffers before re-initialization.
codecReinitializationState = REINITIALIZATION_STATE_SIGNAL_END_OF_STREAM;
@@ -937,23 +956,20 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
}
/**
- * Determines whether the existing {@link MediaCodec} should be reconfigured for a new format by
- * sending codec specific initialization data at the start of the next input buffer. If true is
- * returned then the {@link MediaCodec} instance will be reconfigured in this way. If false is
- * returned then the instance will be released, and a new instance will be created for the new
- * format.
- *
- * The default implementation returns false.
+ * Determines whether the existing {@link MediaCodec} can be kept for a new format, and if it can
+ * whether it requires reconfiguration.
+ *
+ *
The default implementation returns {@link #KEEP_CODEC_RESULT_NO}.
*
* @param codec The existing {@link MediaCodec} instance.
* @param codecIsAdaptive Whether the codec is adaptive.
* @param oldFormat The format for which the existing instance is configured.
* @param newFormat The new format.
- * @return Whether the existing instance can be reconfigured.
+ * @return Whether the instance can be kept, and if it can whether it requires reconfiguration.
*/
- protected boolean canReconfigureCodec(MediaCodec codec, boolean codecIsAdaptive, Format oldFormat,
- Format newFormat) {
- return false;
+ protected @KeepCodecResult int canKeepCodec(
+ MediaCodec codec, boolean codecIsAdaptive, Format oldFormat, Format newFormat) {
+ return KEEP_CODEC_RESULT_NO;
}
@Override
@@ -1185,11 +1201,6 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
return false;
}
- @TargetApi(23)
- private static void configureMediaFormatForPlaybackV23(MediaFormat mediaFormat) {
- mediaFormat.setInteger(MediaFormat.KEY_PRIORITY, 0 /* realtime priority */);
- }
-
/**
* Returns whether the decoder is known to fail when flushed.
*
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaFormatUtil.java b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaFormatUtil.java
new file mode 100644
index 0000000000..3cfefc0736
--- /dev/null
+++ b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaFormatUtil.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2018 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.exoplayer2.mediacodec;
+
+import android.annotation.TargetApi;
+import android.media.MediaFormat;
+import android.support.annotation.Nullable;
+import com.google.android.exoplayer2.Format;
+import com.google.android.exoplayer2.video.ColorInfo;
+import java.nio.ByteBuffer;
+import java.util.List;
+
+/** Helper class for configuring {@link MediaFormat} instances. */
+@TargetApi(16)
+public final class MediaFormatUtil {
+
+ private MediaFormatUtil() {}
+
+ /**
+ * Sets a {@link MediaFormat} {@link String} value.
+ *
+ * @param format The {@link MediaFormat} being configured.
+ * @param key The key to set.
+ * @param value The value to set.
+ */
+ public static void setString(MediaFormat format, String key, String value) {
+ format.setString(key, value);
+ }
+
+ /**
+ * Sets a {@link MediaFormat}'s codec specific data buffers.
+ *
+ * @param format The {@link MediaFormat} being configured.
+ * @param csdBuffers The csd buffers to set.
+ */
+ public static void setCsdBuffers(MediaFormat format, List csdBuffers) {
+ for (int i = 0; i < csdBuffers.size(); i++) {
+ format.setByteBuffer("csd-" + i, ByteBuffer.wrap(csdBuffers.get(i)));
+ }
+ }
+
+ /**
+ * Sets a {@link MediaFormat} integer value. Does nothing if {@code value} is {@link
+ * Format#NO_VALUE}.
+ *
+ * @param format The {@link MediaFormat} being configured.
+ * @param key The key to set.
+ * @param value The value to set.
+ */
+ public static void maybeSetInteger(MediaFormat format, String key, int value) {
+ if (value != Format.NO_VALUE) {
+ format.setInteger(key, value);
+ }
+ }
+
+ /**
+ * Sets a {@link MediaFormat} float value. Does nothing if {@code value} is {@link
+ * Format#NO_VALUE}.
+ *
+ * @param format The {@link MediaFormat} being configured.
+ * @param key The key to set.
+ * @param value The value to set.
+ */
+ public static void maybeSetFloat(MediaFormat format, String key, float value) {
+ if (value != Format.NO_VALUE) {
+ format.setFloat(key, value);
+ }
+ }
+
+ /**
+ * Sets a {@link MediaFormat} {@link ByteBuffer} value. Does nothing if {@code value} is null.
+ *
+ * @param format The {@link MediaFormat} being configured.
+ * @param key The key to set.
+ * @param value The {@link byte[]} that will be wrapped to obtain the value.
+ */
+ public static void maybeSetByteBuffer(MediaFormat format, String key, @Nullable byte[] value) {
+ if (value != null) {
+ format.setByteBuffer(key, ByteBuffer.wrap(value));
+ }
+ }
+
+ /**
+ * Sets a {@link MediaFormat}'s color information. Does nothing if {@code colorInfo} is null.
+ *
+ * @param format The {@link MediaFormat} being configured.
+ * @param colorInfo The color info to set.
+ */
+ @SuppressWarnings("InlinedApi")
+ public static void maybeSetColorInfo(MediaFormat format, @Nullable ColorInfo colorInfo) {
+ if (colorInfo != null) {
+ maybeSetInteger(format, MediaFormat.KEY_COLOR_TRANSFER, colorInfo.colorTransfer);
+ maybeSetInteger(format, MediaFormat.KEY_COLOR_STANDARD, colorInfo.colorSpace);
+ maybeSetInteger(format, MediaFormat.KEY_COLOR_RANGE, colorInfo.colorRange);
+ maybeSetByteBuffer(format, MediaFormat.KEY_HDR_STATIC_INFO, colorInfo.hdrStaticInfo);
+ }
+ }
+}
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaPeriod.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaPeriod.java
index e71c278e37..98bd7daaec 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaPeriod.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaPeriod.java
@@ -293,7 +293,7 @@ public final class ClippingMediaPeriod implements MediaPeriod, MediaPeriod.Callb
int result = childStream.readData(formatHolder, buffer, requireFormat);
if (result == C.RESULT_FORMAT_READ) {
Format format = formatHolder.format;
- if (format.encoderDelay != Format.NO_VALUE || format.encoderPadding != Format.NO_VALUE) {
+ if (format.encoderDelay != 0 || format.encoderPadding != 0) {
// Clear gapless playback metadata if the start/end points don't match the media.
int encoderDelay = startUs != 0 ? 0 : format.encoderDelay;
int encoderPadding = endUs != C.TIME_END_OF_SOURCE ? 0 : format.encoderPadding;
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java
index 62a7657ea7..3ac5b1a12a 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java
@@ -44,6 +44,7 @@ import com.google.android.exoplayer2.mediacodec.MediaCodecRenderer;
import com.google.android.exoplayer2.mediacodec.MediaCodecSelector;
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil;
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil.DecoderQueryException;
+import com.google.android.exoplayer2.mediacodec.MediaFormatUtil;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.TraceUtil;
@@ -91,7 +92,6 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
private final boolean deviceNeedsAutoFrcWorkaround;
private final long[] pendingOutputStreamOffsetsUs;
- private Format[] streamFormats;
private CodecMaxValues codecMaxValues;
private boolean codecNeedsSetOutputSurfaceWorkaround;
@@ -258,7 +258,6 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
@Override
protected void onStreamChanged(Format[] formats, long offsetUs) throws ExoPlaybackException {
- streamFormats = formats;
if (outputStreamOffsetUs == C.TIME_UNSET) {
outputStreamOffsetUs = offsetUs;
} else {
@@ -352,7 +351,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
scalingMode = (Integer) message;
MediaCodec codec = getCodec();
if (codec != null) {
- setVideoScalingMode(codec, scalingMode);
+ codec.setVideoScalingMode(scalingMode);
}
} else {
super.handleMessage(messageType, message);
@@ -415,7 +414,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
@Override
protected void configureCodec(MediaCodecInfo codecInfo, MediaCodec codec, Format format,
MediaCrypto crypto) throws DecoderQueryException {
- codecMaxValues = getCodecMaxValues(codecInfo, format, streamFormats);
+ codecMaxValues = getCodecMaxValues(codecInfo, format, getStreamFormats());
MediaFormat mediaFormat = getMediaFormat(format, codecMaxValues, deviceNeedsAutoFrcWorkaround,
tunnelingAudioSessionId);
if (surface == null) {
@@ -431,6 +430,20 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
}
}
+ @Override
+ protected @KeepCodecResult int canKeepCodec(
+ MediaCodec codec, boolean codecIsAdaptive, Format oldFormat, Format newFormat) {
+ if (areAdaptationCompatible(codecIsAdaptive, oldFormat, newFormat)
+ && newFormat.width <= codecMaxValues.width
+ && newFormat.height <= codecMaxValues.height
+ && getMaxInputSize(newFormat) <= codecMaxValues.inputSize) {
+ return oldFormat.initializationDataEquals(newFormat)
+ ? KEEP_CODEC_RESULT_YES_WITHOUT_RECONFIGURATION
+ : KEEP_CODEC_RESULT_YES_WITH_RECONFIGURATION;
+ }
+ return KEEP_CODEC_RESULT_NO;
+ }
+
@CallSuper
@Override
protected void releaseCodec() {
@@ -468,8 +481,8 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
protected void onInputFormatChanged(Format newFormat) throws ExoPlaybackException {
super.onInputFormatChanged(newFormat);
eventDispatcher.inputFormatChanged(newFormat);
- pendingPixelWidthHeightRatio = getPixelWidthHeightRatio(newFormat);
- pendingRotationDegrees = getRotationDegrees(newFormat);
+ pendingPixelWidthHeightRatio = newFormat.pixelWidthHeightRatio;
+ pendingRotationDegrees = newFormat.rotationDegrees;
}
/**
@@ -513,15 +526,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
currentUnappliedRotationDegrees = pendingRotationDegrees;
}
// Must be applied each time the output format changes.
- setVideoScalingMode(codec, scalingMode);
- }
-
- @Override
- protected boolean canReconfigureCodec(MediaCodec codec, boolean codecIsAdaptive,
- Format oldFormat, Format newFormat) {
- return areAdaptationCompatible(codecIsAdaptive, oldFormat, newFormat)
- && newFormat.width <= codecMaxValues.width && newFormat.height <= codecMaxValues.height
- && getMaxInputSize(newFormat) <= codecMaxValues.inputSize;
+ codec.setVideoScalingMode(scalingMode);
}
@Override
@@ -908,33 +913,48 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
}
/**
- * Returns the framework {@link MediaFormat} that should be used to configure the decoder when
- * playing media in the specified input format.
+ * Returns the framework {@link MediaFormat} that should be used to configure the decoder.
*
- * @param format The format of input media.
- * @param codecMaxValues The codec's maximum supported values.
+ * @param format The format of media.
+ * @param codecMaxValues Codec max values that should be used when configuring the decoder.
* @param deviceNeedsAutoFrcWorkaround Whether the device is known to enable frame-rate conversion
* logic that negatively impacts ExoPlayer.
- * @param tunnelingAudioSessionId The audio session id to use for tunneling, or
- * {@link C#AUDIO_SESSION_ID_UNSET} if tunneling should not be enabled.
+ * @param tunnelingAudioSessionId The audio session id to use for tunneling, or {@link
+ * C#AUDIO_SESSION_ID_UNSET} if tunneling should not be enabled.
* @return The framework {@link MediaFormat} that should be used to configure the decoder.
*/
@SuppressLint("InlinedApi")
- protected MediaFormat getMediaFormat(Format format, CodecMaxValues codecMaxValues,
- boolean deviceNeedsAutoFrcWorkaround, int tunnelingAudioSessionId) {
- MediaFormat frameworkMediaFormat = getMediaFormatForPlayback(format);
- frameworkMediaFormat.setInteger(MediaFormat.KEY_MAX_WIDTH, codecMaxValues.width);
- frameworkMediaFormat.setInteger(MediaFormat.KEY_MAX_HEIGHT, codecMaxValues.height);
- if (codecMaxValues.inputSize != Format.NO_VALUE) {
- frameworkMediaFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, codecMaxValues.inputSize);
+ protected MediaFormat getMediaFormat(
+ Format format,
+ CodecMaxValues codecMaxValues,
+ boolean deviceNeedsAutoFrcWorkaround,
+ int tunnelingAudioSessionId) {
+ MediaFormat mediaFormat = new MediaFormat();
+ // Set format parameters that should always be set.
+ mediaFormat.setString(MediaFormat.KEY_MIME, format.sampleMimeType);
+ mediaFormat.setInteger(MediaFormat.KEY_WIDTH, format.width);
+ mediaFormat.setInteger(MediaFormat.KEY_HEIGHT, format.height);
+ MediaFormatUtil.setCsdBuffers(mediaFormat, format.initializationData);
+ // Set format parameters that may be unset.
+ MediaFormatUtil.maybeSetFloat(mediaFormat, MediaFormat.KEY_FRAME_RATE, format.frameRate);
+ MediaFormatUtil.maybeSetInteger(mediaFormat, MediaFormat.KEY_ROTATION, format.rotationDegrees);
+ MediaFormatUtil.maybeSetColorInfo(mediaFormat, format.colorInfo);
+ // Set codec max values.
+ mediaFormat.setInteger(MediaFormat.KEY_MAX_WIDTH, codecMaxValues.width);
+ mediaFormat.setInteger(MediaFormat.KEY_MAX_HEIGHT, codecMaxValues.height);
+ MediaFormatUtil.maybeSetInteger(
+ mediaFormat, MediaFormat.KEY_MAX_INPUT_SIZE, codecMaxValues.inputSize);
+ // Set codec configuration values.
+ if (Util.SDK_INT >= 23) {
+ mediaFormat.setInteger(MediaFormat.KEY_PRIORITY, 0 /* realtime priority */);
}
if (deviceNeedsAutoFrcWorkaround) {
- frameworkMediaFormat.setInteger("auto-frc", 0);
+ mediaFormat.setInteger("auto-frc", 0);
}
if (tunnelingAudioSessionId != C.AUDIO_SESSION_ID_UNSET) {
- configureTunnelingV21(frameworkMediaFormat, tunnelingAudioSessionId);
+ configureTunnelingV21(mediaFormat, tunnelingAudioSessionId);
}
- return frameworkMediaFormat;
+ return mediaFormat;
}
/**
@@ -1054,8 +1074,21 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
return (maxPixels * 3) / (2 * minCompressionRatio);
}
- private static void setVideoScalingMode(MediaCodec codec, int scalingMode) {
- codec.setVideoScalingMode(scalingMode);
+ /**
+ * Returns whether a codec with suitable {@link CodecMaxValues} will support adaptation between
+ * two {@link Format}s.
+ *
+ * @param codecIsAdaptive Whether the codec supports seamless resolution switches.
+ * @param first The first format.
+ * @param second The second format.
+ * @return Whether the codec will support adaptation between the two {@link Format}s.
+ */
+ private static boolean areAdaptationCompatible(
+ boolean codecIsAdaptive, Format first, Format second) {
+ return first.sampleMimeType.equals(second.sampleMimeType)
+ && first.rotationDegrees == second.rotationDegrees
+ && (codecIsAdaptive || (first.width == second.width && first.height == second.height))
+ && Util.areEqual(first.colorInfo, second.colorInfo);
}
/**
@@ -1103,30 +1136,6 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
&& "OMX.k3.video.decoder.avc".equals(name));
}
- /**
- * Returns whether a codec with suitable {@link CodecMaxValues} will support adaptation between
- * two {@link Format}s.
- *
- * @param codecIsAdaptive Whether the codec supports seamless resolution switches.
- * @param first The first format.
- * @param second The second format.
- * @return Whether the codec will support adaptation between the two {@link Format}s.
- */
- private static boolean areAdaptationCompatible(boolean codecIsAdaptive, Format first,
- Format second) {
- return first.sampleMimeType.equals(second.sampleMimeType)
- && getRotationDegrees(first) == getRotationDegrees(second)
- && (codecIsAdaptive || (first.width == second.width && first.height == second.height));
- }
-
- private static float getPixelWidthHeightRatio(Format format) {
- return format.pixelWidthHeightRatio == Format.NO_VALUE ? 1 : format.pixelWidthHeightRatio;
- }
-
- private static int getRotationDegrees(Format format) {
- return format.rotationDegrees == Format.NO_VALUE ? 0 : format.rotationDegrees;
- }
-
protected static final class CodecMaxValues {
public final int width;
diff --git a/library/core/src/test/assets/flv/sample.flv.0.dump b/library/core/src/test/assets/flv/sample.flv.0.dump
index f4502749f5..098311a310 100644
--- a/library/core/src/test/assets/flv/sample.flv.0.dump
+++ b/library/core/src/test/assets/flv/sample.flv.0.dump
@@ -13,13 +13,13 @@ track 8:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
@@ -218,13 +218,13 @@ track 9:
width = 1080
height = 720
frameRate = -1.0
- rotationDegrees = -1
+ rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/mkv/sample.mkv.0.dump b/library/core/src/test/assets/mkv/sample.mkv.0.dump
index 009ff55c23..847799396d 100644
--- a/library/core/src/test/assets/mkv/sample.mkv.0.dump
+++ b/library/core/src/test/assets/mkv/sample.mkv.0.dump
@@ -13,13 +13,13 @@ track 1:
width = 1080
height = 720
frameRate = -1.0
- rotationDegrees = -1
+ rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
@@ -159,13 +159,13 @@ track 2:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 1
language = und
diff --git a/library/core/src/test/assets/mkv/sample.mkv.1.dump b/library/core/src/test/assets/mkv/sample.mkv.1.dump
index 91396e81b8..5caa638437 100644
--- a/library/core/src/test/assets/mkv/sample.mkv.1.dump
+++ b/library/core/src/test/assets/mkv/sample.mkv.1.dump
@@ -13,13 +13,13 @@ track 1:
width = 1080
height = 720
frameRate = -1.0
- rotationDegrees = -1
+ rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
@@ -127,13 +127,13 @@ track 2:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 1
language = und
diff --git a/library/core/src/test/assets/mkv/sample.mkv.2.dump b/library/core/src/test/assets/mkv/sample.mkv.2.dump
index 5c56dcc8af..de4e2a58bf 100644
--- a/library/core/src/test/assets/mkv/sample.mkv.2.dump
+++ b/library/core/src/test/assets/mkv/sample.mkv.2.dump
@@ -13,13 +13,13 @@ track 1:
width = 1080
height = 720
frameRate = -1.0
- rotationDegrees = -1
+ rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
@@ -83,13 +83,13 @@ track 2:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 1
language = und
diff --git a/library/core/src/test/assets/mkv/sample.mkv.3.dump b/library/core/src/test/assets/mkv/sample.mkv.3.dump
index cf5a0199fc..6034c54dec 100644
--- a/library/core/src/test/assets/mkv/sample.mkv.3.dump
+++ b/library/core/src/test/assets/mkv/sample.mkv.3.dump
@@ -13,13 +13,13 @@ track 1:
width = 1080
height = 720
frameRate = -1.0
- rotationDegrees = -1
+ rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
@@ -39,13 +39,13 @@ track 2:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 1
language = und
diff --git a/library/core/src/test/assets/mkv/subsample_encrypted_altref.webm.0.dump b/library/core/src/test/assets/mkv/subsample_encrypted_altref.webm.0.dump
index 62a270eb9e..89a7514784 100644
--- a/library/core/src/test/assets/mkv/subsample_encrypted_altref.webm.0.dump
+++ b/library/core/src/test/assets/mkv/subsample_encrypted_altref.webm.0.dump
@@ -13,13 +13,13 @@ track 1:
width = 360
height = 240
frameRate = -1.0
- rotationDegrees = -1
+ rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/mkv/subsample_encrypted_noaltref.webm.0.dump b/library/core/src/test/assets/mkv/subsample_encrypted_noaltref.webm.0.dump
index 43e5eed5d1..1caa3f9f27 100644
--- a/library/core/src/test/assets/mkv/subsample_encrypted_noaltref.webm.0.dump
+++ b/library/core/src/test/assets/mkv/subsample_encrypted_noaltref.webm.0.dump
@@ -13,13 +13,13 @@ track 1:
width = 360
height = 240
frameRate = -1.0
- rotationDegrees = -1
+ rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/mp3/bear.mp3.0.dump b/library/core/src/test/assets/mp3/bear.mp3.0.dump
index b12a68a60b..5c8700fed1 100644
--- a/library/core/src/test/assets/mp3/bear.mp3.0.dump
+++ b/library/core/src/test/assets/mp3/bear.mp3.0.dump
@@ -13,8 +13,8 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
diff --git a/library/core/src/test/assets/mp3/bear.mp3.1.dump b/library/core/src/test/assets/mp3/bear.mp3.1.dump
index abf5b10415..c2f37973b7 100644
--- a/library/core/src/test/assets/mp3/bear.mp3.1.dump
+++ b/library/core/src/test/assets/mp3/bear.mp3.1.dump
@@ -13,8 +13,8 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
diff --git a/library/core/src/test/assets/mp3/bear.mp3.2.dump b/library/core/src/test/assets/mp3/bear.mp3.2.dump
index 813f61b7fc..543cf44cc0 100644
--- a/library/core/src/test/assets/mp3/bear.mp3.2.dump
+++ b/library/core/src/test/assets/mp3/bear.mp3.2.dump
@@ -13,8 +13,8 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
diff --git a/library/core/src/test/assets/mp3/bear.mp3.3.dump b/library/core/src/test/assets/mp3/bear.mp3.3.dump
index 9a0207bd53..a87b7d6d37 100644
--- a/library/core/src/test/assets/mp3/bear.mp3.3.dump
+++ b/library/core/src/test/assets/mp3/bear.mp3.3.dump
@@ -13,8 +13,8 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
diff --git a/library/core/src/test/assets/mp3/play-trimmed.mp3.0.dump b/library/core/src/test/assets/mp3/play-trimmed.mp3.0.dump
index 435360dfed..96b0cd259c 100644
--- a/library/core/src/test/assets/mp3/play-trimmed.mp3.0.dump
+++ b/library/core/src/test/assets/mp3/play-trimmed.mp3.0.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/mp3/play-trimmed.mp3.1.dump b/library/core/src/test/assets/mp3/play-trimmed.mp3.1.dump
index 435360dfed..96b0cd259c 100644
--- a/library/core/src/test/assets/mp3/play-trimmed.mp3.1.dump
+++ b/library/core/src/test/assets/mp3/play-trimmed.mp3.1.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/mp3/play-trimmed.mp3.2.dump b/library/core/src/test/assets/mp3/play-trimmed.mp3.2.dump
index 435360dfed..96b0cd259c 100644
--- a/library/core/src/test/assets/mp3/play-trimmed.mp3.2.dump
+++ b/library/core/src/test/assets/mp3/play-trimmed.mp3.2.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/mp3/play-trimmed.mp3.3.dump b/library/core/src/test/assets/mp3/play-trimmed.mp3.3.dump
index 435360dfed..96b0cd259c 100644
--- a/library/core/src/test/assets/mp3/play-trimmed.mp3.3.dump
+++ b/library/core/src/test/assets/mp3/play-trimmed.mp3.3.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/mp3/play-trimmed.mp3.unklen.dump b/library/core/src/test/assets/mp3/play-trimmed.mp3.unklen.dump
index 6b49619b50..d28cca025b 100644
--- a/library/core/src/test/assets/mp3/play-trimmed.mp3.unklen.dump
+++ b/library/core/src/test/assets/mp3/play-trimmed.mp3.unklen.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/mp4/sample.mp4.0.dump b/library/core/src/test/assets/mp4/sample.mp4.0.dump
index 77708b16df..efc804d48b 100644
--- a/library/core/src/test/assets/mp4/sample.mp4.0.dump
+++ b/library/core/src/test/assets/mp4/sample.mp4.0.dump
@@ -18,8 +18,8 @@ track 0:
channelCount = -1
sampleRate = -1
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
@@ -159,13 +159,13 @@ track 1:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = und
diff --git a/library/core/src/test/assets/mp4/sample.mp4.1.dump b/library/core/src/test/assets/mp4/sample.mp4.1.dump
index 30ed21ef98..10104b5e81 100644
--- a/library/core/src/test/assets/mp4/sample.mp4.1.dump
+++ b/library/core/src/test/assets/mp4/sample.mp4.1.dump
@@ -18,8 +18,8 @@ track 0:
channelCount = -1
sampleRate = -1
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
@@ -159,13 +159,13 @@ track 1:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = und
diff --git a/library/core/src/test/assets/mp4/sample.mp4.2.dump b/library/core/src/test/assets/mp4/sample.mp4.2.dump
index 640d92722c..8af96be673 100644
--- a/library/core/src/test/assets/mp4/sample.mp4.2.dump
+++ b/library/core/src/test/assets/mp4/sample.mp4.2.dump
@@ -18,8 +18,8 @@ track 0:
channelCount = -1
sampleRate = -1
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
@@ -159,13 +159,13 @@ track 1:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = und
diff --git a/library/core/src/test/assets/mp4/sample.mp4.3.dump b/library/core/src/test/assets/mp4/sample.mp4.3.dump
index b4fd4a0b02..f1259661ed 100644
--- a/library/core/src/test/assets/mp4/sample.mp4.3.dump
+++ b/library/core/src/test/assets/mp4/sample.mp4.3.dump
@@ -18,8 +18,8 @@ track 0:
channelCount = -1
sampleRate = -1
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
@@ -159,13 +159,13 @@ track 1:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = und
diff --git a/library/core/src/test/assets/mp4/sample_fragmented.mp4.0.dump b/library/core/src/test/assets/mp4/sample_fragmented.mp4.0.dump
index ec2cb7b8ce..faa8a015ca 100644
--- a/library/core/src/test/assets/mp4/sample_fragmented.mp4.0.dump
+++ b/library/core/src/test/assets/mp4/sample_fragmented.mp4.0.dump
@@ -18,8 +18,8 @@ track 0:
channelCount = -1
sampleRate = -1
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
@@ -159,13 +159,13 @@ track 1:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = und
diff --git a/library/core/src/test/assets/mp4/sample_fragmented_sei.mp4.0.dump b/library/core/src/test/assets/mp4/sample_fragmented_sei.mp4.0.dump
index ae012055fe..87f2cc6714 100644
--- a/library/core/src/test/assets/mp4/sample_fragmented_sei.mp4.0.dump
+++ b/library/core/src/test/assets/mp4/sample_fragmented_sei.mp4.0.dump
@@ -18,8 +18,8 @@ track 0:
channelCount = -1
sampleRate = -1
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
@@ -159,13 +159,13 @@ track 1:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = und
@@ -368,13 +368,13 @@ track 3:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear.opus.0.dump b/library/core/src/test/assets/ogg/bear.opus.0.dump
index 643972b836..f8eadb16fa 100644
--- a/library/core/src/test/assets/ogg/bear.opus.0.dump
+++ b/library/core/src/test/assets/ogg/bear.opus.0.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear.opus.1.dump b/library/core/src/test/assets/ogg/bear.opus.1.dump
index 8df1563d90..593116a22e 100644
--- a/library/core/src/test/assets/ogg/bear.opus.1.dump
+++ b/library/core/src/test/assets/ogg/bear.opus.1.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear.opus.2.dump b/library/core/src/test/assets/ogg/bear.opus.2.dump
index bed4c46d9c..beabde35c8 100644
--- a/library/core/src/test/assets/ogg/bear.opus.2.dump
+++ b/library/core/src/test/assets/ogg/bear.opus.2.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear.opus.3.dump b/library/core/src/test/assets/ogg/bear.opus.3.dump
index 8a9c99250e..d0f3e2948b 100644
--- a/library/core/src/test/assets/ogg/bear.opus.3.dump
+++ b/library/core/src/test/assets/ogg/bear.opus.3.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear.opus.unklen.dump b/library/core/src/test/assets/ogg/bear.opus.unklen.dump
index 5d2c84b047..ec8f8b8665 100644
--- a/library/core/src/test/assets/ogg/bear.opus.unklen.dump
+++ b/library/core/src/test/assets/ogg/bear.opus.unklen.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear_flac.ogg.0.dump b/library/core/src/test/assets/ogg/bear_flac.ogg.0.dump
index ff22bb2d3e..dbe97c02bd 100644
--- a/library/core/src/test/assets/ogg/bear_flac.ogg.0.dump
+++ b/library/core/src/test/assets/ogg/bear_flac.ogg.0.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear_flac.ogg.1.dump b/library/core/src/test/assets/ogg/bear_flac.ogg.1.dump
index 50110149fd..d1246a3e64 100644
--- a/library/core/src/test/assets/ogg/bear_flac.ogg.1.dump
+++ b/library/core/src/test/assets/ogg/bear_flac.ogg.1.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear_flac.ogg.2.dump b/library/core/src/test/assets/ogg/bear_flac.ogg.2.dump
index 483ae36721..ec0336309a 100644
--- a/library/core/src/test/assets/ogg/bear_flac.ogg.2.dump
+++ b/library/core/src/test/assets/ogg/bear_flac.ogg.2.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear_flac.ogg.3.dump b/library/core/src/test/assets/ogg/bear_flac.ogg.3.dump
index a47407e63d..1e3254a9fc 100644
--- a/library/core/src/test/assets/ogg/bear_flac.ogg.3.dump
+++ b/library/core/src/test/assets/ogg/bear_flac.ogg.3.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear_flac.ogg.unklen.dump b/library/core/src/test/assets/ogg/bear_flac.ogg.unklen.dump
index ff22bb2d3e..dbe97c02bd 100644
--- a/library/core/src/test/assets/ogg/bear_flac.ogg.unklen.dump
+++ b/library/core/src/test/assets/ogg/bear_flac.ogg.unklen.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.0.dump b/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.0.dump
index 32f350efcb..cce7bf2450 100644
--- a/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.0.dump
+++ b/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.0.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.1.dump b/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.1.dump
index 3082e8faca..ac36a48412 100644
--- a/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.1.dump
+++ b/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.1.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.2.dump b/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.2.dump
index b574409f70..dae0d878fa 100644
--- a/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.2.dump
+++ b/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.2.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.3.dump b/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.3.dump
index f411596b44..c9570ab58e 100644
--- a/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.3.dump
+++ b/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.3.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.unklen.dump b/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.unklen.dump
index bdfe90277d..7a3e7ef5ac 100644
--- a/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.unklen.dump
+++ b/library/core/src/test/assets/ogg/bear_flac_noseektable.ogg.unklen.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear_vorbis.ogg.0.dump b/library/core/src/test/assets/ogg/bear_vorbis.ogg.0.dump
index dd129ce9dc..138e13c54d 100644
--- a/library/core/src/test/assets/ogg/bear_vorbis.ogg.0.dump
+++ b/library/core/src/test/assets/ogg/bear_vorbis.ogg.0.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear_vorbis.ogg.1.dump b/library/core/src/test/assets/ogg/bear_vorbis.ogg.1.dump
index 4fb8a74d92..6b37dfb6cf 100644
--- a/library/core/src/test/assets/ogg/bear_vorbis.ogg.1.dump
+++ b/library/core/src/test/assets/ogg/bear_vorbis.ogg.1.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear_vorbis.ogg.2.dump b/library/core/src/test/assets/ogg/bear_vorbis.ogg.2.dump
index fad8f33d77..9620979357 100644
--- a/library/core/src/test/assets/ogg/bear_vorbis.ogg.2.dump
+++ b/library/core/src/test/assets/ogg/bear_vorbis.ogg.2.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear_vorbis.ogg.3.dump b/library/core/src/test/assets/ogg/bear_vorbis.ogg.3.dump
index 49dca02220..18d869030d 100644
--- a/library/core/src/test/assets/ogg/bear_vorbis.ogg.3.dump
+++ b/library/core/src/test/assets/ogg/bear_vorbis.ogg.3.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ogg/bear_vorbis.ogg.unklen.dump b/library/core/src/test/assets/ogg/bear_vorbis.ogg.unklen.dump
index 756be42854..2686f740db 100644
--- a/library/core/src/test/assets/ogg/bear_vorbis.ogg.unklen.dump
+++ b/library/core/src/test/assets/ogg/bear_vorbis.ogg.unklen.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 2
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/rawcc/sample.rawcc.0.dump b/library/core/src/test/assets/rawcc/sample.rawcc.0.dump
index 130be06ceb..adeaaf6a37 100644
--- a/library/core/src/test/assets/rawcc/sample.rawcc.0.dump
+++ b/library/core/src/test/assets/rawcc/sample.rawcc.0.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ts/sample.ac3.0.dump b/library/core/src/test/assets/ts/sample.ac3.0.dump
index 46028638fe..a1d29a77dc 100644
--- a/library/core/src/test/assets/ts/sample.ac3.0.dump
+++ b/library/core/src/test/assets/ts/sample.ac3.0.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 6
sampleRate = 48000
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ts/sample.adts.0.dump b/library/core/src/test/assets/ts/sample.adts.0.dump
index 132859a00e..93d7b776c0 100644
--- a/library/core/src/test/assets/ts/sample.adts.0.dump
+++ b/library/core/src/test/assets/ts/sample.adts.0.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
@@ -614,13 +614,13 @@ track 1:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ts/sample.ps.0.dump b/library/core/src/test/assets/ts/sample.ps.0.dump
index e833201692..dda6de8ab4 100644
--- a/library/core/src/test/assets/ts/sample.ps.0.dump
+++ b/library/core/src/test/assets/ts/sample.ps.0.dump
@@ -13,13 +13,13 @@ track 192:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
@@ -53,13 +53,13 @@ track 224:
width = 640
height = 426
frameRate = -1.0
- rotationDegrees = -1
+ rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/ts/sample.ts.0.dump b/library/core/src/test/assets/ts/sample.ts.0.dump
index 39b1565289..a74268a702 100644
--- a/library/core/src/test/assets/ts/sample.ts.0.dump
+++ b/library/core/src/test/assets/ts/sample.ts.0.dump
@@ -13,13 +13,13 @@ track 256:
width = 640
height = 426
frameRate = -1.0
- rotationDegrees = -1
+ rotationDegrees = 0
pixelWidthHeightRatio = 1.0
channelCount = -1
sampleRate = -1
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
@@ -46,13 +46,13 @@ track 257:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = -1
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = und
diff --git a/library/core/src/test/assets/wav/sample.wav.0.dump b/library/core/src/test/assets/wav/sample.wav.0.dump
index 32f9d495d2..a6c46f75fc 100644
--- a/library/core/src/test/assets/wav/sample.wav.0.dump
+++ b/library/core/src/test/assets/wav/sample.wav.0.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = 2
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/wav/sample.wav.1.dump b/library/core/src/test/assets/wav/sample.wav.1.dump
index d4758e65b5..3cc70dc71f 100644
--- a/library/core/src/test/assets/wav/sample.wav.1.dump
+++ b/library/core/src/test/assets/wav/sample.wav.1.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = 2
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/wav/sample.wav.2.dump b/library/core/src/test/assets/wav/sample.wav.2.dump
index ea33c62423..07ce135dfa 100644
--- a/library/core/src/test/assets/wav/sample.wav.2.dump
+++ b/library/core/src/test/assets/wav/sample.wav.2.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = 2
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/assets/wav/sample.wav.3.dump b/library/core/src/test/assets/wav/sample.wav.3.dump
index de0d8f22d0..82ed95ad60 100644
--- a/library/core/src/test/assets/wav/sample.wav.3.dump
+++ b/library/core/src/test/assets/wav/sample.wav.3.dump
@@ -13,13 +13,13 @@ track 0:
width = -1
height = -1
frameRate = -1.0
- rotationDegrees = -1
- pixelWidthHeightRatio = -1.0
+ rotationDegrees = 0
+ pixelWidthHeightRatio = 1.0
channelCount = 1
sampleRate = 44100
pcmEncoding = 2
- encoderDelay = -1
- encoderPadding = -1
+ encoderDelay = 0
+ encoderPadding = 0
subsampleOffsetUs = 9223372036854775807
selectionFlags = 0
language = null
diff --git a/library/core/src/test/java/com/google/android/exoplayer2/FormatTest.java b/library/core/src/test/java/com/google/android/exoplayer2/FormatTest.java
index eb51485a36..7ca2181ebf 100644
--- a/library/core/src/test/java/com/google/android/exoplayer2/FormatTest.java
+++ b/library/core/src/test/java/com/google/android/exoplayer2/FormatTest.java
@@ -20,20 +20,14 @@ import static com.google.android.exoplayer2.util.MimeTypes.VIDEO_MP4;
import static com.google.android.exoplayer2.util.MimeTypes.VIDEO_WEBM;
import static com.google.common.truth.Truth.assertThat;
-import android.annotation.SuppressLint;
-import android.annotation.TargetApi;
-import android.media.MediaFormat;
import android.os.Parcel;
import com.google.android.exoplayer2.drm.DrmInitData;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.id3.TextInformationFrame;
import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.util.MimeTypes;
-import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.ColorInfo;
-import java.nio.ByteBuffer;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.junit.Test;
@@ -85,73 +79,4 @@ public final class FormatTest {
parcel.recycle();
}
- @Test
- public void testConversionToFrameworkMediaFormat() {
- if (Util.SDK_INT < 16) {
- // Test doesn't apply.
- return;
- }
-
- testConversionToFrameworkMediaFormatV16(Format.createVideoSampleFormat(null, "video/xyz", null,
- 5000, 102400, 1280, 720, 30, INIT_DATA, null));
- testConversionToFrameworkMediaFormatV16(Format.createVideoSampleFormat(null, "video/xyz", null,
- 5000, Format.NO_VALUE, 1280, 720, 30, null, null));
- testConversionToFrameworkMediaFormatV16(Format.createAudioSampleFormat(null, "audio/xyz", null,
- 500, 128, 5, 44100, INIT_DATA, null, 0, null));
- testConversionToFrameworkMediaFormatV16(Format.createAudioSampleFormat(null, "audio/xyz", null,
- 500, Format.NO_VALUE, 5, 44100, null, null, 0, null));
- testConversionToFrameworkMediaFormatV16(Format.createTextSampleFormat(null, "text/xyz", 0,
- "eng"));
- testConversionToFrameworkMediaFormatV16(Format.createTextSampleFormat(null, "text/xyz", 0,
- null));
- }
-
- @SuppressLint("InlinedApi")
- @TargetApi(16)
- private static void testConversionToFrameworkMediaFormatV16(Format in) {
- MediaFormat out = in.getFrameworkMediaFormatV16();
- assertThat(out.getString(MediaFormat.KEY_MIME)).isEqualTo(in.sampleMimeType);
- assertOptionalV16(out, MediaFormat.KEY_LANGUAGE, in.language);
- assertOptionalV16(out, MediaFormat.KEY_MAX_INPUT_SIZE, in.maxInputSize);
- assertOptionalV16(out, MediaFormat.KEY_WIDTH, in.width);
- assertOptionalV16(out, MediaFormat.KEY_HEIGHT, in.height);
- assertOptionalV16(out, MediaFormat.KEY_CHANNEL_COUNT, in.channelCount);
- assertOptionalV16(out, MediaFormat.KEY_SAMPLE_RATE, in.sampleRate);
- assertOptionalV16(out, MediaFormat.KEY_FRAME_RATE, in.frameRate);
-
- for (int i = 0; i < in.initializationData.size(); i++) {
- byte[] originalData = in.initializationData.get(i);
- ByteBuffer frameworkBuffer = out.getByteBuffer("csd-" + i);
- byte[] frameworkData = Arrays.copyOf(frameworkBuffer.array(), frameworkBuffer.limit());
- assertThat(frameworkData).isEqualTo(originalData);
- }
- }
-
- @TargetApi(16)
- private static void assertOptionalV16(MediaFormat format, String key, String value) {
- if (value == null) {
- assertThat(format.containsKey(key)).isEqualTo(false);
- } else {
- assertThat(format.getString(key)).isEqualTo(value);
- }
- }
-
- @TargetApi(16)
- private static void assertOptionalV16(MediaFormat format, String key, int value) {
- if (value == Format.NO_VALUE) {
- assertThat(format.containsKey(key)).isEqualTo(false);
- } else {
- assertThat(format.getInteger(key)).isEqualTo(value);
- }
- }
-
- @TargetApi(16)
- private static void assertOptionalV16(MediaFormat format, String key, float value) {
- if (value == Format.NO_VALUE) {
- assertThat(format.containsKey(key)).isEqualTo(false);
- } else {
- assertThat(format.getFloat(key)).isEqualTo(value);
- }
- }
-
}