1 // This file was generated by the Gtk# code generator.
2 // Any changes made will be lost if regenerated.
7 using System.Runtime.InteropServices;
9 #region Autogenerated code
10 public partial class URIHandlerAdapter : GLib.GInterfaceAdapter, Gst.IURIHandler {
12 [StructLayout (LayoutKind.Sequential)]
13 struct GstURIHandlerInterface {
15 public GetUriNativeDelegate GetUri;
16 public SetUriNativeDelegate SetUri;
19 static GstURIHandlerInterface iface;
21 static URIHandlerAdapter ()
23 GLib.GType.Register (_gtype, typeof (URIHandlerAdapter));
24 iface.GetUri = new GetUriNativeDelegate (GetUri_cb);
25 iface.SetUri = new SetUriNativeDelegate (SetUri_cb);
28 [UnmanagedFunctionPointer (CallingConvention.Cdecl)]
29 delegate IntPtr GetUriNativeDelegate (IntPtr inst);
31 static IntPtr GetUri_cb (IntPtr inst)
34 IURIHandlerImplementor __obj = GLib.Object.GetObject (inst, false) as IURIHandlerImplementor;
37 return GLib.Marshaller.StringToPtrGStrdup(__result);
38 } catch (Exception e) {
39 GLib.ExceptionManager.RaiseUnhandledException (e, true);
40 // NOTREACHED: above call does not return.
45 [UnmanagedFunctionPointer (CallingConvention.Cdecl)]
46 delegate bool SetUriNativeDelegate (IntPtr inst, IntPtr uri, out IntPtr error);
48 static bool SetUri_cb (IntPtr inst, IntPtr uri, out IntPtr error)
53 IURIHandlerImplementor __obj = GLib.Object.GetObject (inst, false) as IURIHandlerImplementor;
55 __result = __obj.SetUri (GLib.Marshaller.Utf8PtrToString (uri));
57 } catch (Exception e) {
58 GLib.ExceptionManager.RaiseUnhandledException (e, true);
59 // NOTREACHED: above call does not return.
64 static int class_offset = 2 * IntPtr.Size;
66 static void Initialize (IntPtr ptr, IntPtr data)
68 IntPtr ifaceptr = new IntPtr (ptr.ToInt64 () + class_offset);
69 GstURIHandlerInterface native_iface = (GstURIHandlerInterface) Marshal.PtrToStructure (ifaceptr, typeof (GstURIHandlerInterface));
70 native_iface.GetUri = iface.GetUri;
71 native_iface.SetUri = iface.SetUri;
72 Marshal.StructureToPtr (native_iface, ifaceptr, false);
75 GLib.Object implementor;
77 public URIHandlerAdapter ()
79 InitHandler = new GLib.GInterfaceInitHandler (Initialize);
82 public URIHandlerAdapter (IURIHandlerImplementor implementor)
84 if (implementor == null)
85 throw new ArgumentNullException ("implementor");
86 else if (!(implementor is GLib.Object))
87 throw new ArgumentException ("implementor must be a subclass of GLib.Object");
88 this.implementor = implementor as GLib.Object;
91 public URIHandlerAdapter (IntPtr handle)
93 if (!_gtype.IsInstance (handle))
94 throw new ArgumentException ("The gobject doesn't implement the GInterface of this adapter", "handle");
95 implementor = GLib.Object.GetObject (handle);
98 [DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
99 static extern IntPtr gst_uri_handler_get_type();
101 private static GLib.GType _gtype = new GLib.GType (gst_uri_handler_get_type ());
103 public static GLib.GType GType {
109 public override GLib.GType GInterfaceGType {
115 public override IntPtr Handle {
117 return implementor.Handle;
121 public IntPtr OwnedHandle {
123 return implementor.OwnedHandle;
127 public static IURIHandler GetObject (IntPtr handle, bool owned)
129 GLib.Object obj = GLib.Object.GetObject (handle, owned);
130 return GetObject (obj);
133 public static IURIHandler GetObject (GLib.Object obj)
137 else if (obj is IURIHandlerImplementor)
138 return new URIHandlerAdapter (obj as IURIHandlerImplementor);
139 else if (obj as IURIHandler == null)
140 return new URIHandlerAdapter (obj.Handle);
142 return obj as IURIHandler;
145 public IURIHandlerImplementor Implementor {
147 return implementor as IURIHandlerImplementor;
151 [DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
152 static extern IntPtr gst_uri_handler_get_uri(IntPtr raw);
156 IntPtr raw_ret = gst_uri_handler_get_uri(Handle);
157 string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
162 [DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
163 static extern int gst_uri_handler_get_uri_type(IntPtr raw);
165 public Gst.URIType UriType {
167 int raw_ret = gst_uri_handler_get_uri_type(Handle);
168 Gst.URIType ret = (Gst.URIType) raw_ret;
173 [DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
174 static extern bool gst_uri_handler_set_uri(IntPtr raw, IntPtr uri, out IntPtr error);
176 public bool SetUri(string uri) {
177 IntPtr native_uri = GLib.Marshaller.StringToPtrGStrdup (uri);
178 IntPtr error = IntPtr.Zero;
179 bool raw_ret = gst_uri_handler_set_uri(Handle, native_uri, out error);
181 GLib.Marshaller.Free (native_uri);
182 if (error != IntPtr.Zero) throw new GLib.GException (error);