[longomatch] Add bindings for the device change signal
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add bindings for the device change signal
- Date: Mon, 2 Aug 2010 22:44:35 +0000 (UTC)
commit 0df6a684bd4cf62e1f4e461c2948d48914a0b433
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sun Aug 1 20:50:16 2010 +0200
Add bindings for the device change signal
CesarPlayer/Capturer/GstCameraCapturer.cs | 69 +++++++++++++++++++++++++++++
CesarPlayer/Common/Handlers.cs | 10 ++++
2 files changed, 79 insertions(+), 0 deletions(-)
---
diff --git a/CesarPlayer/Capturer/GstCameraCapturer.cs b/CesarPlayer/Capturer/GstCameraCapturer.cs
index 4806b6f..7f6b0d5 100644
--- a/CesarPlayer/Capturer/GstCameraCapturer.cs
+++ b/CesarPlayer/Capturer/GstCameraCapturer.cs
@@ -212,6 +212,75 @@ namespace LongoMatch.Video.Capturer {
sig.RemoveDelegate (value);
}
}
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ delegate void DeviceChangeSignalDelegate (IntPtr arg0, int arg1, IntPtr gch);
+
+ static void DeviceChangeSignalCallback (IntPtr arg0, int arg1, IntPtr gch)
+ {
+ DeviceChangeArgs args = new DeviceChangeArgs ();
+ try {
+ GLib.Signal sig = ((GCHandle) gch).Target as GLib.Signal;
+ if (sig == null)
+ throw new Exception("Unknown signal GC handle received " + gch);
+
+ args.Args = new object[1];
+ args.Args[0] = arg1;
+ DeviceChangeHandler handler = (DeviceChangeHandler) sig.Handler;
+ handler (GLib.Object.GetObject (arg0), args);
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException (e, false);
+ }
+ }
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ delegate void DeviceChangeVMDelegate (IntPtr gcc, int deviceChange);
+
+ static DeviceChangeVMDelegate DeviceChangeVMCallback;
+
+ static void device_change_cb (IntPtr gcc, int deviceChange)
+ {
+ try {
+ GstCameraCapturer gcc_managed = GLib.Object.GetObject (gcc, false) as GstCameraCapturer;
+ gcc_managed.OnDeviceChange (deviceChange);
+ } catch (Exception e) {
+ GLib.ExceptionManager.RaiseUnhandledException (e, false);
+ }
+ }
+
+ private static void OverrideDeviceChange (GLib.GType gtype)
+ {
+ if (DeviceChangeVMCallback == null)
+ DeviceChangeVMCallback = new DeviceChangeVMDelegate (device_change_cb);
+ OverrideVirtualMethod (gtype, "device_change", DeviceChangeVMCallback);
+ }
+
+ [GLib.DefaultSignalHandler(Type=typeof(LongoMatch.Video.Capturer.GstCameraCapturer), ConnectionMethod="OverrideDeviceChange")]
+ protected virtual void OnDeviceChange (int deviceChange)
+ {
+ GLib.Value ret = GLib.Value.Empty;
+ GLib.ValueArray inst_and_params = new GLib.ValueArray (2);
+ GLib.Value[] vals = new GLib.Value [2];
+ vals [0] = new GLib.Value (this);
+ inst_and_params.Append (vals [0]);
+ vals [1] = new GLib.Value (deviceChange);
+ inst_and_params.Append (vals [1]);
+ g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
+ foreach (GLib.Value v in vals)
+ v.Dispose ();
+ }
+
+ [GLib.Signal("device_change")]
+ public event DeviceChangeHandler DeviceChange {
+ add {
+ GLib.Signal sig = GLib.Signal.Lookup (this, "device_change", new DeviceChangeSignalDelegate(DeviceChangeSignalCallback));
+ sig.AddDelegate (value);
+ }
+ remove {
+ GLib.Signal sig = GLib.Signal.Lookup (this, "device_change", new DeviceChangeSignalDelegate(DeviceChangeSignalCallback));
+ sig.RemoveDelegate (value);
+ }
+ }
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void EosVMDelegate (IntPtr gcc);
diff --git a/CesarPlayer/Common/Handlers.cs b/CesarPlayer/Common/Handlers.cs
index 15718d1..ae02ad6 100644
--- a/CesarPlayer/Common/Handlers.cs
+++ b/CesarPlayer/Common/Handlers.cs
@@ -39,6 +39,7 @@ namespace LongoMatch.Video.Common
public delegate void PercentCompletedHandler(object o, PercentCompletedArgs args);
public delegate void StateChangeHandler(object o, StateChangeArgs args);
public delegate void TickHandler(object o, TickArgs args);
+ public delegate void DeviceChangeHandler(object o, DeviceChangeArgs args);
@@ -93,4 +94,13 @@ namespace LongoMatch.Video.Common
}
}
}
+
+ public class DeviceChangeArgs : GLib.SignalArgs {
+ public int DeviceChange{
+ get {
+ return (int) Args[0];
+ }
+ }
+
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]