1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003-2019 the VideoLAN team
6 * Authors: Cyril Deguet <asmax@via.ecp.fr>
7 * Olivier Teulière <ipkiss@via.ecp.fr>
8 * Erwan Tulou <erwan10@videolan.org>
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 *****************************************************************************/
29 #include <vlc_common.h>
32 #include <vlc_player.h>
33 #include <vlc_playlist.h>
35 #include <vlc_strings.h>
37 #include "vlcproc.hpp"
38 #include "os_factory.hpp"
39 #include "os_loop.hpp"
40 #include "os_timer.hpp"
41 #include "var_manager.hpp"
42 #include "vout_manager.hpp"
43 #include "fsc_window.hpp"
45 #include "window_manager.hpp"
46 #include "../commands/async_queue.hpp"
47 #include "../commands/cmd_change_skin.hpp"
48 #include "../commands/cmd_show_window.hpp"
49 #include "../commands/cmd_quit.hpp"
50 #include "../commands/cmd_resize.hpp"
51 #include "../commands/cmd_vars.hpp"
52 #include "../commands/cmd_playtree.hpp"
53 #include "../commands/cmd_dialogs.hpp"
54 #include "../commands/cmd_audio.hpp"
55 #include "../commands/cmd_callbacks.hpp"
56 #include "../utils/var_bool.hpp"
57 #include "../utils/var_string.hpp"
62 void on_playlist_items_reset( vlc_playlist_t
*playlist
,
63 vlc_playlist_item_t
*const items
[],
64 size_t count
, void *data
)
66 (void)playlist
;(void)items
;(void)count
;
67 VlcProc
*pThis
= (VlcProc
*)data
;
68 CmdGeneric
*pCmdTree
= new CmdPlaytreeReset( pThis
->getIntf() );
70 // Push the command in the asynchronous command queue
71 AsyncQueue
*pQueue
= AsyncQueue::instance( pThis
->getIntf() );
72 pQueue
->push( CmdGenericPtr( pCmdTree
), true );
75 void on_playlist_items_added( vlc_playlist_t
*playlist
, size_t index
,
76 vlc_playlist_item_t
*const items
[],
77 size_t count
, void *data
)
79 (void)playlist
;(void)items
;
80 VlcProc
*pThis
= (VlcProc
*)data
;
81 for( size_t i
= 0; i
< count
; i
++ )
83 CmdGeneric
*pCmdTree
=
84 new CmdPlaytreeAppend( pThis
->getIntf(), index
+ i
);
86 // Push the command in the asynchronous command queue
87 AsyncQueue
*pQueue
= AsyncQueue::instance( pThis
->getIntf() );
88 pQueue
->push( CmdGenericPtr( pCmdTree
), false );
92 void on_playlist_items_removed( vlc_playlist_t
*playlist
, size_t index
,
93 size_t count
, void *data
)
96 VlcProc
*pThis
= (VlcProc
*)data
;
97 for( size_t i
= 0; i
< count
; i
++ )
99 CmdPlaytreeDelete
*pCmdTree
=
100 new CmdPlaytreeDelete( pThis
->getIntf(), index
+ i
);
102 // Push the command in the asynchronous command queue
103 AsyncQueue
*pQueue
= AsyncQueue::instance( pThis
->getIntf() );
104 pQueue
->push( CmdGenericPtr( pCmdTree
), false );
108 void on_playlist_items_updated( vlc_playlist_t
*playlist
, size_t index
,
109 vlc_playlist_item_t
*const items
[],
110 size_t count
, void *data
)
112 (void)playlist
;(void)items
;
113 VlcProc
*pThis
= (VlcProc
*)data
;
114 for( size_t i
= 0; i
< count
; i
++ )
116 CmdGeneric
*pCmd
= new CmdItemUpdate( pThis
->getIntf(), index
+ i
);
118 // Push the command in the asynchronous command queue
119 AsyncQueue
*pQueue
= AsyncQueue::instance( pThis
->getIntf() );
120 pQueue
->push( CmdGenericPtr( pCmd
), false );
124 void on_playlist_playback_repeat_changed( vlc_playlist_t
*playlist
,
125 enum vlc_playlist_playback_repeat repeat
, void *data
)
128 vlc_value_t val
= { .i_int
= repeat
};
129 VlcProc::onGenericCallback( "repeat", val
, data
);
132 void on_playlist_playback_order_changed( vlc_playlist_t
*playlist
,
133 enum vlc_playlist_playback_order order
, void *data
)
136 vlc_value_t val
= { .i_int
= order
};
137 VlcProc::onGenericCallback( "order", val
, data
);
140 void on_playlist_current_index_changed( vlc_playlist_t
*playlist
,
141 ssize_t index
, void *data
)
144 VlcProc
*pThis
= (VlcProc
*)data
;
145 msg_Dbg( pThis
->getIntf(), "current index changed %i", (int)index
);
146 CmdGeneric
*pCmd
= new CmdItemPlaying( pThis
->getIntf(), index
);
148 // Push the command in the asynchronous command queue
149 AsyncQueue
*pQueue
= AsyncQueue::instance( pThis
->getIntf() );
150 pQueue
->push( CmdGenericPtr( pCmd
), false );
153 void on_player_current_media_changed( vlc_player_t
*player
,
154 input_item_t
*media
, void *data
)
157 vlc_value_t val
= { .p_address
= media
};
158 if( media
) input_item_Hold( media
);
159 VlcProc::onGenericCallback( "current_media", val
, data
);
162 void on_player_state_changed( vlc_player_t
*player
,
163 enum vlc_player_state new_state
, void *data
)
166 vlc_value_t val
= { .i_int
= new_state
};
167 VlcProc::onGenericCallback( "state", val
, data
);
170 void on_player_rate_changed( vlc_player_t
*player
, float new_rate
, void *data
)
173 vlc_value_t val
= { .f_float
= new_rate
};
174 VlcProc::onGenericCallback( "rate", val
, data
);
177 void on_player_capabilities_changed( vlc_player_t
*player
,
178 int old_caps
, int new_caps
, void *data
)
180 (void)player
;(void)old_caps
;
181 vlc_value_t val
= { .i_int
= new_caps
};
182 VlcProc::onGenericCallback( "capabilities", val
, data
);
185 void on_player_position_changed( vlc_player_t
*player
, vlc_tick_t time
,
186 float pos
, void *data
)
188 (void)player
;(void)time
;
189 vlc_value_t val
= { .f_float
= pos
};
190 VlcProc::onGenericCallback( "position", val
, data
);
193 void on_player_track_selection_changed( vlc_player_t
*player
,
194 vlc_es_id_t
*unselected_id
, vlc_es_id_t
*selected_id
, void *data
)
198 const struct vlc_player_track
*track
;
202 track
= vlc_player_GetTrack( player
, selected_id
);
203 if( track
&& track
->fmt
.i_cat
== AUDIO_ES
)
206 VlcProc::onGenericCallback( "audio_es", val
, data
);
208 val
.i_int
= track
->fmt
.i_bitrate
;
209 VlcProc::onGenericCallback( "bit_rate", val
, data
);
211 val
.i_int
= track
->fmt
.audio
.i_rate
;
212 VlcProc::onGenericCallback( "sample_rate", val
, data
);
215 else if( unselected_id
)
217 track
= vlc_player_GetSelectedTrack( player
, AUDIO_ES
);
221 VlcProc::onGenericCallback( "audio_es", val
, data
);
224 VlcProc::onGenericCallback( "bit_rate", val
, data
);
225 VlcProc::onGenericCallback( "sample_rate", val
, data
);
230 void on_player_titles_changed( vlc_player_t
*player
,
231 vlc_player_title_list
*titles
, void *data
)
234 bool isDvd
= vlc_player_title_list_GetCount( titles
) > 0;
235 vlc_value_t val
= { .b_bool
= isDvd
};
236 VlcProc::onGenericCallback( "isDvd", val
, data
);
239 void on_player_recording_changed( vlc_player_t
*player
,
240 bool recording
, void *data
)
244 val
.b_bool
= recording
;
245 VlcProc::onGenericCallback( "recording", val
, data
);
248 void on_player_vout_changed( vlc_player_t
*player
,
249 enum vlc_player_vout_action action
, vout_thread_t
*vout
,
250 enum vlc_vout_order order
, vlc_es_id_t
*es_id
, void *data
)
252 (void)player
;(void)order
;(void)es_id
;
253 vlc_value_t val
= { .p_address
= NULL
};
254 if( vout
&& action
== VLC_PLAYER_VOUT_STARTED
)
256 val
.p_address
= vout
;
259 VlcProc::onGenericCallback( "vout", val
, data
);
262 void on_player_aout_volume_changed( audio_output
*aout
,
263 float volume
, void *data
)
266 vlc_value_t val
= { .f_float
= volume
};
267 VlcProc::onGenericCallback( "volume", val
, data
);
270 void on_player_aout_mute_changed( audio_output_t
*aout
, bool mute
, void *data
)
273 vlc_value_t val
= { .b_bool
= mute
};
274 VlcProc::onGenericCallback( "mute", val
, data
);
277 VlcProc
*VlcProc::instance( intf_thread_t
*pIntf
)
279 if( pIntf
->p_sys
->p_vlcProc
== NULL
)
281 pIntf
->p_sys
->p_vlcProc
= new VlcProc( pIntf
);
284 return pIntf
->p_sys
->p_vlcProc
;
288 void VlcProc::destroy( intf_thread_t
*pIntf
)
290 delete pIntf
->p_sys
->p_vlcProc
;
291 pIntf
->p_sys
->p_vlcProc
= NULL
;
294 #define SET_BOOL(m,v) ((VarBoolImpl*)(m).get())->set(v)
295 #define SET_STREAMTIME(m,v,b) ((StreamTime*)(m).get())->set(v,b)
296 #define SET_TEXT(m,v) ((VarText*)(m).get())->set(v)
297 #define SET_STRING(m,v) ((VarString*)(m).get())->set(v)
298 #define SET_VOLUME(m,v,b) ((Volume*)(m).get())->setVolume(v,b)
300 VlcProc::VlcProc( intf_thread_t
*pIntf
): SkinObject( pIntf
),
301 m_varEqBands( pIntf
), m_pVout( NULL
), m_pAout( NULL
),
302 mPlaylistListenerId( NULL
),
303 mPlayerListenerId( NULL
),
304 mPlayerAoutListenerId( NULL
),
305 mPlayerVoutListenerId( NULL
)
307 // Create and register VLC variables
308 VarManager
*pVarManager
= VarManager::instance( getIntf() );
310 #define REGISTER_VAR( var, type, name ) \
311 var = VariablePtr( new type( getIntf() ) ); \
312 pVarManager->registerVar( var, name );
313 REGISTER_VAR( m_cVarRandom
, VarBoolImpl
, "playlist.isRandom" )
314 REGISTER_VAR( m_cVarLoop
, VarBoolImpl
, "playlist.isLoop" )
315 REGISTER_VAR( m_cVarRepeat
, VarBoolImpl
, "playlist.isRepeat" )
316 REGISTER_VAR( m_cPlaytree
, Playtree
, "playtree" )
317 pVarManager
->registerVar( getPlaytreeVar().getPositionVarPtr(),
319 pVarManager
->registerVar( m_cVarRandom
, "playtree.isRandom" );
320 pVarManager
->registerVar( m_cVarLoop
, "playtree.isLoop" );
322 REGISTER_VAR( m_cVarPlaying
, VarBoolImpl
, "vlc.isPlaying" )
323 REGISTER_VAR( m_cVarStopped
, VarBoolImpl
, "vlc.isStopped" )
324 REGISTER_VAR( m_cVarPaused
, VarBoolImpl
, "vlc.isPaused" )
326 /* Input variables */
327 pVarManager
->registerVar( m_cVarRepeat
, "playtree.isRepeat" );
328 REGISTER_VAR( m_cVarTime
, StreamTime
, "time" )
329 REGISTER_VAR( m_cVarSeekable
, VarBoolImpl
, "vlc.isSeekable" )
330 REGISTER_VAR( m_cVarDvdActive
, VarBoolImpl
, "dvd.isActive" )
332 REGISTER_VAR( m_cVarRecordable
, VarBoolImpl
, "vlc.canRecord" )
333 REGISTER_VAR( m_cVarRecording
, VarBoolImpl
, "vlc.isRecording" )
336 REGISTER_VAR( m_cVarFullscreen
, VarBoolImpl
, "vlc.isFullscreen" )
337 REGISTER_VAR( m_cVarHasVout
, VarBoolImpl
, "vlc.hasVout" )
340 REGISTER_VAR( m_cVarHasAudio
, VarBoolImpl
, "vlc.hasAudio" )
341 REGISTER_VAR( m_cVarVolume
, Volume
, "volume" )
342 REGISTER_VAR( m_cVarMute
, VarBoolImpl
, "vlc.isMute" )
343 REGISTER_VAR( m_cVarEqualizer
, VarBoolImpl
, "equalizer.isEnabled" )
344 REGISTER_VAR( m_cVarEqPreamp
, EqualizerPreamp
, "equalizer.preamp" )
347 m_cVarSpeed
= VariablePtr( new VarText( getIntf(), false ) );
348 pVarManager
->registerVar( m_cVarSpeed
, "speed" );
349 SET_TEXT( m_cVarSpeed
, UString( getIntf(), "1") );
350 m_cVarStreamName
= VariablePtr( new VarText( getIntf(), false ) );
351 pVarManager
->registerVar( m_cVarStreamName
, "streamName" );
352 m_cVarStreamURI
= VariablePtr( new VarText( getIntf(), false ) );
353 pVarManager
->registerVar( m_cVarStreamURI
, "streamURI" );
354 m_cVarStreamBitRate
= VariablePtr( new VarText( getIntf(), false ) );
355 pVarManager
->registerVar( m_cVarStreamBitRate
, "bitrate" );
356 m_cVarStreamSampleRate
= VariablePtr( new VarText( getIntf(), false ) );
357 pVarManager
->registerVar( m_cVarStreamSampleRate
, "samplerate" );
358 m_cVarStreamArt
= VariablePtr( new VarString( getIntf() ) );
359 pVarManager
->registerVar( m_cVarStreamArt
, "streamArt" );
361 // Register the equalizer bands
362 for( int i
= 0; i
< EqualizerBands::kNbBands
; i
++)
364 std::stringstream ss
;
365 ss
<< "equalizer.band(" << i
<< ")";
366 pVarManager
->registerVar( m_varEqBands
.getBand( i
), ss
.str() );
369 static const struct vlc_playlist_callbacks playlist_cbs
= {
370 on_playlist_items_reset
,
371 on_playlist_items_added
,
372 NULL
, // on_playlist_items_moved,
373 on_playlist_items_removed
,
374 on_playlist_items_updated
,
375 on_playlist_playback_repeat_changed
,
376 on_playlist_playback_order_changed
,
377 on_playlist_current_index_changed
,
378 NULL
, // on_playlist_has_prev_changed
379 NULL
, // on_playlist_has_next_changed
382 static const struct vlc_player_cbs player_cbs
= {
383 on_player_current_media_changed
,
384 on_player_state_changed
,
385 NULL
, //on_player_error_changed,
386 NULL
, //on_player_buffering,
387 on_player_rate_changed
,
388 on_player_capabilities_changed
,
389 on_player_position_changed
,
390 NULL
, //on_player_length_changed,
391 NULL
, //on_player_track_list_changed,
392 on_player_track_selection_changed
,
393 NULL
, //on_player_track_delay_changed,
394 NULL
, //on_player_program_list_changed,
395 NULL
, //on_player_program_selection_changed,
396 on_player_titles_changed
,
397 NULL
, //on_player_title_selection_changed,
398 NULL
, //on_player_chapter_selection_changed,
399 NULL
, //on_player_teletext_menu_changed,
400 NULL
, //on_player_teletext_enabled_changed,
401 NULL
, //on_player_teletext_page_changed,
402 NULL
, //on_player_teletext_transparency_changed,
403 NULL
, //on_player_category_delay_changed,
404 NULL
, //on_player_associated_subs_fps_changed,
405 NULL
, //on_player_renderer_changed,
406 on_player_recording_changed
,
407 NULL
, //on_player_signal_changed,
408 NULL
, //on_player_stats_changed,
409 NULL
, //on_player_atobloop_changed,
410 NULL
, //on_player_media_stopped_action_changed,
411 NULL
, //on_player_media_meta_changed,
412 NULL
, //on_player_media_epg_changed,
413 NULL
, //on_player_subitems_changed,
414 on_player_vout_changed
,
415 NULL
, //on_player_corks_changed
416 NULL
, //on_playback_restore_queried
419 static const struct vlc_player_vout_cbs player_vout_cbs
= {
420 NULL
, // on_player_vout_fullscreen_changed,
421 NULL
, // on_player_vout_wallpaper_mode_changed
424 static const struct vlc_player_aout_cbs player_aout_cbs
= {
425 on_player_aout_volume_changed
,
426 on_player_aout_mute_changed
,
427 NULL
, //on_player_device_changed,
430 // Add various listeners
431 vlc_playlist_Lock( getPL() );
433 mPlaylistListenerId
=
434 vlc_playlist_AddListener( getPL(), &playlist_cbs
, this, true);
436 vlc_player_t
*player
= vlc_playlist_GetPlayer( getPL() );
439 vlc_player_AddListener( player
, &player_cbs
, this );
440 mPlayerAoutListenerId
=
441 vlc_player_aout_AddListener( player
, &player_aout_cbs
, this );
442 mPlayerVoutListenerId
=
443 vlc_player_vout_AddListener( player
, &player_vout_cbs
, this );
445 vlc_playlist_Unlock( getPL() );
448 // The object variable callbacks are called from other VLC threads,
449 // so they must put commands in the queue and NOT do anything else
450 // (X11 calls are not reentrant)
453 var_AddCallback( vlc_object_instance(getIntf()), "intf-toggle-fscontrol",
454 genericCallback
, this );
456 // initialize variables refering to libvlc and playlist objects
465 var_DelCallback( m_pVout
, "mouse-moved",
466 genericCallback
, this );
467 vout_Release( m_pVout
);
472 var_DelCallback( m_pAout
, "audio-filter", genericCallback
, this );
473 var_DelCallback( m_pAout
, "equalizer-bands",
474 EqBandsCallback
, this );
475 var_DelCallback( m_pAout
, "equalizer-preamp",
476 EqPreampCallback
, this );
477 aout_Release( m_pAout
);
481 var_DelCallback( vlc_object_instance(getIntf()), "intf-toggle-fscontrol",
482 genericCallback
, this );
484 // Remove various listeners
485 vlc_playlist_Lock( getPL() );
487 vlc_playlist_RemoveListener( getPL(), mPlaylistListenerId
);
489 vlc_player_t
*player
= vlc_playlist_GetPlayer( getPL() );
490 vlc_player_RemoveListener( player
, mPlayerListenerId
);
491 vlc_player_aout_RemoveListener( player
, mPlayerAoutListenerId
);
492 vlc_player_vout_RemoveListener( player
, mPlayerVoutListenerId
);
494 vlc_playlist_Unlock( getPL() );
497 int VlcProc::genericCallback( vlc_object_t
*pObj
, const char *pVariable
,
498 vlc_value_t oldVal
, vlc_value_t newVal
,
501 (void)pObj
; (void)oldVal
;
502 onGenericCallback( pVariable
, newVal
, pParam
);
507 int VlcProc::EqBandsCallback( vlc_object_t
*pObj
, const char *pVariable
,
508 vlc_value_t oldVal
, vlc_value_t newVal
,
511 (void)pObj
; (void)pVariable
; (void)oldVal
;
512 VlcProc
*pThis
= (VlcProc
*)pParam
;
514 // Post a set equalizer bands command
515 CmdSetEqBands
*pCmd
= new CmdSetEqBands( pThis
->getIntf(),
518 AsyncQueue
*pQueue
= AsyncQueue::instance( pThis
->getIntf() );
519 pQueue
->push( CmdGenericPtr( pCmd
) );
524 int VlcProc::EqPreampCallback( vlc_object_t
*pObj
, const char *pVariable
,
525 vlc_value_t oldVal
, vlc_value_t newVal
,
528 (void)pObj
; (void)pVariable
; (void)oldVal
;
529 VlcProc
*pThis
= (VlcProc
*)pParam
;
530 EqualizerPreamp
*pVarPreamp
= (EqualizerPreamp
*)(pThis
->m_cVarEqPreamp
.get());
532 // Post a set preamp command
533 CmdSetEqPreamp
*pCmd
= new CmdSetEqPreamp( pThis
->getIntf(), *pVarPreamp
,
534 (newVal
.f_float
+ 20.0) / 40.0 );
535 AsyncQueue
*pQueue
= AsyncQueue::instance( pThis
->getIntf() );
536 pQueue
->push( CmdGenericPtr( pCmd
) );
541 #define ADD_CALLBACK_ENTRY( var, func, remove ) \
542 if( strcmp( pVariable, var ) == 0 ){\
543 cb = &VlcProc::func; \
548 void VlcProc::onGenericCallback( const char *pVariable
,
549 vlc_value_t newVal
, void *data
)
551 VlcProc
*pThis
= (VlcProc
*)data
;
552 AsyncQueue
*pQueue
= AsyncQueue::instance( pThis
->getIntf() );
553 std::string label
= pVariable
;
554 void (VlcProc::*cb
)(vlc_value_t
);
557 ADD_CALLBACK_ENTRY( "current_media", on_current_media_changed
, false )
558 ADD_CALLBACK_ENTRY( "repeat", on_repeat_changed
, false )
559 ADD_CALLBACK_ENTRY( "order", on_order_changed
, false )
560 ADD_CALLBACK_ENTRY( "volume", on_volume_changed
, true )
561 ADD_CALLBACK_ENTRY( "mute", on_mute_changed
, false )
562 ADD_CALLBACK_ENTRY( "random", on_random_changed
, false )
564 ADD_CALLBACK_ENTRY( "state", on_state_changed
, false )
565 ADD_CALLBACK_ENTRY( "rate", on_rate_changed
, true )
566 ADD_CALLBACK_ENTRY( "capabilities", on_capabilities_changed
, true )
567 ADD_CALLBACK_ENTRY( "position", on_position_changed
, true )
568 ADD_CALLBACK_ENTRY( "audio_es", on_audio_es_changed
, false )
569 ADD_CALLBACK_ENTRY( "bit_rate", on_bit_rate_changed
, false )
570 ADD_CALLBACK_ENTRY( "sample_rate", on_sample_rate_changed
, false )
571 ADD_CALLBACK_ENTRY( "isDvd", on_isDvd_changed
, false )
572 ADD_CALLBACK_ENTRY( "recording", on_recording_changed
, true )
573 ADD_CALLBACK_ENTRY( "vout", on_vout_changed
, false )
575 ADD_CALLBACK_ENTRY( "intf-toggle-fscontrol", on_intf_show_changed
, false )
577 ADD_CALLBACK_ENTRY( "mouse-moved", on_mouse_moved_changed
,false )
578 ADD_CALLBACK_ENTRY( "audio-filter", on_audio_filter_changed
, false )
579 vlc_assert_unreachable();
581 CmdGeneric
*pCmd
= new CmdCallback( pThis
->getIntf(), newVal
, cb
, label
);
583 pQueue
->push( CmdGenericPtr( pCmd
), bRemove
);
586 #undef ADD_CALLBACK_ENTRY
588 void VlcProc::on_bit_rate_changed( vlc_value_t newVal
)
590 int bitrate
= newVal
.i_int
/ 1000;
592 SET_TEXT( m_cVarStreamBitRate
, UString::fromInt( getIntf(), bitrate
) );
594 SET_TEXT( m_cVarStreamBitRate
, UString( getIntf(), "") );
597 void VlcProc::on_sample_rate_changed( vlc_value_t newVal
)
599 int sampleRate
= newVal
.i_int
/ 1000;
600 if( sampleRate
!= 0 )
601 SET_TEXT( m_cVarStreamSampleRate
, UString::fromInt(getIntf(),sampleRate
) );
603 SET_TEXT( m_cVarStreamSampleRate
, UString( getIntf(), "") );
606 void VlcProc::on_random_changed( vlc_value_t newVal
)
608 SET_BOOL( m_cVarRandom
, newVal
.b_bool
);
611 void VlcProc::on_loop_changed( vlc_value_t newVal
)
613 SET_BOOL( m_cVarLoop
, newVal
.b_bool
);
616 void VlcProc::on_current_media_changed( vlc_value_t newVal
)
618 input_item_t
* pItem
= static_cast<input_item_t
*>(newVal
.p_address
);
619 msg_Dbg(getIntf(),"current media changed %p", pItem
);
622 // Update short name (as defined by --input-title-format)
623 char *psz_name
= NULL
;
624 char *psz_fmt
= var_InheritString( getIntf(), "input-title-format" );
625 if( psz_fmt
!= NULL
)
627 vlc_playlist_Lock( getPL() );
628 vlc_player_t
* player
= vlc_playlist_GetPlayer( getPL() );
629 psz_name
= vlc_strfplayer( player
, NULL
, psz_fmt
);
630 vlc_playlist_Unlock( getPL() );
634 SET_TEXT( m_cVarStreamName
, UString( getIntf(),
635 psz_name
? psz_name
: "" ) );
638 // Update local path (if possible) or full uri
639 char *psz_uri
= input_item_GetURI( pItem
);
640 char *psz_path
= vlc_uri2path( psz_uri
);
641 char *psz_save
= psz_path
? psz_path
: psz_uri
;
642 SET_TEXT( m_cVarStreamURI
, UString( getIntf(), psz_save
) );
647 char *psz_art
= input_item_GetArtURL( pItem
);
648 SET_STRING( m_cVarStreamArt
, std::string( psz_art
? psz_art
: "" ) );
651 input_item_Release( pItem
);
655 void VlcProc::on_repeat_changed( vlc_value_t newVal
)
657 enum vlc_playlist_playback_repeat repeat
=
658 (enum vlc_playlist_playback_repeat
)newVal
.i_int
;
660 if( repeat
== VLC_PLAYLIST_PLAYBACK_REPEAT_ALL
)
662 SET_BOOL( m_cVarRepeat
, false );
663 SET_BOOL( m_cVarLoop
, true );
665 else if( repeat
== VLC_PLAYLIST_PLAYBACK_REPEAT_CURRENT
)
667 SET_BOOL( m_cVarLoop
, false );
668 SET_BOOL( m_cVarRepeat
, true );
672 SET_BOOL( m_cVarRepeat
, false );
673 SET_BOOL( m_cVarLoop
, false );
677 void VlcProc::on_order_changed( vlc_value_t newVal
)
679 enum vlc_playlist_playback_order order
=
680 (enum vlc_playlist_playback_order
)newVal
.i_int
;
682 SET_BOOL( m_cVarRandom
, (order
== VLC_PLAYLIST_PLAYBACK_ORDER_RANDOM
) );
685 void VlcProc::on_volume_changed( vlc_value_t newVal
)
687 SET_VOLUME( m_cVarVolume
, newVal
.f_float
, false );
690 void VlcProc::on_mute_changed( vlc_value_t newVal
)
692 SET_BOOL( m_cVarMute
, newVal
.b_bool
);
695 void VlcProc::on_recording_changed( vlc_value_t newVal
)
697 SET_BOOL( m_cVarRecording
, newVal
.b_bool
);
700 void VlcProc::on_state_changed( vlc_value_t newVal
)
702 enum vlc_player_state state
= (enum vlc_player_state
)newVal
.i_int
;
703 msg_Dbg( getIntf(),"playlist state changed : %i", state
);
705 bool stopped
= ( state
== VLC_PLAYER_STATE_STOPPED
);
706 bool playing
= ( state
== VLC_PLAYER_STATE_STARTED
||
707 state
== VLC_PLAYER_STATE_PLAYING
||
708 state
== VLC_PLAYER_STATE_STOPPING
);
709 bool paused
= ( state
== VLC_PLAYER_STATE_PAUSED
);
711 SET_BOOL( m_cVarStopped
, stopped
);
712 SET_BOOL( m_cVarPlaying
, playing
);
713 SET_BOOL( m_cVarPaused
, paused
);
715 // extra cleaning done
716 if( state
== VLC_PLAYER_STATE_STOPPED
)
720 void VlcProc::on_rate_changed( vlc_value_t newVal
)
722 float rate
= newVal
.f_float
;
724 if( asprintf( &buffer
, "%.3g", rate
) != -1 )
726 SET_TEXT( m_cVarSpeed
, UString( getIntf(), buffer
) );
731 void VlcProc::on_capabilities_changed( vlc_value_t newVal
)
733 int capabilities
= newVal
.i_int
;
734 SET_BOOL( m_cVarSeekable
, capabilities
& VLC_PLAYER_CAP_SEEK
);
737 void VlcProc::on_position_changed( vlc_value_t newVal
)
739 float pos
= newVal
.f_float
;
740 SET_STREAMTIME( m_cVarTime
, pos
, false );
743 void VlcProc::on_audio_es_changed( vlc_value_t newVal
)
745 SET_BOOL( m_cVarHasAudio
, newVal
.b_bool
);
748 void VlcProc::on_isDvd_changed( vlc_value_t newVal
)
750 SET_BOOL( m_cVarDvdActive
, newVal
.b_bool
);
753 void VlcProc::on_vout_changed( vlc_value_t newVal
)
755 vout_thread_t
* pVout
= (vout_thread_t
*)newVal
.p_address
;
756 SET_BOOL( m_cVarHasVout
, pVout
!= NULL
);
757 if( !pVout
|| pVout
== m_pVout
)
760 vout_Release( pVout
);
764 // release previous Vout
767 var_DelCallback( m_pVout
, "mouse-moved",
768 genericCallback
, this );
769 vout_Release( m_pVout
);
773 // keep new vout held and install callback
775 var_AddCallback( m_pVout
, "mouse-moved", genericCallback
, this );
778 void VlcProc::on_audio_filter_changed( vlc_value_t newVal
)
780 char *pFilters
= newVal
.psz_string
;
781 bool b_equalizer
= pFilters
&& strstr( pFilters
, "equalizer" );
782 SET_BOOL( m_cVarEqualizer
, b_equalizer
);
785 void VlcProc::on_intf_show_changed( vlc_value_t newVal
)
787 bool b_fullscreen
= getFullscreenVar().get();
793 // Create a raise all command
794 CmdRaiseAll
*pCmd
= new CmdRaiseAll( getIntf(),
795 getIntf()->p_sys
->p_theme
->getWindowManager() );
797 // Push the command in the asynchronous command queue
798 AsyncQueue
*pQueue
= AsyncQueue::instance( getIntf() );
799 pQueue
->push( CmdGenericPtr( pCmd
) );
804 VoutManager
* pVoutManager
= VoutManager::instance( getIntf() );
805 FscWindow
*pWin
= pVoutManager
->getFscWindow();
808 bool b_visible
= pWin
->getVisibleVar().get();
809 AsyncQueue
*pQueue
= AsyncQueue::instance( getIntf() );
813 CmdShowWindow
* pCmd
= new CmdShowWindow( getIntf(),
814 getIntf()->p_sys
->p_theme
->getWindowManager(),
816 pQueue
->push( CmdGenericPtr( pCmd
) );
820 CmdHideWindow
* pCmd
= new CmdHideWindow( getIntf(),
821 getIntf()->p_sys
->p_theme
->getWindowManager(),
823 pQueue
->push( CmdGenericPtr( pCmd
) );
829 void VlcProc::on_mouse_moved_changed( vlc_value_t newVal
)
832 FscWindow
* pFscWindow
= VoutManager::instance( getIntf() )->getFscWindow();
834 pFscWindow
->onMouseMoved();
837 void VlcProc::reset_input()
839 SET_BOOL( m_cVarSeekable
, false );
840 SET_BOOL( m_cVarRecordable
, true );
841 SET_BOOL( m_cVarRecording
, false );
842 SET_BOOL( m_cVarDvdActive
, false );
843 SET_BOOL( m_cVarHasAudio
, false );
844 SET_BOOL( m_cVarHasVout
, false );
846 SET_STREAMTIME( m_cVarTime
, 0, false );
847 SET_TEXT( m_cVarStreamName
, UString( getIntf(), "") );
848 SET_TEXT( m_cVarStreamURI
, UString( getIntf(), "") );
849 SET_STRING( m_cVarStreamArt
, std::string( "" ) );
850 SET_TEXT( m_cVarStreamBitRate
, UString( getIntf(), "") );
851 SET_TEXT( m_cVarStreamSampleRate
, UString( getIntf(), "") );
854 void VlcProc::init_variables()
856 vlc_player_t
*player
= vlc_playlist_GetPlayer( getPL() );
858 float volume
= vlc_player_aout_GetVolume( player
);
859 SET_VOLUME( m_cVarVolume
, volume
, false );
861 bool mute
= vlc_player_aout_IsMuted( player
) == 1;
862 SET_BOOL( m_cVarMute
, mute
);
864 SET_BOOL( m_cVarStopped
, true );
868 void VlcProc::init_equalizer()
870 //audio_output_t* pAout = playlist_GetAout( getPL() );
871 vlc_player_t
* player
= vlc_playlist_GetPlayer( getPL() );
872 audio_output_t
* pAout
= vlc_player_aout_Hold( player
);
875 if( !var_Type( pAout
, "equalizer-bands" ) )
876 var_Create( pAout
, "equalizer-bands",
877 VLC_VAR_STRING
| VLC_VAR_DOINHERIT
);
878 if( !var_Type( pAout
, "equalizer-preamp" ) )
879 var_Create( pAout
, "equalizer-preamp",
880 VLC_VAR_FLOAT
| VLC_VAR_DOINHERIT
);
882 // New Aout (addCallbacks)
883 var_AddCallback( pAout
, "audio-filter", genericCallback
, this );
884 var_AddCallback( pAout
, "equalizer-bands",
885 EqBandsCallback
, this );
886 var_AddCallback( pAout
, "equalizer-preamp",
887 EqPreampCallback
, this );
893 // is equalizer enabled ?
894 char *pFilters
= pAout
?
895 var_GetNonEmptyString( pAout
, "audio-filter" ) :
896 var_InheritString( getIntf(), "audio-filter" );
897 bool b_equalizer
= pFilters
&& strstr( pFilters
, "equalizer" );
899 SET_BOOL( m_cVarEqualizer
, b_equalizer
);
901 // retrieve initial bands
902 char* bands
= pAout
?
903 var_GetString( pAout
, "equalizer-bands" ) :
904 var_InheritString( getIntf(), "equalizer-bands" );
907 m_varEqBands
.set( bands
);
911 // retrieve initial preamp
912 float preamp
= pAout
?
913 var_GetFloat( pAout
, "equalizer-preamp" ) :
914 var_InheritFloat( getIntf(), "equalizer-preamp" );
915 EqualizerPreamp
*pVarPreamp
= (EqualizerPreamp
*)m_cVarEqPreamp
.get();
916 pVarPreamp
->set( (preamp
+ 20.0) / 40.0 );
919 void VlcProc::setFullscreenVar( bool b_fullscreen
)
921 SET_BOOL( m_cVarFullscreen
, b_fullscreen
);
925 #undef SET_STREAMTIME