ffmpegrtspgoogle-nativeclientrtsp-client

FFmpeg NaCl module avformat_open_input (on rtsp stream) returns -5: I/O error


I want to create an RTSP player in Chrome PNaCl.

I have successfully built the ffmpeg naclport including the following networking flags in the build.sh file for the ffmpeg NaCl port.

--enable network --enable-protocols --enable-demuxer=rtsp --enable-demux=rtp --enable-demuxer=sdp --enable-decoder=h264

Furthermore, I have successfully coded and the linked the ffmpeg NaCl port in my own PNaCl module. I have included the following network permissions in the manifest.json file:

"permissions": [
{
    "socket": [
        "tcp-listen:*:*", 
        "tcp-connect:*:*", 
        "resolve-host:*:*", 
        "udp-bind:*:*", 
        "udp-send-to:*:*"
    ],
}

Now once I run the following code, in PNaCl, the avformat_open_input(...) returns -5 or I/O Error:

    AVFormatContext* formatContext = avformat_alloc_context();

    av_register_all();

    avformat_network_init();

    const char * stream_path = "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov";

    int result = avformat_open_input(&formatContext, stream_path ,NULL,NULL);

    if(result< 0){

        PostMessage("input not opened, result: ");

        PostMessage(result);

    }else{

      PostMessage(std::string("input successfully opened"));

    }

What am I possibly doing wrong, and why can't the PNaCl module access the RTSP stream?

PS. This is a similar question, but it gives no definitive answer.


Solution

  • Are you calling avformat_open_input from your main thread? It seems like socket operations are blocked from working in the main thread.

    Try moving your code to a background thread or, better yet, use ppapi_simple as this automatically executes your code in a background thread.