[vlc-devel] Strange behavior with stream_UrlNew()

Ron Crocker ron.crocker at nsn.com
Tue Sep 4 23:44:39 CEST 2012


On 9/3/12 4:17 AM, ext Rémi Denis-Courmont wrote:
> Le jeudi 30 août 2012 06:08:42, Ron Crocker a écrit :
>> Still new, but the last bit of advice was helpful so I thought I'd try
>> again for a little more. I've made it to the point where I'm trying to
>> load that JSON file I mentioned before. I've modified the HLS code to
>> ask for this file prior to loading any of the media, since that's pretty
>> close to what I want in the end. I'm asking for the file using
>> stream_UrlNew(), and I'm struggling with it a bit.
> It's not entirely obvious what's going on from your log. I'm afraid you'll
> need to debug this yourself. Maybe the size is not known yet immediately after
> stream_UrlNew() returns, but that would be odd.
>
> You should perhaps not rely on the size anyway. In HTTP it is not always
> known, depending how the server generates the resource.
>
That's good advice, so I decided to try something a little different: 
instead of asking for the size prior to reading, I just read what's 
there. That seems quite reliable, actually - the code became simpler and 
is working well.

This is what the code looks like now:

         char buf[4096];

         msg_Info(s,"Loading JSON file from URL: %s",p_sys->abc_url);

         stream_t *p_ts = stream_UrlNew(s,p_sys->abc_url);

         if (!p_ts) {
             return VLC_EGENERIC;
         }

         int64_t bytes = stream_Read(p_ts, buf, sizeof(buf));
         stream_Delete(p_ts);

With the corresponding log:

    stream_filter_abc: Loading JSON file from URL: http://localhost:80/~qa1007/cgi-bin/abc.cgi
    main debug: creating access 'http' location='localhost:80/~qa1007/cgi-bin/abc.cgi', path='(null)'
    main debug: looking for access module: 2 candidates
    access_http debug: http: server='localhost' port=80 file='/~qa1007/cgi-bin/abc.cgi'
    main debug: net: connecting to localhost port 80
    main debug: connection succeeded (socket = 18)
    access_http debug: protocol 'HTTP' answer code 200
    access_http debug: Server: Apache/2.2.22 (Unix) DAV/2 mod_ssl/2.2.22 OpenSSL/0.9.8r
    access_http debug: Connection: close
    access_http debug: Transfer-Encoding: chunked
    access_http debug: Content-Type: application/json
    main debug: using access module "access_http"
    main debug: Using stream method for AStream*
    main debug: starting pre-buffering
    main debug: received first data after 0 ms
    main debug: pre-buffering done 218 bytes in 0s - 834 KiB/s
    main debug: removing module "access_http"
    stream_filter_abc: Processing server response:'{"abc":{...}}'

I fully expect that this JSON file will not exceed my buffer dimension, 
but it's possible that it could. I don't have code that handles that 
case, but it's pretty straightforward and as I'm the source of both the 
JSON file and this extension to VLC I'm not too concerned about it 
becoming an issue.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20120904/06f29eef/attachment.html>


More information about the vlc-devel mailing list