diff --git a/library/src/main/java/com/google/android/exoplayer/MediaFormat.java b/library/src/main/java/com/google/android/exoplayer/MediaFormat.java index f53defdf93..3188e36db0 100644 --- a/library/src/main/java/com/google/android/exoplayer/MediaFormat.java +++ b/library/src/main/java/com/google/android/exoplayer/MediaFormat.java @@ -148,12 +148,25 @@ public class MediaFormat { if (obj == null || getClass() != obj.getClass()) { return false; } - MediaFormat other = (MediaFormat) obj; - if (maxInputSize != other.maxInputSize || width != other.width || height != other.height || - maxWidth != other.maxWidth || maxHeight != other.maxHeight || - channelCount != other.channelCount || sampleRate != other.sampleRate || - !Util.areEqual(mimeType, other.mimeType) || - initializationData.size() != other.initializationData.size()) { + return equalsInternal((MediaFormat) obj, false); + } + + public boolean equals(MediaFormat other, boolean ignoreMaxDimensions) { + if (this == other) { + return true; + } + if (other == null) { + return false; + } + return equalsInternal(other, ignoreMaxDimensions); + } + + private boolean equalsInternal(MediaFormat other, boolean ignoreMaxDimensions) { + if (maxInputSize != other.maxInputSize || width != other.width || height != other.height + || (!ignoreMaxDimensions && (maxWidth != other.maxWidth || maxHeight != other.maxHeight)) + || channelCount != other.channelCount || sampleRate != other.sampleRate + || !Util.areEqual(mimeType, other.mimeType) + || initializationData.size() != other.initializationData.size()) { return false; } for (int i = 0; i < initializationData.size(); i++) { diff --git a/library/src/main/java/com/google/android/exoplayer/chunk/ChunkSampleSource.java b/library/src/main/java/com/google/android/exoplayer/chunk/ChunkSampleSource.java index 860de3c179..069f5c69dc 100644 --- a/library/src/main/java/com/google/android/exoplayer/chunk/ChunkSampleSource.java +++ b/library/src/main/java/com/google/android/exoplayer/chunk/ChunkSampleSource.java @@ -319,7 +319,7 @@ public class ChunkSampleSource implements SampleSource, Loader.Listener { } MediaFormat mediaFormat = mediaChunk.getMediaFormat(); - if (mediaFormat != null && !mediaFormat.equals(downstreamMediaFormat)) { + if (mediaFormat != null && !mediaFormat.equals(downstreamMediaFormat, true)) { chunkSource.getMaxVideoDimensions(mediaFormat); formatHolder.format = mediaFormat; formatHolder.drmInitData = mediaChunk.getPsshInfo();