use of com.google.android.exoplayer2.testutil.FakeSampleStream.FakeSampleStreamItem.END_OF_STREAM_ITEM in project ExoPlayer by google.
the class MediaCodecVideoRendererTest method render_withMultipleQueued_sendsVideoSizeChangedWithCorrectPixelAspectRatioWhenMultipleQueued.
@Test
public void render_withMultipleQueued_sendsVideoSizeChangedWithCorrectPixelAspectRatioWhenMultipleQueued() throws Exception {
Format pAsp1 = VIDEO_H264.buildUpon().setPixelWidthHeightRatio(1f).build();
Format pAsp2 = VIDEO_H264.buildUpon().setPixelWidthHeightRatio(2f).build();
Format pAsp3 = VIDEO_H264.buildUpon().setPixelWidthHeightRatio(3f).build();
FakeSampleStream fakeSampleStream = new FakeSampleStream(new DefaultAllocator(/* trimOnReset= */
true, /* individualAllocationSize= */
1024), /* mediaSourceEventDispatcher= */
null, DrmSessionManager.DRM_UNSUPPORTED, new DrmSessionEventListener.EventDispatcher(), /* initialFormat= */
pAsp1, ImmutableList.of(oneByteSample(/* timeUs= */
0, C.BUFFER_FLAG_KEY_FRAME)));
fakeSampleStream.writeData(/* startPositionUs= */
0);
mediaCodecVideoRenderer.enable(RendererConfiguration.DEFAULT, new Format[] { pAsp1, pAsp2, pAsp3 }, fakeSampleStream, /* positionUs= */
0, /* joining= */
false, /* mayRenderStartOfStream= */
false, /* startPositionUs= */
0, /* offsetUs */
0);
mediaCodecVideoRenderer.start();
mediaCodecVideoRenderer.render(/* positionUs= */
0, SystemClock.elapsedRealtime() * 1000);
mediaCodecVideoRenderer.render(/* positionUs= */
250, SystemClock.elapsedRealtime() * 1000);
fakeSampleStream.append(ImmutableList.of(format(pAsp2), oneByteSample(/* timeUs= */
5_000), oneByteSample(/* timeUs= */
10_000), format(pAsp3), oneByteSample(/* timeUs= */
15_000), oneByteSample(/* timeUs= */
20_000), END_OF_STREAM_ITEM));
fakeSampleStream.writeData(/* startPositionUs= */
5_000);
mediaCodecVideoRenderer.setCurrentStreamFinal();
int pos = 500;
do {
mediaCodecVideoRenderer.render(/* positionUs= */
pos, SystemClock.elapsedRealtime() * 1000);
pos += 250;
} while (!mediaCodecVideoRenderer.isEnded());
shadowOf(testMainLooper).idle();
ArgumentCaptor<VideoSize> videoSizesCaptor = ArgumentCaptor.forClass(VideoSize.class);
verify(eventListener, times(3)).onVideoSizeChanged(videoSizesCaptor.capture());
assertThat(videoSizesCaptor.getAllValues().stream().map(videoSize -> videoSize.pixelWidthHeightRatio).collect(Collectors.toList())).containsExactly(1f, 2f, 3f);
}
use of com.google.android.exoplayer2.testutil.FakeSampleStream.FakeSampleStreamItem.END_OF_STREAM_ITEM in project ExoPlayer by google.
the class MetadataRendererTest method runRenderer.
private static List<Metadata> runRenderer(byte[] input) throws ExoPlaybackException {
List<Metadata> metadata = new ArrayList<>();
MetadataRenderer renderer = new MetadataRenderer(metadata::add, /* outputLooper= */
null);
FakeSampleStream fakeSampleStream = new FakeSampleStream(new DefaultAllocator(/* trimOnReset= */
true, /* individualAllocationSize= */
1024), /* mediaSourceEventDispatcher= */
null, DrmSessionManager.DRM_UNSUPPORTED, new DrmSessionEventListener.EventDispatcher(), EMSG_FORMAT, ImmutableList.of(sample(/* timeUs= */
0, C.BUFFER_FLAG_KEY_FRAME, input), END_OF_STREAM_ITEM));
fakeSampleStream.writeData(/* startPositionUs= */
0);
renderer.replaceStream(new Format[] { EMSG_FORMAT }, fakeSampleStream, /* startPositionUs= */
0L, /* offsetUs= */
0L);
// Read the format
renderer.render(/* positionUs= */
0, /* elapsedRealtimeUs= */
0);
// Read the data
renderer.render(/* positionUs= */
0, /* elapsedRealtimeUs= */
0);
return Collections.unmodifiableList(metadata);
}
Aggregations