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 rateChanged( int );
207 void nameChanged( const QString& );
208 /// Used to signal whether we should show navigation buttons
209 void titleChanged( bool );
210 void chapterChanged( bool );
211 /// Statistics are updated
212 void statisticsUpdated( input_item_t* );
213 void infoChanged( input_item_t* );
214 void currentMetaChanged( input_item_t* );
215 void metaChanged( input_item_t *);
216 void artChanged( QString );
217 /// Play/pause status
218 void statusChanged( int );
219 void recordingStateChanged( bool );
221 void teletextPossible( bool );
222 void teletextActivated( bool );
223 void teletextTransparencyActivated( bool );
224 void newTelexPageSet( int );
226 void AtoBchanged( bool, bool );
228 void voutChanged( bool );
229 void voutListChanged( vout_thread_t **pp_vout, int i_vout );
231 void synchroChanged();
232 void bookmarksChanged();
233 void cachingChanged( float );
234 /// Program Event changes
235 void encryptionChanged( bool );
238 class MainInputManager : public QObject
242 static MainInputManager *getInstance( intf_thread_t *_p_intf )
245 instance = new MainInputManager( _p_intf );
248 static void killInstance()
254 input_thread_t *getInput() { return p_input; }
255 InputManager *getIM() { return im; }
257 vout_thread_t* getVout();
258 aout_instance_t *getAout();
261 MainInputManager( intf_thread_t * );
262 virtual ~MainInputManager();
264 static MainInputManager *instance;
266 void customEvent( QEvent * );
269 input_thread_t *p_input;
270 intf_thread_t *p_intf;
272 void notifyRepeatLoop();
274 void togglePlayPause();
281 void activatePlayQuit( bool );
283 void loopRepeatLoopStatus();
286 void inputChanged( input_thread_t * );
287 void volumeChanged();
288 void soundMuteChanged();
289 void playlistItemAppended( int itemId, int parentId );
290 void playlistItemRemoved( int itemId );
291 void randomChanged( bool );
292 void repeatLoopChanged( int );
293 void leafBecameParent( input_item_t * );