Merge pull request #8215 from TiVo:p-fix-apple-iframe-bug

PiperOrigin-RevId: 345202157
This commit is contained in:
Oliver Woodman 2020-12-03 17:11:03 +00:00 committed by Ian Baker
parent eb38a63e36
commit 495347d3c0
3 changed files with 24 additions and 0 deletions

View File

@ -101,4 +101,9 @@ public final class BundledHlsMediaChunkExtractor implements HlsMediaChunkExtract
return new BundledHlsMediaChunkExtractor(
newExtractorInstance, masterPlaylistFormat, timestampAdjuster);
}
@Override
public void onTruncatedSegmentParsed() {
extractor.seek(/* position= */ 0, /* timeUs= */ 0);
}
}

View File

@ -403,6 +403,14 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
}
try {
while (!loadCanceled && extractor.read(input)) {}
} catch (EOFException e) {
if ((trackFormat.roleFlags & C.ROLE_FLAG_TRICK_PLAY) != 0) {
// See onTruncatedSegmentParsed's javadoc for more info on why we are swallowing the EOF
// exception for trick play tracks.
extractor.onTruncatedSegmentParsed();
} else {
throw e;
}
} finally {
nextLoadPosition = (int) (input.getPosition() - dataSpec.position);
}

View File

@ -59,4 +59,15 @@ public interface HlsMediaChunkExtractor {
* instances that are not {@link #isReusable() reusable}.
*/
HlsMediaChunkExtractor recreate();
/**
* Resets the sample parsing state.
*
* <p>Resetting the parsing state allows support for Fragmented MP4 EXT-X-I-FRAME-STREAM-INF
* segments. EXT-X-I-FRAME-STREAM-INF segments are truncated to include only a leading key frame.
* After parsing said keyframe, an extractor may reach an unexpected end of file. By resetting its
* state, we can continue feeding samples from the following segments to the extractor. See <a
* href="https://github.com/google/ExoPlayer/issues/7512">#7512</a> for context.
*/
void onTruncatedSegmentParsed();
}