Search in sources :

Example 1 with StandaloneDatabaseProvider

use of androidx.media3.database.StandaloneDatabaseProvider in project ExoPlayer by google.

the class DefaultDownloadIndexTest method setUp.

@Before
public void setUp() {
    databaseProvider = new StandaloneDatabaseProvider(ApplicationProvider.getApplicationContext());
    downloadIndex = new DefaultDownloadIndex(databaseProvider);
}
Also used : StandaloneDatabaseProvider(com.google.android.exoplayer2.database.StandaloneDatabaseProvider) Before(org.junit.Before)

Example 2 with StandaloneDatabaseProvider

use of androidx.media3.database.StandaloneDatabaseProvider in project media by androidx.

the class DashDownloadTest method setUp.

@Before
public void setUp() throws Exception {
    testRunner = new DashTestRunner(TAG, testRule.getActivity()).setManifestUrl(DashTestData.H264_MANIFEST).setFullPlaybackNoSeeking(true).setCanIncludeAdditionalVideoFormats(false).setAudioVideoFormats(DashTestData.AAC_AUDIO_REPRESENTATION_ID, DashTestData.H264_CDD_FIXED);
    tempFolder = Util.createTempDirectory(testRule.getActivity(), "ExoPlayerTest");
    cache = new SimpleCache(tempFolder, new NoOpCacheEvictor(), new StandaloneDatabaseProvider(testRule.getActivity()));
    httpDataSourceFactory = new DefaultHttpDataSource.Factory();
    offlineDataSourceFactory = new CacheDataSource.Factory().setCache(cache);
}
Also used : SimpleCache(androidx.media3.datasource.cache.SimpleCache) NoOpCacheEvictor(androidx.media3.datasource.cache.NoOpCacheEvictor) StandaloneDatabaseProvider(androidx.media3.database.StandaloneDatabaseProvider) DefaultHttpDataSource(androidx.media3.datasource.DefaultHttpDataSource) Before(org.junit.Before)

Example 3 with StandaloneDatabaseProvider

use of androidx.media3.database.StandaloneDatabaseProvider in project media by androidx.

the class DefaultDownloadIndexTest method downloadIndex_upgradesFromVersion2.

@Test
public void downloadIndex_upgradesFromVersion2() throws IOException {
    Context context = ApplicationProvider.getApplicationContext();
    File databaseFile = context.getDatabasePath(StandaloneDatabaseProvider.DATABASE_NAME);
    try (FileOutputStream output = new FileOutputStream(databaseFile)) {
        output.write(TestUtil.getByteArray(context, "media/offline/exoplayer_internal_v2.db"));
    }
    Download dashDownload = createDownload(/* uri= */
    "http://www.test.com/manifest.mpd", /* mimeType= */
    MimeTypes.APPLICATION_MPD, ImmutableList.of(), /* customCacheKey= */
    null);
    Download hlsDownload = createDownload(/* uri= */
    "http://www.test.com/manifest.m3u8", /* mimeType= */
    MimeTypes.APPLICATION_M3U8, ImmutableList.of(), /* customCacheKey= */
    null);
    Download ssDownload = createDownload(/* uri= */
    "http://www.test.com/video.ism/manifest", /* mimeType= */
    MimeTypes.APPLICATION_SS, Arrays.asList(new StreamKey(0, 0), new StreamKey(1, 1)), /* customCacheKey= */
    null);
    Download progressiveDownload = createDownload(/* uri= */
    "http://www.test.com/video.mp4", /* mimeType= */
    MimeTypes.VIDEO_UNKNOWN, ImmutableList.of(), /* customCacheKey= */
    "customCacheKey");
    databaseProvider = new StandaloneDatabaseProvider(context);
    downloadIndex = new DefaultDownloadIndex(databaseProvider);
    assertEqual(downloadIndex.getDownload("http://www.test.com/manifest.mpd"), dashDownload);
    assertEqual(downloadIndex.getDownload("http://www.test.com/manifest.m3u8"), hlsDownload);
    assertEqual(downloadIndex.getDownload("http://www.test.com/video.ism/manifest"), ssDownload);
    assertEqual(downloadIndex.getDownload("http://www.test.com/video.mp4"), progressiveDownload);
}
Also used : Context(android.content.Context) FileOutputStream(java.io.FileOutputStream) StandaloneDatabaseProvider(androidx.media3.database.StandaloneDatabaseProvider) File(java.io.File) StreamKey(androidx.media3.common.StreamKey) Test(org.junit.Test)

Example 4 with StandaloneDatabaseProvider

use of androidx.media3.database.StandaloneDatabaseProvider in project ExoPlayer by google.

the class DefaultDownloadIndexTest method downloadIndex_upgradesFromVersion2.

@Test
public void downloadIndex_upgradesFromVersion2() throws IOException {
    Context context = ApplicationProvider.getApplicationContext();
    File databaseFile = context.getDatabasePath(StandaloneDatabaseProvider.DATABASE_NAME);
    try (FileOutputStream output = new FileOutputStream(databaseFile)) {
        output.write(TestUtil.getByteArray(context, "media/offline/exoplayer_internal_v2.db"));
    }
    Download dashDownload = createDownload(/* uri= */
    "http://www.test.com/manifest.mpd", /* mimeType= */
    MimeTypes.APPLICATION_MPD, ImmutableList.of(), /* customCacheKey= */
    null);
    Download hlsDownload = createDownload(/* uri= */
    "http://www.test.com/manifest.m3u8", /* mimeType= */
    MimeTypes.APPLICATION_M3U8, ImmutableList.of(), /* customCacheKey= */
    null);
    Download ssDownload = createDownload(/* uri= */
    "http://www.test.com/video.ism/manifest", /* mimeType= */
    MimeTypes.APPLICATION_SS, Arrays.asList(new StreamKey(0, 0), new StreamKey(1, 1)), /* customCacheKey= */
    null);
    Download progressiveDownload = createDownload(/* uri= */
    "http://www.test.com/video.mp4", /* mimeType= */
    MimeTypes.VIDEO_UNKNOWN, ImmutableList.of(), /* customCacheKey= */
    "customCacheKey");
    databaseProvider = new StandaloneDatabaseProvider(context);
    downloadIndex = new DefaultDownloadIndex(databaseProvider);
    assertEqual(downloadIndex.getDownload("http://www.test.com/manifest.mpd"), dashDownload);
    assertEqual(downloadIndex.getDownload("http://www.test.com/manifest.m3u8"), hlsDownload);
    assertEqual(downloadIndex.getDownload("http://www.test.com/video.ism/manifest"), ssDownload);
    assertEqual(downloadIndex.getDownload("http://www.test.com/video.mp4"), progressiveDownload);
}
Also used : Context(android.content.Context) FileOutputStream(java.io.FileOutputStream) StandaloneDatabaseProvider(com.google.android.exoplayer2.database.StandaloneDatabaseProvider) File(java.io.File) Test(org.junit.Test)

Example 5 with StandaloneDatabaseProvider

use of androidx.media3.database.StandaloneDatabaseProvider in project ExoPlayer by google.

the class DashDownloadTest method setUp.

@Before
public void setUp() throws Exception {
    testRunner = new DashTestRunner(TAG, testRule.getActivity()).setManifestUrl(DashTestData.H264_MANIFEST).setFullPlaybackNoSeeking(true).setCanIncludeAdditionalVideoFormats(false).setAudioVideoFormats(DashTestData.AAC_AUDIO_REPRESENTATION_ID, DashTestData.H264_CDD_FIXED);
    tempFolder = Util.createTempDirectory(testRule.getActivity(), "ExoPlayerTest");
    cache = new SimpleCache(tempFolder, new NoOpCacheEvictor(), new StandaloneDatabaseProvider(testRule.getActivity()));
    httpDataSourceFactory = new DefaultHttpDataSource.Factory();
    offlineDataSourceFactory = new CacheDataSource.Factory().setCache(cache);
}
Also used : SimpleCache(com.google.android.exoplayer2.upstream.cache.SimpleCache) NoOpCacheEvictor(com.google.android.exoplayer2.upstream.cache.NoOpCacheEvictor) StandaloneDatabaseProvider(com.google.android.exoplayer2.database.StandaloneDatabaseProvider) DefaultHttpDataSource(com.google.android.exoplayer2.upstream.DefaultHttpDataSource) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)4 StandaloneDatabaseProvider (androidx.media3.database.StandaloneDatabaseProvider)3 StandaloneDatabaseProvider (com.google.android.exoplayer2.database.StandaloneDatabaseProvider)3 Context (android.content.Context)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 Test (org.junit.Test)2 StreamKey (androidx.media3.common.StreamKey)1 DefaultHttpDataSource (androidx.media3.datasource.DefaultHttpDataSource)1 NoOpCacheEvictor (androidx.media3.datasource.cache.NoOpCacheEvictor)1 SimpleCache (androidx.media3.datasource.cache.SimpleCache)1 DefaultHttpDataSource (com.google.android.exoplayer2.upstream.DefaultHttpDataSource)1 NoOpCacheEvictor (com.google.android.exoplayer2.upstream.cache.NoOpCacheEvictor)1 SimpleCache (com.google.android.exoplayer2.upstream.cache.SimpleCache)1