Java Code Examples for android.opengl.EGLExt#eglPresentationTimeANDROID()

The following examples show how to use android.opengl.EGLExt#eglPresentationTimeANDROID() . 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: EglBase14Impl.java    From webrtc_android with MIT License 5 votes vote down vote up
@Override
public void swapBuffers(long timeStampNs) {
  checkIsNotReleased();
  if (eglSurface == EGL14.EGL_NO_SURFACE) {
    throw new RuntimeException("No EGLSurface - can't swap buffers");
  }
  synchronized (EglBase.lock) {
    // See
    // https://android.googlesource.com/platform/frameworks/native/+/tools_r22.2/opengl/specs/EGL_ANDROID_presentation_time.txt
    EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, timeStampNs);
    EGL14.eglSwapBuffers(eglDisplay, eglSurface);
  }
}
 
Example 2
Source File: EglCore.java    From RtmpPublisher with Apache License 2.0 4 votes vote down vote up
/**
 * Sends the presentation time stamp to EGL.  Time is expressed in nanoseconds.
 */
public void setPresentationTime(EGLSurface eglSurface, long nsecs) {
    EGLExt.eglPresentationTimeANDROID(mEGLDisplay, eglSurface, nsecs);
}
 
Example 3
Source File: InputSurface.java    From SimpleVideoEditor with Apache License 2.0 4 votes vote down vote up
/**
 * Sends the presentation time stamp to EGL.  Time is expressed in nanoseconds.
 */
public void setPresentationTime(long nsecs) {
    EGLExt.eglPresentationTimeANDROID(mEGLDisplay, mEGLSurface, nsecs);
}
 
Example 4
Source File: InputSurface.java    From VideoCompressor with Apache License 2.0 4 votes vote down vote up
public void setPresentationTime(long nsecs) {
    EGLExt.eglPresentationTimeANDROID(mEGLDisplay, mEGLSurface, nsecs);
}
 
Example 5
Source File: EGLBase14.java    From libcommon with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public void setPresentationTime(final long presentationTimeNs) {
	EGLExt.eglPresentationTimeANDROID(mEglBase.mEglDisplay,	// API>=18
		mEglSurface, presentationTimeNs);
}
 
Example 6
Source File: EglCore.java    From pause-resume-video-recording with Apache License 2.0 4 votes vote down vote up
/**
 * Sends the presentation time stamp to EGL.  Time is expressed in nanoseconds.
 */
public void setPresentationTime(EGLSurface eglSurface, long nsecs) {
    EGLExt.eglPresentationTimeANDROID(mEGLDisplay, eglSurface, nsecs);
}
 
Example 7
Source File: GLSurfaceView2.java    From java6-android-glframework with Mozilla Public License 2.0 4 votes vote down vote up
public void setPresentationTime(long timestamp)
{
   EGLExt.eglPresentationTimeANDROID(eglHelper.mEglDisplay, eglHelper.mEglSurface, timestamp);
}
 
Example 8
Source File: EglCore.java    From TikTok with Apache License 2.0 4 votes vote down vote up
/**
 * Sends the presentation time stamp to EGL.  Time is expressed in nanoseconds.
 */
public void setPresentationTime(EGLSurface eglSurface, long nsecs) {
    EGLExt.eglPresentationTimeANDROID(mEGLDisplay, eglSurface, nsecs);
}
 
Example 9
Source File: SurfaceManager.java    From rtmp-rtsp-stream-client-java with Apache License 2.0 4 votes vote down vote up
/**
 * Sends the presentation time stamp to EGL.  Time is expressed in nanoseconds.
 */
public void setPresentationTime(long nsecs) {
  EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, nsecs);
  GlUtil.checkEglError("eglPresentationTimeANDROID");
}
 
Example 10
Source File: EglHelper.java    From AAVT with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public void setPresentationTime(EGLSurface surface, long time){
    EGLExt.eglPresentationTimeANDROID(mEGLDisplay,surface,time);
}
 
Example 11
Source File: InputSurface.java    From talk-android with MIT License 4 votes vote down vote up
public void setPresentationTime(long nsecs) {
    EGLExt.eglPresentationTimeANDROID(mEGLDisplay, mEGLSurface, nsecs);
}
 
Example 12
Source File: SurfaceManager.java    From spydroid-ipcamera with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Sends the presentation time stamp to EGL.  Time is expressed in nanoseconds.
 */
public void setPresentationTime(long nsecs) {
	EGLExt.eglPresentationTimeANDROID(mEGLDisplay, mEGLSurface, nsecs);
	checkEglError("eglPresentationTimeANDROID");
}
 
Example 13
Source File: EncodeAndMuxTest.java    From AndroidPlayground with MIT License 4 votes vote down vote up
/**
 * Sends the presentation time stamp to EGL.  Time is expressed in nanoseconds.
 */
public void setPresentationTime(long nsecs) {
    EGLExt.eglPresentationTimeANDROID(mEGLDisplay, mEGLSurface, nsecs);
    checkEglError("eglPresentationTimeANDROID");
}
 
Example 14
Source File: InstantCameraView.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private void handleVideoFrameAvailable(long timestampNanos, Integer cameraId) {
    try {
        drainEncoder(false);
    } catch (Exception e) {
        FileLog.e(e);
    }
    long dt, alphaDt;
    if (!lastCameraId.equals(cameraId)) {
        lastTimestamp = -1;
        lastCameraId = cameraId;
    }
    if (lastTimestamp == -1) {
        lastTimestamp = timestampNanos;
        if (currentTimestamp != 0) {
            dt = (System.currentTimeMillis() - lastCommitedFrameTime) * 1000000;
            alphaDt = 0;
        } else {
            alphaDt = dt = 0;
        }
    } else {
        alphaDt = dt = (timestampNanos - lastTimestamp);
        lastTimestamp = timestampNanos;
    }
    lastCommitedFrameTime = System.currentTimeMillis();
    if (!skippedFirst) {
        skippedTime += dt;
        if (skippedTime < 200000000) {
            return;
        }
        skippedFirst = true;
    }
    currentTimestamp += dt;
    if (videoFirst == -1) {
        videoFirst = timestampNanos / 1000;
        if (BuildVars.LOGS_ENABLED) {
            FileLog.d("first video frame was at " + videoFirst);
        }
    }
    videoLast = timestampNanos;

    GLES20.glUseProgram(drawProgram);
    GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT, false, 12, vertexBuffer);
    GLES20.glEnableVertexAttribArray(positionHandle);
    GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
    GLES20.glEnableVertexAttribArray(textureHandle);
    GLES20.glUniform1f(scaleXHandle, scaleX);
    GLES20.glUniform1f(scaleYHandle, scaleY);
    GLES20.glUniformMatrix4fv(vertexMatrixHandle, 1, false, mMVPMatrix, 0);

    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    if (oldCameraTexture[0] != 0) {
        if (!blendEnabled) {
            GLES20.glEnable(GLES20.GL_BLEND);
            blendEnabled = true;
        }
        GLES20.glUniformMatrix4fv(textureMatrixHandle, 1, false, moldSTMatrix, 0);
        GLES20.glUniform1f(alphaHandle, 1.0f);
        GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, oldCameraTexture[0]);
        GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
    }
    GLES20.glUniformMatrix4fv(textureMatrixHandle, 1, false, mSTMatrix, 0);
    GLES20.glUniform1f(alphaHandle, cameraTextureAlpha);
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, cameraTexture[0]);
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);

    GLES20.glDisableVertexAttribArray(positionHandle);
    GLES20.glDisableVertexAttribArray(textureHandle);
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0);
    GLES20.glUseProgram(0);

    EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, currentTimestamp);
    EGL14.eglSwapBuffers(eglDisplay, eglSurface);

    if (oldCameraTexture[0] != 0 && cameraTextureAlpha < 1.0f) {
        cameraTextureAlpha += alphaDt / 200000000.0f;
        if (cameraTextureAlpha > 1) {
            GLES20.glDisable(GLES20.GL_BLEND);
            blendEnabled = false;
            cameraTextureAlpha = 1;
            GLES20.glDeleteTextures(1, oldCameraTexture, 0);
            oldCameraTexture[0] = 0;
            if (!cameraReady) {
                cameraReady = true;
            }
        }
    } else if (!cameraReady) {
        cameraReady = true;
    }
}
 
Example 15
Source File: InputSurface.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public void setPresentationTime(long nsecs) {
    EGLExt.eglPresentationTimeANDROID(mEGLDisplay, mEGLSurface, nsecs);
}
 
Example 16
Source File: InputSurface.java    From deltachat-android with GNU General Public License v3.0 4 votes vote down vote up
public void setPresentationTime(long nsecs) {
    EGLExt.eglPresentationTimeANDROID(mEGLDisplay, mEGLSurface, nsecs);
}
 
Example 17
Source File: VideoRenderOutputSurface.java    From LiTr with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Sends the presentation time stamp to EGL.  Time is expressed in nanoseconds.
 */
void setPresentationTime(long nanoseconds) {
    EGLExt.eglPresentationTimeANDROID(eglDisplay, eglSurface, nanoseconds);
}
 
Example 18
Source File: EglCore.java    From cineio-broadcast-android with MIT License 4 votes vote down vote up
/**
 * Sends the presentation time stamp to EGL.  Time is expressed in nanoseconds.
 */
public void setPresentationTime(EGLSurface eglSurface, long nsecs) {
    EGLExt.eglPresentationTimeANDROID(mEGLDisplay, eglSurface, nsecs);
}
 
Example 19
Source File: EglCore.java    From grafika with Apache License 2.0 4 votes vote down vote up
/**
 * Sends the presentation time stamp to EGL.  Time is expressed in nanoseconds.
 */
public void setPresentationTime(EGLSurface eglSurface, long nsecs) {
    EGLExt.eglPresentationTimeANDROID(mEGLDisplay, eglSurface, nsecs);
}
 
Example 20
Source File: InputSurface.java    From phoenix with Apache License 2.0 4 votes vote down vote up
/**
 * Sends the presentation time stamp to EGL.  Time is expressed in nanoseconds.
 */
public void setPresentationTime(long nsecs) {
    EGLExt.eglPresentationTimeANDROID(mEGLDisplay, mEGLSurface, nsecs);
}