| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
#ifdef HAVE_CONFIG_H |
|---|
| 26 |
# include "config.h" |
|---|
| 27 |
#endif |
|---|
| 28 |
|
|---|
| 29 |
#include "qt4.hpp" |
|---|
| 30 |
#include "input_manager.hpp" |
|---|
| 31 |
#include "dialogs_provider.hpp" |
|---|
| 32 |
|
|---|
| 33 |
static int ChangeSPU( vlc_object_t *p_this, const char *var, vlc_value_t o, |
|---|
| 34 |
vlc_value_t n, void *param ); |
|---|
| 35 |
|
|---|
| 36 |
static int ChangeTeletext( vlc_object_t *p_this, const char *var, vlc_value_t o, |
|---|
| 37 |
vlc_value_t n, void *param ); |
|---|
| 38 |
|
|---|
| 39 |
static int ItemChanged( vlc_object_t *, const char *, |
|---|
| 40 |
vlc_value_t, vlc_value_t, void * ); |
|---|
| 41 |
static int PLItemChanged( vlc_object_t *, const char *, |
|---|
| 42 |
vlc_value_t, vlc_value_t, void * ); |
|---|
| 43 |
static int InterfaceChanged( vlc_object_t *, const char *, |
|---|
| 44 |
vlc_value_t, vlc_value_t, void * ); |
|---|
| 45 |
static int InterfaceVoutChanged( vlc_object_t *, const char *, |
|---|
| 46 |
vlc_value_t, vlc_value_t, void * ); |
|---|
| 47 |
static int ItemStateChanged( vlc_object_t *, const char *, |
|---|
| 48 |
vlc_value_t, vlc_value_t, void * ); |
|---|
| 49 |
static int ItemRateChanged( vlc_object_t *, const char *, |
|---|
| 50 |
vlc_value_t, vlc_value_t, void * ); |
|---|
| 51 |
static int ItemTitleChanged( vlc_object_t *, const char *, |
|---|
| 52 |
vlc_value_t, vlc_value_t, void * ); |
|---|
| 53 |
static int VolumeChanged( vlc_object_t *, const char *, |
|---|
| 54 |
vlc_value_t, vlc_value_t, void * ); |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) : |
|---|
| 64 |
QObject( parent ), p_intf( _p_intf ) |
|---|
| 65 |
{ |
|---|
| 66 |
i_old_playing_status = END_S; |
|---|
| 67 |
old_name = ""; |
|---|
| 68 |
artUrl = ""; |
|---|
| 69 |
p_input = NULL; |
|---|
| 70 |
i_rate = 0; |
|---|
| 71 |
i_input_id = 0; |
|---|
| 72 |
b_video = false; |
|---|
| 73 |
b_transparentTelextext = false; |
|---|
| 74 |
} |
|---|
| 75 |
|
|---|
| 76 |
InputManager::~InputManager() |
|---|
| 77 |
{ |
|---|
| 78 |
delInput(); |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
void InputManager::setInput( input_thread_t *_p_input ) |
|---|
| 85 |
{ |
|---|
| 86 |
delInput(); |
|---|
| 87 |
p_input = _p_input; |
|---|
| 88 |
if( p_input && !( p_input->b_dead || !vlc_object_alive (p_input) ) ) |
|---|
| 89 |
{ |
|---|
| 90 |
vlc_object_hold( p_input ); |
|---|
| 91 |
emit statusChanged( PLAYING_S ); |
|---|
| 92 |
UpdateMeta(); |
|---|
| 93 |
UpdateArt(); |
|---|
| 94 |
UpdateSPU(); |
|---|
| 95 |
UpdateTeletext(); |
|---|
| 96 |
UpdateNavigation(); |
|---|
| 97 |
UpdateVout(); |
|---|
| 98 |
addCallbacks(); |
|---|
| 99 |
i_input_id = input_GetItem( p_input )->i_id; |
|---|
| 100 |
} |
|---|
| 101 |
else |
|---|
| 102 |
{ |
|---|
| 103 |
p_input = NULL; |
|---|
| 104 |
i_input_id = 0; |
|---|
| 105 |
emit rateChanged( INPUT_RATE_DEFAULT ); |
|---|
| 106 |
} |
|---|
| 107 |
} |
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
void InputManager::delInput() |
|---|
| 113 |
{ |
|---|
| 114 |
if( p_input ) |
|---|
| 115 |
{ |
|---|
| 116 |
delCallbacks(); |
|---|
| 117 |
i_old_playing_status = END_S; |
|---|
| 118 |
i_input_id = 0; |
|---|
| 119 |
old_name = ""; |
|---|
| 120 |
artUrl = ""; |
|---|
| 121 |
b_video = false; |
|---|
| 122 |
emit positionUpdated( -1.0, 0 ,0 ); |
|---|
| 123 |
emit statusChanged( END_S ); |
|---|
| 124 |
emit nameChanged( "" ); |
|---|
| 125 |
emit artChanged( NULL ); |
|---|
| 126 |
emit rateChanged( INPUT_RATE_DEFAULT ); |
|---|
| 127 |
emit voutChanged( false ); |
|---|
| 128 |
vlc_object_release( p_input ); |
|---|
| 129 |
p_input = NULL; |
|---|
| 130 |
UpdateSPU(); |
|---|
| 131 |
UpdateTeletext(); |
|---|
| 132 |
} |
|---|
| 133 |
} |
|---|
| 134 |
|
|---|
| 135 |
|
|---|
| 136 |
void InputManager::addCallbacks() |
|---|
| 137 |
{ |
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
var_AddCallback( p_input, "state", ItemStateChanged, this ); |
|---|
| 148 |
|
|---|
| 149 |
var_AddCallback( p_input, "spu-es", ChangeSPU, this ); |
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
var_AddCallback( p_input, "video-es", ItemStateChanged, this ); |
|---|
| 153 |
|
|---|
| 154 |
var_AddCallback( p_input, "teletext-es", ChangeTeletext, this ); |
|---|
| 155 |
|
|---|
| 156 |
var_AddCallback( p_input, "rate-change", ItemRateChanged, this ); |
|---|
| 157 |
|
|---|
| 158 |
var_AddCallback( p_input, "title", ItemTitleChanged, this ); |
|---|
| 159 |
|
|---|
| 160 |
var_AddCallback( p_input, "intf-change", InterfaceChanged, this ); |
|---|
| 161 |
|
|---|
| 162 |
var_AddCallback( p_input, "intf-change-vout", InterfaceVoutChanged, this ); |
|---|
| 163 |
} |
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
void InputManager::delCallbacks() |
|---|
| 167 |
{ |
|---|
| 168 |
var_DelCallback( p_input, "spu-es", ChangeSPU, this ); |
|---|
| 169 |
var_DelCallback( p_input, "video-es", ItemStateChanged, this ); |
|---|
| 170 |
var_DelCallback( p_input, "teletext-es", ChangeTeletext, this ); |
|---|
| 171 |
var_DelCallback( p_input, "state", ItemStateChanged, this ); |
|---|
| 172 |
var_DelCallback( p_input, "rate-change", ItemRateChanged, this ); |
|---|
| 173 |
var_DelCallback( p_input, "title", ItemTitleChanged, this ); |
|---|
| 174 |
var_DelCallback( p_input, "intf-change", InterfaceChanged, this ); |
|---|
| 175 |
var_DelCallback( p_input, "intf-change-vout", InterfaceVoutChanged, this ); |
|---|
| 176 |
} |
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 |
void InputManager::customEvent( QEvent *event ) |
|---|
| 180 |
{ |
|---|
| 181 |
int type = event->type(); |
|---|
| 182 |
IMEvent *ple = static_cast<IMEvent *>(event); |
|---|
| 183 |
|
|---|
| 184 |
if ( type != PositionUpdate_Type && |
|---|
| 185 |
type != ItemChanged_Type && |
|---|
| 186 |
type != ItemRateChanged_Type && |
|---|
| 187 |
type != ItemTitleChanged_Type && |
|---|
| 188 |
type != ItemSpuChanged_Type && |
|---|
| 189 |
type != ItemTeletextChanged_Type && |
|---|
| 190 |
type != ItemStateChanged_Type && |
|---|
| 191 |
type != InterfaceVoutUpdate_Type ) |
|---|
| 192 |
return; |
|---|
| 193 |
|
|---|
| 194 |
if( type == ItemStateChanged_Type ) |
|---|
| 195 |
{ |
|---|
| 196 |
UpdateNavigation(); |
|---|
| 197 |
UpdateTeletext(); |
|---|
| 198 |
} |
|---|
| 199 |
|
|---|
| 200 |
if( !hasInput() ) return; |
|---|
| 201 |
|
|---|
| 202 |
if( ( type != PositionUpdate_Type && |
|---|
| 203 |
type != ItemRateChanged_Type && |
|---|
| 204 |
type != ItemSpuChanged_Type && |
|---|
| 205 |
type != ItemTeletextChanged_Type && |
|---|
| 206 |
type != ItemStateChanged_Type && |
|---|
| 207 |
type != InterfaceVoutUpdate_Type |
|---|
| 208 |
) |
|---|
| 209 |
&& ( i_input_id != ple->i_id ) ) |
|---|
| 210 |
return; |
|---|
| 211 |
|
|---|
| 212 |
if( type != PositionUpdate_Type ) |
|---|
| 213 |
msg_Dbg( p_intf, "New Event: type %i", type ); |
|---|
| 214 |
|
|---|
| 215 |
|
|---|
| 216 |
switch( type ) |
|---|
| 217 |
{ |
|---|
| 218 |
case PositionUpdate_Type: |
|---|
| 219 |
UpdatePosition(); |
|---|
| 220 |
break; |
|---|
| 221 |
case ItemChanged_Type: |
|---|
| 222 |
UpdateMeta(); |
|---|
| 223 |
UpdateStatus(); |
|---|
| 224 |
UpdateArt(); |
|---|
| 225 |
break; |
|---|
| 226 |
case ItemStateChanged_Type: |
|---|
| 227 |
UpdateStatus(); |
|---|
| 228 |
UpdateNavigation(); |
|---|
| 229 |
UpdateMeta(); |
|---|
| 230 |
break; |
|---|
| 231 |
case ItemTitleChanged_Type: |
|---|
| 232 |
UpdateNavigation(); |
|---|
| 233 |
UpdateMeta(); |
|---|
| 234 |
break; |
|---|
| 235 |
case ItemRateChanged_Type: |
|---|
| 236 |
UpdateRate(); |
|---|
| 237 |
break; |
|---|
| 238 |
case ItemSpuChanged_Type: |
|---|
| 239 |
UpdateSPU(); |
|---|
| 240 |
break; |
|---|
| 241 |
case ItemTeletextChanged_Type: |
|---|
| 242 |
UpdateTeletext(); |
|---|
| 243 |
break; |
|---|
| 244 |
case InterfaceVoutUpdate_Type: |
|---|
| 245 |
UpdateVout(); |
|---|
| 246 |
break; |
|---|
| 247 |
} |
|---|
| 248 |
} |
|---|
| 249 |
|
|---|
| 250 |
void InputManager::UpdatePosition() |
|---|
| 251 |
{ |
|---|
| 252 |
|
|---|
| 253 |
int i_length, i_time; |
|---|
| 254 |
float f_pos; |
|---|
| 255 |
i_length = var_GetTime( p_input , "length" ) / 1000000; |
|---|
| 256 |
i_time = var_GetTime( p_input , "time") / 1000000; |
|---|
| 257 |
f_pos = var_GetFloat( p_input , "position" ); |
|---|
| 258 |
emit positionUpdated( f_pos, i_time, i_length ); |
|---|
| 259 |
} |
|---|
| 260 |
|
|---|
| 261 |
void InputManager::UpdateNavigation() |
|---|
| 262 |
{ |
|---|
| 263 |
|
|---|
| 264 |
vlc_value_t val; val.i_int = 0; |
|---|
| 265 |
if( hasInput() ) |
|---|
| 266 |
var_Change( p_input, "title", VLC_VAR_CHOICESCOUNT, &val, NULL ); |
|---|
| 267 |
if( val.i_int > 0 ) |
|---|
| 268 |
{ |
|---|
| 269 |
val.i_int = 0; |
|---|
| 270 |
var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &val, NULL ); |
|---|
| 271 |
emit navigationChanged( (val.i_int > 0) ? 1 : 2 ); |
|---|
| 272 |
} |
|---|
| 273 |
else |
|---|
| 274 |
{ |
|---|
| 275 |
emit navigationChanged( 0 ); |
|---|
| 276 |
} |
|---|
| 277 |
} |
|---|
| 278 |
|
|---|
| 279 |
void InputManager::UpdateStatus() |
|---|
| 280 |
{ |
|---|
| 281 |
|
|---|
| 282 |
vlc_value_t val; val.i_int = 0; |
|---|
| 283 |
var_Get( p_input, "state", &val ); |
|---|
| 284 |
if( i_old_playing_status != val.i_int ) |
|---|
| 285 |
{ |
|---|
| 286 |
i_old_playing_status = val.i_int; |
|---|
| 287 |
emit statusChanged( val.i_int ); |
|---|
| 288 |
} |
|---|
| 289 |
} |
|---|
| 290 |
|
|---|
| 291 |
void InputManager::UpdateRate() |
|---|
| 292 |
{ |
|---|
| 293 |
|
|---|
| 294 |
int i_new_rate = var_GetInteger( p_input, "rate"); |
|---|
| 295 |
if( i_new_rate != i_rate ) |
|---|
| 296 |
{ |
|---|
| 297 |
i_rate = i_new_rate; |
|---|
| 298 |
|
|---|
| 299 |
emit rateChanged( i_rate ); |
|---|
| 300 |
} |
|---|
| 301 |
} |
|---|
| 302 |
|
|---|
| 303 |
void InputManager::UpdateMeta() |
|---|
| 304 |
{ |
|---|
| 305 |
|
|---|
| 306 |
QString text; |
|---|
| 307 |
|
|---|
| 308 |
|
|---|
| 309 |
char *psz_name = input_item_GetTitle( input_GetItem( p_input ) ); |
|---|
| 310 |
if( EMPTY_STR( psz_name ) ) |
|---|
| 311 |
{ |
|---|
| 312 |
free( psz_name ); |
|---|
| 313 |
psz_name = input_item_GetName( input_GetItem( p_input ) ); |
|---|
| 314 |
} |
|---|
| 315 |
|
|---|
| 316 |
|
|---|
| 317 |
char *psz_nowplaying = |
|---|
| 318 |
input_item_GetNowPlaying( input_GetItem( p_input ) ); |
|---|
| 319 |
if( !EMPTY_STR( psz_nowplaying ) ) |
|---|
| 320 |
{ |
|---|
| 321 |
text.sprintf( "%s - %s", psz_nowplaying, psz_name ); |
|---|
| 322 |
} |
|---|
| 323 |
else |
|---|
| 324 |
{ |
|---|
| 325 |
char *psz_artist = input_item_GetArtist( input_GetItem( p_input ) ); |
|---|
| 326 |
|
|---|
| 327 |
if( !EMPTY_STR( psz_artist ) ) |
|---|
| 328 |
text.sprintf( "%s - %s", psz_artist, psz_name ); |
|---|
| 329 |
else |
|---|
| 330 |
text.sprintf( "%s", psz_name ); |
|---|
| 331 |
|
|---|
| 332 |
free( psz_artist ); |
|---|
| 333 |
} |
|---|
| 334 |
|
|---|
| 335 |
free( psz_name ); |
|---|
| 336 |
free( psz_nowplaying ); |
|---|
| 337 |
|
|---|
| 338 |
|
|---|
| 339 |
if( text.isEmpty() ) |
|---|
| 340 |
{ |
|---|
| 341 |
psz_name = input_item_GetURI( input_GetItem( p_input ) ); |
|---|
| 342 |
text.sprintf( "%s", psz_name ); |
|---|
| 343 |
text = text.remove( 0, text.lastIndexOf( DIR_SEP ) + 1 ); |
|---|
| 344 |
free( psz_name ); |
|---|
| 345 |
} |
|---|
| 346 |
|
|---|
| 347 |
if( old_name != text ) |
|---|
| 348 |
{ |
|---|
| 349 |
emit nameChanged( text ); |
|---|
| 350 |
old_name=text; |
|---|
| 351 |
} |
|---|
| 352 |
} |
|---|
| 353 |
|
|---|
| 354 |
bool InputManager::hasAudio() |
|---|
| 355 |
{ |
|---|
| 356 |
if( hasInput() ) |
|---|
| 357 |
{ |
|---|
| 358 |
vlc_value_t val; |
|---|
| 359 |
var_Change( p_input, "audio-es", VLC_VAR_CHOICESCOUNT, &val, NULL ); |
|---|
| 360 |
return val.i_int > 0; |
|---|
| 361 |
} |
|---|
| 362 |
return false; |
|---|
| 363 |
} |
|---|
| 364 |
|
|---|
| 365 |
void InputManager::UpdateSPU() |
|---|
| 366 |
{ |
|---|
| 367 |
UpdateTeletext(); |
|---|
| 368 |
} |
|---|
| 369 |
|
|---|
| 370 |
void InputManager::UpdateTeletext() |
|---|
| 371 |
{ |
|---|
| 372 |
if( hasInput() ) |
|---|
| 373 |
telexToggle( var_GetInteger( p_input, "teletext-es" ) >= 0 ); |
|---|
| 374 |
else |
|---|
| 375 |
telexToggle( false ); |
|---|
| 376 |
} |
|---|
| 377 |
|
|---|
| 378 |
void InputManager::UpdateVout() |
|---|
| 379 |
{ |
|---|
| 380 |
if( hasInput() ) |
|---|
| 381 |
{ |
|---|
| 382 |
bool b_old_video = b_video; |
|---|
| 383 |
|
|---|
| 384 |
vlc_object_t *p_vout = (vlc_object_t*)vlc_object_find( p_input, VLC_OBJECT_VOUT, FIND_CHILD ); |
|---|
| 385 |
b_video = p_vout != NULL; |
|---|
| 386 |
if( p_vout ) |
|---|
| 387 |
vlc_object_release( p_vout ); |
|---|
| 388 |
if( !!b_old_video != !!b_video ) |
|---|
| 389 |
emit voutChanged( b_video ); |
|---|
| 390 |
} |
|---|
| 391 |
} |
|---|
| 392 |
|
|---|
| 393 |
void InputManager::UpdateArt() |
|---|
| 394 |
{ |
|---|
| 395 |
|
|---|
| 396 |
emit artChanged( input_GetItem( p_input ) ); |
|---|
| 397 |
} |
|---|
| 398 |
|
|---|
| 399 |
|
|---|
| 400 |
void InputManager::sliderUpdate( float new_pos ) |
|---|
| 401 |
{ |
|---|
| 402 |
if( hasInput() ) |
|---|
| 403 |
var_SetFloat( p_input, "position", new_pos ); |
|---|
| 404 |
} |
|---|
| 405 |
|
|---|
| 406 |
|
|---|
| 407 |
void InputManager::togglePlayPause() |
|---|
| 408 |
{ |
|---|
| 409 |
vlc_value_t state; |
|---|
| 410 |
var_Get( p_input, "state", &state ); |
|---|
| 411 |
state.i_int = ( state.i_int != PLAYING_S ) ? PLAYING_S : PAUSE_S; |
|---|
| 412 |
var_Set( p_input, "state", state ); |
|---|
| 413 |
emit statusChanged( state.i_int ); |
|---|
| 414 |
} |
|---|
| 415 |
|
|---|
| 416 |
void InputManager::sectionPrev() |
|---|
| 417 |
{ |
|---|
| 418 |
if( hasInput() ) |
|---|
| 419 |
{ |
|---|
| 420 |
int i_type = var_Type( p_input, "next-chapter" ); |
|---|
| 421 |
vlc_value_t val; val.b_bool = true; |
|---|
| 422 |
var_Set( p_input, (i_type & VLC_VAR_TYPE) != 0 ? |
|---|
| 423 |
"prev-chapter":"prev-title", val ); |
|---|
| 424 |
} |
|---|
| 425 |
} |
|---|
| 426 |
|
|---|
| 427 |
void InputManager::sectionNext() |
|---|
| 428 |
{ |
|---|
| 429 |
if( hasInput() ) |
|---|
| 430 |
{ |
|---|
| 431 |
int i_type = var_Type( p_input, "next-chapter" ); |
|---|
| 432 |
vlc_value_t val; val.b_bool = true; |
|---|
| 433 |
var_Set( p_input, (i_type & VLC_VAR_TYPE) != 0 ? |
|---|
| 434 |
"next-chapter":"next-title", val ); |
|---|
| 435 |
} |
|---|
| 436 |
} |
|---|
| 437 |
|
|---|
| 438 |
void InputManager::sectionMenu() |
|---|
| 439 |
{ |
|---|
| 440 |
if( hasInput() ) |
|---|
| 441 |
{ |
|---|
| 442 |
vlc_value_t val, text; |
|---|
| 443 |
vlc_value_t root; |
|---|
| 444 |
|
|---|
| 445 |
if( var_Change( p_input, "title 0", VLC_VAR_GETLIST, &val, &text ) < 0 ) |
|---|
| 446 |
return; |
|---|
| 447 |
|
|---|
| 448 |
|
|---|
| 449 |
root.i_int = 0; |
|---|
| 450 |
for( int i = 0; i < val.p_list->i_count; i++ ) |
|---|
| 451 |
{ |
|---|
| 452 |
if( !strcmp( text.p_list->p_values[i].psz_string, "Title" ) ) |
|---|
| 453 |
root.i_int = i; |
|---|
| 454 |
} |
|---|
| 455 |
var_Change( p_input, "title 0", VLC_VAR_FREELIST, &val, &text ); |
|---|
| 456 |
|
|---|
| 457 |
var_Set( p_input, "title 0", root ); |
|---|
| 458 |
} |
|---|
| 459 |
} |
|---|
| 460 |
|
|---|
| 461 |
void InputManager::telexGotoPage( int page ) |
|---|
| 462 |
{ |
|---|
| 463 |
if( hasInput() ) |
|---|
| 464 |
{ |
|---|
| 465 |
const int i_teletext_es = var_GetInteger( p_input, "teletext-es" ); |
|---|
| 466 |
const int i_spu_es = var_GetInteger( p_input, "spu-es" ); |
|---|
| 467 |
|
|---|
| 468 |
if( i_teletext_es >= 0 && i_teletext_es == i_spu_es ) |
|---|
| 469 |
{ |
|---|
| 470 |
vlc_object_t *p_vbi; |
|---|
| 471 |
p_vbi = (vlc_object_t *) vlc_object_find_name( p_input, |
|---|
| 472 |
"zvbi", FIND_ANYWHERE ); |
|---|
| 473 |
if( p_vbi ) |
|---|
| 474 |
{ |
|---|
| 475 |
var_SetInteger( p_vbi, "vbi-page", page ); |
|---|
| 476 |
vlc_object_release( p_vbi ); |
|---|
| 477 |
} |
|---|
| 478 |
} |
|---|
| 479 |
} |
|---|
| 480 |
emit setNewTelexPage( page ); |
|---|
| 481 |
} |
|---|
| 482 |
|
|---|
| 483 |
void InputManager::telexToggle( bool b_enabled ) |
|---|
| 484 |
{ |
|---|
| 485 |
if( hasInput() ) |
|---|
| 486 |
{ |
|---|
| 487 |
const int i_teletext_es = var_GetInteger( p_input, "teletext-es" ); |
|---|
| 488 |
const int i_spu_es = var_GetInteger( p_input, "spu-es" ); |
|---|
| 489 |
|
|---|
| 490 |
b_enabled = (i_teletext_es >= 0); |
|---|
| 491 |
emit teletextEnabled( b_enabled ); |
|---|
| 492 |
if( b_enabled && (i_teletext_es == i_spu_es) ) |
|---|
| 493 |
{ |
|---|
| 494 |
vlc_object_t *p_vbi; |
|---|
| 495 |
int i_page = 100; |
|---|
| 496 |
p_vbi = (vlc_object_t *) vlc_object_find_name( p_input, |
|---|
| 497 |
"zvbi", FIND_ANYWHERE ); |
|---|
| 498 |
if( p_vbi ) |
|---|
| 499 |
{ |
|---|
| 500 |
i_page = var_GetInteger( p_vbi, "vbi-page" ); |
|---|
| 501 |
vlc_object_release( p_vbi ); |
|---|
| 502 |
i_page = b_enabled ? i_page : 0; |
|---|
| 503 |
telexGotoPage( i_page ); |
|---|
| 504 |
} |
|---|
| 505 |
} |
|---|
| 506 |
} |
|---|
| 507 |
else emit teletextEnabled( b_enabled ); |
|---|
| 508 |
} |
|---|
| 509 |
|
|---|
| 510 |
void InputManager::telexToggleButtons() |
|---|
| 511 |
{ |
|---|
| 512 |
if( hasInput() ) |
|---|
| 513 |
{ |
|---|
| 514 |
const int i_teletext_es = var_GetInteger( p_input, "teletext-es" ); |
|---|
| 515 |
if( i_teletext_es >= 0 ) |
|---|
| 516 |
{ |
|---|
| 517 |
const int i_spu_es = var_GetInteger( p_input, "spu-es" ); |
|---|
| 518 |
|
|---|
| 519 |
if( i_teletext_es == i_spu_es ) |
|---|
| 520 |
var_SetInteger( p_input, "spu-es", -1 ); |
|---|
| 521 |
else |
|---|
| 522 |
var_SetInteger( p_input, "spu-es", i_teletext_es ); |
|---|
| 523 |
|
|---|
| 524 |
emit toggleTelexButtons(); |
|---|
| 525 |
} |
|---|
| 526 |
} |
|---|
| 527 |
} |
|---|
| 528 |
|
|---|
| 529 |
void InputManager::telexSetTransparency() |
|---|
| 530 |
{ |
|---|
| 531 |
if( hasInput() ) |
|---|
| 532 |
{ |
|---|
| 533 |
vlc_object_t *p_vbi; |
|---|
| 534 |
p_vbi = (vlc_object_t *) vlc_object_find_name( p_input, |
|---|
| 535 |
"zvbi", FIND_ANYWHERE ); |
|---|
| 536 |
if( p_vbi ) |
|---|
| 537 |
{ |
|---|
| 538 |
var_SetBool( p_vbi, "vbi-opaque", b_transparentTelextext ); |
|---|
| 539 |
b_transparentTelextext = !b_transparentTelextext; |
|---|
| 540 |
vlc_object_release( p_vbi ); |
|---|
| 541 |
} |
|---|
| 542 |
} |
|---|
| 543 |
emit toggleTelexTransparency(); |
|---|
| 544 |
} |
|---|
| 545 |
|
|---|
| 546 |
void InputManager::slower() |
|---|
| 547 |
{ |
|---|
| 548 |
if( hasInput() ) |
|---|
| 549 |
var_SetVoid( p_input, "rate-slower" ); |
|---|
| 550 |
} |
|---|
| 551 |
|
|---|
| 552 |
void InputManager::faster() |
|---|
| 553 |
{ |
|---|
| 554 |
if( hasInput() ) |
|---|
| 555 |
var_SetVoid( p_input, "rate-faster" ); |
|---|
| 556 |
} |
|---|
| 557 |
|
|---|
| 558 |
void InputManager::normalRate() |
|---|
| 559 |
{ |
|---|
| 560 |
if( hasInput() ) |
|---|
| 561 |
var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT ); |
|---|
| 562 |
} |
|---|
| 563 |
|
|---|
| 564 |
void InputManager::setRate( int new_rate ) |
|---|
| 565 |
{ |
|---|
| 566 |
if( hasInput() ) |
|---|
| 567 |
var_SetInteger( p_input, "rate", new_rate ); |
|---|
| 568 |
} |
|---|
| 569 |
|
|---|
| 570 |
|
|---|
| 571 |
|
|---|
| 572 |
|
|---|
| 573 |
|
|---|
| 574 |
|
|---|
| 575 |
MainInputManager * MainInputManager::instance = NULL; |
|---|
| 576 |
|
|---|
| 577 |
MainInputManager::MainInputManager( intf_thread_t *_p_intf ) |
|---|
| 578 |
: QObject(NULL), p_intf( _p_intf ) |
|---|
| 579 |
{ |
|---|
| 580 |
p_input = NULL; |
|---|
| 581 |
im = new InputManager( this, p_intf ); |
|---|
| 582 |
|
|---|
| 583 |
|
|---|
| 584 |
var_AddCallback( THEPL, "item-change", ItemChanged, im ); |
|---|
| 585 |
var_AddCallback( THEPL, "playlist-current", PLItemChanged, this ); |
|---|
| 586 |
var_AddCallback( THEPL, "activity", PLItemChanged, this ); |
|---|
| 587 |
|
|---|
| 588 |
var_AddCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, this ); |
|---|
| 589 |
|
|---|
| 590 |
|
|---|
| 591 |
CONNECT( this, inputChanged( input_thread_t * ), |
|---|
| 592 |
im, setInput( input_thread_t * ) ); |
|---|
| 593 |
|
|---|
| 594 |
|
|---|
| 595 |
vlc_value_t val; |
|---|
| 596 |
var_Change( THEPL, "playlist-current", VLC_VAR_CHOICESCOUNT, &val, NULL ); |
|---|
| 597 |
IMEvent *event = new IMEvent( ItemChanged_Type, val.i_int); |
|---|
| 598 |
QApplication::postEvent( this, static_cast<QEvent*>(event) ); |
|---|
| 599 |
|
|---|
| 600 |
} |
|---|
| 601 |
|
|---|
| 602 |
MainInputManager::~MainInputManager() |
|---|
| 603 |
{ |
|---|
| 604 |
if( p_input ) |
|---|
| 605 |
{ |
|---|
| 606 |
var_DelCallback( p_input, "state", PLItemChanged, this ); |
|---|
| 607 |
vlc_object_release( p_input ); |
|---|
| 608 |
emit inputChanged( NULL ); |
|---|
| 609 |
} |
|---|
| 610 |
|
|---|
| 611 |
var_DelCallback( p_intf->p_libvlc, "volume-change", VolumeChanged, this ); |
|---|
| 612 |
|
|---|
| 613 |
var_DelCallback( THEPL, "activity", PLItemChanged, this ); |
|---|
| 614 |
var_DelCallback( THEPL, "item-change", ItemChanged, im ); |
|---|
| 615 |
|
|---|
| 616 |
|
|---|
| 617 |
var_DelCallback( THEPL, "playlist-current", PLItemChanged, this ); |
|---|
| 618 |
} |
|---|
| 619 |
|
|---|
| 620 |
void MainInputManager::customEvent( QEvent *event ) |
|---|
| 621 |
{ |
|---|
| 622 |
int type = event->type(); |
|---|
| 623 |
if ( type != ItemChanged_Type && type != VolumeChanged_Type ) |
|---|
| 624 |
return; |
|---|
| 625 |
|
|---|
| 626 |
|
|---|
| 627 |
if( type == VolumeChanged_Type ) |
|---|
| 628 |
{ |
|---|
| 629 |
emit volumeChanged(); |
|---|
| 630 |
return; |
|---|
| 631 |
} |
|---|
| 632 |
|
|---|
| 633 |
|
|---|
| 634 |
if( VLC_OBJECT_INTF == p_intf->i_object_type ) |
|---|
| 635 |
{ |
|---|
| 636 |
vlc_mutex_lock( &p_intf->change_lock ); |
|---|
| 637 |
if( p_input && ( p_input->b_dead || !vlc_object_alive (p_input) ) ) |
|---|
| 638 |
{ |
|---|
| 639 |
var_DelCallback( p_input, "state", PLItemChanged, this ); |
|---|
| 640 |
vlc_object_release( p_input ); |
|---|
| 641 |
emit inputChanged( NULL ); |
|---|
| 642 |
p_input = NULL; |
|---|
| 643 |
vlc_mutex_unlock( &p_intf->change_lock ); |
|---|
| 644 |
return; |
|---|
| 645 |
} |
|---|
| 646 |
|
|---|
| 647 |
if( !p_input ) |
|---|
| 648 |
{ |
|---|
| 649 |
p_input = playlist_CurrentInput(THEPL); |
|---|
| 650 |
if( p_input ) |
|---|
| 651 |
{ |
|---|
| 652 |
var_AddCallback( p_input, "state", PLItemChanged, this ); |
|---|
| 653 |
emit inputChanged( p_input ); |
|---|
| 654 |
} |
|---|
| 655 |
} |
|---|
| 656 |
vlc_mutex_unlock( &p_intf->change_lock ); |
|---|
| 657 |
} |
|---|
| 658 |
else |
|---|
| 659 |
{ |
|---|
| 660 |
|
|---|
| 661 |
playlist_t *p_playlist = pl_Hold( p_intf ); |
|---|
| 662 |
p_input = playlist_CurrentInput( p_playlist ); |
|---|
| 663 |
if( p_input ) |
|---|
| 664 |
{ |
|---|
| 665 |
emit inputChanged( p_input ); |
|---|
| 666 |
vlc_object_release( p_input ); |
|---|
| 667 |
} |
|---|
| 668 |
pl_Release( p_intf ); |
|---|
| 669 |
} |
|---|
| 670 |
} |
|---|
| 671 |
|
|---|
| 672 |
|
|---|
| 673 |
void MainInputManager::stop() |
|---|
| 674 |
{ |
|---|
| 675 |
playlist_Stop( THEPL ); |
|---|
| 676 |
} |
|---|
| 677 |
|
|---|
| 678 |
void MainInputManager::next() |
|---|
| 679 |
{ |
|---|
| 680 |
playlist_Next( THEPL ); |
|---|
| 681 |
} |
|---|
| 682 |
|
|---|
| 683 |
void MainInputManager::prev() |
|---|
| 684 |
{ |
|---|
| 685 |
playlist_Prev( THEPL ); |
|---|
| 686 |
} |
|---|
| 687 |
|
|---|
| 688 |
void MainInputManager::togglePlayPause() |
|---|
| 689 |
{ |
|---|
| 690 |
if( p_input == NULL ) |
|---|
| 691 |
{ |
|---|
| 692 |
playlist_Play( THEPL ); |
|---|
| 693 |
return; |
|---|
| 694 |
} |
|---|
| 695 |
getIM()->togglePlayPause(); |
|---|
| 696 |
} |
|---|
| 697 |
|
|---|
| 698 |
bool MainInputManager::teletextState() |
|---|
| 699 |
{ |
|---|
| 700 |
im = getIM(); |
|---|
| 701 |
if( im->hasInput() ) |
|---|
| 702 |
{ |
|---|
| 703 |
const int i_teletext_es = var_GetInteger( getInput(), "teletext-es" ); |
|---|
| 704 |
const int i_spu_es = var_GetInteger( getInput(), "spu-es" ); |
|---|
| 705 |
|
|---|
| 706 |
return i_teletext_es >= 0 && i_teletext_es == i_spu_es; |
|---|
| 707 |
} |
|---|
| 708 |
return false; |
|---|
| 709 |
} |
|---|
| 710 |
|
|---|
| 711 |
|
|---|
| 712 |
|
|---|
| 713 |
|
|---|
| 714 |
static int InterfaceChanged( vlc_object_t *p_this, const char *psz_var, |
|---|
| 715 |
vlc_value_t oldval, vlc_value_t newval, void *param ) |
|---|
| 716 |
{ |
|---|
| 717 |
|
|---|
| 718 |
static int counter = 0; |
|---|
| 719 |
InputManager *im = (InputManager*)param; |
|---|
| 720 |
|
|---|
| 721 |
counter = ++counter % 4; |
|---|
| 722 |
if(!counter) |
|---|
| 723 |
return VLC_SUCCESS; |
|---|
| 724 |
IMEvent *event = new IMEvent( PositionUpdate_Type, 0 ); |
|---|
| 725 |
QApplication::postEvent( im, static_cast<QEvent*>(event) ); |
|---|
| 726 |
return VLC_SUCCESS; |
|---|
| 727 |
} |
|---|
| 728 |
|
|---|
| 729 |
static int InterfaceVoutChanged( vlc_object_t *p_this, const char *psz_var, |
|---|
| 730 |
vlc_value_t oldval, vlc_value_t newval, void *param ) |
|---|
| 731 |
{ |
|---|
| 732 |
InputManager *im = (InputManager*)param; |
|---|
| 733 |
|
|---|
| 734 |
IMEvent *event = new IMEvent( InterfaceVoutUpdate_Type, 0 ); |
|---|
| 735 |
QApplication::postEvent( im, static_cast<QEvent*>(event) ); |
|---|
| 736 |
return VLC_SUCCESS; |
|---|
| 737 |
} |
|---|
| 738 |
|
|---|
| 739 |
static int ItemStateChanged( vlc_object_t *p_this, const char *psz_var, |
|---|
| 740 |
vlc_value_t oldval, vlc_value_t newval, void *param ) |
|---|
| 741 |
{ |
|---|
| 742 |
InputManager *im = (InputManager*)param; |
|---|
| 743 |
|
|---|
| 744 |
IMEvent *event = new IMEvent( ItemStateChanged_Type, 0 ); |
|---|
| 745 |
QApplication::postEvent( im, static_cast<QEvent*>(event) ); |
|---|
| 746 |
return VLC_SUCCESS; |
|---|
| 747 |
} |
|---|
| 748 |
|
|---|
| 749 |
static int ItemRateChanged( vlc_object_t *p_this, const char *psz_var, |
|---|
| 750 |
vlc_value_t oldval, vlc_value_t newval, void *param ) |
|---|
| 751 |
{ |
|---|
| 752 |
InputManager *im = (InputManager*)param; |
|---|
| 753 |
|
|---|
| 754 |
IMEvent *event = new IMEvent( ItemRateChanged_Type, 0 ); |
|---|
| 755 |
QApplication::postEvent( im, static_cast<QEvent*>(event) ); |
|---|
| 756 |
return VLC_SUCCESS; |
|---|
| 757 |
} |
|---|
| 758 |
|
|---|
| 759 |
static int ItemTitleChanged( vlc_object_t *p_this, const char *psz_var, |
|---|
| 760 |
vlc_value_t oldval, vlc_value_t newval, void *param ) |
|---|
| 761 |
{ |
|---|
| 762 |
InputManager *im = (InputManager*)param; |
|---|
| 763 |
|
|---|
| 764 |
IMEvent *event = new IMEvent( ItemTitleChanged_Type, 0 ); |
|---|
| 765 |
QApplication::postEvent( im, static_cast<QEvent*>(event) ); |
|---|
| 766 |
return VLC_SUCCESS; |
|---|
| 767 |
} |
|---|
| 768 |
|
|---|
| 769 |
static int ItemChanged( vlc_object_t *p_this, const char *psz_var, |
|---|
| 770 |
vlc_value_t oldval, vlc_value_t newval, void *param ) |
|---|
| 771 |
{ |
|---|
| 772 |
InputManager *im = (InputManager*)param; |
|---|
| 773 |
|
|---|
| 774 |
IMEvent *event = new IMEvent( ItemChanged_Type, newval.i_int ); |
|---|
| 775 |
QApplication::postEvent( im, static_cast<QEvent*>(event) ); |
|---|
| 776 |
return VLC_SUCCESS; |
|---|
| 777 |
} |
|---|
| 778 |
|
|---|
| 779 |
static int ChangeSPU( vlc_object_t *p_this, const char *var, vlc_value_t o, |
|---|
| 780 |
vlc_value_t n, void *param ) |
|---|
| 781 |
{ |
|---|
| 782 |
InputManager *im = (InputManager*)param; |
|---|
| 783 |
IMEvent *event = new IMEvent( ItemSpuChanged_Type, 0 ); |
|---|
| 784 |
QApplication::postEvent( im, static_cast<QEvent*>(event) ); |
|---|
| 785 |
return VLC_SUCCESS; |
|---|
| 786 |
} |
|---|
| 787 |
|
|---|
| 788 |
static int ChangeTeletext( vlc_object_t *p_this, const char *var, vlc_value_t o, |
|---|
| 789 |
vlc_value_t n, void *param ) |
|---|
| 790 |
{ |
|---|
| 791 |
|
|---|
| 792 |
InputManager *im = (InputManager*)param; |
|---|
| 793 |
IMEvent *event = new IMEvent( ItemTeletextChanged_Type, 0 ); |
|---|
| 794 |
QApplication::postEvent( im, static_cast<QEvent*>(event) ); |
|---|
| 795 |
return VLC_SUCCESS; |
|---|
| 796 |
} |
|---|
| 797 |
|
|---|
| 798 |
|
|---|
| 799 |
static int PLItemChanged( vlc_object_t *p_this, const char *psz_var, |
|---|
| 800 |
vlc_value_t oldval, vlc_value_t newval, void *param ) |
|---|
| 801 |
{ |
|---|
| 802 |
MainInputManager *mim = (MainInputManager*)param; |
|---|
| 803 |
|
|---|
| 804 |
IMEvent *event = new IMEvent( ItemChanged_Type, newval.i_int ); |
|---|
| 805 |
QApplication::postEvent( mim, static_cast<QEvent*>(event) ); |
|---|
| 806 |
return VLC_SUCCESS; |
|---|
| 807 |
} |
|---|
| 808 |
|
|---|
| 809 |
static int VolumeChanged( vlc_object_t *p_this, const char *psz_var, |
|---|
| 810 |
vlc_value_t oldval, vlc_value_t newval, void *param ) |
|---|
| 811 |
{ |
|---|
| 812 |
MainInputManager *mim = (MainInputManager*)param; |
|---|
| 813 |
|
|---|
| 814 |
IMEvent *event = new IMEvent( VolumeChanged_Type, newval.i_int ); |
|---|
| 815 |
QApplication::postEvent( mim, static_cast<QEvent*>(event) ); |
|---|
| 816 |
return VLC_SUCCESS; |
|---|
| 817 |
} |
|---|
| 818 |
|
|---|