Commit 1c09af02 by andrewlewis Committed by Oliver Woodman

Fix handling of text codecs strings in DashManifestParser

Also fix an NPE in FfmpegAudioRenderer if sampleMimeType wasn't set.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=208230947
parent 9d14a3b3
...@@ -95,7 +95,7 @@ public final class FfmpegAudioRenderer extends SimpleDecoderAudioRenderer { ...@@ -95,7 +95,7 @@ public final class FfmpegAudioRenderer extends SimpleDecoderAudioRenderer {
protected int supportsFormatInternal(DrmSessionManager<ExoMediaCrypto> drmSessionManager, protected int supportsFormatInternal(DrmSessionManager<ExoMediaCrypto> drmSessionManager,
Format format) { Format format) {
Assertions.checkNotNull(format.sampleMimeType); Assertions.checkNotNull(format.sampleMimeType);
if (!FfmpegLibrary.isAvailable() || !MimeTypes.isAudio(format.sampleMimeType)) { if (!FfmpegLibrary.isAvailable()) {
return FORMAT_UNSUPPORTED_TYPE; return FORMAT_UNSUPPORTED_TYPE;
} else if (!FfmpegLibrary.supportsFormat(format.sampleMimeType, format.pcmEncoding) } else if (!FfmpegLibrary.supportsFormat(format.sampleMimeType, format.pcmEncoding)
|| !isOutputSupported(format)) { || !isOutputSupported(format)) {
......
...@@ -218,6 +218,9 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements ...@@ -218,6 +218,9 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
@Override @Override
public final int supportsFormat(Format format) { public final int supportsFormat(Format format) {
if (!MimeTypes.isAudio(format.sampleMimeType)) {
return FORMAT_UNSUPPORTED_TYPE;
}
int formatSupport = supportsFormatInternal(drmSessionManager, format); int formatSupport = supportsFormatInternal(drmSessionManager, format);
if (formatSupport <= FORMAT_UNSUPPORTED_DRM) { if (formatSupport <= FORMAT_UNSUPPORTED_DRM) {
return formatSupport; return formatSupport;
...@@ -227,15 +230,15 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements ...@@ -227,15 +230,15 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
} }
/** /**
* Returns the {@link #FORMAT_SUPPORT_MASK} component of the return value for * Returns the {@link #FORMAT_SUPPORT_MASK} component of the return value for {@link
* {@link #supportsFormat(Format)}. * #supportsFormat(Format)}.
* *
* @param drmSessionManager The renderer's {@link DrmSessionManager}. * @param drmSessionManager The renderer's {@link DrmSessionManager}.
* @param format The format. * @param format The format, which has an audio {@link Format#sampleMimeType}.
* @return The extent to which the renderer supports the format itself. * @return The extent to which the renderer supports the format itself.
*/ */
protected abstract int supportsFormatInternal(DrmSessionManager<ExoMediaCrypto> drmSessionManager, protected abstract int supportsFormatInternal(
Format format); DrmSessionManager<ExoMediaCrypto> drmSessionManager, Format format);
/** /**
* Returns whether the audio sink can accept audio in the specified encoding. * Returns whether the audio sink can accept audio in the specified encoding.
......
...@@ -1022,10 +1022,12 @@ public class DashManifestParser extends DefaultHandler ...@@ -1022,10 +1022,12 @@ public class DashManifestParser extends DefaultHandler
} else if (mimeTypeIsRawText(containerMimeType)) { } else if (mimeTypeIsRawText(containerMimeType)) {
return containerMimeType; return containerMimeType;
} else if (MimeTypes.APPLICATION_MP4.equals(containerMimeType)) { } else if (MimeTypes.APPLICATION_MP4.equals(containerMimeType)) {
if ("stpp".equals(codecs)) { if (codecs != null) {
return MimeTypes.APPLICATION_TTML; if (codecs.startsWith("stpp")) {
} else if ("wvtt".equals(codecs)) { return MimeTypes.APPLICATION_TTML;
return MimeTypes.APPLICATION_MP4VTT; } else if (codecs.startsWith("wvtt")) {
return MimeTypes.APPLICATION_MP4VTT;
}
} }
} else if (MimeTypes.APPLICATION_RAWCC.equals(containerMimeType)) { } else if (MimeTypes.APPLICATION_RAWCC.equals(containerMimeType)) {
if (codecs != null) { if (codecs != null) {
......
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