Search in sources :

Example 6 with DashDownloader

use of com.google.android.exoplayer2.source.dash.offline.DashDownloader in project ExoPlayer by google.

the class DashDownloaderTest method representationWithoutIndex.

@Test
public void representationWithoutIndex() throws Exception {
    FakeDataSet fakeDataSet = new FakeDataSet().setData(TEST_MPD_URI, TEST_MPD_NO_INDEX).setRandomData("test_segment_1", 4);
    DashDownloader dashDownloader = getDashDownloader(fakeDataSet, new StreamKey(0, 0, 0));
    try {
        dashDownloader.download(progressListener);
        fail();
    } catch (DownloadException e) {
    // Expected.
    }
    dashDownloader.remove();
    assertCacheEmpty(cache);
}
Also used : DownloadException(com.google.android.exoplayer2.offline.DownloadException) FakeDataSet(com.google.android.exoplayer2.testutil.FakeDataSet) StreamKey(com.google.android.exoplayer2.offline.StreamKey) Test(org.junit.Test)

Example 7 with DashDownloader

use of com.google.android.exoplayer2.source.dash.offline.DashDownloader in project ExoPlayer by google.

the class DashDownloaderTest method downloadRepresentationFailure.

@Test
public void downloadRepresentationFailure() throws Exception {
    FakeDataSet fakeDataSet = new FakeDataSet().setData(TEST_MPD_URI, TEST_MPD).setRandomData("audio_init_data", 10).setRandomData("audio_segment_1", 4).newData("audio_segment_2").appendReadData(TestUtil.buildTestData(2)).appendReadError(new IOException()).appendReadData(TestUtil.buildTestData(3)).endData().setRandomData("audio_segment_3", 6);
    DashDownloader dashDownloader = getDashDownloader(fakeDataSet, new StreamKey(0, 0, 0));
    try {
        dashDownloader.download(progressListener);
        fail();
    } catch (IOException e) {
    // Expected.
    }
    dashDownloader.download(progressListener);
    assertCachedData(cache, new RequestSet(fakeDataSet).useBoundedDataSpecFor("audio_init_data"));
}
Also used : RequestSet(com.google.android.exoplayer2.testutil.CacheAsserts.RequestSet) FakeDataSet(com.google.android.exoplayer2.testutil.FakeDataSet) IOException(java.io.IOException) StreamKey(com.google.android.exoplayer2.offline.StreamKey) Test(org.junit.Test)

Example 8 with DashDownloader

use of com.google.android.exoplayer2.source.dash.offline.DashDownloader in project ExoPlayer by google.

the class DashDownloaderTest method remove.

@Test
public void remove() throws Exception {
    FakeDataSet fakeDataSet = new FakeDataSet().setData(TEST_MPD_URI, TEST_MPD).setRandomData("audio_init_data", 10).setRandomData("audio_segment_1", 4).setRandomData("audio_segment_2", 5).setRandomData("audio_segment_3", 6).setRandomData("text_segment_1", 1).setRandomData("text_segment_2", 2).setRandomData("text_segment_3", 3);
    DashDownloader dashDownloader = getDashDownloader(fakeDataSet, new StreamKey(0, 0, 0), new StreamKey(0, 1, 0));
    dashDownloader.download(progressListener);
    dashDownloader.remove();
    assertCacheEmpty(cache);
}
Also used : FakeDataSet(com.google.android.exoplayer2.testutil.FakeDataSet) StreamKey(com.google.android.exoplayer2.offline.StreamKey) Test(org.junit.Test)

Example 9 with DashDownloader

use of com.google.android.exoplayer2.source.dash.offline.DashDownloader in project ExoPlayer by google.

the class DashDownloaderTest method downloadRepresentation.

@Test
public void downloadRepresentation() throws Exception {
    FakeDataSet fakeDataSet = new FakeDataSet().setData(TEST_MPD_URI, TEST_MPD).setRandomData("audio_init_data", 10).setRandomData("audio_segment_1", 4).setRandomData("audio_segment_2", 5).setRandomData("audio_segment_3", 6);
    DashDownloader dashDownloader = getDashDownloader(fakeDataSet, new StreamKey(0, 0, 0));
    dashDownloader.download(progressListener);
    assertCachedData(cache, new RequestSet(fakeDataSet).useBoundedDataSpecFor("audio_init_data"));
}
Also used : RequestSet(com.google.android.exoplayer2.testutil.CacheAsserts.RequestSet) FakeDataSet(com.google.android.exoplayer2.testutil.FakeDataSet) StreamKey(com.google.android.exoplayer2.offline.StreamKey) Test(org.junit.Test)

Example 10 with DashDownloader

use of com.google.android.exoplayer2.source.dash.offline.DashDownloader in project ExoPlayer by google.

the class DashDownloaderTest method downloadRepresentationInSmallParts.

@Test
public void downloadRepresentationInSmallParts() throws Exception {
    FakeDataSet fakeDataSet = new FakeDataSet().setData(TEST_MPD_URI, TEST_MPD).setRandomData("audio_init_data", 10).newData("audio_segment_1").appendReadData(TestUtil.buildTestData(10)).appendReadData(TestUtil.buildTestData(10)).appendReadData(TestUtil.buildTestData(10)).endData().setRandomData("audio_segment_2", 5).setRandomData("audio_segment_3", 6);
    DashDownloader dashDownloader = getDashDownloader(fakeDataSet, new StreamKey(0, 0, 0));
    dashDownloader.download(progressListener);
    assertCachedData(cache, new RequestSet(fakeDataSet).useBoundedDataSpecFor("audio_init_data"));
}
Also used : RequestSet(com.google.android.exoplayer2.testutil.CacheAsserts.RequestSet) FakeDataSet(com.google.android.exoplayer2.testutil.FakeDataSet) StreamKey(com.google.android.exoplayer2.offline.StreamKey) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)11 StreamKey (com.google.android.exoplayer2.offline.StreamKey)10 FakeDataSet (com.google.android.exoplayer2.testutil.FakeDataSet)10 RequestSet (com.google.android.exoplayer2.testutil.CacheAsserts.RequestSet)5 DashDownloader (com.google.android.exoplayer2.source.dash.offline.DashDownloader)2 FakeDataSource (com.google.android.exoplayer2.testutil.FakeDataSource)2 DataSpec (com.google.android.exoplayer2.upstream.DataSpec)2 IOException (java.io.IOException)2 DownloadException (com.google.android.exoplayer2.offline.DownloadException)1 AdaptationSet (com.google.android.exoplayer2.source.dash.manifest.AdaptationSet)1 DashManifest (com.google.android.exoplayer2.source.dash.manifest.DashManifest)1 Representation (com.google.android.exoplayer2.source.dash.manifest.Representation)1 CacheDataSource (com.google.android.exoplayer2.upstream.cache.CacheDataSource)1 ArrayList (java.util.ArrayList)1