gstreamer-sharp: apply new code style to alll sources

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/983>
This commit is contained in:
Andoni Morales Alastruey 2021-09-30 13:02:26 +02:00 committed by GStreamer Marge Bot
parent f89dff303a
commit 6ddb443743
27 changed files with 676 additions and 780 deletions

View file

@ -19,8 +19,7 @@ namespace Gst.Base {
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
public partial class Adapter public partial class Adapter {
{
[DllImport("gstbase-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("gstbase-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void gst_adapter_copy(IntPtr raw, out IntPtr dest, int offset, int size); static extern void gst_adapter_copy(IntPtr raw, out IntPtr dest, int offset, int size);

View file

@ -25,8 +25,7 @@ namespace Gst.App {
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
partial class AppSink partial class AppSink {
{
public AppSink(String name) : base(IntPtr.Zero) { public AppSink(String name) : base(IntPtr.Zero) {
Raw = ElementFactory.MakeRaw("appsink", name); Raw = ElementFactory.MakeRaw("appsink", name);
} }

View file

@ -25,8 +25,7 @@ namespace Gst.App {
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
partial class AppSrc partial class AppSrc {
{
public AppSrc(String name) : base(IntPtr.Zero) { public AppSrc(String name) : base(IntPtr.Zero) {
Raw = ElementFactory.MakeRaw("appsrc", name); Raw = ElementFactory.MakeRaw("appsrc", name);
} }

View file

@ -19,8 +19,7 @@ namespace Gst {
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
partial class Application partial class Application {
{
// Because of: https://bugzilla.gnome.org/show_bug.cgi?id=743062#c30 // Because of: https://bugzilla.gnome.org/show_bug.cgi?id=743062#c30
private static uint MIN_GSTREAMER_MINOR = 14; private static uint MIN_GSTREAMER_MINOR = 14;

View file

@ -25,8 +25,7 @@ namespace Gst.Audio {
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
partial class AudioFilter partial class AudioFilter {
{
[DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("gstaudio-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void gst_audio_filter_class_add_pad_templates(IntPtr klass, IntPtr allowed_caps); static extern void gst_audio_filter_class_add_pad_templates(IntPtr klass, IntPtr allowed_caps);

View file

@ -50,8 +50,7 @@ namespace Gst {
[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gst_buffer_new_wrapped(IntPtr data, UIntPtr n_length); static extern IntPtr gst_buffer_new_wrapped(IntPtr data, UIntPtr n_length);
public Buffer (byte[] data) public Buffer(byte[] data) {
{
IntPtr ptr = GLib.Marshaller.Malloc((ulong)data.Length); IntPtr ptr = GLib.Marshaller.Malloc((ulong)data.Length);
Marshal.Copy(data, 0, ptr, data.Length); Marshal.Copy(data, 0, ptr, data.Length);
Raw = gst_buffer_new_wrapped(ptr, new UIntPtr((ulong)data.Length)); Raw = gst_buffer_new_wrapped(ptr, new UIntPtr((ulong)data.Length));

View file

@ -17,10 +17,8 @@
using System; using System;
namespace Gst namespace Gst {
{ partial class Bus {
partial class Bus
{
public uint AddWatch(Gst.BusFunc func) { public uint AddWatch(Gst.BusFunc func) {
// https://developer.gnome.org/glib/unstable/glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS // https://developer.gnome.org/glib/unstable/glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS
int G_PRIORITY_DEFAULT = 0; int G_PRIORITY_DEFAULT = 0;
@ -28,4 +26,3 @@ namespace Gst
} }
} }
} }

View file

@ -26,8 +26,7 @@ namespace Gst {
using System.Collections; using System.Collections;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
partial class Caps : IEnumerable partial class Caps : IEnumerable {
{
public Structure this[uint index] { public Structure this[uint index] {
get { get {
if (index >= Size) if (index >= Size)

View file

@ -25,8 +25,7 @@ namespace Gst {
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
partial class DeviceProvider partial class DeviceProvider {
{
[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void gst_device_provider_class_add_metadata(IntPtr klass, IntPtr key, IntPtr value); static extern void gst_device_provider_class_add_metadata(IntPtr klass, IntPtr key, IntPtr value);

View file

@ -25,12 +25,11 @@
using GLib; using GLib;
using System; using System;
using System.Collections;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Collections;
namespace Gst namespace Gst {
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
delegate void GClosureMarshal(IntPtr closure, ref GLib.Value retval, uint argc, IntPtr argsPtr, delegate void GClosureMarshal(IntPtr closure, ref GLib.Value retval, uint argc, IntPtr argsPtr,
@ -38,24 +37,20 @@ namespace Gst
public delegate void SignalHandler(object o, SignalArgs args); public delegate void SignalHandler(object o, SignalArgs args);
public static class DynamicSignal public static class DynamicSignal {
{
private static readonly int gvalue_struct_size = Marshal.SizeOf(typeof(GLib.Value)); private static readonly int gvalue_struct_size = Marshal.SizeOf(typeof(GLib.Value));
class ObjectSignalKey class ObjectSignalKey {
{
object o; object o;
string signal_name; string signal_name;
public ObjectSignalKey (object o, string name) public ObjectSignalKey(object o, string name) {
{
this.o = o; this.o = o;
signal_name = name; signal_name = name;
} }
public override bool Equals (object o) public override bool Equals(object o) {
{
if (o is ObjectSignalKey) { if (o is ObjectSignalKey) {
ObjectSignalKey k = (ObjectSignalKey)o; ObjectSignalKey k = (ObjectSignalKey)o;
return k.o.Equals(this.o) && signal_name.Equals(k.signal_name); return k.o.Equals(this.o) && signal_name.Equals(k.signal_name);
@ -63,14 +58,12 @@ namespace Gst
return base.Equals(o); return base.Equals(o);
} }
public override int GetHashCode () public override int GetHashCode() {
{
return o.GetHashCode() ^ signal_name.GetHashCode(); return o.GetHashCode() ^ signal_name.GetHashCode();
} }
} }
class SignalInfo : IDisposable class SignalInfo : IDisposable {
{
uint handlerId; uint handlerId;
IntPtr closure; IntPtr closure;
Delegate registeredHandler; Delegate registeredHandler;
@ -113,8 +106,7 @@ namespace Gst
} }
} }
public SignalInfo (uint handlerId, IntPtr closure, Delegate registeredHandler, GCHandle gch) public SignalInfo(uint handlerId, IntPtr closure, Delegate registeredHandler, GCHandle gch) {
{
this.handlerId = handlerId; this.handlerId = handlerId;
this.closure = closure; this.closure = closure;
this.registeredHandler = registeredHandler; this.registeredHandler = registeredHandler;
@ -128,8 +120,7 @@ namespace Gst
this.argsType = parms[1].ParameterType; this.argsType = parms[1].ParameterType;
} }
public void UpdateArgsType (Delegate d) public void UpdateArgsType(Delegate d) {
{
if (!IsCompatibleDelegate(d)) if (!IsCompatibleDelegate(d))
throw new Exception("Incompatible delegate"); throw new Exception("Incompatible delegate");
@ -150,8 +141,7 @@ namespace Gst
throw new Exception("Incompatible delegate"); throw new Exception("Incompatible delegate");
} }
public bool IsCompatibleDelegate (Delegate d) public bool IsCompatibleDelegate(Delegate d) {
{
if (!IsValidDelegate(d)) if (!IsValidDelegate(d))
return false; return false;
@ -166,15 +156,13 @@ namespace Gst
return true; return true;
} }
public void Dispose () public void Dispose() {
{
registeredHandler = null; registeredHandler = null;
gch.Free(); gch.Free();
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
public static bool IsValidDelegate (Delegate d) public static bool IsValidDelegate(Delegate d) {
{
MethodInfo mi = d.Method; MethodInfo mi = d.Method;
if (mi.ReturnType != typeof(void)) if (mi.ReturnType != typeof(void))
@ -196,25 +184,21 @@ namespace Gst
static GClosureMarshal marshalHandler = new GClosureMarshal(OnMarshal); static GClosureMarshal marshalHandler = new GClosureMarshal(OnMarshal);
public static void Connect (GLib.Object o, string name, SignalHandler handler) public static void Connect(GLib.Object o, string name, SignalHandler handler) {
{
Connect(o, name, false, (Delegate)handler); Connect(o, name, false, (Delegate)handler);
} }
public static void Connect(GLib.Object o, string name, public static void Connect(GLib.Object o, string name,
bool after, SignalHandler handler) bool after, SignalHandler handler) {
{
Connect(o, name, after, (Delegate)handler); Connect(o, name, after, (Delegate)handler);
} }
public static void Connect (GLib.Object o, string name, Delegate handler) public static void Connect(GLib.Object o, string name, Delegate handler) {
{
Connect(o, name, false, handler); Connect(o, name, false, handler);
} }
public static void Connect(GLib.Object o, string name, public static void Connect(GLib.Object o, string name,
bool after, Delegate handler) bool after, Delegate handler) {
{
Delegate newHandler; Delegate newHandler;
ObjectSignalKey k = new ObjectSignalKey(o, name); ObjectSignalKey k = new ObjectSignalKey(o, name);
@ -230,7 +214,8 @@ namespace Gst
newHandler = Delegate.Combine(si.RegisteredHandler, handler); newHandler = Delegate.Combine(si.RegisteredHandler, handler);
si.UpdateArgsType(handler); si.UpdateArgsType(handler);
si.RegisteredHandler = newHandler; si.RegisteredHandler = newHandler;
} else { }
else {
if (!SignalInfo.IsValidDelegate(handler)) if (!SignalInfo.IsValidDelegate(handler))
throw new Exception("Invalid delegate"); throw new Exception("Invalid delegate");
@ -243,8 +228,7 @@ namespace Gst
} }
} }
public static void Disconnect (GLib.Object o, string name, Delegate handler) public static void Disconnect(GLib.Object o, string name, Delegate handler) {
{
ObjectSignalKey k = new ObjectSignalKey(o, name); ObjectSignalKey k = new ObjectSignalKey(o, name);
if (SignalHandlers[k] != null) { if (SignalHandlers[k] != null) {
SignalInfo si = (SignalInfo)SignalHandlers[k]; SignalInfo si = (SignalInfo)SignalHandlers[k];
@ -253,15 +237,15 @@ namespace Gst
g_signal_handler_disconnect(o.Handle, si.HandlerId); g_signal_handler_disconnect(o.Handle, si.HandlerId);
SignalHandlers.Remove(k); SignalHandlers.Remove(k);
si.Dispose(); si.Dispose();
} else { }
else {
si.RegisteredHandler = newHandler; si.RegisteredHandler = newHandler;
} }
} }
} }
static void OnMarshal(IntPtr closure, ref GLib.Value retval, uint argc, IntPtr argsPtr, static void OnMarshal(IntPtr closure, ref GLib.Value retval, uint argc, IntPtr argsPtr,
IntPtr ihint, IntPtr data) IntPtr ihint, IntPtr data) {
{
object[] args = new object[argc - 1]; object[] args = new object[argc - 1];
object o = ((GLib.Value)Marshal.PtrToStructure(argsPtr, typeof(GLib.Value))).Val; object o = ((GLib.Value)Marshal.PtrToStructure(argsPtr, typeof(GLib.Value))).Val;
@ -299,19 +283,16 @@ namespace Gst
[DllImport("gobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("gobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void g_closure_set_meta_marshal(IntPtr closure, IntPtr data, GClosureMarshal marshal); static extern void g_closure_set_meta_marshal(IntPtr closure, IntPtr data, GClosureMarshal marshal);
class GTypeSignalKey class GTypeSignalKey {
{
GType type; GType type;
string signal_name; string signal_name;
public GTypeSignalKey (GType type, string name) public GTypeSignalKey(GType type, string name) {
{
this.type = type; this.type = type;
signal_name = name; signal_name = name;
} }
public override bool Equals (object o) public override bool Equals(object o) {
{
if (o is GTypeSignalKey) { if (o is GTypeSignalKey) {
GTypeSignalKey k = (GTypeSignalKey)o; GTypeSignalKey k = (GTypeSignalKey)o;
return k.type.Equals(this.type) && signal_name.Equals(k.signal_name); return k.type.Equals(this.type) && signal_name.Equals(k.signal_name);
@ -319,14 +300,12 @@ namespace Gst
return base.Equals(o); return base.Equals(o);
} }
public override int GetHashCode () public override int GetHashCode() {
{
return type.GetHashCode() ^ signal_name.GetHashCode(); return type.GetHashCode() ^ signal_name.GetHashCode();
} }
} }
struct SignalQuery struct SignalQuery {
{
public uint signal_id; public uint signal_id;
public string signal_name; public string signal_name;
public GType itype; public GType itype;
@ -338,8 +317,7 @@ namespace Gst
static Hashtable SignalEmitInfo = new Hashtable(); static Hashtable SignalEmitInfo = new Hashtable();
public static object Emit (GLib.Object o, string name, params object[] parameters) public static object Emit(GLib.Object o, string name, params object[] parameters) {
{
SignalQuery query; SignalQuery query;
GType gtype = o.NativeType; GType gtype = o.NativeType;
IntPtr type = gtype.Val; IntPtr type = gtype.Val;
@ -352,7 +330,8 @@ namespace Gst
if (colon == -1) { if (colon == -1) {
signal_name = name; signal_name = name;
signal_detail = String.Empty; signal_detail = String.Empty;
} else { }
else {
signal_name = name.Substring(0, colon); signal_name = name.Substring(0, colon);
signal_detail = name.Substring(colon + 2); signal_detail = name.Substring(colon + 2);
} }
@ -445,8 +424,7 @@ namespace Gst
static extern void g_signal_emitv(GLib.Value[] parameters, uint signal_id, uint detail, ref GLib.Value return_value); static extern void g_signal_emitv(GLib.Value[] parameters, uint signal_id, uint detail, ref GLib.Value return_value);
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
struct GSignalQuery struct GSignalQuery {
{
public uint signal_id; public uint signal_id;
public IntPtr signal_name; public IntPtr signal_name;
public IntPtr itype; public IntPtr itype;

View file

@ -30,8 +30,7 @@ namespace Gst {
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
partial class Element partial class Element {
{
public static bool Link(params Element[] elements) { public static bool Link(params Element[] elements) {
for (int i = 0; i < elements.Length - 1; i++) { for (int i = 0; i < elements.Length - 1; i++) {
if (!elements[i].Link(elements[i + 1])) if (!elements[i].Link(elements[i + 1]))

View file

@ -21,15 +21,12 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301 USA // 02110-1301 USA
namespace Gst namespace Gst {
{
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
public partial class ElementFactory public partial class ElementFactory {
{ public static IntPtr MakeRaw(string factoryname, string name) {
public static IntPtr MakeRaw(string factoryname, string name)
{
IntPtr native_factoryname = GLib.Marshaller.StringToPtrGStrdup(factoryname); IntPtr native_factoryname = GLib.Marshaller.StringToPtrGStrdup(factoryname);
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup(name); IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup(name);
IntPtr raw_ret = gst_element_factory_make(native_factoryname, native_name); IntPtr raw_ret = gst_element_factory_make(native_factoryname, native_name);

View file

@ -19,8 +19,7 @@ namespace Gst {
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
partial class Global partial class Global {
{
public static string TimeFormat(ulong time) { public static string TimeFormat(ulong time) {
return (time / (Gst.Constants.SECOND * 60 * 60)) + ":" + return (time / (Gst.Constants.SECOND * 60 * 60)) + ":" +
(time / (Gst.Constants.SECOND * 60)) % 60 + ":" + (time / (Gst.Constants.SECOND * 60)) % 60 + ":" +
@ -37,4 +36,3 @@ namespace Gst {
} }
} }

View file

@ -25,11 +25,11 @@
namespace Gst { namespace Gst {
using GLib;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using GLib;
public partial class Iterator : IEnumerable { public partial class Iterator : IEnumerable {

View file

@ -25,8 +25,7 @@ namespace Gst {
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
partial struct MapInfo partial struct MapInfo {
{
public byte[] Data { public byte[] Data {
get { get {
byte[] data = new byte[Size]; byte[] data = new byte[Size];

View file

@ -20,8 +20,7 @@ namespace Gst {
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
partial class Message partial class Message {
{
[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void gst_message_parse_error(IntPtr msg, out IntPtr err, out IntPtr debug); static extern void gst_message_parse_error(IntPtr msg, out IntPtr err, out IntPtr debug);

View file

@ -20,8 +20,7 @@ namespace Gst {
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
partial class MiniObject partial class MiniObject {
{
protected MiniObject() { } protected MiniObject() { }
[DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("gstreamer-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]

View file

@ -44,8 +44,7 @@ namespace Gst {
private IntPtr[] _gstGstReserved; private IntPtr[] _gstGstReserved;
} }
partial class Object partial class Object {
{
private Dictionary<string, bool> PropertyNameCache = new Dictionary<string, bool>(); private Dictionary<string, bool> PropertyNameCache = new Dictionary<string, bool>();
[DllImport("gobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("gobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
@ -74,9 +73,11 @@ namespace Gst {
using (GLib.Value v = GetProperty(property)) { using (GLib.Value v = GetProperty(property)) {
return v.Val; return v.Val;
} }
} else }
else
throw new PropertyNotFoundException(); throw new PropertyNotFoundException();
} set { }
set {
if (PropertyExists(property)) { if (PropertyExists(property)) {
if (value == null) { if (value == null) {
throw new ArgumentNullException(); throw new ArgumentNullException();
@ -90,7 +91,8 @@ namespace Gst {
v.Val = value; v.Val = value;
SetProperty(property, v); SetProperty(property, v);
v.Dispose(); v.Dispose();
} else }
else
throw new PropertyNotFoundException(); throw new PropertyNotFoundException();
} }
} }

View file

@ -19,8 +19,7 @@ namespace Gst {
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
partial class Pad partial class Pad {
{
[GLib.Property("caps")] [GLib.Property("caps")]
public Gst.Caps Caps { public Gst.Caps Caps {
get { get {

View file

@ -15,13 +15,11 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301 USA // 02110-1301 USA
namespace Gst namespace Gst {
{
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
public partial class TagList public partial class TagList {
{
public object this[string tag, uint index] { public object this[string tag, uint index] {
get { return GetValueIndex(tag, index).Val; } get { return GetValueIndex(tag, index).Val; }
} }
@ -54,8 +52,7 @@ namespace Gst
} }
} }
public void Add (Gst.TagMergeMode mode, string tag, object value) public void Add(Gst.TagMergeMode mode, string tag, object value) {
{
if (!Tag.Exists(tag)) if (!Tag.Exists(tag))
throw new ArgumentException(String.Format("Invalid tag name '{0}'", tag)); throw new ArgumentException(String.Format("Invalid tag name '{0}'", tag));

View file

@ -16,17 +16,15 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
// Wrapper for GLib.Value to add support for GstFraction, GstFourcc, Gst*Range, ... // Wrapper for GLib.Value to add support for GstFraction, GstFourcc, Gst*Range, ...
using GLib;
using System; using System;
using System.Text;
using System.Collections; using System.Collections;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using GLib; using System.Text;
/* TODO: intersect, compare, substract, .... */ /* TODO: intersect, compare, substract, .... */
namespace Gst namespace Gst {
{ public struct Fraction {
public struct Fraction
{
public int Numerator { public int Numerator {
get { get {
return numerator; return numerator;
@ -61,8 +59,7 @@ namespace Gst
} }
} }
private void Reduce () private void Reduce() {
{
int gcd = GreatestCommonDivisor(this); int gcd = GreatestCommonDivisor(this);
if (gcd != 0) { if (gcd != 0) {
@ -71,8 +68,7 @@ namespace Gst
} }
} }
private static int GreatestCommonDivisor (Fraction fraction) private static int GreatestCommonDivisor(Fraction fraction) {
{
int a = fraction.numerator; int a = fraction.numerator;
int b = fraction.denominator; int b = fraction.denominator;
@ -85,8 +81,7 @@ namespace Gst
return Math.Abs(a); return Math.Abs(a);
} }
public Fraction (int numerator, int denominator) public Fraction(int numerator, int denominator) {
{
if (denominator == 0) if (denominator == 0)
throw new ArgumentException(); throw new ArgumentException();
@ -95,52 +90,43 @@ namespace Gst
Reduce(); Reduce();
} }
public Fraction (GLib.Value val) : this () public Fraction(GLib.Value val) : this() {
{
this.numerator = gst_value_get_fraction_numerator(ref val); this.numerator = gst_value_get_fraction_numerator(ref val);
this.denominator = gst_value_get_fraction_denominator(ref val); this.denominator = gst_value_get_fraction_denominator(ref val);
} }
public void SetGValue (ref GLib.Value val) public void SetGValue(ref GLib.Value val) {
{
gst_value_set_fraction(ref val, Numerator, Denominator); gst_value_set_fraction(ref val, Numerator, Denominator);
} }
public override string ToString () public override string ToString() {
{
return String.Format("{0}/{1}", numerator, denominator); return String.Format("{0}/{1}", numerator, denominator);
} }
public static explicit operator GLib.Value (Fraction fraction) public static explicit operator GLib.Value(Fraction fraction) {
{
GLib.Value val = new GLib.Value(Fraction.GType); GLib.Value val = new GLib.Value(Fraction.GType);
gst_value_set_fraction(ref val, fraction.Numerator, fraction.Denominator); gst_value_set_fraction(ref val, fraction.Numerator, fraction.Denominator);
return val; return val;
} }
public static explicit operator double (Fraction fraction) public static explicit operator double(Fraction fraction) {
{
return ((double)fraction.numerator) / ((double)fraction.denominator); return ((double)fraction.numerator) / ((double)fraction.denominator);
} }
public static Fraction operator + (Fraction a, Fraction b) public static Fraction operator +(Fraction a, Fraction b) {
{
return new Fraction((a.Numerator * b.Denominator) + (b.Numerator * a.Denominator), a.Denominator * b.Denominator); return new Fraction((a.Numerator * b.Denominator) + (b.Numerator * a.Denominator), a.Denominator * b.Denominator);
} }
public static Fraction operator - (Fraction a, Fraction b) public static Fraction operator -(Fraction a, Fraction b) {
{
return new Fraction((a.Numerator * b.Denominator) - (b.Numerator * a.Denominator), a.Denominator * b.Denominator); return new Fraction((a.Numerator * b.Denominator) - (b.Numerator * a.Denominator), a.Denominator * b.Denominator);
} }
public static Fraction operator * (Fraction a, Fraction b) public static Fraction operator *(Fraction a, Fraction b) {
{
return new Fraction(a.Numerator * b.Numerator, a.Denominator * b.Denominator); return new Fraction(a.Numerator * b.Numerator, a.Denominator * b.Denominator);
} }
public static Fraction operator / (Fraction a, Fraction b) public static Fraction operator /(Fraction a, Fraction b) {
{
return new Fraction(a.Numerator * b.Denominator, a.Denominator * b.Numerator); return new Fraction(a.Numerator * b.Denominator, a.Denominator * b.Numerator);
} }
@ -161,8 +147,7 @@ namespace Gst
private static extern IntPtr gst_fraction_get_type(); private static extern IntPtr gst_fraction_get_type();
} }
public struct DoubleRange public struct DoubleRange {
{
public double Min; public double Min;
public double Max; public double Max;
@ -172,8 +157,7 @@ namespace Gst
} }
} }
public DoubleRange (double min, double max) public DoubleRange(double min, double max) {
{
if (min > max) if (min > max)
throw new ArgumentException(); throw new ArgumentException();
@ -181,24 +165,20 @@ namespace Gst
this.Max = max; this.Max = max;
} }
public DoubleRange (GLib.Value val) : this () public DoubleRange(GLib.Value val) : this() {
{
this.Min = gst_value_get_double_range_min(ref val); this.Min = gst_value_get_double_range_min(ref val);
this.Max = gst_value_get_double_range_max(ref val); this.Max = gst_value_get_double_range_max(ref val);
} }
public override string ToString () public override string ToString() {
{
return String.Format("[{0}, {1}]", Min, Max); return String.Format("[{0}, {1}]", Min, Max);
} }
public void SetGValue (ref GLib.Value val) public void SetGValue(ref GLib.Value val) {
{
gst_value_set_double_range(ref val, Min, Max); gst_value_set_double_range(ref val, Min, Max);
} }
public static explicit operator GLib.Value (DoubleRange range) public static explicit operator GLib.Value(DoubleRange range) {
{
GLib.Value val = new GLib.Value(DoubleRange.GType); GLib.Value val = new GLib.Value(DoubleRange.GType);
gst_value_set_double_range(ref val, range.Min, range.Max); gst_value_set_double_range(ref val, range.Min, range.Max);
@ -222,8 +202,7 @@ namespace Gst
private static extern double gst_value_get_double_range_max(ref GLib.Value v); private static extern double gst_value_get_double_range_max(ref GLib.Value v);
} }
public struct IntRange public struct IntRange {
{
public int Min; public int Min;
public int Max; public int Max;
@ -233,8 +212,7 @@ namespace Gst
} }
} }
public IntRange (int min, int max) public IntRange(int min, int max) {
{
if (min > max) if (min > max)
throw new ArgumentException(); throw new ArgumentException();
@ -242,24 +220,20 @@ namespace Gst
this.Max = max; this.Max = max;
} }
public IntRange (GLib.Value val) : this () public IntRange(GLib.Value val) : this() {
{
this.Min = gst_value_get_int_range_min(ref val); this.Min = gst_value_get_int_range_min(ref val);
this.Max = gst_value_get_int_range_max(ref val); this.Max = gst_value_get_int_range_max(ref val);
} }
public void SetGValue (ref GLib.Value val) public void SetGValue(ref GLib.Value val) {
{
gst_value_set_int_range(ref val, Min, Max); gst_value_set_int_range(ref val, Min, Max);
} }
public override string ToString () public override string ToString() {
{
return String.Format("[{0}, {1}]", Min, Max); return String.Format("[{0}, {1}]", Min, Max);
} }
public static explicit operator GLib.Value (IntRange range) public static explicit operator GLib.Value(IntRange range) {
{
GLib.Value val = new GLib.Value(IntRange.GType); GLib.Value val = new GLib.Value(IntRange.GType);
gst_value_set_int_range(ref val, range.Min, range.Max); gst_value_set_int_range(ref val, range.Min, range.Max);
@ -283,8 +257,7 @@ namespace Gst
private static extern int gst_value_get_int_range_max(ref GLib.Value v); private static extern int gst_value_get_int_range_max(ref GLib.Value v);
} }
public struct FractionRange public struct FractionRange {
{
public Fraction Min; public Fraction Min;
public Fraction Max; public Fraction Max;
@ -294,8 +267,7 @@ namespace Gst
} }
} }
public FractionRange (Fraction min, Fraction max) public FractionRange(Fraction min, Fraction max) {
{
double a = (double)min, b = (double)max; double a = (double)min, b = (double)max;
if (a > b) if (a > b)
@ -305,8 +277,7 @@ namespace Gst
this.Max = max; this.Max = max;
} }
public FractionRange (GLib.Value val) : this () public FractionRange(GLib.Value val) : this() {
{
IntPtr min_ptr, max_ptr; IntPtr min_ptr, max_ptr;
GLib.Value min, max; GLib.Value min, max;
@ -319,8 +290,7 @@ namespace Gst
this.Max = (Fraction)max.Val; this.Max = (Fraction)max.Val;
} }
public void SetGValue (ref GLib.Value val) public void SetGValue(ref GLib.Value val) {
{
GLib.Value min = new GLib.Value(Min); GLib.Value min = new GLib.Value(Min);
GLib.Value max = new GLib.Value(Max); GLib.Value max = new GLib.Value(Max);
gst_value_set_fraction_range(ref val, ref min, ref max); gst_value_set_fraction_range(ref val, ref min, ref max);
@ -328,13 +298,11 @@ namespace Gst
max.Dispose(); max.Dispose();
} }
public override string ToString () public override string ToString() {
{
return String.Format("[{0}, {1}]", Min, Max); return String.Format("[{0}, {1}]", Min, Max);
} }
public static explicit operator GLib.Value (FractionRange range) public static explicit operator GLib.Value(FractionRange range) {
{
GLib.Value val = new GLib.Value(FractionRange.GType); GLib.Value val = new GLib.Value(FractionRange.GType);
GLib.Value min = new GLib.Value(range.Min); GLib.Value min = new GLib.Value(range.Min);
@ -362,8 +330,7 @@ namespace Gst
private static extern IntPtr gst_value_get_fraction_range_max(ref GLib.Value v); private static extern IntPtr gst_value_get_fraction_range_max(ref GLib.Value v);
} }
public class Date : IWrapper public class Date : IWrapper {
{
public DateTime Val; public DateTime Val;
private IntPtr handle; private IntPtr handle;
@ -379,38 +346,32 @@ namespace Gst
} }
} }
~Date () ~Date() {
{
g_date_free(handle); g_date_free(handle);
} }
public Date (DateTime date) public Date(DateTime date) {
{
this.Val = date; this.Val = date;
handle = g_date_new_dmy((byte)Val.Day, (int)Val.Month, (ushort)Val.Year); handle = g_date_new_dmy((byte)Val.Day, (int)Val.Month, (ushort)Val.Year);
} }
public Date (int day, int month, int year) public Date(int day, int month, int year) {
{
this.Val = new DateTime(year, month, day); this.Val = new DateTime(year, month, day);
handle = g_date_new_dmy((byte)Val.Day, (int)Val.Month, (ushort)Val.Year); handle = g_date_new_dmy((byte)Val.Day, (int)Val.Month, (ushort)Val.Year);
} }
public Date (GLib.Value val) public Date(GLib.Value val) {
{
IntPtr date = gst_value_get_date(ref val); IntPtr date = gst_value_get_date(ref val);
this.Val = new DateTime(g_date_get_year(date), g_date_get_month(date), g_date_get_day(date)); this.Val = new DateTime(g_date_get_year(date), g_date_get_month(date), g_date_get_day(date));
handle = g_date_new_dmy((byte)Val.Day, (int)Val.Month, (ushort)Val.Year); handle = g_date_new_dmy((byte)Val.Day, (int)Val.Month, (ushort)Val.Year);
} }
public static Date New (IntPtr date) public static Date New(IntPtr date) {
{
return new Date(g_date_get_day(date), g_date_get_month(date), g_date_get_year(date)); return new Date(g_date_get_day(date), g_date_get_month(date), g_date_get_year(date));
} }
public void SetGValue (ref GLib.Value val) public void SetGValue(ref GLib.Value val) {
{
IntPtr date_ptr = g_date_new_dmy((byte)Val.Day, (int)Val.Month, (ushort)Val.Year); IntPtr date_ptr = g_date_new_dmy((byte)Val.Day, (int)Val.Month, (ushort)Val.Year);
gst_value_set_date(ref val, date_ptr); gst_value_set_date(ref val, date_ptr);
@ -418,13 +379,11 @@ namespace Gst
GLib.Marshaller.Free(date_ptr); GLib.Marshaller.Free(date_ptr);
} }
public override string ToString () public override string ToString() {
{
return String.Format("{0}-{1}-{2}", Val.Year, Val.Month, Val.Day); return String.Format("{0}-{1}-{2}", Val.Year, Val.Month, Val.Day);
} }
public static explicit operator GLib.Value (Date date) public static explicit operator GLib.Value(Date date) {
{
GLib.Value val = new GLib.Value(Date.GType); GLib.Value val = new GLib.Value(Date.GType);
date.SetGValue(ref val); date.SetGValue(ref val);
@ -460,8 +419,7 @@ namespace Gst
private static extern void gst_value_set_date(ref GLib.Value val, IntPtr date); private static extern void gst_value_set_date(ref GLib.Value val, IntPtr date);
} }
public struct List : IEnumerable public struct List : IEnumerable {
{
private IList content; private IList content;
public static GLib.GType GType { public static GLib.GType GType {
@ -470,13 +428,11 @@ namespace Gst
} }
} }
public List (IList content) public List(IList content) {
{
this.content = content; this.content = content;
} }
public List (GLib.Value val) public List(GLib.Value val) {
{
this.content = new ArrayList(); this.content = new ArrayList();
uint n = gst_value_list_get_size(ref val); uint n = gst_value_list_get_size(ref val);
@ -487,8 +443,7 @@ namespace Gst
} }
} }
public void SetGValue (ref GLib.Value val) public void SetGValue(ref GLib.Value val) {
{
foreach (object o in content) { foreach (object o in content) {
GLib.Value v = new GLib.Value(o); GLib.Value v = new GLib.Value(o);
gst_value_list_append_value(ref val, ref v); gst_value_list_append_value(ref val, ref v);
@ -496,8 +451,7 @@ namespace Gst
} }
} }
public override string ToString () public override string ToString() {
{
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.Append("< "); sb.Append("< ");
@ -511,8 +465,7 @@ namespace Gst
return sb.ToString(); return sb.ToString();
} }
public static explicit operator GLib.Value (List l) public static explicit operator GLib.Value(List l) {
{
GLib.Value val = new GLib.Value(List.GType); GLib.Value val = new GLib.Value(List.GType);
foreach (object o in l.content) { foreach (object o in l.content) {
@ -524,8 +477,7 @@ namespace Gst
return val; return val;
} }
public IEnumerator GetEnumerator () public IEnumerator GetEnumerator() {
{
return content.GetEnumerator(); return content.GetEnumerator();
} }
@ -555,8 +507,7 @@ namespace Gst
private static extern void gst_value_list_append_value(ref GLib.Value val, ref GLib.Value el); private static extern void gst_value_list_append_value(ref GLib.Value val, ref GLib.Value el);
} }
public struct Array : IEnumerable public struct Array : IEnumerable {
{
private IList content; private IList content;
public static GLib.GType GType { public static GLib.GType GType {
@ -565,13 +516,11 @@ namespace Gst
} }
} }
public Array (IList content) public Array(IList content) {
{
this.content = content; this.content = content;
} }
public Array (GLib.Value val) public Array(GLib.Value val) {
{
this.content = new ArrayList(); this.content = new ArrayList();
uint n = gst_value_array_get_size(ref val); uint n = gst_value_array_get_size(ref val);
@ -582,8 +531,7 @@ namespace Gst
} }
} }
public void SetGValue (ref GLib.Value val) public void SetGValue(ref GLib.Value val) {
{
foreach (object o in content) { foreach (object o in content) {
GLib.Value v = new GLib.Value(o); GLib.Value v = new GLib.Value(o);
gst_value_array_append_value(ref val, ref v); gst_value_array_append_value(ref val, ref v);
@ -591,8 +539,7 @@ namespace Gst
} }
} }
public static explicit operator GLib.Value (Array a) public static explicit operator GLib.Value(Array a) {
{
GLib.Value val = new GLib.Value(Gst.Array.GType); GLib.Value val = new GLib.Value(Gst.Array.GType);
foreach (object o in a.content) { foreach (object o in a.content) {
@ -604,8 +551,7 @@ namespace Gst
return val; return val;
} }
public override string ToString () public override string ToString() {
{
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.Append("{ "); sb.Append("{ ");
@ -619,8 +565,7 @@ namespace Gst
return sb.ToString(); return sb.ToString();
} }
public IEnumerator GetEnumerator () public IEnumerator GetEnumerator() {
{
return content.GetEnumerator(); return content.GetEnumerator();
} }

View file

@ -25,18 +25,15 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Gst namespace Gst {
{ public static class Version {
public static class Version
{
private static uint major; private static uint major;
private static uint minor; private static uint minor;
private static uint micro; private static uint micro;
private static uint nano; private static uint nano;
private static string version_string; private static string version_string;
static Version () static Version() {
{
gst_version(out major, out minor, out micro, out nano); gst_version(out major, out minor, out micro, out nano);
} }

View file

@ -19,10 +19,8 @@ namespace Gst.Video {
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
partial struct VideoGLTextureUploadMeta partial struct VideoGLTextureUploadMeta {
{ public bool Equals(VideoGLTextureUploadMeta other) {
public bool Equals (VideoGLTextureUploadMeta other)
{
return Meta.Equals(other.Meta) && TextureOrientation.Equals(other.TextureOrientation) && NTextures.Equals(other.NTextures) && TextureType.Equals(other.TextureType); return Meta.Equals(other.Meta) && TextureOrientation.Equals(other.TextureOrientation) && NTextures.Equals(other.NTextures) && TextureType.Equals(other.TextureType);
} }
} }