Java Code Examples for android.graphics.SurfaceTexture#OnFrameAvailableListener

The following examples show how to use android.graphics.SurfaceTexture#OnFrameAvailableListener . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RongRTCSurfaceTextureHelper.java    From sealrtc-android with MIT License 6 votes vote down vote up
@TargetApi(21)
private static void setOnFrameAvailableListener(
        SurfaceTexture surfaceTexture,
        SurfaceTexture.OnFrameAvailableListener listener,
        Handler handler) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        surfaceTexture.setOnFrameAvailableListener(listener, handler);
    } else {
        // The documentation states that the listener will be called on an arbitrary thread, but
        // in
        // pratice, it is always the thread on which the SurfaceTexture was constructed. There
        // are
        // assertions in place in case this ever changes. For API >= 21, we use the new API to
        // explicitly specify the handler.
        surfaceTexture.setOnFrameAvailableListener(listener);
    }
}
 
Example 2
Source File: SurfaceTextureHelper.java    From webrtc_android with MIT License 5 votes vote down vote up
@TargetApi(21)
private static void setOnFrameAvailableListener(SurfaceTexture surfaceTexture,
    SurfaceTexture.OnFrameAvailableListener listener, Handler handler) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    surfaceTexture.setOnFrameAvailableListener(listener, handler);
  } else {
    // The documentation states that the listener will be called on an arbitrary thread, but in
    // pratice, it is always the thread on which the SurfaceTexture was constructed. There are
    // assertions in place in case this ever changes. For API >= 21, we use the new API to
    // explicitly specify the handler.
    surfaceTexture.setOnFrameAvailableListener(listener);
  }
}
 
Example 3
Source File: OutputSurface.java    From SimpleVideoEdit with Apache License 2.0 5 votes vote down vote up
/**
 * Creates instances of TextureRender and SurfaceTexture, and a Surface associated
 * with the SurfaceTexture.
 */
private void setup(SurfaceTexture.OnFrameAvailableListener listener) {
    mTextureRender = new FrameBufferObjectRenderer(mFilter);
    mTextureRender.surfaceCreated();

    // Even if we don't access the SurfaceTexture after the constructor returns, we
    // still need to keep a reference to it.  The Surface doesn't retain a reference
    // at the Java level, so if we don't either then the object can get GCed, which
    // causes the native finalizer to run.
    if (VERBOSE) Log.d(TAG, "textureID=" + mTextureRender.getTextureId());
    mSurfaceTexture = new SurfaceTexture(mTextureRender.getTextureId());

    // This doesn't work if OutputSurface is created on the thread that CTS started for
    // these test cases.
    //
    // The CTS-created thread has a Looper, and the SurfaceTexture constructor will
    // create a Handler that uses it.  The "frame available" message is delivered
    // there, but since we're not a Looper-based thread we'll never see it.  For
    // this to do anything useful, OutputSurface must be created on a thread without
    // a Looper, so that SurfaceTexture uses the main application Looper instead.
    //
    // Java language note: passing "this" out of a constructor is generally unwise,
    // but we should be able to get away with it here.
    mSurfaceTexture.setOnFrameAvailableListener(listener);

    mSurface = new Surface(mSurfaceTexture);
    checkEglError("setup");
}
 
Example 4
Source File: FuSurfaceTextureHelper.java    From FuAgoraDemoDroid with MIT License 5 votes vote down vote up
@TargetApi(21)
private static void setOnFrameAvailableListener(SurfaceTexture surfaceTexture, SurfaceTexture.OnFrameAvailableListener listener, Handler handler) {
    if (Build.VERSION.SDK_INT >= 21) {
        surfaceTexture.setOnFrameAvailableListener(listener, handler);
    } else {
        surfaceTexture.setOnFrameAvailableListener(listener);
    }
}
 
Example 5
Source File: GlSurfaceTexture.java    From GPUVideo-android with MIT License 4 votes vote down vote up
public void setOnFrameAvailableListener(final SurfaceTexture.OnFrameAvailableListener l) {
    onFrameAvailableListener = l;
}
 
Example 6
Source File: GlSurfaceTexture.java    From Mp4Composer-android with MIT License 4 votes vote down vote up
public void setOnFrameAvailableListener(final SurfaceTexture.OnFrameAvailableListener l) {
    onFrameAvailableListener = l;
}
 
Example 7
Source File: OutputSurface.java    From SimpleVideoEdit with Apache License 2.0 4 votes vote down vote up
public OutputSurface(final SurfaceTexture.OnFrameAvailableListener listener) {
    setup(listener);
}
 
Example 8
Source File: GlSurfaceTexture.java    From CameraRecorder-android with MIT License 4 votes vote down vote up
public void setOnFrameAvailableListener(final SurfaceTexture.OnFrameAvailableListener l) {
    onFrameAvailableListener = l;
}
 
Example 9
Source File: ExternalSurfaceTexture.java    From Spectaculum with Apache License 2.0 4 votes vote down vote up
public void setOnFrameAvailableListener(SurfaceTexture.OnFrameAvailableListener l) {
    mOnFrameAvailableListener = l;
}