Use MP4VTT MIME type in DashManifestParser (again)

We stopped using using this MIME type in
74a9d8f680

This broke subtitle decoding in some cases (Issue: #7985), which I
fixed in
7b8895d655.

After some discussion we've decided SubtitleDecoderFactory shouldn't
depend on Format.containerMimeType (since the samples have already been
extracted by this point, so the container shouldn't matter). So this
change fixes DashManifestParser to use MimeTypes.APPLICATION_MP4VTT (and
reverts the no-longer-needed SubtitleDecoderFactory change).

PiperOrigin-RevId: 336668450
This commit is contained in:
ibaker 2020-10-12 16:32:46 +01:00 committed by Oliver Woodman
parent d4a0dfda77
commit 907d10705a
2 changed files with 8 additions and 11 deletions

View File

@ -91,15 +91,11 @@ public interface SubtitleDecoderFactory {
@Override @Override
public SubtitleDecoder createDecoder(Format format) { public SubtitleDecoder createDecoder(Format format) {
@Nullable String sampleMimeType = format.sampleMimeType; @Nullable String mimeType = format.sampleMimeType;
if (sampleMimeType != null) { if (mimeType != null) {
switch (sampleMimeType) { switch (mimeType) {
case MimeTypes.TEXT_VTT: case MimeTypes.TEXT_VTT:
if (MimeTypes.APPLICATION_MP4.equals(format.containerMimeType)) { return new WebvttDecoder();
return new Mp4WebvttDecoder();
} else {
return new WebvttDecoder();
}
case MimeTypes.TEXT_SSA: case MimeTypes.TEXT_SSA:
return new SsaDecoder(format.initializationData); return new SsaDecoder(format.initializationData);
case MimeTypes.APPLICATION_MP4VTT: case MimeTypes.APPLICATION_MP4VTT:
@ -113,7 +109,7 @@ public interface SubtitleDecoderFactory {
case MimeTypes.APPLICATION_CEA608: case MimeTypes.APPLICATION_CEA608:
case MimeTypes.APPLICATION_MP4CEA608: case MimeTypes.APPLICATION_MP4CEA608:
return new Cea608Decoder( return new Cea608Decoder(
sampleMimeType, mimeType,
format.accessibilityChannel, format.accessibilityChannel,
Cea608Decoder.MIN_DATA_CHANNEL_TIMEOUT_MS); Cea608Decoder.MIN_DATA_CHANNEL_TIMEOUT_MS);
case MimeTypes.APPLICATION_CEA708: case MimeTypes.APPLICATION_CEA708:
@ -127,7 +123,7 @@ public interface SubtitleDecoderFactory {
} }
} }
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Attempted to create decoder for unsupported MIME type: " + sampleMimeType); "Attempted to create decoder for unsupported MIME type: " + mimeType);
} }
}; };
} }

View File

@ -1363,7 +1363,8 @@ public class DashManifestParser extends DefaultHandler
// All other text types are raw formats. // All other text types are raw formats.
return containerMimeType; return containerMimeType;
} else if (MimeTypes.APPLICATION_MP4.equals(containerMimeType)) { } else if (MimeTypes.APPLICATION_MP4.equals(containerMimeType)) {
return MimeTypes.getMediaMimeType(codecs); @Nullable String mimeType = MimeTypes.getMediaMimeType(codecs);
return MimeTypes.TEXT_VTT.equals(mimeType) ? MimeTypes.APPLICATION_MP4VTT : mimeType;
} }
return null; return null;
} }