| 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 |
|
|---|
| 26 |
#define VLC_MPRIS_VERSION_MAJOR 1 |
|---|
| 27 |
#define VLC_MPRIS_VERSION_MINOR 0 |
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
#define VLC_MPRIS_DBUS_SERVICE "org.mpris.vlc" |
|---|
| 33 |
#define MPRIS_DBUS_INTERFACE "org.freedesktop.MediaPlayer" |
|---|
| 34 |
#define MPRIS_DBUS_ROOT_PATH "/" |
|---|
| 35 |
#define MPRIS_DBUS_PLAYER_PATH "/Player" |
|---|
| 36 |
#define MPRIS_DBUS_TRACKLIST_PATH "/TrackList" |
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
#define DBUS_METHOD( method_function ) \ |
|---|
| 41 |
static DBusHandlerResult method_function \ |
|---|
| 42 |
( DBusConnection *p_conn, DBusMessage *p_from, void *p_this ) |
|---|
| 43 |
|
|---|
| 44 |
#define DBUS_SIGNAL( signal_function ) \ |
|---|
| 45 |
static DBusHandlerResult signal_function \ |
|---|
| 46 |
( DBusConnection *p_conn, void *p_data ) |
|---|
| 47 |
|
|---|
| 48 |
#define REPLY_INIT \ |
|---|
| 49 |
DBusMessage* p_msg = dbus_message_new_method_return( p_from ); \ |
|---|
| 50 |
if( !p_msg ) return DBUS_HANDLER_RESULT_NEED_MEMORY; \ |
|---|
| 51 |
|
|---|
| 52 |
#define REPLY_SEND \ |
|---|
| 53 |
if( !dbus_connection_send( p_conn, p_msg, NULL ) ) \ |
|---|
| 54 |
return DBUS_HANDLER_RESULT_NEED_MEMORY; \ |
|---|
| 55 |
dbus_connection_flush( p_conn ); \ |
|---|
| 56 |
dbus_message_unref( p_msg ); \ |
|---|
| 57 |
return DBUS_HANDLER_RESULT_HANDLED |
|---|
| 58 |
|
|---|
| 59 |
#define SIGNAL_INIT( signal ) \ |
|---|
| 60 |
DBusMessage *p_msg = dbus_message_new_signal( MPRIS_DBUS_PLAYER_PATH, \ |
|---|
| 61 |
MPRIS_DBUS_INTERFACE, signal ); \ |
|---|
| 62 |
if( !p_msg ) return DBUS_HANDLER_RESULT_NEED_MEMORY; \ |
|---|
| 63 |
|
|---|
| 64 |
#define SIGNAL_SEND \ |
|---|
| 65 |
if( !dbus_connection_send( p_conn, p_msg, NULL ) ) \ |
|---|
| 66 |
return DBUS_HANDLER_RESULT_NEED_MEMORY; \ |
|---|
| 67 |
dbus_message_unref( p_msg ); \ |
|---|
| 68 |
dbus_connection_flush( p_conn ); \ |
|---|
| 69 |
return DBUS_HANDLER_RESULT_HANDLED |
|---|
| 70 |
|
|---|
| 71 |
#define OUT_ARGUMENTS \ |
|---|
| 72 |
DBusMessageIter args; \ |
|---|
| 73 |
dbus_message_iter_init_append( p_msg, &args ) |
|---|
| 74 |
|
|---|
| 75 |
#define DBUS_ADD( dbus_type, value ) \ |
|---|
| 76 |
if( !dbus_message_iter_append_basic( &args, dbus_type, value ) ) \ |
|---|
| 77 |
return DBUS_HANDLER_RESULT_NEED_MEMORY |
|---|
| 78 |
|
|---|
| 79 |
#define ADD_STRING( s ) DBUS_ADD( DBUS_TYPE_STRING, s ) |
|---|
| 80 |
#define ADD_BOOL( b ) DBUS_ADD( DBUS_TYPE_BOOLEAN, b ) |
|---|
| 81 |
#define ADD_INT32( i ) DBUS_ADD( DBUS_TYPE_INT32, i ) |
|---|
| 82 |
#define ADD_BYTE( b ) DBUS_ADD( DBUS_TYPE_BYTE, b ) |
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
const char* psz_introspection_xml_data_root = |
|---|
| 87 |
"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n" |
|---|
| 88 |
"\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n" |
|---|
| 89 |
"<node>\n" |
|---|
| 90 |
" <node name=\"Player\"/>\n" |
|---|
| 91 |
" <node name=\"TrackList\"/>\n" |
|---|
| 92 |
" <interface name=\"org.freedesktop.DBus.Introspectable\">\n" |
|---|
| 93 |
" <method name=\"Introspect\">\n" |
|---|
| 94 |
" <arg name=\"data\" direction=\"out\" type=\"s\"/>\n" |
|---|
| 95 |
" </method>\n" |
|---|
| 96 |
" </interface>\n" |
|---|
| 97 |
" <interface name=\"org.freedesktop.MediaPlayer\">\n" |
|---|
| 98 |
" <method name=\"Identity\">\n" |
|---|
| 99 |
" <arg type=\"s\" direction=\"out\" />\n" |
|---|
| 100 |
" </method>\n" |
|---|
| 101 |
" <method name=\"MprisVersion\">\n" |
|---|
| 102 |
" <arg type=\"(qq)\" direction=\"out\" />\n" |
|---|
| 103 |
" </method>\n" |
|---|
| 104 |
" <method name=\"Quit\">\n" |
|---|
| 105 |
" </method>\n" |
|---|
| 106 |
" </interface>\n" |
|---|
| 107 |
"</node>\n" |
|---|
| 108 |
; |
|---|
| 109 |
|
|---|
| 110 |
const char* psz_introspection_xml_data_player = |
|---|
| 111 |
"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n" |
|---|
| 112 |
"\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n" |
|---|
| 113 |
"<node>" |
|---|
| 114 |
" <interface name=\"org.freedesktop.DBus.Introspectable\">\n" |
|---|
| 115 |
" <method name=\"Introspect\">\n" |
|---|
| 116 |
" <arg name=\"data\" direction=\"out\" type=\"s\"/>\n" |
|---|
| 117 |
" </method>\n" |
|---|
| 118 |
" </interface>\n" |
|---|
| 119 |
" <interface name=\"org.freedesktop.MediaPlayer\">\n" |
|---|
| 120 |
" <method name=\"GetStatus\">\n" |
|---|
| 121 |
" <arg type=\"(iiii)\" direction=\"out\" />\n" |
|---|
| 122 |
" </method>\n" |
|---|
| 123 |
" <method name=\"Prev\">\n" |
|---|
| 124 |
" </method>\n" |
|---|
| 125 |
" <method name=\"Next\">\n" |
|---|
| 126 |
" </method>\n" |
|---|
| 127 |
" <method name=\"Stop\">\n" |
|---|
| 128 |
" </method>\n" |
|---|
| 129 |
" <method name=\"Play\">\n" |
|---|
| 130 |
" </method>\n" |
|---|
| 131 |
" <method name=\"Pause\">\n" |
|---|
| 132 |
" </method>\n" |
|---|
| 133 |
" <method name=\"Repeat\">\n" |
|---|
| 134 |
" <arg type=\"b\" direction=\"in\" />\n" |
|---|
| 135 |
" </method>\n" |
|---|
| 136 |
" <method name=\"VolumeSet\">\n" |
|---|
| 137 |
" <arg type=\"i\" direction=\"in\" />\n" |
|---|
| 138 |
" </method>\n" |
|---|
| 139 |
" <method name=\"VolumeGet\">\n" |
|---|
| 140 |
" <arg type=\"i\" direction=\"out\" />\n" |
|---|
| 141 |
" </method>\n" |
|---|
| 142 |
" <method name=\"PositionSet\">\n" |
|---|
| 143 |
" <arg type=\"i\" direction=\"in\" />\n" |
|---|
| 144 |
" </method>\n" |
|---|
| 145 |
" <method name=\"PositionGet\">\n" |
|---|
| 146 |
" <arg type=\"i\" direction=\"out\" />\n" |
|---|
| 147 |
" </method>\n" |
|---|
| 148 |
" <method name=\"GetMetadata\">\n" |
|---|
| 149 |
" <arg type=\"a{sv}\" direction=\"out\" />\n" |
|---|
| 150 |
" </method>\n" |
|---|
| 151 |
" <method name=\"GetCaps\">\n" |
|---|
| 152 |
" <arg type=\"i\" direction=\"out\" />\n" |
|---|
| 153 |
" </method>\n" |
|---|
| 154 |
" <signal name=\"TrackChange\">\n" |
|---|
| 155 |
" <arg type=\"a{sv}\"/>\n" |
|---|
| 156 |
" </signal>\n" |
|---|
| 157 |
" <signal name=\"StatusChange\">\n" |
|---|
| 158 |
" <arg type=\"(iiii)\"/>\n" |
|---|
| 159 |
" </signal>\n" |
|---|
| 160 |
" <signal name=\"CapsChange\">\n" |
|---|
| 161 |
" <arg type=\"i\"/>\n" |
|---|
| 162 |
" </signal>\n" |
|---|
| 163 |
" </interface>\n" |
|---|
| 164 |
"</node>\n" |
|---|
| 165 |
; |
|---|
| 166 |
|
|---|
| 167 |
const char* psz_introspection_xml_data_tracklist = |
|---|
| 168 |
"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n" |
|---|
| 169 |
"\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n" |
|---|
| 170 |
"<node>" |
|---|
| 171 |
" <interface name=\"org.freedesktop.DBus.Introspectable\">\n" |
|---|
| 172 |
" <method name=\"Introspect\">\n" |
|---|
| 173 |
" <arg name=\"data\" direction=\"out\" type=\"s\"/>\n" |
|---|
| 174 |
" </method>\n" |
|---|
| 175 |
" </interface>\n" |
|---|
| 176 |
" <interface name=\"org.freedesktop.MediaPlayer\">\n" |
|---|
| 177 |
" <method name=\"AddTrack\">\n" |
|---|
| 178 |
" <arg type=\"s\" direction=\"in\" />\n" |
|---|
| 179 |
" <arg type=\"b\" direction=\"in\" />\n" |
|---|
| 180 |
" <arg type=\"i\" direction=\"out\" />\n" |
|---|
| 181 |
" </method>\n" |
|---|
| 182 |
" <method name=\"DelTrack\">\n" |
|---|
| 183 |
" <arg type=\"i\" direction=\"in\" />\n" |
|---|
| 184 |
" </method>\n" |
|---|
| 185 |
" <method name=\"GetMetadata\">\n" |
|---|
| 186 |
" <arg type=\"i\" direction=\"in\" />\n" |
|---|
| 187 |
" <arg type=\"a{sv}\" direction=\"out\" />\n" |
|---|
| 188 |
" </method>\n" |
|---|
| 189 |
" <method name=\"GetCurrentTrack\">\n" |
|---|
| 190 |
" <arg type=\"i\" direction=\"out\" />\n" |
|---|
| 191 |
" </method>\n" |
|---|
| 192 |
" <method name=\"GetLength\">\n" |
|---|
| 193 |
" <arg type=\"i\" direction=\"out\" />\n" |
|---|
| 194 |
" </method>\n" |
|---|
| 195 |
" <method name=\"SetLoop\">\n" |
|---|
| 196 |
" <arg type=\"b\" direction=\"in\" />\n" |
|---|
| 197 |
" </method>\n" |
|---|
| 198 |
" <method name=\"SetRandom\">\n" |
|---|
| 199 |
" <arg type=\"b\" direction=\"in\" />\n" |
|---|
| 200 |
" </method>\n" |
|---|
| 201 |
" <signal name=\"TrackListChange\">\n" |
|---|
| 202 |
" <arg type=\"i\" />\n" |
|---|
| 203 |
" </signal>\n" |
|---|
| 204 |
" </interface>\n" |
|---|
| 205 |
"</node>\n" |
|---|
| 206 |
; |
|---|
| 207 |
|
|---|
| 208 |
#define MPRIS_DBUS_ROOT_PATH "/" |
|---|
| 209 |
#define MPRIS_DBUS_PLAYER_PATH "/Player" |
|---|
| 210 |
#define MPRIS_DBUS_TRACKLIST_PATH "/TrackList" |
|---|
| 211 |
|
|---|
| 212 |
|
|---|
| 213 |
DBUS_METHOD( handle_root ); |
|---|
| 214 |
DBUS_METHOD( handle_player ); |
|---|
| 215 |
DBUS_METHOD( handle_tracklist ); |
|---|
| 216 |
|
|---|
| 217 |
static const DBusObjectPathVTable vlc_dbus_root_vtable = { |
|---|
| 218 |
NULL, handle_root, |
|---|
| 219 |
NULL, NULL, NULL, NULL |
|---|
| 220 |
}; |
|---|
| 221 |
|
|---|
| 222 |
static const DBusObjectPathVTable vlc_dbus_player_vtable = { |
|---|
| 223 |
NULL, handle_player, |
|---|
| 224 |
NULL, NULL, NULL, NULL |
|---|
| 225 |
}; |
|---|
| 226 |
|
|---|
| 227 |
static const DBusObjectPathVTable vlc_dbus_tracklist_vtable = { |
|---|
| 228 |
NULL, handle_tracklist, |
|---|
| 229 |
NULL, NULL, NULL, NULL |
|---|
| 230 |
}; |
|---|
| 231 |
|
|---|