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 *****************************************************************************/
31 #include "../vars/equalizer.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 #include "../controls/ctrl_video.hpp"
42 struct aout_instance_t;
46 /// Singleton object handling VLC internal state and playlist
47 class VlcProc: public SkinObject
50 /// Get the instance of VlcProc
51 /// Returns NULL if the initialization of the object failed
52 static VlcProc *instance( intf_thread_t *pIntf );
54 /// Delete the instance of VlcProc
55 static void destroy( intf_thread_t *pIntf );
57 /// Getter for the playtree variable
58 Playtree &getPlaytreeVar() { return *((Playtree*)m_cPlaytree.get()); }
60 /// Getter for the time variable
61 StreamTime &getTimeVar() { return *((StreamTime*)(m_cVarTime.get())); }
63 /// Getter for the volume variable
64 Volume &getVolumeVar() { return *((Volume*)(m_cVarVolume.get())); }
66 /// Getter for the stream name variable
67 VarText &getStreamNameVar()
68 { return *((VarText*)(m_cVarStreamName.get())); }
70 /// Getter for the stream URI variable
71 VarText &getStreamURIVar()
72 { return *((VarText*)(m_cVarStreamURI.get())); }
74 /// Getter for the stream bitrate variable
75 VarText &getStreamBitRateVar()
76 { return *((VarText*)(m_cVarStreamBitRate.get())); }
78 /// Getter for the stream sample rate variable
79 VarText &getStreamSampleRateVar()
80 { return *((VarText*)(m_cVarStreamSampleRate.get())); }
82 /// Getter for the vout size variable
83 VarBox &getVoutSizeVar() { return m_varVoutSize; }
85 /// Indicate whether the embedded video output is currently used
86 bool isVoutUsed() const { return m_pVout != NULL; }
89 // Protected because it is a singleton
90 VlcProc( intf_thread_t *pIntf );
94 /// Timer to call manage() regularly (via doManage())
97 VariablePtr m_cPlaytree;
98 VariablePtr m_cVarRandom;
99 VariablePtr m_cVarLoop;
100 VariablePtr m_cVarRepeat;
101 /// Variable for current position of the stream
102 VariablePtr m_cVarTime;
103 /// Variable for audio volume
104 VariablePtr m_cVarVolume;
105 /// Variable for current stream properties
106 VariablePtr m_cVarStreamName;
107 VariablePtr m_cVarStreamURI;
108 VariablePtr m_cVarStreamBitRate;
109 VariablePtr m_cVarStreamSampleRate;
110 /// Variable for the "mute" state
111 VariablePtr m_cVarMute;
112 /// Variables related to the input
113 VariablePtr m_cVarPlaying;
114 VariablePtr m_cVarStopped;
115 VariablePtr m_cVarPaused;
116 VariablePtr m_cVarSeekable;
117 /// Variables related to the vout
118 VariablePtr m_cVarFullscreen;
119 VarBox m_varVoutSize;
120 VariablePtr m_cVarHasVout;
121 /// Variables related to audio
122 VariablePtr m_cVarHasAudio;
123 /// Equalizer variables
124 EqualizerBands m_varEqBands;
125 VariablePtr m_cVarEqPreamp;
126 VariablePtr m_cVarEqualizer;
127 /// Variable for DVD detection
128 VariablePtr m_cVarDvdActive;
131 vout_thread_t *m_pVout;
133 aout_instance_t *m_pAout;
136 * Poll VLC internals to update the status (volume, current time in
137 * the stream, current filename, play/pause/stop status, ...)
138 * This function should be called regurlarly, since there is no
139 * callback mechanism (yet?) to automatically update a variable when
140 * the internal status changes
144 /// Define the command that calls manage()
145 DEFINE_CALLBACK( VlcProc, Manage );
147 /// Refresh audio variables
149 /// Refresh playlist variables
150 void refreshPlaylist();
151 /// Refresh input variables
154 /// Update the stream name variable
155 void updateStreamName();
157 /// Callback for intf-change variable
158 static int onIntfChange( vlc_object_t *pObj, const char *pVariable,
159 vlc_value_t oldVal, vlc_value_t newVal,
162 /// Callback for intf-show variable
163 static int onIntfShow( vlc_object_t *pObj, const char *pVariable,
164 vlc_value_t oldVal, vlc_value_t newVal,
167 /// Callback for item-change variable
168 static int onItemChange( vlc_object_t *pObj, const char *pVariable,
169 vlc_value_t oldVal, vlc_value_t newVal,
172 /// Callback for item-change variable
173 static int onItemAppend( vlc_object_t *pObj, const char *pVariable,
174 vlc_value_t oldVal, vlc_value_t newVal,
177 /// Callback for item-change variable
178 static int onItemDelete( vlc_object_t *pObj, const char *pVariable,
179 vlc_value_t oldVal, vlc_value_t newVal,
183 /// Callback for playlist-current variable
184 static int onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
185 vlc_value_t oldVal, vlc_value_t newVal,
188 /// Callback for skins2-to-load variable
189 static int onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
190 vlc_value_t oldVal, vlc_value_t newVal,
193 /// Callback for interaction variable
194 static int onInteraction( vlc_object_t *pObj, const char *pVariable,
195 vlc_value_t oldVal, vlc_value_t newVal,
198 /// Callback for equalizer-bands variable
199 static int onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
200 vlc_value_t oldVal, vlc_value_t newVal,
203 /// Callback for equalizer-preamp variable
204 static int onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
205 vlc_value_t oldVal, vlc_value_t newVal,