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>
35 #include "util/singleton.hpp"
36 #include "variables.hpp"
42 PositionUpdate_Type = QEvent::User + IMEventType + 1,
44 ItemStateChanged_Type,
45 ItemTitleChanged_Type,
48 ItemTeletextChanged_Type,
49 InterfaceVoutUpdate_Type,
50 StatisticsUpdate_Type, /*10*/
51 InterfaceAoutUpdate_Type,
57 BookmarksChanged_Type,
61 LoopOrRepeatChanged_Type,
64 /* SignalChanged_Type, */
66 FullscreenControlToggle_Type = QEvent::User + IMEventType + 20,
67 FullscreenControlShow_Type,
68 FullscreenControlHide_Type,
69 FullscreenControlPlanHide_Type,
72 enum { NORMAL, /* loop: 0, repeat: 0 */
73 REPEAT_ONE,/* loop: 0, repeat: 1 */
74 REPEAT_ALL,/* loop: 1, repeat: 0 */
77 class IMEvent : public QEvent
79 friend class InputManager;
80 friend class MainInputManager;
82 IMEvent( int type, input_item_t *p_input = NULL )
83 : QEvent( (QEvent::Type)(type) )
85 if( (p_item = p_input) != NULL )
86 vlc_gc_incref( p_item );
91 vlc_gc_decref( p_item );
100 PLItemAppended_Type = QEvent::User + PLEventType + 1,
105 class PLEvent : public QEvent
108 PLEvent( int t, int i, int p = 0 )
109 : QEvent( (QEvent::Type)(t) ), i_item(i), i_parent(p) {}
111 /* Needed for "playlist-item*" and "leaf-to-parent" callbacks
112 * !! Can be a input_item_t->i_id or a playlist_item_t->i_id */
114 // Needed for "playlist-item-append" callback, notably
118 class InputManager : public QObject
121 friend class MainInputManager;
124 InputManager( QObject *, intf_thread_t * );
125 virtual ~InputManager();
130 return p_input /* We have an input */
131 && !p_input->b_dead /* not dead yet, */
132 && !p_input->b_eof /* not EOF either, */
133 && vlc_object_alive (p_input); /* and the VLC object is alive */
138 bool hasVideo() { return hasInput() && b_video; }
139 bool hasVisualisation();
140 void requestArtUpdate( input_item_t *p_item );
142 QString getName() { return oldName; }
143 static const QString decodeArtURL( input_item_t *p_item );
146 intf_thread_t *p_intf;
147 input_thread_t *p_input;
148 vlc_object_t *p_input_vbi;
149 input_item_t *p_item;
150 int i_old_playing_status;
156 mtime_t timeA, timeB;
158 void customEvent( QEvent * );
166 void UpdateNavigation();
167 void UpdatePosition();
168 void UpdateTeletext();
172 void UpdateMeta(input_item_t *);
176 void UpdateCaching();
178 void UpdateProgramEvent();
182 void setInput( input_thread_t * ); ///< Our controlled input changed
183 void sliderUpdate( float ); ///< User dragged the slider. We get new pos
184 /* SpeedRate Rate Management */
200 void telexSetPage( int ); ///< Goto teletext page
201 void telexSetTransparency( bool ); ///< Transparency on teletext background
202 void activateTeletext( bool ); ///< Toggle buttons after click
207 void AtoBLoop( float, int64_t, int );
210 /// Send new position, new time and new length
211 void positionUpdated( float , int64_t, int );
212 void seekRequested( float pos );
213 void rateChanged( float );
214 void nameChanged( const QString& );
215 /// Used to signal whether we should show navigation buttons
216 void titleChanged( bool );
217 void chapterChanged( bool );
218 void inputCanSeek( bool );
219 /// Statistics are updated
220 void statisticsUpdated( input_item_t* );
221 void infoChanged( input_item_t* );
222 void currentMetaChanged( input_item_t* );
223 void metaChanged( input_item_t *);
224 void artChanged( QString ); /* current item art ( same as item == NULL ) */
225 void artChanged( input_item_t * );
226 /// Play/pause status
227 void playingStatusChanged( int );
228 void recordingStateChanged( bool );
230 void teletextPossible( bool );
231 void teletextActivated( bool );
232 void teletextTransparencyActivated( bool );
233 void newTelexPageSet( int );
235 void AtoBchanged( bool, bool );
237 void voutChanged( bool );
238 void voutListChanged( vout_thread_t **pp_vout, int i_vout );
240 void synchroChanged();
241 void bookmarksChanged();
242 void cachingChanged( float );
243 /// Program Event changes
244 void encryptionChanged( bool );
248 class MainInputManager : public QObject, public Singleton<MainInputManager>
251 friend class Singleton<MainInputManager>;
253 input_thread_t *getInput() { return p_input; }
254 InputManager *getIM() { return im; }
255 inline input_item_t *currentInputItem()
257 return ( p_input ? input_GetItem( p_input ) : NULL );
260 vout_thread_t* getVout();
261 audio_output_t *getAout();
263 bool getPlayExitState();
264 bool hasEmptyPlaylist();
266 void requestVoutUpdate() { return im->UpdateVout(); }
268 MainInputManager( intf_thread_t * );
269 virtual ~MainInputManager();
271 void customEvent( QEvent * );
274 input_thread_t *p_input;
275 intf_thread_t *p_intf;
276 QVLCBool random, repeat, loop;
281 void togglePlayPause();
289 void activatePlayQuit( bool );
291 void loopRepeatLoopStatus();
293 void notifyRandom( bool );
294 void notifyRepeatLoop( bool );
295 void notifyVolume( qlonglong );
296 void notifyMute( bool );
298 void inputChanged( input_thread_t * );
299 void volumeChanged( float );
300 void soundMuteChanged( bool );
301 void playlistItemAppended( int itemId, int parentId );
302 void playlistItemRemoved( int itemId );
303 void playlistNotEmpty( bool );
304 void randomChanged( bool );
305 void repeatLoopChanged( int );
306 void leafBecameParent( int );