Changeset 211b483e7eb44ad8c4fe56ca298515d210d9ef71

Show
Ignore:
Timestamp:
30/05/07 01:25:47 (2 years ago)
Author:
Jean-Baptiste Kempf <jb@videolan.org>
git-committer:
Jean-Baptiste Kempf <jb@videolan.org> 1180481147 +0000
git-parent:

[18ce8f4b3eedd946fc1a0fed2271b0e77b21a585]

git-author:
Jean-Baptiste Kempf <jb@videolan.org> 1180481147 +0000
Message:

Dbus Improvements thanks to Mirsal ENNAIME

* Added Loop and Repeat methods in /TrackList
* Added GetMetadata? method in /Player
* Fixed "length" metadata item to fit the spec (It should be expressed

in seconds)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/control/dbus.c

    r9025fab r211b483  
    6767static int  Open    ( vlc_object_t * ); 
    6868static void Close   ( vlc_object_t * ); 
    69 static void Run        ( intf_thread_t * ); 
     69static void Run     ( intf_thread_t * ); 
    7070 
    7171 
     
    179179        i_pos = position.f_float * 1000 ; 
    180180    } 
     181    pl_Release( ((vlc_object_t*) p_this) ); 
    181182    ADD_INT32( &i_pos ); 
    182     pl_Release( ((vlc_object_t*) p_this) ); 
    183183    REPLY_SEND; 
    184184} 
     
    189189    REPLY_INIT; 
    190190    vlc_value_t position; 
     191    playlist_t* p_playlist = NULL; 
    191192    dbus_int32_t i_pos; 
    192193 
     
    205206        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 
    206207    } 
    207     playlist_t *p_playlist = pl_Yield( ((vlc_object_t*) p_this) ); 
     208    p_playlist = pl_Yield( ((vlc_object_t*) p_this) ); 
    208209    input_thread_t *p_input = p_playlist->p_input; 
    209210 
     
    330331} 
    331332 
     333DBUS_METHOD( GetCurrentMetadata ) 
     334{ 
     335    REPLY_INIT; 
     336    OUT_ARGUMENTS; 
     337    playlist_t* p_playlist = pl_Yield( (vlc_object_t*) p_this ); 
     338 
     339    GetInputMeta( p_playlist->status.p_item->p_input, &args ); 
     340 
     341    pl_Release( p_playlist ); 
     342    REPLY_SEND; 
     343} 
     344 
    332345/* Media Player information */ 
    333346 
     
    351364    DBusError error; 
    352365    dbus_error_init( &error ); 
     366    playlist_t* p_playlist = NULL; 
    353367 
    354368    char *psz_mrl; 
     
    368382    } 
    369383 
    370     playlist_t *p_playlist = pl_Yield( (vlc_object_t*) p_this ); 
     384    p_playlist = pl_Yield( (vlc_object_t*) p_this ); 
    371385    playlist_Add( p_playlist, psz_mrl, NULL, PLAYLIST_APPEND | 
    372             ( ( b_play == TRUE ) ? PLAYLIST_GO : 0 ) ,  
    373        PLAYLIST_END, VLC_TRUE, VLC_FALSE ); 
     386            ( ( b_play == TRUE ) ? PLAYLIST_GO : 0 ) , 
     387            PLAYLIST_END, VLC_TRUE, VLC_FALSE ); 
    374388    pl_Release( p_playlist ); 
    375389 
     
    384398    playlist_t *p_playlist = pl_Yield( (vlc_object_t*) p_this ); 
    385399    playlist_item_t* p_tested_item = p_playlist->p_root_onelevel; 
    386      
    387     while ( p_tested_item->p_input->i_id !=  
     400 
     401    while ( p_tested_item->p_input->i_id != 
    388402                    p_playlist->status.p_item->p_input->i_id ) 
    389403    { 
     
    399413 
    400414DBUS_METHOD( GetMetadata ) 
    401 {  
     415{ 
    402416    REPLY_INIT; 
    403417    OUT_ARGUMENTS; 
     
    406420 
    407421    dbus_int32_t i_position, i_count = 0; 
    408      
     422 
    409423    playlist_t *p_playlist = pl_Yield( (vlc_object_t*) p_this ); 
    410424    playlist_item_t* p_tested_item = p_playlist->p_root_onelevel; 
     
    494508    pl_Release( p_playlist ); 
    495509     
     510    REPLY_SEND; 
     511} 
     512 
     513DBUS_METHOD( Loop ) 
     514{ 
     515    REPLY_INIT; 
     516    OUT_ARGUMENTS; 
     517 
     518    DBusError error; 
     519    dbus_bool_t b_loop; 
     520    vlc_value_t val; 
     521    playlist_t* p_playlist = NULL; 
     522     
     523    dbus_error_init( &error ); 
     524    dbus_message_get_args( p_from, &error, 
     525            DBUS_TYPE_BOOLEAN, &b_loop, 
     526            DBUS_TYPE_INVALID ); 
     527     
     528    if( dbus_error_is_set( &error ) ) 
     529    { 
     530        msg_Err( (vlc_object_t*) p_this, "D-Bus message reading : %s\n", 
     531                error.message ); 
     532        dbus_error_free( &error ); 
     533        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 
     534    } 
     535 
     536    val.b_bool = ( b_loop == TRUE ) ? VLC_TRUE : VLC_FALSE ; 
     537    p_playlist = pl_Yield( (vlc_object_t*) p_this ); 
     538    var_Set ( p_playlist, "loop", val ); 
     539    pl_Release( ((vlc_object_t*) p_this) ); 
     540 
     541    REPLY_SEND; 
     542} 
     543 
     544DBUS_METHOD( Repeat ) 
     545{ 
     546    REPLY_INIT; 
     547    OUT_ARGUMENTS; 
     548 
     549    DBusError error; 
     550    dbus_bool_t b_repeat; 
     551    vlc_value_t val; 
     552    playlist_t* p_playlist = NULL; 
     553     
     554    dbus_error_init( &error ); 
     555    dbus_message_get_args( p_from, &error, 
     556            DBUS_TYPE_BOOLEAN, &b_repeat, 
     557            DBUS_TYPE_INVALID ); 
     558     
     559    if( dbus_error_is_set( &error ) ) 
     560    { 
     561        msg_Err( (vlc_object_t*) p_this, "D-Bus message reading : %s\n", 
     562                error.message ); 
     563        dbus_error_free( &error ); 
     564        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 
     565    } 
     566 
     567    val.b_bool = ( b_repeat == TRUE ) ? VLC_TRUE : VLC_FALSE ; 
     568     
     569    p_playlist = pl_Yield( (vlc_object_t*) p_this ); 
     570    var_Set ( p_playlist, "repeat", val ); 
     571    pl_Release( ((vlc_object_t*) p_this) ); 
     572 
    496573    REPLY_SEND; 
    497574} 
     
    567644    METHOD_FUNC( "PositionGet",             PositionGet ); 
    568645    METHOD_FUNC( "GetStatus",               GetStatus ); 
     646    METHOD_FUNC( "GetMetadata",             GetCurrentMetadata ); 
    569647 
    570648    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 
     
    584662    METHOD_FUNC( "AddTrack",                AddTrack ); 
    585663    METHOD_FUNC( "DelTrack",                DelTrack ); 
     664    METHOD_FUNC( "Loop",                    Loop ); 
     665    METHOD_FUNC( "Repeat",                  Repeat ); 
    586666 
    587667    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 
     
    753833                        DBusMessageIter *args ) 
    754834{ /*FIXME: Works only for already read metadata. */  
    755   /*FIXME: Should return the length in seconds rather than milliseconds */ 
    756835   
    757836    DBusMessageIter dict, dict_entry, variant; 
     837    /* We need the track length to be expressed in seconds 
     838     * instead of milliseconds */ 
     839    dbus_int64_t i_length = (p_input->i_duration / 1000); 
     840 
    758841 
    759842    const char* ppsz_meta_items[] =  
     
    788871    ADD_META( 17, DBUS_TYPE_INT32, p_input->p_meta->i_status ); 
    789872    ADD_META( 18, DBUS_TYPE_STRING, p_input->psz_uri );  
    790     ADD_META( 19, DBUS_TYPE_INT64, p_input->i_duration );  
     873    ADD_META( 19, DBUS_TYPE_INT64, i_length );  
    791874 
    792875    dbus_message_iter_close_container( args, &dict ); 
  • modules/control/dbus.h

    ra33fbe9 r211b483  
    55 * $Id$ 
    66 * 
    7  * Author:    Rafaël Carré <funman at videolanorg> 
     7 * Authors:    Rafaël Carré <funman at videolanorg> 
     8 *             Mirsal ENNAIME <mirsal dot ennaime at gmail dot com> 
    89 * 
    910 * This program is free software; you can redistribute it and/or modify 
     
    139140"      <arg type=\"i\" direction=\"out\" />\n" 
    140141"    </method>\n" 
     142"    <method name=\"GetMetadata\">\n" 
     143"      <arg type=\"a{sv}\" direction=\"out\" />\n" 
     144"    </method>\n" 
    141145"  </interface>\n" 
    142146"</node>\n" 
     
    170174"      <arg type=\"i\" direction=\"out\" />\n" 
    171175"    </method>\n" 
     176"    <method name=\"Loop\">\n" 
     177"      <arg type=\"b\" direction=\"in\" />\n" 
     178"    </method>\n" 
     179"    <method name=\"Repeat\">\n" 
     180"      <arg type=\"b\" direction=\"in\" />\n" 
     181"    </method>\n" 
    172182"  </interface>\n" 
    173183"</node>\n"