Commit dbaeecc4 by Oliver Woodman

Improve DASH manifest parsing.

- Parse all attributes that may exist in either the AdaptationSet or
  in the child Representation elements at both levels.
- Correctly infer TYPE_TEXT for Representation elements whose mimeType
  is application/mp4 and whose codecs attribute indicates a known text
  codec type.

Issue: #689
parent d6152dc3
...@@ -272,7 +272,7 @@ public class DashRendererBuilder implements RendererBuilder { ...@@ -272,7 +272,7 @@ public class DashRendererBuilder implements RendererBuilder {
List<String> codecs = new ArrayList<>(); List<String> codecs = new ArrayList<>();
for (int i = 0; i < audioRepresentations.size(); i++) { for (int i = 0; i < audioRepresentations.size(); i++) {
Format format = audioRepresentations.get(i).format; Format format = audioRepresentations.get(i).format;
audioTrackNameList.add(format.id + " (" + format.numChannels + "ch, " + audioTrackNameList.add(format.id + " (" + format.audioChannels + "ch, " +
format.audioSamplingRate + "Hz)"); format.audioSamplingRate + "Hz)");
audioChunkSourceList.add(new DashChunkSource(manifestFetcher, audioAdaptationSetIndex, audioChunkSourceList.add(new DashChunkSource(manifestFetcher, audioAdaptationSetIndex,
new int[] {i}, audioDataSource, audioEvaluator, LIVE_EDGE_LATENCY_MS, new int[] {i}, audioDataSource, audioEvaluator, LIVE_EDGE_LATENCY_MS,
......
...@@ -69,7 +69,7 @@ public class Format { ...@@ -69,7 +69,7 @@ public class Format {
/** /**
* The number of audio channels, or -1 if unknown or not applicable. * The number of audio channels, or -1 if unknown or not applicable.
*/ */
public final int numChannels; public final int audioChannels;
/** /**
* The audio sampling rate in Hz, or -1 if unknown or not applicable. * The audio sampling rate in Hz, or -1 if unknown or not applicable.
...@@ -131,20 +131,20 @@ public class Format { ...@@ -131,20 +131,20 @@ public class Format {
* @param height The height of the video in pixels, or -1 if unknown or not applicable. * @param height The height of the video in pixels, or -1 if unknown or not applicable.
* @param frameRate The frame rate of the video in frames per second, or -1 if unknown or not * @param frameRate The frame rate of the video in frames per second, or -1 if unknown or not
* applicable. * applicable.
* @param numChannels The number of audio channels, or -1 if unknown or not applicable. * @param audioChannels The number of audio channels, or -1 if unknown or not applicable.
* @param audioSamplingRate The audio sampling rate in Hz, or -1 if unknown or not applicable. * @param audioSamplingRate The audio sampling rate in Hz, or -1 if unknown or not applicable.
* @param bitrate The average bandwidth of the format in bits per second. * @param bitrate The average bandwidth of the format in bits per second.
* @param language The language of the format. * @param language The language of the format.
* @param codecs The codecs used to decode the format. * @param codecs The codecs used to decode the format.
*/ */
public Format(String id, String mimeType, int width, int height, float frameRate, int numChannels, public Format(String id, String mimeType, int width, int height, float frameRate,
int audioSamplingRate, int bitrate, String language, String codecs) { int audioChannels, int audioSamplingRate, int bitrate, String language, String codecs) {
this.id = Assertions.checkNotNull(id); this.id = Assertions.checkNotNull(id);
this.mimeType = mimeType; this.mimeType = mimeType;
this.width = width; this.width = width;
this.height = height; this.height = height;
this.frameRate = frameRate; this.frameRate = frameRate;
this.numChannels = numChannels; this.audioChannels = audioChannels;
this.audioSamplingRate = audioSamplingRate; this.audioSamplingRate = audioSamplingRate;
this.bitrate = bitrate; this.bitrate = bitrate;
this.language = language; this.language = language;
......
...@@ -392,10 +392,10 @@ public class SmoothStreamingChunkSource implements ChunkSource { ...@@ -392,10 +392,10 @@ public class SmoothStreamingChunkSource implements ChunkSource {
csd = Arrays.asList(trackElement.csd); csd = Arrays.asList(trackElement.csd);
} else { } else {
csd = Collections.singletonList(CodecSpecificDataUtil.buildAacAudioSpecificConfig( csd = Collections.singletonList(CodecSpecificDataUtil.buildAacAudioSpecificConfig(
trackFormat.audioSamplingRate, trackFormat.numChannels)); trackFormat.audioSamplingRate, trackFormat.audioChannels));
} }
MediaFormat format = MediaFormat.createAudioFormat(mimeType, MediaFormat.NO_VALUE, MediaFormat format = MediaFormat.createAudioFormat(mimeType, MediaFormat.NO_VALUE,
trackFormat.numChannels, trackFormat.audioSamplingRate, csd); trackFormat.audioChannels, trackFormat.audioSamplingRate, csd);
return format; return format;
} else if (streamElement.type == StreamElement.TYPE_TEXT) { } else if (streamElement.type == StreamElement.TYPE_TEXT) {
return MediaFormat.createTextFormat(trackFormat.mimeType, trackFormat.language); return MediaFormat.createTextFormat(trackFormat.mimeType, trackFormat.language);
......
...@@ -50,6 +50,7 @@ public final class MimeTypes { ...@@ -50,6 +50,7 @@ public final class MimeTypes {
public static final String TEXT_VTT = BASE_TYPE_TEXT + "/vtt"; public static final String TEXT_VTT = BASE_TYPE_TEXT + "/vtt";
public static final String APPLICATION_MP4 = BASE_TYPE_APPLICATION + "/mp4";
public static final String APPLICATION_ID3 = BASE_TYPE_APPLICATION + "/id3"; public static final String APPLICATION_ID3 = BASE_TYPE_APPLICATION + "/id3";
public static final String APPLICATION_EIA608 = BASE_TYPE_APPLICATION + "/eia-608"; public static final String APPLICATION_EIA608 = BASE_TYPE_APPLICATION + "/eia-608";
public static final String APPLICATION_SUBRIP = BASE_TYPE_APPLICATION + "/x-subrip"; public static final String APPLICATION_SUBRIP = BASE_TYPE_APPLICATION + "/x-subrip";
...@@ -113,14 +114,4 @@ public final class MimeTypes { ...@@ -113,14 +114,4 @@ public final class MimeTypes {
return getTopLevelType(mimeType).equals(BASE_TYPE_APPLICATION); return getTopLevelType(mimeType).equals(BASE_TYPE_APPLICATION);
} }
/**
* Whether the mimeType is {@link #APPLICATION_TTML}.
*
* @param mimeType The mimeType to test.
* @return Whether the mimeType is {@link #APPLICATION_TTML}.
*/
public static boolean isTtml(String mimeType) {
return mimeType.equals(APPLICATION_TTML);
}
} }
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