Java Code Examples for android.opengl.EGL14#eglGetCurrentContext()

The following examples show how to use android.opengl.EGL14#eglGetCurrentContext() . 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: RenderHandler.java    From EZFilter with MIT License 6 votes vote down vote up
/**
 * 设置输入纹理
 * <p>
 * 必须在GL线程调用
 *
 * @param surface
 * @param texId
 */
public final void setInputTextureId(final Object surface, final int texId) {
    if (!(surface instanceof Surface)
            && !(surface instanceof SurfaceTexture)
            && !(surface instanceof SurfaceHolder)) {
        throw new RuntimeException("unsupported window type:" + surface);
    }
    synchronized (mSync) {
        if (mRequestRelease) return;
        mSharedContext = EGL14.eglGetCurrentContext();
        mTextureId = texId;
        mSurface = surface;
        mRequestSetEglContext = true;
        mSync.notifyAll();
        try {
            mSync.wait();
        } catch (final InterruptedException e) {
        }
    }
}
 
Example 2
Source File: EglCore.java    From sealrtc-android with MIT License 6 votes vote down vote up
/** Writes the current display, context, and surface to the log. */
public static void logCurrent(String msg) {
    EGLDisplay display;
    EGLContext context;
    EGLSurface surface;

    display = EGL14.eglGetCurrentDisplay();
    context = EGL14.eglGetCurrentContext();
    surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    Log.i(
            TAG,
            "Current EGL ("
                    + msg
                    + "): display="
                    + display
                    + ", context="
                    + context
                    + ", surface="
                    + surface);
}
 
Example 3
Source File: EglCore.java    From pause-resume-video-recording with Apache License 2.0 5 votes vote down vote up
/**
 * Writes the current display, context, and surface to the log.
 */
public static void logCurrent(String msg) {
    EGLDisplay display;
    EGLContext context;
    EGLSurface surface;

    display = EGL14.eglGetCurrentDisplay();
    context = EGL14.eglGetCurrentContext();
    surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context +
            ", surface=" + surface);
}
 
Example 4
Source File: EglCore.java    From IjkVRPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * Writes the current display, context, and surface to the log.
 */
public static void logCurrent(String msg) {
    EGLDisplay display;
    EGLContext context;
    EGLSurface surface;

    display = EGL14.eglGetCurrentDisplay();
    context = EGL14.eglGetCurrentContext();
    surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context +
            ", surface=" + surface);
}
 
Example 5
Source File: EglCore.java    From LiveVideoBroadcaster with Apache License 2.0 5 votes vote down vote up
/**
 * Writes the current display, activity, and surface to the log.
 */
public static void logCurrent(String msg) {
    EGLDisplay display;
    EGLContext context;
    EGLSurface surface;

    display = EGL14.eglGetCurrentDisplay();
    context = EGL14.eglGetCurrentContext();
    surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", activity=" + context +
            ", surface=" + surface);
}
 
Example 6
Source File: OffscreenImage.java    From EZFilter with MIT License 5 votes vote down vote up
private void initRenderSize() {
    // 初始化EGL环境
    mEgl = new EGLEnvironment(EGL14.eglGetCurrentContext(), false);
    // 创建离屏缓冲
    mInputSurface = mEgl.createOffscreen(mWidth, mHeight);
    // 设置渲染环境可用
    mInputSurface.makeCurrent();

    mWidth = mBitmap.getWidth();
    mHeight = mBitmap.getHeight();
}
 
Example 7
Source File: InputSurface.java    From EZFilter with MIT License 5 votes vote down vote up
/**
 * @param surface 来自MediaCodec.createInputSurface()
 */
public InputSurface(Surface surface) {
    if (surface == null) {
        throw new NullPointerException();
    }
    mSurface = surface;

    // 初始化EGL环境
    mEgl = new EGLEnvironment(EGL14.eglGetCurrentContext(), false);
    // 创建离屏缓冲
    mInputSurface = mEgl.createFromSurface(surface);
    // 设置渲染环境可用
    mInputSurface.makeCurrent();
}
 
Example 8
Source File: EglCore.java    From Fatigue-Detection with MIT License 5 votes vote down vote up
/**
 * Writes the current display, context, and surface to the log.
 */
public static void logCurrent(String msg) {
    EGLDisplay display;
    EGLContext context;
    EGLSurface surface;

    display = EGL14.eglGetCurrentDisplay();
    context = EGL14.eglGetCurrentContext();
    surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context +
            ", surface=" + surface);
}
 
Example 9
Source File: EglStateSaver.java    From kickflip-android-sdk with Apache License 2.0 5 votes vote down vote up
public void saveEGLState(){
    mSavedContext = EGL14.eglGetCurrentContext();
    if(DEBUG && mSavedContext.equals(EGL14.EGL_NO_CONTEXT)) Log.e(TAG, "Saved EGL_NO_CONTEXT");
    mSavedReadSurface = EGL14.eglGetCurrentSurface(EGL14.EGL_READ);
    if(DEBUG && mSavedReadSurface.equals(EGL14.EGL_NO_CONTEXT)) Log.e(TAG, "Saved EGL_NO_SURFACE");
    mSavedDrawSurface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    if(DEBUG && mSavedDrawSurface.equals(EGL14.EGL_NO_CONTEXT)) Log.e(TAG, "Saved EGL_NO_SURFACE");
    mSavedDisplay = EGL14.eglGetCurrentDisplay();
    if(DEBUG && mSavedDisplay.equals(EGL14.EGL_NO_DISPLAY)) Log.e(TAG, "Saved EGL_NO_DISPLAY");

}
 
Example 10
Source File: EglCore.java    From AndroidPlayground with MIT License 5 votes vote down vote up
/**
 * Writes the current display, context, and surface to the log.
 */
public static void logCurrent(String msg) {
    EGLDisplay display;
    EGLContext context;
    EGLSurface surface;

    display = EGL14.eglGetCurrentDisplay();
    context = EGL14.eglGetCurrentContext();
    surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context +
            ", surface=" + surface);
}
 
Example 11
Source File: EglCore.java    From kickflip-android-sdk with Apache License 2.0 5 votes vote down vote up
/**
 * Writes the current display, context, and surface to the log.
 */
public static void logCurrent(String msg) {
    EGLDisplay display;
    EGLContext context;
    EGLSurface surface;

    display = EGL14.eglGetCurrentDisplay();
    context = EGL14.eglGetCurrentContext();
    surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context +
            ", surface=" + surface);
}
 
Example 12
Source File: EglCore.java    From TikTok with Apache License 2.0 5 votes vote down vote up
/**
 * Writes the current display, context, and surface to the log.
 */
public static void logCurrent(String msg) {
    EGLDisplay display;
    EGLContext context;
    EGLSurface surface;

    display = EGL14.eglGetCurrentDisplay();
    context = EGL14.eglGetCurrentContext();
    surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context +
            ", surface=" + surface);
}
 
Example 13
Source File: EglCore.java    From PhotoMovie with Apache License 2.0 5 votes vote down vote up
/**
 * Writes the current display, context, and surface to the log.
 */
public static void logCurrent(String msg) {
    EGLDisplay display;
    EGLContext context;
    EGLSurface surface;

    display = EGL14.eglGetCurrentDisplay();
    context = EGL14.eglGetCurrentContext();
    surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context +
            ", surface=" + surface);
}
 
Example 14
Source File: EglCore.java    From RtmpPublisher with Apache License 2.0 5 votes vote down vote up
/**
 * Writes the current display, context, and surface to the log.
 */
public static void logCurrent(String msg) {
    EGLDisplay display;
    EGLContext context;
    EGLSurface surface;

    display = EGL14.eglGetCurrentDisplay();
    context = EGL14.eglGetCurrentContext();
    surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context +
            ", surface=" + surface);
}
 
Example 15
Source File: EglCore.java    From mobile-ar-sensor-logger with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Writes the current display, context, and surface to the log.
 */
public static void logCurrent(String msg) {
    EGLDisplay display;
    EGLContext context;
    EGLSurface surface;

    display = EGL14.eglGetCurrentDisplay();
    context = EGL14.eglGetCurrentContext();
    surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context +
            ", surface=" + surface);
}
 
Example 16
Source File: EglCore.java    From MockCamera with Apache License 2.0 5 votes vote down vote up
/**
 * Writes the current display, context, and surface to the log.
 */
public static void logCurrent(String msg) {
    EGLDisplay display;
    EGLContext context;
    EGLSurface surface;

    display = EGL14.eglGetCurrentDisplay();
    context = EGL14.eglGetCurrentContext();
    surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
    Log.d(TAG,"Current EGL (" + msg + "): display=" + display + ", context=" + context +
            ", surface=" + surface);
}
 
Example 17
Source File: GLRender.java    From Fatigue-Detection with MIT License 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private EGLContext getSharedContext() {
    return EGL14.eglGetCurrentContext();
}
 
Example 18
Source File: AndroidMediaObjectFactory.java    From media-for-mobile with Apache License 2.0 4 votes vote down vote up
@Override
public IEglContext getCurrentEglContext() {
    return new EGLContextWrapper(EGL14.eglGetCurrentContext());
}
 
Example 19
Source File: EGLContextWrapper.java    From media-for-mobile with Apache License 2.0 4 votes vote down vote up
@Override
public IEglContext getCurrentContext() {
    return new EGLContextWrapper(EGL14.eglGetCurrentContext());
}
 
Example 20
Source File: SnapshotVideoRecorder.java    From Lassi-Android with MIT License 4 votes vote down vote up
@RendererThread
@Override
public void onRendererFrame(@NonNull SurfaceTexture surfaceTexture, float scaleX, float scaleY) {
    if (mCurrentState == STATE_NOT_RECORDING && mDesiredState == STATE_RECORDING) {
        // Set default options
        if (mResult.videoBitRate <= 0) mResult.videoBitRate = DEFAULT_VIDEO_BITRATE;
        if (mResult.videoFrameRate <= 0) mResult.videoFrameRate = DEFAULT_VIDEO_FRAMERATE;
        if (mResult.audioBitRate <= 0) mResult.audioBitRate = DEFAULT_AUDIO_BITRATE;

        // Video. Ensure width and height are divisible by 2, as I have read somewhere.
        Size size = mResult.getSize();
        int width = size.getWidth();
        int height = size.getHeight();
        width = width % 2 == 0 ? width : width + 1;
        height = height % 2 == 0 ? height : height + 1;
        String type = "";
        switch (mResult.codec) {
            case H_263:
                type = "video/3gpp";
                break; // MediaFormat.MIMETYPE_VIDEO_H263;
            case H_264:
                type = "video/avc";
                break; // MediaFormat.MIMETYPE_VIDEO_AVC:
            case DEVICE_DEFAULT:
                type = "video/avc";
                break;
        }
        LOG.w("Creating frame encoder. Rotation:", mResult.rotation);
        TextureMediaEncoder.Config config = new TextureMediaEncoder.Config(width, height,
                mResult.videoBitRate,
                mResult.videoFrameRate,
                mResult.rotation,
                type, mTextureId,
                scaleX, scaleY,
                mPreview.mInputFlipped,
                EGL14.eglGetCurrentContext()
        );
        TextureMediaEncoder videoEncoder = new TextureMediaEncoder(config);

        // Audio
        AudioMediaEncoder audioEncoder = null;
        if (mResult.audio == Audio.ON) {
            audioEncoder = new AudioMediaEncoder(new AudioMediaEncoder.Config(mResult.audioBitRate));
        }

        // Engine
        mEncoderEngine = new MediaEncoderEngine(mResult.file, videoEncoder, audioEncoder,
                mResult.maxDuration, mResult.maxSize, SnapshotVideoRecorder.this);
        mEncoderEngine.start();
        mResult.rotation = 0; // We will rotate the result instead.
        mCurrentState = STATE_RECORDING;
    }

    if (mCurrentState == STATE_RECORDING) {
        TextureMediaEncoder textureEncoder = (TextureMediaEncoder) mEncoderEngine.getVideoEncoder();
        TextureMediaEncoder.TextureFrame textureFrame = textureEncoder.acquireFrame();
        textureFrame.timestamp = surfaceTexture.getTimestamp();
        surfaceTexture.getTransformMatrix(textureFrame.transform);
        mEncoderEngine.notify(TextureMediaEncoder.FRAME_EVENT, textureFrame);
    }

    if (mCurrentState == STATE_RECORDING && mDesiredState == STATE_NOT_RECORDING) {
        mCurrentState = STATE_NOT_RECORDING; // before nulling encoderEngine!
        mEncoderEngine.stop();
        mEncoderEngine = null;
        mPreview.removeRendererFrameCallback(SnapshotVideoRecorder.this);
        mPreview = null;
    }

}