Search code examples
httpnetwork-programmingvideo-streamingvlchttp-streaming

How does a VLC client ask the server for more data in application layer (HTTP)?


I am working on a project related to video streaming. I have been reading the http code extensively in the access_output and access modules. My question is regarding how the client asks the server to send more data in the application layer, specifically using http. I assume it is within the httpd file located in the src/network folder, but I have been writing to log files and I can't seem to figure out how the client asks for the data. It really seems like the server just sends it to the client without acknowledgement, but I highly doubt this is the case.

Thank you so much for your help!


Solution

  • Requesting more data is achieved using HTTP GET with a Range header.

    Examples:

    Range: bytes=123-

    Range: bytes=123-456

    In VLC you can find the relevant code in modules/access/http.c:

    static int Request( access_t *p_access, uint64_t i_tell )
    {
    
        [...]
    
        /* Offset */
        if( p_sys->i_version == 1 && ! p_sys->b_continuous )
        {
            p_sys->b_persist = true;
            net_Printf( p_access, p_sys->fd, pvs,
                        "Range: bytes=%"PRIu64"-\r\n", i_tell );
            net_Printf( p_access, p_sys->fd, pvs, "Connection: close\r\n" );
        }
    

    See also: HTTP Range Requests in the RFC.