Commit af6e144a by Oliver Woodman

Fix bug introduced supporting self-contained media chunks.

The equals check we perform needs to ignore the max dimensions.
This tended to work in practice because formats would be the
same object, but in the case where different format objects
are used, things can break.
parent 5cfa9ada
...@@ -148,12 +148,25 @@ public class MediaFormat { ...@@ -148,12 +148,25 @@ public class MediaFormat {
if (obj == null || getClass() != obj.getClass()) { if (obj == null || getClass() != obj.getClass()) {
return false; return false;
} }
MediaFormat other = (MediaFormat) obj; return equalsInternal((MediaFormat) obj, false);
if (maxInputSize != other.maxInputSize || width != other.width || height != other.height || }
maxWidth != other.maxWidth || maxHeight != other.maxHeight ||
channelCount != other.channelCount || sampleRate != other.sampleRate || public boolean equals(MediaFormat other, boolean ignoreMaxDimensions) {
!Util.areEqual(mimeType, other.mimeType) || if (this == other) {
initializationData.size() != other.initializationData.size()) { 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; return false;
} }
for (int i = 0; i < initializationData.size(); i++) { for (int i = 0; i < initializationData.size(); i++) {
......
...@@ -319,7 +319,7 @@ public class ChunkSampleSource implements SampleSource, Loader.Listener { ...@@ -319,7 +319,7 @@ public class ChunkSampleSource implements SampleSource, Loader.Listener {
} }
MediaFormat mediaFormat = mediaChunk.getMediaFormat(); MediaFormat mediaFormat = mediaChunk.getMediaFormat();
if (mediaFormat != null && !mediaFormat.equals(downstreamMediaFormat)) { if (mediaFormat != null && !mediaFormat.equals(downstreamMediaFormat, true)) {
chunkSource.getMaxVideoDimensions(mediaFormat); chunkSource.getMaxVideoDimensions(mediaFormat);
formatHolder.format = mediaFormat; formatHolder.format = mediaFormat;
formatHolder.drmInitData = mediaChunk.getPsshInfo(); formatHolder.drmInitData = mediaChunk.getPsshInfo();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment