Commit cd9041c0 by Itay Kinnrot Committed by itay.kinnrot

Parse the label of audio and text from stream and add it to Format type + add it…

Parse the label of audio and text from stream and add it to Format type + add it to default ui + update from dev-v2
parent 5725a727
...@@ -248,6 +248,7 @@ public class DashManifestParser extends DefaultHandler ...@@ -248,6 +248,7 @@ public class DashManifestParser extends DefaultHandler
int audioSamplingRate = parseInt(xpp, "audioSamplingRate", Format.NO_VALUE); int audioSamplingRate = parseInt(xpp, "audioSamplingRate", Format.NO_VALUE);
String language = xpp.getAttributeValue(null, "lang"); String language = xpp.getAttributeValue(null, "lang");
String drmSchemeType = null; String drmSchemeType = null;
String label = xpp.getAttributeValue(null, "label");
ArrayList<SchemeData> drmSchemeDatas = new ArrayList<>(); ArrayList<SchemeData> drmSchemeDatas = new ArrayList<>();
ArrayList<Descriptor> inbandEventStreams = new ArrayList<>(); ArrayList<Descriptor> inbandEventStreams = new ArrayList<>();
ArrayList<Descriptor> accessibilityDescriptors = new ArrayList<>(); ArrayList<Descriptor> accessibilityDescriptors = new ArrayList<>();
...@@ -285,7 +286,7 @@ public class DashManifestParser extends DefaultHandler ...@@ -285,7 +286,7 @@ public class DashManifestParser extends DefaultHandler
} else if (XmlPullParserUtil.isStartTag(xpp, "Representation")) { } else if (XmlPullParserUtil.isStartTag(xpp, "Representation")) {
RepresentationInfo representationInfo = parseRepresentation(xpp, baseUrl, mimeType, codecs, RepresentationInfo representationInfo = parseRepresentation(xpp, baseUrl, mimeType, codecs,
width, height, frameRate, audioChannels, audioSamplingRate, language, width, height, frameRate, audioChannels, audioSamplingRate, language,
selectionFlags, accessibilityDescriptors, segmentBase); selectionFlags, accessibilityDescriptors, segmentBase, label);
contentType = checkContentTypeConsistency(contentType, contentType = checkContentTypeConsistency(contentType,
getContentType(representationInfo.format)); getContentType(representationInfo.format));
representationInfos.add(representationInfo); representationInfos.add(representationInfo);
...@@ -451,7 +452,7 @@ public class DashManifestParser extends DefaultHandler ...@@ -451,7 +452,7 @@ public class DashManifestParser extends DefaultHandler
int adaptationSetHeight, float adaptationSetFrameRate, int adaptationSetAudioChannels, int adaptationSetHeight, float adaptationSetFrameRate, int adaptationSetAudioChannels,
int adaptationSetAudioSamplingRate, String adaptationSetLanguage, int adaptationSetAudioSamplingRate, String adaptationSetLanguage,
@C.SelectionFlags int adaptationSetSelectionFlags, @C.SelectionFlags int adaptationSetSelectionFlags,
List<Descriptor> adaptationSetAccessibilityDescriptors, SegmentBase segmentBase) List<Descriptor> adaptationSetAccessibilityDescriptors, SegmentBase segmentBase, String label)
throws XmlPullParserException, IOException { throws XmlPullParserException, IOException {
String id = xpp.getAttributeValue(null, "id"); String id = xpp.getAttributeValue(null, "id");
int bandwidth = parseInt(xpp, "bandwidth", Format.NO_VALUE); int bandwidth = parseInt(xpp, "bandwidth", Format.NO_VALUE);
...@@ -501,7 +502,7 @@ public class DashManifestParser extends DefaultHandler ...@@ -501,7 +502,7 @@ public class DashManifestParser extends DefaultHandler
Format format = buildFormat(id, mimeType, width, height, frameRate, audioChannels, Format format = buildFormat(id, mimeType, width, height, frameRate, audioChannels,
audioSamplingRate, bandwidth, adaptationSetLanguage, adaptationSetSelectionFlags, audioSamplingRate, bandwidth, adaptationSetLanguage, adaptationSetSelectionFlags,
adaptationSetAccessibilityDescriptors, codecs, supplementalProperties); adaptationSetAccessibilityDescriptors, codecs, supplementalProperties, label);
segmentBase = segmentBase != null ? segmentBase : new SingleSegmentBase(); segmentBase = segmentBase != null ? segmentBase : new SingleSegmentBase();
return new RepresentationInfo(format, baseUrl, segmentBase, drmSchemeType, drmSchemeDatas, return new RepresentationInfo(format, baseUrl, segmentBase, drmSchemeType, drmSchemeDatas,
...@@ -511,7 +512,7 @@ public class DashManifestParser extends DefaultHandler ...@@ -511,7 +512,7 @@ public class DashManifestParser extends DefaultHandler
protected Format buildFormat(String id, String containerMimeType, int width, int height, protected Format buildFormat(String id, String containerMimeType, int width, int height,
float frameRate, int audioChannels, int audioSamplingRate, int bitrate, String language, float frameRate, int audioChannels, int audioSamplingRate, int bitrate, String language,
@C.SelectionFlags int selectionFlags, List<Descriptor> accessibilityDescriptors, @C.SelectionFlags int selectionFlags, List<Descriptor> accessibilityDescriptors,
String codecs, List<Descriptor> supplementalProperties) { String codecs, List<Descriptor> supplementalProperties, String label) {
String sampleMimeType = getSampleMimeType(containerMimeType, codecs); String sampleMimeType = getSampleMimeType(containerMimeType, codecs);
if (sampleMimeType != null) { if (sampleMimeType != null) {
if (MimeTypes.AUDIO_E_AC3.equals(sampleMimeType)) { if (MimeTypes.AUDIO_E_AC3.equals(sampleMimeType)) {
...@@ -522,7 +523,7 @@ public class DashManifestParser extends DefaultHandler ...@@ -522,7 +523,7 @@ public class DashManifestParser extends DefaultHandler
bitrate, width, height, frameRate, null, selectionFlags); bitrate, width, height, frameRate, null, selectionFlags);
} else if (MimeTypes.isAudio(sampleMimeType)) { } else if (MimeTypes.isAudio(sampleMimeType)) {
return Format.createAudioContainerFormat(id, containerMimeType, sampleMimeType, codecs, return Format.createAudioContainerFormat(id, containerMimeType, sampleMimeType, codecs,
bitrate, audioChannels, audioSamplingRate, null, selectionFlags, language); bitrate, audioChannels, audioSamplingRate, null, selectionFlags, language, label);
} else if (mimeTypeIsRawText(sampleMimeType)) { } else if (mimeTypeIsRawText(sampleMimeType)) {
int accessibilityChannel; int accessibilityChannel;
if (MimeTypes.APPLICATION_CEA608.equals(sampleMimeType)) { if (MimeTypes.APPLICATION_CEA608.equals(sampleMimeType)) {
...@@ -533,7 +534,7 @@ public class DashManifestParser extends DefaultHandler ...@@ -533,7 +534,7 @@ public class DashManifestParser extends DefaultHandler
accessibilityChannel = Format.NO_VALUE; accessibilityChannel = Format.NO_VALUE;
} }
return Format.createTextContainerFormat(id, containerMimeType, sampleMimeType, codecs, return Format.createTextContainerFormat(id, containerMimeType, sampleMimeType, codecs,
bitrate, selectionFlags, language, accessibilityChannel); bitrate, selectionFlags, language, accessibilityChannel, label);
} }
} }
return Format.createContainerFormat(id, containerMimeType, sampleMimeType, codecs, bitrate, return Format.createContainerFormat(id, containerMimeType, sampleMimeType, codecs, bitrate,
......
...@@ -288,7 +288,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli ...@@ -288,7 +288,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
String sampleMimeType = codecs != null ? MimeTypes.getMediaMimeType(codecs) : null; String sampleMimeType = codecs != null ? MimeTypes.getMediaMimeType(codecs) : null;
format = Format.createAudioContainerFormat(id, MimeTypes.APPLICATION_M3U8, sampleMimeType, format = Format.createAudioContainerFormat(id, MimeTypes.APPLICATION_M3U8, sampleMimeType,
codecs, Format.NO_VALUE, Format.NO_VALUE, Format.NO_VALUE, null, selectionFlags, codecs, Format.NO_VALUE, Format.NO_VALUE, Format.NO_VALUE, null, selectionFlags,
language); language, id);
if (uri == null) { if (uri == null) {
muxedAudioFormat = format; muxedAudioFormat = format;
} else { } else {
...@@ -297,7 +297,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli ...@@ -297,7 +297,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
break; break;
case TYPE_SUBTITLES: case TYPE_SUBTITLES:
format = Format.createTextContainerFormat(id, MimeTypes.APPLICATION_M3U8, format = Format.createTextContainerFormat(id, MimeTypes.APPLICATION_M3U8,
MimeTypes.TEXT_VTT, null, Format.NO_VALUE, selectionFlags, language); MimeTypes.TEXT_VTT, null, Format.NO_VALUE, selectionFlags, language, id);
subtitles.add(new HlsMasterPlaylist.HlsUrl(uri, format)); subtitles.add(new HlsMasterPlaylist.HlsUrl(uri, format));
break; break;
case TYPE_CLOSED_CAPTIONS: case TYPE_CLOSED_CAPTIONS:
...@@ -315,7 +315,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli ...@@ -315,7 +315,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
muxedCaptionFormats = new ArrayList<>(); muxedCaptionFormats = new ArrayList<>();
} }
muxedCaptionFormats.add(Format.createTextContainerFormat(id, null, mimeType, null, muxedCaptionFormats.add(Format.createTextContainerFormat(id, null, mimeType, null,
Format.NO_VALUE, selectionFlags, language, accessibilityChannel)); Format.NO_VALUE, selectionFlags, language, accessibilityChannel, id));
break; break;
default: default:
// Do nothing. // Do nothing.
......
...@@ -603,6 +603,7 @@ public class SsManifestParser implements ParsingLoadable.Parser<SsManifest> { ...@@ -603,6 +603,7 @@ public class SsManifestParser implements ParsingLoadable.Parser<SsManifest> {
private static final String KEY_FOUR_CC = "FourCC"; private static final String KEY_FOUR_CC = "FourCC";
private static final String KEY_TYPE = "Type"; private static final String KEY_TYPE = "Type";
private static final String KEY_LANGUAGE = "Language"; private static final String KEY_LANGUAGE = "Language";
private static final String KEY_NAME = "Name";
private static final String KEY_MAX_WIDTH = "MaxWidth"; private static final String KEY_MAX_WIDTH = "MaxWidth";
private static final String KEY_MAX_HEIGHT = "MaxHeight"; private static final String KEY_MAX_HEIGHT = "MaxHeight";
...@@ -637,12 +638,14 @@ public class SsManifestParser implements ParsingLoadable.Parser<SsManifest> { ...@@ -637,12 +638,14 @@ public class SsManifestParser implements ParsingLoadable.Parser<SsManifest> {
CodecSpecificDataUtil.buildAacLcAudioSpecificConfig(samplingRate, channels)); CodecSpecificDataUtil.buildAacLcAudioSpecificConfig(samplingRate, channels));
} }
String language = (String) getNormalizedAttribute(KEY_LANGUAGE); String language = (String) getNormalizedAttribute(KEY_LANGUAGE);
String label = (String) getNormalizedAttribute(KEY_NAME);
format = Format.createAudioContainerFormat(id, MimeTypes.AUDIO_MP4, sampleMimeType, null, format = Format.createAudioContainerFormat(id, MimeTypes.AUDIO_MP4, sampleMimeType, null,
bitrate, channels, samplingRate, codecSpecificData, 0, language); bitrate, channels, samplingRate, codecSpecificData, 0, language, label);
} else if (type == C.TRACK_TYPE_TEXT) { } else if (type == C.TRACK_TYPE_TEXT) {
String language = (String) getNormalizedAttribute(KEY_LANGUAGE); String language = (String) getNormalizedAttribute(KEY_LANGUAGE);
String label = (String) getNormalizedAttribute(KEY_NAME);
format = Format.createTextContainerFormat(id, MimeTypes.APPLICATION_MP4, sampleMimeType, format = Format.createTextContainerFormat(id, MimeTypes.APPLICATION_MP4, sampleMimeType,
null, bitrate, 0, language); null, bitrate, 0, language, label);
} else { } else {
format = Format.createContainerFormat(id, MimeTypes.APPLICATION_MP4, sampleMimeType, null, format = Format.createContainerFormat(id, MimeTypes.APPLICATION_MP4, sampleMimeType, null,
bitrate, 0, null); bitrate, 0, null);
......
...@@ -88,6 +88,9 @@ public class DefaultTrackNameProvider implements TrackNameProvider { ...@@ -88,6 +88,9 @@ public class DefaultTrackNameProvider implements TrackNameProvider {
} }
private String buildLanguageString(Format format) { private String buildLanguageString(Format format) {
if ( !TextUtils.isEmpty(format.label) ){
return format.label;
}
String language = format.language; String language = format.language;
return TextUtils.isEmpty(language) || C.LANGUAGE_UNDETERMINED.equals(language) return TextUtils.isEmpty(language) || C.LANGUAGE_UNDETERMINED.equals(language)
? "" ? ""
......
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