Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix indeterminate z-order of EditedMediaItemSequences #1055

Merged
merged 8 commits into from
May 8, 2024
Merged
Prev Previous commit
Next Next commit
Format with google-java-format
  • Loading branch information
claincly committed May 8, 2024
commit 0403e5881d4045eb2b56675c70e1b1a2da51961b
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ interface Listener {

/**
* Returns the {@link VideoFrameProcessor} that handles the processing for an input registered via
* {@link #registerInput(int)}. If the {@code inputId} is not {@linkplain #registerInput(int)
* registered} before, this method will throw an {@link IllegalStateException}.
* {@link #registerInput(int)}. If the {@code sequenceIndex} is not {@linkplain
* #registerInput(int) registered} before, this method will throw an {@link
* IllegalStateException}.
*/
VideoFrameProcessor getProcessor(int inputId);
VideoFrameProcessor getProcessor(int sequenceIndex);

/**
* Sets the output surface and supporting information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
import androidx.media3.common.VideoGraph;
import androidx.media3.common.util.GlUtil;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;

import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayDeque;
import java.util.ArrayList;
Expand Down Expand Up @@ -262,9 +260,9 @@ public void onEnded() {
}

@Override
public VideoFrameProcessor getProcessor(int inputId) {
checkState(Util.contains(preProcessors, inputId));
return preProcessors.get(inputId);
public VideoFrameProcessor getProcessor(int sequenceIndex) {
checkState(contains(preProcessors, sequenceIndex));
return preProcessors.get(sequenceIndex);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void onEnded() {
}

@Override
public VideoFrameProcessor getProcessor(int inputId) {
public VideoFrameProcessor getProcessor(int sequenceIndex) {
return checkStateNotNull(videoFrameProcessor);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ interface Listener {
}

/**
* Registers a new input source, and returns a unique {@code inputId} corresponding to this
* source, to be used in {@link #queueInputTexture}.
* Registers a new input source.
*
* @param sequenceIndex The sequence index of the input source which is used to determine the
* order of the input sources.
* order of the input sources. The same index should to be used in {@link #queueInputTexture}.
*/
void registerInputSource(int sequenceIndex);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,8 @@ public VideoSinkImpl(Context context) {
// reduces decoder timeouts, and consider restoring.
videoFrameProcessorMaxPendingFrameCount =
Util.getMaxPendingFramesCountForMediaCodecDecoders(context);
videoGraph.registerInput(0);
videoFrameProcessor = videoGraph.getProcessor(0);
videoGraph.registerInput(/* sequenceIndex= */ 0);
videoFrameProcessor = videoGraph.getProcessor(/* sequenceIndex= */ 0);

videoEffects = new ArrayList<>();
finalBufferPresentationTimeUs = C.TIME_UNSET;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ TransformerVideoGraph create(
*
* <p>If the method throws any {@link Exception}, the caller must call {@link #release}.
*
* @param sequenceIndex The sequence index of the input, which can aid ordering of the inputs.
* @param sequenceIndex The index of the input sequence, which is used to order the inputs.
*/
GraphInput createInput(int sequenceIndex) throws VideoFrameProcessingException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,8 @@ public void registerInput(int sequenceIndex) throws VideoFrameProcessingExceptio
}

@Override
public VideoFrameProcessor getProcessor(int inputId) {
return videoGraph.getProcessor(inputId);
public VideoFrameProcessor getProcessor(int sequenceIndex) {
return videoGraph.getProcessor(sequenceIndex);
}

@Override
Expand Down