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 along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
30 #include <vlc_common.h>
31 #include <vlc_input.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 "../utils/var_string.hpp"
40 #include "../commands/cmd_generic.hpp"
41 #include "../controls/ctrl_video.hpp"
45 struct aout_instance_t
;
49 /// Singleton object handling VLC internal state and playlist
50 class VlcProc
: public SkinObject
53 /// Get the instance of VlcProc
54 /// Returns NULL if the initialization of the object failed
55 static VlcProc
*instance( intf_thread_t
*pIntf
);
57 /// Delete the instance of VlcProc
58 static void destroy( intf_thread_t
*pIntf
);
60 /// Getter for the playtree variable
61 Playtree
&getPlaytreeVar() { return *((Playtree
*)m_cPlaytree
.get()); }
63 /// Getter for the time variable
64 StreamTime
&getTimeVar() { return *((StreamTime
*)(m_cVarTime
.get())); }
66 /// Getter for the volume variable
67 Volume
&getVolumeVar() { return *((Volume
*)(m_cVarVolume
.get())); }
69 /// Getter for the stream name variable
70 VarText
&getStreamNameVar()
71 { return *((VarText
*)(m_cVarStreamName
.get())); }
73 /// Getter for the stream URI variable
74 VarText
&getStreamURIVar()
75 { return *((VarText
*)(m_cVarStreamURI
.get())); }
77 /// Getter for the stream bitrate variable
78 VarText
&getStreamBitRateVar()
79 { return *((VarText
*)(m_cVarStreamBitRate
.get())); }
81 /// Getter for the stream sample rate variable
82 VarText
&getStreamSampleRateVar()
83 { return *((VarText
*)(m_cVarStreamSampleRate
.get())); }
85 /// Getter for the stream Art url variable
86 VarString
&getStreamArtVar()
87 { return *((VarString
*)(m_cVarStreamArt
.get())); }
89 /// Getter/Setter for the fullscreen variable
90 VarBool
&getFullscreenVar() { return *((VarBool
*)(m_cVarFullscreen
.get())); }
91 void setFullscreenVar( bool );
93 /// Indicate whether the embedded video output is currently used
94 bool isVoutUsed() const { return m_pVout
!= NULL
; }
97 void update_equalizer( );
99 void on_item_current_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
);
100 void on_intf_event_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
);
101 void on_bit_rate_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
);
102 void on_sample_rate_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
);
103 void on_can_record_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
);
105 void on_random_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
);
106 void on_loop_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
);
107 void on_repeat_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
);
109 void on_volume_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
);
110 void on_audio_filter_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
);
112 void on_intf_show_changed( vlc_object_t
* p_obj
, vlc_value_t newVal
);
115 // Protected because it is a singleton
116 VlcProc( intf_thread_t
*pIntf
);
120 /// Timer to call manage() regularly (via doManage())
122 /// Playtree variable
123 VariablePtr m_cPlaytree
;
124 VariablePtr m_cVarRandom
;
125 VariablePtr m_cVarLoop
;
126 VariablePtr m_cVarRepeat
;
127 /// Variable for current position of the stream
128 VariablePtr m_cVarTime
;
129 /// Variable for audio volume
130 VariablePtr m_cVarVolume
;
131 /// Variable for current stream properties
132 VariablePtr m_cVarStreamName
;
133 VariablePtr m_cVarStreamURI
;
134 VariablePtr m_cVarStreamBitRate
;
135 VariablePtr m_cVarStreamSampleRate
;
136 VariablePtr m_cVarStreamArt
;
137 /// Variable for the "mute" state
138 VariablePtr m_cVarMute
;
139 /// Variables related to the input
140 VariablePtr m_cVarPlaying
;
141 VariablePtr m_cVarStopped
;
142 VariablePtr m_cVarPaused
;
143 VariablePtr m_cVarSeekable
;
144 VariablePtr m_cVarRecordable
;
145 VariablePtr m_cVarRecording
;
146 /// Variables related to the vout
147 VariablePtr m_cVarFullscreen
;
148 VariablePtr m_cVarHasVout
;
149 /// Variables related to audio
150 VariablePtr m_cVarHasAudio
;
151 /// Equalizer variables
152 EqualizerBands m_varEqBands
;
153 VariablePtr m_cVarEqPreamp
;
154 VariablePtr m_cVarEqualizer
;
155 /// Variable for DVD detection
156 VariablePtr m_cVarDvdActive
;
159 vout_thread_t
*m_pVout
;
161 aout_instance_t
*m_pAout
;
162 bool m_bEqualizer_started
;
165 * Poll VLC internals to update the status (volume, current time in
166 * the stream, current filename, play/pause/stop status, ...)
167 * This function should be called regurlarly, since there is no
168 * callback mechanism (yet?) to automatically update a variable when
169 * the internal status changes
173 // reset variables when input is over
176 // init variables (libvlc and playlist levels)
177 void init_variables();
179 /// Define the command that calls manage()
180 DEFINE_CALLBACK( VlcProc
, Manage
);
182 /// Callback for intf-show variable
183 static int onIntfShow( vlc_object_t
*pObj
, const char *pVariable
,
184 vlc_value_t oldVal
, vlc_value_t newVal
,
187 /// Callback for input-current variable
188 static int onInputNew( vlc_object_t
*pObj
, const char *pVariable
,
189 vlc_value_t oldVal
, vlc_value_t newVal
,
192 /// Callback for item-change variable
193 static int onItemChange( vlc_object_t
*pObj
, const char *pVariable
,
194 vlc_value_t oldVal
, vlc_value_t newVal
,
197 /// Callback for item-change variable
198 static int onItemAppend( vlc_object_t
*pObj
, const char *pVariable
,
199 vlc_value_t oldVal
, vlc_value_t newVal
,
202 /// Callback for item-change variable
203 static int onItemDelete( vlc_object_t
*pObj
, const char *pVariable
,
204 vlc_value_t oldVal
, vlc_value_t newVal
,
207 static int onInteraction( vlc_object_t
*pObj
, const char *pVariable
,
208 vlc_value_t oldVal
, vlc_value_t newVal
,
211 static int onEqBandsChange( vlc_object_t
*pObj
, const char *pVariable
,
212 vlc_value_t oldVal
, vlc_value_t newVal
,
215 static int onEqPreampChange( vlc_object_t
*pObj
, const char *pVariable
,
216 vlc_value_t oldVal
, vlc_value_t newVal
,
220 static int onGenericCallback( vlc_object_t
*pObj
, const char *pVariable
,
221 vlc_value_t oldVal
, vlc_value_t newVal
,