1

我正在尝试数周来在 Android 上将 vlc 流渲染到 OpenGL。我想我错过了一些东西。这是我到目前为止所拥有的。

这是我的自定义类:

公共类 VLCVideoView 扩展 SurfaceView 实现 SurfaceHolder.Callback、IVideoPlayer、GLSurfaceView.Renderer

我在 VLC 上的初始化:

try {
    // Create a new media player
    libvlc = LibVLC.getInstance();
    libvlc.setHardwareAcceleration(LibVLC.HW_ACCELERATION_FULL);
    libvlc.eventVideoPlayerActivityCreated(true);
    libvlc.setSubtitlesEncoding("");
    libvlc.setAout(LibVLC.AOUT_OPENSLES);
    libvlc.setVout(LibVLC.VOUT_OPEGLES2);
    //libvlc.setVout(LibVLC.VOUT_ANDROID_SURFACE);
    libvlc.setTimeStretching(true);
    libvlc.setChroma("RV32");
    libvlc.setVerboseMode(true);
    LibVLC.restart(context);
    holder.setFormat(PixelFormat.RGBA_8888);

    mSurface = holder.getSurface();
    libvlc.attachSurface(mSurface, this);

实现了整个 GLSurfaceView.Renderer 方法:

@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config)

@Override
public void onSurfaceChanged(GL10 gl, int width, int height)

@Override
public void onDrawFrame(GL10 gl)

也:

@Override
protected void onDraw(Canvas canvas) for the VLCVideoView
{
    if (mSurface!= null)
    {
        try {
            Canvas surfaceCanvas = mSurface.lockCanvas(null); 
            if(surfaceCanvas != null)
            {
                super.onDraw(surfaceCanvas);
                mSurface.unlockCanvasAndPost(surfaceCanvas);
            }
        } catch (Surface.OutOfResourcesException excp) {
            excp.printStackTrace();
        }
    }
}

我有一个正在绘制的旋转立方体,但它没有将流式帧作为纹理,而是简单地出现在平面上流式传输。

有什么线索吗?

4

0 回答 0