Effect: Report errors during registerInputStream

Without this, GLSL compilation errors may lead to the test stalling indefinitely

PiperOrigin-RevId: 603381111
This commit is contained in:
huangdarwin 2024-02-01 08:39:53 -08:00 committed by Copybara-Service
parent 198e3fb166
commit 42ac0e5492

View File

@ -312,6 +312,7 @@ public final class VideoFrameProcessorTestRunner {
public void onError(VideoFrameProcessingException exception) {
videoFrameProcessingException.set(exception);
checkNotNull(videoFrameProcessingEndedLatch).countDown();
videoFrameProcessorReadyCondition.open();
}
@Override
@ -340,12 +341,7 @@ public final class VideoFrameProcessorTestRunner {
mediaFormat.getInteger(MediaFormat.KEY_HEIGHT))
.setPixelWidthHeightRatio(pixelWidthHeightRatio)
.build());
try {
videoFrameProcessorReadyCondition.block();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException(e);
}
awaitVideoFrameProcessorReady();
checkState(videoFrameProcessor.registerInputFrame());
}
@ -365,8 +361,11 @@ public final class VideoFrameProcessorTestRunner {
}
public void queueInputBitmap(
Bitmap inputBitmap, long durationUs, long offsetToAddUs, float frameRate, ColorInfo colorInfo)
throws InterruptedException {
Bitmap inputBitmap,
long durationUs,
long offsetToAddUs,
float frameRate,
ColorInfo colorInfo) {
videoFrameProcessorReadyCondition.close();
videoFrameProcessor.registerInputStream(
INPUT_TYPE_BITMAP,
@ -375,20 +374,18 @@ public final class VideoFrameProcessorTestRunner {
.setPixelWidthHeightRatio(pixelWidthHeightRatio)
.setOffsetToAddUs(offsetToAddUs)
.build());
videoFrameProcessorReadyCondition.block();
awaitVideoFrameProcessorReady();
checkState(
videoFrameProcessor.queueInputBitmap(
inputBitmap, new ConstantRateTimestampIterator(durationUs, frameRate)));
}
public void queueInputBitmaps(int width, int height, Pair<Bitmap, TimestampIterator>... frames)
throws InterruptedException {
public void queueInputBitmaps(int width, int height, Pair<Bitmap, TimestampIterator>... frames) {
queueInputBitmaps(width, height, ColorInfo.SRGB_BT709_FULL, frames);
}
public void queueInputBitmaps(
int width, int height, ColorInfo colorInfo, Pair<Bitmap, TimestampIterator>... frames)
throws InterruptedException {
int width, int height, ColorInfo colorInfo, Pair<Bitmap, TimestampIterator>... frames) {
videoFrameProcessorReadyCondition.close();
videoFrameProcessor.registerInputStream(
INPUT_TYPE_BITMAP,
@ -396,7 +393,7 @@ public final class VideoFrameProcessorTestRunner {
new FrameInfo.Builder(colorInfo, width, height)
.setPixelWidthHeightRatio(pixelWidthHeightRatio)
.build());
videoFrameProcessorReadyCondition.block();
awaitVideoFrameProcessorReady();
for (Pair<Bitmap, TimestampIterator> frame : frames) {
videoFrameProcessor.queueInputBitmap(frame.first, frame.second);
}
@ -419,7 +416,7 @@ public final class VideoFrameProcessorTestRunner {
throw new VideoFrameProcessingException(e);
}
});
videoFrameProcessorReadyCondition.block();
awaitVideoFrameProcessorReady();
checkState(videoFrameProcessor.queueInputTexture(inputTexture.texId, pts));
}
@ -557,4 +554,14 @@ public final class VideoFrameProcessorTestRunner {
}
};
}
private void awaitVideoFrameProcessorReady() {
try {
videoFrameProcessorReadyCondition.block();
assertThat(videoFrameProcessingException.get()).isNull();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException(e);
}
}
}