|
|
|
@ -4,16 +4,17 @@ import android.graphics.SurfaceTexture; |
|
|
|
|
import android.opengl.Matrix; |
|
|
|
|
import android.os.Build; |
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull; |
|
|
|
|
import androidx.annotation.Nullable; |
|
|
|
|
import androidx.annotation.RequiresApi; |
|
|
|
|
|
|
|
|
|
import com.otaliastudios.cameraview.CameraLogger; |
|
|
|
|
import com.otaliastudios.cameraview.filters.Filter; |
|
|
|
|
import com.otaliastudios.cameraview.internal.egl.EglCore; |
|
|
|
|
import com.otaliastudios.cameraview.internal.egl.EglViewport; |
|
|
|
|
import com.otaliastudios.cameraview.internal.egl.EglWindowSurface; |
|
|
|
|
import com.otaliastudios.cameraview.internal.utils.Pool; |
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull; |
|
|
|
|
import androidx.annotation.Nullable; |
|
|
|
|
import androidx.annotation.RequiresApi; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Default implementation for video encoding. |
|
|
|
|
*/ |
|
|
|
@ -24,6 +25,7 @@ public class TextureMediaEncoder extends VideoMediaEncoder<TextureConfig> { |
|
|
|
|
private static final CameraLogger LOG = CameraLogger.create(TAG); |
|
|
|
|
|
|
|
|
|
public final static String FRAME_EVENT = "frame"; |
|
|
|
|
public final static String FILTER_EVENT = "filter"; |
|
|
|
|
|
|
|
|
|
private int mTransformRotation; |
|
|
|
|
private EglCore mEglCore; |
|
|
|
@ -132,7 +134,11 @@ public class TextureMediaEncoder extends VideoMediaEncoder<TextureConfig> { |
|
|
|
|
@EncoderThread |
|
|
|
|
@Override |
|
|
|
|
protected void onEvent(@NonNull String event, @Nullable Object data) { |
|
|
|
|
if (!event.equals(FRAME_EVENT)) return; |
|
|
|
|
|
|
|
|
|
if (event.equals(FILTER_EVENT)) { |
|
|
|
|
Filter filter = (Filter) data; |
|
|
|
|
mViewport.changeShaderFilter(filter); |
|
|
|
|
} else if (event.equals(FRAME_EVENT)) { |
|
|
|
|
Frame frame = (Frame) data; |
|
|
|
|
if (frame == null) { |
|
|
|
|
throw new IllegalArgumentException("Got null frame for FRAME_EVENT."); |
|
|
|
@ -207,6 +213,7 @@ public class TextureMediaEncoder extends VideoMediaEncoder<TextureConfig> { |
|
|
|
|
mWindow.swapBuffers(); |
|
|
|
|
mFramePool.recycle(frame); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected void onStopped() { |
|
|
|
|