implement top down approach for passing input source id
This commit is contained in:
parent
3cccecf368
commit
52adaf8d26
@ -76,10 +76,8 @@ public interface VideoGraph {
|
||||
* <p>If the method throws, the caller must call {@link #release}.
|
||||
*
|
||||
* @param sequenceIndex The sequence index of the input which can aid ordering of the inputs.
|
||||
* @return The id of the registered input, which can be used to get the underlying {@link
|
||||
* VideoFrameProcessor} via {@link #getProcessor(int)}.
|
||||
*/
|
||||
int registerInput(int sequenceIndex) throws VideoFrameProcessingException;
|
||||
void registerInput(int sequenceIndex) throws VideoFrameProcessingException;
|
||||
|
||||
/**
|
||||
* Returns the {@link VideoFrameProcessor} that handles the processing for an input registered via
|
||||
|
@ -142,9 +142,8 @@ public final class DefaultVideoCompositor implements VideoCompositor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized int registerInputSource(int sequenceIndex) {
|
||||
public synchronized void registerInputSource(int sequenceIndex) {
|
||||
inputSources.put(sequenceIndex, new InputSource());
|
||||
return sequenceIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -211,10 +211,9 @@ public abstract class MultipleInputVideoGraph implements VideoGraph {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int registerInput(int sequenceIndex) throws VideoFrameProcessingException {
|
||||
public void registerInput(int sequenceIndex) throws VideoFrameProcessingException {
|
||||
checkStateNotNull(videoCompositor);
|
||||
|
||||
int videoCompositorInputId = videoCompositor.registerInputSource(sequenceIndex);
|
||||
videoCompositor.registerInputSource(sequenceIndex);
|
||||
// Creating a new VideoFrameProcessor for the input.
|
||||
VideoFrameProcessor preProcessor =
|
||||
videoFrameProcessorFactory
|
||||
@ -223,7 +222,7 @@ public abstract class MultipleInputVideoGraph implements VideoGraph {
|
||||
// Texture output to compositor.
|
||||
(textureProducer, texture, presentationTimeUs, syncObject) ->
|
||||
queuePreProcessingOutputToCompositor(
|
||||
videoCompositorInputId, textureProducer, texture, presentationTimeUs),
|
||||
sequenceIndex, textureProducer, texture, presentationTimeUs),
|
||||
PRE_COMPOSITOR_TEXTURE_OUTPUT_CAPACITY)
|
||||
.build()
|
||||
.create(
|
||||
@ -254,11 +253,10 @@ public abstract class MultipleInputVideoGraph implements VideoGraph {
|
||||
|
||||
@Override
|
||||
public void onEnded() {
|
||||
onPreProcessingVideoFrameProcessorEnded(videoCompositorInputId);
|
||||
onPreProcessingVideoFrameProcessorEnded(sequenceIndex);
|
||||
}
|
||||
});
|
||||
preProcessors.put(videoCompositorInputId, preProcessor);
|
||||
return videoCompositorInputId;
|
||||
preProcessors.put(sequenceIndex, preProcessor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -99,7 +99,7 @@ public abstract class SingleInputVideoGraph implements VideoGraph {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int registerInput(int sequenceIndex) throws VideoFrameProcessingException {
|
||||
public void registerInput(int sequenceIndex) throws VideoFrameProcessingException {
|
||||
checkStateNotNull(videoFrameProcessor == null && !released);
|
||||
|
||||
videoFrameProcessor =
|
||||
@ -159,7 +159,6 @@ public abstract class SingleInputVideoGraph implements VideoGraph {
|
||||
if (outputSurfaceInfo != null) {
|
||||
videoFrameProcessor.setOutputSurfaceInfo(outputSurfaceInfo);
|
||||
}
|
||||
return SINGLE_INPUT_INDEX;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,7 +52,7 @@ public interface VideoCompositor extends GlTextureProducer {
|
||||
* @param sequenceIndex The sequence index of the input source, which is can be used to determine
|
||||
* the order of the input sources.
|
||||
*/
|
||||
int registerInputSource(int sequenceIndex);
|
||||
void registerInputSource(int sequenceIndex);
|
||||
|
||||
/**
|
||||
* Signals that no more frames will come from the upstream {@link GlTextureProducer.Listener}.
|
||||
|
@ -550,8 +550,8 @@ public final class CompositingVideoSinkProvider
|
||||
// reduces decoder timeouts, and consider restoring.
|
||||
videoFrameProcessorMaxPendingFrameCount =
|
||||
Util.getMaxPendingFramesCountForMediaCodecDecoders(context);
|
||||
int videoGraphInputId = videoGraph.registerInput(0);
|
||||
videoFrameProcessor = videoGraph.getProcessor(videoGraphInputId);
|
||||
videoGraph.registerInput(0);
|
||||
videoFrameProcessor = videoGraph.getProcessor(0);
|
||||
|
||||
videoEffects = new ArrayList<>();
|
||||
finalBufferPresentationTimeUs = C.TIME_UNSET;
|
||||
|
@ -856,7 +856,8 @@ public final class DefaultVideoCompositorPixelTest {
|
||||
VideoCompositor videoCompositor,
|
||||
@Nullable ExecutorService executorService,
|
||||
GlObjectsProvider glObjectsProvider) {
|
||||
int inputId = videoCompositor.registerInputSource(0);
|
||||
int sequenceIndex = 0;
|
||||
videoCompositor.registerInputSource(sequenceIndex);
|
||||
DefaultVideoFrameProcessor.Factory.Builder defaultVideoFrameProcessorFactoryBuilder =
|
||||
new DefaultVideoFrameProcessor.Factory.Builder()
|
||||
.setGlObjectsProvider(glObjectsProvider)
|
||||
@ -870,7 +871,7 @@ public final class DefaultVideoCompositorPixelTest {
|
||||
textureBitmapReader.readBitmapUnpremultipliedAlpha(
|
||||
outputTexture, presentationTimeUs);
|
||||
videoCompositor.queueInputTexture(
|
||||
inputId,
|
||||
sequenceIndex,
|
||||
outputTextureProducer,
|
||||
outputTexture,
|
||||
ColorInfo.SRGB_BT709_FULL,
|
||||
@ -884,7 +885,7 @@ public final class DefaultVideoCompositorPixelTest {
|
||||
.setTestId(testId)
|
||||
.setVideoFrameProcessorFactory(defaultVideoFrameProcessorFactoryBuilder.build())
|
||||
.setBitmapReader(textureBitmapReader)
|
||||
.setOnEndedListener(() -> videoCompositor.signalEndOfInputSource(inputId));
|
||||
.setOnEndedListener(() -> videoCompositor.signalEndOfInputSource(sequenceIndex));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,8 +80,8 @@ import java.util.concurrent.Executor;
|
||||
|
||||
@Override
|
||||
public GraphInput createInput(int sequenceIndex) throws VideoFrameProcessingException {
|
||||
int inputId = registerInput(sequenceIndex);
|
||||
registerInput(sequenceIndex);
|
||||
return new VideoFrameProcessingWrapper(
|
||||
getProcessor(inputId), /* presentation= */ null, getInitialTimestampOffsetUs());
|
||||
getProcessor(sequenceIndex), /* presentation= */ null, getInitialTimestampOffsetUs());
|
||||
}
|
||||
}
|
||||
|
@ -108,13 +108,10 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@Override
|
||||
public GraphInput createInput(int sequenceIndex) throws VideoFrameProcessingException {
|
||||
checkState(videoFrameProcessingWrapper == null);
|
||||
int inputId = registerInput(sequenceIndex);
|
||||
registerInput(sequenceIndex);
|
||||
videoFrameProcessingWrapper =
|
||||
new VideoFrameProcessingWrapper(
|
||||
getProcessor(inputId),
|
||||
getInputColorInfo(),
|
||||
getPresentation(),
|
||||
getInitialTimestampOffsetUs());
|
||||
getProcessor(sequenceIndex), getPresentation(), getInitialTimestampOffsetUs());
|
||||
return videoFrameProcessingWrapper;
|
||||
}
|
||||
}
|
||||
|
@ -543,8 +543,8 @@ import org.checkerframework.dataflow.qual.Pure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int registerInput(int sequenceIndex) throws VideoFrameProcessingException {
|
||||
return videoGraph.registerInput(sequenceIndex);
|
||||
public void registerInput(int sequenceIndex) throws VideoFrameProcessingException {
|
||||
videoGraph.registerInput(sequenceIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user