]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/vlcproc.hpp
skins2: use new input-item variable for callbacks on input variables and some cleanup
[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 <vlc_common.h>
31 #include <vlc_input.h>
32 #include <vlc_vout.h>
33 #include "../vars/equalizer.hpp"
34 #include "../vars/playtree.hpp"
35 #include "../vars/time.hpp"
36 #include "../vars/volume.hpp"
37 #include "../utils/position.hpp"
38 #include "../utils/var_text.hpp"
39 #include "../commands/cmd_generic.hpp"
40 #include "../controls/ctrl_video.hpp"
41
42 class OSTimer;
43 class VarBool;
44 struct aout_instance_t;
45 struct vout_window_t;
46
47
48 /// Singleton object handling VLC internal state and playlist
49 class VlcProc: public SkinObject
50 {
51     public:
52         /// Get the instance of VlcProc
53         /// Returns NULL if the initialization of the object failed
54         static VlcProc *instance( intf_thread_t *pIntf );
55
56         /// Delete the instance of VlcProc
57         static void destroy( intf_thread_t *pIntf );
58
59         /// Getter for the playtree variable
60         Playtree &getPlaytreeVar() { return *((Playtree*)m_cPlaytree.get()); }
61
62         /// Getter for the time variable
63         StreamTime &getTimeVar() { return *((StreamTime*)(m_cVarTime.get())); }
64
65         /// Getter for the volume variable
66         Volume &getVolumeVar() { return *((Volume*)(m_cVarVolume.get())); }
67
68         /// Getter for the stream name variable
69         VarText &getStreamNameVar()
70            { return *((VarText*)(m_cVarStreamName.get())); }
71
72         /// Getter for the stream URI variable
73         VarText &getStreamURIVar()
74             { return *((VarText*)(m_cVarStreamURI.get())); }
75
76         /// Getter for the stream bitrate variable
77         VarText &getStreamBitRateVar()
78             { return *((VarText*)(m_cVarStreamBitRate.get())); }
79
80         /// Getter for the stream sample rate variable
81         VarText &getStreamSampleRateVar()
82             { return *((VarText*)(m_cVarStreamSampleRate.get())); }
83
84         /// Getter for the vout size variable
85         VarBox &getVoutSizeVar() { return m_varVoutSize; }
86
87         /// Indicate whether the embedded video output is currently used
88         bool isVoutUsed() const { return m_pVout != NULL; }
89
90         void on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal );
91         void on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal );
92         void on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal );
93         void on_sample_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal );
94         void on_can_record_changed( vlc_object_t* p_obj, vlc_value_t newVal );
95
96         void on_random_changed( vlc_object_t* p_obj, vlc_value_t newVal );
97         void on_loop_changed( vlc_object_t* p_obj, vlc_value_t newVal );
98         void on_repeat_changed( vlc_object_t* p_obj, vlc_value_t newVal );
99
100         void on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal );
101         void on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal );
102
103     protected:
104         // Protected because it is a singleton
105         VlcProc( intf_thread_t *pIntf );
106         virtual ~VlcProc();
107
108     private:
109         /// Timer to call manage() regularly (via doManage())
110         OSTimer *m_pTimer;
111         /// Playtree variable
112         VariablePtr m_cPlaytree;
113         VariablePtr m_cVarRandom;
114         VariablePtr m_cVarLoop;
115         VariablePtr m_cVarRepeat;
116         /// Variable for current position of the stream
117         VariablePtr m_cVarTime;
118         /// Variable for audio volume
119         VariablePtr m_cVarVolume;
120         /// Variable for current stream properties
121         VariablePtr m_cVarStreamName;
122         VariablePtr m_cVarStreamURI;
123         VariablePtr m_cVarStreamBitRate;
124         VariablePtr m_cVarStreamSampleRate;
125         /// Variable for the "mute" state
126         VariablePtr m_cVarMute;
127         /// Variables related to the input
128         VariablePtr m_cVarPlaying;
129         VariablePtr m_cVarStopped;
130         VariablePtr m_cVarPaused;
131         VariablePtr m_cVarSeekable;
132         VariablePtr m_cVarRecordable;
133         VariablePtr m_cVarRecording;
134         /// Variables related to the vout
135         VariablePtr m_cVarFullscreen;
136         VarBox m_varVoutSize;
137         VariablePtr m_cVarHasVout;
138         /// Variables related to audio
139         VariablePtr m_cVarHasAudio;
140         /// Equalizer variables
141         EqualizerBands m_varEqBands;
142         VariablePtr m_cVarEqPreamp;
143         VariablePtr m_cVarEqualizer;
144         /// Variable for DVD detection
145         VariablePtr m_cVarDvdActive;
146
147         /// Vout thread
148         vout_thread_t *m_pVout;
149         /// Audio output
150         aout_instance_t *m_pAout;
151
152         /**
153          * Poll VLC internals to update the status (volume, current time in
154          * the stream, current filename, play/pause/stop status, ...)
155          * This function should be called regurlarly, since there is no
156          * callback mechanism (yet?) to automatically update a variable when
157          * the internal status changes
158          */
159         void manage();
160
161         // reset variables when input is over
162         void reset_input();
163
164         // init variables (libvlc and playlist levels)
165         void init_variables();
166
167         /// Define the command that calls manage()
168         DEFINE_CALLBACK( VlcProc, Manage );
169
170         /// Update the stream name variable
171         void updateStreamName();
172
173         /// Callback for intf-change variable
174         static int onIntfChange( vlc_object_t *pObj, const char *pVariable,
175                                  vlc_value_t oldVal, vlc_value_t newVal,
176                                  void *pParam );
177
178         /// Callback for intf-show variable
179         static int onIntfShow( vlc_object_t *pObj, const char *pVariable,
180                                vlc_value_t oldVal, vlc_value_t newVal,
181                                void *pParam );
182
183         /// Callback for input-current variable
184         static int onInputNew( vlc_object_t *pObj, const char *pVariable,
185                                vlc_value_t oldVal, vlc_value_t newVal,
186                                void *pParam );
187
188         /// Callback for item-change variable
189         static int onItemChange( vlc_object_t *pObj, const char *pVariable,
190                                  vlc_value_t oldVal, vlc_value_t newVal,
191                                  void *pParam );
192
193         /// Callback for item-change variable
194         static int onItemAppend( vlc_object_t *pObj, const char *pVariable,
195                                  vlc_value_t oldVal, vlc_value_t newVal,
196                                  void *pParam );
197
198         /// Callback for item-change variable
199         static int onItemDelete( vlc_object_t *pObj, const char *pVariable,
200                                  vlc_value_t oldVal, vlc_value_t newVal,
201                                  void *pParam );
202
203         /// Callback for skins2-to-load variable
204         static int onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
205                                  vlc_value_t oldVal, vlc_value_t newVal,
206                                  void *pParam );
207
208         /// Callback for interaction variable
209         static int onInteraction( vlc_object_t *pObj, const char *pVariable,
210                                   vlc_value_t oldVal, vlc_value_t newVal,
211                                   void *pParam );
212
213         /// Callback for equalizer-bands variable
214         static int onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
215                                     vlc_value_t oldVal, vlc_value_t newVal,
216                                     void *pParam );
217
218         /// Callback for equalizer-preamp variable
219         static int onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
220                                      vlc_value_t oldVal, vlc_value_t newVal,
221                                      void *pParam );
222
223         /// Generic Callback
224         static int onGenericCallback( vlc_object_t *pObj, const char *pVariable,
225                                       vlc_value_t oldVal, vlc_value_t newVal,
226                                       void *pParam );
227
228 };
229
230
231 #endif