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