Search in sources :

Example 1 with IllegalMergeException

use of com.google.android.exoplayer2.source.MergingMediaSource.IllegalMergeException in project ExoPlayer by google.

the class MergingMediaSourceTest method prepare_differentPeriodCounts_fails.

@Test
public void prepare_differentPeriodCounts_fails() throws IOException {
    FakeTimeline firstTimeline = new FakeTimeline(new TimelineWindowDefinition(/* periodCount= */
    1, /* id= */
    1));
    FakeTimeline secondTimeline = new FakeTimeline(new TimelineWindowDefinition(/* periodCount= */
    2, /* id= */
    2));
    IllegalMergeException exception = assertThrows(IllegalMergeException.class, () -> prepareMergingMediaSource(/* clipDurations= */
    false, firstTimeline, secondTimeline));
    assertThat(exception.reason).isEqualTo(IllegalMergeException.REASON_PERIOD_COUNT_MISMATCH);
}
Also used : FakeTimeline(com.google.android.exoplayer2.testutil.FakeTimeline) TimelineWindowDefinition(com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition) IllegalMergeException(com.google.android.exoplayer2.source.MergingMediaSource.IllegalMergeException) Test(org.junit.Test)

Example 2 with IllegalMergeException

use of com.google.android.exoplayer2.source.MergingMediaSource.IllegalMergeException in project ExoPlayer by google.

the class MergingMediaSource method onChildSourceInfoRefreshed.

@Override
protected void onChildSourceInfoRefreshed(Integer id, MediaSource mediaSource, Timeline timeline) {
    if (mergeError != null) {
        return;
    }
    if (periodCount == PERIOD_COUNT_UNSET) {
        periodCount = timeline.getPeriodCount();
    } else if (timeline.getPeriodCount() != periodCount) {
        mergeError = new IllegalMergeException(IllegalMergeException.REASON_PERIOD_COUNT_MISMATCH);
        return;
    }
    if (periodTimeOffsetsUs.length == 0) {
        periodTimeOffsetsUs = new long[periodCount][timelines.length];
    }
    pendingTimelineSources.remove(mediaSource);
    timelines[id] = timeline;
    if (pendingTimelineSources.isEmpty()) {
        if (adjustPeriodTimeOffsets) {
            computePeriodTimeOffsets();
        }
        Timeline mergedTimeline = timelines[0];
        if (clipDurations) {
            updateClippedDuration();
            mergedTimeline = new ClippedTimeline(mergedTimeline, clippedDurationsUs);
        }
        refreshSourceInfo(mergedTimeline);
    }
}
Also used : Timeline(com.google.android.exoplayer2.Timeline)

Aggregations

Timeline (com.google.android.exoplayer2.Timeline)1 IllegalMergeException (com.google.android.exoplayer2.source.MergingMediaSource.IllegalMergeException)1 FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)1 TimelineWindowDefinition (com.google.android.exoplayer2.testutil.FakeTimeline.TimelineWindowDefinition)1 Test (org.junit.Test)1