mirror of
https://github.com/samsonjs/media.git
synced 2026-03-29 10:05:48 +00:00
Move inputExternalSurfaceTexture to the ExternalTextureManager
Now that the GLEffectFrameProcessor handles external (video) and internal (image) input, components used only for external input needs should be moved to the ExternalTextureManager for code clarity PiperOrigin-RevId: 509787494
This commit is contained in:
parent
7497b1e003
commit
f7621aacc3
2 changed files with 18 additions and 13 deletions
|
|
@ -18,6 +18,7 @@ package com.google.android.exoplayer2.effect;
|
|||
import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
|
||||
|
||||
import android.graphics.SurfaceTexture;
|
||||
import android.view.Surface;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.WorkerThread;
|
||||
import com.google.android.exoplayer2.C;
|
||||
|
|
@ -39,6 +40,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
private final FrameProcessingTaskExecutor frameProcessingTaskExecutor;
|
||||
private final ExternalShaderProgram externalShaderProgram;
|
||||
private final int externalTexId;
|
||||
private final Surface surface;
|
||||
private final SurfaceTexture surfaceTexture;
|
||||
private final float[] textureTransformMatrix;
|
||||
private final Queue<FrameInfo> pendingFrames;
|
||||
|
|
@ -71,6 +73,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
* @param frameProcessingTaskExecutor The {@link FrameProcessingTaskExecutor}.
|
||||
* @throws FrameProcessingException If a problem occurs while creating the external texture.
|
||||
*/
|
||||
// The onFrameAvailableListener will not be invoked until the constructor returns.
|
||||
@SuppressWarnings("nullness:method.invocation.invalid")
|
||||
public ExternalTextureManager(
|
||||
ExternalShaderProgram externalShaderProgram,
|
||||
FrameProcessingTaskExecutor frameProcessingTaskExecutor)
|
||||
|
|
@ -86,11 +90,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
textureTransformMatrix = new float[16];
|
||||
pendingFrames = new ConcurrentLinkedQueue<>();
|
||||
externalShaderProgramInputCapacity = new AtomicInteger();
|
||||
|
||||
previousStreamOffsetUs = C.TIME_UNSET;
|
||||
}
|
||||
|
||||
public SurfaceTexture getSurfaceTexture() {
|
||||
surfaceTexture.setOnFrameAvailableListener(
|
||||
unused ->
|
||||
frameProcessingTaskExecutor.submit(
|
||||
|
|
@ -104,7 +104,17 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
maybeQueueFrameToExternalShaderProgram();
|
||||
}
|
||||
}));
|
||||
return surfaceTexture;
|
||||
surface = new Surface(surfaceTexture);
|
||||
}
|
||||
|
||||
/** See {@link GlEffectsFrameProcessor#setInputDefaultBufferSize}. */
|
||||
public void setDefaultBufferSize(int width, int height) {
|
||||
surfaceTexture.setDefaultBufferSize(width, height);
|
||||
}
|
||||
|
||||
/** Returns the {@linkplain Surface input surface} that wraps the external texture. */
|
||||
public Surface getInputSurface() {
|
||||
return surface;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -173,6 +183,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
|
||||
public void release() {
|
||||
surfaceTexture.release();
|
||||
surface.release();
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
|
|||
|
|
@ -356,8 +356,6 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
|
|||
private final FrameProcessingTaskExecutor frameProcessingTaskExecutor;
|
||||
private @MonotonicNonNull InternalTextureManager inputInternalTextureManager;
|
||||
private @MonotonicNonNull ExternalTextureManager inputExternalTextureManager;
|
||||
// TODO(262693274): Move this variable to ExternalTextureManager.
|
||||
private @MonotonicNonNull Surface inputExternalSurface;
|
||||
private final boolean releaseFramesAutomatically;
|
||||
private final FinalMatrixShaderProgramWrapper finalShaderProgramWrapper;
|
||||
private final ImmutableList<GlShaderProgram> allShaderPrograms;
|
||||
|
|
@ -396,7 +394,6 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
|
|||
new ExternalTextureManager(
|
||||
(ExternalShaderProgram) inputShaderProgram, frameProcessingTaskExecutor);
|
||||
inputShaderProgram.setInputListener(inputExternalTextureManager);
|
||||
inputExternalSurface = new Surface(inputExternalTextureManager.getSurfaceTexture());
|
||||
} else {
|
||||
inputInternalTextureManager =
|
||||
new InternalTextureManager(inputShaderProgram, frameProcessingTaskExecutor);
|
||||
|
|
@ -430,9 +427,7 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
|
|||
* @param height The default height for input buffers, in pixels.
|
||||
*/
|
||||
public void setInputDefaultBufferSize(int width, int height) {
|
||||
checkNotNull(inputExternalTextureManager)
|
||||
.getSurfaceTexture()
|
||||
.setDefaultBufferSize(width, height);
|
||||
checkNotNull(inputExternalTextureManager).setDefaultBufferSize(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -443,7 +438,7 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
|
|||
|
||||
@Override
|
||||
public Surface getInputSurface() {
|
||||
return checkNotNull(inputExternalSurface);
|
||||
return checkNotNull(inputExternalTextureManager).getInputSurface();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -521,7 +516,6 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
|
|||
}
|
||||
if (inputExternalTextureManager != null) {
|
||||
inputExternalTextureManager.release();
|
||||
checkNotNull(inputExternalSurface).release();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue