Skip to content

Commit

Permalink
Implement get_composite_mode on DBus-Api
Browse files Browse the repository at this point in the history
Remote-Applications such as the Python-UI can retrieve the current Composition-Mode this way
  • Loading branch information
MaZderMind committed Jan 17, 2015
1 parent a96b423 commit b915863
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 0 deletions.
23 changes: 23 additions & 0 deletions python-api/gstswitch/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,29 @@ def set_composite_mode(self, mode):
new_message = "{0}: {1}".format(message, "set_composite_mode")
raise ConnectionError(new_message)

def get_composite_mode(self):
"""get_composite_mode(out b result);
Calls get_composite_mode remotely
:returns: tuple with first element being the current compsition mode
"""
try:
connection = self.connection
result = connection.call_sync(
self.bus_name,
self.object_path,
self.default_interface,
'get_composite_mode',
None,
GLib.VariantType.new("(i)"),
Gio.DBusCallFlags.NONE, -1,
None)
return result
except GLib.GError as error:
message = error.message
new_message = "{0}: {1}".format(message, "get_composite_mode")
raise ConnectionError(new_message)

def set_encode_mode(self, channel):
"""set_encode_mode(in i channel,
out b result);
Expand Down
24 changes: 24 additions & 0 deletions python-api/gstswitch/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,30 @@ def set_composite_mode(self, mode):
# raise some Exception
return res

def get_composite_mode(self):
"""Set the current composite mode.
Modes allowed are:
- COMPOSITE_NONE
- COMPOSITE_PIP
- COMPOSITE_DUAL_PREVIEW
- COMPOSITE_DUAL_EQUAL
:returns: The current composition mode
"""
self.establish_connection()
# only modes from 0 to 3 are supported
res = None
try:
conn = self.connection.get_composite_mode()
res = conn.unpack()[0]
if res in range(0, 4):
print "Current composite mode is %u" % (res)
except AttributeError:
raise ConnectionReturnError('Connection returned invalid '
'values. Should return a '
'GVariant tuple')
return res

def set_encode_mode(self, channel):
"""Set the encode mode
WARNING: THIS DOES NOT WORK.
Expand Down
23 changes: 23 additions & 0 deletions tools/gstswitchcontroller.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ static const gchar introspection_xml[] =
" <arg type='i' name='channel' direction='in'/>"
" <arg type='b' name='result' direction='out'/>"
" </method>"
" <method name='get_composite_mode'>"
" <arg type='i' name='result' direction='out'/>"
" </method>"
" <method name='set_encode_mode'>"
" <arg type='i' name='channel' direction='in'/>"
" <arg type='b' name='result' direction='out'/>"
Expand Down Expand Up @@ -968,6 +971,24 @@ gst_switch_controller__set_composite_mode (GstSwitchController * controller,
return result;
}

/**
* @memberof GstSwitchController
*
* Remoting method stub of "get_composite_mode".
*/
static GVariant *
gst_switch_controller__get_composite_mode (GstSwitchController * controller,
GDBusConnection * connection, GVariant * parameters)
{
GVariant *result = NULL;
gint mode;
if (controller->server) {
mode = gst_switch_server_get_composite_mode (controller->server);
result = g_variant_new ("(i)", mode);
}
return result;
}

/**
* @memberof GstSwitchController
*
Expand Down Expand Up @@ -1089,6 +1110,8 @@ static MethodTableEntry gst_switch_controller_method_table[] = {
(MethodFunc) gst_switch_controller__get_preview_ports},
{"set_composite_mode",
(MethodFunc) gst_switch_controller__set_composite_mode},
{"get_composite_mode",
(MethodFunc) gst_switch_controller__get_composite_mode},
{"new_record", (MethodFunc) gst_switch_controller__new_record},
{"adjust_pip", (MethodFunc) gst_switch_controller__adjust_pip},
{"click_video", (MethodFunc) gst_switch_controller__click_video},
Expand Down
6 changes: 6 additions & 0 deletions tools/gstswitchserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,12 @@ gst_switch_server_set_composite_mode (GstSwitchServer * srv, gint mode)
return result;
}

gint
gst_switch_server_get_composite_mode (GstSwitchServer * srv)
{
return srv->composite->mode;
}

static void
gst_switch_server_start_audio (GstCase * cas, GstSwitchServer * srv)
{
Expand Down
1 change: 1 addition & 0 deletions tools/gstswitchserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ GArray *gst_switch_server_get_preview_sink_ports (GstSwitchServer * srv,
GArray ** serves, GArray ** types);
gboolean gst_switch_server_set_composite_mode (GstSwitchServer * srv,
gint mode);
gint gst_switch_server_get_composite_mode (GstSwitchServer * srv);
gboolean gst_switch_server_switch (GstSwitchServer * srv, gint channel,
gint port);
gboolean gst_switch_server_click_video (GstSwitchServer * srv,
Expand Down

0 comments on commit b915863

Please sign in to comment.