[vlc-devel] [PATCH 1/2] demux: mkv: parse language codes with embedded country codes

Rémi Denis-Courmont remi at remlab.net
Wed Apr 12 15:37:35 CEST 2017


On April 12, 2017 12:14:08 PM GMT+03:00, Shaleen Jain <shaleen.jain95 at gmail.com> wrote:
>fixes bug: https://trac.videolan.org/vlc/ticket/11813
>---
> modules/demux/mkv/matroska_segment_parse.cpp | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
>diff --git a/modules/demux/mkv/matroska_segment_parse.cpp
>b/modules/demux/mkv/matroska_segment_parse.cpp
>index f4d73613c9..94f54838f8 100644
>--- a/modules/demux/mkv/matroska_segment_parse.cpp
>+++ b/modules/demux/mkv/matroska_segment_parse.cpp
>@@ -80,6 +80,17 @@ static inline char * ToUTF8( const UTFstring &u )
>     return strdup( u.GetUTF8().c_str() );
> }
> 
>+// https://www.matroska.org/technical/specs/index.html#languages
>+static inline char * parseLanguage(const char * lang)
>+{
>+    char* psz_lang = strdup(lang);
>+	if( strchr(psz_lang, '-' ) != NULL ) {
>+		return strtok(psz_lang, "-");
>+	} else {
>+		return psz_lang;
>+	}
>+}
>+
>/*****************************************************************************
>  * ParseSeekHead:
>*****************************************************************************/
>@@ -380,7 +391,7 @@ void matroska_segment_c::ParseTrackEntry(
>KaxTrackEntry *m )
>         E_CASE( KaxTrackLanguage, lang )
>         {
>             free( vars.tk->fmt.psz_language );
>-            vars.tk->fmt.psz_language = strdup( std::string( lang
>).c_str() );
>+            vars.tk->fmt.psz_language = parseLanguage(std::string(
>lang ).c_str());
>       debug( vars, "Track Language=`%s'", vars.tk->fmt.psz_language );
>         }
>         E_CASE( KaxCodecID, codecid )
>-- 
>2.12.2
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

This is not thread-safe.
-- 
Rémi Denis-Courmont


More information about the vlc-devel mailing list