[vlc-devel] [PATCH] Detecting language of subtitles using its filename
Walter Cacau
waltercacau at gmail.com
Fri Feb 15 20:52:22 CET 2013
I am not sure what is next, because this is my first time sending a patch
to VLC. Should we wait more comments? Should I ask somebody for review?
Thanks
On Thu, Feb 7, 2013 at 12:11 PM, Walter Cacau <waltercacau at gmail.com> wrote:
> Hi Jean,
>
> 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.
>
> 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?
>
> Best regards,
>
> Walter
>
> On Thu, Feb 7, 2013 at 11:18 AM, Jean-Baptiste Kempf <jb at videolan.org>wrote:
>
>> On 02 Feb, Walter Cacau wrote :
>> > + /* Detecting subtitle language using its filename */
>> > + {
>> > + input_thread_t * p_input = demux_GetParentInput(p_demux);
>> > + char * psz_video_url =
>> input_item_GetURI(input_GetItem(p_input));
>> > + vlc_object_release(p_input);
>> > +
>> > + if ( psz_video_url )
>> > + {
>> > + char * psz_language = get_language_from_filename(
>> > + p_demux->psz_location,
>> > + psz_video_url
>> > +
>> > + );
>> The new line is weirdly placed.
>>
>> Are you sure you cannot get the filename and not the URL?
>>
>>
>> > +static char * get_language_from_filename( const char *
>> psz_sub_location,
>> > + const char * psz_video_url )
>> > +{
>> > + char * psz_ret = NULL;
>> > + char * psz_video_file = NULL;
>> > + char * psz_sub_file = NULL;
>> > + char * psz_tmp;
>> > + char * psz_sub_suffix;
>> > + char * ps_language_end;
>> > +
>> > + psz_video_file = strrchr( psz_video_url, '/' );
>> > + if( !psz_video_file ) goto end;
>> > + psz_video_file++;
>> > + psz_video_file = decode_URI_duplicate(psz_video_file);
>> > + if( !psz_video_file ) goto end;
>> > +
>> > + psz_sub_file = strrchr( psz_sub_location, '/' );
>> > + if( !psz_sub_file ) goto end;
>> > + psz_sub_file++;
>> > + psz_sub_file = decode_URI_duplicate(psz_sub_file);
>> > + if( !psz_video_file ) goto end;
>> > +
>> > + /* Removing extension, but leaving the dot */
>> > + psz_tmp = strrchr( psz_video_file, '.' );
>> > + if( !psz_tmp ) goto end;
>> > + psz_tmp[1] = '\0';
>> > +
>> > + /* Extracting sub file prefix */
>> > + if( strstr(psz_sub_file, psz_video_file) != psz_sub_file ) goto
>> end;
>> > + psz_sub_suffix = psz_sub_file + strlen(psz_video_file);
>> > +
>> > + ps_language_end = strrchr( psz_sub_suffix, '.' );
>> > + if( !ps_language_end ) goto end;
>> > + *ps_language_end = '\0';
>> > +
>> > + psz_ret = strdup(psz_sub_suffix);
>> > +
>> > +end:
>> > + FREENULL(psz_video_file);
>> > + FREENULL(psz_sub_file);
>> > + return psz_ret;
>> > +}
>>
>> Best regards,
>>
>> --
>> Jean-Baptiste Kempf
>> http://www.jbkempf.com/ - +33 672 704 734
>> Sent from my Electronic Device
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> http://mailman.videolan.org/listinfo/vlc-devel
>>
>
>
>
> --
> Walter Carlos P. Cacau Filho
> ITA T12 - Engenharia de Computação
> waltercacau at gmail.com
>
--
Walter Carlos P. Cacau Filho
ITA T12 - Engenharia de Computação
waltercacau at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20130215/61e2b805/attachment.html>
More information about the vlc-devel
mailing list