Workaround missing data offsets in FMP4

If they're omitted, it's reasonable to assume it's because
they were uninteresting (i.e. sample data always tightly
packed at the start of the mdat). This is an issue for some
SmoothStreaming streams.

We actually already play such streams successfully, but
that's only due to another bug to be fixed in a following CL.
The same is true for V1, but given the low impact nature,
the fix will be V2 only.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=131191975
This commit is contained in:
olly 2016-08-24 10:57:44 -07:00 committed by Oliver Woodman
parent abaa4f1aad
commit 0b6a93b468
2 changed files with 12 additions and 1 deletions

View File

@ -246,6 +246,7 @@ public final class FragmentedMp4Extractor implements Extractor {
int trackCount = trackBundles.size(); int trackCount = trackBundles.size();
for (int i = 0; i < trackCount; i++) { for (int i = 0; i < trackCount; i++) {
TrackFragment fragment = trackBundles.valueAt(i).fragment; TrackFragment fragment = trackBundles.valueAt(i).fragment;
fragment.atomPosition = atomPosition;
fragment.auxiliaryDataPosition = atomPosition; fragment.auxiliaryDataPosition = atomPosition;
fragment.dataPosition = atomPosition; fragment.dataPosition = atomPosition;
} }
@ -935,7 +936,13 @@ public final class FragmentedMp4Extractor implements Extractor {
// We skip bytes preceding the next sample to read. // We skip bytes preceding the next sample to read.
int bytesToSkip = (int) (nextDataPosition - input.getPosition()); int bytesToSkip = (int) (nextDataPosition - input.getPosition());
if (bytesToSkip < 0) { if (bytesToSkip < 0) {
throw new ParserException("Offset to sample data was negative."); if (nextDataPosition == currentTrackBundle.fragment.atomPosition) {
// Assume the sample data must be contiguous in the mdat with no preceeding data.
Log.w(TAG, "Offset to sample data was missing.");
bytesToSkip = 0;
} else {
throw new ParserException("Offset to sample data was negative.");
}
} }
input.skipFully(bytesToSkip); input.skipFully(bytesToSkip);
this.currentTrackBundle = currentTrackBundle; this.currentTrackBundle = currentTrackBundle;

View File

@ -28,6 +28,10 @@ import java.io.IOException;
* The default values for samples from the track fragment header. * The default values for samples from the track fragment header.
*/ */
public DefaultSampleValues header; public DefaultSampleValues header;
/**
* The position (byte offset) of the start of fragment.
*/
public long atomPosition;
/** /**
* The position (byte offset) of the start of data contained in the fragment. * The position (byte offset) of the start of data contained in the fragment.
*/ */