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,
66 /* SignalChanged_Type, */
68 FullscreenControlToggle_Type = QEvent::User + IMEventType + 20,
69 FullscreenControlShow_Type,
70 FullscreenControlHide_Type,
71 FullscreenControlPlanHide_Type,
74 enum { NORMAL, /* loop: 0, repeat: 0 */
75 REPEAT_ONE,/* loop: 1, repeat: 0 */
76 REPEAT_ALL,/* loop: 0, repeat: 1 */
79 class IMEvent : public QEvent
81 friend class InputManager;
82 friend class MainInputManager;
84 IMEvent( int type, input_item_t *p_input = NULL )
85 : QEvent( (QEvent::Type)(type) )
87 if( (p_item = p_input) != NULL )
88 vlc_gc_incref( p_item );
93 vlc_gc_decref( p_item );
102 PLItemAppended_Type = QEvent::User + PLEventType + 1,
106 class PLEvent : public QEvent
109 PLEvent( PLEventTypes t, int i, int p )
110 : QEvent( (QEvent::Type)t ), i_item(i), i_parent(p) {}
115 class InputManager : public QObject
118 friend class MainInputManager;
121 InputManager( QObject *, intf_thread_t * );
122 virtual ~InputManager();
127 return p_input /* We have an input */
128 && !p_input->b_dead /* not dead yet, */
129 && !p_input->b_eof /* not EOF either, */
130 && vlc_object_alive (p_input); /* and the VLC object is alive */
135 bool hasVideo() { return hasInput() && b_video; }
136 void requestArtUpdate();
138 QString getName() { return oldName; }
139 static const QString decodeArtURL( input_item_t *p_item );
142 intf_thread_t *p_intf;
143 input_thread_t *p_input;
144 vlc_object_t *p_input_vbi;
145 input_item_t *p_item;
146 int i_old_playing_status;
152 mtime_t timeA, timeB;
154 void customEvent( QEvent * );
162 void UpdateNavigation();
163 void UpdatePosition();
164 void UpdateTeletext();
168 void UpdateMeta(input_item_t *);
172 void UpdateCaching();
174 void UpdateProgramEvent();
178 void setInput( input_thread_t * ); ///< Our controlled input changed
179 void sliderUpdate( float ); ///< User dragged the slider. We get new pos
180 /* SpeedRate Rate Management */
196 void telexSetPage( int ); ///< Goto teletext page
197 void telexSetTransparency( bool ); ///< Transparency on teletext background
198 void activateTeletext( bool ); ///< Toggle buttons after click
203 void togglePlayPause();
204 void AtoBLoop( float, int64_t, int );
207 /// Send new position, new time and new length
208 void positionUpdated( float , int64_t, int );
209 void seekRequested( float pos );
210 void rateChanged( float );
211 void nameChanged( const QString& );
212 /// Used to signal whether we should show navigation buttons
213 void titleChanged( bool );
214 void chapterChanged( bool );
215 /// Statistics are updated
216 void statisticsUpdated( input_item_t* );
217 void infoChanged( input_item_t* );
218 void currentMetaChanged( input_item_t* );
219 void metaChanged( input_item_t *);
220 void artChanged( QString );
221 /// Play/pause status
222 void playingStatusChanged( int );
223 void recordingStateChanged( bool );
225 void teletextPossible( bool );
226 void teletextActivated( bool );
227 void teletextTransparencyActivated( bool );
228 void newTelexPageSet( int );
230 void AtoBchanged( bool, bool );
232 void voutChanged( bool );
233 void voutListChanged( vout_thread_t **pp_vout, int i_vout );
235 void synchroChanged();
236 void bookmarksChanged();
237 void cachingChanged( float );
238 /// Program Event changes
239 void encryptionChanged( bool );
243 class MainInputManager : public QObject
247 static MainInputManager *getInstance( intf_thread_t *_p_intf )
250 instance = new MainInputManager( _p_intf );
253 static void killInstance()
259 input_thread_t *getInput() { return p_input; }
260 InputManager *getIM() { return im; }
261 inline input_item_t *currentInputItem()
263 return ( p_input ? input_GetItem( p_input ) : NULL );
266 vout_thread_t* getVout();
267 aout_instance_t *getAout();
269 bool getPlayExitState();
271 MainInputManager( intf_thread_t * );
272 virtual ~MainInputManager();
274 static MainInputManager *instance;
276 void customEvent( QEvent * );
279 input_thread_t *p_input;
280 intf_thread_t *p_intf;
282 void notifyRepeatLoop();
284 void togglePlayPause();
291 void activatePlayQuit( bool );
293 void loopRepeatLoopStatus();
296 void inputChanged( input_thread_t * );
297 void volumeChanged();
298 void soundMuteChanged();
299 void playlistItemAppended( int itemId, int parentId );
300 void playlistItemRemoved( int itemId );
301 void randomChanged( bool );
302 void repeatLoopChanged( int );
303 void leafBecameParent( input_item_t * );