1 // This file was generated by the Gtk# code generator.
2 // Any changes made will be lost if regenerated.
7 using System.Collections;
8 using System.Collections.Generic;
9 using System.Runtime.InteropServices;
11 #region Autogenerated code
12 [StructLayout(LayoutKind.Sequential)]
13 public partial struct AudioBuffer : IEquatable<AudioBuffer> {
16 public Gst.Audio.AudioInfo Info {
18 return _info == IntPtr.Zero ? null : (Gst.Audio.AudioInfo) GLib.Opaque.GetOpaque (_info, typeof (Gst.Audio.AudioInfo), false);
21 _info = value == null ? IntPtr.Zero : value.Handle;
24 private UIntPtr n_samples;
25 public ulong NSamples {
27 return (ulong) n_samples;
30 n_samples = new UIntPtr (value);
34 private IntPtr _planes;
35 private IntPtr _buffer;
36 public Gst.Buffer Buffer {
38 return _buffer == IntPtr.Zero ? null : (Gst.Buffer) GLib.Opaque.GetOpaque (_buffer, typeof (Gst.Buffer), false);
41 _buffer = value == null ? IntPtr.Zero : value.Handle;
44 private IntPtr _map_infos;
46 [MarshalAs (UnmanagedType.ByValArray, SizeConst=4)]
47 private IntPtr[] _gstGstReserved;
49 public static Gst.Audio.AudioBuffer Zero = new Gst.Audio.AudioBuffer ();
51 public static Gst.Audio.AudioBuffer New(IntPtr raw) {
52 if (raw == IntPtr.Zero)
53 return Gst.Audio.AudioBuffer.Zero;
54 return (Gst.Audio.AudioBuffer) Marshal.PtrToStructure (raw, typeof (Gst.Audio.AudioBuffer));
57 [DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
58 static extern bool gst_audio_buffer_map(IntPtr raw, IntPtr info, IntPtr gstbuffer, int flags);
60 public bool Map(Gst.Audio.AudioInfo info, Gst.Buffer gstbuffer, Gst.MapFlags flags) {
61 IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));
62 System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
63 bool raw_ret = gst_audio_buffer_map(this_as_native, info == null ? IntPtr.Zero : info.Handle, gstbuffer == null ? IntPtr.Zero : gstbuffer.Handle, (int) flags);
65 ReadNative (this_as_native, ref this);
66 System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
70 [DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
71 static extern void gst_audio_buffer_unmap(IntPtr raw);
74 IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal (System.Runtime.InteropServices.Marshal.SizeOf (this));
75 System.Runtime.InteropServices.Marshal.StructureToPtr (this, this_as_native, false);
76 gst_audio_buffer_unmap(this_as_native);
77 ReadNative (this_as_native, ref this);
78 System.Runtime.InteropServices.Marshal.FreeHGlobal (this_as_native);
81 [DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
82 static extern IntPtr gst_audio_buffer_clip(IntPtr buffer, IntPtr segment, int rate, int bpf);
84 public static Gst.Buffer Clip(Gst.Buffer buffer, Gst.Segment segment, int rate, int bpf) {
86 IntPtr native_segment = GLib.Marshaller.StructureToPtrAlloc (segment);
87 IntPtr raw_ret = gst_audio_buffer_clip(buffer == null ? IntPtr.Zero : buffer.Handle, native_segment, rate, bpf);
88 Gst.Buffer ret = raw_ret == IntPtr.Zero ? null : (Gst.Buffer) GLib.Opaque.GetOpaque (raw_ret, typeof (Gst.Buffer), true);
89 Marshal.FreeHGlobal (native_segment);
93 [DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
94 static extern bool gst_audio_buffer_reorder_channels(IntPtr buffer, int format, int channels, int[] from, int[] to);
96 public static bool ReorderChannels(Gst.Buffer buffer, Gst.Audio.AudioFormat format, int channels, Gst.Audio.AudioChannelPosition[] from, Gst.Audio.AudioChannelPosition[] to) {
97 int cnt_from = from == null ? 0 : from.Length;
98 int[] native_from = new int [cnt_from];
99 for (int i = 0; i < cnt_from; i++)
100 native_from [i] = (int) from[i];
101 int cnt_to = to == null ? 0 : to.Length;
102 int[] native_to = new int [cnt_to];
103 for (int i = 0; i < cnt_to; i++)
104 native_to [i] = (int) to[i];
105 bool raw_ret = gst_audio_buffer_reorder_channels(buffer == null ? IntPtr.Zero : buffer.Handle, (int) format, channels, native_from, native_to);
110 [DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
111 static extern IntPtr gst_audio_buffer_truncate(IntPtr buffer, int bpf, UIntPtr trim, UIntPtr samples);
113 public static Gst.Buffer Truncate(Gst.Buffer buffer, int bpf, ulong trim, ulong samples) {
114 buffer.Owned = false;
115 IntPtr raw_ret = gst_audio_buffer_truncate(buffer == null ? IntPtr.Zero : buffer.Handle, bpf, new UIntPtr (trim), new UIntPtr (samples));
116 Gst.Buffer ret = raw_ret == IntPtr.Zero ? null : (Gst.Buffer) GLib.Opaque.GetOpaque (raw_ret, typeof (Gst.Buffer), true);
120 static void ReadNative (IntPtr native, ref Gst.Audio.AudioBuffer target)
122 target = New (native);
125 public bool Equals (AudioBuffer other)
127 return true && Info.Equals (other.Info) && NSamples.Equals (other.NSamples) && NPlanes.Equals (other.NPlanes) && _planes.Equals (other._planes) && Buffer.Equals (other.Buffer) && _map_infos.Equals (other._map_infos);
130 public override bool Equals (object other)
132 return other is AudioBuffer && Equals ((AudioBuffer) other);
135 public override int GetHashCode ()
137 return this.GetType ().FullName.GetHashCode () ^ Info.GetHashCode () ^ NSamples.GetHashCode () ^ NPlanes.GetHashCode () ^ _planes.GetHashCode () ^ Buffer.GetHashCode () ^ _map_infos.GetHashCode ();
140 private static GLib.GType GType {
141 get { return GLib.GType.Pointer; }