Hi Jean,<div><br></div><div>I could not figure out a way to get the filename directly inside the demux. At least I could not find a function on src/input/item.c for that.</div><div><br></div><div>About the white space, it is really weird placed, probably an accident, sorry about that :). Should I send another patch fixing it or should I wait to see if there are other comments about the code?</div>
<div><br></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)">Best regards,</span></div><div><font color="#222222" face="arial, sans-serif"><br>
</font></div><div><font color="#222222" face="arial, sans-serif">Walter<br></font><br><div class="gmail_quote">On Thu, Feb 7, 2013 at 11:18 AM, Jean-Baptiste Kempf <span dir="ltr"><<a href="mailto:jb@videolan.org" target="_blank">jb@videolan.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 02 Feb, Walter Cacau wrote :<br>
<div class="im">> +    /* Detecting subtitle language using its filename */<br>
> +    {<br>
> +        input_thread_t * p_input = demux_GetParentInput(p_demux);<br>
> +        char * psz_video_url = input_item_GetURI(input_GetItem(p_input));<br>
> +        vlc_object_release(p_input);<br>
> +<br>
> +        if ( psz_video_url )<br>
> +        {<br>
> +            char * psz_language = get_language_from_filename(<br>
> +                p_demux->psz_location,<br>
> +                psz_video_url<br>
> +<br>
> +            );<br>
</div>The new line is weirdly placed.<br>
<br>
Are you sure you cannot get the filename and not the URL?<br>
<div><div class="h5"><br>
<br>
> +static char * get_language_from_filename( const char * psz_sub_location,<br>
> +                                          const char * psz_video_url )<br>
> +{<br>
> +    char * psz_ret = NULL;<br>
> +    char * psz_video_file = NULL;<br>
> +    char * psz_sub_file = NULL;<br>
> +    char * psz_tmp;<br>
> +    char * psz_sub_suffix;<br>
> +    char * ps_language_end;<br>
> +<br>
> +    psz_video_file = strrchr( psz_video_url, '/' );<br>
> +    if( !psz_video_file ) goto end;<br>
> +    psz_video_file++;<br>
> +    psz_video_file = decode_URI_duplicate(psz_video_file);<br>
> +    if( !psz_video_file ) goto end;<br>
> +<br>
> +    psz_sub_file = strrchr( psz_sub_location, '/' );<br>
> +    if( !psz_sub_file ) goto end;<br>
> +    psz_sub_file++;<br>
> +    psz_sub_file = decode_URI_duplicate(psz_sub_file);<br>
> +    if( !psz_video_file ) goto end;<br>
> +<br>
> +    /* Removing extension, but leaving the dot */<br>
> +    psz_tmp = strrchr( psz_video_file, '.' );<br>
> +    if( !psz_tmp ) goto end;<br>
> +    psz_tmp[1] = '\0';<br>
> +<br>
> +    /* Extracting sub file prefix */<br>
> +    if( strstr(psz_sub_file, psz_video_file) != psz_sub_file ) goto end;<br>
> +    psz_sub_suffix = psz_sub_file + strlen(psz_video_file);<br>
> +<br>
> +    ps_language_end = strrchr( psz_sub_suffix, '.' );<br>
> +    if( !ps_language_end ) goto end;<br>
> +    *ps_language_end = '\0';<br>
> +<br>
> +    psz_ret = strdup(psz_sub_suffix);<br>
> +<br>
> +end:<br>
> +    FREENULL(psz_video_file);<br>
> +    FREENULL(psz_sub_file);<br>
> +    return psz_ret;<br>
> +}<br>
<br>
</div></div>Best regards,<br>
<div class="HOEnZb"><div class="h5"><br>
--<br>
Jean-Baptiste Kempf<br>
<a href="http://www.jbkempf.com/" target="_blank">http://www.jbkempf.com/</a> - <a href="tel:%2B33%20672%20704%20734" value="+33672704734">+33 672 704 734</a><br>
Sent from my Electronic Device<br>
_______________________________________________<br>
vlc-devel mailing list<br>
To unsubscribe or modify your subscription options:<br>
<a href="http://mailman.videolan.org/listinfo/vlc-devel" target="_blank">http://mailman.videolan.org/listinfo/vlc-devel</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Walter Carlos P. Cacau Filho<br>ITA T12 - Engenharia de Computação<div><a href="mailto:waltercacau@gmail.com" target="_blank">waltercacau@gmail.com</a></div>

</div>