本文整理匯總了Java中android.graphics.SurfaceTexture.updateTexImage方法的典型用法代碼示例。如果您正苦於以下問題:Java SurfaceTexture.updateTexImage方法的具體用法?Java SurfaceTexture.updateTexImage怎麽用?Java SurfaceTexture.updateTexImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.SurfaceTexture
的用法示例。
在下文中一共展示了SurfaceTexture.updateTexImage方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onFrameAvailable
import android.graphics.SurfaceTexture; //導入方法依賴的package包/類
@Override
public void onFrameAvailable(SurfaceTexture surfaceTexture) {
surfaceTexture.updateTexImage();
float[] transform = new float[16]; // TODO - avoid alloc every frame
surfaceTexture.getTransformMatrix(transform);
long timestamp = mIncomingFramePts;// surfaceTexture.getTimestamp();
if (timestamp == 0) {
// Seeing this after device is toggled off/on with power button. The
// first frame back has a zero timestamp.
//
// MPEG4Writer thinks this is cause to abort() in native code, so it's very
// important that we just ignore the frame.
return;
}
handleFrameAvailable(transform, timestamp * 1000);
}
示例2: glRun
import android.graphics.SurfaceTexture; //導入方法依賴的package包/類
private void glRun(){
EglHelper egl=new EglHelper();
boolean ret=egl.createGLESWithSurface(new EGLConfigAttrs(),new EGLContextAttrs(),new SurfaceTexture(1));
if(!ret){
//todo 錯誤處理
return;
}
int mInputSurfaceTextureId = GpuUtils.createTextureID(true);
SurfaceTexture mInputSurfaceTexture = new SurfaceTexture(mInputSurfaceTextureId);
Point size=mProvider.open(mInputSurfaceTexture);
AvLog.d(TAG,"Provider Opened . data size (x,y)="+size.x+"/"+size.y);
if(size.x<=0||size.y<=0){
//todo 錯誤處理
destroyGL(egl);
synchronized (LOCK){
LOCK.notifyAll();
}
return;
}
int mSourceWidth = size.x;
int mSourceHeight = size.y;
synchronized (LOCK){
LOCK.notifyAll();
}
//要求數據源提供者必須同步返回數據大小
if(mSourceWidth <=0|| mSourceHeight <=0){
error(1,"video source return inaccurate size to SurfaceTextureActuator");
return;
}
if(mRenderer==null){
mRenderer=new WrapRenderer(null);
}
FrameBuffer sourceFrame=new FrameBuffer();
mRenderer.create();
mRenderer.sizeChanged(mSourceWidth, mSourceHeight);
mRenderer.setFlag(mProvider.isLandscape()?WrapRenderer.TYPE_CAMERA:WrapRenderer.TYPE_MOVE);
//用於其他的回調
RenderBean rb=new RenderBean();
rb.egl=egl;
rb.sourceWidth= mSourceWidth;
rb.sourceHeight= mSourceHeight;
rb.endFlag=false;
rb.threadId=Thread.currentThread().getId();
AvLog.d(TAG,"Processor While Loop Entry");
//要求數據源必須同步填充SurfaceTexture,填充完成前等待
while (!mProvider.frame()&&mGLThreadFlag){
mInputSurfaceTexture.updateTexImage();
mInputSurfaceTexture.getTransformMatrix(mRenderer.getTextureMatrix());
AvLog.d(TAG,"timestamp:"+ mInputSurfaceTexture.getTimestamp());
sourceFrame.bindFrameBuffer(mSourceWidth, mSourceHeight);
GLES20.glViewport(0,0, mSourceWidth, mSourceHeight);
mRenderer.draw(mInputSurfaceTextureId);
sourceFrame.unBindFrameBuffer();
rb.textureId=sourceFrame.getCacheTextureId();
//接收數據源傳入的時間戳
rb.timeStamp=mProvider.getTimeStamp();
rb.textureTime= mInputSurfaceTexture.getTimestamp();
observable.notify(rb);
}
AvLog.d(TAG,"out of gl thread loop");
synchronized (LOCK){
rb.endFlag=true;
observable.notify(rb);
mRenderer.destroy();
destroyGL(egl);
LOCK.notifyAll();
AvLog.d(TAG,"gl thread exit");
}
}