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"
42 PositionUpdate_Type
= QEvent::User
+ IMEventType
+ 1,
44 ItemStateChanged_Type
,
45 ItemTitleChanged_Type
,
48 SoundMuteChanged_Type
,
50 ItemTeletextChanged_Type
,
51 InterfaceVoutUpdate_Type
,
52 StatisticsUpdate_Type
, /*10*/
53 InterfaceAoutUpdate_Type
,
59 BookmarksChanged_Type
,
67 /* SignalChanged_Type, */
69 FullscreenControlToggle_Type
= QEvent::User
+ IMEventType
+ 20,
70 FullscreenControlShow_Type
,
71 FullscreenControlHide_Type
,
72 FullscreenControlPlanHide_Type
,
75 enum { NORMAL
, /* loop: 0, repeat: 0 */
76 REPEAT_ONE
,/* loop: 1, repeat: 0 */
77 REPEAT_ALL
,/* loop: 0, repeat: 1 */
80 class IMEvent
: public QEvent
82 friend class InputManager
;
83 friend class MainInputManager
;
85 IMEvent( int type
, input_item_t
*p_input
= NULL
)
86 : QEvent( (QEvent::Type
)(type
) )
88 if( (p_item
= p_input
) != NULL
)
89 vlc_gc_incref( p_item
);
94 vlc_gc_decref( p_item
);
103 PLItemAppended_Type
= QEvent::User
+ PLEventType
+ 1,
107 class PLEvent
: public QEvent
110 PLEvent( int t
, int i
, int p
= 0 )
111 : QEvent( (QEvent::Type
)(t
) ), i_item(i
), i_parent(p
) {}
113 /* Needed for "playlist-item*" and "leaf-to-parent" callbacks
114 * !! Can be a input_item_t->i_id or a playlist_item_t->i_id */
116 // Needed for "playlist-item-append" callback, notably
120 class InputManager
: public QObject
123 friend class MainInputManager
;
126 InputManager( QObject
*, intf_thread_t
* );
127 virtual ~InputManager();
132 return p_input
/* We have an input */
133 && !p_input
->b_dead
/* not dead yet, */
134 && !p_input
->b_eof
/* not EOF either, */
135 && vlc_object_alive (p_input
); /* and the VLC object is alive */
140 bool hasVideo() { return hasInput() && b_video
; }
141 bool hasVisualisation();
142 void requestArtUpdate();
144 QString
getName() { return oldName
; }
145 static const QString
decodeArtURL( input_item_t
*p_item
);
148 intf_thread_t
*p_intf
;
149 input_thread_t
*p_input
;
150 vlc_object_t
*p_input_vbi
;
151 input_item_t
*p_item
;
152 int i_old_playing_status
;
158 mtime_t timeA
, timeB
;
160 void customEvent( QEvent
* );
168 void UpdateNavigation();
169 void UpdatePosition();
170 void UpdateTeletext();
174 void UpdateMeta(input_item_t
*);
178 void UpdateCaching();
180 void UpdateProgramEvent();
184 void setInput( input_thread_t
* ); ///< Our controlled input changed
185 void sliderUpdate( float ); ///< User dragged the slider. We get new pos
186 /* SpeedRate Rate Management */
202 void telexSetPage( int ); ///< Goto teletext page
203 void telexSetTransparency( bool ); ///< Transparency on teletext background
204 void activateTeletext( bool ); ///< Toggle buttons after click
209 void togglePlayPause();
210 void AtoBLoop( float, int64_t, int );
213 /// Send new position, new time and new length
214 void positionUpdated( float , int64_t, int );
215 void seekRequested( float pos
);
216 void rateChanged( float );
217 void nameChanged( const QString
& );
218 /// Used to signal whether we should show navigation buttons
219 void titleChanged( bool );
220 void chapterChanged( bool );
221 /// Statistics are updated
222 void statisticsUpdated( input_item_t
* );
223 void infoChanged( input_item_t
* );
224 void currentMetaChanged( input_item_t
* );
225 void metaChanged( input_item_t
*);
226 void artChanged( QString
);
227 /// Play/pause status
228 void playingStatusChanged( int );
229 void recordingStateChanged( bool );
231 void teletextPossible( bool );
232 void teletextActivated( bool );
233 void teletextTransparencyActivated( bool );
234 void newTelexPageSet( int );
236 void AtoBchanged( bool, bool );
238 void voutChanged( bool );
239 void voutListChanged( vout_thread_t
**pp_vout
, int i_vout
);
241 void synchroChanged();
242 void bookmarksChanged();
243 void cachingChanged( float );
244 /// Program Event changes
245 void encryptionChanged( bool );
249 class MainInputManager
: public QObject
, public Singleton
<MainInputManager
>
252 friend class Singleton
<MainInputManager
>;
254 input_thread_t
*getInput() { return p_input
; }
255 InputManager
*getIM() { return im
; }
256 inline input_item_t
*currentInputItem()
258 return ( p_input
? input_GetItem( p_input
) : NULL
);
261 vout_thread_t
* getVout();
262 audio_output_t
*getAout();
264 bool getPlayExitState();
266 MainInputManager( intf_thread_t
* );
267 virtual ~MainInputManager();
269 void customEvent( QEvent
* );
272 input_thread_t
*p_input
;
273 intf_thread_t
*p_intf
;
275 void notifyRepeatLoop();
277 void togglePlayPause();
285 void activatePlayQuit( bool );
287 void loopRepeatLoopStatus();
290 void inputChanged( input_thread_t
* );
291 void volumeChanged();
292 void soundMuteChanged();
293 void playlistItemAppended( int itemId
, int parentId
);
294 void playlistItemRemoved( int itemId
);
295 void randomChanged( bool );
296 void repeatLoopChanged( int );
297 void leafBecameParent( int );