Search in sources :

Example 1 with SsManifest

use of androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest in project media by androidx.

the class SsMediaPeriod method buildTrackGroups.

private static TrackGroupArray buildTrackGroups(SsManifest manifest, DrmSessionManager drmSessionManager) {
    TrackGroup[] trackGroups = new TrackGroup[manifest.streamElements.length];
    for (int i = 0; i < manifest.streamElements.length; i++) {
        Format[] manifestFormats = manifest.streamElements[i].formats;
        Format[] exposedFormats = new Format[manifestFormats.length];
        for (int j = 0; j < manifestFormats.length; j++) {
            Format manifestFormat = manifestFormats[j];
            exposedFormats[j] = manifestFormat.copyWithCryptoType(drmSessionManager.getCryptoType(manifestFormat));
        }
        trackGroups[i] = new TrackGroup(/* id= */
        Integer.toString(i), exposedFormats);
    }
    return new TrackGroupArray(trackGroups);
}
Also used : Format(androidx.media3.common.Format) TrackGroup(androidx.media3.common.TrackGroup) TrackGroupArray(androidx.media3.common.TrackGroupArray)

Example 2 with SsManifest

use of androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest in project media by androidx.

the class SsMediaSource method startLoadingManifest.

private void startLoadingManifest() {
    if (manifestLoader.hasFatalError()) {
        return;
    }
    ParsingLoadable<SsManifest> loadable = new ParsingLoadable<>(manifestDataSource, manifestUri, C.DATA_TYPE_MANIFEST, manifestParser);
    long elapsedRealtimeMs = manifestLoader.startLoading(loadable, this, loadErrorHandlingPolicy.getMinimumLoadableRetryCount(loadable.type));
    manifestEventDispatcher.loadStarted(new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, elapsedRealtimeMs), loadable.type);
}
Also used : LoadEventInfo(androidx.media3.exoplayer.source.LoadEventInfo) ParsingLoadable(androidx.media3.exoplayer.upstream.ParsingLoadable) SsManifest(androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest)

Example 3 with SsManifest

use of androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest in project media by androidx.

the class SsMediaSource method onLoadCanceled.

@Override
public void onLoadCanceled(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs, boolean released) {
    LoadEventInfo loadEventInfo = new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded());
    loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
    manifestEventDispatcher.loadCanceled(loadEventInfo, loadable.type);
}
Also used : LoadEventInfo(androidx.media3.exoplayer.source.LoadEventInfo)

Example 4 with SsManifest

use of androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest in project media by androidx.

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(androidx.media3.common.Format) ArrayList(java.util.ArrayList) StreamKey(androidx.media3.common.StreamKey)

Example 5 with SsManifest

use of androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest in project media by androidx.

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 : LoaderErrorThrower(androidx.media3.exoplayer.upstream.LoaderErrorThrower) FilterableManifestMediaPeriodFactory(androidx.media3.test.utils.MediaPeriodAsserts.FilterableManifestMediaPeriodFactory) SsManifest(androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest) TransferListener(androidx.media3.datasource.TransferListener) MediaSourceEventListener(androidx.media3.exoplayer.source.MediaSourceEventListener) MimeTypes(androidx.media3.common.MimeTypes) LoadErrorHandlingPolicy(androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy) RunWith(org.junit.runner.RunWith) SsTestUtils.createSsManifest(androidx.media3.exoplayer.smoothstreaming.SsTestUtils.createSsManifest) Allocator(androidx.media3.exoplayer.upstream.Allocator) Test(org.junit.Test) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) Format(androidx.media3.common.Format) DrmSessionManager(androidx.media3.exoplayer.drm.DrmSessionManager) C(androidx.media3.common.C) DrmSessionEventListener(androidx.media3.exoplayer.drm.DrmSessionEventListener) MediaPeriodId(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId) CompositeSequenceableLoaderFactory(androidx.media3.exoplayer.source.CompositeSequenceableLoaderFactory) SsTestUtils.createStreamElement(androidx.media3.exoplayer.smoothstreaming.SsTestUtils.createStreamElement) MediaPeriodAsserts(androidx.media3.test.utils.MediaPeriodAsserts) Mockito.mock(org.mockito.Mockito.mock) MediaSourceEventListener(androidx.media3.exoplayer.source.MediaSourceEventListener) MediaPeriodId(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId) DrmSessionEventListener(androidx.media3.exoplayer.drm.DrmSessionEventListener) SsManifest(androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest) SsTestUtils.createSsManifest(androidx.media3.exoplayer.smoothstreaming.SsTestUtils.createSsManifest) Test(org.junit.Test)

Aggregations

LoadEventInfo (androidx.media3.exoplayer.source.LoadEventInfo)4 Format (androidx.media3.common.Format)3 StreamKey (androidx.media3.common.StreamKey)3 SsTestUtils.createSsManifest (androidx.media3.exoplayer.smoothstreaming.SsTestUtils.createSsManifest)3 Test (org.junit.Test)3 SsManifest (androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest)2 StreamElement (androidx.media3.exoplayer.smoothstreaming.manifest.SsManifest.StreamElement)2 C (androidx.media3.common.C)1 MimeTypes (androidx.media3.common.MimeTypes)1 TrackGroup (androidx.media3.common.TrackGroup)1 TrackGroupArray (androidx.media3.common.TrackGroupArray)1 TransferListener (androidx.media3.datasource.TransferListener)1 DrmSessionEventListener (androidx.media3.exoplayer.drm.DrmSessionEventListener)1 DrmSessionManager (androidx.media3.exoplayer.drm.DrmSessionManager)1 SsTestUtils.createStreamElement (androidx.media3.exoplayer.smoothstreaming.SsTestUtils.createStreamElement)1 CompositeSequenceableLoaderFactory (androidx.media3.exoplayer.source.CompositeSequenceableLoaderFactory)1 MediaLoadData (androidx.media3.exoplayer.source.MediaLoadData)1 MediaPeriodId (androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)1 MediaSourceEventListener (androidx.media3.exoplayer.source.MediaSourceEventListener)1 Allocator (androidx.media3.exoplayer.upstream.Allocator)1