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"
36 static void Trigger( input_thread_t *p_input, int i_type );
38 /*****************************************************************************
40 *****************************************************************************/
41 void input_SendEventTimes( input_thread_t *p_input, const input_event_times_t *p_times )
46 val.f_float = p_times->f_position;
47 var_Change( p_input, "position", VLC_VAR_SETVALUE, &val, NULL );
50 val.i_time = p_times->i_time;
51 var_Change( p_input, "time", VLC_VAR_SETVALUE, &val, NULL );
53 /* FIXME ugly + what about meta change event ? */
54 if( var_GetTime( p_input, "length" ) != p_times->i_length )
55 input_item_SetDuration( p_input->p->input.p_item, p_times->i_length );
56 val.i_time = p_times->i_length;
57 var_Change( p_input, "length", VLC_VAR_SETVALUE, &val, NULL );
59 Trigger( p_input, INPUT_EVENT_TIMES );
61 void input_SendEventStatistics( input_thread_t *p_input )
63 Trigger( p_input, INPUT_EVENT_STATISTICS );
65 void input_SendEventRate( input_thread_t *p_input, int i_rate )
70 var_Change( p_input, "rate", VLC_VAR_SETVALUE, &val, NULL );
72 Trigger( p_input, INPUT_EVENT_RATE );
74 void input_SendEventAudioDelay( input_thread_t *p_input, mtime_t i_delay )
79 var_Change( p_input, "audio-delay", VLC_VAR_SETVALUE, &val, NULL );
81 Trigger( p_input, INPUT_EVENT_AUDIO_DELAY );
84 void input_SendEventSubtitleDelay( input_thread_t *p_input, mtime_t i_delay )
89 var_Change( p_input, "spu-delay", VLC_VAR_SETVALUE, &val, NULL );
91 Trigger( p_input, INPUT_EVENT_SUBTITLE_DELAY );
94 /* TODO and file name ? */
95 void input_SendEventRecord( input_thread_t *p_input, bool b_recording )
99 val.b_bool = b_recording;
100 var_Change( p_input, "record", VLC_VAR_SETVALUE, &val, NULL );
102 Trigger( p_input, INPUT_EVENT_RECORD );
105 void input_SendEventTitle( input_thread_t *p_input, int i_title )
110 var_Change( p_input, "title", VLC_VAR_SETVALUE, &val, NULL );
112 input_ControlVarTitle( p_input, i_title );
114 Trigger( p_input, INPUT_EVENT_TITLE );
117 void input_SendEventSeekpoint( input_thread_t *p_input, int i_title, int i_seekpoint )
121 VLC_UNUSED( i_title );
122 val.i_int = i_seekpoint;
123 var_Change( p_input, "chapter", VLC_VAR_SETVALUE, &val, NULL );
125 Trigger( p_input, INPUT_EVENT_CHAPTER );
128 void input_SendEventSignal( input_thread_t *p_input, double f_quality, double f_strength )
132 val.f_float = f_quality;
133 var_Change( p_input, "signal-quality", VLC_VAR_SETVALUE, &val, NULL );
135 val.f_float = f_strength;
136 var_Change( p_input, "signal-strength", VLC_VAR_SETVALUE, &val, NULL );
138 Trigger( p_input, INPUT_EVENT_SIGNAL );
141 void input_SendEventState( input_thread_t *p_input, int i_state )
146 var_Change( p_input, "state", VLC_VAR_SETVALUE, &val, NULL );
148 Trigger( p_input, INPUT_EVENT_STATE );
150 /* FIXME remove this ugliness */
153 event.type = vlc_InputStateChanged;
154 event.u.input_state_changed.new_state = i_state;
155 vlc_event_send( &p_input->p->event_manager, &event );
158 /* FIXME: review them because vlc_event_send might be
159 * moved inside input_item* functions.
161 void input_SendEventMeta( input_thread_t *p_input )
163 Trigger( p_input, INPUT_EVENT_ITEM_META );
165 /* FIXME remove this ugliness ? */
168 event.type = vlc_InputItemMetaChanged;
169 event.u.input_item_meta_changed.meta_type = vlc_meta_ArtworkURL;
170 vlc_event_send( &p_input->p->input.p_item->event_manager, &event );
173 void input_SendEventMetaInfo( input_thread_t *p_input )
175 Trigger( p_input, INPUT_EVENT_ITEM_INFO );
177 /* FIXME remove this ugliness */
180 event.type = vlc_InputItemInfoChanged;
181 vlc_event_send( &p_input->p->input.p_item->event_manager, &event );
184 void input_SendEventMetaName( input_thread_t *p_input, const char *psz_name )
186 Trigger( p_input, INPUT_EVENT_ITEM_NAME );
188 /* FIXME remove this ugliness */
191 event.type = vlc_InputItemNameChanged;
192 event.u.input_item_name_changed.new_name = psz_name;
193 vlc_event_send( &p_input->p->input.p_item->event_manager, &event );
196 /*****************************************************************************
198 *****************************************************************************/
199 void input_SendEventProgramAdd( input_thread_t *p_input,
200 int i_program, const char *psz_text )
205 val.i_int = i_program;
206 text.psz_string = (char*)psz_text;
208 var_Change( p_input, "program", VLC_VAR_ADDCHOICE,
209 &val, psz_text ? &text : NULL );
211 Trigger( p_input, INPUT_EVENT_PROGRAM );
213 void input_SendEventProgramDel( input_thread_t *p_input, int i_program )
217 val.i_int = i_program;
218 var_Change( p_input, "program", VLC_VAR_DELCHOICE, &val, NULL );
220 Trigger( p_input, INPUT_EVENT_PROGRAM );
222 void input_SendEventProgramSelect( input_thread_t *p_input, int i_program )
226 val.i_int = i_program;
227 var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL );
229 Trigger( p_input, INPUT_EVENT_PROGRAM );
232 static const char *GetEsVarName( int i_cat )
241 assert( i_cat == SPU_ES );
245 void input_SendEventEsDel( input_thread_t *p_input, int i_cat, int i_id )
252 var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_DELCHOICE, &val, NULL );
256 var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_CLEARCHOICES, NULL, NULL );
259 Trigger( p_input, INPUT_EVENT_ES );
261 void input_SendEventEsAdd( input_thread_t *p_input, int i_cat, int i_id, const char *psz_text )
267 text.psz_string = (char*)psz_text;
269 var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_ADDCHOICE,
270 &val, psz_text ? &text : NULL );
272 Trigger( p_input, INPUT_EVENT_ES );
275 /* i_id == -1 will unselect */
276 void input_SendEventEsSelect( input_thread_t *p_input, int i_cat, int i_id )
281 var_Change( p_input, GetEsVarName( i_cat ), VLC_VAR_SETVALUE, &val, NULL );
283 Trigger( p_input, INPUT_EVENT_ES );
285 /* FIXME to remove this ugliness */
287 event.type = vlc_InputSelectedStreamChanged;
288 vlc_event_send( &p_input->p->event_manager, &event );
291 void input_SendEventTeletext( input_thread_t *p_input, int i_id )
296 var_Change( p_input, "teletext-es", VLC_VAR_SETVALUE, &val, NULL );
298 Trigger( p_input, INPUT_EVENT_TELETEXT );
301 void input_SendEventVout( input_thread_t *p_input )
303 Trigger( p_input, INPUT_EVENT_VOUT );
306 /*****************************************************************************
308 *****************************************************************************/
309 static void Trigger( input_thread_t *p_input, int i_type )
311 var_SetInteger( p_input, "intf-event", i_type );