Format cleanup
This commit is contained in:
parent
41636ada88
commit
05a31dfd24
@ -101,8 +101,15 @@ import com.google.android.gms.cast.MediaTrack;
|
||||
* @return The equivalent {@link Format}.
|
||||
*/
|
||||
public static Format mediaTrackToFormat(MediaTrack mediaTrack) {
|
||||
return Format.createContainerFormat(mediaTrack.getContentId(), mediaTrack.getContentType(),
|
||||
null, null, Format.NO_VALUE, 0, mediaTrack.getLanguage());
|
||||
return Format.createContainerFormat(
|
||||
mediaTrack.getContentId(),
|
||||
/* label= */ null,
|
||||
mediaTrack.getContentType(),
|
||||
/* sampleMimeType= */ null,
|
||||
/* codecs= */ null,
|
||||
/* bitrate= */ Format.NO_VALUE,
|
||||
/* selectionFlags= */ 0,
|
||||
mediaTrack.getLanguage());
|
||||
}
|
||||
|
||||
private CastUtils() {}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -64,10 +64,35 @@ public final class FormatTest {
|
||||
ColorInfo colorInfo = new ColorInfo(C.COLOR_SPACE_BT709,
|
||||
C.COLOR_RANGE_LIMITED, C.COLOR_TRANSFER_SDR, new byte[] {1, 2, 3, 4, 5, 6, 7});
|
||||
|
||||
Format formatToParcel = new Format("id", MimeTypes.VIDEO_MP4, MimeTypes.VIDEO_H264, null,
|
||||
1024, 2048, 1920, 1080, 24, 90, 2, projectionData, C.STEREO_MODE_TOP_BOTTOM, colorInfo, 6,
|
||||
44100, C.ENCODING_PCM_24BIT, 1001, 1002, 0, "und", Format.NO_VALUE,
|
||||
Format.OFFSET_SAMPLE_RELATIVE, INIT_DATA, drmInitData, metadata);
|
||||
Format formatToParcel =
|
||||
new Format(
|
||||
"id",
|
||||
"label",
|
||||
/* containerMimeType= */ MimeTypes.VIDEO_MP4,
|
||||
/* sampleMimeType= */ MimeTypes.VIDEO_H264,
|
||||
"codec",
|
||||
/* bitrate= */ 1024,
|
||||
/* maxInputSize= */ 2048,
|
||||
/* width= */ 1920,
|
||||
/* height= */ 1080,
|
||||
/* frameRate= */ 24,
|
||||
/* rotationDegrees= */ 90,
|
||||
/* pixelWidthHeightRatio= */ 2,
|
||||
projectionData,
|
||||
C.STEREO_MODE_TOP_BOTTOM,
|
||||
colorInfo,
|
||||
/* channelCount= */ 6,
|
||||
/* sampleRate= */ 44100,
|
||||
C.ENCODING_PCM_24BIT,
|
||||
/* encoderDelay= */ 1001,
|
||||
/* encoderPadding= */ 1002,
|
||||
C.SELECTION_FLAG_DEFAULT,
|
||||
"language",
|
||||
/* accessibilityChannel= */ Format.NO_VALUE,
|
||||
Format.OFFSET_SAMPLE_RELATIVE,
|
||||
INIT_DATA,
|
||||
drmInitData,
|
||||
metadata);
|
||||
|
||||
Parcel parcel = Parcel.obtain();
|
||||
formatToParcel.writeToParcel(parcel, 0);
|
||||
|
@ -38,14 +38,15 @@ public final class RawCcExtractorTest {
|
||||
public Extractor create() {
|
||||
return new RawCcExtractor(
|
||||
Format.createTextContainerFormat(
|
||||
null,
|
||||
null,
|
||||
MimeTypes.APPLICATION_CEA608,
|
||||
"cea608",
|
||||
Format.NO_VALUE,
|
||||
0,
|
||||
null,
|
||||
1));
|
||||
/* id= */ null,
|
||||
/* label= */ null,
|
||||
/* containerMimeType= */ null,
|
||||
/* sampleMimeType= */ MimeTypes.APPLICATION_CEA608,
|
||||
/* codecs= */ "cea608",
|
||||
/* bitrate= */ Format.NO_VALUE,
|
||||
/* selectionFlags= */ 0,
|
||||
/* language= */ null,
|
||||
/* accessibilityChannel= */ 1));
|
||||
}
|
||||
},
|
||||
"rawcc/sample.rawcc");
|
||||
|
@ -759,45 +759,12 @@ public final class DefaultTrackSelectorTest {
|
||||
/** Tests text track selection flags. */
|
||||
@Test
|
||||
public void testsTextTrackSelectionFlags() throws ExoPlaybackException {
|
||||
Format forcedOnly =
|
||||
Format.createTextContainerFormat(
|
||||
"forcedOnly",
|
||||
null,
|
||||
MimeTypes.TEXT_VTT,
|
||||
null,
|
||||
Format.NO_VALUE,
|
||||
C.SELECTION_FLAG_FORCED,
|
||||
"eng");
|
||||
Format forcedOnly = buildTextFormat("forcedOnly", "eng", C.SELECTION_FLAG_FORCED);
|
||||
Format forcedDefault =
|
||||
Format.createTextContainerFormat(
|
||||
"forcedDefault",
|
||||
null,
|
||||
MimeTypes.TEXT_VTT,
|
||||
null,
|
||||
Format.NO_VALUE,
|
||||
C.SELECTION_FLAG_FORCED | C.SELECTION_FLAG_DEFAULT,
|
||||
"eng");
|
||||
Format defaultOnly =
|
||||
Format.createTextContainerFormat(
|
||||
"defaultOnly",
|
||||
null,
|
||||
MimeTypes.TEXT_VTT,
|
||||
null,
|
||||
Format.NO_VALUE,
|
||||
C.SELECTION_FLAG_DEFAULT,
|
||||
"eng");
|
||||
Format forcedOnlySpanish =
|
||||
Format.createTextContainerFormat(
|
||||
"forcedOnlySpanish",
|
||||
null,
|
||||
MimeTypes.TEXT_VTT,
|
||||
null,
|
||||
Format.NO_VALUE,
|
||||
C.SELECTION_FLAG_FORCED,
|
||||
"spa");
|
||||
Format noFlag =
|
||||
Format.createTextContainerFormat(
|
||||
"noFlag", null, MimeTypes.TEXT_VTT, null, Format.NO_VALUE, 0, "eng");
|
||||
buildTextFormat("forcedDefault", "eng", C.SELECTION_FLAG_FORCED | C.SELECTION_FLAG_DEFAULT);
|
||||
Format defaultOnly = buildTextFormat("defaultOnly", "eng", C.SELECTION_FLAG_DEFAULT);
|
||||
Format forcedOnlySpanish = buildTextFormat("forcedOnlySpanish", "spa", C.SELECTION_FLAG_FORCED);
|
||||
Format noFlag = buildTextFormat("noFlag", "eng");
|
||||
|
||||
RendererCapabilities[] textRendererCapabilities =
|
||||
new RendererCapabilities[] {ALL_TEXT_FORMAT_SUPPORTED_RENDERER_CAPABILITIES};
|
||||
@ -891,14 +858,10 @@ public final class DefaultTrackSelectorTest {
|
||||
*/
|
||||
@Test
|
||||
public void testSelectUndeterminedTextLanguageAsFallback() throws ExoPlaybackException{
|
||||
Format spanish = Format.createTextContainerFormat("spanish", null,
|
||||
MimeTypes.TEXT_VTT, null, Format.NO_VALUE, 0, "spa");
|
||||
Format german = Format.createTextContainerFormat("german", null,
|
||||
MimeTypes.TEXT_VTT, null, Format.NO_VALUE, 0, "de");
|
||||
Format undeterminedUnd = Format.createTextContainerFormat("undeterminedUnd", null,
|
||||
MimeTypes.TEXT_VTT, null, Format.NO_VALUE, 0, "und");
|
||||
Format undeterminedNull = Format.createTextContainerFormat("undeterminedNull", null,
|
||||
MimeTypes.TEXT_VTT, null, Format.NO_VALUE, 0, null);
|
||||
Format spanish = buildTextFormat("spanish", "spa");
|
||||
Format german = buildTextFormat("german", "de");
|
||||
Format undeterminedUnd = buildTextFormat("undeterminedUnd", "und");
|
||||
Format undeterminedNull = buildTextFormat("undeterminedNull", null);
|
||||
|
||||
RendererCapabilities[] textRendererCapabilites =
|
||||
new RendererCapabilities[] {ALL_TEXT_FORMAT_SUPPORTED_RENDERER_CAPABILITIES};
|
||||
@ -1090,6 +1053,22 @@ public final class DefaultTrackSelectorTest {
|
||||
return new TrackGroupArray(trackGroups);
|
||||
}
|
||||
|
||||
private static Format buildTextFormat(String id, String language) {
|
||||
return buildTextFormat(id, language, /* selectionFlags= */ 0);
|
||||
}
|
||||
|
||||
private static Format buildTextFormat(String id, String language, int selectionFlags) {
|
||||
return Format.createTextContainerFormat(
|
||||
id,
|
||||
/* label= */ null,
|
||||
/* containerMimeType= */ null,
|
||||
/* sampleMimeType= */ MimeTypes.TEXT_VTT,
|
||||
/* codecs= */ null,
|
||||
/* bitrate= */ Format.NO_VALUE,
|
||||
selectionFlags,
|
||||
language);
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link RendererCapabilities} that advertises support for all formats of a given type using
|
||||
* a provided support value. For any format that does not have the given track type,
|
||||
|
@ -247,8 +247,8 @@ public class DashManifestParser extends DefaultHandler
|
||||
int audioChannels = Format.NO_VALUE;
|
||||
int audioSamplingRate = parseInt(xpp, "audioSamplingRate", Format.NO_VALUE);
|
||||
String language = xpp.getAttributeValue(null, "lang");
|
||||
String drmSchemeType = null;
|
||||
String label = xpp.getAttributeValue(null, "label");
|
||||
String drmSchemeType = null;
|
||||
ArrayList<SchemeData> drmSchemeDatas = new ArrayList<>();
|
||||
ArrayList<Descriptor> inbandEventStreams = new ArrayList<>();
|
||||
ArrayList<Descriptor> accessibilityDescriptors = new ArrayList<>();
|
||||
@ -284,9 +284,22 @@ public class DashManifestParser extends DefaultHandler
|
||||
} else if (XmlPullParserUtil.isStartTag(xpp, "SupplementalProperty")) {
|
||||
supplementalProperties.add(parseDescriptor(xpp, "SupplementalProperty"));
|
||||
} else if (XmlPullParserUtil.isStartTag(xpp, "Representation")) {
|
||||
RepresentationInfo representationInfo = parseRepresentation(xpp, baseUrl, mimeType, codecs,
|
||||
width, height, frameRate, audioChannels, audioSamplingRate, language,
|
||||
selectionFlags, accessibilityDescriptors, segmentBase, label);
|
||||
RepresentationInfo representationInfo =
|
||||
parseRepresentation(
|
||||
xpp,
|
||||
baseUrl,
|
||||
label,
|
||||
mimeType,
|
||||
codecs,
|
||||
width,
|
||||
height,
|
||||
frameRate,
|
||||
audioChannels,
|
||||
audioSamplingRate,
|
||||
language,
|
||||
selectionFlags,
|
||||
accessibilityDescriptors,
|
||||
segmentBase);
|
||||
contentType = checkContentTypeConsistency(contentType,
|
||||
getContentType(representationInfo.format));
|
||||
representationInfos.add(representationInfo);
|
||||
@ -453,12 +466,21 @@ public class DashManifestParser extends DefaultHandler
|
||||
|
||||
// Representation parsing.
|
||||
|
||||
protected RepresentationInfo parseRepresentation(XmlPullParser xpp, String baseUrl,
|
||||
String adaptationSetMimeType, String adaptationSetCodecs, int adaptationSetWidth,
|
||||
int adaptationSetHeight, float adaptationSetFrameRate, int adaptationSetAudioChannels,
|
||||
int adaptationSetAudioSamplingRate, String adaptationSetLanguage,
|
||||
protected RepresentationInfo parseRepresentation(
|
||||
XmlPullParser xpp,
|
||||
String baseUrl,
|
||||
String label,
|
||||
String adaptationSetMimeType,
|
||||
String adaptationSetCodecs,
|
||||
int adaptationSetWidth,
|
||||
int adaptationSetHeight,
|
||||
float adaptationSetFrameRate,
|
||||
int adaptationSetAudioChannels,
|
||||
int adaptationSetAudioSamplingRate,
|
||||
String adaptationSetLanguage,
|
||||
@C.SelectionFlags int adaptationSetSelectionFlags,
|
||||
List<Descriptor> adaptationSetAccessibilityDescriptors, SegmentBase segmentBase, String label)
|
||||
List<Descriptor> adaptationSetAccessibilityDescriptors,
|
||||
SegmentBase segmentBase)
|
||||
throws XmlPullParserException, IOException {
|
||||
String id = xpp.getAttributeValue(null, "id");
|
||||
int bandwidth = parseInt(xpp, "bandwidth", Format.NO_VALUE);
|
||||
@ -506,30 +528,74 @@ public class DashManifestParser extends DefaultHandler
|
||||
}
|
||||
} while (!XmlPullParserUtil.isEndTag(xpp, "Representation"));
|
||||
|
||||
Format format = buildFormat(id, mimeType, width, height, frameRate, audioChannels,
|
||||
audioSamplingRate, bandwidth, adaptationSetLanguage, adaptationSetSelectionFlags,
|
||||
adaptationSetAccessibilityDescriptors, codecs, supplementalProperties, label);
|
||||
Format format =
|
||||
buildFormat(
|
||||
id,
|
||||
label,
|
||||
mimeType,
|
||||
width,
|
||||
height,
|
||||
frameRate,
|
||||
audioChannels,
|
||||
audioSamplingRate,
|
||||
bandwidth,
|
||||
adaptationSetLanguage,
|
||||
adaptationSetSelectionFlags,
|
||||
adaptationSetAccessibilityDescriptors,
|
||||
codecs,
|
||||
supplementalProperties);
|
||||
segmentBase = segmentBase != null ? segmentBase : new SingleSegmentBase();
|
||||
|
||||
return new RepresentationInfo(format, baseUrl, segmentBase, drmSchemeType, drmSchemeDatas,
|
||||
inbandEventStreams, Representation.REVISION_ID_DEFAULT);
|
||||
}
|
||||
|
||||
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 label) {
|
||||
protected Format buildFormat(
|
||||
String id,
|
||||
String label,
|
||||
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 sampleMimeType = getSampleMimeType(containerMimeType, codecs);
|
||||
if (sampleMimeType != null) {
|
||||
if (MimeTypes.AUDIO_E_AC3.equals(sampleMimeType)) {
|
||||
sampleMimeType = parseEac3SupplementalProperties(supplementalProperties);
|
||||
}
|
||||
if (MimeTypes.isVideo(sampleMimeType)) {
|
||||
return Format.createVideoContainerFormat(id, containerMimeType, sampleMimeType, codecs,
|
||||
bitrate, width, height, frameRate, null, selectionFlags);
|
||||
return Format.createVideoContainerFormat(
|
||||
id,
|
||||
label,
|
||||
containerMimeType,
|
||||
sampleMimeType,
|
||||
codecs,
|
||||
bitrate,
|
||||
width,
|
||||
height,
|
||||
frameRate,
|
||||
/* initializationData= */ null,
|
||||
selectionFlags);
|
||||
} else if (MimeTypes.isAudio(sampleMimeType)) {
|
||||
return Format.createAudioContainerFormat(id, containerMimeType, sampleMimeType, codecs,
|
||||
bitrate, audioChannels, audioSamplingRate, null, selectionFlags, language, label);
|
||||
return Format.createAudioContainerFormat(
|
||||
id,
|
||||
label,
|
||||
containerMimeType,
|
||||
sampleMimeType,
|
||||
codecs,
|
||||
bitrate,
|
||||
audioChannels,
|
||||
audioSamplingRate,
|
||||
/* initializationData= */ null,
|
||||
selectionFlags,
|
||||
language);
|
||||
} else if (mimeTypeIsRawText(sampleMimeType)) {
|
||||
int accessibilityChannel;
|
||||
if (MimeTypes.APPLICATION_CEA608.equals(sampleMimeType)) {
|
||||
@ -539,12 +605,20 @@ public class DashManifestParser extends DefaultHandler
|
||||
} else {
|
||||
accessibilityChannel = Format.NO_VALUE;
|
||||
}
|
||||
return Format.createTextContainerFormat(id, containerMimeType, sampleMimeType, codecs,
|
||||
bitrate, selectionFlags, language, accessibilityChannel, label);
|
||||
return Format.createTextContainerFormat(
|
||||
id,
|
||||
label,
|
||||
containerMimeType,
|
||||
sampleMimeType,
|
||||
codecs,
|
||||
bitrate,
|
||||
selectionFlags,
|
||||
language,
|
||||
accessibilityChannel);
|
||||
}
|
||||
}
|
||||
return Format.createContainerFormat(id, containerMimeType, sampleMimeType, codecs, bitrate,
|
||||
selectionFlags, language);
|
||||
return Format.createContainerFormat(
|
||||
id, label, containerMimeType, sampleMimeType, codecs, bitrate, selectionFlags, language);
|
||||
}
|
||||
|
||||
protected Representation buildRepresentation(RepresentationInfo representationInfo,
|
||||
|
@ -76,15 +76,16 @@ public final class DashUtilTest {
|
||||
Format format =
|
||||
Format.createVideoContainerFormat(
|
||||
"id",
|
||||
"label",
|
||||
MimeTypes.VIDEO_MP4,
|
||||
MimeTypes.VIDEO_H264,
|
||||
"",
|
||||
/* codecs= */ "",
|
||||
Format.NO_VALUE,
|
||||
1024,
|
||||
768,
|
||||
/* width= */ 1024,
|
||||
/* height= */ 768,
|
||||
Format.NO_VALUE,
|
||||
null,
|
||||
0);
|
||||
/* initializationData= */ null,
|
||||
/* selectionFlags= */ 0);
|
||||
if (drmInitData != null) {
|
||||
format = format.copyWithDrmInitData(drmInitData);
|
||||
}
|
||||
|
@ -32,37 +32,30 @@ public class RepresentationTest {
|
||||
public void testGetCacheKey() {
|
||||
String uri = "http://www.google.com";
|
||||
SegmentBase base = new SingleSegmentBase(new RangedUri(null, 0, 1), 1, 0, 1, 1);
|
||||
Format format =
|
||||
Format.createVideoContainerFormat(
|
||||
"0",
|
||||
MimeTypes.APPLICATION_MP4,
|
||||
null,
|
||||
MimeTypes.VIDEO_H264,
|
||||
2500000,
|
||||
1920,
|
||||
1080,
|
||||
Format.NO_VALUE,
|
||||
null,
|
||||
0);
|
||||
Format format = createVideoContainerFormat("0");
|
||||
Representation representation =
|
||||
Representation.newInstance("test_stream_1", 3, format, uri, base);
|
||||
assertThat(representation.getCacheKey()).isEqualTo("test_stream_1.0.3");
|
||||
|
||||
format =
|
||||
Format.createVideoContainerFormat(
|
||||
"150",
|
||||
MimeTypes.APPLICATION_MP4,
|
||||
null,
|
||||
MimeTypes.VIDEO_H264,
|
||||
2500000,
|
||||
1920,
|
||||
1080,
|
||||
Format.NO_VALUE,
|
||||
null,
|
||||
0);
|
||||
format = createVideoContainerFormat("150");
|
||||
representation =
|
||||
Representation.newInstance(
|
||||
"test_stream_1", Representation.REVISION_ID_DEFAULT, format, uri, base);
|
||||
assertThat(representation.getCacheKey()).isEqualTo("test_stream_1.150.-1");
|
||||
}
|
||||
|
||||
private static Format createVideoContainerFormat(String id) {
|
||||
return Format.createVideoContainerFormat(
|
||||
id,
|
||||
"label",
|
||||
/* containerMimeType= */ MimeTypes.APPLICATION_MP4,
|
||||
/* sampleMimeType= */ MimeTypes.VIDEO_H264,
|
||||
/* codecs= */ null,
|
||||
/* bitrate= */ 2500000,
|
||||
/* width= */ 1920,
|
||||
/* height= */ 1080,
|
||||
/* frameRate= */ Format.NO_VALUE,
|
||||
/* initializationData= */ null,
|
||||
/* selectionFlags= */ 0);
|
||||
}
|
||||
}
|
||||
|
@ -50,8 +50,16 @@ public final class HlsMasterPlaylist extends HlsPlaylist {
|
||||
* @return An HLS url.
|
||||
*/
|
||||
public static HlsUrl createMediaPlaylistHlsUrl(String url) {
|
||||
Format format = Format.createContainerFormat("0", MimeTypes.APPLICATION_M3U8, null, null,
|
||||
Format.NO_VALUE, 0, null);
|
||||
Format format =
|
||||
Format.createContainerFormat(
|
||||
"0",
|
||||
/* label= */ null,
|
||||
MimeTypes.APPLICATION_M3U8,
|
||||
/* sampleMimeType= */ null,
|
||||
/* codecs= */ null,
|
||||
/* bitrate= */ Format.NO_VALUE,
|
||||
/* selectionFlags= */ 0,
|
||||
/* language= */ null);
|
||||
return new HlsUrl(url, format);
|
||||
}
|
||||
|
||||
|
@ -274,8 +274,19 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
||||
}
|
||||
line = iterator.next(); // #EXT-X-STREAM-INF's URI.
|
||||
if (variantUrls.add(line)) {
|
||||
Format format = Format.createVideoContainerFormat(Integer.toString(variants.size()),
|
||||
MimeTypes.APPLICATION_M3U8, null, codecs, bitrate, width, height, frameRate, null, 0);
|
||||
Format format =
|
||||
Format.createVideoContainerFormat(
|
||||
/* id= */ Integer.toString(variants.size()),
|
||||
/* label= */ null,
|
||||
/* containerMimeType= */ MimeTypes.APPLICATION_M3U8,
|
||||
/* sampleMimeType= */ null,
|
||||
codecs,
|
||||
bitrate,
|
||||
width,
|
||||
height,
|
||||
frameRate,
|
||||
/* initializationData= */ null,
|
||||
/* selectionFlags= */ 0);
|
||||
variants.add(new HlsMasterPlaylist.HlsUrl(line, format));
|
||||
}
|
||||
}
|
||||
@ -285,7 +296,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
||||
line = mediaTags.get(i);
|
||||
@C.SelectionFlags int selectionFlags = parseSelectionFlags(line);
|
||||
String uri = parseOptionalStringAttr(line, REGEX_URI);
|
||||
String id = parseStringAttr(line, REGEX_NAME);
|
||||
String name = parseStringAttr(line, REGEX_NAME);
|
||||
String language = parseOptionalStringAttr(line, REGEX_LANGUAGE);
|
||||
String groupId = parseOptionalStringAttr(line, REGEX_GROUP_ID);
|
||||
Format format;
|
||||
@ -293,9 +304,19 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
||||
case TYPE_AUDIO:
|
||||
String codecs = audioGroupIdToCodecs.get(groupId);
|
||||
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, id);
|
||||
format =
|
||||
Format.createAudioContainerFormat(
|
||||
/* id= */ name,
|
||||
/* label= */ name,
|
||||
/* containerMimeType= */ MimeTypes.APPLICATION_M3U8,
|
||||
sampleMimeType,
|
||||
codecs,
|
||||
/* bitrate= */ Format.NO_VALUE,
|
||||
/* channelCount= */ Format.NO_VALUE,
|
||||
/* sampleRate= */ Format.NO_VALUE,
|
||||
/* initializationData= */ null,
|
||||
selectionFlags,
|
||||
language);
|
||||
if (uri == null) {
|
||||
muxedAudioFormat = format;
|
||||
} else {
|
||||
@ -303,8 +324,16 @@ 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, id);
|
||||
format =
|
||||
Format.createTextContainerFormat(
|
||||
/* id= */ name,
|
||||
/* label= */ name,
|
||||
/* containerMimeType= */ MimeTypes.APPLICATION_M3U8,
|
||||
/* sampleMimeType= */ MimeTypes.TEXT_VTT,
|
||||
/* codecs= */ null,
|
||||
/* bitrate= */ Format.NO_VALUE,
|
||||
selectionFlags,
|
||||
language);
|
||||
subtitles.add(new HlsMasterPlaylist.HlsUrl(uri, format));
|
||||
break;
|
||||
case TYPE_CLOSED_CAPTIONS:
|
||||
@ -321,8 +350,17 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
||||
if (muxedCaptionFormats == null) {
|
||||
muxedCaptionFormats = new ArrayList<>();
|
||||
}
|
||||
muxedCaptionFormats.add(Format.createTextContainerFormat(id, null, mimeType, null,
|
||||
Format.NO_VALUE, selectionFlags, language, accessibilityChannel, id));
|
||||
muxedCaptionFormats.add(
|
||||
Format.createTextContainerFormat(
|
||||
/* id= */ name,
|
||||
/* label= */ name,
|
||||
/* containerMimeType= */ null,
|
||||
/* sampleMimeType= */ mimeType,
|
||||
/* codecs= */ null,
|
||||
/* bitrate= */ Format.NO_VALUE,
|
||||
selectionFlags,
|
||||
language,
|
||||
accessibilityChannel));
|
||||
break;
|
||||
default:
|
||||
// Do nothing.
|
||||
|
@ -617,6 +617,7 @@ public class SsManifestParser implements ParsingLoadable.Parser<SsManifest> {
|
||||
public void parseStartTag(XmlPullParser parser) throws ParserException {
|
||||
int type = (Integer) getNormalizedAttribute(KEY_TYPE);
|
||||
String id = parser.getAttributeValue(null, KEY_INDEX);
|
||||
String name = (String) getNormalizedAttribute(KEY_NAME);
|
||||
int bitrate = parseRequiredInt(parser, KEY_BITRATE);
|
||||
String sampleMimeType = fourCCToMimeType(parseRequiredString(parser, KEY_FOUR_CC));
|
||||
|
||||
@ -625,8 +626,19 @@ public class SsManifestParser implements ParsingLoadable.Parser<SsManifest> {
|
||||
int height = parseRequiredInt(parser, KEY_MAX_HEIGHT);
|
||||
List<byte[]> codecSpecificData = buildCodecSpecificData(
|
||||
parser.getAttributeValue(null, KEY_CODEC_PRIVATE_DATA));
|
||||
format = Format.createVideoContainerFormat(id, MimeTypes.VIDEO_MP4, sampleMimeType, null,
|
||||
bitrate, width, height, Format.NO_VALUE, codecSpecificData, 0);
|
||||
format =
|
||||
Format.createVideoContainerFormat(
|
||||
id,
|
||||
name,
|
||||
MimeTypes.VIDEO_MP4,
|
||||
sampleMimeType,
|
||||
/* codecs= */ null,
|
||||
bitrate,
|
||||
width,
|
||||
height,
|
||||
/* frameRate= */ Format.NO_VALUE,
|
||||
codecSpecificData,
|
||||
/* selectionFlags= */ 0);
|
||||
} else if (type == C.TRACK_TYPE_AUDIO) {
|
||||
sampleMimeType = sampleMimeType == null ? MimeTypes.AUDIO_AAC : sampleMimeType;
|
||||
int channels = parseRequiredInt(parser, KEY_CHANNELS);
|
||||
@ -638,17 +650,42 @@ 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, label);
|
||||
format =
|
||||
Format.createAudioContainerFormat(
|
||||
id,
|
||||
name,
|
||||
MimeTypes.AUDIO_MP4,
|
||||
sampleMimeType,
|
||||
/* codecs= */ null,
|
||||
bitrate,
|
||||
channels,
|
||||
samplingRate,
|
||||
codecSpecificData,
|
||||
/* selectionFlags= */ 0,
|
||||
language);
|
||||
} 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, label);
|
||||
format =
|
||||
Format.createTextContainerFormat(
|
||||
id,
|
||||
name,
|
||||
MimeTypes.APPLICATION_MP4,
|
||||
sampleMimeType,
|
||||
/* codecs= */ null,
|
||||
bitrate,
|
||||
/* selectionFlags= */ 0,
|
||||
language);
|
||||
} else {
|
||||
format = Format.createContainerFormat(id, MimeTypes.APPLICATION_MP4, sampleMimeType, null,
|
||||
bitrate, 0, null);
|
||||
format =
|
||||
Format.createContainerFormat(
|
||||
id,
|
||||
name,
|
||||
MimeTypes.APPLICATION_MP4,
|
||||
sampleMimeType,
|
||||
/* codecs= */ null,
|
||||
bitrate,
|
||||
/* selectionFlags= */ 0,
|
||||
/* language= */ null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,6 +135,13 @@ public class SsManifestTest {
|
||||
|
||||
private static Format newFormat(String id) {
|
||||
return Format.createContainerFormat(
|
||||
id, MimeTypes.VIDEO_MP4, MimeTypes.VIDEO_H264, null, Format.NO_VALUE, 0, null);
|
||||
id,
|
||||
/* label= */ null,
|
||||
MimeTypes.VIDEO_MP4,
|
||||
MimeTypes.VIDEO_H264,
|
||||
/* codecs= */ null,
|
||||
/* bitrate= */ Format.NO_VALUE,
|
||||
/* selectionFlags= */ 0,
|
||||
/* language= */ null);
|
||||
}
|
||||
}
|
||||
|
@ -88,9 +88,6 @@ 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)
|
||||
? ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user