mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Create a private util method to create blank frame bitmap
This method will be reused when inserting gaps in `GapSignalingAssetLoader` in upcoming CL. PiperOrigin-RevId: 732896566
This commit is contained in:
parent
1361d569cd
commit
86df7572d2
@ -65,10 +65,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
.setChannelCount(2)
|
.setChannelCount(2)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
private static final int BLANK_IMAGE_BITMAP_WIDTH = 1;
|
||||||
|
private static final int BLANK_IMAGE_BITMAP_HEIGHT = 1;
|
||||||
private static final Format BLANK_IMAGE_BITMAP_FORMAT =
|
private static final Format BLANK_IMAGE_BITMAP_FORMAT =
|
||||||
new Format.Builder()
|
new Format.Builder()
|
||||||
.setWidth(1)
|
.setWidth(BLANK_IMAGE_BITMAP_WIDTH)
|
||||||
.setHeight(1)
|
.setHeight(BLANK_IMAGE_BITMAP_HEIGHT)
|
||||||
.setSampleMimeType(MimeTypes.IMAGE_RAW)
|
.setSampleMimeType(MimeTypes.IMAGE_RAW)
|
||||||
.setColorInfo(ColorInfo.SRGB_BT709_FULL)
|
.setColorInfo(ColorInfo.SRGB_BT709_FULL)
|
||||||
.build();
|
.build();
|
||||||
@ -347,10 +349,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
// Fill video gap with blank frames.
|
// Fill video gap with blank frames.
|
||||||
onMediaItemChanged(C.TRACK_TYPE_VIDEO, /* outputFormat= */ BLANK_IMAGE_BITMAP_FORMAT);
|
onMediaItemChanged(C.TRACK_TYPE_VIDEO, /* outputFormat= */ BLANK_IMAGE_BITMAP_FORMAT);
|
||||||
nonEndedTrackCount.incrementAndGet();
|
nonEndedTrackCount.incrementAndGet();
|
||||||
Bitmap bitmap =
|
handler.post(() -> insertBlankFrames(getBlankImageBitmap()));
|
||||||
Bitmap.createBitmap(
|
|
||||||
new int[] {Color.BLACK}, /* width= */ 1, /* height= */ 1, Bitmap.Config.ARGB_8888);
|
|
||||||
handler.post(() -> insertBlankFrames(bitmap));
|
|
||||||
} else {
|
} else {
|
||||||
// Generate audio silence in the AudioGraph by signalling null format.
|
// Generate audio silence in the AudioGraph by signalling null format.
|
||||||
onMediaItemChanged(C.TRACK_TYPE_AUDIO, /* outputFormat= */ null);
|
onMediaItemChanged(C.TRACK_TYPE_AUDIO, /* outputFormat= */ null);
|
||||||
@ -359,6 +358,14 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
return sampleConsumer;
|
return sampleConsumer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Bitmap getBlankImageBitmap() {
|
||||||
|
return Bitmap.createBitmap(
|
||||||
|
new int[] {Color.BLACK},
|
||||||
|
BLANK_IMAGE_BITMAP_WIDTH,
|
||||||
|
BLANK_IMAGE_BITMAP_HEIGHT,
|
||||||
|
Bitmap.Config.ARGB_8888);
|
||||||
|
}
|
||||||
|
|
||||||
private void insertBlankFrames(Bitmap bitmap) {
|
private void insertBlankFrames(Bitmap bitmap) {
|
||||||
SampleConsumerWrapper videoSampleConsumer =
|
SampleConsumerWrapper videoSampleConsumer =
|
||||||
checkNotNull(sampleConsumersByTrackType.get(C.TRACK_TYPE_VIDEO));
|
checkNotNull(sampleConsumersByTrackType.get(C.TRACK_TYPE_VIDEO));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user