Search in sources :

Example 1 with DefaultDrmSessionManagerProvider

use of com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider in project ExoPlayer by google.

the class DefaultDrmSessionManagerProviderTest method create_reusesCachedInstanceWherePossible.

@Test
public void create_reusesCachedInstanceWherePossible() {
    MediaItem mediaItem1 = new MediaItem.Builder().setUri("https://example.test/content-1").setDrmConfiguration(new MediaItem.DrmConfiguration.Builder(C.WIDEVINE_UUID).build()).build();
    // Same DRM info as item1, but different URL to check it doesn't prevent re-using a manager.
    MediaItem mediaItem2 = new MediaItem.Builder().setUri("https://example.test/content-2").setDrmConfiguration(new MediaItem.DrmConfiguration.Builder(C.WIDEVINE_UUID).build()).build();
    // Different DRM info to 1 and 2, needs a different manager instance.
    MediaItem mediaItem3 = new MediaItem.Builder().setUri("https://example.test/content-3").setDrmConfiguration(new MediaItem.DrmConfiguration.Builder(C.WIDEVINE_UUID).setLicenseUri("https://example.test/license").build()).build();
    DefaultDrmSessionManagerProvider provider = new DefaultDrmSessionManagerProvider();
    DrmSessionManager drmSessionManager1 = provider.get(mediaItem1);
    DrmSessionManager drmSessionManager2 = provider.get(mediaItem2);
    DrmSessionManager drmSessionManager3 = provider.get(mediaItem3);
    // Get a manager for the first item again - expect it to be a different instance to last time
    // since we only cache one.
    DrmSessionManager drmSessionManager4 = provider.get(mediaItem1);
    assertThat(drmSessionManager1).isSameInstanceAs(drmSessionManager2);
    assertThat(drmSessionManager1).isNotSameInstanceAs(drmSessionManager3);
    assertThat(drmSessionManager1).isNotSameInstanceAs(drmSessionManager4);
}
Also used : MediaItem(com.google.android.exoplayer2.MediaItem) DrmSessionManager(com.google.android.exoplayer2.drm.DrmSessionManager) DefaultDrmSessionManagerProvider(com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider) Test(org.junit.Test)

Example 2 with DefaultDrmSessionManagerProvider

use of com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider in project ExoPlayer by google.

the class DefaultDrmSessionManagerProviderTest method create_createsManager.

@Test
public void create_createsManager() {
    MediaItem mediaItem = new MediaItem.Builder().setUri(Uri.EMPTY).setDrmConfiguration(new MediaItem.DrmConfiguration.Builder(C.WIDEVINE_UUID).setLicenseUri(Uri.EMPTY).build()).build();
    DrmSessionManager drmSessionManager = new DefaultDrmSessionManagerProvider().get(mediaItem);
    assertThat(drmSessionManager).isNotEqualTo(DrmSessionManager.DRM_UNSUPPORTED);
}
Also used : MediaItem(com.google.android.exoplayer2.MediaItem) DrmSessionManager(com.google.android.exoplayer2.drm.DrmSessionManager) DefaultDrmSessionManagerProvider(com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider) Test(org.junit.Test)

Example 3 with DefaultDrmSessionManagerProvider

use of com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider in project ExoPlayer by google.

the class DefaultDrmSessionManagerProviderTest method create_noDrmProperties_createsNoopManager.

@Test
public void create_noDrmProperties_createsNoopManager() {
    DrmSessionManager drmSessionManager = new DefaultDrmSessionManagerProvider().get(MediaItem.fromUri(Uri.EMPTY));
    assertThat(drmSessionManager).isEqualTo(DrmSessionManager.DRM_UNSUPPORTED);
}
Also used : DrmSessionManager(com.google.android.exoplayer2.drm.DrmSessionManager) DefaultDrmSessionManagerProvider(com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider) Test(org.junit.Test)

Aggregations

DefaultDrmSessionManagerProvider (com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider)3 DrmSessionManager (com.google.android.exoplayer2.drm.DrmSessionManager)3 Test (org.junit.Test)3 MediaItem (com.google.android.exoplayer2.MediaItem)2