use of com.google.android.exoplayer2.source.dash.manifest.AdaptationSet in project ExoPlayer by google.
the class DashMediaPeriodTest method cea608AccessibilityDescriptor_createsCea608TrackGroup.
@Test
public void cea608AccessibilityDescriptor_createsCea608TrackGroup() throws IOException {
DashManifest manifest = parseManifest("media/mpd/sample_mpd_cea_608_accessibility");
DashMediaPeriod dashMediaPeriod = createDashMediaPeriod(manifest, 0);
List<AdaptationSet> adaptationSets = manifest.getPeriod(0).adaptationSets;
// We expect two adaptation sets. The first containing the video representations, and the second
// containing the embedded CEA-608 tracks.
Format.Builder cea608FormatBuilder = new Format.Builder().setSampleMimeType(MimeTypes.APPLICATION_CEA608);
TrackGroupArray expectedTrackGroups = new TrackGroupArray(new TrackGroup(/* id= */
"123", adaptationSets.get(0).representations.get(0).format, adaptationSets.get(0).representations.get(1).format), new TrackGroup(/* id= */
"123:cc", cea608FormatBuilder.setId("123:cea608:1").setLanguage("eng").setAccessibilityChannel(1).build(), cea608FormatBuilder.setId("123:cea608:3").setLanguage("deu").setAccessibilityChannel(3).build()));
MediaPeriodAsserts.assertTrackGroups(dashMediaPeriod, expectedTrackGroups);
}
use of com.google.android.exoplayer2.source.dash.manifest.AdaptationSet in project ExoPlayer by google.
the class DashMediaPeriod method getStreamKeys.
@Override
public List<StreamKey> getStreamKeys(List<ExoTrackSelection> trackSelections) {
List<AdaptationSet> manifestAdaptationSets = manifest.getPeriod(periodIndex).adaptationSets;
List<StreamKey> streamKeys = new ArrayList<>();
for (ExoTrackSelection trackSelection : trackSelections) {
int trackGroupIndex = trackGroups.indexOf(trackSelection.getTrackGroup());
TrackGroupInfo trackGroupInfo = trackGroupInfos[trackGroupIndex];
if (trackGroupInfo.trackGroupCategory != TrackGroupInfo.CATEGORY_PRIMARY) {
// Ignore non-primary tracks.
continue;
}
int[] adaptationSetIndices = trackGroupInfo.adaptationSetIndices;
int[] trackIndices = new int[trackSelection.length()];
for (int i = 0; i < trackSelection.length(); i++) {
trackIndices[i] = trackSelection.getIndexInTrackGroup(i);
}
Arrays.sort(trackIndices);
int currentAdaptationSetIndex = 0;
int totalTracksInPreviousAdaptationSets = 0;
int tracksInCurrentAdaptationSet = manifestAdaptationSets.get(adaptationSetIndices[0]).representations.size();
for (int trackIndex : trackIndices) {
while (trackIndex >= totalTracksInPreviousAdaptationSets + tracksInCurrentAdaptationSet) {
currentAdaptationSetIndex++;
totalTracksInPreviousAdaptationSets += tracksInCurrentAdaptationSet;
tracksInCurrentAdaptationSet = manifestAdaptationSets.get(adaptationSetIndices[currentAdaptationSetIndex]).representations.size();
}
streamKeys.add(new StreamKey(periodIndex, adaptationSetIndices[currentAdaptationSetIndex], trackIndex - totalTracksInPreviousAdaptationSets));
}
}
return streamKeys;
}
use of com.google.android.exoplayer2.source.dash.manifest.AdaptationSet in project ExoPlayer by google.
the class DashMediaPeriod method getClosedCaptionTrackFormats.
private static Format[] getClosedCaptionTrackFormats(List<AdaptationSet> adaptationSets, int[] adaptationSetIndices) {
for (int i : adaptationSetIndices) {
AdaptationSet adaptationSet = adaptationSets.get(i);
List<Descriptor> descriptors = adaptationSets.get(i).accessibilityDescriptors;
for (int j = 0; j < descriptors.size(); j++) {
Descriptor descriptor = descriptors.get(j);
if ("urn:scte:dash:cc:cea-608:2015".equals(descriptor.schemeIdUri)) {
Format cea608Format = new Format.Builder().setSampleMimeType(MimeTypes.APPLICATION_CEA608).setId(adaptationSet.id + ":cea608").build();
return parseClosedCaptionDescriptor(descriptor, CEA608_SERVICE_DESCRIPTOR_REGEX, cea608Format);
} else if ("urn:scte:dash:cc:cea-708:2015".equals(descriptor.schemeIdUri)) {
Format cea708Format = new Format.Builder().setSampleMimeType(MimeTypes.APPLICATION_CEA708).setId(adaptationSet.id + ":cea708").build();
return parseClosedCaptionDescriptor(descriptor, CEA708_SERVICE_DESCRIPTOR_REGEX, cea708Format);
}
}
}
return new Format[0];
}
use of com.google.android.exoplayer2.source.dash.manifest.AdaptationSet in project ExoPlayer by google.
the class DashManifest method copyAdaptationSets.
private static ArrayList<AdaptationSet> copyAdaptationSets(List<AdaptationSet> adaptationSets, LinkedList<StreamKey> keys) {
StreamKey key = keys.poll();
int periodIndex = key.periodIndex;
ArrayList<AdaptationSet> copyAdaptationSets = new ArrayList<>();
do {
int adaptationSetIndex = key.groupIndex;
AdaptationSet adaptationSet = adaptationSets.get(adaptationSetIndex);
List<Representation> representations = adaptationSet.representations;
ArrayList<Representation> copyRepresentations = new ArrayList<>();
do {
Representation representation = representations.get(key.streamIndex);
copyRepresentations.add(representation);
key = keys.poll();
} while (key.periodIndex == periodIndex && key.groupIndex == adaptationSetIndex);
copyAdaptationSets.add(new AdaptationSet(adaptationSet.id, adaptationSet.type, copyRepresentations, adaptationSet.accessibilityDescriptors, adaptationSet.essentialProperties, adaptationSet.supplementalProperties));
} while (key.periodIndex == periodIndex);
// Add back the last key which doesn't belong to the period being processed
keys.addFirst(key);
return copyAdaptationSets;
}
use of com.google.android.exoplayer2.source.dash.manifest.AdaptationSet in project ExoPlayer by google.
the class DashManifest method copy.
@Override
public final DashManifest copy(List<StreamKey> streamKeys) {
LinkedList<StreamKey> keys = new LinkedList<>(streamKeys);
Collections.sort(keys);
// Add a stopper key to the end
keys.add(new StreamKey(-1, -1, -1));
ArrayList<Period> copyPeriods = new ArrayList<>();
long shiftMs = 0;
for (int periodIndex = 0; periodIndex < getPeriodCount(); periodIndex++) {
if (keys.peek().periodIndex != periodIndex) {
// No representations selected in this period.
long periodDurationMs = getPeriodDurationMs(periodIndex);
if (periodDurationMs != C.TIME_UNSET) {
shiftMs += periodDurationMs;
}
} else {
Period period = getPeriod(periodIndex);
ArrayList<AdaptationSet> copyAdaptationSets = copyAdaptationSets(period.adaptationSets, keys);
Period copiedPeriod = new Period(period.id, period.startMs - shiftMs, copyAdaptationSets, period.eventStreams);
copyPeriods.add(copiedPeriod);
}
}
long newDuration = durationMs != C.TIME_UNSET ? durationMs - shiftMs : C.TIME_UNSET;
return new DashManifest(availabilityStartTimeMs, newDuration, minBufferTimeMs, dynamic, minUpdatePeriodMs, timeShiftBufferDepthMs, suggestedPresentationDelayMs, publishTimeMs, programInformation, utcTiming, serviceDescription, location, copyPeriods);
}
Aggregations