Back to development
[platform/upstream/gstreamer.git] / subprojects / gstreamer-sharp / sources / generated / Gst / URIHandlerAdapter.cs
1 // This file was generated by the Gtk# code generator.
2 // Any changes made will be lost if regenerated.
3
4 namespace Gst {
5
6         using System;
7         using System.Runtime.InteropServices;
8
9 #region Autogenerated code
10         public partial class URIHandlerAdapter : GLib.GInterfaceAdapter, Gst.IURIHandler {
11
12                 [StructLayout (LayoutKind.Sequential)]
13                 struct GstURIHandlerInterface {
14                         IntPtr GetProtocols;
15                         public GetUriNativeDelegate GetUri;
16                         public SetUriNativeDelegate SetUri;
17                 }
18
19                 static GstURIHandlerInterface iface;
20
21                 static URIHandlerAdapter ()
22                 {
23                         GLib.GType.Register (_gtype, typeof (URIHandlerAdapter));
24                         iface.GetUri = new GetUriNativeDelegate (GetUri_cb);
25                         iface.SetUri = new SetUriNativeDelegate (SetUri_cb);
26                 }
27
28                 [UnmanagedFunctionPointer (CallingConvention.Cdecl)]
29                 delegate IntPtr GetUriNativeDelegate (IntPtr inst);
30
31                 static IntPtr GetUri_cb (IntPtr inst)
32                 {
33                         try {
34                                 IURIHandlerImplementor __obj = GLib.Object.GetObject (inst, false) as IURIHandlerImplementor;
35                                 string __result;
36                                 __result = __obj.Uri;
37                                 return GLib.Marshaller.StringToPtrGStrdup(__result);
38                         } catch (Exception e) {
39                                 GLib.ExceptionManager.RaiseUnhandledException (e, true);
40                                 // NOTREACHED: above call does not return.
41                                 throw e;
42                         }
43                 }
44
45                 [UnmanagedFunctionPointer (CallingConvention.Cdecl)]
46                 delegate bool SetUriNativeDelegate (IntPtr inst, IntPtr uri, out IntPtr error);
47
48                 static bool SetUri_cb (IntPtr inst, IntPtr uri, out IntPtr error)
49                 {
50                         error = IntPtr.Zero;
51
52                         try {
53                                 IURIHandlerImplementor __obj = GLib.Object.GetObject (inst, false) as IURIHandlerImplementor;
54                                 bool __result;
55                                 __result = __obj.SetUri (GLib.Marshaller.Utf8PtrToString (uri));
56                                 return __result;
57                         } catch (Exception e) {
58                                 GLib.ExceptionManager.RaiseUnhandledException (e, true);
59                                 // NOTREACHED: above call does not return.
60                                 throw e;
61                         }
62                 }
63
64                 static int class_offset = 2 * IntPtr.Size;
65
66                 static void Initialize (IntPtr ptr, IntPtr data)
67                 {
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);
73                 }
74
75                 GLib.Object implementor;
76
77                 public URIHandlerAdapter ()
78                 {
79                         InitHandler = new GLib.GInterfaceInitHandler (Initialize);
80                 }
81
82                 public URIHandlerAdapter (IURIHandlerImplementor implementor)
83                 {
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;
89                 }
90
91                 public URIHandlerAdapter (IntPtr handle)
92                 {
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);
96                 }
97
98                 [DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
99                 static extern IntPtr gst_uri_handler_get_type();
100
101                 private static GLib.GType _gtype = new GLib.GType (gst_uri_handler_get_type ());
102
103                 public static GLib.GType GType {
104                         get {
105                                 return _gtype;
106                         }
107                 }
108
109                 public override GLib.GType GInterfaceGType {
110                         get {
111                                 return _gtype;
112                         }
113                 }
114
115                 public override IntPtr Handle {
116                         get {
117                                 return implementor.Handle;
118                         }
119                 }
120
121                 public IntPtr OwnedHandle {
122                         get {
123                                 return implementor.OwnedHandle;
124                         }
125                 }
126
127                 public static IURIHandler GetObject (IntPtr handle, bool owned)
128                 {
129                         GLib.Object obj = GLib.Object.GetObject (handle, owned);
130                         return GetObject (obj);
131                 }
132
133                 public static IURIHandler GetObject (GLib.Object obj)
134                 {
135                         if (obj == null)
136                                 return null;
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);
141                         else
142                                 return obj as IURIHandler;
143                 }
144
145                 public IURIHandlerImplementor Implementor {
146                         get {
147                                 return implementor as IURIHandlerImplementor;
148                         }
149                 }
150
151                 [DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
152                 static extern IntPtr gst_uri_handler_get_uri(IntPtr raw);
153
154                 public string Uri { 
155                         get {
156                                 IntPtr raw_ret = gst_uri_handler_get_uri(Handle);
157                                 string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
158                                 return ret;
159                         }
160                 }
161
162                 [DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
163                 static extern int gst_uri_handler_get_uri_type(IntPtr raw);
164
165                 public Gst.URIType UriType { 
166                         get {
167                                 int raw_ret = gst_uri_handler_get_uri_type(Handle);
168                                 Gst.URIType ret = (Gst.URIType) raw_ret;
169                                 return ret;
170                         }
171                 }
172
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);
175
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);
180                         bool ret = raw_ret;
181                         GLib.Marshaller.Free (native_uri);
182                         if (error != IntPtr.Zero) throw new GLib.GException (error);
183                         return ret;
184                 }
185
186 #endregion
187         }
188 }