当前位置: 首页>>代码示例>>Java>>正文


Java SurfaceTexture.updateTexImage方法代码示例

本文整理汇总了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);
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:17,代码来源:MovieTranscoder.java

示例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");
    }
}
 
开发者ID:aiyaapp,项目名称:AAVT,代码行数:73,代码来源:VideoSurfaceProcessor.java


注:本文中的android.graphics.SurfaceTexture.updateTexImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。