1 /*****************************************************************************
2 * input_manager.hpp : Manage an input and interact with its GUI elements
3 ****************************************************************************
4 * Copyright (C) 2006-2008 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste <jb@videolan.org>
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 #ifndef QVLC_INPUT_MANAGER_H_
26 #define QVLC_INPUT_MANAGER_H_
32 #include <vlc_input.h>
41 PositionUpdate_Type = QEvent::User + IMEventType + 1,
43 ItemStateChanged_Type,
44 ItemTitleChanged_Type,
47 SoundMuteChanged_Type,
49 ItemTeletextChanged_Type,
50 InterfaceVoutUpdate_Type,
51 StatisticsUpdate_Type, /*10*/
52 InterfaceAoutUpdate_Type,
58 BookmarksChanged_Type,
65 /* SignalChanged_Type, */
67 FullscreenControlToggle_Type = QEvent::User + IMEventType + 20,
68 FullscreenControlShow_Type,
69 FullscreenControlHide_Type,
70 FullscreenControlPlanHide_Type,
73 enum { NORMAL, /* loop: 0, repeat: 0 */
74 REPEAT_ONE,/* loop: 1, repeat: 0 */
75 REPEAT_ALL,/* loop: 0, repeat: 1 */
78 class IMEvent : public QEvent
80 friend class InputManager;
81 friend class MainInputManager;
83 IMEvent( int type, input_item_t *p_input = NULL )
84 : QEvent( (QEvent::Type)(type) )
86 if( (p_item = p_input) != NULL )
87 vlc_gc_incref( p_item );
92 vlc_gc_decref( p_item );
101 PLItemAppended_Type = QEvent::User + PLEventType + 1,
105 class PLEvent : public QEvent
108 PLEvent( PLEventTypes t, int i, int p )
109 : QEvent( (QEvent::Type)t ), i_item(i), i_parent(p) {}
114 class InputManager : public QObject
117 friend class MainInputManager;
120 InputManager( QObject *, intf_thread_t * );
121 virtual ~InputManager();
126 return p_input /* We have an input */
127 && !p_input->b_dead /* not dead yet, */
128 && !p_input->b_eof /* not EOF either, */
129 && vlc_object_alive (p_input); /* and the VLC object is alive */
133 bool hasVideo() { return hasInput() && b_video; }
134 void requestArtUpdate();
136 QString getName() { return oldName; }
137 static const QString decodeArtURL( input_item_t *p_item );
140 intf_thread_t *p_intf;
141 input_thread_t *p_input;
142 vlc_object_t *p_input_vbi;
143 input_item_t *p_item;
144 int i_old_playing_status;
150 mtime_t timeA, timeB;
152 void customEvent( QEvent * );
160 void UpdateNavigation();
161 void UpdatePosition();
162 void UpdateTeletext();
166 void UpdateMeta(input_item_t *);
170 void UpdateCaching();
172 void UpdateProgramEvent();
175 void setInput( input_thread_t * ); ///< Our controlled input changed
176 void sliderUpdate( float ); ///< User dragged the slider. We get new pos
177 /* SpeedRate Rate Management */
193 void telexSetPage( int ); ///< Goto teletext page
194 void telexSetTransparency( bool ); ///< Transparency on teletext background
195 void activateTeletext( bool ); ///< Toggle buttons after click
200 void togglePlayPause();
201 void AtoBLoop( float, int64_t, int );
204 /// Send new position, new time and new length
205 void positionUpdated( float , int64_t, int );
206 void seekRequested( float pos );
207 void rateChanged( float );
208 void nameChanged( const QString& );
209 /// Used to signal whether we should show navigation buttons
210 void titleChanged( bool );
211 void chapterChanged( bool );
212 /// Statistics are updated
213 void statisticsUpdated( input_item_t* );
214 void infoChanged( input_item_t* );
215 void currentMetaChanged( input_item_t* );
216 void metaChanged( input_item_t *);
217 void artChanged( QString );
218 /// Play/pause status
219 void statusChanged( int );
220 void recordingStateChanged( bool );
222 void teletextPossible( bool );
223 void teletextActivated( bool );
224 void teletextTransparencyActivated( bool );
225 void newTelexPageSet( int );
227 void AtoBchanged( bool, bool );
229 void voutChanged( bool );
230 void voutListChanged( vout_thread_t **pp_vout, int i_vout );
232 void synchroChanged();
233 void bookmarksChanged();
234 void cachingChanged( float );
235 /// Program Event changes
236 void encryptionChanged( bool );
239 class MainInputManager : public QObject
243 static MainInputManager *getInstance( intf_thread_t *_p_intf )
246 instance = new MainInputManager( _p_intf );
249 static void killInstance()
255 input_thread_t *getInput() { return p_input; }
256 InputManager *getIM() { return im; }
257 inline input_item_t *currentInputItem()
259 return ( p_input ? input_GetItem( p_input ) : NULL );
262 vout_thread_t* getVout();
263 aout_instance_t *getAout();
266 MainInputManager( intf_thread_t * );
267 virtual ~MainInputManager();
269 static MainInputManager *instance;
271 void customEvent( QEvent * );
274 input_thread_t *p_input;
275 intf_thread_t *p_intf;
277 void notifyRepeatLoop();
279 void togglePlayPause();
286 void activatePlayQuit( bool );
288 void loopRepeatLoopStatus();
291 void inputChanged( input_thread_t * );
292 void volumeChanged();
293 void soundMuteChanged();
294 void playlistItemAppended( int itemId, int parentId );
295 void playlistItemRemoved( int itemId );
296 void randomChanged( bool );
297 void repeatLoopChanged( int );
298 void leafBecameParent( input_item_t * );