Commit 0b6a93b4 by olly Committed by Oliver Woodman

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
parent abaa4f1a
...@@ -246,6 +246,7 @@ public final class FragmentedMp4Extractor implements Extractor { ...@@ -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,8 +936,14 @@ public final class FragmentedMp4Extractor implements Extractor { ...@@ -935,8 +936,14 @@ 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) {
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."); throw new ParserException("Offset to sample data was negative.");
} }
}
input.skipFully(bytesToSkip); input.skipFully(bytesToSkip);
this.currentTrackBundle = currentTrackBundle; this.currentTrackBundle = currentTrackBundle;
} }
......
...@@ -29,6 +29,10 @@ import java.io.IOException; ...@@ -29,6 +29,10 @@ import java.io.IOException;
*/ */
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.
*/ */
public long dataPosition; public long dataPosition;
......
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