use of com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerTrackEmsgHandler in project ExoPlayer by google.
the class DefaultDashChunkSourceTest method getNextChunk_forLowLatencyManifest_setsCorrectMayNotLoadAtFullNetworkSpeedFlag.
@Test
public void getNextChunk_forLowLatencyManifest_setsCorrectMayNotLoadAtFullNetworkSpeedFlag() 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_LIVE_WITH_OFFSET_INSIDE_WINDOW));
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);
long nowInPeriodUs = Util.msToUs(nowMs - manifest.availabilityStartTimeMs);
ChunkHolder output = new ChunkHolder();
chunkSource.getNextChunk(/* playbackPositionUs= */
nowInPeriodUs - 5 * C.MICROS_PER_SECOND, /* loadPositionUs= */
nowInPeriodUs - 5 * C.MICROS_PER_SECOND, /* queue= */
ImmutableList.of(), output);
assertThat(output.chunk.dataSpec.flags & DataSpec.FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED).isEqualTo(0);
chunkSource.getNextChunk(/* playbackPositionUs= */
nowInPeriodUs, /* loadPositionUs= */
nowInPeriodUs, /* queue= */
ImmutableList.of(), output);
assertThat(output.chunk.dataSpec.flags & DataSpec.FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED).isNotEqualTo(0);
}
use of com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerTrackEmsgHandler in project ExoPlayer by google.
the class DefaultDashChunkSource method onChunkLoadCompleted.
@Override
public void onChunkLoadCompleted(Chunk chunk) {
if (chunk instanceof InitializationChunk) {
InitializationChunk initializationChunk = (InitializationChunk) chunk;
int trackIndex = trackSelection.indexOf(initializationChunk.trackFormat);
RepresentationHolder representationHolder = representationHolders[trackIndex];
// where it does we should ignore it.
if (representationHolder.segmentIndex == null) {
@Nullable ChunkIndex chunkIndex = representationHolder.chunkExtractor.getChunkIndex();
if (chunkIndex != null) {
representationHolders[trackIndex] = representationHolder.copyWithNewSegmentIndex(new DashWrappingSegmentIndex(chunkIndex, representationHolder.representation.presentationTimeOffsetUs));
}
}
}
if (playerTrackEmsgHandler != null) {
playerTrackEmsgHandler.onChunkLoadCompleted(chunk);
}
}
Aggregations