mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
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:
parent
5cfa9adacc
commit
af6e144adc
@ -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 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user