Search in sources :

Example 1 with SsManifest

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

the class DefaultSsChunkSource method updateManifest.

@Override
public void updateManifest(SsManifest newManifest) {
    StreamElement currentElement = manifest.streamElements[streamElementIndex];
    int currentElementChunkCount = currentElement.chunkCount;
    StreamElement newElement = newManifest.streamElements[streamElementIndex];
    if (currentElementChunkCount == 0 || newElement.chunkCount == 0) {
        // There's no overlap between the old and new elements because at least one is empty.
        currentManifestChunkOffset += currentElementChunkCount;
    } else {
        long currentElementEndTimeUs = currentElement.getStartTimeUs(currentElementChunkCount - 1) + currentElement.getChunkDurationUs(currentElementChunkCount - 1);
        long newElementStartTimeUs = newElement.getStartTimeUs(0);
        if (currentElementEndTimeUs <= newElementStartTimeUs) {
            // There's no overlap between the old and new elements.
            currentManifestChunkOffset += currentElementChunkCount;
        } else {
            // The new element overlaps with the old one.
            currentManifestChunkOffset += currentElement.getChunkIndex(newElementStartTimeUs);
        }
    }
    manifest = newManifest;
}
Also used : StreamElement(com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.StreamElement)

Example 2 with SsManifest

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

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(com.google.android.exoplayer2.Format) TrackGroup(com.google.android.exoplayer2.source.TrackGroup) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray)

Example 3 with SsManifest

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

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(com.google.android.exoplayer2.source.LoadEventInfo) ParsingLoadable(com.google.android.exoplayer2.upstream.ParsingLoadable) SsManifest(com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest)

Example 4 with SsManifest

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

the class SsMediaSource method onLoadCompleted.

// Loader.Callback implementation
@Override
public void onLoadCompleted(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs) {
    LoadEventInfo loadEventInfo = new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded());
    loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
    manifestEventDispatcher.loadCompleted(loadEventInfo, loadable.type);
    manifest = loadable.getResult();
    manifestLoadStartTimestamp = elapsedRealtimeMs - loadDurationMs;
    processManifest();
    scheduleManifestRefresh();
}
Also used : LoadEventInfo(com.google.android.exoplayer2.source.LoadEventInfo)

Example 5 with SsManifest

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

the class SsManifestTest method copy.

@Test
public void copy() throws Exception {
    Format[][] formats = newFormats(2, 3);
    SsManifest sourceManifest = createSsManifest(createStreamElement("1", formats[0]), createStreamElement("2", formats[1]));
    List<StreamKey> keys = Arrays.asList(new StreamKey(0, 0), new StreamKey(0, 2), new StreamKey(1, 0));
    // Keys don't need to be in any particular order
    Collections.shuffle(keys, new Random(0));
    SsManifest copyManifest = sourceManifest.copy(keys);
    SsManifest expectedManifest = createSsManifest(createStreamElement("1", formats[0][0], formats[0][2]), createStreamElement("2", formats[1][0]));
    assertManifestEquals(expectedManifest, copyManifest);
}
Also used : Random(java.util.Random) SsTestUtils.createSsManifest(com.google.android.exoplayer2.source.smoothstreaming.SsTestUtils.createSsManifest) StreamKey(com.google.android.exoplayer2.offline.StreamKey) Test(org.junit.Test)

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