use of android.graphics.SurfaceTexture in project UltimateAndroid by cymcsg.
the class CameraPreviewInput method initWithGLContext.
@Override
protected void initWithGLContext() {
super.initWithGLContext();
int[] textures = new int[1];
GLES20.glGenTextures(1, textures, 0);
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textures[0]);
GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
GLES20.glTexParameterf(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
texture_in = textures[0];
camTex = new SurfaceTexture(texture_in);
camTex.setOnFrameAvailableListener(this);
boolean failed = true;
while (failed) {
try {
if (camera != null) {
camera.stopPreview();
camera.release();
camera = null;
}
camera = createCamera();
camera.setPreviewTexture(camTex);
camera.startPreview();
setRenderSizeToCameraSize();
failed = false;
} catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
Log.e("CameraInput", sw.toString());
if (camera != null) {
camera.release();
camera = null;
}
}
}
}
use of android.graphics.SurfaceTexture in project android_frameworks_base by ResurrectionRemix.
the class EGLImpl method eglCreateWindowSurface.
public EGLSurface eglCreateWindowSurface(EGLDisplay display, EGLConfig config, Object native_window, int[] attrib_list) {
Surface sur = null;
if (native_window instanceof SurfaceView) {
SurfaceView surfaceView = (SurfaceView) native_window;
sur = surfaceView.getHolder().getSurface();
} else if (native_window instanceof SurfaceHolder) {
SurfaceHolder holder = (SurfaceHolder) native_window;
sur = holder.getSurface();
} else if (native_window instanceof Surface) {
sur = (Surface) native_window;
}
long eglSurfaceId;
if (sur != null) {
eglSurfaceId = _eglCreateWindowSurface(display, config, sur, attrib_list);
} else if (native_window instanceof SurfaceTexture) {
eglSurfaceId = _eglCreateWindowSurfaceTexture(display, config, native_window, attrib_list);
} else {
throw new java.lang.UnsupportedOperationException("eglCreateWindowSurface() can only be called with an instance of " + "Surface, SurfaceView, SurfaceHolder or SurfaceTexture at the moment.");
}
if (eglSurfaceId == 0) {
return EGL10.EGL_NO_SURFACE;
}
return new EGLSurfaceImpl(eglSurfaceId);
}
use of android.graphics.SurfaceTexture in project android_frameworks_base by ResurrectionRemix.
the class CameraSource method open.
@Override
public void open(FilterContext context) {
if (mLogVerbose)
Log.v(TAG, "Opening");
// Open camera
mCamera = Camera.open(mCameraId);
// Set parameters
getCameraParameters();
mCamera.setParameters(mCameraParameters);
// Create frame formats
createFormats();
// Bind it to our camera frame
mCameraFrame = (GLFrame) context.getFrameManager().newBoundFrame(mOutputFormat, GLFrame.EXTERNAL_TEXTURE, 0);
mSurfaceTexture = new SurfaceTexture(mCameraFrame.getTextureId());
try {
mCamera.setPreviewTexture(mSurfaceTexture);
} catch (IOException e) {
throw new RuntimeException("Could not bind camera surface texture: " + e.getMessage() + "!");
}
// Connect SurfaceTexture to callback
mSurfaceTexture.setOnFrameAvailableListener(onCameraFrameAvailableListener);
// Start the preview
mNewFrameAvailable = false;
mCamera.startPreview();
}
use of android.graphics.SurfaceTexture in project android_frameworks_base by ResurrectionRemix.
the class MediaSource method open.
@Override
public void open(FilterContext context) {
if (mLogVerbose) {
Log.v(TAG, "Opening MediaSource");
if (mSelectedIsUrl) {
Log.v(TAG, "Current URL is " + mSourceUrl);
} else {
Log.v(TAG, "Current source is Asset!");
}
}
mMediaFrame = (GLFrame) context.getFrameManager().newBoundFrame(mOutputFormat, GLFrame.EXTERNAL_TEXTURE, 0);
mSurfaceTexture = new SurfaceTexture(mMediaFrame.getTextureId());
if (!setupMediaPlayer(mSelectedIsUrl)) {
throw new RuntimeException("Error setting up MediaPlayer!");
}
}
use of android.graphics.SurfaceTexture in project android_frameworks_base by ResurrectionRemix.
the class SurfaceTextureSource method open.
@Override
public void open(FilterContext context) {
if (mLogVerbose)
Log.v(TAG, "Opening SurfaceTextureSource");
// Create SurfaceTexture anew each time - it can use substantial memory.
mSurfaceTexture = new SurfaceTexture(mMediaFrame.getTextureId());
// Connect SurfaceTexture to callback
mSurfaceTexture.setOnFrameAvailableListener(onFrameAvailableListener);
// Connect SurfaceTexture to source
mSourceListener.onSurfaceTextureSourceReady(mSurfaceTexture);
mFirstFrame = true;
}
Aggregations