Search in sources :

Example 21 with EventDispatcher

use of androidx.media3.exoplayer.source.MediaSourceEventListener.EventDispatcher in project media by androidx.

the class SampleQueueTest method setUp.

@Before
public void setUp() {
    allocator = new DefaultAllocator(false, ALLOCATION_SIZE);
    mockDrmSession = Mockito.mock(DrmSession.class);
    mockDrmSessionManager = new MockDrmSessionManager(mockDrmSession);
    eventDispatcher = new DrmSessionEventListener.EventDispatcher();
    sampleQueue = new SampleQueue(allocator, mockDrmSessionManager, eventDispatcher);
    formatHolder = new FormatHolder();
    inputBuffer = new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_NORMAL);
}
Also used : DrmSession(androidx.media3.exoplayer.drm.DrmSession) DecoderInputBuffer(androidx.media3.decoder.DecoderInputBuffer) FormatHolder(androidx.media3.exoplayer.FormatHolder) DefaultAllocator(androidx.media3.exoplayer.upstream.DefaultAllocator) DrmSessionEventListener(androidx.media3.exoplayer.drm.DrmSessionEventListener) Before(org.junit.Before)

Example 22 with EventDispatcher

use of androidx.media3.exoplayer.source.MediaSourceEventListener.EventDispatcher in project media by androidx.

the class OfflineLicenseHelper method getLicenseDurationRemainingSec.

/**
 * Returns the remaining license and playback durations in seconds, for an offline license.
 *
 * @param offlineLicenseKeySetId The key set id of the license.
 * @return The remaining license and playback durations, in seconds.
 * @throws DrmSessionException Thrown when a DRM session error occurs.
 */
public synchronized Pair<Long, Long> getLicenseDurationRemainingSec(byte[] offlineLicenseKeySetId) throws DrmSessionException {
    Assertions.checkNotNull(offlineLicenseKeySetId);
    drmSessionManager.setPlayer(handlerThread.getLooper(), PlayerId.UNSET);
    drmSessionManager.prepare();
    DrmSession drmSession = openBlockingKeyRequest(DefaultDrmSessionManager.MODE_QUERY, offlineLicenseKeySetId, FORMAT_WITH_EMPTY_DRM_INIT_DATA);
    DrmSessionException error = drmSession.getError();
    Pair<Long, Long> licenseDurationRemainingSec = WidevineUtil.getLicenseDurationRemainingSec(drmSession);
    drmSession.release(eventDispatcher);
    drmSessionManager.release();
    if (error != null) {
        if (error.getCause() instanceof KeysExpiredException) {
            return Pair.create(0L, 0L);
        }
        throw error;
    }
    return Assertions.checkNotNull(licenseDurationRemainingSec);
}
Also used : DrmSessionException(androidx.media3.exoplayer.drm.DrmSession.DrmSessionException)

Aggregations

Test (org.junit.Test)16 FakeExoMediaDrm (androidx.media3.test.utils.FakeExoMediaDrm)15 AppManagedProvider (androidx.media3.exoplayer.drm.ExoMediaDrm.AppManagedProvider)7 DrmSessionReference (androidx.media3.exoplayer.drm.DrmSessionManager.DrmSessionReference)5 Nullable (androidx.annotation.Nullable)3 C (androidx.media3.common.C)3 Format (androidx.media3.common.Format)3 DrmSessionException (androidx.media3.exoplayer.drm.DrmSession.DrmSessionException)3 MediaSource (androidx.media3.exoplayer.source.MediaSource)3 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)3 ImmutableList (com.google.common.collect.ImmutableList)3 Truth.assertThat (com.google.common.truth.Truth.assertThat)3 RunWith (org.junit.runner.RunWith)3 Looper (android.os.Looper)2 DrmInitData (androidx.media3.common.DrmInitData)2 MimeTypes (androidx.media3.common.MimeTypes)2 Assertions.checkNotNull (androidx.media3.common.util.Assertions.checkNotNull)2 Util (androidx.media3.common.util.Util)2 DecoderInputBuffer (androidx.media3.decoder.DecoderInputBuffer)2 FormatHolder (androidx.media3.exoplayer.FormatHolder)2