1 /*****************************************************************************
2 * input_manager.hpp : Manage an input and interact with its GUI elements
3 ****************************************************************************
4 * Copyright (C) 2006-2008 the VideoLAN team
6 * Authors: Clément Stenac <zorglub@videolan.org>
7 * Jean-Baptiste <jb@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifndef QVLC_INPUT_MANAGER_H_
25 #define QVLC_INPUT_MANAGER_H_
31 #include <vlc_input.h>
34 #include "util/singleton.hpp"
35 #include "adapters/variables.hpp"
41 enum { NORMAL
, /* loop: 0, repeat: 0 */
42 REPEAT_ONE
,/* loop: 0, repeat: 1 */
43 REPEAT_ALL
,/* loop: 1, repeat: 0 */
46 class IMEvent
: public QEvent
50 PositionUpdate
= QEvent::User
+ IMEventTypeOffset
+ 1,
69 CapabilitiesChanged
, /* 20 */
72 FullscreenControlToggle
= QEvent::User
+ IMEventTypeOffset
+ 50,
73 FullscreenControlShow
,
74 FullscreenControlHide
,
75 FullscreenControlPlanHide
,
78 IMEvent( event_types type
, input_item_t
*p_input
= NULL
)
79 : QEvent( (QEvent::Type
)(type
) )
81 if( (p_item
= p_input
) != NULL
)
82 input_item_Hold( p_item
);
88 input_item_Release( p_item
);
91 input_item_t
*item() const { return p_item
; };
97 class PLEvent
: public QEvent
102 PLItemAppended
= QEvent::User
+ PLEventTypeOffset
+ 1,
108 PLEvent( PLEventTypes t
, int i
, int p
= 0 )
109 : QEvent( (QEvent::Type
)(t
) ), i_item(i
), i_parent(p
) {}
110 int getItemId() const { return i_item
; };
111 int getParentId() const { return i_parent
; };
114 /* Needed for "playlist-item*" and "leaf-to-parent" callbacks
115 * !! Can be a input_item_t->i_id or a playlist_item_t->i_id */
117 // Needed for "playlist-item-append" callback, notably
121 class MainInputManager
;
123 class InputManager
: public QObject
126 friend class MainInputManager
;
129 InputManager( MainInputManager
*, intf_thread_t
* );
130 virtual ~InputManager();
133 bool hasInput() const { return p_input
!= NULL
; }
135 int playingStatus() const;
137 bool hasVideo() { return hasInput() && b_video
; }
138 bool hasVisualisation();
139 void requestArtUpdate( input_item_t
*p_item
, bool b_forced
);
140 void setArt( input_item_t
*p_item
, QString fileUrl
);
142 QString
getName() { return oldName
; }
143 static const QString
decodeArtURL( input_item_t
*p_item
);
146 intf_thread_t
*p_intf
;
147 MainInputManager
* p_mim
;
148 input_thread_t
*p_input
;
149 vlc_object_t
*p_input_vbi
;
150 input_item_t
*p_item
;
151 int i_old_playing_status
;
158 vlc_tick_t timeA
, timeB
;
160 void customEvent( QEvent
* );
168 void UpdateNavigation();
169 void UpdateCapabilities();
170 void UpdatePosition();
171 void UpdateTeletext();
175 void UpdateMeta(input_item_t
*);
178 void UpdateCaching();
180 void UpdateProgramEvent();
183 void setInput( input_thread_t
* );
186 void inputChangedHandler(); ///< Our controlled input changed
187 void sliderUpdate( float ); ///< User dragged the slider. We get new pos
188 /* SpeedRate Rate Management */
195 void setRate( float );
204 void changeProgram( int );
206 void telexSetPage( int ); ///< Goto teletext page
207 void telexSetTransparency( bool ); ///< Transparency on teletext background
208 void activateTeletext( bool ); ///< Toggle buttons after click
213 void AtoBLoop( float, vlc_tick_t
, int );
216 /// Send new position, new time and new length
217 void positionUpdated( float , vlc_tick_t
, int );
218 void remainingTimeChanged( bool );
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 resume playback
227 void resumePlayback( vlc_tick_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 QVector
<vout_thread_t
*> getVouts() const;
273 audio_output_t
*getAout();
275 bool getPlayExitState();
276 bool hasEmptyPlaylist();
278 void requestVoutUpdate() { return im
->UpdateVout(); }
279 // Probe for initial input. Doing this from the constructor would cause
280 // the getInstance to call itself recursively from the inputChangedHandler
281 void probeCurrentInput();
284 QSignalMapper
*menusAudioMapper
;
287 MainInputManager( intf_thread_t
* );
288 virtual ~MainInputManager();
290 void customEvent( QEvent
* );
293 input_thread_t
*p_input
;
294 intf_thread_t
*p_intf
;
295 QVLCBool random
, repeat
, loop
;
300 static int ItemChanged( vlc_object_t
*, const char *,
301 vlc_value_t
, vlc_value_t
, void * );
302 static int LeafToParent( vlc_object_t
*, const char *,
303 vlc_value_t
, vlc_value_t
, void * );
304 static int PLItemChanged( vlc_object_t
*, const char *,
305 vlc_value_t
, vlc_value_t
, void * );
306 static int PLItemAppended( vlc_object_t
*, const char *,
307 vlc_value_t
, vlc_value_t
, void * );
308 static int PLItemRemoved( vlc_object_t
*, const char *,
309 vlc_value_t
, vlc_value_t
, void * );
312 void togglePlayPause();
320 void activatePlayQuit( bool );
322 void loopRepeatLoopStatus();
323 void changeFullscreen( bool );
326 void notifyRandom( bool );
327 void notifyRepeatLoop( bool );
328 void notifyVolume( float );
329 void notifyMute( bool );
330 void menusUpdateAudio( const QString
& );
333 void inputChanged( bool );
334 void volumeChanged( float );
335 void soundMuteChanged( bool );
336 void playlistItemAppended( int itemId
, int parentId
);
337 void playlistItemRemoved( int itemId
);
338 void playlistNotEmpty( bool );
339 void randomChanged( bool );
340 void repeatLoopChanged( int );
341 void leafBecameParent( int );