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.
This commit is contained in:
Oliver Woodman 2014-08-12 21:35:13 +01:00
parent 5cfa9adacc
commit af6e144adc
2 changed files with 20 additions and 7 deletions

View File

@ -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++) {

View File

@ -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();