Search in sources :

Example 11 with EventDispatcher

use of com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener.EventDispatcher in project ExoPlayer by google.

the class DefaultDrmSessionManagerTest method keepaliveDisabled_sessionsReleasedImmediately.

@Test(timeout = 10_000)
public void keepaliveDisabled_sessionsReleasedImmediately() throws Exception {
    FakeExoMediaDrm.LicenseServer licenseServer = FakeExoMediaDrm.LicenseServer.allowingSchemeDatas(DRM_SCHEME_DATAS);
    DrmSessionManager drmSessionManager = new DefaultDrmSessionManager.Builder().setUuidAndExoMediaDrmProvider(DRM_SCHEME_UUID, uuid -> new FakeExoMediaDrm()).setSessionKeepaliveMs(C.TIME_UNSET).build(/* mediaDrmCallback= */
    licenseServer);
    drmSessionManager.prepare();
    drmSessionManager.setPlayer(/* playbackLooper= */
    Looper.myLooper(), PlayerId.UNSET);
    DrmSession drmSession = checkNotNull(drmSessionManager.acquireSession(/* eventDispatcher= */
    null, FORMAT_WITH_DRM_INIT_DATA));
    waitForOpenedWithKeys(drmSession);
    drmSession.release(/* eventDispatcher= */
    null);
    assertThat(drmSession.getState()).isEqualTo(DrmSession.STATE_RELEASED);
}
Also used : FakeExoMediaDrm(com.google.android.exoplayer2.testutil.FakeExoMediaDrm) Test(org.junit.Test)

Example 12 with EventDispatcher

use of com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener.EventDispatcher in project ExoPlayer by google.

the class DefaultDrmSessionManagerTest method managerRelease_allKeepaliveSessionsImmediatelyReleased.

@Test(timeout = 10_000)
public void managerRelease_allKeepaliveSessionsImmediatelyReleased() throws Exception {
    FakeExoMediaDrm.LicenseServer licenseServer = FakeExoMediaDrm.LicenseServer.allowingSchemeDatas(DRM_SCHEME_DATAS);
    DrmSessionManager drmSessionManager = new DefaultDrmSessionManager.Builder().setUuidAndExoMediaDrmProvider(DRM_SCHEME_UUID, uuid -> new FakeExoMediaDrm()).setSessionKeepaliveMs(10_000).build(/* mediaDrmCallback= */
    licenseServer);
    drmSessionManager.prepare();
    drmSessionManager.setPlayer(/* playbackLooper= */
    Looper.myLooper(), PlayerId.UNSET);
    DrmSession drmSession = checkNotNull(drmSessionManager.acquireSession(/* eventDispatcher= */
    null, FORMAT_WITH_DRM_INIT_DATA));
    waitForOpenedWithKeys(drmSession);
    drmSession.release(/* eventDispatcher= */
    null);
    assertThat(drmSession.getState()).isEqualTo(DrmSession.STATE_OPENED_WITH_KEYS);
    drmSessionManager.release();
    assertThat(drmSession.getState()).isEqualTo(DrmSession.STATE_RELEASED);
}
Also used : FakeExoMediaDrm(com.google.android.exoplayer2.testutil.FakeExoMediaDrm) Test(org.junit.Test)

Example 13 with EventDispatcher

use of com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener.EventDispatcher in project ExoPlayer by google.

the class FakeMediaSource method finishSourcePreparation.

private void finishSourcePreparation(boolean sendManifestLoadEvents) {
    refreshSourceInfo(Assertions.checkStateNotNull(timeline));
    if (!timeline.isEmpty() && sendManifestLoadEvents) {
        MediaLoadData mediaLoadData = new MediaLoadData(C.DATA_TYPE_MANIFEST, C.TRACK_TYPE_UNKNOWN, /* trackFormat= */
        null, C.SELECTION_REASON_UNKNOWN, /* trackSelectionData= */
        null, /* mediaStartTimeMs= */
        C.TIME_UNSET, /* mediaEndTimeMs = */
        C.TIME_UNSET);
        long elapsedRealTimeMs = SystemClock.elapsedRealtime();
        MediaSourceEventListener.EventDispatcher eventDispatcher = createEventDispatcher(/* mediaPeriodId= */
        null);
        long loadTaskId = LoadEventInfo.getNewId();
        eventDispatcher.loadStarted(new LoadEventInfo(loadTaskId, FAKE_DATA_SPEC, FAKE_DATA_SPEC.uri, /* responseHeaders= */
        ImmutableMap.of(), elapsedRealTimeMs, /* loadDurationMs= */
        0, /* bytesLoaded= */
        0), mediaLoadData);
        eventDispatcher.loadCompleted(new LoadEventInfo(loadTaskId, FAKE_DATA_SPEC, FAKE_DATA_SPEC.uri, /* responseHeaders= */
        ImmutableMap.of(), elapsedRealTimeMs, /* loadDurationMs= */
        0, /* bytesLoaded= */
        MANIFEST_LOAD_BYTES), mediaLoadData);
    }
}
Also used : MediaLoadData(com.google.android.exoplayer2.source.MediaLoadData) LoadEventInfo(com.google.android.exoplayer2.source.LoadEventInfo) MediaSourceEventListener(com.google.android.exoplayer2.source.MediaSourceEventListener)

Example 14 with EventDispatcher

use of com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener.EventDispatcher in project ExoPlayer by google.

the class DashMediaPeriod method buildSampleStream.

private ChunkSampleStream<DashChunkSource> buildSampleStream(int adaptationSetIndex, TrackSelection selection, long positionUs) {
    AdaptationSet adaptationSet = adaptationSets.get(adaptationSetIndex);
    int embeddedTrackCount = 0;
    int[] embeddedTrackTypes = new int[2];
    boolean enableEventMessageTrack = hasEventMessageTrack(adaptationSet);
    if (enableEventMessageTrack) {
        embeddedTrackTypes[embeddedTrackCount++] = C.TRACK_TYPE_METADATA;
    }
    boolean enableCea608Track = hasCea608Track(adaptationSet);
    if (enableCea608Track) {
        embeddedTrackTypes[embeddedTrackCount++] = C.TRACK_TYPE_TEXT;
    }
    if (embeddedTrackCount < embeddedTrackTypes.length) {
        embeddedTrackTypes = Arrays.copyOf(embeddedTrackTypes, embeddedTrackCount);
    }
    DashChunkSource chunkSource = chunkSourceFactory.createDashChunkSource(manifestLoaderErrorThrower, manifest, periodIndex, adaptationSetIndex, selection, elapsedRealtimeOffset, enableEventMessageTrack, enableCea608Track);
    ChunkSampleStream<DashChunkSource> stream = new ChunkSampleStream<>(adaptationSet.type, embeddedTrackTypes, chunkSource, this, allocator, positionUs, minLoadableRetryCount, eventDispatcher);
    return stream;
}
Also used : ChunkSampleStream(com.google.android.exoplayer2.source.chunk.ChunkSampleStream) AdaptationSet(com.google.android.exoplayer2.source.dash.manifest.AdaptationSet)

Example 15 with EventDispatcher

use of com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener.EventDispatcher in project ExoPlayer by google.

the class DashMediaSource method createPeriod.

@Override
public MediaPeriod createPeriod(int periodIndex, Allocator allocator, long positionUs) {
    EventDispatcher periodEventDispatcher = eventDispatcher.copyWithMediaTimeOffsetMs(manifest.getPeriod(periodIndex).startMs);
    DashMediaPeriod mediaPeriod = new DashMediaPeriod(firstPeriodId + periodIndex, manifest, periodIndex, chunkSourceFactory, minLoadableRetryCount, periodEventDispatcher, elapsedRealtimeOffsetMs, loaderErrorThrower, allocator);
    periodsById.put(mediaPeriod.id, mediaPeriod);
    return mediaPeriod;
}
Also used : EventDispatcher(com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener.EventDispatcher)

Aggregations

Test (org.junit.Test)16 FakeExoMediaDrm (com.google.android.exoplayer2.testutil.FakeExoMediaDrm)15 AppManagedProvider (com.google.android.exoplayer2.drm.ExoMediaDrm.AppManagedProvider)7 DrmSessionReference (com.google.android.exoplayer2.drm.DrmSessionManager.DrmSessionReference)5 Nullable (androidx.annotation.Nullable)3 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)3 C (com.google.android.exoplayer2.C)3 Format (com.google.android.exoplayer2.Format)3 DrmSessionException (com.google.android.exoplayer2.drm.DrmSession.DrmSessionException)3 MediaSource (com.google.android.exoplayer2.source.MediaSource)3 ImmutableList (com.google.common.collect.ImmutableList)3 Truth.assertThat (com.google.common.truth.Truth.assertThat)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 RunWith (org.junit.runner.RunWith)3 Looper (android.os.Looper)2 FormatHolder (com.google.android.exoplayer2.FormatHolder)2 PlayerId (com.google.android.exoplayer2.analytics.PlayerId)2 DecoderInputBuffer (com.google.android.exoplayer2.decoder.DecoderInputBuffer)2 DrmSessionEventListener (com.google.android.exoplayer2.drm.DrmSessionEventListener)2 LoadEventInfo (com.google.android.exoplayer2.source.LoadEventInfo)2