Add MediaParser-based implementation of ChunkExtractor

PiperOrigin-RevId: 315720712
This commit is contained in:
aquilescanta 2020-06-10 18:42:53 +01:00 committed by Oliver Woodman
parent 3ce57ae2e8
commit e7da26368a
2 changed files with 12 additions and 6 deletions

View File

@ -529,6 +529,16 @@ public final class MimeTypes {
}
}
/** Returns whether the given {@code mimeType} is a WebM MIME type. */
public static boolean isWebm(@Nullable String mimeType) {
if (mimeType == null) {
return false;
}
return mimeType.startsWith(MimeTypes.VIDEO_WEBM)
|| mimeType.startsWith(MimeTypes.AUDIO_WEBM)
|| mimeType.startsWith(MimeTypes.APPLICATION_WEBM);
}
/**
* Returns the top-level type of {@code mimeType}, or null if {@code mimeType} is null or does not
* contain a forward slash character ({@code '/'}).

View File

@ -771,11 +771,6 @@ public class DefaultDashChunkSource implements DashChunkSource {
return getFirstSegmentNum() + availableSegmentCount - 1;
}
private static boolean mimeTypeIsWebm(String mimeType) {
return mimeType.startsWith(MimeTypes.VIDEO_WEBM) || mimeType.startsWith(MimeTypes.AUDIO_WEBM)
|| mimeType.startsWith(MimeTypes.APPLICATION_WEBM);
}
@Nullable
private static ChunkExtractor createChunkExtractor(
int trackType,
@ -784,6 +779,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
List<Format> closedCaptionFormats,
@Nullable TrackOutput playerEmsgTrackOutput) {
String containerMimeType = representation.format.containerMimeType;
Extractor extractor;
if (MimeTypes.isText(containerMimeType)) {
if (MimeTypes.APPLICATION_RAWCC.equals(containerMimeType)) {
@ -793,7 +789,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
// All other text types are raw formats that do not need an extractor.
return null;
}
} else if (mimeTypeIsWebm(containerMimeType)) {
} else if (MimeTypes.isWebm(containerMimeType)) {
extractor = new MatroskaExtractor(MatroskaExtractor.FLAG_DISABLE_SEEK_FOR_CUES);
} else {
int flags = 0;