* es.c: functions to handle elementary streams.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: es.c,v 1.2 2002/08/07 00:29:36 sam Exp $
+ * $Id: es.c,v 1.7 2003/10/25 00:49:13 sam Exp $
*
* Author: Stéphane Borel <stef@via.ecp.fr>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
p_input->stream.pp_selected_es = NULL;
p_input->stream.i_selected_es_number = 0;
-
+
while( p_input->stream.i_es_number )
{
input_DelES( p_input, p_input->stream.pp_es[0] );
}
-#define ADDES( id, fourcc, cat, lang, size ) \
+#define ADDES( id, fourcc, cat, lang, descr, size ) \
msg_Dbg( p_input, "new es 0x%x", i_id ); \
- p_es = input_AddES( p_input, NULL, id, size ); \
- p_es->i_stream_id = i_id & 0xff; \
- p_es->i_fourcc = (fourcc); \
- p_es->i_cat = (cat); \
- if( lang ) \
{ \
- strcpy( p_es->psz_desc, DecodeLanguage( lang ) ); \
- }
+ char *psz_descr; \
+ psz_descr = malloc( strlen(DecodeLanguage( lang )) + \
+ strlen(descr) + 1 ); \
+ if( psz_descr ) {strcpy( psz_descr, DecodeLanguage( lang ) ); \
+ strcat( psz_descr, descr );} \
+ p_es = input_AddES( p_input, NULL, id, cat, \
+ psz_descr, size ); \
+ if( psz_descr ) free( psz_descr ); \
+ } \
+ p_es->i_stream_id = i_id & 0xff; \
+ p_es->i_fourcc = (fourcc);
/*****************************************************************************
* dvdplay_Video: read video ES
p_dvd = (dvd_data_t*)(p_input->p_access_data);
p_attr = dvdplay_video_attr( p_dvd->vmg );
-
+
/* ES 0 -> video MPEG2 */
i_id = 0xe0;
-
+
if( p_attr->display_aspect_ratio )
{
- ADDES( 0xe0, VLC_FOURCC('m','p','g','v'), VIDEO_ES, 0, sizeof(int) );
+ ADDES( 0xe0, VLC_FOURCC('m','p','g','v'), VIDEO_ES, 0,
+ "", sizeof(int) );
*(int*)(p_es->p_demux_data) = p_attr->display_aspect_ratio;
}
else
{
- ADDES( 0xe0, VLC_FOURCC('m','p','g','v'), VIDEO_ES, 0, 0 );
+ ADDES( 0xe0, VLC_FOURCC('m','p','g','v'), VIDEO_ES, 0, "", 0 );
}
-
+
}
/*****************************************************************************
p_dvd = (dvd_data_t*)(p_input->p_access_data);
p_dvd->i_audio_nb = 0;
dvdplay_audio_info( p_dvd->vmg, &i_audio_nr, &i_audio );
-
+
/* Audio ES, in the order they appear in .ifo */
for( i = 1 ; i <= i_audio_nr ; i++ )
{
switch( p_attr->audio_format )
{
case 0x00: /* A52 */
- ADDES( i_id, VLC_FOURCC('a','5','2',' '), AUDIO_ES, i_lang, 0 );
- strcat( p_es->psz_desc, " (A52)" );
+ ADDES( i_id, VLC_FOURCC('a','5','2','b'), AUDIO_ES, i_lang,
+ " (A52)", 0 );
break;
case 0x02:
case 0x03: /* MPEG audio */
- ADDES( i_id, VLC_FOURCC('m','p','g','a'), AUDIO_ES, i_lang, 0 );
- strcat( p_es->psz_desc, " (mpeg)" );
+ ADDES( i_id, VLC_FOURCC('m','p','g','a'), AUDIO_ES, i_lang,
+ " (mpeg)", 0 );
break;
case 0x04: /* LPCM */
- ADDES( i_id, VLC_FOURCC('l','p','c','m'), AUDIO_ES, i_lang, 0 );
- strcat( p_es->psz_desc, " (lpcm)" );
+ ADDES( i_id, VLC_FOURCC('l','p','c','b'), AUDIO_ES, i_lang,
+ " (lpcm)", 0 );
break;
case 0x05: /* SDDS */
- msg_Warn( p_input, "SDDS audio not handled" );
+ ADDES( i_id, VLC_FOURCC('s','d','d','b'), AUDIO_ES, i_lang,
+ " (sdds)", 0 );
+
break;
case 0x06: /* DTS */
- msg_Warn( p_input, "DTS audio not handled yet"
- "(0x%x)", i_id );
+ ADDES( i_id, VLC_FOURCC('d','t','s','b'), AUDIO_ES, i_lang,
+ " (dts)", 0 );
+
break;
default:
i_id = 0;
dvd_data_t * p_dvd;
es_descriptor_t * p_es;
subp_attr_t * p_attr;
- u32 * pi_palette;
+ uint32_t * pi_palette;
int i_subp_nr = -1;
int i_subp = -1;
int i_id;
int i;
-
+
p_dvd = (dvd_data_t*)(p_input->p_access_data);
p_dvd->i_spu_nb = 0;
{
p_attr = dvdplay_subp_attr( p_dvd->vmg, i-1 );
++p_dvd->i_spu_nb;
-
+
if( pi_palette )
{
- ADDES( i_id, VLC_FOURCC('s','p','u',' '), SPU_ES,
- p_attr->lang_code, sizeof(int) + 16*sizeof(u32) );
+ ADDES( i_id, VLC_FOURCC('s','p','u','b'), SPU_ES,
+ p_attr->lang_code, "", sizeof(int) + 16*sizeof(uint32_t) );
*(int*)p_es->p_demux_data = 0xBeeF;
memcpy( (void*)p_es->p_demux_data + sizeof(int),
- pi_palette, 16*sizeof(u32) );
+ pi_palette, 16*sizeof(uint32_t) );
}
else
{
- ADDES( i_id, VLC_FOURCC('s','p','u',' '), SPU_ES,
- p_attr->lang_code, 0 );
+ ADDES( i_id, VLC_FOURCC('s','p','u','b'), SPU_ES,
+ p_attr->lang_code, "", 0 );
}
}
}
p_dvd = (dvd_data_t*)(p_input->p_access_data);
+ /* For audio: check user settings first, then check dvdplay settings. */
+ i_audio = config_GetInt( p_input, "audio-channel" );
+ if( i_audio <= 0 || i_audio > p_dvd->i_audio_nb )
+ {
+ /* if i_audio = -1 dvdplay_audio_info() will select a default channel,
+ * otherwise it warns libdvdplay that we have chosen another stream. */
+ i_audio = -1;
+ }
dvdplay_audio_info( p_dvd->vmg, &i_audio_nr, &i_audio );
- dvdplay_subp_info( p_dvd->vmg, &i_subp_nr, &i_subp );
-
- if( config_GetInt( p_input, "video" ) )
+
+ /* For spu: check user settings first, the check dvdplay settings. */
+ i_subp = config_GetInt( p_input, "spu-channel" );
+ if( i_subp <= 0 || i_subp > p_dvd->i_spu_nb )
{
- input_SelectES( p_input, p_input->stream.pp_es[0] );
+ i_subp = -1;
}
+ dvdplay_subp_info( p_dvd->vmg, &i_subp_nr, &i_subp );
+
+ input_SelectES( p_input, p_input->stream.pp_es[0] );
-// if( !i_audio ) i_audio = 1;
if( i_audio > p_dvd->i_audio_nb ) i_audio = 1;
- if( config_GetInt( p_input, "audio" )
- &&( i_audio > 0 ) && ( p_dvd->i_audio_nb > 0 ) )
+ if( ( i_audio > 0 ) && ( p_dvd->i_audio_nb > 0 ) )
{
if( config_GetInt( p_input, "audio-type" ) == REQUESTED_A52 )
{
int i_a52 = i_audio;
-
+
while( ( i_a52 < p_dvd->i_audio_nb ) &&
( p_input->stream.pp_es[i_a52]->i_fourcc !=
- VLC_FOURCC('a','5','2',' ') ) )
+ VLC_FOURCC('a','5','2','b') ) )
{
i_a52++;
}
if( p_input->stream.pp_es[i_a52]->i_fourcc ==
- VLC_FOURCC('a','5','2',' ') )
+ VLC_FOURCC('a','5','2','b') )
{
input_SelectES( p_input,
p_input->stream.pp_es[i_a52] );
-
+
/* warn libdvdplay that we have chosen another stream */
dvdplay_audio_info( p_dvd->vmg, &i_audio_nr, &i_a52 );
}
else
{
-// input_SelectES( p_input,
-// p_input->stream.pp_es[i_audio] );
+ /* none found, select the default one */
+ input_SelectES( p_input,
+ p_input->stream.pp_es[i_audio] );
}
}
else
}
}
- if( config_GetInt( p_input, "video" )
- && ( i_subp > 0 ) && ( p_dvd->i_spu_nb > 0 ) )
+ if( i_subp > p_dvd->i_spu_nb ) i_subp = -1;
+ if( ( i_subp > 0 ) && ( p_dvd->i_spu_nb > 0 ) )
{
i_subp += p_dvd->i_audio_nb;
input_SelectES( p_input, p_input->stream.pp_es[i_subp] );