1 /*****************************************************************************
2 * es_out.c: Es Out handler for input.
3 *****************************************************************************
4 * Copyright (C) 2003-2004 VideoLAN
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
30 #include <vlc/input.h>
31 #include <vlc/decoder.h>
33 #include "input_internal.h"
35 #include "vlc_playlist.h"
38 /*****************************************************************************
40 *****************************************************************************/
46 /* Number of es for this pgrm */
49 vlc_bool_t b_selected;
51 /* Clock for this program */
60 es_out_pgrm_t *p_pgrm;
62 /* Channel in the track type */
65 char *psz_description;
71 input_thread_t *p_input;
76 es_out_pgrm_t *p_pgrm; /* Master program */
97 es_out_id_t *p_es_audio;
98 es_out_id_t *p_es_video;
99 es_out_id_t *p_es_sub;
102 static es_out_id_t *EsOutAdd ( es_out_t *, es_format_t * );
103 static int EsOutSend ( es_out_t *, es_out_id_t *, block_t * );
104 static void EsOutDel ( es_out_t *, es_out_id_t * );
105 static void EsOutSelect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_force );
106 static int EsOutControl( es_out_t *, int i_query, va_list );
109 static void EsSelect( es_out_t *out, es_out_id_t *es );
110 static void EsUnselect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_update );
111 static char *LanguageGetName( const char *psz_code );
113 /*****************************************************************************
115 *****************************************************************************/
116 es_out_t *input_EsOutNew( input_thread_t *p_input )
118 es_out_t *out = malloc( sizeof( es_out_t ) );
119 es_out_sys_t *p_sys = malloc( sizeof( es_out_sys_t ) );
122 out->pf_add = EsOutAdd;
123 out->pf_send = EsOutSend;
124 out->pf_del = EsOutDel;
125 out->pf_control = EsOutControl;
128 p_sys->p_input = p_input;
130 p_sys->b_active = VLC_FALSE;
131 p_sys->i_mode = ES_OUT_MODE_AUTO;
136 p_sys->p_pgrm = NULL;
146 var_Get( p_input, "audio-channel", &val );
147 p_sys->i_audio_last = val.i_int;
149 var_Get( p_input, "spu-channel", &val );
150 p_sys->i_sub_last = val.i_int;
152 p_sys->p_es_audio = NULL;
153 p_sys->p_es_video = NULL;
154 p_sys->p_es_sub = NULL;
159 /*****************************************************************************
161 *****************************************************************************/
162 void input_EsOutDelete( es_out_t *out )
164 es_out_sys_t *p_sys = out->p_sys;
167 for( i = 0; i < p_sys->i_es; i++ )
169 if( p_sys->es[i]->p_dec )
171 input_DecoderDelete( p_sys->es[i]->p_dec );
173 if( p_sys->es[i]->psz_description )
174 free( p_sys->es[i]->psz_description );
175 es_format_Clean( &p_sys->es[i]->fmt );
177 free( p_sys->es[i] );
182 for( i = 0; i < p_sys->i_pgrm; i++ )
184 free( p_sys->pgrm[i] );
193 es_out_id_t *input_EsOutGetFromID( es_out_t *out, int i_id )
198 /* Special HACK, -i_id is tha cat of the stream */
199 return (es_out_id_t*)((uint8_t*)NULL-i_id);
202 for( i = 0; i < out->p_sys->i_es; i++ )
204 if( out->p_sys->es[i]->i_id == i_id )
205 return out->p_sys->es[i];
210 void input_EsOutDiscontinuity( es_out_t *out, vlc_bool_t b_audio )
212 es_out_sys_t *p_sys = out->p_sys;
215 for( i = 0; i < p_sys->i_es; i++ )
217 es_out_id_t *es = p_sys->es[i];
219 /* Send a dummy block to let decoder know that
220 * there is a discontinuity */
221 if( es->p_dec && ( !b_audio || es->fmt.i_cat == AUDIO_ES ) )
223 input_DecoderDiscontinuity( es->p_dec );
228 /*****************************************************************************
230 *****************************************************************************/
231 static void EsOutESVarUpdate( es_out_t *out, es_out_id_t *es )
233 es_out_sys_t *p_sys = out->p_sys;
234 input_thread_t *p_input = p_sys->p_input;
235 vlc_value_t val, text;
239 if( es->fmt.i_cat == AUDIO_ES )
240 psz_var = "audio-es";
241 else if( es->fmt.i_cat == VIDEO_ES )
242 psz_var = "video-es";
243 else if( es->fmt.i_cat == SPU_ES )
248 /* Get the number of ES already added */
249 var_Change( p_input, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
254 /* First one, we need to add the "Disable" choice */
255 val2.i_int = -1; text.psz_string = _("Disable");
256 var_Change( p_input, psz_var, VLC_VAR_ADDCHOICE, &val2, &text );
260 /* Take care of the ES description */
261 if( es->psz_description && *es->psz_description )
263 text.psz_string = strdup( es->psz_description );
267 text.psz_string = malloc( strlen( _("Track %i") ) + 20 );
268 sprintf( text.psz_string, _("Track %i"), val.i_int );
271 val.i_int = es->i_id;
272 var_Change( p_input, psz_var, VLC_VAR_ADDCHOICE, &val, &text );
274 free( text.psz_string );
276 var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE );
279 /* EsOutProgramSelect:
280 * Select a program and update the object variable
282 static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm )
284 es_out_sys_t *p_sys = out->p_sys;
285 input_thread_t *p_input = p_sys->p_input;
289 if( p_sys->p_pgrm == p_pgrm )
290 return; /* Nothing to do */
294 es_out_pgrm_t *old = p_sys->p_pgrm;
295 msg_Dbg( p_input, "Unselecting program id=%d", old->i_id );
297 for( i = 0; i < p_sys->i_es; i++ )
299 if( p_sys->es[i]->p_pgrm == old && p_sys->es[i]->p_dec &&
300 p_sys->i_mode != ES_OUT_MODE_ALL )
301 EsUnselect( out, p_sys->es[i], VLC_TRUE );
305 msg_Dbg( p_input, "Selecting program id=%d", p_pgrm->i_id );
307 /* Mark it selected */
308 p_pgrm->b_selected = VLC_TRUE;
310 /* Switch master stream */
311 if( p_sys->p_pgrm && p_sys->p_pgrm->clock.b_master )
313 p_sys->p_pgrm->clock.b_master = VLC_FALSE;
315 p_pgrm->clock.b_master = VLC_TRUE;
316 p_sys->p_pgrm = p_pgrm;
318 /* Update "program" */
319 val.i_int = p_pgrm->i_id;
320 var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL );
323 var_Change( p_input, "audio-es", VLC_VAR_CLEARCHOICES, NULL, NULL );
324 var_Change( p_input, "video-es", VLC_VAR_CLEARCHOICES, NULL, NULL );
325 var_Change( p_input, "spu-es", VLC_VAR_CLEARCHOICES, NULL, NULL );
326 for( i = 0; i < p_sys->i_es; i++ )
328 EsOutESVarUpdate( out, p_sys->es[i] );
329 EsOutSelect( out, p_sys->es[i], VLC_FALSE );
332 var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE );
338 static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, int i_group )
340 es_out_sys_t *p_sys = out->p_sys;
341 input_thread_t *p_input = p_sys->p_input;
344 es_out_pgrm_t *p_pgrm = malloc( sizeof( es_out_pgrm_t ) );
347 p_pgrm->i_id = i_group;
349 p_pgrm->b_selected = VLC_FALSE;
350 input_ClockInit( &p_pgrm->clock, VLC_FALSE, p_input->input.i_cr_average );
353 TAB_APPEND( p_sys->i_pgrm, p_sys->pgrm, p_pgrm );
355 /* Update "program" variable */
357 var_Change( p_input, "program", VLC_VAR_ADDCHOICE, &val, NULL );
359 if( i_group == var_GetInteger( p_input, "program" ) )
361 EsOutProgramSelect( out, p_pgrm );
365 var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE );
373 static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt )
375 es_out_sys_t *p_sys = out->p_sys;
376 input_thread_t *p_input = p_sys->p_input;
378 es_out_id_t *es = malloc( sizeof( es_out_id_t ) );
379 es_out_pgrm_t *p_pgrm = NULL;
382 if( fmt->i_group < 0 )
384 msg_Err( p_input, "invakud group number" );
388 /* Search the program */
389 for( i = 0; i < p_sys->i_pgrm; i++ )
391 if( fmt->i_group == p_sys->pgrm[i]->i_id )
393 p_pgrm = p_sys->pgrm[i];
399 /* Create a new one */
400 p_pgrm = EsOutProgramAdd( out, fmt->i_group );
403 /* Increase ref count for program */
408 fmt->i_id = out->p_sys->i_id;
409 es->i_id = fmt->i_id;
411 es_format_Copy( &es->fmt, fmt );
415 es->i_channel = p_sys->i_audio;
419 es->i_channel = p_sys->i_video;
423 es->i_channel = p_sys->i_sub;
430 es->psz_description = LanguageGetName( fmt->psz_language );
433 if( es->p_pgrm == p_sys->p_pgrm )
434 EsOutESVarUpdate( out, es );
437 /* Add stream info */
438 sprintf( psz_cat, _("Stream %d"), out->p_sys->i_id - 1 );
440 input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Codec"),
441 "%.4s", (char*)&fmt->i_codec );
443 if( *psz_description )
444 input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Language"),
445 "%s", psz_description );
447 if( fmt->psz_description && *fmt->psz_description )
448 input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Description"),
449 "%s", fmt->psz_description );
451 /* Add information */
455 input_Control( p_input, INPUT_ADD_INFO, psz_cat,
456 _("Type"), _("Audio") );
458 if( fmt->audio.i_channels > 0 )
459 input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Channels"),
460 "%d", fmt->audio.i_channels );
462 if( fmt->audio.i_rate > 0 )
463 input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Sample rate"),
464 _("%d Hz"), fmt->audio.i_rate );
466 if( fmt->audio.i_bitspersample > 0 )
467 input_Control( p_input, INPUT_ADD_INFO, psz_cat,
468 _("Bits per sample"), "%d",
469 fmt->audio.i_bitspersample );
471 if( fmt->i_bitrate > 0 )
472 input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Bitrate"),
473 _("%d bps"), fmt->i_bitrate );
477 input_Control( p_input, INPUT_ADD_INFO, psz_cat,
478 _("Type"), _("Video") );
480 if( fmt->video.i_width > 0 && fmt->video.i_height > 0 )
481 input_Control( p_input, INPUT_ADD_INFO, psz_cat,
482 _("Resolution"), "%dx%d",
483 fmt->video.i_width, fmt->video.i_height );
485 if( fmt->video.i_visible_width > 0 &&
486 fmt->video.i_visible_height > 0 )
487 input_Control( p_input, INPUT_ADD_INFO, psz_cat,
488 _("Display resolution"), "%dx%d",
489 fmt->video.i_visible_width,
490 fmt->video.i_visible_height);
494 input_Control( p_input, INPUT_ADD_INFO, psz_cat,
495 _("Type"), _("Subtitle") );
501 free( psz_description );
504 /* Select it if needed */
505 EsOutSelect( out, es, VLC_FALSE );
508 TAB_APPEND( out->p_sys->i_es, out->p_sys->es, es );
509 p_sys->i_id++; /* always incremented */
526 static void EsSelect( es_out_t *out, es_out_id_t *es )
528 es_out_sys_t *p_sys = out->p_sys;
529 input_thread_t *p_input = p_sys->p_input;
535 msg_Warn( p_input, "ES 0x%x is already selected", es->i_id );
539 if( es->fmt.i_cat == VIDEO_ES || es->fmt.i_cat == SPU_ES )
541 if( !var_GetBool( p_input, "video" ) || ( p_input->p_sout && !var_GetBool( p_input, "sout-video" ) ) )
543 msg_Dbg( p_input, "video is disabled, not selecting ES 0x%x", es->i_id );
547 else if( es->fmt.i_cat == AUDIO_ES )
549 var_Get( p_input, "audio", &val );
550 if( !var_GetBool( p_input, "audio" ) || ( p_input->p_sout && !var_GetBool( p_input, "sout-audio" ) ) )
552 msg_Dbg( p_input, "audio is disabled, not selecting ES 0x%x", es->i_id );
557 es->p_dec = input_DecoderNew( p_input, &es->fmt, VLC_FALSE );
558 if( es->p_dec == NULL || es->p_pgrm != p_sys->p_pgrm )
561 if( es->fmt.i_cat == VIDEO_ES )
562 psz_var = "video-es";
563 else if( es->fmt.i_cat == AUDIO_ES )
564 psz_var = "audio-es";
565 else if( es->fmt.i_cat == SPU_ES )
570 /* Mark it as selected */
571 val.i_int = es->i_id;
572 var_Change( p_input, psz_var, VLC_VAR_SETVALUE, &val, NULL );
575 var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE );
578 static void EsUnselect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_update )
580 es_out_sys_t *p_sys = out->p_sys;
581 input_thread_t *p_input = p_sys->p_input;
585 if( es->p_dec == NULL )
587 msg_Warn( p_input, "ES 0x%x is already unselected", es->i_id );
591 input_DecoderDelete( es->p_dec );
598 if( es->p_dec == NULL )
600 if( es->fmt.i_cat == VIDEO_ES )
601 psz_var = "video-es";
602 else if( es->fmt.i_cat == AUDIO_ES )
603 psz_var = "audio-es";
604 else if( es->fmt.i_cat == SPU_ES )
609 /* Mark it as selected */
611 var_Change( p_input, psz_var, VLC_VAR_SETVALUE, &val, NULL );
613 var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE );
617 * Select an ES given the current mode
618 * XXX: you need to take a the lock before (stream.stream_lock)
620 * \param out The es_out structure
621 * \param es es_out_id structure
625 static void EsOutSelect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_force )
627 es_out_sys_t *p_sys = out->p_sys;
629 int i_cat = es->fmt.i_cat;
631 if( !p_sys->b_active ||
632 ( !b_force && es->fmt.i_priority < 0 ) )
637 if( p_sys->i_mode == ES_OUT_MODE_ALL || b_force )
642 else if( p_sys->i_mode == ES_OUT_MODE_AUTO )
646 if( es->p_pgrm != p_sys->p_pgrm )
649 if( i_cat == AUDIO_ES )
651 if( p_sys->p_es_audio &&
652 p_sys->p_es_audio->fmt.i_priority >= es->fmt.i_priority )
656 i_wanted = p_sys->i_audio_last >= 0 ?
657 p_sys->i_audio_last : es->i_channel;
659 else if( i_cat == SPU_ES )
661 if( p_sys->p_es_sub &&
662 p_sys->p_es_sub->fmt.i_priority >=
667 i_wanted = p_sys->i_sub_last;
669 else if( i_cat == VIDEO_ES )
671 i_wanted = es->i_channel;
674 if( i_wanted == es->i_channel && es->p_dec == NULL )
678 /* FIXME TODO handle priority here */
681 if( i_cat == AUDIO_ES )
683 if( p_sys->i_mode == ES_OUT_MODE_AUTO &&
684 p_sys->p_es_audio && p_sys->p_es_audio->p_dec )
686 EsUnselect( out, p_sys->p_es_audio, VLC_FALSE );
688 p_sys->p_es_audio = es;
690 else if( i_cat == SPU_ES )
692 if( p_sys->i_mode == ES_OUT_MODE_AUTO &&
693 p_sys->p_es_sub && p_sys->p_es_sub->p_dec )
695 EsUnselect( out, p_sys->p_es_sub, VLC_FALSE );
697 p_sys->p_es_sub = es;
699 else if( i_cat == VIDEO_ES )
701 p_sys->p_es_video = es;
707 * Send a block for the given es_out
709 * \param out the es_out to send from
710 * \param es the es_out_id
711 * \param p_block the data block to send
713 static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
715 es_out_sys_t *p_sys = out->p_sys;
716 input_thread_t *p_input = p_sys->p_input;
717 es_out_pgrm_t *p_pgrm = es->p_pgrm;
719 /* +11 -> avoid null value with non null dts/pts */
720 if( p_block->i_dts > 0 )
723 input_ClockGetTS( p_input, &p_pgrm->clock, ( p_block->i_dts + 11 ) * 9 / 100 );
725 if( p_block->i_pts > 0 )
728 input_ClockGetTS( p_input, &p_pgrm->clock, ( p_block->i_pts + 11 )* 9 / 100 );
731 p_block->i_rate = p_input->i_rate;
733 /* TODO handle mute */
734 if( es->p_dec && ( es->fmt.i_cat != AUDIO_ES || p_input->i_rate == INPUT_RATE_DEFAULT ) )
736 input_DecoderDecode( es->p_dec, p_block );
740 block_Release( p_block );
746 /*****************************************************************************
748 *****************************************************************************/
749 static void EsOutDel( es_out_t *out, es_out_id_t *es )
751 es_out_sys_t *p_sys = out->p_sys;
753 /* We don't try to reselect */
755 EsUnselect( out, es, es->p_pgrm == p_sys->p_pgrm );
757 TAB_REMOVE( p_sys->i_es, p_sys->es, es );
760 if( es->p_pgrm->i_es == 0 )
762 msg_Err( p_sys->p_input, "Program doesn't have es anymore, clenaing TODO ?" );
765 if( p_sys->p_es_audio == es ) p_sys->p_es_audio = NULL;
766 if( p_sys->p_es_video == es ) p_sys->p_es_video = NULL;
767 if( p_sys->p_es_sub == es ) p_sys->p_es_sub = NULL;
769 switch( es->fmt.i_cat )
782 if( es->psz_description )
783 free( es->psz_description );
785 es_format_Clean( &es->fmt );
791 * Control query handler
793 * \param out the es_out to control
794 * \param i_query A es_out query as defined in include/ninput.h
795 * \param args a variable list of arguments for the query
796 * \return VLC_SUCCESS or an error code
798 static int EsOutControl( es_out_t *out, int i_query, va_list args )
800 es_out_sys_t *p_sys = out->p_sys;
808 case ES_OUT_SET_ES_STATE:
809 es = (es_out_id_t*) va_arg( args, es_out_id_t * );
810 b = (vlc_bool_t) va_arg( args, vlc_bool_t );
811 if( b && es->p_dec == NULL )
814 return es->p_dec ? VLC_SUCCESS : VLC_EGENERIC;
816 else if( !b && es->p_dec )
818 EsUnselect( out, es, es->p_pgrm == p_sys->p_pgrm );
823 case ES_OUT_GET_ES_STATE:
824 es = (es_out_id_t*) va_arg( args, es_out_id_t * );
825 pb = (vlc_bool_t*) va_arg( args, vlc_bool_t * );
827 *pb = es->p_dec ? VLC_TRUE : VLC_FALSE;
830 case ES_OUT_SET_ACTIVE:
832 b = (vlc_bool_t) va_arg( args, vlc_bool_t );
836 var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE );
840 case ES_OUT_GET_ACTIVE:
841 pb = (vlc_bool_t*) va_arg( args, vlc_bool_t * );
842 *pb = p_sys->b_active;
845 case ES_OUT_SET_MODE:
846 i = (int) va_arg( args, int );
847 if( i == ES_OUT_MODE_NONE || i == ES_OUT_MODE_ALL ||
848 i == ES_OUT_MODE_AUTO )
852 /* Reapply policy mode */
853 for( i = 0; i < p_sys->i_es; i++ )
855 if( p_sys->es[i]->p_dec )
857 EsUnselect( out, p_sys->es[i], p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
860 for( i = 0; i < p_sys->i_es; i++ )
862 EsOutSelect( out, p_sys->es[i], VLC_FALSE );
868 case ES_OUT_GET_MODE:
869 pi = (int*) va_arg( args, int* );
874 es = (es_out_id_t*) va_arg( args, es_out_id_t * );
875 /* Special case NULL, NULL+i_cat */
878 for( i = 0; i < p_sys->i_es; i++ )
880 if( p_sys->es[i]->p_dec )
881 EsUnselect( out, p_sys->es[i],
882 p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
885 else if( es == (es_out_id_t*)((uint8_t*)NULL+AUDIO_ES) )
887 for( i = 0; i < p_sys->i_es; i++ )
889 if( p_sys->es[i]->p_dec && p_sys->es[i]->fmt.i_cat == AUDIO_ES )
890 EsUnselect( out, p_sys->es[i], p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
893 else if( es == (es_out_id_t*)((uint8_t*)NULL+VIDEO_ES) )
895 for( i = 0; i < p_sys->i_es; i++ )
897 if( p_sys->es[i]->p_dec && p_sys->es[i]->fmt.i_cat == VIDEO_ES )
898 EsUnselect( out, p_sys->es[i], p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
901 else if( es == (es_out_id_t*)((uint8_t*)NULL+SPU_ES) )
903 for( i = 0; i < p_sys->i_es; i++ )
905 if( p_sys->es[i]->p_dec && p_sys->es[i]->fmt.i_cat == SPU_ES )
906 EsUnselect( out, p_sys->es[i], p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
911 for( i = 0; i < p_sys->i_es; i++ )
913 if( es == p_sys->es[i] )
915 EsOutSelect( out, es, VLC_TRUE );
923 case ES_OUT_SET_GROUP_PCR:
925 es_out_pgrm_t *p_pgrm = NULL;
929 if( i_query == ES_OUT_SET_PCR )
931 p_pgrm = p_sys->p_pgrm;
936 i_group = (int)va_arg( args, int );
937 for( i = 0; i < p_sys->i_pgrm; i++ )
939 if( p_sys->pgrm[i]->i_id == i_group )
941 p_pgrm = p_sys->pgrm[i];
947 p_pgrm = EsOutProgramAdd( out, i_group ); /* Create it */
949 i_pcr = (int64_t)va_arg( args, int64_t );
951 /* 11 is a vodoo trick to avoid non_pcr*9/100 to be null */
952 input_ClockSetPCR( p_sys->p_input, &p_pgrm->clock, (i_pcr + 11 ) * 9 / 100);
956 case ES_OUT_RESET_PCR:
957 for( i = 0; i < p_sys->i_pgrm; i++ )
959 p_sys->pgrm[i]->clock.i_synchro_state = SYNCHRO_REINIT;
960 p_sys->pgrm[i]->clock.last_pts = 0;
964 case ES_OUT_GET_GROUP:
965 pi = (int*) va_arg( args, int* );
967 *pi = p_sys->p_pgrm->i_id;
969 *pi = -1; /* FIXME */
972 case ES_OUT_SET_GROUP:
975 i = (int) va_arg( args, int );
976 for( j = 0; j < p_sys->i_pgrm; j++ )
978 es_out_pgrm_t *p_pgrm = p_sys->pgrm[j];
979 if( p_pgrm->i_id == i )
981 EsOutProgramSelect( out, p_pgrm );
989 msg_Err( p_sys->p_input, "unknown query in es_out_Control" );
994 /****************************************************************************
995 * LanguageGetName: try to expend iso639 into plain name
996 ****************************************************************************/
997 static char *LanguageGetName( const char *psz_code )
999 const iso639_lang_t *pl;
1001 if( psz_code == NULL )
1003 return strdup( "" );
1006 if( strlen( psz_code ) == 2 )
1008 pl = GetLang_1( psz_code );
1010 else if( strlen( psz_code ) == 3 )
1012 pl = GetLang_2B( psz_code );
1013 if( !strcmp( pl->psz_iso639_1, "??" ) )
1015 pl = GetLang_2T( psz_code );
1020 return strdup( psz_code );
1023 if( !strcmp( pl->psz_iso639_1, "??" ) )
1025 return strdup( psz_code );
1029 if( *pl->psz_native_name )
1031 return strdup( pl->psz_native_name );
1033 return strdup( pl->psz_eng_name );