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}.
|
* <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.
|
* @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
|
* Returns the {@link VideoFrameProcessor} that handles the processing for an input registered via
|
||||||
|
@ -142,9 +142,8 @@ public final class DefaultVideoCompositor implements VideoCompositor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized int registerInputSource(int sequenceIndex) {
|
public synchronized void registerInputSource(int sequenceIndex) {
|
||||||
inputSources.put(sequenceIndex, new InputSource());
|
inputSources.put(sequenceIndex, new InputSource());
|
||||||
return sequenceIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -211,10 +211,9 @@ public abstract class MultipleInputVideoGraph implements VideoGraph {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int registerInput(int sequenceIndex) throws VideoFrameProcessingException {
|
public void registerInput(int sequenceIndex) throws VideoFrameProcessingException {
|
||||||
checkStateNotNull(videoCompositor);
|
checkStateNotNull(videoCompositor);
|
||||||
|
videoCompositor.registerInputSource(sequenceIndex);
|
||||||
int videoCompositorInputId = videoCompositor.registerInputSource(sequenceIndex);
|
|
||||||
// Creating a new VideoFrameProcessor for the input.
|
// Creating a new VideoFrameProcessor for the input.
|
||||||
VideoFrameProcessor preProcessor =
|
VideoFrameProcessor preProcessor =
|
||||||
videoFrameProcessorFactory
|
videoFrameProcessorFactory
|
||||||
@ -223,7 +222,7 @@ public abstract class MultipleInputVideoGraph implements VideoGraph {
|
|||||||
// Texture output to compositor.
|
// Texture output to compositor.
|
||||||
(textureProducer, texture, presentationTimeUs, syncObject) ->
|
(textureProducer, texture, presentationTimeUs, syncObject) ->
|
||||||
queuePreProcessingOutputToCompositor(
|
queuePreProcessingOutputToCompositor(
|
||||||
videoCompositorInputId, textureProducer, texture, presentationTimeUs),
|
sequenceIndex, textureProducer, texture, presentationTimeUs),
|
||||||
PRE_COMPOSITOR_TEXTURE_OUTPUT_CAPACITY)
|
PRE_COMPOSITOR_TEXTURE_OUTPUT_CAPACITY)
|
||||||
.build()
|
.build()
|
||||||
.create(
|
.create(
|
||||||
@ -254,11 +253,10 @@ public abstract class MultipleInputVideoGraph implements VideoGraph {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnded() {
|
public void onEnded() {
|
||||||
onPreProcessingVideoFrameProcessorEnded(videoCompositorInputId);
|
onPreProcessingVideoFrameProcessorEnded(sequenceIndex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
preProcessors.put(videoCompositorInputId, preProcessor);
|
preProcessors.put(sequenceIndex, preProcessor);
|
||||||
return videoCompositorInputId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -99,7 +99,7 @@ public abstract class SingleInputVideoGraph implements VideoGraph {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int registerInput(int sequenceIndex) throws VideoFrameProcessingException {
|
public void registerInput(int sequenceIndex) throws VideoFrameProcessingException {
|
||||||
checkStateNotNull(videoFrameProcessor == null && !released);
|
checkStateNotNull(videoFrameProcessor == null && !released);
|
||||||
|
|
||||||
videoFrameProcessor =
|
videoFrameProcessor =
|
||||||
@ -159,7 +159,6 @@ public abstract class SingleInputVideoGraph implements VideoGraph {
|
|||||||
if (outputSurfaceInfo != null) {
|
if (outputSurfaceInfo != null) {
|
||||||
videoFrameProcessor.setOutputSurfaceInfo(outputSurfaceInfo);
|
videoFrameProcessor.setOutputSurfaceInfo(outputSurfaceInfo);
|
||||||
}
|
}
|
||||||
return SINGLE_INPUT_INDEX;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
* @param sequenceIndex The sequence index of the input source, which is can be used to determine
|
||||||
* the order of the input sources.
|
* 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}.
|
* 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.
|
// reduces decoder timeouts, and consider restoring.
|
||||||
videoFrameProcessorMaxPendingFrameCount =
|
videoFrameProcessorMaxPendingFrameCount =
|
||||||
Util.getMaxPendingFramesCountForMediaCodecDecoders(context);
|
Util.getMaxPendingFramesCountForMediaCodecDecoders(context);
|
||||||
int videoGraphInputId = videoGraph.registerInput(0);
|
videoGraph.registerInput(0);
|
||||||
videoFrameProcessor = videoGraph.getProcessor(videoGraphInputId);
|
videoFrameProcessor = videoGraph.getProcessor(0);
|
||||||
|
|
||||||
videoEffects = new ArrayList<>();
|
videoEffects = new ArrayList<>();
|
||||||
finalBufferPresentationTimeUs = C.TIME_UNSET;
|
finalBufferPresentationTimeUs = C.TIME_UNSET;
|
||||||
|
@ -856,7 +856,8 @@ public final class DefaultVideoCompositorPixelTest {
|
|||||||
VideoCompositor videoCompositor,
|
VideoCompositor videoCompositor,
|
||||||
@Nullable ExecutorService executorService,
|
@Nullable ExecutorService executorService,
|
||||||
GlObjectsProvider glObjectsProvider) {
|
GlObjectsProvider glObjectsProvider) {
|
||||||
int inputId = videoCompositor.registerInputSource(0);
|
int sequenceIndex = 0;
|
||||||
|
videoCompositor.registerInputSource(sequenceIndex);
|
||||||
DefaultVideoFrameProcessor.Factory.Builder defaultVideoFrameProcessorFactoryBuilder =
|
DefaultVideoFrameProcessor.Factory.Builder defaultVideoFrameProcessorFactoryBuilder =
|
||||||
new DefaultVideoFrameProcessor.Factory.Builder()
|
new DefaultVideoFrameProcessor.Factory.Builder()
|
||||||
.setGlObjectsProvider(glObjectsProvider)
|
.setGlObjectsProvider(glObjectsProvider)
|
||||||
@ -870,7 +871,7 @@ public final class DefaultVideoCompositorPixelTest {
|
|||||||
textureBitmapReader.readBitmapUnpremultipliedAlpha(
|
textureBitmapReader.readBitmapUnpremultipliedAlpha(
|
||||||
outputTexture, presentationTimeUs);
|
outputTexture, presentationTimeUs);
|
||||||
videoCompositor.queueInputTexture(
|
videoCompositor.queueInputTexture(
|
||||||
inputId,
|
sequenceIndex,
|
||||||
outputTextureProducer,
|
outputTextureProducer,
|
||||||
outputTexture,
|
outputTexture,
|
||||||
ColorInfo.SRGB_BT709_FULL,
|
ColorInfo.SRGB_BT709_FULL,
|
||||||
@ -884,7 +885,7 @@ public final class DefaultVideoCompositorPixelTest {
|
|||||||
.setTestId(testId)
|
.setTestId(testId)
|
||||||
.setVideoFrameProcessorFactory(defaultVideoFrameProcessorFactoryBuilder.build())
|
.setVideoFrameProcessorFactory(defaultVideoFrameProcessorFactoryBuilder.build())
|
||||||
.setBitmapReader(textureBitmapReader)
|
.setBitmapReader(textureBitmapReader)
|
||||||
.setOnEndedListener(() -> videoCompositor.signalEndOfInputSource(inputId));
|
.setOnEndedListener(() -> videoCompositor.signalEndOfInputSource(sequenceIndex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,8 +80,8 @@ import java.util.concurrent.Executor;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GraphInput createInput(int sequenceIndex) throws VideoFrameProcessingException {
|
public GraphInput createInput(int sequenceIndex) throws VideoFrameProcessingException {
|
||||||
int inputId = registerInput(sequenceIndex);
|
registerInput(sequenceIndex);
|
||||||
return new VideoFrameProcessingWrapper(
|
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
|
@Override
|
||||||
public GraphInput createInput(int sequenceIndex) throws VideoFrameProcessingException {
|
public GraphInput createInput(int sequenceIndex) throws VideoFrameProcessingException {
|
||||||
checkState(videoFrameProcessingWrapper == null);
|
checkState(videoFrameProcessingWrapper == null);
|
||||||
int inputId = registerInput(sequenceIndex);
|
registerInput(sequenceIndex);
|
||||||
videoFrameProcessingWrapper =
|
videoFrameProcessingWrapper =
|
||||||
new VideoFrameProcessingWrapper(
|
new VideoFrameProcessingWrapper(
|
||||||
getProcessor(inputId),
|
getProcessor(sequenceIndex), getPresentation(), getInitialTimestampOffsetUs());
|
||||||
getInputColorInfo(),
|
|
||||||
getPresentation(),
|
|
||||||
getInitialTimestampOffsetUs());
|
|
||||||
return videoFrameProcessingWrapper;
|
return videoFrameProcessingWrapper;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -543,8 +543,8 @@ import org.checkerframework.dataflow.qual.Pure;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int registerInput(int sequenceIndex) throws VideoFrameProcessingException {
|
public void registerInput(int sequenceIndex) throws VideoFrameProcessingException {
|
||||||
return videoGraph.registerInput(sequenceIndex);
|
videoGraph.registerInput(sequenceIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user