use of androidx.media3.test.utils.FakeDataSource in project media by androidx.
the class DefaultDashChunkSourceTest method getNextChunk_forVodManifest_doesNotSetMayNotLoadAtFullNetworkSpeedFlag.
@Test
public void getNextChunk_forVodManifest_doesNotSetMayNotLoadAtFullNetworkSpeedFlag() throws Exception {
long nowMs = 2_000_000_000_000L;
SystemClock.setCurrentTimeMillis(nowMs);
DashManifest manifest = new DashManifestParser().parse(Uri.parse("https://example.com/test.mpd"), TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_MPD_VOD));
DefaultDashChunkSource chunkSource = new DefaultDashChunkSource(BundledChunkExtractor.FACTORY, new LoaderErrorThrower.Dummy(), manifest, new BaseUrlExclusionList(), /* periodIndex= */
0, /* adaptationSetIndices= */
new int[] { 0 }, new FixedTrackSelection(new TrackGroup(new Format.Builder().build()), /* track= */
0), C.TRACK_TYPE_VIDEO, new FakeDataSource(), /* elapsedRealtimeOffsetMs= */
0, /* maxSegmentsPerLoad= */
1, /* enableEventMessageTrack= */
false, /* closedCaptionFormats */
ImmutableList.of(), /* playerTrackEmsgHandler= */
null, PlayerId.UNSET);
ChunkHolder output = new ChunkHolder();
chunkSource.getNextChunk(/* playbackPositionUs= */
0, /* loadPositionUs= */
0, /* queue= */
ImmutableList.of(), output);
assertThat(output.chunk.dataSpec.flags & DataSpec.FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED).isEqualTo(0);
}
use of androidx.media3.test.utils.FakeDataSource in project media by androidx.
the class DefaultDashChunkSourceTest method createDashChunkSource.
private DashChunkSource createDashChunkSource(int numberOfTracks) throws IOException {
Assertions.checkArgument(numberOfTracks < 6);
DashManifest manifest = new DashManifestParser().parse(Uri.parse("https://example.com/test.mpd"), TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_MPD_VOD_LOCATION_FALLBACK));
int[] adaptationSetIndices = new int[] { 0 };
int[] selectedTracks = new int[numberOfTracks];
Format[] formats = new Format[numberOfTracks];
for (int i = 0; i < numberOfTracks; i++) {
selectedTracks[i] = i;
formats[i] = manifest.getPeriod(0).adaptationSets.get(adaptationSetIndices[0]).representations.get(i).format;
}
AdaptiveTrackSelection adaptiveTrackSelection = new AdaptiveTrackSelection(new TrackGroup(formats), selectedTracks, new DefaultBandwidthMeter.Builder(ApplicationProvider.getApplicationContext()).build());
return new DefaultDashChunkSource(BundledChunkExtractor.FACTORY, new LoaderErrorThrower.Dummy(), manifest, new BaseUrlExclusionList(new Random(/* seed= */
1234)), /* periodIndex= */
0, /* adaptationSetIndices= */
adaptationSetIndices, adaptiveTrackSelection, C.TRACK_TYPE_VIDEO, new FakeDataSource(), /* elapsedRealtimeOffsetMs= */
0, /* maxSegmentsPerLoad= */
1, /* enableEventMessageTrack= */
false, /* closedCaptionFormats */
ImmutableList.of(), /* playerTrackEmsgHandler= */
null, PlayerId.UNSET);
}
use of androidx.media3.test.utils.FakeDataSource in project media by androidx.
the class DashDownloaderTest method progressiveDownloadSeparatePeriods.
@Test
public void progressiveDownloadSeparatePeriods() 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("period_2_segment_1", 1).setRandomData("period_2_segment_2", 2).setRandomData("period_2_segment_3", 3);
FakeDataSource fakeDataSource = new FakeDataSource(fakeDataSet);
FakeDataSource.Factory factory = mock(FakeDataSource.Factory.class);
when(factory.createDataSource()).thenReturn(fakeDataSource);
DashDownloader dashDownloader = getDashDownloader(factory, new StreamKey(0, 0, 0), new StreamKey(1, 0, 0));
dashDownloader.download(progressListener);
DataSpec[] openedDataSpecs = fakeDataSource.getAndClearOpenedDataSpecs();
assertThat(openedDataSpecs.length).isEqualTo(8);
assertThat(openedDataSpecs[0].uri).isEqualTo(TEST_MPD_URI);
assertThat(openedDataSpecs[1].uri.getPath()).isEqualTo("audio_init_data");
assertThat(openedDataSpecs[2].uri.getPath()).isEqualTo("audio_segment_1");
assertThat(openedDataSpecs[3].uri.getPath()).isEqualTo("audio_segment_2");
assertThat(openedDataSpecs[4].uri.getPath()).isEqualTo("audio_segment_3");
assertThat(openedDataSpecs[5].uri.getPath()).isEqualTo("period_2_segment_1");
assertThat(openedDataSpecs[6].uri.getPath()).isEqualTo("period_2_segment_2");
assertThat(openedDataSpecs[7].uri.getPath()).isEqualTo("period_2_segment_3");
}
use of androidx.media3.test.utils.FakeDataSource in project media by androidx.
the class DashDownloaderTest method progressiveDownload.
@Test
public void progressiveDownload() 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);
FakeDataSource fakeDataSource = new FakeDataSource(fakeDataSet);
FakeDataSource.Factory factory = mock(FakeDataSource.Factory.class);
when(factory.createDataSource()).thenReturn(fakeDataSource);
DashDownloader dashDownloader = getDashDownloader(factory, new StreamKey(0, 0, 0), new StreamKey(0, 1, 0));
dashDownloader.download(progressListener);
DataSpec[] openedDataSpecs = fakeDataSource.getAndClearOpenedDataSpecs();
assertThat(openedDataSpecs.length).isEqualTo(8);
assertThat(openedDataSpecs[0].uri).isEqualTo(TEST_MPD_URI);
assertThat(openedDataSpecs[1].uri.getPath()).isEqualTo("audio_init_data");
assertThat(openedDataSpecs[2].uri.getPath()).isEqualTo("audio_segment_1");
assertThat(openedDataSpecs[3].uri.getPath()).isEqualTo("text_segment_1");
assertThat(openedDataSpecs[4].uri.getPath()).isEqualTo("audio_segment_2");
assertThat(openedDataSpecs[5].uri.getPath()).isEqualTo("text_segment_2");
assertThat(openedDataSpecs[6].uri.getPath()).isEqualTo("audio_segment_3");
assertThat(openedDataSpecs[7].uri.getPath()).isEqualTo("text_segment_3");
}
use of androidx.media3.test.utils.FakeDataSource in project media by androidx.
the class ExtractorUtilTest method skipFullyQuietly_endNotReached_isTrueAndSkipsData.
@Test
public void skipFullyQuietly_endNotReached_isTrueAndSkipsData() throws Exception {
FakeDataSource testDataSource = new FakeDataSource();
testDataSource.getDataSet().newDefaultData().appendReadData(Arrays.copyOf(TEST_DATA, 3)).appendReadData(Arrays.copyOfRange(TEST_DATA, 3, 6)).appendReadData(Arrays.copyOfRange(TEST_DATA, 6, 9));
testDataSource.open(new DataSpec(Uri.parse(TEST_URI)));
ExtractorInput input = new DefaultExtractorInput(testDataSource, 0, C.LENGTH_UNSET);
int length = 4;
boolean hasRead = ExtractorUtil.skipFullyQuietly(input, length);
assertThat(hasRead).isTrue();
assertThat(input.getPosition()).isEqualTo(length);
}
Aggregations