1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2008 Laurent Aimar
7 * Authors: Laurent Aimar < fenrir _AT_ videolan _DOT_ org>
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
31 #include <vlc_common.h>
32 #include <vlc_input.h>
33 #include "input_internal.h"
37 static void Trigger( input_thread_t *p_input, int i_type );
39 /*****************************************************************************
41 *****************************************************************************/
42 void input_SendEventTimes( input_thread_t *p_input,
43 double f_position, mtime_t i_time, mtime_t i_length )
48 val.f_float = f_position;
49 var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
53 var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
55 /* FIXME ugly + what about meta change event ? */
56 if( var_GetTime( p_input, "length" ) != i_length )
57 input_item_SetDuration( p_input->p->p_item, i_length );
58 val.i_time = i_length;
59 var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL );
61 Trigger( p_input, INPUT_EVENT_TIMES );
63 void input_SendEventStatistics( input_thread_t *p_input )
65 Trigger( p_input, INPUT_EVENT_STATISTICS );
67 void input_SendEventRate( input_thread_t *p_input, int i_rate )
72 var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL );
74 Trigger( p_input, INPUT_EVENT_RATE );
76 void input_SendEventAudioDelay( input_thread_t *p_input, mtime_t i_delay )
81 var_Change( p_input, "audio-delay", VLC_VAR_SETVALUE, &val, NULL );
83 Trigger( p_input, INPUT_EVENT_AUDIO_DELAY );
86 void input_SendEventSubtitleDelay( input_thread_t *p_input, mtime_t i_delay )
91 var_Change( p_input, "spu-delay", VLC_VAR_SETVALUE, &val, NULL );
93 Trigger( p_input, INPUT_EVENT_SUBTITLE_DELAY );
96 /* TODO and file name ? */
97 void input_SendEventRecord( input_thread_t *p_input, bool b_recording )
101 val.b_bool = b_recording;
102 var_Change( p_input, "record", VLC_VAR_SETVALUE, &val, NULL );
104 Trigger( p_input, INPUT_EVENT_RECORD );
107 void input_SendEventTitle( input_thread_t *p_input, int i_title )
112 var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
114 input_ControlVarTitle( p_input, i_title );
116 Trigger( p_input, INPUT_EVENT_TITLE );
119 void input_SendEventSeekpoint( input_thread_t *p_input, int i_title, int i_seekpoint )
123 VLC_UNUSED( i_title );
124 val.i_int = i_seekpoint;
125 var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL );
127 Trigger( p_input, INPUT_EVENT_CHAPTER );
130 void input_SendEventSignal( input_thread_t *p_input, double f_quality, double f_strength )
134 val.f_float = f_quality;
135 var_Change( p_input, "signal-quality", VLC_VAR_SETVALUE, &val, NULL );
137 val.f_float = f_strength;
138 var_Change( p_input, "signal-strength", VLC_VAR_SETVALUE, &val, NULL );
140 Trigger( p_input, INPUT_EVENT_SIGNAL );
143 void input_SendEventState( input_thread_t *p_input, int i_state )
148 var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
150 Trigger( p_input, INPUT_EVENT_STATE );
153 void input_SendEventCache( input_thread_t *p_input, double f_level )
157 val.f_float = f_level;
158 var_Change( p_input, "cache", VLC_VAR_SETVALUE, &val, NULL );
160 Trigger( p_input, INPUT_EVENT_CACHE );
163 /* FIXME: review them because vlc_event_send might be
164 * moved inside input_item* functions.
166 void input_SendEventMeta( input_thread_t *p_input )
168 Trigger( p_input, INPUT_EVENT_ITEM_META );
170 /* FIXME remove this ugliness ? */
173 event.type = vlc_InputItemMetaChanged;
174 event.u.input_item_meta_changed.meta_type = vlc_meta_ArtworkURL;
175 vlc_event_send( &p_input->p->p_item->event_manager, &event );
178 void input_SendEventMetaInfo( input_thread_t *p_input )
180 Trigger( p_input, INPUT_EVENT_ITEM_INFO );
182 /* FIXME remove this ugliness */
185 event.type = vlc_InputItemInfoChanged;
186 vlc_event_send( &p_input->p->p_item->event_manager, &event );
189 void input_SendEventMetaName( input_thread_t *p_input, const char *psz_name )
191 Trigger( p_input, INPUT_EVENT_ITEM_NAME );
193 /* FIXME remove this ugliness */
196 event.type = vlc_InputItemNameChanged;
197 event.u.input_item_name_changed.new_name = psz_name;
198 vlc_event_send( &p_input->p->p_item->event_manager, &event );
201 /*****************************************************************************
203 *****************************************************************************/
204 void input_SendEventProgramAdd( input_thread_t *p_input,
205 int i_program, const char *psz_text )
210 val.i_int = i_program;
211 text.psz_string = (char*)psz_text;
213 var_Change( p_input, "program", VLC_VAR_ADDCHOICE,
214 &val, psz_text ? &text : NULL );
216 Trigger( p_input, INPUT_EVENT_PROGRAM );
218 void input_SendEventProgramDel( input_thread_t *p_input, int i_program )
222 val.i_int = i_program;
223 var_Change( p_input, "program", VLC_VAR_DELCHOICE, &val, NULL );
225 Trigger( p_input, INPUT_EVENT_PROGRAM );
227 void input_SendEventProgramSelect( input_thread_t *p_input, int i_program )
231 val.i_int = i_program;
232 var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL );
234 Trigger( p_input, INPUT_EVENT_PROGRAM );
237 static const char *GetEsVarName( int i_cat )
246 assert( i_cat == SPU_ES );
250 void input_SendEventEsDel( input_thread_t *p_input, int i_cat, int i_id )
254 if( i_cat == UNKNOWN_ES )
260 var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_DELCHOICE, &val, NULL );
264 var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_CLEARCHOICES, NULL, NULL );
267 Trigger( p_input, INPUT_EVENT_ES );
269 void input_SendEventEsAdd( input_thread_t *p_input, int i_cat, int i_id, const char *psz_text )
274 if( i_cat == UNKNOWN_ES )
278 text.psz_string = (char*)psz_text;
280 var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_ADDCHOICE,
281 &val, psz_text ? &text : NULL );
283 Trigger( p_input, INPUT_EVENT_ES );
286 /* i_id == -1 will unselect */
287 void input_SendEventEsSelect( input_thread_t *p_input, int i_cat, int i_id )
291 if( i_cat == UNKNOWN_ES )
295 var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_SETVALUE, &val, NULL );
297 Trigger( p_input, INPUT_EVENT_ES );
300 void input_SendEventTeletext( input_thread_t *p_input, int i_id )
305 var_Change( p_input, "teletext-es", VLC_VAR_SETVALUE, &val, NULL );
307 Trigger( p_input, INPUT_EVENT_TELETEXT );
310 void input_SendEventVout( input_thread_t *p_input )
312 Trigger( p_input, INPUT_EVENT_VOUT );
315 /*****************************************************************************
316 * Event for control.c/input.c
317 *****************************************************************************/
318 void input_SendEventBookmark( input_thread_t *p_input )
320 Trigger( p_input, INPUT_EVENT_BOOKMARK );
323 /*****************************************************************************
325 *****************************************************************************/
326 static void Trigger( input_thread_t *p_input, int i_type )
328 var_SetInteger( p_input, "intf-event", i_type );