mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Make VideoGraph and VideoFrameProcessor listener methods optional
PiperOrigin-RevId: 686833280
This commit is contained in:
parent
d2ccace75c
commit
38c27d45f1
@ -143,8 +143,8 @@ public interface VideoFrameProcessor {
|
||||
* @param effects The list of {@link Effect effects} to apply to the new input stream.
|
||||
* @param frameInfo The {@link FrameInfo} of the new input stream.
|
||||
*/
|
||||
void onInputStreamRegistered(
|
||||
@InputType int inputType, List<Effect> effects, FrameInfo frameInfo);
|
||||
default void onInputStreamRegistered(
|
||||
@InputType int inputType, List<Effect> effects, FrameInfo frameInfo) {}
|
||||
|
||||
/**
|
||||
* Called when the output size changes.
|
||||
@ -155,7 +155,7 @@ public interface VideoFrameProcessor {
|
||||
* <p>The output size may differ from the size specified using {@link
|
||||
* #setOutputSurfaceInfo(SurfaceInfo)}.
|
||||
*/
|
||||
void onOutputSizeChanged(int width, int height);
|
||||
default void onOutputSizeChanged(int width, int height) {}
|
||||
|
||||
/**
|
||||
* Called when an output frame with the given {@code presentationTimeUs} becomes available for
|
||||
@ -163,7 +163,7 @@ public interface VideoFrameProcessor {
|
||||
*
|
||||
* @param presentationTimeUs The presentation time of the frame, in microseconds.
|
||||
*/
|
||||
void onOutputFrameAvailableForRendering(long presentationTimeUs);
|
||||
default void onOutputFrameAvailableForRendering(long presentationTimeUs) {}
|
||||
|
||||
/**
|
||||
* Called when an exception occurs during asynchronous video frame processing.
|
||||
@ -171,10 +171,10 @@ public interface VideoFrameProcessor {
|
||||
* <p>If this is called, the calling {@link VideoFrameProcessor} must immediately be {@linkplain
|
||||
* VideoFrameProcessor#release() released}.
|
||||
*/
|
||||
void onError(VideoFrameProcessingException exception);
|
||||
default void onError(VideoFrameProcessingException exception) {}
|
||||
|
||||
/** Called after the {@link VideoFrameProcessor} has rendered its final output frame. */
|
||||
void onEnded();
|
||||
default void onEnded() {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,7 +33,7 @@ public interface VideoGraph {
|
||||
* @param width The new output width in pixels.
|
||||
* @param height The new output width in pixels.
|
||||
*/
|
||||
void onOutputSizeChanged(int width, int height);
|
||||
default void onOutputSizeChanged(int width, int height) {}
|
||||
|
||||
/**
|
||||
* Called when an output frame with the given {@code framePresentationTimeUs} becomes available
|
||||
@ -41,14 +41,14 @@ public interface VideoGraph {
|
||||
*
|
||||
* @param framePresentationTimeUs The presentation time of the frame, in microseconds.
|
||||
*/
|
||||
void onOutputFrameAvailableForRendering(long framePresentationTimeUs);
|
||||
default void onOutputFrameAvailableForRendering(long framePresentationTimeUs) {}
|
||||
|
||||
/**
|
||||
* Called after the {@link VideoGraph} has rendered its final output frame.
|
||||
*
|
||||
* @param finalFramePresentationTimeUs The timestamp of the last output frame, in microseconds.
|
||||
*/
|
||||
void onEnded(long finalFramePresentationTimeUs);
|
||||
default void onEnded(long finalFramePresentationTimeUs) {}
|
||||
|
||||
/**
|
||||
* Called when an exception occurs during video frame processing.
|
||||
@ -56,7 +56,7 @@ public interface VideoGraph {
|
||||
* <p>If this is called, the calling {@link VideoGraph} must immediately be {@linkplain
|
||||
* #release() released}.
|
||||
*/
|
||||
void onError(VideoFrameProcessingException exception);
|
||||
default void onError(VideoFrameProcessingException exception) {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,19 +95,10 @@ public class DefaultVideoFrameProcessorTest {
|
||||
inputStreamRegisteredCountDownLatch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOutputSizeChanged(int width, int height) {}
|
||||
|
||||
@Override
|
||||
public void onOutputFrameAvailableForRendering(long presentationTimeUs) {}
|
||||
|
||||
@Override
|
||||
public void onError(VideoFrameProcessingException exception) {
|
||||
videoFrameProcessingException.set(exception);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnded() {}
|
||||
});
|
||||
|
||||
CountDownLatch videoFrameProcessorConfigurationCountDownLatch = new CountDownLatch(1);
|
||||
@ -157,19 +148,10 @@ public class DefaultVideoFrameProcessorTest {
|
||||
countDownLatch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOutputSizeChanged(int width, int height) {}
|
||||
|
||||
@Override
|
||||
public void onOutputFrameAvailableForRendering(long presentationTimeUs) {}
|
||||
|
||||
@Override
|
||||
public void onError(VideoFrameProcessingException exception) {
|
||||
videoFrameProcessingException.set(exception);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnded() {}
|
||||
});
|
||||
|
||||
InputStreamInfo stream1 =
|
||||
@ -230,9 +212,6 @@ public class DefaultVideoFrameProcessorTest {
|
||||
inputStreamRegisteredCondition.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOutputSizeChanged(int width, int height) {}
|
||||
|
||||
@Override
|
||||
public void onOutputFrameAvailableForRendering(long presentationTimeUs) {
|
||||
outputFrameCount++;
|
||||
@ -313,9 +292,6 @@ public class DefaultVideoFrameProcessorTest {
|
||||
inputStreamRegisteredCountDownLatch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOutputSizeChanged(int width, int height) {}
|
||||
|
||||
@Override
|
||||
public void onOutputFrameAvailableForRendering(long presentationTimeUs) {
|
||||
outputFrameCount.incrementAndGet();
|
||||
|
@ -138,9 +138,6 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
videoFrameProcessorReadyCountDownLatch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOutputSizeChanged(int width, int height) {}
|
||||
|
||||
@Override
|
||||
public void onOutputFrameAvailableForRendering(long presentationTimeUs) {
|
||||
actualPresentationTimesUs.add(presentationTimeUs);
|
||||
|
@ -249,17 +249,6 @@ public abstract class MultipleInputVideoGraph implements VideoGraph {
|
||||
listenerExecutor,
|
||||
new VideoFrameProcessor.Listener() {
|
||||
// All of this listener's methods are called on the sharedExecutorService.
|
||||
@Override
|
||||
public void onInputStreamRegistered(
|
||||
@VideoFrameProcessor.InputType int inputType,
|
||||
List<Effect> effects,
|
||||
FrameInfo frameInfo) {}
|
||||
|
||||
@Override
|
||||
public void onOutputSizeChanged(int width, int height) {}
|
||||
|
||||
@Override
|
||||
public void onOutputFrameAvailableForRendering(long presentationTimeUs) {}
|
||||
|
||||
@Override
|
||||
public void onError(VideoFrameProcessingException exception) {
|
||||
|
@ -25,15 +25,12 @@ import androidx.annotation.Nullable;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.ColorInfo;
|
||||
import androidx.media3.common.DebugViewProvider;
|
||||
import androidx.media3.common.Effect;
|
||||
import androidx.media3.common.FrameInfo;
|
||||
import androidx.media3.common.SurfaceInfo;
|
||||
import androidx.media3.common.VideoFrameProcessingException;
|
||||
import androidx.media3.common.VideoFrameProcessor;
|
||||
import androidx.media3.common.VideoGraph;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
/** A {@link VideoGraph} that handles one input stream. */
|
||||
@ -112,12 +109,6 @@ public abstract class SingleInputVideoGraph implements VideoGraph {
|
||||
new VideoFrameProcessor.Listener() {
|
||||
private long lastProcessedFramePresentationTimeUs;
|
||||
|
||||
@Override
|
||||
public void onInputStreamRegistered(
|
||||
@VideoFrameProcessor.InputType int inputType,
|
||||
List<Effect> effects,
|
||||
FrameInfo frameInfo) {}
|
||||
|
||||
@Override
|
||||
public void onOutputSizeChanged(int width, int height) {
|
||||
listenerExecutor.execute(() -> listener.onOutputSizeChanged(width, height));
|
||||
|
Loading…
x
Reference in New Issue
Block a user