[vlc-devel] suggestion of modifications of 2.0.5 code for playing stream

julien de ROSNY m8hpw at yahoo.fr
Sun May 19 01:53:48 CEST 2013


SFR (french) provider have developped its own version of VLC (version 1.x) in order to play crypted ts stream (source codes are available). Here i have modified the code to play the same stream but with version 2.0.5.
The first modification is at line 550 of httplive.c file where 
char    *path_end = strrchr(psz_url, '/');
is replaced by
    char *path_end;
    if (psz_path[0]=='/')
    {
    //If the psz path contains all the subpaths and the file name but not the URL
        path_end = strstr(psz_url,"//");
        path_end = strchr(path_end+2, '/')-1;
    }
    else
    {
    //If the psz path only contains the file name 
        path_end = strrchr(psz_url, '/');
    }

because otherwise the subpath after the main internet adress was repeated twice.

Also, I prefer to start with the best image quality, i.e., the flux with the maximum bandwidth

so I replaced in Open function (line 1949 of httplive.c)

int current = p_sys->playback.stream = 0;

by 

int current = p_sys->playback.stream = p_sys->hls_stream->i_count-1;

Now in file http.c
In function "cookie_get_domain" 
I changed (line 1681)
if( !strncmp( str, domain, sizeof(domain) - 1 /* minus \0 */ ) )
into 
if( !strncasemp( str, domain, sizeof(domain) - 1 /* minus \0 */ ) )
 
because in order to be case insensitive. Indeed for my application, the served send "Domain = " instead of "domain="

Ok now, the main modification consists of restoring the cookie jar approach that is used in vlc 1.x.
Indeed, for SFR streaming,  I need to send all the cookies during all the streaming session (i.e., between several http sessions). But because it appears in the 2.x vlc version, the cookies are lost between  http vlc sessions, so we need to keep the cookies even if a http session is closed. The method is directly inspired from the vlc 1.x version
In http.c function Open 
I add
    vlc_array_t *p_jar;
    p_jar = (vlc_array_t *)var_GetAddress( p_this->p_libvlc, "http-cookie-jar" );
    if ( p_jar == NULL )
    {
        p_jar =  (vlc_array_t *) vlc_array_new(); 
        var_Create( p_this->p_libvlc, "http-cookie-jar", VLC_VAR_ADDRESS );
        var_SetAddress( p_this->p_libvlc, "http-cookie-jar", p_jar );
    }
    return OpenWithCookies( p_this, p_access->psz_access, 5, p_jar );


Then if I want to keep the cookies with the http-forward-cookies flag I do not anymore delete it

at line 691
I modified the function OpenWithCookies 
 if (!(b_forward_cookies)||( p_sys->cookies ))
    {
        int i;
        for( i = 0; i < vlc_array_count( p_sys->cookies ); i++ )
            free(vlc_array_item_at_index( p_sys->cookies, i ));
        vlc_array_destroy( p_sys->cookies );
        p_sys->cookies=NULL;
    }
 
Line 733 same modifications
    if (( p_sys->cookies )&&(!var_InheritBool( p_access, "http-forward-cookies" )))
    {
        int i;
        for( i = 0; i < vlc_array_count( p_sys->cookies ); i++ )
            free(vlc_array_item_at_index( p_sys->cookies, i ));
        vlc_array_destroy( p_sys->cookies );
        p_sys->cookies=NULL;
   }

Now with these modifications, I successfully play with vlc the streams.

But with this approach I think the cookie array is never destroyed. Should I destroyed it in libvlc_InternalCleanup function or not?
More generally do you think the code is ok to be added to vlc?

juju27
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20130519/1b151d56/attachment.html>


More information about the vlc-devel mailing list