houxiao
2017-06-13 4b914a5d7e3d7971cb3e3ed49047fa331bd74da3
VisitFace/RtspNativeCodec/app/src/main/java/com/example/nativecodec/OutputSurface.java
@@ -191,7 +191,7 @@
        }
        checkEglError("before makeCurrent");
        if (!mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext)) {
            throw new RuntimeException("eglMakeCurrent failed");
            //throw new RuntimeException("eglMakeCurrent failed");
        }
    }
    /**
@@ -221,7 +221,8 @@
                    mFrameSyncObject.wait(TIMEOUT_MS);
                    if (!mFrameAvailable) {
                        // TODO: if "spurious wakeup", continue while loop
                        throw new RuntimeException("Surface frame wait timed out");
                        //throw new RuntimeException("Surface frame wait timed out");
                        return;
                    }
                } catch (InterruptedException ie) {
                    // shouldn't happen
@@ -242,7 +243,8 @@
    }
    @Override
    public void onFrameAvailable(SurfaceTexture st) {
        if (VERBOSE) Log.d(TAG, "new frame available");
        //if (VERBOSE)
            Log.d(TAG, "new frame available");
        synchronized (mFrameSyncObject) {
            if (mFrameAvailable) {
                throw new RuntimeException("mFrameAvailable already set, frame could be dropped");
@@ -250,6 +252,7 @@
            mFrameAvailable = true;
            mFrameSyncObject.notifyAll();
        }
    }
    /**
     * Checks for EGL errors.
@@ -262,14 +265,16 @@
            failed = true;
        }
        if (failed) {
            throw new RuntimeException("EGL error encountered (see log)");
            //throw new RuntimeException("EGL error encountered (see log)");
        }
    }
    public Buffer readPixels()
    public byte[] readPixels()
    {
        Buffer buf = ByteBuffer.allocateDirect( 640 * 480 * 4);
        ByteBuffer buf = ByteBuffer.allocateDirect( 640 * 480 * 4);
        mTextureRender.readPixels(buf);
        return buf;
        byte[] newbuf = new  byte[640 * 480 * 4];
        buf.get(newbuf);
        return newbuf;
    }
}