use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.
the class FakeMediaSource method createPeriod.
@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator, long startPositionUs) {
assertThat(preparedSource).isTrue();
assertThat(releasedSource).isFalse();
int periodIndex = castNonNull(timeline).getIndexOfPeriod(id.periodUid);
Assertions.checkArgument(periodIndex != C.INDEX_UNSET);
Period period = timeline.getPeriod(periodIndex, new Period());
MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher = createEventDispatcher(period.windowIndex, id, period.getPositionInWindowMs());
DrmSessionEventListener.EventDispatcher drmEventDispatcher = createDrmEventDispatcher(period.windowIndex, id);
MediaPeriod mediaPeriod = createMediaPeriod(id, trackGroupArray, allocator, mediaSourceEventDispatcher, drmSessionManager, drmEventDispatcher, transferListener);
activeMediaPeriods.add(mediaPeriod);
createdMediaPeriods.add(id);
return mediaPeriod;
}
use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.
the class FakeTrackSelector method selectAllTracks.
@Override
protected ExoTrackSelection.@NullableType Definition[] selectAllTracks(MappedTrackInfo mappedTrackInfo, @Capabilities int[][][] rendererFormatSupports, @AdaptiveSupport int[] rendererMixedMimeTypeAdaptationSupports, Parameters params) {
int rendererCount = mappedTrackInfo.getRendererCount();
ExoTrackSelection.@NullableType Definition[] definitions = new ExoTrackSelection.Definition[rendererCount];
for (int i = 0; i < rendererCount; i++) {
TrackGroupArray trackGroupArray = mappedTrackInfo.getTrackGroups(i);
boolean hasTracks = trackGroupArray.length > 0;
definitions[i] = hasTracks ? new ExoTrackSelection.Definition(trackGroupArray.get(0)) : null;
}
return definitions;
}
use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.
the class MediaPeriodAsserts method prepareAndGetTrackGroups.
private static TrackGroupArray prepareAndGetTrackGroups(MediaPeriod mediaPeriod) {
AtomicReference<TrackGroupArray> trackGroupArray = new AtomicReference<>();
DummyMainThread testThread = new DummyMainThread();
ConditionVariable preparedCondition = new ConditionVariable();
testThread.runOnMainThread(() -> mediaPeriod.prepare(new Callback() {
@Override
public void onPrepared(MediaPeriod mediaPeriod) {
trackGroupArray.set(mediaPeriod.getTrackGroups());
preparedCondition.open();
}
@Override
public void onContinueLoadingRequested(MediaPeriod source) {
// Ignore.
}
}, /* positionUs= */
0));
try {
preparedCondition.block();
} catch (InterruptedException e) {
// Ignore.
}
testThread.release();
return trackGroupArray.get();
}
use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.
the class MediaPeriodAsserts method assertTrackGroups.
/**
* Prepares the {@link MediaPeriod} and asserts that it provides the specified track groups.
*
* @param mediaPeriod The {@link MediaPeriod} to test.
* @param expectedGroups The expected track groups.
*/
public static void assertTrackGroups(MediaPeriod mediaPeriod, TrackGroupArray expectedGroups) {
TrackGroupArray actualGroups = prepareAndGetTrackGroups(mediaPeriod);
assertThat(actualGroups).isEqualTo(expectedGroups);
}
use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.
the class DefaultAnalyticsCollector method onTracksChanged.
@Override
// Implementing and calling deprecate listener method
@SuppressWarnings("deprecation")
public final void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime();
sendEvent(eventTime, AnalyticsListener.EVENT_TRACKS_CHANGED, listener -> listener.onTracksChanged(eventTime, trackGroups, trackSelections));
}
Aggregations