[gnome-dvb-daemon] Added GetAdapterInfo method to Manager DBus interface.
- From: Sebastian Polsterl <sebp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-dvb-daemon] Added GetAdapterInfo method to Manager DBus interface.
- Date: Fri, 9 Dec 2011 11:35:06 +0000 (UTC)
commit ba6537ea2417f6056f2d3e6ead363b5a02d5a60d
Author: Sebastian PÃlsterl <sebp k-d-w org>
Date: Fri Dec 9 12:22:46 2011 +0100
Added GetAdapterInfo method to Manager DBus interface.
Drop dependency on gstreamer python module.
client/gnomedvb/DBusWrapper.py | 31 ++++++-------------------------
configure.ac | 3 +--
src/Manager.vala | 38 ++++++++++++++++++++++++++++++++++++++
src/dbus/IDBusManager.vala | 14 +++++++++++++-
4 files changed, 58 insertions(+), 28 deletions(-)
---
diff --git a/client/gnomedvb/DBusWrapper.py b/client/gnomedvb/DBusWrapper.py
index 002ea0a..41cab5a 100644
--- a/client/gnomedvb/DBusWrapper.py
+++ b/client/gnomedvb/DBusWrapper.py
@@ -17,7 +17,6 @@
# along with GNOME DVB Daemon. If not, see <http://www.gnu.org/licenses/>.
from gi.repository import GObject
-import gst
import re
import sys
from gi.repository import Gio
@@ -51,29 +50,8 @@ def _default_error_handler_func(*args):
global_error_handler = _default_error_handler_func
def get_adapter_info(adapter, frontend):
- dvbelement = gst.element_factory_make ("dvbsrc", "test_dvbsrc")
- dvbelement.set_property("adapter", int(adapter))
- dvbelement.set_property("frontend", int(frontend))
- pipeline = gst.Pipeline("")
- pipeline.add(dvbelement)
- pipeline.set_state(gst.STATE_READY)
- pipeline.get_state()
- bus = pipeline.get_bus()
- info = {}
- success = False
- while bus.have_pending():
- msg = bus.pop()
- if msg.type == gst.MESSAGE_ELEMENT and msg.src == dvbelement:
- structure = msg.structure
- if structure.get_name() == "dvb-adapter":
- info["type"] = structure["type"]
- info["name"] = structure["name"]
- success = True
- break
- elif msg.type == gst.MESSAGE_ERROR:
- info = msg.structure["debug"]
- global_error_handler(info)
- pipeline.set_state(gst.STATE_NULL)
+ manager = DVBManagerClient()
+ info, success = manager.get_adapter_info(adapter, frontend)
return (success, info)
def get_dvb_devices():
@@ -161,7 +139,10 @@ class DVBManagerClient(GObject.GObject):
def get_devices(self, **kwargs):
return self.manager.GetDevices()
-
+
+ def get_adapter_info(self, adapter, frontend, **kwargs):
+ return self.manager.GetAdapterInfo('(uu)', adapter, frontend, **kwargs)
+
def on_g_signal(self, proxy, sender_name, signal_name, params):
params = params.unpack()
if signal_name == "GroupAdded":
diff --git a/configure.ac b/configure.ac
index 191f26e..bedee9e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -140,8 +140,7 @@ PKG_CHECK_MODULES(PYGOBJECT, pygobject-3.0 >= $PYGOBJECT_REQUIRED)
dnl ******************
dnl * Python modules
dnl *****************
-AM_CHECK_PYMOD(gobject)
-AM_CHECK_PYMOD(gst)
+AM_CHECK_PYMOD(gi.repository)
AC_CONFIG_FILES([
Makefile
diff --git a/src/Manager.vala b/src/Manager.vala
index 9fedc11..60b0352 100644
--- a/src/Manager.vala
+++ b/src/Manager.vala
@@ -380,6 +380,44 @@ namespace DVB {
return arr;
}
+ public bool GetAdapterInfo (uint adapter, uint frontend, out AdapterInfo info) throws DBusError {
+ Gst.Element dvbelement = Gst.ElementFactory.make ("dvbsrc", null);
+ dvbelement.set("adapter", adapter);
+ dvbelement.set("frontend", frontend);
+
+ Gst.Element pipeline = new Gst.Pipeline(null);
+ ((Gst.Bin)pipeline).add(dvbelement);
+ pipeline.set_state(Gst.State.READY);
+
+ Gst.Bus bus = pipeline.get_bus ();
+
+ info = AdapterInfo();
+ bool success = false;
+ while (bus.have_pending()) {
+ Gst.Message msg = bus.pop ();
+ if (msg.type == Gst.MessageType.ELEMENT && msg.src == dvbelement) {
+ Gst.Structure structure = msg.get_structure ();
+ if (structure.get_name () == "dvb-adapter") {
+ info.name = structure.get_string ("name");
+ info.type = structure.get_string ("type");
+ success = true;
+ break;
+ }
+ } else if (msg.type == Gst.MessageType.ERROR) {
+ log.warning ("Could not retrieve adapter infos: %s",
+ msg.get_structure().to_string ());
+ }
+ }
+ pipeline.set_state (Gst.State.NULL);
+
+ if (!success) {
+ info.name = "unknown";
+ info.type = "unknown";
+ }
+
+ return success;
+ }
+
/**
* @returns: Whether the device has been added successfully
*
diff --git a/src/dbus/IDBusManager.vala b/src/dbus/IDBusManager.vala
index 5c46790..cc52442 100644
--- a/src/dbus/IDBusManager.vala
+++ b/src/dbus/IDBusManager.vala
@@ -25,7 +25,12 @@ namespace DVB {
public int id;
public string name;
}
-
+
+ public struct AdapterInfo {
+ public string name;
+ public string type;
+ }
+
[DBus (name = "org.gnome.DVB.Manager")]
public interface IDBusManager : GLib.Object {
@@ -113,6 +118,13 @@ namespace DVB {
*/
public abstract GLib.HashTable<string, string>[] GetDevices () throws DBusError;
+ /**
+ * @info: type and name of adapter
+ * @returns: TRUE on success
+ */
+ public abstract bool GetAdapterInfo (uint adapter, uint frontend,
+ out AdapterInfo info) throws DBusError;
+
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]