mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-02 14:36:41 +00:00
aa7bb8fa1c
glib-sharp will only get a new release with the new API that we need for 3.0 in a year or something. Instead of waiting a year before we can release something we now have our own internal copy of glib-sharp trunk that will be dropped once glib-sharp 3.0 is released. Everything is now compilable and working without any additional patches.
151 lines
4.1 KiB
Text
151 lines
4.1 KiB
Text
public object this[string property] {
|
|
get {
|
|
Gst.GLib.Value v = GetProperty (property);
|
|
object o = v.Val;
|
|
v.Dispose ();
|
|
return o;
|
|
}
|
|
set {
|
|
Gst.GLib.Value v = new Gst.GLib.Value (this, property);
|
|
v.Val = value;
|
|
SetProperty (property, v);
|
|
v.Dispose ();
|
|
}
|
|
}
|
|
|
|
[DllImport ("libgobject-2.0-0.dll") ]
|
|
static extern IntPtr g_object_class_list_properties (IntPtr klass, out uint n_properties);
|
|
|
|
[DllImport ("libgobject-2.0-0.dll") ]
|
|
static extern IntPtr g_object_class_find_property (IntPtr gclass, IntPtr name);
|
|
|
|
public PropertyInfo GetPropertyInfo (string property) {
|
|
IntPtr klass = Marshal.ReadIntPtr (Handle);
|
|
|
|
IntPtr native_property = Gst.GLib.Marshaller.StringToPtrGStrdup (property);
|
|
IntPtr pspec = g_object_class_find_property (klass, native_property);
|
|
Gst.GLib.Marshaller.Free (native_property);
|
|
|
|
if (pspec == IntPtr.Zero)
|
|
throw new ArgumentException ("Unknown property");
|
|
|
|
return new PropertyInfo (pspec);
|
|
}
|
|
|
|
public PropertyInfo[] Properties {
|
|
get {
|
|
uint n_properties;
|
|
IntPtr klass = Marshal.ReadIntPtr (Handle);
|
|
IntPtr properties = g_object_class_list_properties (klass, out n_properties);
|
|
|
|
PropertyInfo[] ret = new PropertyInfo[n_properties];
|
|
for (int i = 0; i < n_properties; i++) {
|
|
IntPtr pspec_ptr = Marshal.ReadIntPtr (properties, i * IntPtr.Size);
|
|
ret[i] = new PropertyInfo (pspec_ptr);
|
|
}
|
|
Gst.GLib.Marshaller.Free (properties);
|
|
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
public void Connect (string signal, SignalHandler handler) {
|
|
DynamicSignal.Connect (this, signal, handler);
|
|
}
|
|
|
|
public void Disconnect (string signal, SignalHandler handler) {
|
|
DynamicSignal.Disconnect (this, signal, handler);
|
|
}
|
|
|
|
public void Connect (string signal, Delegate handler) {
|
|
DynamicSignal.Connect (this, signal, handler);
|
|
}
|
|
|
|
public void Disconnect (string signal, Delegate handler) {
|
|
DynamicSignal.Disconnect (this, signal, handler);
|
|
}
|
|
|
|
public object Emit (string signal, params object[] parameters) {
|
|
return DynamicSignal.Emit (this, signal, parameters);
|
|
}
|
|
|
|
[DllImport("libgstreamer-0.10.dll") ]
|
|
static extern void gst_object_sink (IntPtr raw);
|
|
[DllImport("libgstreamer-0.10.dll") ]
|
|
static extern IntPtr gst_object_ref (IntPtr raw);
|
|
|
|
protected override IntPtr Raw {
|
|
get {
|
|
return base.Raw;
|
|
}
|
|
set {
|
|
if (value != IntPtr.Zero) {
|
|
gst_object_ref (value);
|
|
gst_object_sink (value);
|
|
}
|
|
base.Raw = value;
|
|
}
|
|
}
|
|
|
|
|
|
[DllImport("libgstreamer-0.10.dll") ]
|
|
static extern bool gst_object_set_parent (IntPtr raw, IntPtr parent);
|
|
[DllImport("libgstreamer-0.10.dll") ]
|
|
static extern IntPtr gst_object_get_parent (IntPtr raw);
|
|
|
|
public Gst.Object Parent {
|
|
set {
|
|
bool raw_ret = gst_object_set_parent (Handle, value == null ? IntPtr.Zero : value.Handle);
|
|
if (!raw_ret)
|
|
throw new ApplicationException ();
|
|
}
|
|
get {
|
|
IntPtr raw_ret = gst_object_get_parent (Handle);
|
|
Gst.Object ret = Gst.GLib.Object.GetObject (raw_ret, true) as Gst.Object;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
[DllImport ("gstreamersharpglue-0.10.dll") ]
|
|
extern static uint gstsharp_gst_object_get_lock_offset ();
|
|
|
|
static uint lock_offset = gstsharp_gst_object_get_lock_offset ();
|
|
internal IntPtr LockPtr {
|
|
get {
|
|
unsafe {
|
|
IntPtr* raw_ptr = (IntPtr*) ( ( (byte*) Handle) + lock_offset);
|
|
return (*raw_ptr);
|
|
}
|
|
}
|
|
}
|
|
|
|
[DllImport ("libglib-2.0-0.dll") ]
|
|
static extern void g_mutex_lock (IntPtr mutex);
|
|
[DllImport ("libglib-2.0-0.dll") ]
|
|
static extern void g_mutex_unlock (IntPtr mutex);
|
|
[DllImport ("libglib-2.0-0.dll") ]
|
|
static extern bool g_mutex_trylock (IntPtr mutex);
|
|
|
|
public void Lock () {
|
|
g_mutex_lock (LockPtr);
|
|
}
|
|
|
|
public void Unlock () {
|
|
g_mutex_unlock (LockPtr);
|
|
}
|
|
|
|
public bool TryLock () {
|
|
return g_mutex_trylock (LockPtr);
|
|
}
|
|
|
|
[DllImport("libgstreamer-0.10.dll") ]
|
|
static extern bool gst_object_check_uniqueness (IntPtr list, IntPtr name);
|
|
|
|
public static bool CheckUniqueness (Gst.Object[] objects, string name) {
|
|
Gst.GLib.List list = new Gst.GLib.List (objects, typeof (Gst.Object), false, false);
|
|
IntPtr native_name = Gst.GLib.Marshaller.StringToPtrGStrdup (name);
|
|
bool raw_ret = gst_object_check_uniqueness (list.Handle, native_name);
|
|
bool ret = raw_ret;
|
|
Gst.GLib.Marshaller.Free (native_name);
|
|
return ret;
|
|
}
|