From: Sebastian Dröge Date: Thu, 14 May 2009 14:50:16 +0000 (+0200) Subject: Add Gst.Interfaces.Navigation bindings X-Git-Tag: 1.19.3~483^2~603 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fdc99f178bcc5e235011b6c502efd88e2b0f29c0;p=platform%2Fupstream%2Fgstreamer.git Add Gst.Interfaces.Navigation bindings --- diff --git a/gstreamer-sharp/Gstreamer.metadata b/gstreamer-sharp/Gstreamer.metadata index a5ae5b6..0a9558e 100644 --- a/gstreamer-sharp/Gstreamer.metadata +++ b/gstreamer-sharp/Gstreamer.metadata @@ -987,7 +987,18 @@ MixerMessageType MixerTrackFlags MixerType + NavigationCommand + + + + + + + + + + NavigationEventType NavigationMessageType NavigationQueryType @@ -1022,7 +1033,30 @@ gchar* /api/namespace/interface[@cname='GstMixer'] - 1 + Navigation + true + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + + PropertyProbe Tuner diff --git a/gstreamer-sharp/Makefile.am b/gstreamer-sharp/Makefile.am index c8affea..96d8eb7 100644 --- a/gstreamer-sharp/Makefile.am +++ b/gstreamer-sharp/Makefile.am @@ -52,6 +52,9 @@ sources = \ TypeFindDelegates.cs \ PresetDefault.cs \ MixerMessage.cs \ + NavigationMessage.cs \ + NavigationEvent.cs \ + NavigationQuery.cs \ coreplugins/*.cs \ baseplugins/*.cs @@ -63,7 +66,8 @@ overrides = \ override/MixerAdapter.cs \ override/PropertyProbe.cs \ override/PropertyProbeAdapter.cs \ - override/ProbeNeededHandler.cs + override/ProbeNeededHandler.cs \ + override/NavigationAdapter.cs build_sources = $(addprefix $(srcdir)/, $(sources)) diff --git a/gstreamer-sharp/NavigationEvent.cs b/gstreamer-sharp/NavigationEvent.cs new file mode 100644 index 0000000..2405bfe --- /dev/null +++ b/gstreamer-sharp/NavigationEvent.cs @@ -0,0 +1,59 @@ +namespace Gst.Interfaces { + + using System; + using System.Runtime.InteropServices; + using System.Reflection; + using GLib; + using Gst; + using Gst.Interfaces; + + public static class NavigationEvent { + [DllImport("gstinterfaces-0.10.dll")] + static extern int gst_navigation_event_get_type(IntPtr evnt); + + public static Gst.Interfaces.NavigationEventType EventGetType(Gst.Event evnt) { + int raw_ret = gst_navigation_event_get_type(evnt == null ? IntPtr.Zero : evnt.Handle); + Gst.Interfaces.NavigationEventType ret = (Gst.Interfaces.NavigationEventType) raw_ret; + return ret; + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern bool gst_navigation_event_parse_key_event (IntPtr evnt, out IntPtr key); + + public static bool ParseKeyEvent (Gst.Event evnt, out string key) { + IntPtr raw_key; + bool ret = gst_navigation_event_parse_key_event (evnt.Handle, out raw_key); + + key = GLib.Marshaller.Utf8PtrToString (raw_key); + + return ret; + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern bool gst_navigation_event_parse_mouse_button_event (IntPtr evnt, out int button, out double x, out double y); + + public static bool ParseMouseButtonEvent (Gst.Event evnt, out int button, out double x, out double y) { + return gst_navigation_event_parse_mouse_button_event (evnt.Handle, out button, out x, out y); + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern bool gst_navigation_event_parse_mouse_move_event (IntPtr evnt, out double x, out double y); + + public static bool ParseMouseMoveEvent (Gst.Event evnt, out double x, out double y) { + return gst_navigation_event_parse_mouse_move_event (evnt.Handle, out x, out y); + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern bool gst_navigation_event_parse_command (IntPtr evnt, out int command); + + public static bool ParseCommand (Gst.Event evnt, out Gst.Interfaces.NavigationCommand command) { + int raw_command; + bool ret = gst_navigation_event_parse_command (evnt.Handle, out raw_command); + + command = (Gst.Interfaces.NavigationCommand) raw_command; + + return ret; + } + + } +} diff --git a/gstreamer-sharp/NavigationMessage.cs b/gstreamer-sharp/NavigationMessage.cs new file mode 100644 index 0000000..f1f2e55 --- /dev/null +++ b/gstreamer-sharp/NavigationMessage.cs @@ -0,0 +1,58 @@ +namespace Gst.Interfaces { + + using System; + using System.Runtime.InteropServices; + using System.Reflection; + using GLib; + using Gst; + using Gst.Interfaces; + + public static class NavigationMessage { + [DllImport("gstinterfaces-0.10.dll")] + static extern int gst_navigation_message_get_type(IntPtr message); + + public static Gst.Interfaces.NavigationMessageType MessageGetType(Gst.Message message) { + int raw_ret = gst_navigation_message_get_type(message == null ? IntPtr.Zero : message.Handle); + Gst.Interfaces.NavigationMessageType ret = (Gst.Interfaces.NavigationMessageType) raw_ret; + return ret; + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern IntPtr gst_navigation_message_new_mouse_over (IntPtr src, bool active); + + public static Gst.Message NewMouseOver (Gst.Object src, bool active) { + Message msg = (Message) GLib.Opaque.GetOpaque (gst_navigation_message_new_mouse_over (src.Handle, active), typeof (Message), true); + return msg; + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern bool gst_navigation_message_parse_mouse_over (IntPtr msg, out bool active); + + public static bool ParseMouseOver (Gst.Message msg, out bool active) { + return gst_navigation_message_parse_mouse_over (msg.Handle, out active); + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern IntPtr gst_navigation_message_new_angles_changed (IntPtr src, uint cur_angle, uint n_angles); + + public static Gst.Message NewAnglesChanged (Gst.Object src, uint cur_angle, uint n_angles) { + Message msg = (Message) GLib.Opaque.GetOpaque (gst_navigation_message_new_angles_changed (src.Handle, cur_angle, n_angles), typeof (Message), true); + return msg; + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern bool gst_navigation_message_parse_angles_changed (IntPtr msg, out uint cur_angle, out uint n_angles); + + public static bool ParseMouseOver (Gst.Message msg, out uint cur_angle, out uint n_angles) { + return gst_navigation_message_parse_angles_changed (msg.Handle, out cur_angle, out n_angles); + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern IntPtr gst_navigation_message_new_commands_changed (IntPtr src); + + public static Gst.Message NewCommandsChanged (Gst.Object src) { + Message msg = (Message) GLib.Opaque.GetOpaque (gst_navigation_message_new_commands_changed (src.Handle), typeof (Message), true); + return msg; + } + } +} diff --git a/gstreamer-sharp/NavigationQuery.cs b/gstreamer-sharp/NavigationQuery.cs new file mode 100644 index 0000000..13dcb29 --- /dev/null +++ b/gstreamer-sharp/NavigationQuery.cs @@ -0,0 +1,92 @@ +namespace Gst.Interfaces { + + using System; + using System.Runtime.InteropServices; + using System.Reflection; + using GLib; + using Gst; + using Gst.Interfaces; + + public static class NavigationQuery { + [DllImport("gstinterfaces-0.10.dll")] + static extern int gst_navigation_query_get_type(IntPtr query); + + public static Gst.Interfaces.NavigationQueryType QueryGetType(Gst.Query query) { + int raw_ret = gst_navigation_query_get_type(query == null ? IntPtr.Zero : query.Handle); + Gst.Interfaces.NavigationQueryType ret = (Gst.Interfaces.NavigationQueryType) raw_ret; + return ret; + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern IntPtr gst_navigation_query_new_commands (); + + public static Gst.Query NewCommands () { + Gst.Query query = (Gst.Query) GLib.Opaque.GetOpaque (gst_navigation_query_new_commands (), typeof (Gst.Query), true); + return query; + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern void gst_navigation_query_set_commandsv (IntPtr query, uint n_commands, int[] cmds); + + public static void SetCommands (Gst.Query query, Gst.Interfaces.NavigationCommand[] cmds) { + if (!query.IsWritable) + throw new ApplicationException (); + + int[] raw_cmds = new int[cmds.Length]; + for (int i = 0; i < cmds.Length; i++) + raw_cmds[i] = (int) cmds[i]; + + gst_navigation_query_set_commandsv (query.Handle, (uint) raw_cmds.Length, raw_cmds); + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern bool gst_navigation_query_parse_commands_length (IntPtr query, out uint n_commands); + [DllImport("gstinterfaces-0.10.dll")] + static extern bool gst_navigation_query_parse_commands_nth (IntPtr query, uint nth, out int cmd); + + public static bool ParseCommands (Gst.Query query, out Gst.Interfaces.NavigationCommand[] cmds) { + uint len; + + cmds = null; + if (!gst_navigation_query_parse_commands_length (query.Handle, out len)) + return false; + + cmds = new Gst.Interfaces.NavigationCommand[len]; + + for (uint i = 0; i < len; i++) { + int cmd; + + if (!gst_navigation_query_parse_commands_nth (query.Handle, i, out cmd)) + return false; + cmds[i] = (Gst.Interfaces.NavigationCommand) cmd; + } + + return true; + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern IntPtr gst_navigation_query_new_angles (); + + public static Gst.Query NewAngles () { + Gst.Query query = (Gst.Query) GLib.Opaque.GetOpaque (gst_navigation_query_new_angles (), typeof (Gst.Query), true); + return query; + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern void gst_navigation_query_set_angles (IntPtr query, uint cur_angle, uint n_angles); + + public static void SetAngles (Gst.Query query, uint cur_angle, uint n_angles) { + if (!query.IsWritable) + throw new ApplicationException (); + + gst_navigation_query_set_angles (query.Handle, cur_angle, n_angles); + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern bool gst_navigation_query_parse_angles (IntPtr query, out uint cur_angle, out uint n_angles); + + public static bool ParseAngles (Gst.Query query, out uint cur_angle, out uint n_angles) { + return gst_navigation_query_parse_angles (query.Handle, out cur_angle, out n_angles); + } + } +} diff --git a/gstreamer-sharp/override/NavigationAdapter.cs b/gstreamer-sharp/override/NavigationAdapter.cs new file mode 100644 index 0000000..28c9d57 --- /dev/null +++ b/gstreamer-sharp/override/NavigationAdapter.cs @@ -0,0 +1,156 @@ +// This file was generated by the Gtk# code generator. +// Changed to copy the structure in SendEvent (). + +namespace Gst.Interfaces { + + using System; + using System.Runtime.InteropServices; + +#region Autogenerated code + public class NavigationAdapter : GLib.GInterfaceAdapter, Gst.Interfaces.Navigation { + + [StructLayout (LayoutKind.Sequential)] + struct GstNavigationInterface { + public SendEventNativeDelegate SendEvent; + [MarshalAs (UnmanagedType.ByValArray, SizeConst=4)] + public IntPtr[] GstReserved; + } + + static GstNavigationInterface iface; + + static NavigationAdapter () + { + GLib.GType.Register (_gtype, typeof(NavigationAdapter)); + iface.SendEvent = new SendEventNativeDelegate (SendEvent_cb); + } + + [GLib.CDeclCallback] + delegate void SendEventNativeDelegate (IntPtr inst, IntPtr structure); + + static void SendEvent_cb (IntPtr inst, IntPtr structure) + { + try { + NavigationImplementor __obj = GLib.Object.GetObject (inst, false) as NavigationImplementor; + __obj.SendEvent (structure == IntPtr.Zero ? null : (Gst.Structure) GLib.Opaque.GetOpaque (structure, typeof (Gst.Structure), true)); + } catch (Exception e) { + GLib.ExceptionManager.RaiseUnhandledException (e, false); + } + } + + static int class_offset = 2 * IntPtr.Size; + + static void Initialize (IntPtr ptr, IntPtr data) + { + IntPtr ifaceptr = new IntPtr (ptr.ToInt64 () + class_offset); + GstNavigationInterface native_iface = (GstNavigationInterface) Marshal.PtrToStructure (ifaceptr, typeof (GstNavigationInterface)); + native_iface.SendEvent = iface.SendEvent; + Marshal.StructureToPtr (native_iface, ifaceptr, false); + GCHandle gch = (GCHandle) data; + gch.Free (); + } + + public NavigationAdapter () + { + InitHandler = new GLib.GInterfaceInitHandler (Initialize); + } + + NavigationImplementor implementor; + + public NavigationAdapter (NavigationImplementor implementor) + { + if (implementor == null) + throw new ArgumentNullException ("implementor"); + this.implementor = implementor; + } + + public NavigationAdapter (IntPtr handle) + { + if (!_gtype.IsInstance (handle)) + throw new ArgumentException ("The gobject doesn't implement the GInterface of this adapter", "handle"); + this.handle = handle; + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern IntPtr gst_navigation_get_type(); + + private static GLib.GType _gtype = new GLib.GType (gst_navigation_get_type ()); + + public override GLib.GType GType { + get { + return _gtype; + } + } + + IntPtr handle; + public override IntPtr Handle { + get { + if (handle != IntPtr.Zero) + return handle; + return implementor == null ? IntPtr.Zero : implementor.Handle; + } + } + + public static Navigation GetObject (IntPtr handle, bool owned) + { + GLib.Object obj = GLib.Object.GetObject (handle, owned); + return GetObject (obj); + } + + public static Navigation GetObject (GLib.Object obj) + { + if (obj == null) + return null; + else if (obj is NavigationImplementor) + return new NavigationAdapter (obj as NavigationImplementor); + else if (obj as Navigation == null) + return new NavigationAdapter (obj.Handle); + else + return obj as Navigation; + } + + public NavigationImplementor Implementor { + get { + return implementor; + } + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern void gst_navigation_send_event(IntPtr raw, IntPtr structure); + + [DllImport("gstreamer-0.10.dll")] + static extern IntPtr gst_structure_copy (IntPtr raw); + + public void SendEvent(Gst.Structure structure) { + gst_navigation_send_event(Handle, structure == null ? IntPtr.Zero : gst_structure_copy (structure.Handle)); + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern void gst_navigation_send_mouse_event(IntPtr raw, IntPtr evnt, int button, double x, double y); + + public void SendMouseEvent(string evnt, int button, double x, double y) { + IntPtr native_evnt = GLib.Marshaller.StringToPtrGStrdup (evnt); + gst_navigation_send_mouse_event(Handle, native_evnt, button, x, y); + GLib.Marshaller.Free (native_evnt); + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern void gst_navigation_send_key_event(IntPtr raw, IntPtr evnt, IntPtr key); + + public void SendKeyEvent(string evnt, string key) { + IntPtr native_evnt = GLib.Marshaller.StringToPtrGStrdup (evnt); + IntPtr native_key = GLib.Marshaller.StringToPtrGStrdup (key); + gst_navigation_send_key_event(Handle, native_evnt, native_key); + GLib.Marshaller.Free (native_evnt); + GLib.Marshaller.Free (native_key); + } + + [DllImport("gstinterfaces-0.10.dll")] + static extern void gst_navigation_send_command(IntPtr raw, int command); + + public void SendCommand(Gst.Interfaces.NavigationCommand command) { + gst_navigation_send_command(Handle, (int) command); + } + +#endregion + } +}