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 "adapters/variables.hpp"
42 enum { NORMAL, /* loop: 0, repeat: 0 */
43 REPEAT_ONE,/* loop: 0, repeat: 1 */
44 REPEAT_ALL,/* loop: 1, repeat: 0 */
47 class IMEvent : public QEvent
51 PositionUpdate = QEvent::User + IMEventTypeOffset + 1,
59 StatisticsUpdate, /*10*/
74 FullscreenControlToggle = QEvent::User + IMEventTypeOffset + 20,
75 FullscreenControlShow,
76 FullscreenControlHide,
77 FullscreenControlPlanHide,
80 IMEvent( event_types type, input_item_t *p_input = NULL )
81 : QEvent( (QEvent::Type)(type) )
83 if( (p_item = p_input) != NULL )
84 vlc_gc_incref( p_item );
90 vlc_gc_decref( p_item );
93 input_item_t *item() const { return p_item; };
99 class PLEvent : public QEvent
104 PLItemAppended = QEvent::User + PLEventTypeOffset + 1,
110 PLEvent( PLEventTypes t, int i, int p = 0 )
111 : QEvent( (QEvent::Type)(t) ), i_item(i), i_parent(p) {}
112 int getItemId() const { return i_item; };
113 int getParentId() const { return i_parent; };
116 /* Needed for "playlist-item*" and "leaf-to-parent" callbacks
117 * !! Can be a input_item_t->i_id or a playlist_item_t->i_id */
119 // Needed for "playlist-item-append" callback, notably
123 class InputManager : public QObject
126 friend class MainInputManager;
129 InputManager( QObject *, intf_thread_t * );
130 virtual ~InputManager();
135 return p_input /* We have an input */
136 && !p_input->b_dead /* not dead yet, */
137 && !p_input->b_eof /* not EOF either */;
142 bool hasVideo() { return hasInput() && b_video; }
143 bool hasVisualisation();
144 void requestArtUpdate( input_item_t *p_item, bool b_forced );
145 void setArt( input_item_t *p_item, QString fileUrl );
147 QString getName() { return oldName; }
148 static const QString decodeArtURL( input_item_t *p_item );
151 intf_thread_t *p_intf;
152 input_thread_t *p_input;
153 vlc_object_t *p_input_vbi;
154 input_item_t *p_item;
155 int i_old_playing_status;
161 mtime_t timeA, timeB;
163 void customEvent( QEvent * );
171 void UpdateNavigation();
172 void UpdatePosition();
173 void UpdateTeletext();
177 void UpdateMeta(input_item_t *);
181 void UpdateCaching();
183 void UpdateProgramEvent();
186 void setInput( input_thread_t * );
189 void inputChangedHandler(); ///< Our controlled input changed
190 void sliderUpdate( float ); ///< User dragged the slider. We get new pos
191 /* SpeedRate Rate Management */
207 void telexSetPage( int ); ///< Goto teletext page
208 void telexSetTransparency( bool ); ///< Transparency on teletext background
209 void activateTeletext( bool ); ///< Toggle buttons after click
214 void AtoBLoop( float, int64_t, int );
217 /// Send new position, new time and new length
218 void positionUpdated( float , int64_t, int );
219 void seekRequested( float pos );
220 void rateChanged( float );
221 void nameChanged( const QString& );
222 /// Used to signal whether we should show navigation buttons
223 void titleChanged( bool );
224 void chapterChanged( bool );
225 void inputCanSeek( bool );
226 /// You can continuePlayback
227 void continuePlayback( int64_t );
228 /// Statistics are updated
229 void statisticsUpdated( input_item_t* );
230 void infoChanged( input_item_t* );
231 void currentMetaChanged( input_item_t* );
232 void metaChanged( input_item_t *);
233 void artChanged( QString ); /* current item art ( same as item == NULL ) */
234 void artChanged( input_item_t * );
235 /// Play/pause status
236 void playingStatusChanged( int );
237 void recordingStateChanged( bool );
239 void teletextPossible( bool );
240 void teletextActivated( bool );
241 void teletextTransparencyActivated( bool );
242 void newTelexPageSet( int );
244 void AtoBchanged( bool, bool );
246 void voutChanged( bool );
247 void voutListChanged( vout_thread_t **pp_vout, int i_vout );
249 void synchroChanged();
250 void bookmarksChanged();
251 void cachingChanged( float );
252 /// Program Event changes
253 void encryptionChanged( bool );
257 class MainInputManager : public QObject, public Singleton<MainInputManager>
260 friend class Singleton<MainInputManager>;
261 friend class VLCMenuBar;
264 input_thread_t *getInput() { return p_input; }
265 InputManager *getIM() { return im; }
266 inline input_item_t *currentInputItem()
268 return ( p_input ? input_GetItem( p_input ) : NULL );
271 vout_thread_t* getVout();
272 audio_output_t *getAout();
274 bool getPlayExitState();
275 bool hasEmptyPlaylist();
277 void requestVoutUpdate() { return im->UpdateVout(); }
280 QSignalMapper *menusAudioMapper;
283 MainInputManager( intf_thread_t * );
284 virtual ~MainInputManager();
286 void customEvent( QEvent * );
289 input_thread_t *p_input;
290 intf_thread_t *p_intf;
291 QVLCBool random, repeat, loop;
296 void togglePlayPause();
304 void activatePlayQuit( bool );
306 void loopRepeatLoopStatus();
309 void notifyRandom( bool );
310 void notifyRepeatLoop( bool );
311 void notifyVolume( float );
312 void notifyMute( bool );
313 void menusUpdateAudio( const QString& );
316 void inputChanged( );
317 void volumeChanged( float );
318 void soundMuteChanged( bool );
319 void playlistItemAppended( int itemId, int parentId );
320 void playlistItemRemoved( int itemId );
321 void playlistNotEmpty( bool );
322 void randomChanged( bool );
323 void repeatLoopChanged( int );
324 void leafBecameParent( int );