1 /*****************************************************************************
2 * es_out.c: Es Out handler for input.
3 *****************************************************************************
4 * Copyright (C) 2003-2004 the VideoLAN team
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * Jean-Paul Saman <jpsaman #_at_# m2x dot nl>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
34 #include <vlc_common.h>
36 #include <vlc_input.h>
37 #include <vlc_es_out.h>
38 #include <vlc_block.h>
41 #include "input_internal.h"
46 #include "../stream_output/stream_output.h"
48 #include <vlc_iso_lang.h>
49 /* FIXME we should find a better way than including that */
50 #include "../text/iso-639_def.h"
52 /*****************************************************************************
54 *****************************************************************************/
60 /* Number of es for this pgrm */
65 /* Clock for this program */
66 input_clock_t *p_clock;
69 char *psz_now_playing;
79 es_out_pgrm_t *p_pgrm;
81 /* Channel in the track type */
85 char *psz_language_code;
88 decoder_t *p_dec_record;
90 /* Fields for Video with CC */
91 bool pb_cc_present[4];
92 es_out_id_t *pp_cc_es[4];
94 /* Field for CC track from a master video */
95 es_out_id_t *p_master;
100 input_thread_t *p_input;
107 es_out_pgrm_t **pgrm;
108 es_out_pgrm_t **pp_selected_pgrm; /* --programs */
109 es_out_pgrm_t *p_pgrm; /* Master program */
126 int i_audio_last, i_audio_id;
127 int i_sub_last, i_sub_id;
128 int i_default_sub_id; /* As specified in container; if applicable */
129 char **ppsz_audio_language;
130 char **ppsz_sub_language;
132 /* current main es */
133 es_out_id_t *p_es_audio;
134 es_out_id_t *p_es_video;
135 es_out_id_t *p_es_sub;
138 int64_t i_audio_delay;
141 /* Rate used for clock */
147 /* Current preroll */
148 mtime_t i_preroll_end;
150 /* Used for buffering */
152 mtime_t i_buffering_extra_initial;
153 mtime_t i_buffering_extra_stream;
154 mtime_t i_buffering_extra_system;
157 sout_instance_t *p_sout_record;
160 static es_out_id_t *EsOutAdd ( es_out_t *, es_format_t * );
161 static int EsOutSend ( es_out_t *, es_out_id_t *, block_t * );
162 static void EsOutDel ( es_out_t *, es_out_id_t * );
163 static int EsOutControl( es_out_t *, int i_query, va_list );
164 static void EsOutDelete ( es_out_t * );
166 static void EsOutSelect( es_out_t *, es_out_id_t *es, bool b_force );
167 static void EsOutAddInfo( es_out_t *, es_out_id_t *es );
168 static int EsOutSetRecord( es_out_t *, bool b_record );
170 static bool EsIsSelected( es_out_id_t *es );
171 static void EsSelect( es_out_t *out, es_out_id_t *es );
172 static void EsUnselect( es_out_t *out, es_out_id_t *es, bool b_update );
173 static void EsOutDecoderChangeDelay( es_out_t *out, es_out_id_t *p_es );
174 static void EsOutDecodersChangePause( es_out_t *out, bool b_paused, mtime_t i_date );
175 static void EsOutProgramChangePause( es_out_t *out, bool b_paused, mtime_t i_date );
176 static void EsOutProgramsChangeRate( es_out_t *out );
177 static void EsOutDecodersStopBuffering( es_out_t *out, bool b_forced );
178 static char *LanguageGetName( const char *psz_code );
179 static char *LanguageGetCode( const char *psz_lang );
180 static char **LanguageSplit( const char *psz_langs );
181 static int LanguageArrayIndex( char **ppsz_langs, char *psz_lang );
183 static char *EsOutProgramGetMetaName( es_out_pgrm_t *p_pgrm );
185 static const vlc_fourcc_t EsOutFourccClosedCaptions[4] = {
186 VLC_FOURCC('c', 'c', '1', ' '),
187 VLC_FOURCC('c', 'c', '2', ' '),
188 VLC_FOURCC('c', 'c', '3', ' '),
189 VLC_FOURCC('c', 'c', '4', ' '),
191 static inline int EsOutGetClosedCaptionsChannel( vlc_fourcc_t fcc )
194 for( i = 0; i < 4; i++ )
196 if( fcc == EsOutFourccClosedCaptions[i] )
203 /*****************************************************************************
205 *****************************************************************************/
206 es_out_t *input_EsOutNew( input_thread_t *p_input, int i_rate )
211 es_out_t *out = malloc( sizeof( *out ) );
215 es_out_sys_t *p_sys = malloc( sizeof( *p_sys ) );
222 out->pf_add = EsOutAdd;
223 out->pf_send = EsOutSend;
224 out->pf_del = EsOutDel;
225 out->pf_control = EsOutControl;
226 out->pf_destroy = EsOutDelete;
228 out->b_sout = p_input->p->p_sout != NULL;
231 vlc_mutex_init_recursive( &p_sys->lock );
232 p_sys->p_input = p_input;
234 p_sys->b_active = false;
235 p_sys->i_mode = ES_OUT_MODE_AUTO;
238 TAB_INIT( p_sys->i_pgrm, p_sys->pgrm );
239 p_sys->p_pgrm = NULL;
243 TAB_INIT( p_sys->i_es, p_sys->es );
250 var_Get( p_input, "audio-track", &val );
251 p_sys->i_audio_last = val.i_int;
253 var_Get( p_input, "sub-track", &val );
254 p_sys->i_sub_last = val.i_int;
256 p_sys->i_default_sub_id = -1;
258 if( !p_input->b_preparsing )
260 var_Get( p_input, "audio-language", &val );
261 p_sys->ppsz_audio_language = LanguageSplit(val.psz_string);
262 if( p_sys->ppsz_audio_language )
264 for( i = 0; p_sys->ppsz_audio_language[i]; i++ )
265 msg_Dbg( p_input, "selected audio language[%d] %s",
266 i, p_sys->ppsz_audio_language[i] );
268 free( val.psz_string );
270 var_Get( p_input, "sub-language", &val );
271 p_sys->ppsz_sub_language = LanguageSplit(val.psz_string);
272 if( p_sys->ppsz_sub_language )
274 for( i = 0; p_sys->ppsz_sub_language[i]; i++ )
275 msg_Dbg( p_input, "selected subtitle language[%d] %s",
276 i, p_sys->ppsz_sub_language[i] );
278 free( val.psz_string );
282 p_sys->ppsz_sub_language = NULL;
283 p_sys->ppsz_audio_language = NULL;
286 var_Get( p_input, "audio-track-id", &val );
287 p_sys->i_audio_id = val.i_int;
289 var_Get( p_input, "sub-track-id", &val );
290 p_sys->i_sub_id = val.i_int;
292 p_sys->p_es_audio = NULL;
293 p_sys->p_es_video = NULL;
294 p_sys->p_es_sub = NULL;
296 p_sys->i_audio_delay= 0;
297 p_sys->i_spu_delay = 0;
299 p_sys->b_paused = false;
301 p_sys->i_rate = i_rate;
303 p_sys->b_buffering = true;
304 p_sys->i_buffering_extra_initial = 0;
305 p_sys->i_buffering_extra_stream = 0;
306 p_sys->i_buffering_extra_system = 0;
307 p_sys->i_preroll_end = -1;
309 p_sys->p_sout_record = NULL;
314 void input_EsOutChangeRate( es_out_t *out, int i_rate )
316 es_out_sys_t *p_sys = out->p_sys;
318 p_sys->i_rate = i_rate;
320 if( !p_sys->b_paused )
321 EsOutProgramsChangeRate( out );
324 void input_EsOutChangePause( es_out_t *out, bool b_paused, mtime_t i_date )
326 es_out_sys_t *p_sys = out->p_sys;
328 /* XXX the order is important */
331 EsOutDecodersChangePause( out, true, i_date );
332 EsOutProgramChangePause( out, true, i_date );
336 if( p_sys->i_buffering_extra_initial > 0 )
338 mtime_t i_stream_start;
339 mtime_t i_system_start;
340 mtime_t i_stream_duration;
341 mtime_t i_system_duration;
343 i_ret = input_clock_GetState( p_sys->p_pgrm->p_clock,
344 &i_stream_start, &i_system_start,
345 &i_stream_duration, &i_system_duration );
348 /* FIXME pcr != exactly what wanted */
349 const mtime_t i_used = /*(i_stream_duration - p_sys->p_input->i_pts_delay)*/ p_sys->i_buffering_extra_system - p_sys->i_buffering_extra_initial;
352 p_sys->i_buffering_extra_initial = 0;
353 p_sys->i_buffering_extra_stream = 0;
354 p_sys->i_buffering_extra_system = 0;
356 EsOutProgramChangePause( out, false, i_date );
357 EsOutDecodersChangePause( out, false, i_date );
359 EsOutProgramsChangeRate( out );
361 p_sys->b_paused = b_paused;
363 void input_EsOutChangePosition( es_out_t *out )
365 es_out_sys_t *p_sys = out->p_sys;
367 for( int i = 0; i < p_sys->i_es; i++ )
369 es_out_id_t *p_es = p_sys->es[i];
374 input_DecoderStartBuffering( p_es->p_dec );
376 if( p_es->p_dec_record )
377 input_DecoderStartBuffering( p_es->p_dec );
380 for( int i = 0; i < p_sys->i_pgrm; i++ )
381 input_clock_Reset( p_sys->pgrm[i]->p_clock );
383 p_sys->b_buffering = true;
384 p_sys->i_buffering_extra_initial = 0;
385 p_sys->i_buffering_extra_stream = 0;
386 p_sys->i_buffering_extra_system = 0;
387 p_sys->i_preroll_end = -1;
390 void input_EsOutFrameNext( es_out_t *out )
392 es_out_sys_t *p_sys = out->p_sys;
393 es_out_id_t *p_es_video = NULL;
395 if( p_sys->b_buffering )
397 msg_Warn( p_sys->p_input, "buffering, ignoring 'frame next'" );
401 assert( p_sys->b_paused );
403 for( int i = 0; i < p_sys->i_es; i++ )
405 es_out_id_t *p_es = p_sys->es[i];
407 if( p_es->fmt.i_cat == VIDEO_ES && p_es->p_dec )
416 msg_Warn( p_sys->p_input, "No video track selected, ignoring 'frame next'" );
421 input_DecoderFrameNext( p_es_video->p_dec, &i_duration );
423 msg_Dbg( out->p_sys->p_input, "input_EsOutFrameNext consummed %d ms", (int)(i_duration/1000) );
425 if( i_duration <= 0 )
426 i_duration = 40*1000;
428 /* FIXME it is not a clean way ? */
429 if( p_sys->i_buffering_extra_initial <= 0 )
431 mtime_t i_stream_start;
432 mtime_t i_system_start;
433 mtime_t i_stream_duration;
434 mtime_t i_system_duration;
437 i_ret = input_clock_GetState( p_sys->p_pgrm->p_clock,
438 &i_stream_start, &i_system_start,
439 &i_stream_duration, &i_system_duration );
443 p_sys->i_buffering_extra_initial = 1 + i_stream_duration - p_sys->p_input->i_pts_delay; /* FIXME < 0 ? */
444 p_sys->i_buffering_extra_system =
445 p_sys->i_buffering_extra_stream = p_sys->i_buffering_extra_initial;
448 const int i_rate = input_clock_GetRate( p_sys->p_pgrm->p_clock );
450 p_sys->b_buffering = true;
451 p_sys->i_buffering_extra_system += i_duration;
452 p_sys->i_buffering_extra_stream = p_sys->i_buffering_extra_initial +
453 ( p_sys->i_buffering_extra_system - p_sys->i_buffering_extra_initial ) *
454 INPUT_RATE_DEFAULT / i_rate;
456 p_sys->i_preroll_end = -1;
459 void input_EsOutLock( es_out_t *out )
461 vlc_mutex_lock( &out->p_sys->lock );
463 void input_EsOutUnlock( es_out_t *out )
465 vlc_mutex_unlock( &out->p_sys->lock );
468 /*****************************************************************************
470 *****************************************************************************/
471 static void EsOutDelete( es_out_t *out )
473 es_out_sys_t *p_sys = out->p_sys;
476 if( p_sys->p_sout_record )
477 EsOutSetRecord( out, false );
479 for( i = 0; i < p_sys->i_es; i++ )
481 if( p_sys->es[i]->p_dec )
482 input_DecoderDelete( p_sys->es[i]->p_dec );
484 free( p_sys->es[i]->psz_language );
485 free( p_sys->es[i]->psz_language_code );
486 es_format_Clean( &p_sys->es[i]->fmt );
488 free( p_sys->es[i] );
490 if( p_sys->ppsz_audio_language )
492 for( i = 0; p_sys->ppsz_audio_language[i]; i++ )
493 free( p_sys->ppsz_audio_language[i] );
494 free( p_sys->ppsz_audio_language );
496 if( p_sys->ppsz_sub_language )
498 for( i = 0; p_sys->ppsz_sub_language[i]; i++ )
499 free( p_sys->ppsz_sub_language[i] );
500 free( p_sys->ppsz_sub_language );
504 /* FIXME duplicate work EsOutProgramDel (but we cannot use it) add a EsOutProgramClean ? */
505 for( i = 0; i < p_sys->i_pgrm; i++ )
507 es_out_pgrm_t *p_pgrm = p_sys->pgrm[i];
508 input_clock_Delete( p_pgrm->p_clock );
509 free( p_pgrm->psz_now_playing );
510 free( p_pgrm->psz_publisher );
511 free( p_pgrm->psz_name );
513 vlc_epg_Delete( p_pgrm->p_epg );
517 TAB_CLEAN( p_sys->i_pgrm, p_sys->pgrm );
518 vlc_mutex_destroy( &p_sys->lock );
524 static mtime_t EsOutGetWakeup( es_out_t *out )
526 es_out_sys_t *p_sys = out->p_sys;
527 input_thread_t *p_input = p_sys->p_input;
532 /* We do not have a wake up date if the input cannot have its speed
533 * controlled or sout is imposing its own or while buffering
535 * FIXME for !p_input->b_can_pace_control a wkeup time is still needed to avoid too strong buffering */
536 if( !p_input->b_can_pace_control ||
537 p_input->p->b_out_pace_control ||
541 return input_clock_GetWakeup( p_sys->p_pgrm->p_clock );
544 static es_out_id_t *EsOutGetFromID( es_out_t *out, int i_id )
549 /* Special HACK, -i_id is the cat of the stream */
550 return (es_out_id_t*)((uint8_t*)NULL-i_id);
553 for( i = 0; i < out->p_sys->i_es; i++ )
555 if( out->p_sys->es[i]->i_id == i_id )
556 return out->p_sys->es[i];
561 static bool EsOutDecodersIsEmpty( es_out_t *out )
563 es_out_sys_t *p_sys = out->p_sys;
566 if( p_sys->b_buffering && p_sys->p_pgrm )
568 EsOutDecodersStopBuffering( out, true );
569 if( p_sys->b_buffering )
573 for( i = 0; i < p_sys->i_es; i++ )
575 es_out_id_t *es = p_sys->es[i];
577 if( es->p_dec && !input_DecoderIsEmpty( es->p_dec ) )
579 if( es->p_dec_record && !input_DecoderIsEmpty( es->p_dec_record ) )
585 static void EsOutSetDelay( es_out_t *out, int i_cat, int64_t i_delay )
587 es_out_sys_t *p_sys = out->p_sys;
589 if( i_cat == AUDIO_ES )
590 p_sys->i_audio_delay = i_delay;
591 else if( i_cat == SPU_ES )
592 p_sys->i_spu_delay = i_delay;
594 for( int i = 0; i < p_sys->i_es; i++ )
595 EsOutDecoderChangeDelay( out, p_sys->es[i] );
598 static int EsOutSetRecord( es_out_t *out, bool b_record )
600 es_out_sys_t *p_sys = out->p_sys;
601 input_thread_t *p_input = p_sys->p_input;
603 assert( ( b_record && !p_sys->p_sout_record ) || ( !b_record && p_sys->p_sout_record ) );
607 char *psz_path = var_CreateGetString( p_input, "input-record-path" );
608 if( !psz_path || *psz_path == '\0' )
611 psz_path = strdup( config_GetHomeDir() );
614 char *psz_sout = NULL; // TODO conf
616 if( !psz_sout && psz_path )
618 char *psz_file = input_CreateFilename( VLC_OBJECT(p_input), psz_path, INPUT_RECORD_PREFIX, NULL );
621 if( asprintf( &psz_sout, "#record{dst-prefix='%s'}", psz_file ) < 0 )
632 p_sys->p_sout_record = sout_NewInstance( p_input, psz_sout );
636 if( !p_sys->p_sout_record )
639 for( int i = 0; i < p_sys->i_es; i++ )
641 es_out_id_t *p_es = p_sys->es[i];
643 if( !p_es->p_dec || p_es->p_master )
646 p_es->p_dec_record = input_DecoderNew( p_input, &p_es->fmt, p_es->p_pgrm->p_clock, p_sys->p_sout_record );
647 if( p_es->p_dec_record && p_sys->b_buffering )
648 input_DecoderStartBuffering( p_es->p_dec_record );
653 for( int i = 0; i < p_sys->i_es; i++ )
655 es_out_id_t *p_es = p_sys->es[i];
657 if( !p_es->p_dec_record )
660 input_DecoderDelete( p_es->p_dec_record );
661 p_es->p_dec_record = NULL;
664 sout_DeleteInstance( p_sys->p_sout_record );
666 p_sys->p_sout_record = NULL;
673 static void EsOutDecodersStopBuffering( es_out_t *out, bool b_forced )
675 es_out_sys_t *p_sys = out->p_sys;
678 mtime_t i_stream_start;
679 mtime_t i_system_start;
680 mtime_t i_stream_duration;
681 mtime_t i_system_duration;
682 i_ret = input_clock_GetState( p_sys->p_pgrm->p_clock,
683 &i_stream_start, &i_system_start,
684 &i_stream_duration, &i_system_duration );
685 assert( !i_ret || b_forced );
689 mtime_t i_preroll_duration = 0;
690 if( p_sys->i_preroll_end >= 0 )
691 i_preroll_duration = __MAX( p_sys->i_preroll_end - i_stream_start, 0 );
693 const mtime_t i_buffering_duration = p_sys->p_input->i_pts_delay +
695 p_sys->i_buffering_extra_stream;
697 if( i_stream_duration <= i_buffering_duration && !b_forced )
699 msg_Dbg( p_sys->p_input, "Buffering %d%%",
700 (int)(100 * i_stream_duration / i_buffering_duration ) );
704 msg_Dbg( p_sys->p_input, "Stream buffering done (%d ms in %d ms)",
705 (int)(i_stream_duration/1000), (int)(i_system_duration/1000) );
706 p_sys->b_buffering = false;
707 p_sys->i_preroll_end = -1;
709 if( p_sys->i_buffering_extra_initial > 0 )
715 const mtime_t i_decoder_buffering_start = mdate();
716 for( int i = 0; i < p_sys->i_es; i++ )
718 es_out_id_t *p_es = p_sys->es[i];
722 input_DecoderWaitBuffering( p_es->p_dec );
723 if( p_es->p_dec_record )
724 input_DecoderWaitBuffering( p_es->p_dec_record );
727 msg_Dbg( p_sys->p_input, "Decoder buffering done in %d ms",
728 (int)(mdate() - i_decoder_buffering_start)/1000 );
730 const mtime_t i_ts_delay = 10*1000 + /* FIXME CLEANUP thread wake up time*/
732 //msg_Dbg( p_sys->p_input, "==> %lld", i_ts_delay - p_sys->p_input->i_pts_delay );
733 input_clock_ChangeSystemOrigin( p_sys->p_pgrm->p_clock, i_ts_delay - i_buffering_duration );
735 for( int i = 0; i < p_sys->i_es; i++ )
737 es_out_id_t *p_es = p_sys->es[i];
742 input_DecoderStopBuffering( p_es->p_dec );
743 if( p_es->p_dec_record )
744 input_DecoderStopBuffering( p_es->p_dec );
747 static void EsOutDecodersChangePause( es_out_t *out, bool b_paused, mtime_t i_date )
749 es_out_sys_t *p_sys = out->p_sys;
751 /* Pause decoders first */
752 for( int i = 0; i < p_sys->i_es; i++ )
754 es_out_id_t *es = p_sys->es[i];
758 input_DecoderChangePause( es->p_dec, b_paused, i_date );
759 if( es->p_dec_record )
760 input_DecoderChangePause( es->p_dec_record, b_paused, i_date );
764 static void EsOutProgramChangePause( es_out_t *out, bool b_paused, mtime_t i_date )
766 es_out_sys_t *p_sys = out->p_sys;
768 for( int i = 0; i < p_sys->i_pgrm; i++ )
769 input_clock_ChangePause( p_sys->pgrm[i]->p_clock, b_paused, i_date );
772 static void EsOutDecoderChangeDelay( es_out_t *out, es_out_id_t *p_es )
774 es_out_sys_t *p_sys = out->p_sys;
777 if( p_es->fmt.i_cat == AUDIO_ES )
778 i_delay = p_sys->i_audio_delay;
779 else if( p_es->fmt.i_cat == SPU_ES )
780 i_delay = p_sys->i_spu_delay;
785 input_DecoderChangeDelay( p_es->p_dec, i_delay );
786 if( p_es->p_dec_record )
787 input_DecoderChangeDelay( p_es->p_dec_record, i_delay );
790 static void EsOutProgramsChangeRate( es_out_t *out )
792 es_out_sys_t *p_sys = out->p_sys;
794 for( int i = 0; i < p_sys->i_pgrm; i++ )
795 input_clock_ChangeRate( p_sys->pgrm[i]->p_clock, p_sys->i_rate );
798 static void EsOutESVarUpdateGeneric( es_out_t *out, int i_id, es_format_t *fmt, const char *psz_language,
801 es_out_sys_t *p_sys = out->p_sys;
802 input_thread_t *p_input = p_sys->p_input;
803 const bool b_teletext = fmt->i_cat == SPU_ES && fmt->i_codec == VLC_FOURCC( 't', 'e', 'l', 'x' );
804 vlc_value_t val, text;
808 if( fmt->i_cat == AUDIO_ES )
809 psz_var = "audio-es";
810 else if( fmt->i_cat == VIDEO_ES )
811 psz_var = "video-es";
812 else if( fmt->i_cat == SPU_ES )
820 var_SetInteger( p_sys->p_input, "teletext-es", -1 );
823 var_Change( p_input, psz_var, VLC_VAR_DELCHOICE, &val, NULL );
825 var_SetBool( p_sys->p_input, "intf-change", true );
829 /* Get the number of ES already added */
830 var_Change( p_input, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );
835 /* First one, we need to add the "Disable" choice */
836 val2.i_int = -1; text.psz_string = _("Disable");
837 var_Change( p_input, psz_var, VLC_VAR_ADDCHOICE, &val2, &text );
841 /* Take care of the ES description */
842 if( fmt->psz_description && *fmt->psz_description )
844 if( psz_language && *psz_language )
846 text.psz_string = malloc( strlen( fmt->psz_description) +
847 strlen( psz_language ) + 10 );
848 sprintf( text.psz_string, "%s - [%s]", fmt->psz_description,
851 else text.psz_string = strdup( fmt->psz_description );
855 if( psz_language && *psz_language )
857 if( asprintf( &text.psz_string, "%s %i - [%s]", _( "Track" ), val.i_int, psz_language ) == -1 )
858 text.psz_string = NULL;
862 if( asprintf( &text.psz_string, "%s %i", _( "Track" ), val.i_int ) == -1 )
863 text.psz_string = NULL;
868 var_Change( p_input, psz_var, VLC_VAR_ADDCHOICE, &val, &text );
870 free( text.psz_string );
874 if( var_GetInteger( p_sys->p_input, "teletext-es" ) < 0 )
875 var_SetInteger( p_sys->p_input, "teletext-es", i_id );
878 var_SetBool( p_sys->p_input, "intf-change", true );
881 static void EsOutESVarUpdate( es_out_t *out, es_out_id_t *es,
884 EsOutESVarUpdateGeneric( out, es->i_id, &es->fmt, es->psz_language, b_delete );
887 /* EsOutProgramSelect:
888 * Select a program and update the object variable
890 static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm )
892 es_out_sys_t *p_sys = out->p_sys;
893 input_thread_t *p_input = p_sys->p_input;
897 if( p_sys->p_pgrm == p_pgrm )
898 return; /* Nothing to do */
902 es_out_pgrm_t *old = p_sys->p_pgrm;
903 msg_Dbg( p_input, "unselecting program id=%d", old->i_id );
905 for( i = 0; i < p_sys->i_es; i++ )
907 if( p_sys->es[i]->p_pgrm == old && EsIsSelected( p_sys->es[i] ) &&
908 p_sys->i_mode != ES_OUT_MODE_ALL )
909 EsUnselect( out, p_sys->es[i], true );
912 p_sys->p_es_audio = NULL;
913 p_sys->p_es_sub = NULL;
914 p_sys->p_es_video = NULL;
917 msg_Dbg( p_input, "selecting program id=%d", p_pgrm->i_id );
919 /* Mark it selected */
920 p_pgrm->b_selected = true;
922 /* Switch master stream */
923 p_sys->p_pgrm = p_pgrm;
925 /* Update "program" */
926 val.i_int = p_pgrm->i_id;
927 var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL );
930 var_Change( p_input, "audio-es", VLC_VAR_CLEARCHOICES, NULL, NULL );
931 var_Change( p_input, "video-es", VLC_VAR_CLEARCHOICES, NULL, NULL );
932 var_Change( p_input, "spu-es", VLC_VAR_CLEARCHOICES, NULL, NULL );
933 var_SetInteger( p_input, "teletext-es", -1 );
934 for( i = 0; i < p_sys->i_es; i++ )
936 if( p_sys->es[i]->p_pgrm == p_sys->p_pgrm )
937 EsOutESVarUpdate( out, p_sys->es[i], false );
938 EsOutSelect( out, p_sys->es[i], false );
941 /* Update now playing */
942 input_item_SetNowPlaying( p_input->p->input.p_item,
943 p_pgrm->psz_now_playing );
944 input_item_SetPublisher( p_input->p->input.p_item,
945 p_pgrm->psz_publisher );
947 var_SetBool( p_sys->p_input, "intf-change", true );
953 static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, int i_group )
955 es_out_sys_t *p_sys = out->p_sys;
956 input_thread_t *p_input = p_sys->p_input;
959 es_out_pgrm_t *p_pgrm = malloc( sizeof( es_out_pgrm_t ) );
964 p_pgrm->i_id = i_group;
966 p_pgrm->b_selected = false;
967 p_pgrm->psz_name = NULL;
968 p_pgrm->psz_now_playing = NULL;
969 p_pgrm->psz_publisher = NULL;
970 p_pgrm->p_epg = NULL;
971 p_pgrm->p_clock = input_clock_New( p_input->p->input.i_cr_average, p_sys->i_rate );
972 if( !p_pgrm->p_clock )
979 TAB_APPEND( p_sys->i_pgrm, p_sys->pgrm, p_pgrm );
981 /* Update "program" variable */
983 var_Change( p_input, "program", VLC_VAR_ADDCHOICE, &val, NULL );
985 if( i_group == var_GetInteger( p_input, "program" ) )
987 EsOutProgramSelect( out, p_pgrm );
991 var_SetBool( p_sys->p_input, "intf-change", true );
999 static int EsOutProgramDel( es_out_t *out, int i_group )
1001 es_out_sys_t *p_sys = out->p_sys;
1002 input_thread_t *p_input = p_sys->p_input;
1003 es_out_pgrm_t *p_pgrm = NULL;
1007 for( i = 0; i < p_sys->i_pgrm; i++ )
1009 if( p_sys->pgrm[i]->i_id == i_group )
1011 p_pgrm = p_sys->pgrm[i];
1016 if( p_pgrm == NULL )
1017 return VLC_EGENERIC;
1021 msg_Dbg( p_input, "can't delete program %d which still has %i ES",
1022 i_group, p_pgrm->i_es );
1023 return VLC_EGENERIC;
1026 TAB_REMOVE( p_sys->i_pgrm, p_sys->pgrm, p_pgrm );
1028 /* If program is selected we need to unselect it */
1029 if( p_sys->p_pgrm == p_pgrm )
1030 p_sys->p_pgrm = NULL;
1032 input_clock_Delete( p_pgrm->p_clock );
1034 free( p_pgrm->psz_name );
1035 free( p_pgrm->psz_now_playing );
1036 free( p_pgrm->psz_publisher );
1038 vlc_epg_Delete( p_pgrm->p_epg );
1041 /* Update "program" variable */
1042 val.i_int = i_group;
1043 var_Change( p_input, "program", VLC_VAR_DELCHOICE, &val, NULL );
1045 var_SetBool( p_sys->p_input, "intf-change", true );
1050 /* EsOutProgramMeta:
1052 static char *EsOutProgramGetMetaName( es_out_pgrm_t *p_pgrm )
1055 if( p_pgrm->psz_name )
1057 if( asprintf( &psz, _("%s [%s %d]"), p_pgrm->psz_name, _("Program"), p_pgrm->i_id ) == -1 )
1062 if( asprintf( &psz, "%s %d", _("Program"), p_pgrm->i_id ) == -1 )
1068 static void EsOutProgramMeta( es_out_t *out, int i_group, vlc_meta_t *p_meta )
1070 es_out_sys_t *p_sys = out->p_sys;
1071 es_out_pgrm_t *p_pgrm = NULL;
1072 input_thread_t *p_input = p_sys->p_input;
1074 const char *psz_title = NULL;
1075 const char *psz_provider = NULL;
1078 msg_Dbg( p_input, "EsOutProgramMeta: number=%d", i_group );
1080 /* Check against empty meta data (empty for what we handle) */
1081 if( !vlc_meta_Get( p_meta, vlc_meta_Title) &&
1082 !vlc_meta_Get( p_meta, vlc_meta_NowPlaying) &&
1083 !vlc_meta_Get( p_meta, vlc_meta_Publisher) &&
1084 vlc_dictionary_keys_count( &p_meta->extra_tags ) <= 0 )
1089 for( i = 0; i < p_sys->i_pgrm; i++ )
1091 if( p_sys->pgrm[i]->i_id == i_group )
1093 p_pgrm = p_sys->pgrm[i];
1097 if( p_pgrm == NULL )
1098 p_pgrm = EsOutProgramAdd( out, i_group ); /* Create it */
1101 psz_title = vlc_meta_Get( p_meta, vlc_meta_Title);
1102 psz_provider = vlc_meta_Get( p_meta, vlc_meta_Publisher);
1104 /* Update the description text of the program */
1105 if( psz_title && *psz_title )
1110 if( !p_pgrm->psz_name || strcmp( p_pgrm->psz_name, psz_title ) )
1112 char *psz_cat = EsOutProgramGetMetaName( p_pgrm );
1114 /* Remove old entries */
1115 input_Control( p_input, INPUT_DEL_INFO, psz_cat, NULL );
1116 /* TODO update epg name */
1119 free( p_pgrm->psz_name );
1120 p_pgrm->psz_name = strdup( psz_title );
1122 /* ugly but it works */
1123 val.i_int = i_group;
1124 var_Change( p_input, "program", VLC_VAR_DELCHOICE, &val, NULL );
1126 if( psz_provider && *psz_provider )
1128 if( asprintf( &text.psz_string, "%s [%s]", psz_title, psz_provider ) != -1 )
1130 var_Change( p_input, "program", VLC_VAR_ADDCHOICE, &val, &text );
1131 free( text.psz_string );
1136 text.psz_string = (char *)psz_title;
1137 var_Change( p_input, "program", VLC_VAR_ADDCHOICE, &val, &text );
1141 psz_cat = EsOutProgramGetMetaName( p_pgrm );
1144 if( p_sys->p_pgrm == p_pgrm )
1145 input_item_SetPublisher( p_input->p->input.p_item, psz_provider );
1146 input_Control( p_input, INPUT_ADD_INFO, psz_cat, input_MetaTypeToLocalizedString(vlc_meta_Publisher), psz_provider );
1148 char ** ppsz_all_keys = vlc_dictionary_all_keys( &p_meta->extra_tags );
1149 for( i = 0; ppsz_all_keys[i]; i++ )
1151 input_Control( p_input, INPUT_ADD_INFO, psz_cat, _(ppsz_all_keys[i]),
1152 vlc_dictionary_value_for_key( &p_meta->extra_tags, ppsz_all_keys[i] ) );
1153 free( ppsz_all_keys[i] );
1155 free( ppsz_all_keys );
1160 static void vlc_epg_Merge( vlc_epg_t *p_dst, const vlc_epg_t *p_src )
1165 for( i = 0; i < p_src->i_event; i++ )
1167 vlc_epg_event_t *p_evt = p_src->pp_event[i];
1171 for( j = 0; j < p_dst->i_event; j++ )
1173 if( p_dst->pp_event[j]->i_start == p_evt->i_start && p_dst->pp_event[j]->i_duration == p_evt->i_duration )
1178 if( p_dst->pp_event[j]->i_start > p_evt->i_start )
1183 vlc_epg_event_t *p_copy = malloc( sizeof(vlc_epg_event_t) );
1186 memset( p_copy, 0, sizeof(vlc_epg_event_t) );
1187 p_copy->i_start = p_evt->i_start;
1188 p_copy->i_duration = p_evt->i_duration;
1189 p_copy->psz_name = p_evt->psz_name ? strdup( p_evt->psz_name ) : NULL;
1190 p_copy->psz_short_description = p_evt->psz_short_description ? strdup( p_evt->psz_short_description ) : NULL;
1191 p_copy->psz_description = p_evt->psz_description ? strdup( p_evt->psz_description ) : NULL;
1192 TAB_INSERT( p_dst->i_event, p_dst->pp_event, p_copy, j );
1195 /* Update current */
1196 vlc_epg_SetCurrent( p_dst, p_src->p_current ? p_src->p_current->i_start : -1 );
1198 /* Keep only 1 old event */
1199 if( p_dst->p_current )
1201 while( p_dst->i_event > 1 && p_dst->pp_event[0] != p_dst->p_current && p_dst->pp_event[1] != p_dst->p_current )
1202 TAB_REMOVE( p_dst->i_event, p_dst->pp_event, p_dst->pp_event[0] );
1206 static void EsOutProgramEpg( es_out_t *out, int i_group, vlc_epg_t *p_epg )
1208 es_out_sys_t *p_sys = out->p_sys;
1209 input_thread_t *p_input = p_sys->p_input;
1210 es_out_pgrm_t *p_pgrm = NULL;
1215 for( i = 0; i < p_sys->i_pgrm; i++ )
1217 if( p_sys->pgrm[i]->i_id == i_group )
1219 p_pgrm = p_sys->pgrm[i];
1223 if( p_pgrm == NULL )
1224 p_pgrm = EsOutProgramAdd( out, i_group ); /* Create it */
1227 if( !p_pgrm->p_epg )
1228 p_pgrm->p_epg = vlc_epg_New( p_pgrm->psz_name );
1229 vlc_epg_Merge( p_pgrm->p_epg, p_epg );
1232 psz_cat = EsOutProgramGetMetaName( p_pgrm );
1233 #ifdef HAVE_LOCALTIME_R
1235 if( asprintf( &psz_epg, "EPG %s", psz_cat ) == -1 )
1237 input_Control( p_input, INPUT_DEL_INFO, psz_epg, NULL );
1238 msg_Dbg( p_input, "EsOutProgramEpg: number=%d name=%s", i_group, p_pgrm->p_epg->psz_name );
1239 for( i = 0; i < p_pgrm->p_epg->i_event; i++ )
1241 const vlc_epg_event_t *p_evt = p_pgrm->p_epg->pp_event[i];
1242 time_t t_start = (time_t)p_evt->i_start;
1244 char psz_start[128];
1246 localtime_r( &t_start, &tm_start );
1248 snprintf( psz_start, sizeof(psz_start), "%2.2d:%2.2d:%2.2d", tm_start.tm_hour, tm_start.tm_min, tm_start.tm_sec );
1249 if( p_evt->psz_short_description || p_evt->psz_description )
1250 input_Control( p_input, INPUT_ADD_INFO, psz_epg, psz_start, "%s (%2.2d:%2.2d) - %s",
1252 p_evt->i_duration/60/60, (p_evt->i_duration/60)%60,
1253 p_evt->psz_short_description ? p_evt->psz_short_description : p_evt->psz_description );
1255 input_Control( p_input, INPUT_ADD_INFO, psz_epg, psz_start, "%s (%2.2d:%2.2d)",
1257 p_evt->i_duration/60/60, (p_evt->i_duration/60)%60 );
1261 /* Update now playing */
1262 free( p_pgrm->psz_now_playing );
1263 p_pgrm->psz_now_playing = NULL;
1264 if( p_epg->p_current && p_epg->p_current->psz_name && *p_epg->p_current->psz_name )
1265 p_pgrm->psz_now_playing = strdup( p_epg->p_current->psz_name );
1267 if( p_pgrm == p_sys->p_pgrm )
1268 input_item_SetNowPlaying( p_input->p->input.p_item, p_pgrm->psz_now_playing );
1270 if( p_pgrm->psz_now_playing )
1272 input_Control( p_input, INPUT_ADD_INFO, psz_cat,
1273 input_MetaTypeToLocalizedString(vlc_meta_NowPlaying),
1274 p_pgrm->psz_now_playing );
1278 input_Control( p_input, INPUT_DEL_INFO, psz_cat,
1279 input_MetaTypeToLocalizedString(vlc_meta_NowPlaying) );
1288 static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt )
1290 es_out_sys_t *p_sys = out->p_sys;
1291 input_thread_t *p_input = p_sys->p_input;
1293 if( fmt->i_group < 0 )
1295 msg_Err( p_input, "invalid group number" );
1299 es_out_id_t *es = malloc( sizeof( *es ) );
1300 es_out_pgrm_t *p_pgrm = NULL;
1306 vlc_mutex_lock( &p_sys->lock );
1308 /* Search the program */
1309 for( i = 0; i < p_sys->i_pgrm; i++ )
1311 if( fmt->i_group == p_sys->pgrm[i]->i_id )
1313 p_pgrm = p_sys->pgrm[i];
1317 if( p_pgrm == NULL )
1319 /* Create a new one */
1320 p_pgrm = EsOutProgramAdd( out, fmt->i_group );
1323 /* Increase ref count for program */
1328 fmt->i_id = out->p_sys->i_id;
1329 es->i_id = fmt->i_id;
1330 es->p_pgrm = p_pgrm;
1331 es_format_Copy( &es->fmt, fmt );
1333 switch( fmt->i_cat )
1337 audio_replay_gain_t rg;
1339 es->i_channel = p_sys->i_audio;
1341 memset( &rg, 0, sizeof(rg) );
1342 vlc_mutex_lock( &p_input->p->input.p_item->lock );
1343 vlc_audio_replay_gain_MergeFromMeta( &rg, p_input->p->input.p_item->p_meta );
1344 vlc_mutex_unlock( &p_input->p->input.p_item->lock );
1346 for( i = 0; i < AUDIO_REPLAY_GAIN_MAX; i++ )
1348 if( !es->fmt.audio_replay_gain.pb_peak[i] )
1350 es->fmt.audio_replay_gain.pb_peak[i] = rg.pb_peak[i];
1351 es->fmt.audio_replay_gain.pf_peak[i] = rg.pf_peak[i];
1353 if( !es->fmt.audio_replay_gain.pb_gain[i] )
1355 es->fmt.audio_replay_gain.pb_gain[i] = rg.pb_gain[i];
1356 es->fmt.audio_replay_gain.pf_gain[i] = rg.pf_gain[i];
1363 es->i_channel = p_sys->i_video;
1364 if( fmt->video.i_frame_rate && fmt->video.i_frame_rate_base )
1365 vlc_ureduce( &es->fmt.video.i_frame_rate,
1366 &es->fmt.video.i_frame_rate_base,
1367 fmt->video.i_frame_rate,
1368 fmt->video.i_frame_rate_base, 0 );
1372 es->i_channel = p_sys->i_sub;
1379 es->psz_language = LanguageGetName( fmt->psz_language ); /* remember so we only need to do it once */
1380 es->psz_language_code = LanguageGetCode( fmt->psz_language );
1382 es->p_dec_record = NULL;
1383 for( i = 0; i < 4; i++ )
1384 es->pb_cc_present[i] = false;
1385 es->p_master = NULL;
1387 if( es->p_pgrm == p_sys->p_pgrm )
1388 EsOutESVarUpdate( out, es, false );
1390 /* Select it if needed */
1391 EsOutSelect( out, es, false );
1394 TAB_APPEND( out->p_sys->i_es, out->p_sys->es, es );
1395 p_sys->i_id++; /* always incremented */
1396 switch( fmt->i_cat )
1409 EsOutAddInfo( out, es );
1411 vlc_mutex_unlock( &p_sys->lock );
1416 static bool EsIsSelected( es_out_id_t *es )
1420 bool b_decode = false;
1421 if( es->p_master->p_dec )
1423 int i_channel = EsOutGetClosedCaptionsChannel( es->fmt.i_codec );
1424 if( i_channel != -1 )
1425 input_DecoderGetCcState( es->p_master->p_dec, &b_decode, i_channel );
1431 return es->p_dec != NULL;
1434 static void EsCreateDecoder( es_out_t *out, es_out_id_t *p_es )
1436 es_out_sys_t *p_sys = out->p_sys;
1437 input_thread_t *p_input = p_sys->p_input;
1439 p_es->p_dec = input_DecoderNew( p_input, &p_es->fmt, p_es->p_pgrm->p_clock, p_input->p->p_sout );
1442 if( p_sys->b_buffering )
1443 input_DecoderStartBuffering( p_es->p_dec );
1445 if( !p_es->p_master && p_sys->p_sout_record )
1447 p_es->p_dec_record = input_DecoderNew( p_input, &p_es->fmt, p_es->p_pgrm->p_clock, p_sys->p_sout_record );
1448 if( p_es->p_dec_record && p_sys->b_buffering )
1449 input_DecoderStartBuffering( p_es->p_dec_record );
1453 EsOutDecoderChangeDelay( out, p_es );
1455 static void EsDestroyDecoder( es_out_t *out, es_out_id_t *p_es )
1462 input_DecoderDelete( p_es->p_dec );
1465 if( p_es->p_dec_record )
1467 input_DecoderDelete( p_es->p_dec_record );
1468 p_es->p_dec_record = NULL;
1472 static void EsSelect( es_out_t *out, es_out_id_t *es )
1474 es_out_sys_t *p_sys = out->p_sys;
1475 input_thread_t *p_input = p_sys->p_input;
1477 const char *psz_var;
1479 if( EsIsSelected( es ) )
1481 msg_Warn( p_input, "ES 0x%x is already selected", es->i_id );
1488 if( !es->p_master->p_dec )
1491 i_channel = EsOutGetClosedCaptionsChannel( es->fmt.i_codec );
1492 if( i_channel == -1 || input_DecoderSetCcState( es->p_master->p_dec, true, i_channel ) )
1497 if( es->fmt.i_cat == VIDEO_ES || es->fmt.i_cat == SPU_ES )
1499 if( !var_GetBool( p_input, out->b_sout ? "sout-video" : "video" ) )
1501 msg_Dbg( p_input, "video is disabled, not selecting ES 0x%x",
1506 else if( es->fmt.i_cat == AUDIO_ES )
1508 var_Get( p_input, "audio", &val );
1509 if( !var_GetBool( p_input, out->b_sout ? "sout-audio" : "audio" ) )
1511 msg_Dbg( p_input, "audio is disabled, not selecting ES 0x%x",
1516 if( es->fmt.i_cat == SPU_ES )
1518 var_Get( p_input, "spu", &val );
1519 if( !var_GetBool( p_input, out->b_sout ? "sout-spu" : "spu" ) )
1521 msg_Dbg( p_input, "spu is disabled, not selecting ES 0x%x",
1527 EsCreateDecoder( out, es );
1529 if( es->p_dec == NULL || es->p_pgrm != p_sys->p_pgrm )
1533 if( es->fmt.i_cat == VIDEO_ES )
1534 psz_var = "video-es";
1535 else if( es->fmt.i_cat == AUDIO_ES )
1536 psz_var = "audio-es";
1537 else if( es->fmt.i_cat == SPU_ES )
1542 /* Mark it as selected */
1543 val.i_int = es->i_id;
1544 var_Change( p_input, psz_var, VLC_VAR_SETVALUE, &val, NULL );
1546 var_SetBool( p_sys->p_input, "intf-change", true );
1549 static void EsUnselect( es_out_t *out, es_out_id_t *es, bool b_update )
1551 es_out_sys_t *p_sys = out->p_sys;
1552 input_thread_t *p_input = p_sys->p_input;
1554 const char *psz_var;
1556 if( !EsIsSelected( es ) )
1558 msg_Warn( p_input, "ES 0x%x is already unselected", es->i_id );
1564 if( es->p_master->p_dec )
1566 int i_channel = EsOutGetClosedCaptionsChannel( es->fmt.i_codec );
1567 if( i_channel != -1 )
1568 input_DecoderSetCcState( es->p_master->p_dec, false, i_channel );
1573 const int i_spu_id = var_GetInteger( p_input, "spu-es");
1575 for( i = 0; i < 4; i++ )
1577 if( !es->pb_cc_present[i] || !es->pp_cc_es[i] )
1580 if( i_spu_id == es->pp_cc_es[i]->i_id )
1582 /* Force unselection of the CC */
1584 var_Change( p_input, "spu-es", VLC_VAR_SETVALUE, &val, NULL );
1586 var_SetBool( p_sys->p_input, "intf-change", true );
1588 EsOutDel( out, es->pp_cc_es[i] );
1590 es->pb_cc_present[i] = false;
1592 EsDestroyDecoder( out, es );
1599 if( es->p_dec == NULL )
1601 if( es->fmt.i_cat == VIDEO_ES )
1602 psz_var = "video-es";
1603 else if( es->fmt.i_cat == AUDIO_ES )
1604 psz_var = "audio-es";
1605 else if( es->fmt.i_cat == SPU_ES )
1610 /* Mark it as unselected */
1612 var_Change( p_input, psz_var, VLC_VAR_SETVALUE, &val, NULL );
1614 var_SetBool( p_sys->p_input, "intf-change", true );
1618 * Select an ES given the current mode
1619 * XXX: you need to take a the lock before (stream.stream_lock)
1621 * \param out The es_out structure
1622 * \param es es_out_id structure
1623 * \param b_force ...
1626 static void EsOutSelect( es_out_t *out, es_out_id_t *es, bool b_force )
1628 es_out_sys_t *p_sys = out->p_sys;
1630 int i_cat = es->fmt.i_cat;
1632 if( !p_sys->b_active ||
1633 ( !b_force && es->fmt.i_priority < 0 ) )
1638 if( p_sys->i_mode == ES_OUT_MODE_ALL || b_force )
1640 if( !EsIsSelected( es ) )
1641 EsSelect( out, es );
1643 else if( p_sys->i_mode == ES_OUT_MODE_PARTIAL )
1647 var_Get( p_sys->p_input, "programs", &val );
1648 for ( i = 0; i < val.p_list->i_count; i++ )
1650 if ( val.p_list->p_values[i].i_int == es->p_pgrm->i_id || b_force )
1652 if( !EsIsSelected( es ) )
1653 EsSelect( out, es );
1657 var_Change( p_sys->p_input, "programs", VLC_VAR_FREELIST, &val, NULL );
1659 else if( p_sys->i_mode == ES_OUT_MODE_AUTO )
1663 if( es->p_pgrm != p_sys->p_pgrm )
1666 if( i_cat == AUDIO_ES )
1668 int idx1 = LanguageArrayIndex( p_sys->ppsz_audio_language,
1669 es->psz_language_code );
1671 if( p_sys->p_es_audio &&
1672 p_sys->p_es_audio->fmt.i_priority >= es->fmt.i_priority )
1674 int idx2 = LanguageArrayIndex( p_sys->ppsz_audio_language,
1675 p_sys->p_es_audio->psz_language_code );
1677 if( idx1 < 0 || ( idx2 >= 0 && idx2 <= idx1 ) )
1679 i_wanted = es->i_channel;
1683 /* Select audio if (no audio selected yet)
1684 * - no audio-language
1685 * - no audio code for the ES
1686 * - audio code in the requested list */
1688 !strcmp( es->psz_language_code, "??" ) ||
1689 !p_sys->ppsz_audio_language )
1690 i_wanted = es->i_channel;
1693 if( p_sys->i_audio_last >= 0 )
1694 i_wanted = p_sys->i_audio_last;
1696 if( p_sys->i_audio_id >= 0 )
1698 if( es->i_id == p_sys->i_audio_id )
1699 i_wanted = es->i_channel;
1704 else if( i_cat == SPU_ES )
1706 int idx1 = LanguageArrayIndex( p_sys->ppsz_sub_language,
1707 es->psz_language_code );
1709 if( p_sys->p_es_sub &&
1710 p_sys->p_es_sub->fmt.i_priority >= es->fmt.i_priority )
1712 int idx2 = LanguageArrayIndex( p_sys->ppsz_sub_language,
1713 p_sys->p_es_sub->psz_language_code );
1715 msg_Dbg( p_sys->p_input, "idx1=%d(%s) idx2=%d(%s)",
1716 idx1, es->psz_language_code, idx2,
1717 p_sys->p_es_sub->psz_language_code );
1719 if( idx1 < 0 || ( idx2 >= 0 && idx2 <= idx1 ) )
1721 /* We found a SPU that matches our language request */
1722 i_wanted = es->i_channel;
1724 else if( idx1 >= 0 )
1726 msg_Dbg( p_sys->p_input, "idx1=%d(%s)",
1727 idx1, es->psz_language_code );
1729 i_wanted = es->i_channel;
1731 else if( p_sys->i_default_sub_id >= 0 )
1733 if( es->i_id == p_sys->i_default_sub_id )
1734 i_wanted = es->i_channel;
1737 if( p_sys->i_sub_last >= 0 )
1738 i_wanted = p_sys->i_sub_last;
1740 if( p_sys->i_sub_id >= 0 )
1742 if( es->i_id == p_sys->i_sub_id )
1743 i_wanted = es->i_channel;
1748 else if( i_cat == VIDEO_ES )
1750 i_wanted = es->i_channel;
1753 if( i_wanted == es->i_channel && !EsIsSelected( es ) )
1754 EsSelect( out, es );
1757 /* FIXME TODO handle priority here */
1758 if( EsIsSelected( es ) )
1760 if( i_cat == AUDIO_ES )
1762 if( p_sys->i_mode == ES_OUT_MODE_AUTO &&
1763 p_sys->p_es_audio &&
1764 p_sys->p_es_audio != es &&
1765 EsIsSelected( p_sys->p_es_audio ) )
1767 EsUnselect( out, p_sys->p_es_audio, false );
1769 p_sys->p_es_audio = es;
1771 else if( i_cat == SPU_ES )
1773 if( p_sys->i_mode == ES_OUT_MODE_AUTO &&
1775 p_sys->p_es_sub != es &&
1776 EsIsSelected( p_sys->p_es_sub ) )
1778 EsUnselect( out, p_sys->p_es_sub, false );
1780 p_sys->p_es_sub = es;
1782 else if( i_cat == VIDEO_ES )
1784 p_sys->p_es_video = es;
1790 * Send a block for the given es_out
1792 * \param out the es_out to send from
1793 * \param es the es_out_id
1794 * \param p_block the data block to send
1796 static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )
1798 es_out_sys_t *p_sys = out->p_sys;
1799 input_thread_t *p_input = p_sys->p_input;
1802 if( libvlc_stats( p_input ) )
1804 vlc_mutex_lock( &p_input->p->counters.counters_lock );
1805 stats_UpdateInteger( p_input, p_input->p->counters.p_demux_read,
1806 p_block->i_buffer, &i_total );
1807 stats_UpdateFloat( p_input , p_input->p->counters.p_demux_bitrate,
1808 (float)i_total, NULL );
1809 vlc_mutex_unlock( &p_input->p->counters.counters_lock );
1812 vlc_mutex_lock( &p_sys->lock );
1814 /* Mark preroll blocks */
1815 if( p_sys->i_preroll_end >= 0 )
1817 int64_t i_date = p_block->i_pts;
1819 i_date = p_block->i_dts;
1821 if( i_date < p_sys->i_preroll_end )
1822 p_block->i_flags |= BLOCK_FLAG_PREROLL;
1825 p_block->i_rate = 0;
1829 block_Release( p_block );
1830 vlc_mutex_unlock( &p_sys->lock );
1835 if( es->p_dec_record )
1837 block_t *p_dup = block_Duplicate( p_block );
1839 input_DecoderDecode( es->p_dec_record, p_dup );
1841 input_DecoderDecode( es->p_dec, p_block );
1843 /* Check CC status */
1845 bool b_cc_new = false;
1847 input_DecoderIsCcPresent( es->p_dec, pb_cc );
1848 for( int i = 0; i < 4; i++ )
1850 static const vlc_fourcc_t fcc[4] = {
1851 VLC_FOURCC('c', 'c', '1', ' '),
1852 VLC_FOURCC('c', 'c', '2', ' '),
1853 VLC_FOURCC('c', 'c', '3', ' '),
1854 VLC_FOURCC('c', 'c', '4', ' '),
1858 if( es->pb_cc_present[i] || !pb_cc[i] )
1860 msg_Dbg( p_input, "Adding CC track %d for es[%d]", 1+i, es->i_id );
1862 es_format_Init( &fmt, SPU_ES, fcc[i] );
1863 fmt.i_group = es->fmt.i_group;
1864 if( asprintf( &fmt.psz_description,
1865 _("Closed captions %u"), 1 + i ) == -1 )
1866 fmt.psz_description = NULL;
1867 es->pp_cc_es[i] = EsOutAdd( out, &fmt );
1868 es->pp_cc_es[i]->p_master = es;
1869 es_format_Clean( &fmt );
1872 es->pb_cc_present[i] = true;
1876 var_SetBool( p_sys->p_input, "intf-change", true );
1878 vlc_mutex_unlock( &p_sys->lock );
1883 /*****************************************************************************
1885 *****************************************************************************/
1886 static void EsOutDel( es_out_t *out, es_out_id_t *es )
1888 es_out_sys_t *p_sys = out->p_sys;
1889 bool b_reselect = false;
1892 vlc_mutex_lock( &p_sys->lock );
1894 /* We don't try to reselect */
1897 while( !p_sys->p_input->b_die && !p_sys->b_buffering && es->p_dec )
1899 if( input_DecoderIsEmpty( es->p_dec ) &&
1900 ( !es->p_dec_record || input_DecoderIsEmpty( es->p_dec_record ) ))
1904 EsUnselect( out, es, es->p_pgrm == p_sys->p_pgrm );
1907 if( es->p_pgrm == p_sys->p_pgrm )
1908 EsOutESVarUpdate( out, es, true );
1910 TAB_REMOVE( p_sys->i_es, p_sys->es, es );
1913 if( es->p_pgrm->i_es == 0 )
1915 msg_Dbg( p_sys->p_input, "Program doesn't contain anymore ES" );
1918 if( p_sys->p_es_audio == es || p_sys->p_es_video == es ||
1919 p_sys->p_es_sub == es ) b_reselect = true;
1921 if( p_sys->p_es_audio == es ) p_sys->p_es_audio = NULL;
1922 if( p_sys->p_es_video == es ) p_sys->p_es_video = NULL;
1923 if( p_sys->p_es_sub == es ) p_sys->p_es_sub = NULL;
1925 switch( es->fmt.i_cat )
1938 /* Re-select another track when needed */
1941 for( i = 0; i < p_sys->i_es; i++ )
1943 if( es->fmt.i_cat == p_sys->es[i]->fmt.i_cat )
1944 EsOutSelect( out, p_sys->es[i], false );
1948 free( es->psz_language );
1949 free( es->psz_language_code );
1951 es_format_Clean( &es->fmt );
1953 vlc_mutex_unlock( &p_sys->lock );
1959 * Control query handler
1961 * \param out the es_out to control
1962 * \param i_query A es_out query as defined in include/ninput.h
1963 * \param args a variable list of arguments for the query
1964 * \return VLC_SUCCESS or an error code
1966 static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
1968 es_out_sys_t *p_sys = out->p_sys;
1976 case ES_OUT_SET_ES_STATE:
1977 es = (es_out_id_t*) va_arg( args, es_out_id_t * );
1978 b = (bool) va_arg( args, int );
1979 if( b && !EsIsSelected( es ) )
1981 EsSelect( out, es );
1982 return EsIsSelected( es ) ? VLC_SUCCESS : VLC_EGENERIC;
1984 else if( !b && EsIsSelected( es ) )
1986 EsUnselect( out, es, es->p_pgrm == p_sys->p_pgrm );
1991 case ES_OUT_GET_ES_STATE:
1992 es = (es_out_id_t*) va_arg( args, es_out_id_t * );
1993 pb = (bool*) va_arg( args, bool * );
1995 *pb = EsIsSelected( es );
1998 case ES_OUT_SET_ACTIVE:
2000 b = (bool) va_arg( args, int );
2001 p_sys->b_active = b;
2004 var_SetBool( p_sys->p_input, "intf-change", true );
2008 case ES_OUT_GET_ACTIVE:
2009 pb = (bool*) va_arg( args, bool * );
2010 *pb = p_sys->b_active;
2013 case ES_OUT_SET_MODE:
2014 i = (int) va_arg( args, int );
2015 if( i == ES_OUT_MODE_NONE || i == ES_OUT_MODE_ALL ||
2016 i == ES_OUT_MODE_AUTO || i == ES_OUT_MODE_PARTIAL )
2020 /* Reapply policy mode */
2021 for( i = 0; i < p_sys->i_es; i++ )
2023 if( EsIsSelected( p_sys->es[i] ) )
2025 EsUnselect( out, p_sys->es[i],
2026 p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
2029 for( i = 0; i < p_sys->i_es; i++ )
2031 EsOutSelect( out, p_sys->es[i], false );
2035 return VLC_EGENERIC;
2037 case ES_OUT_GET_MODE:
2038 pi = (int*) va_arg( args, int* );
2039 *pi = p_sys->i_mode;
2043 case ES_OUT_RESTART_ES:
2047 es = (es_out_id_t*) va_arg( args, es_out_id_t * );
2051 else if( es == (es_out_id_t*)((uint8_t*)NULL+AUDIO_ES) )
2053 else if( es == (es_out_id_t*)((uint8_t*)NULL+VIDEO_ES) )
2055 else if( es == (es_out_id_t*)((uint8_t*)NULL+SPU_ES) )
2060 for( i = 0; i < p_sys->i_es; i++ )
2064 if( es == p_sys->es[i] )
2066 EsOutSelect( out, es, true );
2072 if( i_cat == UNKNOWN_ES || p_sys->es[i]->fmt.i_cat == i_cat )
2074 if( EsIsSelected( p_sys->es[i] ) )
2076 if( i_query == ES_OUT_RESTART_ES )
2078 if( p_sys->es[i]->p_dec )
2080 EsDestroyDecoder( out, p_sys->es[i] );
2081 EsCreateDecoder( out, p_sys->es[i] );
2086 EsUnselect( out, p_sys->es[i],
2087 p_sys->es[i]->p_pgrm == p_sys->p_pgrm );
2093 if( i_query == ES_OUT_SET_ES )
2096 event.type = vlc_InputSelectedStreamChanged;
2097 vlc_event_send( &p_sys->p_input->p->event_manager, &event );
2102 case ES_OUT_SET_ES_DEFAULT:
2104 es = (es_out_id_t*) va_arg( args, es_out_id_t * );
2108 /*p_sys->i_default_video_id = -1;*/
2109 /*p_sys->i_default_audio_id = -1;*/
2110 p_sys->i_default_sub_id = -1;
2112 else if( es == (es_out_id_t*)((uint8_t*)NULL+AUDIO_ES) )
2114 /*p_sys->i_default_video_id = -1;*/
2116 else if( es == (es_out_id_t*)((uint8_t*)NULL+VIDEO_ES) )
2118 /*p_sys->i_default_audio_id = -1;*/
2120 else if( es == (es_out_id_t*)((uint8_t*)NULL+SPU_ES) )
2122 p_sys->i_default_sub_id = -1;
2126 /*if( es->fmt.i_cat == VIDEO_ES )
2127 p_sys->i_default_video_id = es->i_id;
2129 if( es->fmt.i_cat == AUDIO_ES )
2130 p_sys->i_default_audio_id = es->i_id;
2132 if( es->fmt.i_cat == SPU_ES )
2133 p_sys->i_default_sub_id = es->i_id;
2138 case ES_OUT_SET_PCR:
2139 case ES_OUT_SET_GROUP_PCR:
2141 es_out_pgrm_t *p_pgrm = NULL;
2145 if( i_query == ES_OUT_SET_PCR )
2147 p_pgrm = p_sys->p_pgrm;
2152 i_group = (int)va_arg( args, int );
2153 for( i = 0; i < p_sys->i_pgrm; i++ )
2155 if( p_sys->pgrm[i]->i_id == i_group )
2157 p_pgrm = p_sys->pgrm[i];
2162 if( p_pgrm == NULL )
2163 p_pgrm = EsOutProgramAdd( out, i_group ); /* Create it */
2165 i_pcr = (int64_t)va_arg( args, int64_t );
2167 * TODO do not use mdate() but proper stream acquisition date */
2168 input_clock_Update( p_pgrm->p_clock, VLC_OBJECT(p_sys->p_input),
2169 p_sys->p_input->b_can_pace_control, i_pcr, mdate() );
2170 /* Check buffering state on master clock update */
2171 if( p_sys->b_buffering && p_pgrm == p_sys->p_pgrm )
2172 EsOutDecodersStopBuffering( out, false );
2177 case ES_OUT_RESET_PCR:
2178 msg_Err( p_sys->p_input, "ES_OUT_RESET_PCR called" );
2179 input_EsOutChangePosition( out );
2185 int64_t i_ts = (int64_t)va_arg( args, int64_t );
2186 int64_t *pi_ts = (int64_t *)va_arg( args, int64_t * );
2187 *pi_ts = input_clock_GetTS( p_sys->p_pgrm->p_clock, NULL,
2188 p_sys->p_input->i_pts_delay, i_ts );
2191 return VLC_EGENERIC;
2193 case ES_OUT_GET_GROUP:
2194 pi = (int*) va_arg( args, int* );
2196 *pi = p_sys->p_pgrm->i_id;
2198 *pi = -1; /* FIXME */
2201 case ES_OUT_SET_GROUP:
2204 i = (int) va_arg( args, int );
2205 for( j = 0; j < p_sys->i_pgrm; j++ )
2207 es_out_pgrm_t *p_pgrm = p_sys->pgrm[j];
2208 if( p_pgrm->i_id == i )
2210 EsOutProgramSelect( out, p_pgrm );
2214 return VLC_EGENERIC;
2217 case ES_OUT_SET_FMT:
2219 /* This ain't pretty but is need by some demuxers (eg. Ogg )
2220 * to update the p_extra data */
2222 es = (es_out_id_t*) va_arg( args, es_out_id_t * );
2223 p_fmt = (es_format_t*) va_arg( args, es_format_t * );
2225 return VLC_EGENERIC;
2227 if( p_fmt->i_extra )
2229 es->fmt.i_extra = p_fmt->i_extra;
2230 es->fmt.p_extra = realloc( es->fmt.p_extra, p_fmt->i_extra );
2231 memcpy( es->fmt.p_extra, p_fmt->p_extra, p_fmt->i_extra );
2236 EsDestroyDecoder( out, es );
2238 EsCreateDecoder( out, es );
2240 es->p_dec->fmt_in.i_extra = p_fmt->i_extra;
2241 es->p_dec->fmt_in.p_extra =
2242 realloc( es->p_dec->fmt_in.p_extra, p_fmt->i_extra );
2243 memcpy( es->p_dec->fmt_in.p_extra,
2244 p_fmt->p_extra, p_fmt->i_extra );
2251 case ES_OUT_SET_NEXT_DISPLAY_TIME:
2253 const int64_t i_date = (int64_t)va_arg( args, int64_t );
2256 return VLC_EGENERIC;
2258 p_sys->i_preroll_end = i_date;
2262 case ES_OUT_SET_GROUP_META:
2264 int i_group = (int)va_arg( args, int );
2265 vlc_meta_t *p_meta = (vlc_meta_t*)va_arg( args, vlc_meta_t * );
2267 EsOutProgramMeta( out, i_group, p_meta );
2270 case ES_OUT_SET_GROUP_EPG:
2272 int i_group = (int)va_arg( args, int );
2273 vlc_epg_t *p_epg = (vlc_epg_t*)va_arg( args, vlc_epg_t * );
2275 EsOutProgramEpg( out, i_group, p_epg );
2278 case ES_OUT_DEL_GROUP:
2280 int i_group = (int)va_arg( args, int );
2282 return EsOutProgramDel( out, i_group );
2285 case ES_OUT_GET_WAKE_UP:
2287 mtime_t *pi_wakeup = (mtime_t*)va_arg( args, mtime_t* );
2288 *pi_wakeup = EsOutGetWakeup( out );
2292 case ES_OUT_SET_ES_BY_ID:
2293 case ES_OUT_RESTART_ES_BY_ID:
2294 case ES_OUT_SET_ES_DEFAULT_BY_ID:
2296 const int i_id = (int)va_arg( args, int );
2297 es_out_id_t *p_es = EsOutGetFromID( out, i_id );
2302 case ES_OUT_SET_ES_BY_ID: i_new_query = ES_OUT_SET_ES; break;
2303 case ES_OUT_RESTART_ES_BY_ID: i_new_query = ES_OUT_RESTART_ES; break;
2304 case ES_OUT_SET_ES_DEFAULT_BY_ID: i_new_query = ES_OUT_SET_ES_DEFAULT; break;
2308 /* TODO if the lock is made non recursive it should be changed */
2309 return es_out_Control( out, i_new_query, p_es );
2312 case ES_OUT_GET_BUFFERING:
2313 pb = (bool *)va_arg( args, bool* );
2314 *pb = p_sys->b_buffering;
2317 case ES_OUT_GET_EMPTY:
2318 pb = (bool *)va_arg( args, bool* );
2319 *pb = EsOutDecodersIsEmpty( out );
2322 case ES_OUT_SET_DELAY:
2324 const int i_cat = (int)va_arg( args, int );
2325 const mtime_t i_delay = (mtime_t)va_arg( args, mtime_t );
2326 EsOutSetDelay( out, i_cat, i_delay );
2330 case ES_OUT_SET_RECORD_STATE:
2331 b = (bool) va_arg( args, int );
2332 return EsOutSetRecord( out, b );
2335 msg_Err( p_sys->p_input, "unknown query in es_out_Control" );
2336 return VLC_EGENERIC;
2339 static int EsOutControl( es_out_t *out, int i_query, va_list args )
2341 es_out_sys_t *p_sys = out->p_sys;
2344 vlc_mutex_lock( &p_sys->lock );
2345 i_ret = EsOutControlLocked( out, i_query, args );
2346 vlc_mutex_unlock( &p_sys->lock );
2351 /****************************************************************************
2352 * LanguageGetName: try to expend iso639 into plain name
2353 ****************************************************************************/
2354 static char *LanguageGetName( const char *psz_code )
2356 const iso639_lang_t *pl;
2358 if( psz_code == NULL )
2360 return strdup( "" );
2363 if( strlen( psz_code ) == 2 )
2365 pl = GetLang_1( psz_code );
2367 else if( strlen( psz_code ) == 3 )
2369 pl = GetLang_2B( psz_code );
2370 if( !strcmp( pl->psz_iso639_1, "??" ) )
2372 pl = GetLang_2T( psz_code );
2377 return strdup( psz_code );
2380 if( !strcmp( pl->psz_iso639_1, "??" ) )
2382 return strdup( psz_code );
2386 if( *pl->psz_native_name )
2388 return strdup( pl->psz_native_name );
2390 return strdup( pl->psz_eng_name );
2394 /* Get a 2 char code */
2395 static char *LanguageGetCode( const char *psz_lang )
2397 const iso639_lang_t *pl;
2399 if( psz_lang == NULL || *psz_lang == '\0' )
2400 return strdup("??");
2402 for( pl = p_languages; pl->psz_iso639_1 != NULL; pl++ )
2404 if( !strcasecmp( pl->psz_eng_name, psz_lang ) ||
2405 !strcasecmp( pl->psz_native_name, psz_lang ) ||
2406 !strcasecmp( pl->psz_iso639_1, psz_lang ) ||
2407 !strcasecmp( pl->psz_iso639_2T, psz_lang ) ||
2408 !strcasecmp( pl->psz_iso639_2B, psz_lang ) )
2412 if( pl->psz_iso639_1 != NULL )
2413 return strdup( pl->psz_iso639_1 );
2415 return strdup("??");
2418 static char **LanguageSplit( const char *psz_langs )
2425 if( psz_langs == NULL ) return NULL;
2427 psz_parser = psz_dup = strdup(psz_langs);
2429 while( psz_parser && *psz_parser )
2434 psz = strchr(psz_parser, ',' );
2435 if( psz ) *psz++ = '\0';
2437 if( !strcmp( psz_parser, "any" ) )
2439 TAB_APPEND( i_psz, ppsz, strdup("any") );
2443 psz_code = LanguageGetCode( psz_parser );
2444 if( strcmp( psz_code, "??" ) )
2446 TAB_APPEND( i_psz, ppsz, psz_code );
2459 TAB_APPEND( i_psz, ppsz, NULL );
2466 static int LanguageArrayIndex( char **ppsz_langs, char *psz_lang )
2470 if( !ppsz_langs || !psz_lang ) return -1;
2472 for( i = 0; ppsz_langs[i]; i++ )
2474 if( !strcasecmp( ppsz_langs[i], psz_lang ) ||
2475 !strcasecmp( ppsz_langs[i], "any" ) )
2484 /****************************************************************************
2486 * - add meta info to the playlist item
2487 ****************************************************************************/
2488 static void EsOutAddInfo( es_out_t *out, es_out_id_t *es )
2490 es_out_sys_t *p_sys = out->p_sys;
2491 input_thread_t *p_input = p_sys->p_input;
2492 es_format_t *fmt = &es->fmt;
2496 /* Add stream info */
2497 if( asprintf( &psz_cat, _("Stream %d"), out->p_sys->i_id - 1 ) == -1 )
2500 input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Codec"),
2501 "%.4s", (char*)&fmt->i_codec );
2503 input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Language"),
2504 "%s", es->psz_language );
2506 /* Add information */
2507 switch( fmt->i_cat )
2510 input_Control( p_input, INPUT_ADD_INFO, psz_cat,
2511 _("Type"), _("Audio") );
2513 if( fmt->audio.i_channels > 0 )
2514 input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Channels"),
2515 "%u", fmt->audio.i_channels );
2517 if( fmt->audio.i_rate > 0 )
2519 input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Sample rate"),
2520 _("%u Hz"), fmt->audio.i_rate );
2521 var_SetInteger( p_input, "sample-rate", fmt->audio.i_rate );
2524 if( fmt->audio.i_bitspersample > 0 )
2525 input_Control( p_input, INPUT_ADD_INFO, psz_cat,
2526 _("Bits per sample"), "%u",
2527 fmt->audio.i_bitspersample );
2529 if( fmt->i_bitrate > 0 )
2531 input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Bitrate"),
2532 _("%u kb/s"), fmt->i_bitrate / 1000 );
2533 var_SetInteger( p_input, "bit-rate", fmt->i_bitrate );
2538 input_Control( p_input, INPUT_ADD_INFO, psz_cat,
2539 _("Type"), _("Video") );
2541 if( fmt->video.i_width > 0 && fmt->video.i_height > 0 )
2542 input_Control( p_input, INPUT_ADD_INFO, psz_cat,
2543 _("Resolution"), "%ux%u",
2544 fmt->video.i_width, fmt->video.i_height );
2546 if( fmt->video.i_visible_width > 0 &&
2547 fmt->video.i_visible_height > 0 )
2548 input_Control( p_input, INPUT_ADD_INFO, psz_cat,
2549 _("Display resolution"), "%ux%u",
2550 fmt->video.i_visible_width,
2551 fmt->video.i_visible_height);
2552 if( fmt->video.i_frame_rate > 0 &&
2553 fmt->video.i_frame_rate_base > 0 )
2555 div = lldiv( (float)fmt->video.i_frame_rate /
2556 fmt->video.i_frame_rate_base * 1000000,
2558 input_Control( p_input, INPUT_ADD_INFO, psz_cat,
2559 _("Frame rate"), "%"PRId64".%06u",
2560 div.quot, (unsigned int )div.rem );
2565 input_Control( p_input, INPUT_ADD_INFO, psz_cat,
2566 _("Type"), _("Subtitle") );