Search in sources :

Example 6 with SsManifest

use of com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest in project ExoPlayer by google.

the class SsMediaPeriodTest method getSteamKeys_isCompatibleWithSsManifestFilter.

@Test
public void getSteamKeys_isCompatibleWithSsManifestFilter() {
    SsManifest testManifest = createSsManifest(createStreamElement(/* name= */
    "video", C.TRACK_TYPE_VIDEO, createVideoFormat(/* bitrate= */
    200000), createVideoFormat(/* bitrate= */
    400000), createVideoFormat(/* bitrate= */
    800000)), createStreamElement(/* name= */
    "audio", C.TRACK_TYPE_AUDIO, createAudioFormat(/* bitrate= */
    48000), createAudioFormat(/* bitrate= */
    96000)), createStreamElement(/* name= */
    "text", C.TRACK_TYPE_TEXT, createTextFormat(/* language= */
    "eng")));
    FilterableManifestMediaPeriodFactory<SsManifest> mediaPeriodFactory = (manifest, periodIndex) -> {
        MediaPeriodId mediaPeriodId = new MediaPeriodId(/* periodUid= */
        new Object());
        return new SsMediaPeriod(manifest, mock(SsChunkSource.Factory.class), mock(TransferListener.class), mock(CompositeSequenceableLoaderFactory.class), mock(DrmSessionManager.class), new DrmSessionEventListener.EventDispatcher().withParameters(/* windowIndex= */
        0, mediaPeriodId), mock(LoadErrorHandlingPolicy.class), new MediaSourceEventListener.EventDispatcher().withParameters(/* windowIndex= */
        0, mediaPeriodId, /* mediaTimeOffsetMs= */
        0), mock(LoaderErrorThrower.class), mock(Allocator.class));
    };
    MediaPeriodAsserts.assertGetStreamKeysAndManifestFilterIntegration(mediaPeriodFactory, testManifest);
}
Also used : MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId) TransferListener(com.google.android.exoplayer2.upstream.TransferListener) SsTestUtils.createSsManifest(com.google.android.exoplayer2.source.smoothstreaming.SsTestUtils.createSsManifest) RunWith(org.junit.runner.RunWith) CompositeSequenceableLoaderFactory(com.google.android.exoplayer2.source.CompositeSequenceableLoaderFactory) Test(org.junit.Test) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) Format(com.google.android.exoplayer2.Format) MediaPeriodAsserts(com.google.android.exoplayer2.testutil.MediaPeriodAsserts) DrmSessionEventListener(com.google.android.exoplayer2.drm.DrmSessionEventListener) MimeTypes(com.google.android.exoplayer2.util.MimeTypes) LoadErrorHandlingPolicy(com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy) SsManifest(com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest) FilterableManifestMediaPeriodFactory(com.google.android.exoplayer2.testutil.MediaPeriodAsserts.FilterableManifestMediaPeriodFactory) SsTestUtils.createStreamElement(com.google.android.exoplayer2.source.smoothstreaming.SsTestUtils.createStreamElement) DrmSessionManager(com.google.android.exoplayer2.drm.DrmSessionManager) MediaSourceEventListener(com.google.android.exoplayer2.source.MediaSourceEventListener) Mockito.mock(org.mockito.Mockito.mock) C(com.google.android.exoplayer2.C) Allocator(com.google.android.exoplayer2.upstream.Allocator) LoaderErrorThrower(com.google.android.exoplayer2.upstream.LoaderErrorThrower) MediaSourceEventListener(com.google.android.exoplayer2.source.MediaSourceEventListener) MediaPeriodId(com.google.android.exoplayer2.source.MediaSource.MediaPeriodId) DrmSessionEventListener(com.google.android.exoplayer2.drm.DrmSessionEventListener) SsTestUtils.createSsManifest(com.google.android.exoplayer2.source.smoothstreaming.SsTestUtils.createSsManifest) SsManifest(com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest) Test(org.junit.Test)

Example 7 with SsManifest

use of com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest in project ExoPlayer by google.

the class SsManifest method copy.

@Override
public final SsManifest copy(List<StreamKey> streamKeys) {
    ArrayList<StreamKey> sortedKeys = new ArrayList<>(streamKeys);
    Collections.sort(sortedKeys);
    StreamElement currentStreamElement = null;
    List<StreamElement> copiedStreamElements = new ArrayList<>();
    List<Format> copiedFormats = new ArrayList<>();
    for (int i = 0; i < sortedKeys.size(); i++) {
        StreamKey key = sortedKeys.get(i);
        StreamElement streamElement = streamElements[key.groupIndex];
        if (streamElement != currentStreamElement && currentStreamElement != null) {
            // We're advancing to a new stream element. Add the current one.
            copiedStreamElements.add(currentStreamElement.copy(copiedFormats.toArray(new Format[0])));
            copiedFormats.clear();
        }
        currentStreamElement = streamElement;
        copiedFormats.add(streamElement.formats[key.streamIndex]);
    }
    if (currentStreamElement != null) {
        // Add the last stream element.
        copiedStreamElements.add(currentStreamElement.copy(copiedFormats.toArray(new Format[0])));
    }
    StreamElement[] copiedStreamElementsArray = copiedStreamElements.toArray(new StreamElement[0]);
    return new SsManifest(majorVersion, minorVersion, durationUs, dvrWindowLengthUs, lookAheadCount, isLive, protectionElement, copiedStreamElementsArray);
}
Also used : Format(com.google.android.exoplayer2.Format) ArrayList(java.util.ArrayList) StreamKey(com.google.android.exoplayer2.offline.StreamKey)

Example 8 with SsManifest

use of com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest in project ExoPlayer by google.

the class SsManifestTest method assertManifestEquals.

private static void assertManifestEquals(SsManifest expected, SsManifest actual) {
    assertThat(actual.durationUs).isEqualTo(expected.durationUs);
    assertThat(actual.dvrWindowLengthUs).isEqualTo(expected.dvrWindowLengthUs);
    assertThat(actual.isLive).isEqualTo(expected.isLive);
    assertThat(actual.lookAheadCount).isEqualTo(expected.lookAheadCount);
    assertThat(actual.majorVersion).isEqualTo(expected.majorVersion);
    assertThat(actual.minorVersion).isEqualTo(expected.minorVersion);
    assertThat(actual.protectionElement.uuid).isEqualTo(expected.protectionElement.uuid);
    assertThat(actual.protectionElement).isEqualTo(expected.protectionElement);
    for (int i = 0; i < expected.streamElements.length; i++) {
        StreamElement expectedStreamElement = expected.streamElements[i];
        StreamElement actualStreamElement = actual.streamElements[i];
        assertThat(actualStreamElement.chunkCount).isEqualTo(expectedStreamElement.chunkCount);
        assertThat(actualStreamElement.displayHeight).isEqualTo(expectedStreamElement.displayHeight);
        assertThat(actualStreamElement.displayWidth).isEqualTo(expectedStreamElement.displayWidth);
        assertThat(actualStreamElement.language).isEqualTo(expectedStreamElement.language);
        assertThat(actualStreamElement.maxHeight).isEqualTo(expectedStreamElement.maxHeight);
        assertThat(actualStreamElement.maxWidth).isEqualTo(expectedStreamElement.maxWidth);
        assertThat(actualStreamElement.name).isEqualTo(expectedStreamElement.name);
        assertThat(actualStreamElement.subType).isEqualTo(expectedStreamElement.subType);
        assertThat(actualStreamElement.timescale).isEqualTo(expectedStreamElement.timescale);
        assertThat(actualStreamElement.type).isEqualTo(expectedStreamElement.type);
        assertThat(actualStreamElement.formats).isEqualTo(expectedStreamElement.formats);
    }
}
Also used : StreamElement(com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.StreamElement)

Example 9 with SsManifest

use of com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest in project ExoPlayer by google.

the class SsManifestTest method copyRemoveStreamElement.

@Test
public void copyRemoveStreamElement() throws Exception {
    Format[][] formats = newFormats(2, 3);
    SsManifest sourceManifest = createSsManifest(createStreamElement("1", formats[0]), createStreamElement("2", formats[1]));
    List<StreamKey> keys = Collections.singletonList(new StreamKey(1, 0));
    SsManifest copyManifest = sourceManifest.copy(keys);
    SsManifest expectedManifest = createSsManifest(createStreamElement("2", formats[1][0]));
    assertManifestEquals(expectedManifest, copyManifest);
}
Also used : SsTestUtils.createSsManifest(com.google.android.exoplayer2.source.smoothstreaming.SsTestUtils.createSsManifest) StreamKey(com.google.android.exoplayer2.offline.StreamKey) Test(org.junit.Test)

Example 10 with SsManifest

use of com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest in project ExoPlayer by google.

the class SsMediaSource method onLoadError.

@Override
public LoadErrorAction onLoadError(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs, IOException error, int errorCount) {
    LoadEventInfo loadEventInfo = new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded());
    MediaLoadData mediaLoadData = new MediaLoadData(loadable.type);
    long retryDelayMs = loadErrorHandlingPolicy.getRetryDelayMsFor(new LoadErrorInfo(loadEventInfo, mediaLoadData, error, errorCount));
    LoadErrorAction loadErrorAction = retryDelayMs == C.TIME_UNSET ? Loader.DONT_RETRY_FATAL : Loader.createRetryAction(/* resetErrorCount= */
    false, retryDelayMs);
    boolean wasCanceled = !loadErrorAction.isRetry();
    manifestEventDispatcher.loadError(loadEventInfo, loadable.type, error, wasCanceled);
    if (wasCanceled) {
        loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
    }
    return loadErrorAction;
}
Also used : LoadEventInfo(com.google.android.exoplayer2.source.LoadEventInfo) MediaLoadData(com.google.android.exoplayer2.source.MediaLoadData) LoadErrorInfo(com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy.LoadErrorInfo) LoadErrorAction(com.google.android.exoplayer2.upstream.Loader.LoadErrorAction)

Aggregations

LoadEventInfo (com.google.android.exoplayer2.source.LoadEventInfo)4 Format (com.google.android.exoplayer2.Format)3 StreamKey (com.google.android.exoplayer2.offline.StreamKey)3 SsTestUtils.createSsManifest (com.google.android.exoplayer2.source.smoothstreaming.SsTestUtils.createSsManifest)3 Test (org.junit.Test)3 SsManifest (com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest)2 StreamElement (com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.StreamElement)2 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)1 C (com.google.android.exoplayer2.C)1 DrmSessionEventListener (com.google.android.exoplayer2.drm.DrmSessionEventListener)1 DrmSessionManager (com.google.android.exoplayer2.drm.DrmSessionManager)1 CompositeSequenceableLoaderFactory (com.google.android.exoplayer2.source.CompositeSequenceableLoaderFactory)1 MediaLoadData (com.google.android.exoplayer2.source.MediaLoadData)1 MediaPeriodId (com.google.android.exoplayer2.source.MediaSource.MediaPeriodId)1 MediaSourceEventListener (com.google.android.exoplayer2.source.MediaSourceEventListener)1 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)1 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)1 SsTestUtils.createStreamElement (com.google.android.exoplayer2.source.smoothstreaming.SsTestUtils.createStreamElement)1 MediaPeriodAsserts (com.google.android.exoplayer2.testutil.MediaPeriodAsserts)1 FilterableManifestMediaPeriodFactory (com.google.android.exoplayer2.testutil.MediaPeriodAsserts.FilterableManifestMediaPeriodFactory)1