Commit 1857cab2 authored by Mirsal Ennaime's avatar Mirsal Ennaime Committed by Mirsal Ennaime

dbus: Implement the MPRIS v2.1, as published on http://www.mpris.org

WARNING: These changes are backwards incompatible.
Please refer to the mpris project for documentation.
parent a1967050
This diff is collapsed.
...@@ -27,6 +27,17 @@ ...@@ -27,6 +27,17 @@
#ifndef _VLC_DBUS_H #ifndef _VLC_DBUS_H
#define _VLC_DBUS_H #define _VLC_DBUS_H
#define DBUS_MPRIS_BUS_NAME "org.mpris.vlc" #define DBUS_MPRIS_BUS_NAME "org.mpris.MediaPlayer2.vlc"
static DBusHandlerResult
MPRISEntryPoint ( DBusConnection *p_conn, DBusMessage *p_from, void *p_this );
static const DBusObjectPathVTable dbus_mpris_vtable = {
NULL, MPRISEntryPoint, /* handler function */
NULL, NULL, NULL, NULL
};
#define ABS(x) ( ( x ) > 0 ? ( x ) : ( -1 * ( x ) ) )
#define SEEK_THRESHOLD 1000 /* µsec */
#endif //dbus.h #endif //dbus.h
...@@ -29,8 +29,11 @@ ...@@ -29,8 +29,11 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_interface.h> #include <vlc_interface.h>
#include <vlc_aout.h>
#include <dbus/dbus.h> #include <dbus/dbus.h>
#define DBUS_MPRIS_OBJECT_PATH "/org/mpris/MediaPlayer2"
/* MACROS */ /* MACROS */
#define INTF ((intf_thread_t *)p_this) #define INTF ((intf_thread_t *)p_this)
...@@ -76,17 +79,22 @@ ...@@ -76,17 +79,22 @@
return DBUS_HANDLER_RESULT_NEED_MEMORY return DBUS_HANDLER_RESULT_NEED_MEMORY
#define ADD_STRING( s ) DBUS_ADD( DBUS_TYPE_STRING, s ) #define ADD_STRING( s ) DBUS_ADD( DBUS_TYPE_STRING, s )
#define ADD_DOUBLE( d ) DBUS_ADD( DBUS_TYPE_DOUBLE, d )
#define ADD_BOOL( b ) DBUS_ADD( DBUS_TYPE_BOOLEAN, b ) #define ADD_BOOL( b ) DBUS_ADD( DBUS_TYPE_BOOLEAN, b )
#define ADD_INT32( i ) DBUS_ADD( DBUS_TYPE_INT32, i ) #define ADD_INT32( i ) DBUS_ADD( DBUS_TYPE_INT32, i )
#define ADD_INT64( i ) DBUS_ADD( DBUS_TYPE_INT64, i )
#define ADD_BYTE( b ) DBUS_ADD( DBUS_TYPE_BYTE, b ) #define ADD_BYTE( b ) DBUS_ADD( DBUS_TYPE_BYTE, b )
#define MPRIS_TRACKID_FORMAT "/org/videolan/vlc/playlist/%d"
struct intf_sys_t struct intf_sys_t
{ {
DBusConnection *p_conn; DBusConnection *p_conn;
playlist_t *p_playlist; playlist_t *p_playlist;
bool b_meta_read; bool b_meta_read;
dbus_int32_t i_caps; dbus_int32_t i_player_caps;
dbus_int32_t i_playing_state; dbus_int32_t i_playing_state;
bool b_can_play;
bool b_dead; bool b_dead;
vlc_array_t *p_events; vlc_array_t *p_events;
vlc_array_t *p_timeouts; vlc_array_t *p_timeouts;
...@@ -94,6 +102,8 @@ struct intf_sys_t ...@@ -94,6 +102,8 @@ struct intf_sys_t
int p_pipe_fds[2]; int p_pipe_fds[2];
vlc_mutex_t lock; vlc_mutex_t lock;
input_thread_t *p_input; input_thread_t *p_input;
mtime_t i_last_input_pos; /* Only access it from the input thread */
mtime_t i_last_input_pos_event; /* idem */
bool b_unique; bool b_unique;
}; };
...@@ -107,7 +117,13 @@ enum ...@@ -107,7 +117,13 @@ enum
SIGNAL_RANDOM, SIGNAL_RANDOM,
SIGNAL_REPEAT, SIGNAL_REPEAT,
SIGNAL_LOOP, SIGNAL_LOOP,
SIGNAL_STATE SIGNAL_STATE,
SIGNAL_RATE,
SIGNAL_SEEK,
SIGNAL_CAN_SEEK,
SIGNAL_CAN_PAUSE,
SIGNAL_VOLUME_CHANGE,
SIGNAL_VOLUME_MUTED
}; };
enum enum
...@@ -118,7 +134,7 @@ enum ...@@ -118,7 +134,7 @@ enum
PLAYBACK_STATE_STOPPED = 2 PLAYBACK_STATE_STOPPED = 2
}; };
int DemarshalSetPropertyValue( DBusMessage *p_msg, void *p_arg );
int GetInputMeta ( input_item_t* p_input, DBusMessageIter *args ); int GetInputMeta ( input_item_t* p_input, DBusMessageIter *args );
int UpdateCaps ( intf_thread_t* );
#endif //dbus-common.h #endif //dbus-common.h
/*****************************************************************************
* dbus-introspect.h : dbus control module (mpris v2.1) - introspection data
*****************************************************************************
* Copyright © 2006-2008 Rafaël Carré
* Copyright © 2007-2010 Mirsal Ennaime
* Copyright © 2009-2010 The VideoLAN team
* $Id$
*
* Authors: Mirsal Ennaime <mirsal at mirsal fr>
* Rafaël Carré <funman at videolanorg>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef _VLC_DBUS_INTROSPECT_H
#define _VLC_DBUS_INTROSPECT_H
#include "dbus_common.h"
/* XML data to answer org.freedesktop.DBus.Introspectable.Introspect requests */
static const char* psz_introspection_xml =
"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
"\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
"<node>\n"
" <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
" <method name=\"Introspect\">\n"
" <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
" </method>\n"
" </interface>\n"
" <interface name=\"org.freedesktop.DBus.Properties\">\n"
" <method name=\"Get\">\n"
" <arg direction=\"in\" type=\"s\"/>\n"
" <arg direction=\"in\" type=\"s\"/>\n"
" <arg direction=\"out\" type=\"v\"/>\n"
" </method>\n"
" <method name=\"Set\">\n"
" <arg direction=\"in\" type=\"s\"/>\n"
" <arg direction=\"in\" type=\"s\"/>\n"
" <arg direction=\"in\" type=\"v\"/>\n"
" </method>\n"
" <signal name=\"PropertiesChanged\">\n"
" <arg type=\"s\"/>\n"
" <arg type=\"a{sv}\"/>\n"
" <arg type=\"as\"/>\n"
" </signal>\n"
" </interface>\n"
" <interface name=\"org.mpris.MediaPlayer2\">\n"
" <property name=\"Identity\" type=\"s\" access=\"read\" />\n"
" <property name=\"DesktopEntry\" type=\"s\" access=\"read\" />\n"
" <property name=\"SupportedMimeTypes\" type=\"as\" access=\"read\" />\n"
" <property name=\"SupportedUriSchemes\" type=\"as\" access=\"read\" />\n"
" <property name=\"HasTrackList\" type=\"b\" access=\"read\" />\n"
" <property name=\"CanQuit\" type=\"b\" access=\"read\" />\n"
" <property name=\"CanRaise\" type=\"b\" access=\"read\" />\n"
" <method name=\"Quit\" />\n"
" </interface>\n"
" <interface name=\"org.mpris.MediaPlayer2.Player\">\n"
" <property name=\"Metadata\" type=\"a{sv}\" access=\"read\" />\n"
" <property name=\"PlaybackStatus\" type=\"s\" access=\"read\" />\n"
" <property name=\"LoopStatus\" type=\"s\" access=\"readwrite\" />\n"
" <property name=\"Volume\" type=\"d\" access=\"readwrite\" />\n"
" <property name=\"Shuffle\" type=\"d\" access=\"readwrite\" />\n"
" <property name=\"Position\" type=\"i\" access=\"read\" />\n"
" <property name=\"Rate\" type=\"d\" access=\"readwrite\" />\n"
" <property name=\"MinimumRate\" type=\"d\" access=\"readwrite\" />\n"
" <property name=\"MaximumRate\" type=\"d\" access=\"readwrite\" />\n"
" <property name=\"CanControl\" type=\"b\" access=\"read\" />\n"
" <property name=\"CanPlay\" type=\"b\" access=\"read\" />\n"
" <property name=\"CanPause\" type=\"b\" access=\"read\" />\n"
" <property name=\"CanSeek\" type=\"b\" access=\"read\" />\n"
" <method name=\"Previous\" />\n"
" <method name=\"Next\" />\n"
" <method name=\"Stop\" />\n"
" <method name=\"Play\" />\n"
" <method name=\"Pause\" />\n"
" <method name=\"PlayPause\" />\n"
" <method name=\"OpenUri\">\n"
" <arg type=\"s\" direction=\"in\" />\n"
" </method>\n"
" <method name=\"SetPosition\">\n"
" <arg type=\"s\" direction=\"in\" />\n"
" <arg type=\"i\" direction=\"in\" />\n"
" </method>\n"
" </interface>\n"
" <interface name=\"org.mpris.MediaPlayer2.TrackList\">\n"
" <method name=\"AddTrack\">\n"
" <arg type=\"s\" direction=\"in\" />\n"
" <arg type=\"b\" direction=\"in\" />\n"
" <arg type=\"i\" direction=\"out\" />\n"
" </method>\n"
" <method name=\"DelTrack\">\n"
" <arg type=\"i\" direction=\"in\" />\n"
" </method>\n"
" <method name=\"GetMetadata\">\n"
" <arg type=\"i\" direction=\"in\" />\n"
" <arg type=\"a{sv}\" direction=\"out\" />\n"
" </method>\n"
" <method name=\"GetCurrentTrack\">\n"
" <arg type=\"i\" direction=\"out\" />\n"
" </method>\n"
" <method name=\"GetLength\">\n"
" <arg type=\"i\" direction=\"out\" />\n"
" </method>\n"
" <method name=\"SetLoop\">\n"
" <arg type=\"b\" direction=\"in\" />\n"
" </method>\n"
" <method name=\"SetRandom\">\n"
" <arg type=\"b\" direction=\"in\" />\n"
" </method>\n"
" <signal name=\"TrackListChange\">\n"
" <arg type=\"i\" />\n"
" </signal>\n"
" </interface>\n"
"</node>\n"
;
/* Handle incoming dbus messages */
DBUS_METHOD( handle_introspect )
{
VLC_UNUSED(p_this);
REPLY_INIT;
OUT_ARGUMENTS;
ADD_STRING( &psz_introspection_xml );
REPLY_SEND;
}
#endif //dbus-introspect.h
This diff is collapsed.
...@@ -30,34 +30,47 @@ ...@@ -30,34 +30,47 @@
#include <vlc_interface.h> #include <vlc_interface.h>
#include "dbus_common.h" #include "dbus_common.h"
#define DBUS_MPRIS_PLAYER_INTERFACE "org.freedesktop.MediaPlayer" #define DBUS_MPRIS_PLAYER_INTERFACE "org.mpris.MediaPlayer2.Player"
#define DBUS_MPRIS_PLAYER_PATH "/Player"
#define LOOP_STATUS_NONE "None"
#define LOOP_STATUS_TRACK "Track"
#define LOOP_STATUS_PLAYLIST "Playlist"
#define PLAYBACK_STATUS_STOPPED "Stopped"
#define PLAYBACK_STATUS_PLAYING "Playing"
#define PLAYBACK_STATUS_PAUSED "Paused"
/* Handle incoming dbus messages */ /* Handle incoming dbus messages */
DBusHandlerResult handle_player ( DBusConnection *p_conn, DBusHandlerResult handle_player ( DBusConnection *p_conn,
DBusMessage *p_from, DBusMessage *p_from,
void *p_this ); void *p_this );
static const DBusObjectPathVTable dbus_mpris_player_vtable = { /* Player capabilities */
NULL, handle_player, /* handler function */
NULL, NULL, NULL, NULL
};
/* GetCaps() capabilities */
enum enum
{ {
CAPS_NONE = 0, PLAYER_CAPS_NONE = 0,
CAPS_CAN_GO_NEXT = 1 << 0, PLAYER_CAN_GO_NEXT = 1 << 0,
CAPS_CAN_GO_PREV = 1 << 1, PLAYER_CAN_GO_PREVIOUS = 1 << 1,
CAPS_CAN_PAUSE = 1 << 2, PLAYER_CAN_PAUSE = 1 << 2,
CAPS_CAN_PLAY = 1 << 3, PLAYER_CAN_PLAY = 1 << 3,
CAPS_CAN_SEEK = 1 << 4, PLAYER_CAN_SEEK = 1 << 4,
CAPS_CAN_PROVIDE_METADATA = 1 << 5, PLAYER_CAN_PROVIDE_METADATA = 1 << 5,
CAPS_CAN_HAS_TRACKLIST = 1 << 6 PLAYER_CAN_PROVIDE_POSITION = 1 << 6,
PLAYER_CAN_REPEAT = 1 << 7,
PLAYER_CAN_LOOP = 1 << 8,
PLAYER_CAN_SHUFFLE = 1 << 9,
PLAYER_CAN_CONTROL_RATE = 1 << 10,
PLAYER_CAN_PLAY_BACKWARDS = 1 << 11
}; };
int StatusChangeEmit ( intf_thread_t * ); int PlayerStatusChangedEmit ( intf_thread_t * );
int CapsChangeEmit ( intf_thread_t * ); int PlayerCapsChangedEmit ( intf_thread_t * );
int TrackChangeEmit ( intf_thread_t *, input_item_t * ); int PlayerMetadataChangedEmit( intf_thread_t*, input_item_t* );
int TrackChangedEmit ( intf_thread_t *, input_item_t * );
int SeekedEmit( intf_thread_t * );
int PlayerPropertiesChangedEmit( intf_thread_t *, vlc_dictionary_t * );
void UpdatePlayerCaps( intf_thread_t * );
#endif //dbus_player.h #endif //dbus_player.h
...@@ -31,75 +31,153 @@ ...@@ -31,75 +31,153 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_interface.h> #include <vlc_interface.h>
#include <unistd.h>
#include <limits.h>
#include "dbus_root.h" #include "dbus_root.h"
#include "dbus_common.h" #include "dbus_common.h"
/* XML data to answer org.freedesktop.DBus.Introspectable.Introspect requests */
static const char* psz_root_introspection_xml =
"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
"\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
"<node>\n"
" <node name=\"Player\"/>\n"
" <node name=\"TrackList\"/>\n"
" <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
" <method name=\"Introspect\">\n"
" <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
" </method>\n"
" </interface>\n"
" <interface name=\"org.freedesktop.MediaPlayer\">\n"
" <method name=\"Identity\">\n"
" <arg type=\"s\" direction=\"out\" />\n"
" </method>\n"
" <method name=\"MprisVersion\">\n"
" <arg type=\"(qq)\" direction=\"out\" />\n"
" </method>\n"
" <method name=\"Quit\">\n"
" </method>\n"
" </interface>\n"
"</node>\n"
;
DBUS_METHOD( Identity ) DBUS_METHOD( Identity )
{ {
VLC_UNUSED(p_this); VLC_UNUSED(p_this);
REPLY_INIT; REPLY_INIT;
OUT_ARGUMENTS; OUT_ARGUMENTS;
char *psz_identity;
if( asprintf( &psz_identity, "%s %s", PACKAGE, VERSION ) != -1 ) char *psz_identity = VLC_IDENTITY;
{
ADD_STRING( &psz_identity ); DBusMessageIter v;
free( psz_identity ); dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "s", &v );
} dbus_message_iter_append_basic( &v, DBUS_TYPE_STRING, &psz_identity );
else
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
DBUS_METHOD( CanQuit )
{
VLC_UNUSED( p_this );
REPLY_INIT;
OUT_ARGUMENTS;
const dbus_bool_t b_ret = TRUE;
DBusMessageIter v;
dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "s", &v );
dbus_message_iter_append_basic( &v, DBUS_TYPE_BOOLEAN, &b_ret );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
DBUS_METHOD( CanRaise )
{
VLC_UNUSED( p_this );
REPLY_INIT;
OUT_ARGUMENTS;
const dbus_bool_t b_ret = FALSE;
DBusMessageIter v;
dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "s", &v );
dbus_message_iter_append_basic( &v, DBUS_TYPE_BOOLEAN, &b_ret );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
DBUS_METHOD( HasTrackList )
{
VLC_UNUSED( p_this );
REPLY_INIT;
OUT_ARGUMENTS;
const dbus_bool_t b_ret = FALSE;
DBusMessageIter v;
dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "s", &v );
dbus_message_iter_append_basic( &v, DBUS_TYPE_BOOLEAN, &b_ret );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
DBUS_METHOD( DesktopEntry )
{
VLC_UNUSED( p_this );
REPLY_INIT;
OUT_ARGUMENTS;
const char* psz_ret = PACKAGE;
DBusMessageIter v;
dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "s", &v );
dbus_message_iter_append_basic( &v, DBUS_TYPE_STRING, &psz_ret );
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY; return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND; REPLY_SEND;
} }
DBUS_METHOD( MprisVersion ) DBUS_METHOD( SupportedMimeTypes )
{ /*implemented version of the mpris spec */ {
VLC_UNUSED( p_this );
REPLY_INIT; REPLY_INIT;
OUT_ARGUMENTS; OUT_ARGUMENTS;
DBusMessageIter ret, v;
dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "s", &v );
size_t i_len = sizeof( ppsz_supported_mime_types ) / sizeof( char* );
if( !dbus_message_iter_open_container( &v, DBUS_TYPE_ARRAY, "s", &ret ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
for( size_t i = 0; i < i_len; ++i )
if( !dbus_message_iter_append_basic( &ret, DBUS_TYPE_STRING,
&ppsz_supported_mime_types[i] ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
if( !dbus_message_iter_close_container( &v, &ret ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND;
}
DBUS_METHOD( SupportedUriSchemes )
{
VLC_UNUSED( p_this ); VLC_UNUSED( p_this );
dbus_uint16_t i_major = DBUS_MPRIS_VERSION_MAJOR; REPLY_INIT;
dbus_uint16_t i_minor = DBUS_MPRIS_VERSION_MINOR; OUT_ARGUMENTS;
DBusMessageIter version;
if( !dbus_message_iter_open_container( &args, DBUS_TYPE_STRUCT, NULL, DBusMessageIter ret, v;
&version ) ) dbus_message_iter_open_container( &args, DBUS_TYPE_VARIANT, "s", &v );
size_t i_len = sizeof( ppsz_supported_uri_schemes ) / sizeof( char* );
if( !dbus_message_iter_open_container( &v, DBUS_TYPE_ARRAY, "s", &ret ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY; return DBUS_HANDLER_RESULT_NEED_MEMORY;
if( !dbus_message_iter_append_basic( &version, DBUS_TYPE_UINT16, for( size_t i = 0; i < i_len; ++i )
&i_major ) ) if( !dbus_message_iter_append_basic( &ret, DBUS_TYPE_STRING,
&ppsz_supported_uri_schemes[i] ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY; return DBUS_HANDLER_RESULT_NEED_MEMORY;
if( !dbus_message_iter_append_basic( &version, DBUS_TYPE_UINT16, if( !dbus_message_iter_close_container( &v, &ret ) )
&i_minor ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY; return DBUS_HANDLER_RESULT_NEED_MEMORY;
if( !dbus_message_iter_close_container( &args, &version ) ) if( !dbus_message_iter_close_container( &args, &v ) )
return DBUS_HANDLER_RESULT_NEED_MEMORY; return DBUS_HANDLER_RESULT_NEED_MEMORY;
REPLY_SEND; REPLY_SEND;
} }
...@@ -110,33 +188,67 @@ DBUS_METHOD( Quit ) ...@@ -110,33 +188,67 @@ DBUS_METHOD( Quit )
REPLY_SEND; REPLY_SEND;
} }
DBUS_METHOD( handle_introspect_root ) #define PROPERTY_MAPPING_BEGIN if( 0 ) {}
{ /* handles introspection of root object */ #define PROPERTY_FUNC( interface, property, function ) \
VLC_UNUSED(p_this); else if( !strcmp( psz_interface_name, interface ) && \
REPLY_INIT; !strcmp( psz_property_name, property ) ) \
OUT_ARGUMENTS; return function( p_conn, p_from, p_this );
ADD_STRING( &psz_root_introspection_xml ); #define PROPERTY_MAPPING_END return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
REPLY_SEND;
DBUS_METHOD( GetProperty )
{
DBusError error;
char *psz_interface_name = NULL;
char *psz_property_name = NULL;
dbus_error_init( &error );
dbus_message_get_args( p_from, &error,
DBUS_TYPE_STRING, &psz_interface_name,
DBUS_TYPE_STRING, &psz_property_name,
DBUS_TYPE_INVALID );
if( dbus_error_is_set( &error ) )
{
msg_Err( (vlc_object_t*) p_this, "D-Bus message reading : %s",
error.message );
dbus_error_free( &error );
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
msg_Dbg( (vlc_object_t*) p_this, "Getting property %s",
psz_property_name );
PROPERTY_MAPPING_BEGIN
PROPERTY_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "Identity", Identity )
PROPERTY_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "DesktopEntry", DesktopEntry )
PROPERTY_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "SupportedMimeTypes", SupportedMimeTypes )
PROPERTY_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "SupportedUriSchemes", SupportedUriSchemes )
PROPERTY_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "HasTrackList", HasTrackList )
PROPERTY_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "CanQuit", CanQuit )
PROPERTY_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "CanRaise", CanRaise )
PROPERTY_MAPPING_END
} }
#undef PROPERTY_MAPPING_BEGIN
#undef PROPERTY_GET_FUNC
#undef PROPERTY_MAPPING_END
#define METHOD_MAPPING_BEGIN if( 0 ) {}
#define METHOD_FUNC( interface, method, function ) \ #define METHOD_FUNC( interface, method, function ) \
else if( dbus_message_is_method_call( p_from, interface, method ) )\ else if( dbus_message_is_method_call( p_from, interface, method ) )\
return function( p_conn, p_from, p_this ) return function( p_conn, p_from, p_this )
#define METHOD_MAPPING_END return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
DBusHandlerResult DBusHandlerResult
handle_root ( DBusConnection *p_conn, DBusMessage *p_from, void *p_this ) handle_root ( DBusConnection *p_conn, DBusMessage *p_from, void *p_this )
{ {
if( dbus_message_is_method_call( p_from, METHOD_MAPPING_BEGIN
DBUS_INTERFACE_INTROSPECTABLE, "Introspect" ) ) METHOD_FUNC( DBUS_INTERFACE_PROPERTIES, "Get", GetProperty );
return handle_introspect_root( p_conn, p_from, p_this );
/* here D-Bus method names are associated to an handler */
METHOD_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "Identity", Identity );
METHOD_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "MprisVersion", MprisVersion );
METHOD_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "Quit", Quit ); METHOD_FUNC( DBUS_MPRIS_ROOT_INTERFACE, "Quit", Quit );
METHOD_MAPPING_END
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
} }
#undef METHOD_MAPPING_BEGIN
#undef METHOD_FUNC #undef METHOD_FUNC
#undef METHOD_MAPPING_END
...@@ -29,22 +29,47 @@ ...@@ -29,22 +29,47 @@
#include "dbus_common.h" #include "dbus_common.h"
/* MPRIS VERSION */ #define VLC_IDENTITY _("VLC media player")
#define DBUS_MPRIS_VERSION_MAJOR 2
#define DBUS_MPRIS_VERSION_MINOR 0
/* DBUS IDENTIFIERS */ /* DBUS IDENTIFIERS */
#define DBUS_MPRIS_ROOT_INTERFACE "org.freedesktop.MediaPlayer" #define DBUS_MPRIS_ROOT_INTERFACE "org.mpris.MediaPlayer2"
#define DBUS_MPRIS_ROOT_PATH "/"
/* Handle incoming dbus messages */ /* Handle incoming dbus messages */
DBusHandlerResult handle_root ( DBusConnection *p_conn, DBusHandlerResult handle_root ( DBusConnection *p_conn,
DBusMessage *p_from, DBusMessage *p_from,
void *p_this ); void *p_this );
static const DBusObjectPathVTable dbus_mpris_root_vtable = { static const char* ppsz_supported_uri_schemes[] = {
NULL, handle_root, /* handler function */ "file", "http", "https", "rtsp", "realrtsp", "pnm", "ftp", "mtp", "smb",
NULL, NULL, NULL, NULL "mms", "mmsu", "mmst", "mmsh", "unsv", "itpc", "icyx", "rtmp", "rtp",
"dccp", "dvd", "vcd", "vcdx"
}; };
static const char* ppsz_supported_mime_types[] = {
"audio/mpeg", "audio/x-mpeg",
"video/mpeg", "video/x-mpeg",
"video/mpeg-system", "video/x-mpeg-system",
"video/mp4",
"audio/mp4",
"video/x-msvideo",
"video/quicktime",
"application/ogg", "application/x-ogg",
"video/x-ms-asf", "video/x-ms-asf-plugin",
"application/x-mplayer2",
"video/x-ms-wmv",
"video/x-google-vlc-plugin",
"audio/wav", "audio/x-wav",
"audio/3gpp",
"video/3gpp",
"audio/3gpp2",
"video/3gpp2",
"video/divx",
"video/flv", "video/x-flv",
"video/x-matroska",
"audio/x-matroska",
"application/xspf+xml"
};
void UpdateRootCaps( intf_thread_t *p_intf );
#endif //dbus-root.h #endif //dbus-root.h
...@@ -36,48 +36,6 @@ ...@@ -36,48 +36,6 @@
#include "dbus_tracklist.h" #include "dbus_tracklist.h"
#include "dbus_common.h" #include "dbus_common.h"
const char* psz_tracklist_introspection_xml =
"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n"
"\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
"<node>"
" <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
" <method name=\"Introspect\">\n"
" <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"
" </method>\n"
" </interface>\n"
" <interface name=\"org.freedesktop.MediaPlayer\">\n"
" <method name=\"AddTrack\">\n"
" <arg type=\"s\" direction=\"in\" />\n"
" <arg type=\"b\" direction=\"in\" />\n"
" <arg type=\"i\" direction=\"out\" />\n"
" </method>\n"
" <method name=\"DelTrack\">\n"
" <arg type=\"i\" direction=\"in\" />\n"
" </method>\n"
" <method name=\"GetMetadata\">\n"
" <arg type=\"i\" direction=\"in\" />\n"
" <arg type=\"a{sv}\" direction=\"out\" />\n"
" </method>\n"
" <method name=\"GetCurrentTrack\">\n"
" <arg type=\"i\" direction=\"out\" />\n"
" </method>\n"
" <method name=\"GetLength\">\n"
" <arg type=#include <vlc_common.h>\"i\" direction=\"out\" />\n"
" </method>\n"
" <method name=\"SetLoop\">\n"
" <arg type=\"b\" direction=\"in\" />\n"
" </method>\n"
" <method name=\"SetRandom\">\n"
" <arg type=\"b\" direction=\"in\" />\n"
" </method>\n"
" <signal name=\"TrackListChange\">\n"
" <arg type=\"i\" />\n"
" </signal>\n"
" </interface>\n"
"</node>\n"
;
DBUS_METHOD( AddTrack ) DBUS_METHOD( AddTrack )
{ /* add the string to the playlist, and play it if the boolean is true */ { /* add the string to the playlist, and play it if the boolean is true */
REPLY_INIT; REPLY_INIT;
...@@ -279,15 +237,6 @@ DBUS_SIGNAL( TrackListChangeSignal ) ...@@ -279,15 +237,6 @@ DBUS_SIGNAL( TrackListChangeSignal )
SIGNAL_SEND; SIGNAL_SEND;
} }
DBUS_METHOD( handle_introspect_tracklist )
{
VLC_UNUSED(p_this);
REPLY_INIT;
OUT_ARGUMENTS;
ADD_STRING( &psz_tracklist_introspection_xml );
REPLY_SEND;
}
#define METHOD_FUNC( interface, method, function ) \ #define METHOD_FUNC( interface, method, function ) \
else if( dbus_message_is_method_call( p_from, interface, method ) )\ else if( dbus_message_is_method_call( p_from, interface, method ) )\
return function( p_conn, p_from, p_this ) return function( p_conn, p_from, p_this )
...@@ -295,9 +244,11 @@ DBUS_METHOD( handle_introspect_tracklist ) ...@@ -295,9 +244,11 @@ DBUS_METHOD( handle_introspect_tracklist )
DBusHandlerResult DBusHandlerResult
handle_tracklist ( DBusConnection *p_conn, DBusMessage *p_from, void *p_this ) handle_tracklist ( DBusConnection *p_conn, DBusMessage *p_from, void *p_this )
{ {
if( dbus_message_is_method_call( p_from, if(0);
DBUS_INTERFACE_INTROSPECTABLE, "Introspect" ) )
return handle_introspect_tracklist( p_conn, p_from, p_this ); /* METHOD_FUNC( DBUS_INTERFACE_PROPERTIES, "Get", GetProperty );
METHOD_FUNC( DBUS_INTERFACE_PROPERTIES, "Set", SetProperty );
METHOD_FUNC( DBUS_INTERFACE_PROPERTIES, "GetAll", GetAllProperties ); */
/* here D-Bus method names are associated to an handler */ /* here D-Bus method names are associated to an handler */
...@@ -339,7 +290,6 @@ int TrackListChangeEmit( intf_thread_t *p_intf, int signal, int i_node ) ...@@ -339,7 +290,6 @@ int TrackListChangeEmit( intf_thread_t *p_intf, int signal, int i_node )
if( p_intf->p_sys->b_dead ) if( p_intf->p_sys->b_dead )
return VLC_SUCCESS; return VLC_SUCCESS;
UpdateCaps( p_intf );
TrackListChangeSignal( p_intf->p_sys->p_conn, p_intf ); TrackListChangeSignal( p_intf->p_sys->p_conn, p_intf );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
#include <vlc_interface.h> #include <vlc_interface.h>
#include "dbus_common.h" #include "dbus_common.h"
#define DBUS_MPRIS_TRACKLIST_INTERFACE "org.freedesktop.MediaPlayer" #define DBUS_MPRIS_TRACKLIST_INTERFACE "org.mpris.MediaPlayer.TrackList"
#define DBUS_MPRIS_TRACKLIST_PATH "/TrackList" #define DBUS_MPRIS_TRACKLIST_PATH "/org/mpris/MediaPlayer/TrackList"
/* Handle incoming dbus messages */ /* Handle incoming dbus messages */
DBusHandlerResult handle_tracklist ( DBusConnection *p_conn, DBusHandlerResult handle_tracklist ( DBusConnection *p_conn,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment