]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/vlcproc.cpp
39e94901fece8cf80b3bcc20bba3881632cc3ca1
[vlc] / modules / gui / skins2 / src / vlcproc.cpp
1 /*****************************************************************************
2  * vlcproc.cpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teuli�e <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 #ifdef HAVE_CONFIG_H
26 # include "config.h"
27 #endif
28
29 #include <vlc/vlc.h>
30 #include <vlc_aout.h>
31 #include <vlc_vout.h>
32 #include <vlc_playlist.h>
33
34 #include "vlcproc.hpp"
35 #include "os_factory.hpp"
36 #include "os_timer.hpp"
37 #include "var_manager.hpp"
38 #include "theme.hpp"
39 #include "window_manager.hpp"
40 #include "../commands/async_queue.hpp"
41 #include "../commands/cmd_change_skin.hpp"
42 #include "../commands/cmd_show_window.hpp"
43 #include "../commands/cmd_quit.hpp"
44 #include "../commands/cmd_resize.hpp"
45 #include "../commands/cmd_vars.hpp"
46 #include "../commands/cmd_dialogs.hpp"
47 #include "../utils/var_bool.hpp"
48 #include <sstream>
49
50
51 VlcProc *VlcProc::instance( intf_thread_t *pIntf )
52 {
53     if( pIntf->p_sys->p_vlcProc == NULL )
54     {
55         pIntf->p_sys->p_vlcProc = new VlcProc( pIntf );
56     }
57
58     return pIntf->p_sys->p_vlcProc;
59 }
60
61
62 void VlcProc::destroy( intf_thread_t *pIntf )
63 {
64     if( pIntf->p_sys->p_vlcProc )
65     {
66         delete pIntf->p_sys->p_vlcProc;
67         pIntf->p_sys->p_vlcProc = NULL;
68     }
69 }
70
71
72 VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
73     m_varVoutSize( pIntf ), m_varEqBands( pIntf ),
74     m_pVout( NULL ), m_pAout( NULL ), m_cmdManage( this )
75 {
76     // Create a timer to poll the status of the vlc
77     OSFactory *pOsFactory = OSFactory::instance( pIntf );
78     m_pTimer = pOsFactory->createOSTimer( m_cmdManage );
79     m_pTimer->start( 100, false );
80
81     // Create and register VLC variables
82     VarManager *pVarManager = VarManager::instance( getIntf() );
83
84 #define REGISTER_VAR( var, type, name ) \
85     var = VariablePtr( new type( getIntf() ) ); \
86     pVarManager->registerVar( var, name );
87     REGISTER_VAR( m_cVarRandom, VarBoolImpl, "playlist.isRandom" )
88     REGISTER_VAR( m_cVarLoop, VarBoolImpl, "playlist.isLoop" )
89     REGISTER_VAR( m_cVarRepeat, VarBoolImpl, "playlist.isRepeat" )
90     REGISTER_VAR( m_cPlaytree, Playtree, "playtree" )
91     pVarManager->registerVar( getPlaytreeVar().getPositionVarPtr(),
92                               "playtree.slider" );
93     pVarManager->registerVar( m_cVarRandom, "playtree.isRandom" );
94     pVarManager->registerVar( m_cVarLoop, "playtree.isLoop" );
95
96     REGISTER_VAR( m_cVarPlaying, VarBoolImpl, "vlc.isPlaying" )
97     REGISTER_VAR( m_cVarStopped, VarBoolImpl, "vlc.isStopped" )
98     REGISTER_VAR( m_cVarPaused, VarBoolImpl, "vlc.isPaused" )
99
100     /* Input variables */
101     pVarManager->registerVar( m_cVarRepeat, "playtree.isRepeat" );
102     REGISTER_VAR( m_cVarTime, StreamTime, "time" )
103     REGISTER_VAR( m_cVarSeekable, VarBoolImpl, "vlc.isSeekable" )
104     REGISTER_VAR( m_cVarDvdActive, VarBoolImpl, "dvd.isActive" )
105
106     /* Vout variables */
107     REGISTER_VAR( m_cVarFullscreen, VarBoolImpl, "vlc.isFullscreen" )
108     REGISTER_VAR( m_cVarHasVout, VarBoolImpl, "vlc.hasVout" )
109
110     /* Aout variables */
111     REGISTER_VAR( m_cVarHasAudio, VarBoolImpl, "vlc.hasAudio" )
112     REGISTER_VAR( m_cVarVolume, Volume, "volume" )
113     REGISTER_VAR( m_cVarMute, VarBoolImpl, "vlc.isMute" )
114     REGISTER_VAR( m_cVarEqualizer, VarBoolImpl, "equalizer.isEnabled" )
115     REGISTER_VAR( m_cVarEqPreamp, EqualizerPreamp, "equalizer.preamp" )
116
117 #undef REGISTER_VAR
118     m_cVarStreamName = VariablePtr( new VarText( getIntf(), false ) );
119     pVarManager->registerVar( m_cVarStreamName, "streamName" );
120     m_cVarStreamURI = VariablePtr( new VarText( getIntf(), false ) );
121     pVarManager->registerVar( m_cVarStreamURI, "streamURI" );
122     m_cVarStreamBitRate = VariablePtr( new VarText( getIntf(), false ) );
123     pVarManager->registerVar( m_cVarStreamBitRate, "bitrate" );
124     m_cVarStreamSampleRate = VariablePtr( new VarText( getIntf(), false ) );
125     pVarManager->registerVar( m_cVarStreamSampleRate, "samplerate" );
126
127     // Register the equalizer bands
128     for( int i = 0; i < EqualizerBands::kNbBands; i++)
129     {
130         stringstream ss;
131         ss << "equalizer.band(" << i << ")";
132         pVarManager->registerVar( m_varEqBands.getBand( i ), ss.str() );
133     }
134
135     // XXX WARNING XXX
136     // The object variable callbacks are called from other VLC threads,
137     // so they must put commands in the queue and NOT do anything else
138     // (X11 calls are not reentrant)
139
140     // Called when the playlist changes
141     var_AddCallback( pIntf->p_sys->p_playlist, "intf-change",
142                      onIntfChange, this );
143     // Called when a playlist item is added
144     var_AddCallback( pIntf->p_sys->p_playlist, "item-append",
145                      onItemAppend, this );
146     // Called when a playlist item is deleted
147     // TODO: properly handle item-deleted
148     var_AddCallback( pIntf->p_sys->p_playlist, "item-deleted",
149                      onItemDelete, this );
150     // Called when the "interface shower" wants us to show the skin
151     var_AddCallback( pIntf->p_sys->p_playlist, "intf-show",
152                      onIntfShow, this );
153     // Called when the current played item changes
154     var_AddCallback( pIntf->p_sys->p_playlist, "playlist-current",
155                      onPlaylistChange, this );
156     // Called when a playlist item changed
157     var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
158                      onItemChange, this );
159     // Called when our skins2 demux wants us to load a new skin
160     var_AddCallback( pIntf, "skin-to-load", onSkinToLoad, this );
161
162     // Called when we have an interaction dialog to display
163     var_Create( pIntf, "interaction", VLC_VAR_ADDRESS );
164     var_AddCallback( pIntf, "interaction", onInteraction, this );
165     pIntf->b_interaction = true;
166
167     // Callbacks for vout requests
168     getIntf()->pf_request_window = &getWindow;
169     getIntf()->pf_release_window = &releaseWindow;
170     getIntf()->pf_control_window = &controlWindow;
171
172     getIntf()->p_sys->p_input = NULL;
173 }
174
175
176 VlcProc::~VlcProc()
177 {
178     m_pTimer->stop();
179     delete( m_pTimer );
180     if( getIntf()->p_sys->p_input )
181     {
182         vlc_object_release( getIntf()->p_sys->p_input );
183     }
184
185     // Callbacks for vout requests
186     getIntf()->pf_request_window = NULL;
187     getIntf()->pf_release_window = NULL;
188     getIntf()->pf_control_window = NULL;
189
190     var_DelCallback( getIntf()->p_sys->p_playlist, "intf-change",
191                      onIntfChange, this );
192     var_DelCallback( getIntf()->p_sys->p_playlist, "item-append",
193                      onItemAppend, this );
194     var_DelCallback( getIntf()->p_sys->p_playlist, "item-deleted",
195                      onItemDelete, this );
196     var_DelCallback( getIntf()->p_sys->p_playlist, "intf-show",
197                      onIntfShow, this );
198     var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-current",
199                      onPlaylistChange, this );
200     var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
201                      onItemChange, this );
202     var_DelCallback( getIntf(), "skin-to-load", onSkinToLoad, this );
203 }
204
205
206 void VlcProc::registerVoutWindow( void *pVoutWindow )
207 {
208     m_handleSet.insert( pVoutWindow );
209     // Reparent the vout window
210     if( m_pVout )
211     {
212         if( vout_Control( m_pVout, VOUT_REPARENT, 0 ) != VLC_SUCCESS )
213             vout_Control( m_pVout, VOUT_CLOSE );
214     }
215 }
216
217
218 void VlcProc::unregisterVoutWindow( void *pVoutWindow )
219 {
220     m_handleSet.erase( pVoutWindow );
221 }
222
223
224 void VlcProc::dropVout()
225 {
226     if( m_pVout )
227     {
228         if( vout_Control( m_pVout, VOUT_REPARENT, 0 ) != VLC_SUCCESS )
229             vout_Control( m_pVout, VOUT_CLOSE );
230         m_pVout = NULL;
231     }
232 }
233
234
235 void VlcProc::manage()
236 {
237     // Did the user request to quit vlc ?
238     if( intf_ShouldDie( getIntf() ) )
239     {
240         CmdQuit *pCmd = new CmdQuit( getIntf() );
241         AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
242         pQueue->push( CmdGenericPtr( pCmd ) );
243     }
244
245     refreshPlaylist();
246     refreshAudio();
247     refreshInput();
248 }
249 void VlcProc::CmdManage::execute()
250 {
251     // Just forward to VlcProc
252     m_pParent->manage();
253 }
254
255 void VlcProc::refreshAudio()
256 {
257     char *pFilters;
258
259     // Check if the audio output has changed
260     aout_instance_t *pAout = (aout_instance_t *)vlc_object_find( getIntf(),
261             VLC_OBJECT_AOUT, FIND_ANYWHERE );
262     if( pAout )
263     {
264         if( pAout != m_pAout )
265         {
266             // Register the equalizer callbacks
267             if( !var_AddCallback( pAout, "equalizer-bands",
268                                   onEqBandsChange, this ) &&
269                 !var_AddCallback( pAout, "equalizer-preamp",
270                                   onEqPreampChange, this ) )
271             {
272                 m_pAout = pAout;
273                 //char * psz_bands = var_GetString( p_aout, "equalizer-bands" );
274             }
275         }
276         // Get the audio filters
277         pFilters = var_GetNonEmptyString( pAout, "audio-filter" );
278         vlc_object_release( pAout );
279     }
280     else
281     {
282         // Get the audio filters
283         pFilters = config_GetPsz( getIntf(), "audio-filter" );
284     }
285
286     // Refresh sound volume
287     audio_volume_t volume;
288     aout_VolumeGet( getIntf(), &volume );
289     Volume *pVolume = (Volume*)m_cVarVolume.get();
290     pVolume->set( (double)volume * 2.0 / AOUT_VOLUME_MAX );
291
292     // Set the mute variable
293     VarBoolImpl *pVarMute = (VarBoolImpl*)m_cVarMute.get();
294     pVarMute->set( volume == 0 );
295
296     // Refresh the equalizer variable
297     VarBoolImpl *pVarEqualizer = (VarBoolImpl*)m_cVarEqualizer.get();
298     pVarEqualizer->set( pFilters && strstr( pFilters, "equalizer" ) );
299     free( pFilters );
300 }
301
302 void VlcProc::refreshPlaylist()
303 {
304     // Refresh the random variable
305     VarBoolImpl *pVarRandom = (VarBoolImpl*)m_cVarRandom.get();
306     vlc_value_t val;
307     var_Get( getIntf()->p_sys->p_playlist, "random", &val );
308     pVarRandom->set( val.b_bool != 0 );
309
310     // Refresh the loop variable
311     VarBoolImpl *pVarLoop = (VarBoolImpl*)m_cVarLoop.get();
312     var_Get( getIntf()->p_sys->p_playlist, "loop", &val );
313     pVarLoop->set( val.b_bool != 0 );
314
315     // Refresh the repeat variable
316     VarBoolImpl *pVarRepeat = (VarBoolImpl*)m_cVarRepeat.get();
317     var_Get( getIntf()->p_sys->p_playlist, "repeat", &val );
318     pVarRepeat->set( val.b_bool != 0 );
319 }
320
321 void VlcProc::refreshInput()
322 {
323     StreamTime *pTime = (StreamTime*)m_cVarTime.get();
324     VarBoolImpl *pVarSeekable = (VarBoolImpl*)m_cVarSeekable.get();
325     VarBoolImpl *pVarDvdActive = (VarBoolImpl*)m_cVarDvdActive.get();
326     VarBoolImpl *pVarHasVout = (VarBoolImpl*)m_cVarHasVout.get();
327     VarBoolImpl *pVarHasAudio = (VarBoolImpl*)m_cVarHasAudio.get();
328     VarText *pBitrate = (VarText*)m_cVarStreamBitRate.get();
329     VarText *pSampleRate = (VarText*)m_cVarStreamSampleRate.get();
330     VarBoolImpl *pVarFullscreen = (VarBoolImpl*)m_cVarFullscreen.get();
331     VarBoolImpl *pVarPlaying = (VarBoolImpl*)m_cVarPlaying.get();
332     VarBoolImpl *pVarStopped = (VarBoolImpl*)m_cVarStopped.get();
333     VarBoolImpl *pVarPaused = (VarBoolImpl*)m_cVarPaused.get();
334
335     input_thread_t *pInput = getIntf()->p_sys->p_input;
336
337     // Update the input
338     if( getIntf()->p_sys->p_input == NULL )
339     {
340         getIntf()->p_sys->p_input = getIntf()->p_sys->p_playlist->p_input;
341         if( getIntf()->p_sys->p_input )
342             vlc_object_yield( getIntf()->p_sys->p_input );
343     }
344     else if( getIntf()->p_sys->p_input->b_dead )
345     {
346         vlc_object_release( getIntf()->p_sys->p_input );
347         getIntf()->p_sys->p_input = NULL;
348     }
349
350
351     if( pInput && !pInput->b_die )
352     {
353         // Refresh time variables
354         vlc_value_t pos;
355         var_Get( pInput, "position", &pos );
356         pTime->set( pos.f_float, false );
357         pVarSeekable->set( pos.f_float != 0.0 );
358
359         // Refresh DVD detection
360         vlc_value_t chapters_count;
361         var_Change( pInput, "chapter", VLC_VAR_CHOICESCOUNT,
362                         &chapters_count, NULL );
363         pVarDvdActive->set( chapters_count.i_int > 0 );
364
365         // Get the input bitrate
366         int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
367         pBitrate->set( UString::fromInt( getIntf(), bitrate ) );
368
369         // Get the audio sample rate
370         int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
371         pSampleRate->set( UString::fromInt( getIntf(), sampleRate ) );
372
373         // Do we have audio
374         vlc_value_t audio_es;
375         var_Change( pInput, "audio-es", VLC_VAR_CHOICESCOUNT,
376                         &audio_es, NULL );
377         pVarHasAudio->set( audio_es.i_int > 0 );
378
379         // Refresh fullscreen status
380         vout_thread_t *pVout = (vout_thread_t *)vlc_object_find( pInput,
381                                      VLC_OBJECT_VOUT, FIND_CHILD );
382         pVarHasVout->set( pVout != NULL );
383         if( pVout )
384         {
385             pVarFullscreen->set( pVout->b_fullscreen );
386             vlc_object_release( pVout );
387         }
388
389         // Refresh play/pause status
390         int state = var_GetInteger( pInput, "state" );
391         pVarStopped->set( false );
392         pVarPlaying->set( state != PAUSE_S );
393         pVarPaused->set( state == PAUSE_S );
394     }
395     else
396     {
397         pVarSeekable->set( false );
398         pVarDvdActive->set( false );
399         pTime->set( 0, false );
400         pVarFullscreen->set( false );
401         pVarHasAudio->set( false );
402         pVarHasVout->set( false );
403         pVarStopped->set( true );
404         pVarPlaying->set( false );
405         pVarPaused->set( false );
406     }
407 }
408
409 int VlcProc::onIntfChange( vlc_object_t *pObj, const char *pVariable,
410                            vlc_value_t oldVal, vlc_value_t newVal,
411                            void *pParam )
412 {
413     VlcProc *pThis = (VlcProc*)pParam;
414
415     // Update the stream variable
416     playlist_t *p_playlist = (playlist_t*)pObj;
417     pThis->updateStreamName(p_playlist);
418
419     // Create a playtree notify command (for new style playtree)
420     CmdPlaytreeChanged *pCmdTree = new CmdPlaytreeChanged( pThis->getIntf() );
421
422     // Push the command in the asynchronous command queue
423     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
424     pQueue->push( CmdGenericPtr( pCmdTree ) );
425
426     return VLC_SUCCESS;
427 }
428
429
430 int VlcProc::onIntfShow( vlc_object_t *pObj, const char *pVariable,
431                          vlc_value_t oldVal, vlc_value_t newVal,
432                          void *pParam )
433 {
434     if (newVal.i_int)
435     {
436         VlcProc *pThis = (VlcProc*)pParam;
437
438         // Create a raise all command
439         CmdRaiseAll *pCmd = new CmdRaiseAll( pThis->getIntf(),
440             pThis->getIntf()->p_sys->p_theme->getWindowManager() );
441
442         // Push the command in the asynchronous command queue
443         AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
444         pQueue->push( CmdGenericPtr( pCmd ) );
445     }
446
447     return VLC_SUCCESS;
448 }
449
450
451 int VlcProc::onItemChange( vlc_object_t *pObj, const char *pVariable,
452                            vlc_value_t oldVal, vlc_value_t newVal,
453                            void *pParam )
454 {
455     VlcProc *pThis = (VlcProc*)pParam;
456
457     // Update the stream variable
458     playlist_t *p_playlist = (playlist_t*)pObj;
459     pThis->updateStreamName(p_playlist);
460
461     // Create a playtree notify command
462     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
463                                                          newVal.i_int );
464
465     // Push the command in the asynchronous command queue
466     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
467     pQueue->push( CmdGenericPtr( pCmdTree ), true );
468
469     return VLC_SUCCESS;
470 }
471
472 int VlcProc::onItemAppend( vlc_object_t *pObj, const char *pVariable,
473                            vlc_value_t oldVal, vlc_value_t newVal,
474                            void *pParam )
475 {
476     VlcProc *pThis = (VlcProc*)pParam;
477
478     playlist_add_t *p_add = (playlist_add_t*)malloc( sizeof(
479                                                 playlist_add_t ) ) ;
480
481     memcpy( p_add, newVal.p_address, sizeof( playlist_add_t ) ) ;
482
483     CmdGenericPtr ptrTree;
484     CmdPlaytreeAppend *pCmdTree = new CmdPlaytreeAppend( pThis->getIntf(),
485                                                              p_add );
486     ptrTree = CmdGenericPtr( pCmdTree );
487
488     // Push the command in the asynchronous command queue
489     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
490     pQueue->push( ptrTree , false );
491
492     return VLC_SUCCESS;
493 }
494
495 int VlcProc::onItemDelete( vlc_object_t *pObj, const char *pVariable,
496                            vlc_value_t oldVal, vlc_value_t newVal,
497                            void *pParam )
498 {
499     VlcProc *pThis = (VlcProc*)pParam;
500
501     int i_id = newVal.i_int;
502
503     CmdGenericPtr ptrTree;
504     CmdPlaytreeDelete *pCmdTree = new CmdPlaytreeDelete( pThis->getIntf(),
505                                                          i_id);
506     ptrTree = CmdGenericPtr( pCmdTree );
507
508     // Push the command in the asynchronous command queue
509     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
510     pQueue->push( ptrTree , false );
511
512     return VLC_SUCCESS;
513 }
514
515
516 int VlcProc::onPlaylistChange( vlc_object_t *pObj, const char *pVariable,
517                                vlc_value_t oldVal, vlc_value_t newVal,
518                                void *pParam )
519 {
520     VlcProc *pThis = (VlcProc*)pParam;
521
522     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
523
524     // Update the stream variable
525     playlist_t *p_playlist = (playlist_t*)pObj;
526     pThis->updateStreamName(p_playlist);
527
528     // Create two playtree notify commands: one for old item, one for new
529     CmdPlaytreeUpdate *pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(),
530                                                          oldVal.i_int );
531     pQueue->push( CmdGenericPtr( pCmdTree ) , true );
532     pCmdTree = new CmdPlaytreeUpdate( pThis->getIntf(), newVal.i_int );
533     pQueue->push( CmdGenericPtr( pCmdTree ) , true );
534
535     return VLC_SUCCESS;
536 }
537
538
539 int VlcProc::onSkinToLoad( vlc_object_t *pObj, const char *pVariable,
540                            vlc_value_t oldVal, vlc_value_t newVal,
541                            void *pParam )
542 {
543     VlcProc *pThis = (VlcProc*)pParam;
544
545     // Create a playlist notify command
546     CmdChangeSkin *pCmd =
547         new CmdChangeSkin( pThis->getIntf(), newVal.psz_string );
548
549     // Push the command in the asynchronous command queue
550     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
551     pQueue->push( CmdGenericPtr( pCmd ) );
552
553     return VLC_SUCCESS;
554 }
555
556 int VlcProc::onInteraction( vlc_object_t *pObj, const char *pVariable,
557                             vlc_value_t oldVal, vlc_value_t newVal,
558                             void *pParam )
559 {
560     VlcProc *pThis = (VlcProc*)pParam;
561     interaction_dialog_t *p_dialog = (interaction_dialog_t *)(newVal.p_address);
562
563     CmdInteraction *pCmd = new CmdInteraction( pThis->getIntf(), p_dialog );
564     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
565     pQueue->push( CmdGenericPtr( pCmd ) );
566     return VLC_SUCCESS;
567 }
568
569
570 void VlcProc::updateStreamName( playlist_t *p_playlist )
571 {
572     if( p_playlist && p_playlist->p_input )
573     {
574         // Get playlist item information
575         input_item_t *pItem = input_GetItem(p_playlist->p_input);
576
577         VarText &rStreamName = getStreamNameVar();
578         VarText &rStreamURI = getStreamURIVar();
579         // XXX: we should not need to access p_input->psz_source directly, a
580         // getter should be provided by VLC core
581         string name = pItem->psz_name;
582         // XXX: This should be done in VLC core, not here...
583         // Remove path information if any
584         OSFactory *pFactory = OSFactory::instance( getIntf() );
585         string::size_type pos = name.rfind( pFactory->getDirSeparator() );
586         if( pos != string::npos )
587         {
588             name = name.substr( pos + 1, name.size() - pos + 1 );
589         }
590         UString srcName( getIntf(), name.c_str() );
591         UString srcURI( getIntf(), pItem->psz_uri );
592
593        // Create commands to update the stream variables
594         CmdSetText *pCmd1 = new CmdSetText( getIntf(), rStreamName, srcName );
595         CmdSetText *pCmd2 = new CmdSetText( getIntf(), rStreamURI, srcURI );
596         // Push the commands in the asynchronous command queue
597         AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
598         pQueue->push( CmdGenericPtr( pCmd1 ), false );
599         pQueue->push( CmdGenericPtr( pCmd2 ), false );
600     }
601 }
602
603
604 void *VlcProc::getWindow( intf_thread_t *pIntf, vout_thread_t *pVout,
605                           int *pXHint, int *pYHint,
606                           unsigned int *pWidthHint,
607                           unsigned int *pHeightHint )
608 {
609     VlcProc *pThis = pIntf->p_sys->p_vlcProc;
610     if( pThis->m_handleSet.empty() )
611     {
612         return NULL;
613     }
614     else
615     {
616         pThis->m_pVout = pVout;
617         // Get the window handle
618         void *pWindow = *pThis->m_handleSet.begin();
619         // Post a resize vout command
620         CmdResizeVout *pCmd = new CmdResizeVout( pThis->getIntf(), pWindow,
621                                                  *pWidthHint, *pHeightHint );
622         AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
623         pQueue->push( CmdGenericPtr( pCmd ) );
624         return pWindow;
625     }
626 }
627
628
629 void VlcProc::releaseWindow( intf_thread_t *pIntf, void *pWindow )
630 {
631     VlcProc *pThis = pIntf->p_sys->p_vlcProc;
632     pThis->m_pVout = NULL;
633 }
634
635
636 int VlcProc::controlWindow( intf_thread_t *pIntf, void *pWindow,
637                             int query, va_list args )
638 {
639     VlcProc *pThis = pIntf->p_sys->p_vlcProc;
640
641     switch( query )
642     {
643         case VOUT_SET_SIZE:
644         {
645             if( pThis->m_pVout )
646             {
647                 unsigned int i_width  = va_arg( args, unsigned int );
648                 unsigned int i_height = va_arg( args, unsigned int );
649                 if( !i_width ) i_width = pThis->m_pVout->i_window_width;
650                 if( !i_height ) i_height = pThis->m_pVout->i_window_height;
651
652                 // Post a resize vout command
653                 CmdResizeVout *pCmd =
654                     new CmdResizeVout( pThis->getIntf(), pWindow,
655                                        i_width, i_height );
656                 AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
657                 pQueue->push( CmdGenericPtr( pCmd ) );
658             }
659         }
660
661         default:
662             msg_Dbg( pIntf, "control query not supported" );
663             break;
664     }
665
666     return VLC_SUCCESS;
667 }
668
669
670 int VlcProc::onEqBandsChange( vlc_object_t *pObj, const char *pVariable,
671                               vlc_value_t oldVal, vlc_value_t newVal,
672                               void *pParam )
673 {
674     VlcProc *pThis = (VlcProc*)pParam;
675
676     // Post a set equalizer bands command
677     CmdSetEqBands *pCmd = new CmdSetEqBands( pThis->getIntf(),
678                                              pThis->m_varEqBands,
679                                              newVal.psz_string );
680     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
681     pQueue->push( CmdGenericPtr( pCmd ) );
682
683     return VLC_SUCCESS;
684 }
685
686
687 int VlcProc::onEqPreampChange( vlc_object_t *pObj, const char *pVariable,
688                                vlc_value_t oldVal, vlc_value_t newVal,
689                                void *pParam )
690 {
691     VlcProc *pThis = (VlcProc*)pParam;
692     EqualizerPreamp *pVarPreamp = (EqualizerPreamp*)(pThis->m_cVarEqPreamp.get());
693
694     // Post a set preamp command
695     CmdSetEqPreamp *pCmd = new CmdSetEqPreamp( pThis->getIntf(), *pVarPreamp,
696                                               (newVal.f_float + 20.0) / 40.0 );
697     AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
698     pQueue->push( CmdGenericPtr( pCmd ) );
699
700     return VLC_SUCCESS;
701 }
702