]> git.sesse.net Git - vlc/blob - modules/gui/qt4/input_manager.hpp
Merge branch 1.0-bugfix
[vlc] / modules / gui / qt4 / input_manager.hpp
1 /*****************************************************************************
2  * input_manager.hpp : Manage an input and interact with its GUI elements
3  ****************************************************************************
4  * Copyright (C) 2006-2008 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *          Jean-Baptiste <jb@videolan.org>
9  *
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.
14  *
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.
19  *
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  *****************************************************************************/
24
25 #ifndef QVLC_INPUT_MANAGER_H_
26 #define QVLC_INPUT_MANAGER_H_
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <vlc_input.h>
33 #include <vlc_vout.h>
34 #include <vlc_aout.h>
35
36 #include "qt4.hpp"
37
38 #include <QObject>
39 #include <QEvent>
40
41
42 enum {
43     PositionUpdate_Type = QEvent::User + IMEventType + 1,
44     ItemChanged_Type,
45     ItemStateChanged_Type,
46     ItemTitleChanged_Type,
47     ItemRateChanged_Type,
48     VolumeChanged_Type,
49     ItemEsChanged_Type,
50     ItemTeletextChanged_Type,
51     InterfaceVoutUpdate_Type,
52     StatisticsUpdate_Type, /*10*/
53     InterfaceAoutUpdate_Type,
54     MetaChanged_Type,
55     NameChanged_Type,
56     InfoChanged_Type,
57     SynchroChanged_Type,
58     CachingEvent_Type,
59     BookmarksChanged_Type,
60     RecordingEvent_Type,
61     ProgramChanged_Type,
62 /*    SignalChanged_Type, */
63
64     FullscreenControlToggle_Type = QEvent::User + IMEventType + 20,
65     FullscreenControlShow_Type,
66     FullscreenControlHide_Type,
67     FullscreenControlPlanHide_Type,
68 };
69
70 class IMEvent : public QEvent
71 {
72 friend class InputManager;
73     public:
74     IMEvent( int type, input_item_t *p_input = NULL )
75         : QEvent( (QEvent::Type)(type) )
76     {
77         if( (p_item = p_input) != NULL )
78             vlc_gc_incref( p_item );
79     }
80     virtual ~IMEvent()
81     {
82         if( p_item )
83             vlc_gc_decref( p_item );
84     }
85
86 private:
87     input_item_t *p_item;
88 };
89
90 class InputManager : public QObject
91 {
92     Q_OBJECT;
93     friend class MainInputManager;
94
95 public:
96     InputManager( QObject *, intf_thread_t * );
97     virtual ~InputManager();
98
99     void delInput();
100     bool hasInput()
101     {
102         return p_input /* We have an input */
103             && !p_input->b_dead /* not dead yet, */
104             && !p_input->b_eof  /* not EOF either, */
105             && vlc_object_alive (p_input); /* and the VLC object is alive */
106     }
107
108     bool hasAudio();
109     bool hasVideo() { return hasInput() && b_video; }
110     void requestArtUpdate();
111
112     QString getName() { return oldName; }
113
114 private:
115     intf_thread_t  *p_intf;
116     input_thread_t *p_input;
117     input_item_t   *p_item;
118     int             i_old_playing_status;
119     QString         oldName;
120     QString         artUrl;
121     int             i_rate;
122     float           f_cache;
123     bool            b_video;
124     mtime_t         timeA, timeB;
125
126     void customEvent( QEvent * );
127
128     void addCallbacks();
129     void delCallbacks();
130
131     void UpdateRate();
132     void UpdateName();
133     void UpdateStatus();
134     void UpdateNavigation();
135     void UpdatePosition();
136     void UpdateTeletext();
137     void UpdateArt();
138     void UpdateInfo();
139     void UpdateMeta();
140     void UpdateMeta(int);
141     void UpdateVout();
142     void UpdateAout();
143     void UpdateStats();
144     void UpdateCaching();
145     void UpdateRecord();
146     void UpdateProgramEvent();
147
148 public slots:
149     void setInput( input_thread_t * ); ///< Our controlled input changed
150     void sliderUpdate( float ); ///< User dragged the slider. We get new pos
151     /* SpeedRate Rate Management */
152     void reverse();
153     void slower();
154     void faster();
155     void littlefaster();
156     void littleslower();
157     void normalRate();
158     void setRate( int );
159     /* Jumping */
160     void jumpFwd();
161     void jumpBwd();
162     /* Menus */
163     void sectionNext();
164     void sectionPrev();
165     void sectionMenu();
166     /* Teletext */
167     void telexSetPage( int );          ///< Goto teletext page
168     void telexSetTransparency( bool ); ///< Transparency on teletext background
169     void activateTeletext( bool );     ///< Toggle buttons after click
170     /* A to B Loop */
171     void setAtoB();
172
173 private slots:
174     void togglePlayPause();
175     void AtoBLoop( float, int, int );
176
177 signals:
178     /// Send new position, new time and new length
179     void positionUpdated( float , int, int );
180     void rateChanged( int );
181     void nameChanged( QString );
182     /// Used to signal whether we should show navigation buttons
183     void titleChanged( bool );
184     void chapterChanged( bool );
185     /// Statistics are updated
186     void statisticsUpdated( input_item_t* );
187     void infoChanged( input_item_t* );
188     void currentMetaChanged( input_item_t* );
189     void metaChanged( int );
190     void artChanged( QString );
191     /// Play/pause status
192     void statusChanged( int );
193     void recordingStateChanged( bool );
194     /// Teletext
195     void teletextPossible( bool );
196     void teletextActivated( bool );
197     void teletextTransparencyActivated( bool );
198     void newTelexPageSet( int );
199     /// Advanced buttons
200     void AtoBchanged( bool, bool );
201     /// Vout
202     void voutChanged( bool );
203     void voutListChanged( vout_thread_t **pp_vout, int i_vout );
204     /// Other
205     void synchroChanged();
206     void bookmarksChanged();
207     void cachingChanged( float );
208     /// Program Event changes
209     void encryptionChanged( bool );
210 };
211
212 class MainInputManager : public QObject
213 {
214     Q_OBJECT;
215 public:
216     static MainInputManager *getInstance( intf_thread_t *_p_intf )
217     {
218         if( !instance )
219             instance = new MainInputManager( _p_intf );
220         return instance;
221     }
222     static void killInstance()
223     {
224         delete instance;
225         instance = NULL;
226     }
227
228     input_thread_t *getInput() { return p_input; };
229     InputManager *getIM() { return im; };
230
231     vout_thread_t* getVout();
232     aout_instance_t *getAout();
233
234 private:
235     MainInputManager( intf_thread_t * );
236     virtual ~MainInputManager();
237
238     static MainInputManager *instance;
239
240     void customEvent( QEvent * );
241
242     InputManager            *im;
243     input_thread_t          *p_input;
244     intf_thread_t           *p_intf;
245
246 public slots:
247     void togglePlayPause();
248     void stop();
249     void next();
250     void prev();
251     void activatePlayQuit( bool );
252
253 signals:
254     void inputChanged( input_thread_t * );
255     void volumeChanged();
256 };
257
258 #endif