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 "util/uniqueevent.hpp"
37 #include "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 UniqueEvent
51 PositionUpdate = QEvent::User + IMEventTypeOffset + 1,
59 StatisticsUpdate, /*10*/
74 FullscreenControlToggle = QEvent::User + IMEventTypeOffset + 20,
75 FullscreenControlShow,
76 FullscreenControlHide,
77 FullscreenControlPlanHide,
79 IMEvent( event_types type, input_item_t *p_input = NULL )
80 : UniqueEvent( (QEvent::Type)(type) )
82 if( (p_item = p_input) != NULL )
83 vlc_gc_incref( p_item );
88 vlc_gc_decref( p_item );
90 input_item_t *item() const { return p_item; };
91 virtual bool equals(UniqueEvent *e) const
93 IMEvent *ev = static_cast<IMEvent *>(e);
94 return ( ev->item() == p_item && ev->type() == type() );
100 class PLEvent : public QEvent
105 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; };
115 /* Needed for "playlist-item*" and "leaf-to-parent" callbacks
116 * !! Can be a input_item_t->i_id or a playlist_item_t->i_id */
118 // Needed for "playlist-item-append" callback, notably
122 class InputManager : public QObject
125 friend class MainInputManager;
128 InputManager( QObject *, intf_thread_t * );
129 virtual ~InputManager();
134 return p_input /* We have an input */
135 && !p_input->b_dead /* not dead yet, */
136 && !p_input->b_eof /* not EOF either, */
137 && vlc_object_alive (p_input); /* and the VLC object is alive */
142 bool hasVideo() { return hasInput() && b_video; }
143 bool hasVisualisation();
144 void requestArtUpdate( input_item_t *p_item );
146 QString getName() { return oldName; }
147 static const QString decodeArtURL( input_item_t *p_item );
148 void postUniqueEvent( QObject *, UniqueEvent * );
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 * );
164 RateLimitedEventPoster *rateLimitedEventPoster;
172 void UpdateNavigation();
173 void UpdatePosition();
174 void UpdateTeletext();
178 void UpdateMeta(input_item_t *);
182 void UpdateCaching();
184 void UpdateProgramEvent();
188 void setInput( input_thread_t * ); ///< Our controlled input changed
189 void sliderUpdate( float ); ///< User dragged the slider. We get new pos
190 /* SpeedRate Rate Management */
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, int64_t, int );
216 /// Send new position, new time and new length
217 void positionUpdated( float , int64_t, int );
218 void seekRequested( float pos );
219 void rateChanged( float );
220 void nameChanged( const QString& );
221 /// Used to signal whether we should show navigation buttons
222 void titleChanged( bool );
223 void chapterChanged( bool );
224 void inputCanSeek( bool );
225 /// Statistics are updated
226 void statisticsUpdated( input_item_t* );
227 void infoChanged( input_item_t* );
228 void currentMetaChanged( input_item_t* );
229 void metaChanged( input_item_t *);
230 void artChanged( QString ); /* current item art ( same as item == NULL ) */
231 void artChanged( input_item_t * );
232 /// Play/pause status
233 void playingStatusChanged( int );
234 void recordingStateChanged( bool );
236 void teletextPossible( bool );
237 void teletextActivated( bool );
238 void teletextTransparencyActivated( bool );
239 void newTelexPageSet( int );
241 void AtoBchanged( bool, bool );
243 void voutChanged( bool );
244 void voutListChanged( vout_thread_t **pp_vout, int i_vout );
246 void synchroChanged();
247 void bookmarksChanged();
248 void cachingChanged( float );
249 /// Program Event changes
250 void encryptionChanged( bool );
254 class MainInputManager : public QObject, public Singleton<MainInputManager>
257 friend class Singleton<MainInputManager>;
259 input_thread_t *getInput() { return p_input; }
260 InputManager *getIM() { return im; }
261 inline input_item_t *currentInputItem()
263 return ( p_input ? input_GetItem( p_input ) : NULL );
266 vout_thread_t* getVout();
267 audio_output_t *getAout();
269 bool getPlayExitState();
270 bool hasEmptyPlaylist();
272 void requestVoutUpdate() { return im->UpdateVout(); }
274 MainInputManager( intf_thread_t * );
275 virtual ~MainInputManager();
277 void customEvent( QEvent * );
280 input_thread_t *p_input;
281 intf_thread_t *p_intf;
282 QVLCBool random, repeat, loop;
287 void togglePlayPause();
295 void activatePlayQuit( bool );
297 void loopRepeatLoopStatus();
299 void notifyRandom( bool );
300 void notifyRepeatLoop( bool );
301 void notifyVolume( float );
302 void notifyMute( bool );
304 void inputChanged( input_thread_t * );
305 void volumeChanged( float );
306 void soundMuteChanged( bool );
307 void playlistItemAppended( int itemId, int parentId );
308 void playlistItemRemoved( int itemId );
309 void playlistNotEmpty( bool );
310 void randomChanged( bool );
311 void repeatLoopChanged( int );
312 void leafBecameParent( int );