Commit f4eac108 authored by Laurent Aimar's avatar Laurent Aimar

* all: fill psz_language with the iso639 code.

 * dvdnav: select the right SPU track only while creating the ES when we
 are not in the menu. (this way user selection won't be lost).
parent 49f3c89b
......@@ -2,7 +2,7 @@
* dvdnav.c: DVD module using the dvdnav library.
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: dvdnav.c,v 1.9 2004/01/30 01:38:53 fenrir Exp $
* $Id: dvdnav.c,v 1.10 2004/01/30 14:27:48 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -304,7 +304,6 @@ static int DemuxOpen( vlc_object_t *p_this )
vlc_value_t val, text;
int i_title, i_titles, i_chapter, i_chapters, i_angle, i;
char *psz_name;
char psz_lang[3] = "en";
if( strncmp( p_demux->psz_access, "dvdnav", 6 ) ||
strncmp( p_demux->psz_demux, "dvdnav", 6 ) )
......@@ -782,9 +781,17 @@ static void ESSubtitleUpdate( demux_t *p_demux )
{
demux_sys_t *p_sys = p_demux->p_sys;
int i_spu = dvdnav_get_active_spu_stream( p_sys->dvdnav );
int32_t i_title, i_part;
ButtonUpdate( p_demux );
dvdnav_current_title_info( p_sys->dvdnav, &i_title, &i_part );
msg_Err( p_demux, "title=%d part=%d", i_title, i_part );
if( i_title > 0 )
{
return;
}
if( i_spu >= 0 && i_spu <= 0x1f )
{
ps_track_t *tk = &p_sys->tk[PS_ID_TO_TK(0xbd20 + i_spu)];
......@@ -897,31 +904,6 @@ static int DemuxBlock( demux_t *p_demux, uint8_t *pkt, int i_pkt )
return VLC_SUCCESS;
}
static char *LangCode2String( uint16_t i_lang )
{
const iso639_lang_t *pl;
char lang[3];
if( i_lang == 0xffff )
{
return NULL;
}
lang[0] = (i_lang >> 8)&0xff;
lang[1] = (i_lang )&0xff;
lang[2] = 0;
pl = GetLang_1( lang );
if( !strcmp( pl->psz_iso639_1, "??" ) )
{
return strdup( lang );
}
else if( *pl->psz_native_name )
{
return strdup( pl->psz_native_name );
}
return strdup( pl->psz_eng_name );
}
static void ESNew( demux_t *p_demux, int i_id )
{
demux_sys_t *p_sys = p_demux->p_sys;
......@@ -970,8 +952,14 @@ static void ESNew( demux_t *p_demux, int i_id )
}
if( i_audio >= 0 )
{
tk->fmt.psz_language =
LangCode2String( dvdnav_audio_stream_to_lang( p_sys->dvdnav, i_audio ) );
int i_lang = dvdnav_audio_stream_to_lang( p_sys->dvdnav, i_audio );
if( i_lang != 0xffff )
{
tk->fmt.psz_language = malloc( 3 );
tk->fmt.psz_language[0] = (i_lang >> 8)&0xff;
tk->fmt.psz_language[1] = (i_lang )&0xff;
tk->fmt.psz_language[2] = 0;
}
if( dvdnav_get_active_audio_stream( p_sys->dvdnav ) == i_audio )
{
b_select = VLC_TRUE;
......@@ -980,11 +968,26 @@ static void ESNew( demux_t *p_demux, int i_id )
}
else if( tk->fmt.i_cat == SPU_ES )
{
tk->fmt.psz_language =
LangCode2String( dvdnav_spu_stream_to_lang( p_sys->dvdnav, i_id&0x1f ) );
int32_t i_title, i_part;
int i_lang = dvdnav_spu_stream_to_lang( p_sys->dvdnav, i_id&0x1f );
if( i_lang != 0xffff )
{
tk->fmt.psz_language = malloc( 3 );
tk->fmt.psz_language[0] = (i_lang >> 8)&0xff;
tk->fmt.psz_language[1] = (i_lang )&0xff;
tk->fmt.psz_language[2] = 0;
}
/* palette */
tk->fmt.subs.spu.palette[0] = 0xBeef;
memcpy( &tk->fmt.subs.spu.palette[1], p_sys->clut, 16 * sizeof( uint32_t ) );
/* We select only when we are not in the menu */
dvdnav_current_title_info( p_sys->dvdnav, &i_title, &i_part );
if( i_title > 0 &&
dvdnav_get_active_spu_stream( p_sys->dvdnav ) == (i_id&0x1f) )
{
b_select = VLC_TRUE;
}
}
tk->es = es_out_Add( p_demux->out, &tk->fmt );
......
......@@ -2,7 +2,7 @@
* mkv.cpp : matroska demuxer
*****************************************************************************
* Copyright (C) 2003-2004 VideoLAN
* $Id: mkv.cpp,v 1.55 2004/01/25 20:05:28 hartman Exp $
* $Id: mkv.cpp,v 1.56 2004/01/30 14:27:48 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -262,8 +262,6 @@ static char *UTF8ToStr ( const UTFstring &u );
static void LoadCues ( input_thread_t *);
static void InformationsCreate ( input_thread_t *p_input );
static char *LanguageGetName ( const char *psz_code );
/*****************************************************************************
* Open: initializes matroska demux structures
*****************************************************************************/
......@@ -615,11 +613,10 @@ static int Open( vlc_object_t * p_this )
KaxTrackLanguage &lang = *(KaxTrackLanguage*)el3;
lang.ReadData( p_sys->es->I_O() );
tk.fmt.psz_language =
LanguageGetName( string( lang ).c_str() );
tk.fmt.psz_language = strdup( string( lang ).c_str() );
msg_Dbg( p_input,
"| | | + Track Language=`%s'(%s) ",
tk.fmt.psz_language, string( lang ).c_str() );
"| | | + Track Language=`%s'",
tk.fmt.psz_language );
}
else if( EbmlId( *el3 ) == KaxCodecID::ClassInfos.GlobalId )
{
......@@ -2308,38 +2305,3 @@ static char * UTF8ToStr( const UTFstring &u )
return dst;
}
static char *LanguageGetName ( const char *psz_code )
{
const iso639_lang_t *pl;
if( strlen( psz_code ) == 2 )
{
pl = GetLang_1( psz_code );
}
else if( strlen( psz_code ) == 3 )
{
pl = GetLang_2B( psz_code );
if( !strcmp( pl->psz_iso639_1, "??" ) )
{
pl = GetLang_2T( psz_code );
}
}
else
{
return strdup( psz_code );
}
if( !strcmp( pl->psz_iso639_1, "??" ) )
{
return strdup( psz_code );
}
else
{
if( *pl->psz_native_name )
{
return strdup( pl->psz_native_name );
}
return strdup( pl->psz_eng_name );
}
}
......@@ -2,7 +2,7 @@
* mp4.c : MP4 file input module for vlc
*****************************************************************************
* Copyright (C) 2001-2004 VideoLAN
* $Id: mp4.c,v 1.57 2004/01/25 20:05:28 hartman Exp $
* $Id: mp4.c,v 1.58 2004/01/30 14:27:48 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -128,8 +128,6 @@ static inline int64_t MP4_GetMoviePTS(demux_sys_t *p_sys )
return (int64_t)1000000 * p_sys->i_time / p_sys->i_timescale;
}
static char *LanguageGetName( const char *psz_code );
#define FREE( p ) if( p ) { free( p ); (p) = NULL;}
/*****************************************************************************
......@@ -1461,7 +1459,7 @@ static void MP4_TrackCreate( input_thread_t *p_input,
/* Set language */
if( strcmp( language, "```" ) && strcmp( language, "und" ) )
{
p_track->fmt.psz_language = LanguageGetName( language );
p_track->fmt.psz_language = strdup( language );
}
/* fxi i_timescale for AUDIO_ES with i_qt_version == 0 */
......@@ -1833,25 +1831,3 @@ static void MP4_TrackSetELST( input_thread_t *p_input, mp4_track_t *tk, int64_t
}
}
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 );
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment