1

I am trying for weeks to render a vlc streaming to OpenGL on Android. I guess I am missing something. Here is what I have so far.

This is my custom class:

public class VLCVideoView extends SurfaceView implements SurfaceHolder.Callback, IVideoPlayer, GLSurfaceView.Renderer

My initialization on 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);

Implemented the entire GLSurfaceView.Renderer methods:

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

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

@Override
public void onDrawFrame(GL10 gl)

As well, as:

@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();
        }
    }
}

I have a rotating cube being draw, but instead of having the streaming frames as textures, it simple appears streaming on a flat surface.

Any clue?

Pang
  • 9,564
  • 146
  • 81
  • 122
Mrax
  • 63
  • 9
  • did you manage to solve your problem ? – RonTLV May 24 '17 at 08:52
  • In my experience, when I wanted to draw the video as an OpenGL texture to my own geometry, I had to use the SurfaceTexture class approach with VLC android. You make an OpenGL texture, make a SurfaceTexture out of it, and pass that to vlc to use as the target of the frame data. You implement the SurfaceTexture.OnFrameAvailableListener callback interface to know when new data is available, and buffer your texture with that new data by calling SurfaceTexture.updateTexImage - see the class documentation. – Peter Flower Jul 09 '17 at 14:03

0 Answers0