use of android.filterfw.core.MutableFrameFormat in project android_frameworks_base by AOSPA.
the class MediaEncoderFilter method startRecording.
private void startRecording(FilterContext context) {
if (mLogVerbose)
Log.v(TAG, "Starting recording");
// Create a frame representing the screen
MutableFrameFormat screenFormat = new MutableFrameFormat(FrameFormat.TYPE_BYTE, FrameFormat.TARGET_GPU);
screenFormat.setBytesPerSample(4);
int width, height;
boolean widthHeightSpecified = mWidth > 0 && mHeight > 0;
// of that in the profile.
if (mProfile != null && !widthHeightSpecified) {
width = mProfile.videoFrameWidth;
height = mProfile.videoFrameHeight;
} else {
width = mWidth;
height = mHeight;
}
screenFormat.setDimensions(width, height);
mScreen = (GLFrame) context.getFrameManager().newBoundFrame(screenFormat, GLFrame.EXISTING_FBO_BINDING, 0);
// Initialize the media recorder
mMediaRecorder = new MediaRecorder();
updateMediaRecorderParams();
try {
mMediaRecorder.prepare();
} catch (IllegalStateException e) {
throw e;
} catch (IOException e) {
throw new RuntimeException("IOException in" + "MediaRecorder.prepare()!", e);
} catch (Exception e) {
throw new RuntimeException("Unknown Exception in" + "MediaRecorder.prepare()!", e);
}
// Make sure start() is called before trying to
// register the surface. The native window handle needed to create
// the surface is initiated in start()
mMediaRecorder.start();
if (mLogVerbose)
Log.v(TAG, "Open: registering surface from Mediarecorder");
mSurfaceId = context.getGLEnvironment().registerSurfaceFromMediaRecorder(mMediaRecorder);
mNumFramesEncoded = 0;
mRecordingActive = true;
}
use of android.filterfw.core.MutableFrameFormat in project android_frameworks_base by AOSPA.
the class SurfaceTargetFilter method prepare.
@Override
public void prepare(FilterContext context) {
mGlEnv = context.getGLEnvironment();
// Create identity shader to render, and make sure to render upside-down, as textures
// are stored internally bottom-to-top.
mProgram = ShaderProgram.createIdentity(context);
mProgram.setSourceRect(0, 1, 1, -1);
mProgram.setClearsOutput(true);
mProgram.setClearColor(0.0f, 0.0f, 0.0f);
MutableFrameFormat screenFormat = ImageFormat.create(mScreenWidth, mScreenHeight, ImageFormat.COLORSPACE_RGBA, FrameFormat.TARGET_GPU);
mScreen = (GLFrame) context.getFrameManager().newBoundFrame(screenFormat, GLFrame.EXISTING_FBO_BINDING, 0);
// Set up cropping
updateRenderMode();
}
use of android.filterfw.core.MutableFrameFormat in project android_frameworks_base by AOSPA.
the class FixedRotationFilter method process.
@Override
public void process(FilterContext context) {
Frame input = pullInput("image");
if (mRotation == 0) {
pushOutput("image", input);
return;
}
FrameFormat inputFormat = input.getFormat();
// Create program if not created already
if (mProgram == null) {
mProgram = ShaderProgram.createIdentity(context);
}
MutableFrameFormat outputFormat = inputFormat.mutableCopy();
int width = inputFormat.getWidth();
int height = inputFormat.getHeight();
Point p1 = new Point(0.0f, 0.0f);
Point p2 = new Point(1.0f, 0.0f);
Point p3 = new Point(0.0f, 1.0f);
Point p4 = new Point(1.0f, 1.0f);
Quad sourceRegion;
switch(((int) Math.round(mRotation / 90f)) % 4) {
case 1:
sourceRegion = new Quad(p3, p1, p4, p2);
outputFormat.setDimensions(height, width);
break;
case 2:
sourceRegion = new Quad(p4, p3, p2, p1);
break;
case 3:
sourceRegion = new Quad(p2, p4, p1, p3);
outputFormat.setDimensions(height, width);
break;
case 0:
default:
sourceRegion = new Quad(p1, p2, p3, p4);
break;
}
// Create output frame
Frame output = context.getFrameManager().newFrame(outputFormat);
// Set the source region
mProgram.setSourceRegion(sourceRegion);
// Process
mProgram.process(input, output);
// Push output
pushOutput("image", output);
// Release pushed frame
output.release();
}
use of android.filterfw.core.MutableFrameFormat in project android_frameworks_base by ResurrectionRemix.
the class SurfaceTargetFilter method prepare.
@Override
public void prepare(FilterContext context) {
mGlEnv = context.getGLEnvironment();
// Create identity shader to render, and make sure to render upside-down, as textures
// are stored internally bottom-to-top.
mProgram = ShaderProgram.createIdentity(context);
mProgram.setSourceRect(0, 1, 1, -1);
mProgram.setClearsOutput(true);
mProgram.setClearColor(0.0f, 0.0f, 0.0f);
MutableFrameFormat screenFormat = ImageFormat.create(mScreenWidth, mScreenHeight, ImageFormat.COLORSPACE_RGBA, FrameFormat.TARGET_GPU);
mScreen = (GLFrame) context.getFrameManager().newBoundFrame(screenFormat, GLFrame.EXISTING_FBO_BINDING, 0);
// Set up cropping
updateRenderMode();
}
use of android.filterfw.core.MutableFrameFormat in project android_frameworks_base by ResurrectionRemix.
the class SurfaceTextureTarget method prepare.
@Override
public void prepare(FilterContext context) {
if (mLogVerbose)
Log.v(TAG, "Prepare. Thread: " + Thread.currentThread());
// Create identity shader to render, and make sure to render upside-down, as textures
// are stored internally bottom-to-top.
mProgram = ShaderProgram.createIdentity(context);
mProgram.setSourceRect(0, 1, 1, -1);
mProgram.setClearColor(0.0f, 0.0f, 0.0f);
updateRenderMode();
// Create a frame representing the screen
MutableFrameFormat screenFormat = new MutableFrameFormat(FrameFormat.TYPE_BYTE, FrameFormat.TARGET_GPU);
screenFormat.setBytesPerSample(4);
screenFormat.setDimensions(mScreenWidth, mScreenHeight);
mScreen = (GLFrame) context.getFrameManager().newBoundFrame(screenFormat, GLFrame.EXISTING_FBO_BINDING, 0);
}
Aggregations