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