]> git.sesse.net Git - vlc/commitdiff
* mp4: convert 3 bytes codes into language (track name).
authorLaurent Aimar <fenrir@videolan.org>
Tue, 13 Jan 2004 01:54:54 +0000 (01:54 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Tue, 13 Jan 2004 01:54:54 +0000 (01:54 +0000)
modules/demux/mp4/mp4.c

index 846fa156d2ac06324104b6c70bf34c3a1b782ae2..bba2c8ceacc962a3715e953e4ebd72765e616d39 100644 (file)
@@ -2,7 +2,7 @@
  * mp4.c : MP4 file input module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: mp4.c,v 1.51 2004/01/13 01:44:49 fenrir Exp $
+ * $Id: mp4.c,v 1.52 2004/01/13 01:54:54 fenrir Exp $
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -28,6 +28,7 @@
 #include <vlc/vlc.h>
 #include <vlc/input.h>
 #include <vlc_playlist.h>
+#include "iso_lang.h"
 
 #include "libmp4.h"
 #include "mp4.h"
@@ -71,6 +72,8 @@ static uint64_t MP4_GetTrackPos    ( track_data_mp4_t * );
 static int      MP4_TrackSampleSize( track_data_mp4_t * );
 static int      MP4_TrackNextSample( input_thread_t *, track_data_mp4_t * );
 
+static char *LanguageGetName( const char *psz_code );
+
 #define FREE( p ) \
     if( p ) { free( p ); (p) = NULL;}
 
@@ -1344,7 +1347,7 @@ static void MP4_TrackCreate( input_thread_t *p_input,
     /* Set language */
     if( strcmp( language, "```" ) && strcmp( language, "und" ) )
     {
-        p_track->fmt.psz_language = strdup( language );
+        p_track->fmt.psz_language = LanguageGetName( language );
     }
 
     /* fxi i_timescale for AUDIO_ES with i_qt_version == 0 */
@@ -1680,3 +1683,25 @@ static int  MP4_TrackNextSample( input_thread_t     *p_input,
 }
 
 
+static char *LanguageGetName( const char *psz_code )
+{
+    const iso639_lang_t *pl;
+
+    pl = GetLang_2B( psz_code );
+    if( !strcmp( pl->psz_iso639_1, "??" ) )
+    {
+        pl = GetLang_2T( psz_code );
+    }
+
+    if( !strcmp( pl->psz_iso639_1, "??" ) )
+    {
+       return strdup( psz_code );
+    }
+
+    if( *pl->psz_native_name )
+    {
+        return strdup( pl->psz_native_name );
+    }
+    return strdup( pl->psz_eng_name );
+}
+