1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
8 * Olivier Teuli�e <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;
43 /// Singleton object handling VLC internal state and playlist
44 class VlcProc: public SkinObject
47 /// Get the instance of VlcProc
48 /// Returns NULL if the initialization of the object failed
49 static VlcProc *instance( intf_thread_t *pIntf );
51 /// Delete the instance of VlcProc
52 static void destroy( intf_thread_t *pIntf );
54 /// Getter for the playtree variable
55 Playtree &getPlaytreeVar() { return *((Playtree*)m_cPlaytree.get()); }
57 /// Getter for the time variable
58 StreamTime &getTimeVar() { return *((StreamTime*)(m_cVarTime.get())); }
60 /// Getter for the volume variable
61 Volume &getVolumeVar() { return *((Volume*)(m_cVarVolume.get())); }
63 /// Getter for the stream name variable
64 VarText &getStreamNameVar()
65 { return *((VarText*)(m_cVarStreamName.get())); }
67 /// Getter for the stream URI variable
68 VarText &getStreamURIVar()
69 { return *((VarText*)(m_cVarStreamURI.get())); }
71 /// Getter for the stream bitrate variable
72 VarText &getStreamBitRateVar()
73 { return *((VarText*)(m_cVarStreamBitRate.get())); }
75 /// Getter for the stream sample rate variable
76 VarText &getStreamSampleRateVar()
77 { return *((VarText*)(m_cVarStreamSampleRate.get())); }
79 /// Getter for the vout size variable
80 VarBox &getVoutSizeVar() { return m_varVoutSize; }
82 /// Set the vout window handle
83 void registerVoutWindow( void *pVoutWindow );
85 /// Unset the vout window handle
86 void unregisterVoutWindow( void *pVoutWindow );
88 /// Indicate whether the embedded video output is currently used
89 bool isVoutUsed() const { return m_pVout != NULL; }
91 /// If an embedded video output is used, drop it (i.e. tell it to stop
92 /// using our window handle)
96 // Protected because it is a singleton
97 VlcProc( intf_thread_t *pIntf );
101 /// Timer to call manage() regularly (via doManage())
103 /// Playtree variable
104 VariablePtr m_cPlaytree;
105 VariablePtr m_cVarRandom;
106 VariablePtr m_cVarLoop;
107 VariablePtr m_cVarRepeat;
108 /// Variable for current position of the stream
109 VariablePtr m_cVarTime;
110 /// Variable for audio volume
111 VariablePtr m_cVarVolume;
112 /// Variable for current stream properties
113 VariablePtr m_cVarStreamName;
114 VariablePtr m_cVarStreamURI;
115 VariablePtr m_cVarStreamBitRate;
116 VariablePtr m_cVarStreamSampleRate;
117 /// Variable for the "mute" state
118 VariablePtr m_cVarMute;
119 /// Variables related to the input
120 VariablePtr m_cVarPlaying;
121 VariablePtr m_cVarStopped;
122 VariablePtr m_cVarPaused;
123 VariablePtr m_cVarSeekable;
124 /// Variables related to the vout
125 VariablePtr m_cVarFullscreen;
126 VarBox m_varVoutSize;
127 VariablePtr m_cVarHasVout;
128 /// Variables related to audio
129 VariablePtr m_cVarHasAudio;
130 /// Equalizer variables
131 EqualizerBands m_varEqBands;
132 VariablePtr m_cVarEqPreamp;
133 VariablePtr m_cVarEqualizer;
134 /// Variable for DVD detection
135 VariablePtr m_cVarDvdActive;
137 /// Set of handles of vout windows
139 * When changing the skin, the handles of the 2 skins coexist in the
140 * set (but this is temporary, until the old theme is destroyed).
142 set<void *> m_handleSet;
144 vout_thread_t *m_pVout;
146 aout_instance_t *m_pAout;
149 * Poll VLC internals to update the status (volume, current time in
150 * the stream, current filename, play/pause/stop status, ...)
151 * This function should be called regurlarly, since there is no
152 * callback mechanism (yet?) to automatically update a variable when
153 * the internal status changes
157 /// Define the command that calls manage()
158 DEFINE_CALLBACK( VlcProc, Manage );
160 /// Refresh audio variables
162 /// Refresh playlist variables
163 void refreshPlaylist();
164 /// Refresh input variables
167 /// Update the stream name variable
168 void updateStreamName( playlist_t *p_playlist );
170 /// Callback for intf-change variable
171 static int onIntfChange( vlc_object_t *pObj, const char *pVariable,
172 vlc_value_t oldVal, vlc_value_t newVal,
175 /// Callback for intf-show variable
176 static int onIntfShow( vlc_object_t *pObj, const char *pVariable,
177 vlc_value_t oldVal, vlc_value_t newVal,
180 /// Callback for item-change variable
181 static int onItemChange( vlc_object_t *pObj, const char *pVariable,
182 vlc_value_t oldVal, vlc_value_t newVal,
185 /// Callback for item-change variable
186 static int onItemAppend( vlc_object_t *pObj, const char *pVariable,
187 vlc_value_t oldVal, vlc_value_t newVal,
190 /// Callback for item-change variable
191 static int onItemDelete( vlc_object_t *pObj, const char *pVariable,
192 vlc_value_t oldVal, vlc_value_t newVal,
196 /// Callback for playlist-current variable
197 static int onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
198 vlc_value_t oldVal, vlc_value_t newVal,
201 /// Callback for skins2-to-load variable
202 static int onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
203 vlc_value_t oldVal, vlc_value_t newVal,
206 /// Callback for interaction variable
207 static int onInteraction( vlc_object_t *pObj, const char *pVariable,
208 vlc_value_t oldVal, vlc_value_t newVal,
211 /// Callback to request a vout window
212 static void *getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
213 int *pXHint, int *pYHint,
214 unsigned int *pWidthHint,
215 unsigned int *pHeightHint );
217 /// Callback to release a vout window
218 static void releaseWindow( intf_thread_t *pIntf, void *pWindow );
220 /// Callback to change a vout window
221 static int controlWindow( intf_thread_t *pIntf, void *pWindow,
222 int query, va_list args );
224 /// Callback for equalizer-bands variable
225 static int onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
226 vlc_value_t oldVal, vlc_value_t newVal,
229 /// Callback for equalizer-preamp variable
230 static int onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
231 vlc_value_t oldVal, vlc_value_t newVal,