Skip to content

Commit

Permalink
Replace remaining stbl assertions with warnings
Browse files Browse the repository at this point in the history
Issue: #5162
PiperOrigin-RevId: 223193019
  • Loading branch information
andrewlewis authored and ojw28 committed Nov 30, 2018
1 parent 5134477 commit 6d232f5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
3 changes: 3 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
([#5139](https:/google/ExoPlayer/issues/5139)).
* Fix issue where null `Metadata` was output when it failed to decode
([#5149](https:/google/ExoPlayer/issues/5149)).
* Fix playback of some invalid but playable MP4 streams by replacing assertions
with logged warnings in sample table parsing code
([#5162](https:/google/ExoPlayer/issues/5162)).

### 2.9.1 ###

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@ public static TrackSampleTable parseStbl(
sizes = Arrays.copyOf(sizes, sampleCount);
timestamps = Arrays.copyOf(timestamps, sampleCount);
flags = Arrays.copyOf(flags, sampleCount);
remainingSamplesAtTimestampOffset = 0;
remainingTimestampOffsetChanges = 0;
break;
}

Expand Down Expand Up @@ -293,23 +291,38 @@ public static TrackSampleTable parseStbl(
}
duration = timestampTimeUnits + timestampOffset;

Assertions.checkArgument(remainingSamplesAtTimestampOffset == 0);
// Remove trailing ctts entries with 0-valued sample counts.
// If the stbl's child boxes are not consistent the container is malformed, but the stream may
// still be playable.
boolean isCttsValid = true;
while (remainingTimestampOffsetChanges > 0) {
Assertions.checkArgument(ctts.readUnsignedIntToInt() == 0);
if (ctts.readUnsignedIntToInt() != 0) {
isCttsValid = false;
break;
}
ctts.readInt(); // Ignore offset.
remainingTimestampOffsetChanges--;
}

// If the stbl's child boxes are not consistent the container is malformed, but the stream may
// still be playable.
if (remainingSynchronizationSamples != 0 || remainingSamplesAtTimestampDelta != 0
|| remainingSamplesInChunk != 0 || remainingTimestampDeltaChanges != 0) {
Log.w(TAG, "Inconsistent stbl box for track " + track.id
+ ": remainingSynchronizationSamples " + remainingSynchronizationSamples
+ ", remainingSamplesAtTimestampDelta " + remainingSamplesAtTimestampDelta
+ ", remainingSamplesInChunk " + remainingSamplesInChunk
+ ", remainingTimestampDeltaChanges " + remainingTimestampDeltaChanges);
if (remainingSynchronizationSamples != 0
|| remainingSamplesAtTimestampDelta != 0
|| remainingSamplesInChunk != 0
|| remainingTimestampDeltaChanges != 0
|| remainingSamplesAtTimestampOffset != 0
|| !isCttsValid) {
Log.w(
TAG,
"Inconsistent stbl box for track "
+ track.id
+ ": remainingSynchronizationSamples "
+ remainingSynchronizationSamples
+ ", remainingSamplesAtTimestampDelta "
+ remainingSamplesAtTimestampDelta
+ ", remainingSamplesInChunk "
+ remainingSamplesInChunk
+ ", remainingTimestampDeltaChanges "
+ remainingTimestampDeltaChanges
+ ", remainingSamplesAtTimestampOffset "
+ remainingSamplesAtTimestampOffset
+ (!isCttsValid ? ", ctts invalid" : ""));
}
} else {
long[] chunkOffsetsBytes = new long[chunkIterator.length];
Expand Down

0 comments on commit 6d232f5

Please sign in to comment.