Search in sources :

Example 6 with GLEnvironment

use of android.filterfw.core.GLEnvironment in project android_frameworks_base by ResurrectionRemix.

the class EffectContext method initInCurrentGlContext.

private void initInCurrentGlContext() {
    if (!GLEnvironment.isAnyContextActive()) {
        throw new RuntimeException("Attempting to initialize EffectContext with no active " + "GL context!");
    }
    GLEnvironment glEnvironment = new GLEnvironment();
    glEnvironment.initWithCurrentContext();
    mFilterContext.initGLEnvironment(glEnvironment);
}
Also used : GLEnvironment(android.filterfw.core.GLEnvironment)

Example 7 with GLEnvironment

use of android.filterfw.core.GLEnvironment in project android_frameworks_base by ResurrectionRemix.

the class MediaEncoderFilter method process.

@Override
public void process(FilterContext context) {
    GLEnvironment glEnv = context.getGLEnvironment();
    // Get input frame
    Frame input = pullInput("videoframe");
    // Check if recording needs to start
    if (!mRecordingActive && mRecording) {
        startRecording(context);
    }
    // Check if recording needs to stop
    if (mRecordingActive && !mRecording) {
        stopRecording(context);
    }
    if (!mRecordingActive)
        return;
    if (mCaptureTimeLapse) {
        if (skipFrameAndModifyTimestamp(input.getTimestamp())) {
            return;
        }
    } else {
        mTimestampNs = input.getTimestamp();
    }
    // Activate our surface
    glEnv.activateSurfaceWithId(mSurfaceId);
    // Process
    mProgram.process(input, mScreen);
    // Set timestamp from input
    glEnv.setSurfaceTimestamp(mTimestampNs);
    // And swap buffers
    glEnv.swapBuffers();
    mNumFramesEncoded++;
}
Also used : GLEnvironment(android.filterfw.core.GLEnvironment) Frame(android.filterfw.core.Frame) GLFrame(android.filterfw.core.GLFrame)

Example 8 with GLEnvironment

use of android.filterfw.core.GLEnvironment in project android_frameworks_base by ResurrectionRemix.

the class SurfaceRenderFilter method process.

@Override
public void process(FilterContext context) {
    // Make sure we are bound to a surface before rendering
    if (!mIsBound) {
        Log.w("SurfaceRenderFilter", this + ": Ignoring frame as there is no surface to render to!");
        return;
    }
    if (mLogVerbose)
        Log.v(TAG, "Starting frame processing");
    GLEnvironment glEnv = mSurfaceView.getGLEnv();
    if (glEnv != context.getGLEnvironment()) {
        throw new RuntimeException("Surface created under different GLEnvironment!");
    }
    // Get input frame
    Frame input = pullInput("frame");
    boolean createdFrame = false;
    float currentAspectRatio = (float) input.getFormat().getWidth() / input.getFormat().getHeight();
    if (currentAspectRatio != mAspectRatio) {
        if (mLogVerbose)
            Log.v(TAG, "New aspect ratio: " + currentAspectRatio + ", previously: " + mAspectRatio);
        mAspectRatio = currentAspectRatio;
        updateTargetRect();
    }
    // See if we need to copy to GPU
    Frame gpuFrame = null;
    if (mLogVerbose)
        Log.v("SurfaceRenderFilter", "Got input format: " + input.getFormat());
    int target = input.getFormat().getTarget();
    if (target != FrameFormat.TARGET_GPU) {
        gpuFrame = context.getFrameManager().duplicateFrameToTarget(input, FrameFormat.TARGET_GPU);
        createdFrame = true;
    } else {
        gpuFrame = input;
    }
    // Activate our surface
    glEnv.activateSurfaceWithId(mSurfaceView.getSurfaceId());
    // Process
    mProgram.process(gpuFrame, mScreen);
    // And swap buffers
    glEnv.swapBuffers();
    if (createdFrame) {
        gpuFrame.release();
    }
}
Also used : GLEnvironment(android.filterfw.core.GLEnvironment) Frame(android.filterfw.core.Frame) GLFrame(android.filterfw.core.GLFrame)

Example 9 with GLEnvironment

use of android.filterfw.core.GLEnvironment in project android_frameworks_base by DirtyUnicorns.

the class SurfaceTextureTarget method process.

@Override
public synchronized void process(FilterContext context) {
    // Surface is not registered. Nothing to render into.
    if (mSurfaceId <= 0) {
        return;
    }
    GLEnvironment glEnv = context.getGLEnvironment();
    // Get input frame
    Frame input = pullInput("frame");
    boolean createdFrame = false;
    float currentAspectRatio = (float) input.getFormat().getWidth() / input.getFormat().getHeight();
    if (currentAspectRatio != mAspectRatio) {
        if (mLogVerbose) {
            Log.v(TAG, "Process. New aspect ratio: " + currentAspectRatio + ", previously: " + mAspectRatio + ". Thread: " + Thread.currentThread());
        }
        mAspectRatio = currentAspectRatio;
        updateTargetRect();
    }
    // See if we need to copy to GPU
    Frame gpuFrame = null;
    int target = input.getFormat().getTarget();
    if (target != FrameFormat.TARGET_GPU) {
        gpuFrame = context.getFrameManager().duplicateFrameToTarget(input, FrameFormat.TARGET_GPU);
        createdFrame = true;
    } else {
        gpuFrame = input;
    }
    // Activate our surface
    glEnv.activateSurfaceWithId(mSurfaceId);
    // Process
    mProgram.process(gpuFrame, mScreen);
    glEnv.setSurfaceTimestamp(input.getTimestamp());
    // And swap buffers
    glEnv.swapBuffers();
    if (createdFrame) {
        gpuFrame.release();
    }
}
Also used : GLEnvironment(android.filterfw.core.GLEnvironment) Frame(android.filterfw.core.Frame) GLFrame(android.filterfw.core.GLFrame) Point(android.filterfw.geometry.Point)

Example 10 with GLEnvironment

use of android.filterfw.core.GLEnvironment in project android_frameworks_base by DirtyUnicorns.

the class MediaEncoderFilter method stopRecording.

private void stopRecording(FilterContext context) {
    if (mLogVerbose)
        Log.v(TAG, "Stopping recording");
    mRecordingActive = false;
    mNumFramesEncoded = 0;
    GLEnvironment glEnv = context.getGLEnvironment();
    // be called before calling Stop on the mediarecorder
    if (mLogVerbose)
        Log.v(TAG, String.format("Unregistering surface %d", mSurfaceId));
    glEnv.unregisterSurfaceId(mSurfaceId);
    try {
        mMediaRecorder.stop();
    } catch (RuntimeException e) {
        throw new MediaRecorderStopException("MediaRecorder.stop() failed!", e);
    }
    mMediaRecorder.release();
    mMediaRecorder = null;
    mScreen.release();
    mScreen = null;
    // to be done to finalize media.
    if (mRecordingDoneListener != null) {
        mRecordingDoneListener.onRecordingDone();
    }
}
Also used : GLEnvironment(android.filterfw.core.GLEnvironment)

Aggregations

GLEnvironment (android.filterfw.core.GLEnvironment)36 Frame (android.filterfw.core.Frame)18 GLFrame (android.filterfw.core.GLFrame)18 Point (android.filterfw.geometry.Point)6 NativeFrame (android.filterfw.core.NativeFrame)3