X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fdvdplay%2Fes.c;h=496e3e5da37a57b0385a92532ee486bf4504528e;hb=5dc138d758b84e847bf434017503fd75b0036c98;hp=6e565c7f45dc41d5b333cd89a56774b0a5e0346e;hpb=66c62b438630d3836cfe5c15226ae0a9db89a342;p=vlc diff --git a/modules/access/dvdplay/es.c b/modules/access/dvdplay/es.c index 6e565c7f45..496e3e5da3 100644 --- a/modules/access/dvdplay/es.c +++ b/modules/access/dvdplay/es.c @@ -2,7 +2,7 @@ * 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 * @@ -10,7 +10,7 @@ * 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 @@ -58,7 +58,7 @@ void dvdplay_DeleteES( input_thread_t* p_input ) 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] ); @@ -71,16 +71,20 @@ void dvdplay_DeleteES( input_thread_t* p_input ) } -#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 @@ -94,20 +98,21 @@ void dvdplay_Video( input_thread_t * p_input ) 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 ); } - + } /***************************************************************************** @@ -128,7 +133,7 @@ void dvdplay_Audio( input_thread_t * p_input ) 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++ ) { @@ -143,27 +148,30 @@ void dvdplay_Audio( input_thread_t * p_input ) 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; @@ -182,12 +190,12 @@ void dvdplay_Subp( input_thread_t * p_input ) 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; @@ -200,19 +208,19 @@ void dvdplay_Subp( input_thread_t * p_input ) { 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 ); } } } @@ -231,42 +239,53 @@ void dvdplay_LaunchDecoders( input_thread_t * p_input ) 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 @@ -276,8 +295,8 @@ void dvdplay_LaunchDecoders( input_thread_t * p_input ) } } - 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] );