1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
8 * Olivier Teulière <ipkiss@via.ecp.fr>
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 *****************************************************************************/
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"
40 struct aout_instance_t;
44 /// Singleton object handling VLC internal state and playlist
45 class VlcProc: public SkinObject
48 /// Get the instance of VlcProc
49 /// Returns NULL if the initialization of the object failed
50 static VlcProc *instance( intf_thread_t *pIntf );
52 /// Delete the instance of VlcProc
53 static void destroy( intf_thread_t *pIntf );
55 /// Getter for the playtree variable
56 Playtree &getPlaytreeVar() { return *((Playtree*)m_cPlaytree.get()); }
58 /// Getter for the time variable
59 StreamTime &getTimeVar() { return *((StreamTime*)(m_cVarTime.get())); }
61 /// Getter for the volume variable
62 Volume &getVolumeVar() { return *((Volume*)(m_cVarVolume.get())); }
64 /// Getter for the stream name variable
65 VarText &getStreamNameVar()
66 { return *((VarText*)(m_cVarStreamName.get())); }
68 /// Getter for the stream URI variable
69 VarText &getStreamURIVar()
70 { return *((VarText*)(m_cVarStreamURI.get())); }
72 /// Getter for the stream bitrate variable
73 VarText &getStreamBitRateVar()
74 { return *((VarText*)(m_cVarStreamBitRate.get())); }
76 /// Getter for the stream sample rate variable
77 VarText &getStreamSampleRateVar()
78 { return *((VarText*)(m_cVarStreamSampleRate.get())); }
80 /// Getter for the vout size variable
81 VarBox &getVoutSizeVar() { return m_varVoutSize; }
83 /// Set the vout window handle
84 void registerVoutWindow( void *pVoutWindow );
86 /// Unset the vout window handle
87 void unregisterVoutWindow( void *pVoutWindow );
89 /// Indicate whether the embedded video output is currently used
90 bool isVoutUsed() const { return m_pVout != NULL; }
92 /// If an embedded video output is used, drop it (i.e. tell it to stop
93 /// using our window handle)
97 // Protected because it is a singleton
98 VlcProc( intf_thread_t *pIntf );
102 /// Timer to call manage() regularly (via doManage())
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;
138 /// Set of handles of vout windows
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).
143 set<void *> m_handleSet;
145 vout_thread_t *m_pVout;
147 aout_instance_t *m_pAout;
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
158 /// Define the command that calls manage()
159 DEFINE_CALLBACK( VlcProc, Manage );
161 /// Refresh audio variables
163 /// Refresh playlist variables
164 void refreshPlaylist();
165 /// Refresh input variables
168 /// Update the stream name variable
169 void updateStreamName();
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,
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,
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,
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,
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,
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,
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,
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,
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 );
219 /// Callback to release a vout window
220 static void releaseWindow( intf_thread_t *pIntf, void *pWindow );
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 */
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,
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,