Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
461fd44c
Commit
461fd44c
authored
Dec 06, 2006
by
Rafaël Carré
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
D-Bus module now uses new specification
TODO: playlist management
parent
33d29c3e
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
337 additions
and
182 deletions
+337
-182
extras/dbus-vlc.py
extras/dbus-vlc.py
+29
-27
modules/control/dbus.c
modules/control/dbus.c
+210
-97
modules/control/dbus.h
modules/control/dbus.h
+84
-38
src/libvlc-common.c
src/libvlc-common.c
+14
-20
No files found.
extras/dbus-vlc.py
View file @
461fd44c
...
...
@@ -30,50 +30,53 @@ import os
global
position
global
timer
global
playing
#
global playing
def
itemchange_handler
(
item
):
gobject
.
timeout_add
(
2000
,
timeset
)
l_item
.
set_text
(
item
)
bus
=
dbus
.
SessionBus
()
remote_object
=
bus
.
get_object
(
"org.videolan.vlc"
,
"/org/videolan/vlc"
)
interface
=
dbus
.
Interface
(
remote_object
,
"org.videolan.vlc"
)
player_o
=
bus
.
get_object
(
"org.freedesktop.MediaPlayer"
,
"/Player"
)
tracklist_o
=
bus
.
get_object
(
"org.freedesktop.MediaPlayer"
,
"/TrackList"
)
tracklist
=
dbus
.
Interface
(
tracklist_o
,
"org.freedesktop.MediaPlayer"
)
player
=
dbus
.
Interface
(
player_o
,
"org.freedesktop.MediaPlayer"
)
try
:
remote_object
.
connect_to_signal
(
"ItemChange"
,
itemchange_handler
,
dbus_interface
=
"org.videolan.vlc
"
)
player_o
.
connect_to_signal
(
"TrackChange"
,
itemchange_handler
,
dbus_interface
=
"org.freedesktop.MediaPlayer
"
)
except
:
True
def
Add
MRL
(
widget
):
def
Add
Track
(
widget
):
mrl
=
e_mrl
.
get_text
()
if
mrl
!=
None
and
mrl
!=
""
:
interface
.
AddMRL
(
mrl
,
True
)
tracklist
.
AddTrack
(
mrl
,
True
)
else
:
mrl
=
bt_file
.
get_filename
()
if
mrl
!=
None
and
mrl
!=
""
:
interface
.
AddMRL
(
"directory://"
+
mrl
,
True
)
tracklist
.
AddTrack
(
"directory://"
+
mrl
,
True
)
def
Next
(
widget
):
interface
.
Next
(
reply_handler
=
(
lambda
*
args
:
None
),
error_handler
=
(
lambda
*
args
:
None
))
player
.
Next
(
reply_handler
=
(
lambda
*
args
:
None
),
error_handler
=
(
lambda
*
args
:
None
))
update
(
0
)
def
Prev
(
widget
):
interface
.
Prev
(
reply_handler
=
(
lambda
*
args
:
None
),
error_handler
=
(
lambda
*
args
:
None
))
player
.
Prev
(
reply_handler
=
(
lambda
*
args
:
None
),
error_handler
=
(
lambda
*
args
:
None
))
update
(
0
)
def
Stop
(
widget
):
interface
.
Stop
(
reply_handler
=
(
lambda
*
args
:
None
),
error_handler
=
(
lambda
*
args
:
None
))
player
.
Stop
(
reply_handler
=
(
lambda
*
args
:
None
),
error_handler
=
(
lambda
*
args
:
None
))
update
(
0
)
def
update
(
widget
):
itemchange_handler
(
str
(
interface
.
GetPlayingItem
()))
vol
.
set_value
(
interface
.
VolumeGet
())
# itemchange_handler(str(player
.GetPlayingItem()))
vol
.
set_value
(
player
.
VolumeGet
())
GetPlayStatus
(
0
)
def
GetPlayStatus
(
widget
):
global
playing
status
=
str
(
interface
.
GetPlay
Status
())
if
status
==
"playing"
:
status
=
str
(
player
.
Get
Status
())
if
status
==
0
:
img_bt_toggle
.
set_from_stock
(
"gtk-media-pause"
,
gtk
.
ICON_SIZE_SMALL_TOOLBAR
)
playing
=
True
else
:
...
...
@@ -81,26 +84,25 @@ def GetPlayStatus(widget):
playing
=
False
def
Quit
(
widget
):
interface
.
Quit
(
reply_handler
=
(
lambda
*
args
:
None
),
error_handler
=
(
lambda
*
args
:
None
))
player
.
Quit
(
reply_handler
=
(
lambda
*
args
:
None
),
error_handler
=
(
lambda
*
args
:
None
))
l_item
.
set_text
(
""
)
def
TogglePause
(
widget
):
if
interface
.
TogglePause
()
==
True
:
img_bt_toggle
.
set_from_stock
(
gtk
.
STOCK_MEDIA_PAUSE
,
gtk
.
ICON_SIZE_SMALL_TOOLBAR
)
else
:
img_bt_toggle
.
set_from_stock
(
gtk
.
STOCK_MEDIA_PLAY
,
gtk
.
ICON_SIZE_SMALL_TOOLBAR
)
def
Pause
(
widget
):
player
.
Pause
()
# img_bt_toggle.set_from_stock(gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_SMALL_TOOLBAR)
# img_bt_toggle.set_from_stock(gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_SMALL_TOOLBAR)
update
(
0
)
def
volchange
(
widget
,
data
):
interface
.
VolumeSet
(
vol
.
get_value_as_int
(),
reply_handler
=
(
lambda
*
args
:
None
),
error_handler
=
(
lambda
*
args
:
None
))
player
.
VolumeSet
(
vol
.
get_value_as_int
(),
reply_handler
=
(
lambda
*
args
:
None
),
error_handler
=
(
lambda
*
args
:
None
))
def
timechange
(
widget
,
x
=
None
,
y
=
None
):
interface
.
PositionSet
(
time_s
.
get_value
(),
reply_handler
=
(
lambda
*
args
:
None
),
error_handler
=
(
lambda
*
args
:
None
))
player
.
PositionSet
(
time_s
.
get_value
(),
reply_handler
=
(
lambda
*
args
:
None
),
error_handler
=
(
lambda
*
args
:
None
))
def
timeset
():
global
playing
time_s
.
set_value
(
interface
.
PositionGet
())
return
playing
#
global playing
time_s
.
set_value
(
player
.
PositionGet
())
#
return playing
def
expander
(
widget
):
if
exp
.
get_expanded
()
==
False
:
...
...
@@ -177,8 +179,8 @@ menu.attach_to_widget(eventbox,None)
bt_close
.
connect
(
'clicked'
,
destroy
)
bt_quit
.
connect
(
'clicked'
,
Quit
)
bt_mrl
.
connect
(
'clicked'
,
Add
MRL
)
bt_toggle
.
connect
(
'clicked'
,
Toggle
Pause
)
bt_mrl
.
connect
(
'clicked'
,
Add
Track
)
bt_toggle
.
connect
(
'clicked'
,
Pause
)
bt_next
.
connect
(
'clicked'
,
Next
)
bt_prev
.
connect
(
'clicked'
,
Prev
)
bt_stop
.
connect
(
'clicked'
,
Stop
)
...
...
modules/control/dbus.c
View file @
461fd44c
This diff is collapsed.
Click to expand it.
modules/control/dbus.h
View file @
461fd44c
...
...
@@ -23,12 +23,12 @@
/* DBUS IDENTIFIERS */
/* this is also defined in src/libvlc-common.c for one-instance mode */
/* name registered on the session bus */
#define VLC_DBUS_SERVICE "org.videolan.vlc"
#define VLC_DBUS_INTERFACE "org.videolan.vlc"
#define VLC_DBUS_OBJECT_PATH "/org/videolan/vlc"
#define VLC_DBUS_SERVICE "org.freedesktop.MediaPlayer"
#define VLC_DBUS_INTERFACE "org.freedesktop.MediaPlayer"
#define VLC_DBUS_ROOT_PATH "/"
#define VLC_DBUS_PLAYER_PATH "/Player"
#define VLC_DBUS_TRACKLIST_PATH "/TrackList"
/* MACROS */
...
...
@@ -52,7 +52,7 @@
return DBUS_HANDLER_RESULT_HANDLED
#define SIGNAL_INIT( signal ) \
DBusMessage *p_msg = dbus_message_new_signal( VLC_DBUS_
OBJECT
_PATH, \
DBusMessage *p_msg = dbus_message_new_signal( VLC_DBUS_
PLAYER
_PATH, \
VLC_DBUS_INTERFACE, signal ); \
if( !p_msg ) return DBUS_HANDLER_RESULT_NEED_MEMORY; \
...
...
@@ -73,13 +73,12 @@
#define ADD_STRING( s ) DBUS_ADD( DBUS_TYPE_STRING, s )
#define ADD_BOOL( b ) DBUS_ADD( DBUS_TYPE_BOOLEAN, b )
#define ADD_UINT32( i ) DBUS_ADD( DBUS_TYPE_UINT32, i )
#define ADD_UINT16( i ) DBUS_ADD( DBUS_TYPE_UINT16, i )
#define ADD_INT32( i ) DBUS_ADD( DBUS_TYPE_INT32, i )
#define ADD_BYTE( b ) DBUS_ADD( DBUS_TYPE_BYTE, b )
/* XML data to answer org.freedesktop.DBus.Introspectable.Introspect requests */
const
char
*
psz_introspection_xml_data
=
const
char
*
psz_introspection_xml_data
_root
=
"<!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>"
...
...
@@ -88,21 +87,26 @@ const char* psz_introspection_xml_data =
" <arg name=
\"
data
\"
direction=
\"
out
\"
type=
\"
s
\"
/>
\n
"
" </method>
\n
"
" </interface>
\n
"
" <interface name=
\"
org.videolan.vlc
\"
>
\n
"
" <method name=
\"
GetPlayStatus
\"
>
\n
"
" <arg type=
\"
s
\"
direction=
\"
out
\"
/>
\n
"
" </method>
\n
"
" <method name=
\"
GetPlayingItem
\"
>
\n
"
" <interface name=
\"
org.freedesktop.MediaPlayer
\"
>
\n
"
" <method name=
\"
Identity
\"
>
\n
"
" <arg type=
\"
s
\"
direction=
\"
out
\"
/>
\n
"
" </method>
\n
"
" <method name=
\"
TogglePause
\"
>
\n
"
" <arg type=
\"
b
\"
direction=
\"
out
\"
/>
\n
"
" </method>
\n
"
" <method name=
\"
AddMRL
\"
>
\n
"
" <arg type=
\"
s
\"
direction=
\"
in
\"
/>
\n
"
" <arg type=
\"
b
\"
direction=
\"
in
\"
/>
\n
"
" </interface>
\n
"
"</node>
\n
"
;
const
char
*
psz_introspection_xml_data_player
=
"<!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
"
" <method name=
\"
Nothing
\"
>
\n
"
" </interface>
\n
"
" <interface name=
\"
org.videolan.vlc
\"
>
\n
"
" <method name=
\"
GetStatus
\"
>
\n
"
" <arg type=
\"
i
\"
direction=
\"
out
\"
/>
\n
"
" </method>
\n
"
" <method name=
\"
Quit
\"
>
\n
"
" </method>
\n
"
...
...
@@ -112,36 +116,78 @@ const char* psz_introspection_xml_data =
" </method>
\n
"
" <method name=
\"
Stop
\"
>
\n
"
" </method>
\n
"
" <method name=
\"
Play
\"
>
\n
"
" </method>
\n
"
" <method name=
\"
Pause
\"
>
\n
"
" </method>
\n
"
" <method name=
\"
VolumeSet
\"
>
\n
"
" <arg type=
\"
q
\"
direction=
\"
in
\"
/>
\n
"
" <arg type=
\"
i
\"
direction=
\"
in
\"
/>
\n
"
" </method>
\n
"
" <method name=
\"
VolumeGet
\"
>
\n
"
" <arg type=
\"
q
\"
direction=
\"
out
\"
/>
\n
"
" <arg type=
\"
i
\"
direction=
\"
out
\"
/>
\n
"
" </method>
\n
"
" <method name=
\"
PositionSet
\"
>
\n
"
" <arg type=
\"
q
\"
direction=
\"
in
\"
/>
\n
"
" <arg type=
\"
i
\"
direction=
\"
in
\"
/>
\n
"
" </method>
\n
"
" <method name=
\"
PositionGet
\"
>
\n
"
" <arg type=
\"
q
\"
direction=
\"
out
\"
/>
\n
"
" <arg type=
\"
i
\"
direction=
\"
out
\"
/>
\n
"
" </method>
\n
"
" <method name=
\"
PlaylistExport_XSPF
\"
>
\n
"
" </interface>
\n
"
"</node>
\n
"
;
const
char
*
psz_introspection_xml_data_tracklist
=
"<!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.videolan.vlc
\"
>
\n
"
" <method name=
\"
AddTrack
\"
>
\n
"
" <arg type=
\"
s
\"
direction=
\"
in
\"
/>
\n
"
" <arg type=
\"
q
\"
direction=
\"
out
\"
/>
\n
"
" <arg type=
\"
b
\"
direction=
\"
in
\"
/>
\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
"
" </interface>
\n
"
"</node>
\n
"
;
/* Handling of messages received onn VLC_DBUS_OBJECT_PATH */
DBUS_METHOD
(
handle_messages
);
/* handler function */
/* vtable passed to dbus_connection_register_object_path() */
static
DBusObjectPathVTable
vlc_dbus_vtable
=
{
NULL
,
/* Called when vtable is unregistered or its connection is freed*/
handle_messages
,
/* handler function */
NULL
,
NULL
,
NULL
,
NULL
#define VLC_DBUS_ROOT_PATH "/"
#define VLC_DBUS_PLAYER_PATH "/Player"
#define VLC_DBUS_TRACKLIST_PATH "/TrackList"
/* Handle messages reception */
DBUS_METHOD
(
handle_root
);
DBUS_METHOD
(
handle_player
);
DBUS_METHOD
(
handle_tracklist
);
static
DBusObjectPathVTable
vlc_dbus_root_vtable
=
{
NULL
,
handle_root
,
/* handler function */
NULL
,
NULL
,
NULL
,
NULL
};
static
DBusObjectPathVTable
vlc_dbus_player_vtable
=
{
NULL
,
handle_player
,
/* handler function */
NULL
,
NULL
,
NULL
,
NULL
};
static
DBusObjectPathVTable
vlc_dbus_tracklist_vtable
=
{
NULL
,
handle_tracklist
,
/* handler function */
NULL
,
NULL
,
NULL
,
NULL
};
src/libvlc-common.c
View file @
461fd44c
...
...
@@ -63,13 +63,8 @@
#endif
#ifdef HAVE_DBUS_3
/* used for one-instance mode */
# include <dbus/dbus.h>
/* this is also defined in modules/control/dbus.h */
/* names registered on the session bus */
#define VLC_DBUS_SERVICE "org.videolan.vlc"
#define VLC_DBUS_INTERFACE "org.videolan.vlc"
#define VLC_DBUS_OBJECT_PATH "/org/videolan/vlc"
#endif
#ifdef HAVE_HAL
...
...
@@ -632,12 +627,12 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] )
else
{
/* we request the service org.videolan.vlc */
i_dbus_service
=
dbus_bus_request_name
(
p_conn
,
VLC_DBUS_SERVICE
,
0
,
i_dbus_service
=
dbus_bus_request_name
(
p_conn
,
"org.videolan.vlc"
,
0
,
&
dbus_error
);
if
(
dbus_error_is_set
(
&
dbus_error
)
)
{
msg_Err
(
p_libvlc
,
"Error requesting
%s service: %s
\n
"
,
VLC_DBUS_SERVICE
,
dbus_error
.
message
);
msg_Err
(
p_libvlc
,
"Error requesting
org.videolan.vlc service: "
"%s
\n
"
,
dbus_error
.
message
);
dbus_error_free
(
&
dbus_error
);
}
else
...
...
@@ -646,14 +641,14 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] )
{
/* the name is already registered by another instance of vlc */
if
(
config_GetInt
(
p_libvlc
,
"one-instance"
)
)
{
/* check if
/org/videolan/vlc exists
/* check if
a Media Player is available
* if not: D-Bus control is not enabled on the other
* instance and we can't pass MRLs to it */
DBusMessage
*
p_test_msg
,
*
p_test_reply
;
p_test_msg
=
dbus_message_new_method_call
(
VLC_DBUS_SERVICE
,
VLC_DBUS_OBJECT_PATH
,
VLC_DBUS_INTERFACE
,
"Nothing
"
);
/* block unti a reply arrives */
"org.freedesktop.MediaPlayer"
,
"/"
,
"org.freedesktop.MediaPlayer"
,
"Identity
"
);
/* block unti
l
a reply arrives */
p_test_reply
=
dbus_connection_send_with_reply_and_block
(
p_conn
,
p_test_msg
,
-
1
,
&
dbus_error
);
dbus_message_unref
(
p_test_msg
);
...
...
@@ -683,8 +678,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] )
ppsz_argv
[
i_input
]
);
p_dbus_msg
=
dbus_message_new_method_call
(
VLC_DBUS_SERVICE
,
VLC_DBUS_OBJECT_PATH
,
VLC_DBUS_INTERFACE
,
"AddMRL
"
);
"org.freedesktop.MediaPlayer"
,
"/TrackList"
,
"org.freedesktop.MediaPlayer"
,
"AddTrack
"
);
if
(
NULL
==
p_dbus_msg
)
{
...
...
@@ -748,9 +743,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] )
}
/* we're not in one-instance mode */
else
{
msg_Dbg
(
p_libvlc
,
"%s is already registered on the session bus
\n
"
,
VLC_DBUS_SERVICE
);
msg_Dbg
(
p_libvlc
,
"org.videolan.vlc is already registered "
"on the session bus
\n
"
);
}
}
/* the named is owned by something else */
else
...
...
@@ -762,8 +756,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] )
msg_Err
(
p_libvlc
,
"Out of memory"
);
}
msg_Dbg
(
p_libvlc
,
"We are the primary owner of
%s on the session bus"
,
VLC_DBUS_SERVICE
);
"We are the primary owner of
org.videolan.vlc on the "
" session bus"
);
}
}
/* no error when requesting the name on the bus */
/* we unreference the connection when we've finished with it */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment