Release 1.22.7
[platform/upstream/gstreamer.git] / subprojects / gstreamer-sharp / sources / generated / Gst / GstSharp.BufferForeachMetaFuncNative.cs
1 // This file was generated by the Gtk# code generator.
2 // Any changes made will be lost if regenerated.
3
4 namespace GstSharp {
5
6         using System;
7         using System.Runtime.InteropServices;
8
9 #region Autogenerated code
10         [UnmanagedFunctionPointer (CallingConvention.Cdecl)]
11         internal delegate bool BufferForeachMetaFuncNative(IntPtr buffer, IntPtr meta, IntPtr user_data);
12
13         internal class BufferForeachMetaFuncInvoker {
14
15                 BufferForeachMetaFuncNative native_cb;
16                 IntPtr __data;
17                 GLib.DestroyNotify __notify;
18
19                 ~BufferForeachMetaFuncInvoker ()
20                 {
21                         if (__notify == null)
22                                 return;
23                         __notify (__data);
24                 }
25
26                 internal BufferForeachMetaFuncInvoker (BufferForeachMetaFuncNative native_cb) : this (native_cb, IntPtr.Zero, null) {}
27
28                 internal BufferForeachMetaFuncInvoker (BufferForeachMetaFuncNative native_cb, IntPtr data) : this (native_cb, data, null) {}
29
30                 internal BufferForeachMetaFuncInvoker (BufferForeachMetaFuncNative native_cb, IntPtr data, GLib.DestroyNotify notify)
31                 {
32                         this.native_cb = native_cb;
33                         __data = data;
34                         __notify = notify;
35                 }
36
37                 internal Gst.BufferForeachMetaFunc Handler {
38                         get {
39                                 return new Gst.BufferForeachMetaFunc(InvokeNative);
40                         }
41                 }
42
43                 bool InvokeNative (Gst.Buffer buffer, out Gst.Meta meta)
44                 {
45                         IntPtr native_meta = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (Gst.Meta)));
46                         bool __result = native_cb (buffer == null ? IntPtr.Zero : buffer.Handle, native_meta, __data);
47                         meta = Gst.Meta.New (native_meta);
48                         Marshal.FreeHGlobal (native_meta);
49                         return __result;
50                 }
51         }
52
53         internal class BufferForeachMetaFuncWrapper {
54
55                 public bool NativeCallback (IntPtr buffer, IntPtr meta, IntPtr user_data)
56                 {
57                         try {
58                                 Gst.Meta mymeta;
59
60                                 bool __ret = managed (buffer == IntPtr.Zero ? null : (Gst.Buffer) GLib.Opaque.GetOpaque (buffer, typeof (Gst.Buffer), false), out mymeta);
61                                 if (meta != IntPtr.Zero) System.Runtime.InteropServices.Marshal.StructureToPtr (mymeta, meta, false);
62
63                                 if (release_on_call)
64                                         gch.Free ();
65                                 return __ret;
66                         } catch (Exception e) {
67                                 GLib.ExceptionManager.RaiseUnhandledException (e, true);
68                                 // NOTREACHED: Above call does not return.
69                                 throw e;
70                         }
71                 }
72
73                 bool release_on_call = false;
74                 GCHandle gch;
75
76                 public void PersistUntilCalled ()
77                 {
78                         release_on_call = true;
79                         gch = GCHandle.Alloc (this);
80                 }
81
82                 internal BufferForeachMetaFuncNative NativeDelegate;
83                 Gst.BufferForeachMetaFunc managed;
84
85                 public BufferForeachMetaFuncWrapper (Gst.BufferForeachMetaFunc managed)
86                 {
87                         this.managed = managed;
88                         if (managed != null)
89                                 NativeDelegate = new BufferForeachMetaFuncNative (NativeCallback);
90                 }
91
92                 public static Gst.BufferForeachMetaFunc GetManagedDelegate (BufferForeachMetaFuncNative native)
93                 {
94                         if (native == null)
95                                 return null;
96                         BufferForeachMetaFuncWrapper wrapper = (BufferForeachMetaFuncWrapper) native.Target;
97                         if (wrapper == null)
98                                 return null;
99                         return wrapper.managed;
100                 }
101         }
102 #endregion
103 }