]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/vlcproc.hpp
9f0ecea61ee14e4739c5b6fc8618290d8cd6f395
[vlc] / modules / gui / skins2 / src / vlcproc.hpp
1 /*****************************************************************************
2  * vlcproc.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teuli�e <ipkiss@via.ecp.fr>
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 VLCPROC_HPP
26 #define VLCPROC_HPP
27
28 #include <set>
29
30 #include "../vars/equalizer.hpp"
31 #include "../vars/playlist.hpp"
32 #include "../vars/playtree.hpp"
33 #include "../vars/time.hpp"
34 #include "../vars/volume.hpp"
35 #include "../utils/position.hpp"
36 #include "../utils/var_text.hpp"
37 #include "../commands/cmd_generic.hpp"
38
39 class OSTimer;
40 class VarBool;
41 struct aout_instance_t;
42
43
44 /// Singleton object handling VLC internal state and playlist
45 class VlcProc: public SkinObject
46 {
47     public:
48         /// Get the instance of VlcProc
49         /// Returns NULL if the initialization of the object failed
50         static VlcProc *instance( intf_thread_t *pIntf );
51
52         /// Delete the instance of VlcProc
53         static void destroy( intf_thread_t *pIntf );
54
55         /// Getter for the playlist variable
56         Playlist &getPlaylistVar() { return *((Playlist*)m_cPlaylist.get()); }
57
58         /// Getter for the playtree variable
59         Playtree &getPlaytreeVar() { return *((Playtree*)m_cPlaytree.get()); }
60
61         /// Getter for the time variable
62         StreamTime &getTimeVar() { return *((StreamTime*)(m_cVarTime.get())); }
63
64         /// Getter for the volume variable
65         Volume &getVolumeVar() { return *((Volume*)(m_cVarVolume.get())); }
66
67         /// Getter for the stream name variable
68         VarText &getStreamNameVar()
69            { return *((VarText*)(m_cVarStreamName.get())); }
70
71         /// Getter for the stream URI variable
72         VarText &getStreamURIVar()
73             { return *((VarText*)(m_cVarStreamURI.get())); }
74
75         /// Getter for the stream bitrate variable
76         VarText &getStreamBitRateVar()
77             { return *((VarText*)(m_cVarStreamBitRate.get())); }
78
79         /// Getter for the stream sample rate variable
80         VarText &getStreamSampleRateVar()
81             { return *((VarText*)(m_cVarStreamSampleRate.get())); }
82
83         /// Getter for the vout size variable
84         VarBox &getVoutSizeVar() { return m_varVoutSize; }
85
86         /// Set the vout window handle
87         void registerVoutWindow( void *pVoutWindow );
88
89         /// Unset the vout window handle
90         void unregisterVoutWindow( void *pVoutWindow );
91
92         /// Indicate whether the embedded video output is currently used
93         bool isVoutUsed() const { return m_pVout != NULL; }
94
95         /// If an embedded video output is used, drop it (i.e. tell it to stop
96         /// using our window handle)
97         void dropVout();
98
99     protected:
100         // Protected because it is a singleton
101         VlcProc( intf_thread_t *pIntf );
102         virtual ~VlcProc();
103
104     private:
105         /// Timer to call manage() regularly (via doManage())
106         OSTimer *m_pTimer;
107         /// Playlist variable
108         VariablePtr m_cPlaylist;
109         /// Playtree variable FIXME
110         VariablePtr m_cPlaytree;
111         VariablePtr m_cVarRandom;
112         VariablePtr m_cVarLoop;
113         VariablePtr m_cVarRepeat;
114         /// Variable for current position of the stream
115         VariablePtr m_cVarTime;
116         /// Variable for audio volume
117         VariablePtr m_cVarVolume;
118         /// Variable for current stream properties
119         VariablePtr m_cVarStreamName;
120         VariablePtr m_cVarStreamURI;
121         VariablePtr m_cVarStreamBitRate;
122         VariablePtr m_cVarStreamSampleRate;
123         /// Variable for the "mute" state
124         VariablePtr m_cVarMute;
125         /// Variables related to the input
126         VariablePtr m_cVarPlaying;
127         VariablePtr m_cVarStopped;
128         VariablePtr m_cVarPaused;
129         VariablePtr m_cVarSeekable;
130         /// Variables related to the vout
131         VariablePtr m_cVarFullscreen;
132         VarBox m_varVoutSize;
133         VariablePtr m_cVarHasVout;
134         /// Variables related to audio
135         VariablePtr m_cVarHasAudio;
136         /// Equalizer variables
137         EqualizerBands m_varEqBands;
138         VariablePtr m_cVarEqPreamp;
139         VariablePtr m_cVarEqualizer;
140         /// Variable for DVD detection
141         VariablePtr m_cVarDvdActive;
142
143         /// Set of handles of vout windows
144         /**
145          * When changing the skin, the handles of the 2 skins coexist in the
146          * set (but this is temporary, until the old theme is destroyed).
147          */
148         set<void *> m_handleSet;
149         /// Vout thread
150         vout_thread_t *m_pVout;
151         /// Audio output
152         aout_instance_t *m_pAout;
153
154         /**
155          * Poll VLC internals to update the status (volume, current time in
156          * the stream, current filename, play/pause/stop status, ...)
157          * This function should be called regurlarly, since there is no
158          * callback mechanism (yet?) to automatically update a variable when
159          * the internal status changes
160          */
161         void manage();
162
163         /// Define the command that calls manage()
164         DEFINE_CALLBACK( VlcProc, Manage );
165
166         /// Refresh audio variables
167         void refreshAudio();
168         /// Refresh playlist variables
169         void refreshPlaylist();
170         /// Refresh input variables
171         void refreshInput();
172
173         /// Update the stream name variable
174         void updateStreamName( playlist_t *p_playlist );
175
176         /// Callback for intf-change variable
177         static int onIntfChange( vlc_object_t *pObj, const char *pVariable,
178                                  vlc_value_t oldVal, vlc_value_t newVal,
179                                  void *pParam );
180
181         /// Callback for intf-show variable
182         static int onIntfShow( vlc_object_t *pObj, const char *pVariable,
183                                vlc_value_t oldVal, vlc_value_t newVal,
184                                void *pParam );
185
186         /// Callback for item-change variable
187         static int onItemChange( vlc_object_t *pObj, const char *pVariable,
188                                  vlc_value_t oldVal, vlc_value_t newVal,
189                                  void *pParam );
190
191         /// Callback for item-change variable
192         static int onItemAppend( vlc_object_t *pObj, const char *pVariable,
193                                  vlc_value_t oldVal, vlc_value_t newVal,
194                                  void *pParam );
195
196         /// Callback for item-change variable
197         static int onItemDelete( vlc_object_t *pObj, const char *pVariable,
198                                  vlc_value_t oldVal, vlc_value_t newVal,
199                                  void *pParam );
200
201
202         /// Callback for playlist-current variable
203         static int onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
204                                      vlc_value_t oldVal, vlc_value_t newVal,
205                                      void *pParam );
206
207         /// Callback for skins2-to-load variable
208         static int onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
209                                  vlc_value_t oldVal, vlc_value_t newVal,
210                                  void *pParam );
211
212         /// Callback for interaction variable
213         static int onInteraction( vlc_object_t *pObj, const char *pVariable,
214                                   vlc_value_t oldVal, vlc_value_t newVal,
215                                   void *pParam );
216
217         /// Callback to request a vout window
218         static void *getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
219                                 int *pXHint, int *pYHint,
220                                 unsigned int *pWidthHint,
221                                 unsigned int *pHeightHint );
222
223         /// Callback to release a vout window
224         static void releaseWindow( intf_thread_t *pIntf, void *pWindow );
225
226         /// Callback to change a vout window
227         static int controlWindow( intf_thread_t *pIntf, void *pWindow,
228                                   int query, va_list args );
229
230         /// Callback for equalizer-bands variable
231         static int onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
232                                     vlc_value_t oldVal, vlc_value_t newVal,
233                                     void *pParam );
234
235         /// Callback for equalizer-preamp variable
236         static int onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
237                                      vlc_value_t oldVal, vlc_value_t newVal,
238                                      void *pParam );
239 };
240
241
242 #endif