Fix indention of all files

This commit is contained in:
Sebastian Dröge 2009-04-07 11:27:20 +02:00
parent 2a2822bb80
commit 85e2db4e5f
25 changed files with 975 additions and 1009 deletions

View file

@ -12,85 +12,78 @@
using System;
using System.Runtime.InteropServices;
namespace Gst
{
public static class Application
{
public static void Init()
{
IntPtr argv = new IntPtr(0);
int argc = 0;
namespace Gst {
public static class Application {
public static void Init() {
IntPtr argv = new IntPtr (0);
int argc = 0;
gst_init(ref argc, ref argv);
}
public static void Init(string progname, ref string [] args)
{
FullInit(progname, ref args, false);
}
public static void InitCheck(string progname, ref string [] args)
{
FullInit(progname, ref args, true);
}
public static void Deinit()
{
gst_deinit();
}
private static void FullInit(string progname, ref string [] args, bool check)
{
string [] progargs = new string[args.Length + 1];
progargs[0] = progname;
args.CopyTo(progargs, 1);
GLib.Argv argv = new GLib.Argv(progargs);
IntPtr argv_ptr = argv.Handle;
int argc = progargs.Length;
if(check) {
IntPtr error_ptr;
bool result = gst_init_check(ref argc, ref argv_ptr, out error_ptr);
if(error_ptr != IntPtr.Zero) {
string message = GError.GetMessage (error_ptr);
if (message == String.Empty)
message = "Reason unknown";
GError.Free (error_ptr);
throw new ApplicationException(String.Format ("gst_init_check() failed: {0}", message));
} else if(!result) {
throw new ApplicationException("gst_init_check() failed: Reason unknown");
}
} else {
gst_init(ref argc, ref argv_ptr);
}
if(argv_ptr != argv.Handle) {
string init_call = check ? "gst_init_check()" : "gst_init()";
throw new ApplicationException(init_call + " returned a new argv handle");
}
if(argc <= 1) {
args = new string[0];
} else {
progargs = argv.GetArgs(argc);
args = new string[argc - 1];
Array.Copy(progargs, 1, args, 0, argc - 1);
}
}
[DllImport("gstreamer-0.10")]
private static extern void gst_init(ref int argc, ref IntPtr argv);
[DllImport("gstreamer-0.10")]
private static extern bool gst_init_check(ref int argc, ref IntPtr argv, out IntPtr error);
[DllImport("gstreamer-0.10")]
private static extern void gst_deinit();
gst_init (ref argc, ref argv);
}
public static void Init (string progname, ref string [] args) {
FullInit (progname, ref args, false);
}
public static void InitCheck (string progname, ref string [] args) {
FullInit (progname, ref args, true);
}
public static void Deinit() {
gst_deinit();
}
private static void FullInit (string progname, ref string [] args, bool check) {
string [] progargs = new string[args.Length + 1];
progargs[0] = progname;
args.CopyTo (progargs, 1);
GLib.Argv argv = new GLib.Argv (progargs);
IntPtr argv_ptr = argv.Handle;
int argc = progargs.Length;
if (check) {
IntPtr error_ptr;
bool result = gst_init_check (ref argc, ref argv_ptr, out error_ptr);
if (error_ptr != IntPtr.Zero) {
string message = GError.GetMessage (error_ptr);
if (message == String.Empty)
message = "Reason unknown";
GError.Free (error_ptr);
throw new ApplicationException (String.Format ("gst_init_check() failed: {0}", message));
} else if (!result) {
throw new ApplicationException ("gst_init_check() failed: Reason unknown");
}
} else {
gst_init (ref argc, ref argv_ptr);
}
if (argv_ptr != argv.Handle) {
string init_call = check ? "gst_init_check()" : "gst_init()";
throw new ApplicationException (init_call + " returned a new argv handle");
}
if (argc <= 1) {
args = new string[0];
} else {
progargs = argv.GetArgs (argc);
args = new string[argc - 1];
Array.Copy (progargs, 1, args, 0, argc - 1);
}
}
[DllImport ("gstreamer-0.10") ]
private static extern void gst_init (ref int argc, ref IntPtr argv);
[DllImport ("gstreamer-0.10") ]
private static extern bool gst_init_check (ref int argc, ref IntPtr argv, out IntPtr error);
[DllImport ("gstreamer-0.10") ]
private static extern void gst_deinit();
}
}

View file

@ -1,6 +1,6 @@
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly:AssemblyVersion("@VERSION@")]
[assembly:AssemblyDelaySign(false)]
[assembly:AssemblyKeyFile("gstreamer-sharp.snk")]
[assembly:AssemblyVersion ("@VERSION@") ]
[assembly:AssemblyDelaySign (false) ]
[assembly:AssemblyKeyFile ("gstreamer-sharp.snk") ]

View file

@ -1,68 +1,66 @@
[DllImport ("gstreamersharpglue-0.10")]
private extern static uint gstsharp_gst_bin_get_children_offset();
[DllImport ("gstreamersharpglue-0.10") ]
private extern static uint gstsharp_gst_bin_get_children_offset();
static uint children_offset = gstsharp_gst_bin_get_children_offset();
static uint children_offset = gstsharp_gst_bin_get_children_offset();
public Element [] Children {
get {
GLib.List list;
unsafe {
IntPtr* raw_ptr = (IntPtr*)(((byte*)Handle) + children_offset);
list = new GLib.List((*raw_ptr));
}
Element [] result = new Element[list.Count];
for(int i = list.Count - 1; i >= 0; i--) {
result[i] = list[i] as Element;
}
return result;
}
public Element [] Children {
get {
GLib.List list;
unsafe {
IntPtr* raw_ptr = (IntPtr*) ( ( (byte*) Handle) + children_offset);
list = new GLib.List ( (*raw_ptr));
}
[DllImport("gstreamer-0.10.dll")]
static extern bool gst_bin_add(IntPtr raw, IntPtr element);
Element [] result = new Element[list.Count];
public bool Add(Gst.Element element) {
bool raw_ret = gst_bin_add(Handle, element == null ? IntPtr.Zero : element.Handle);
if(raw_ret) {
// Incrmenting the refcount of the element.
Gst.Object.Ref(element.Handle);
}
bool ret = raw_ret;
return ret;
for (int i = list.Count - 1; i >= 0; i--) {
result[i] = list[i] as Element;
}
public bool AddMany(params Element[] elements)
{
if(elements == null) {
return false;
}
foreach(Element element in elements) {
if(element == null || !Add(element)) {
return false;
}
}
return true;
return result;
}
}
[DllImport ("gstreamer-0.10.dll") ]
static extern bool gst_bin_add (IntPtr raw, IntPtr element);
public bool Add (Gst.Element element) {
bool raw_ret = gst_bin_add (Handle, element == null ? IntPtr.Zero : element.Handle);
if (raw_ret) {
// Incrmenting the refcount of the element.
Gst.Object.Ref (element.Handle);
}
bool ret = raw_ret;
return ret;
}
public bool AddMany (params Element[] elements) {
if (elements == null) {
return false;
}
foreach (Element element in elements) {
if (element == null || !Add (element)) {
return false;
}
}
public bool RemoveMany(params Element[] elements)
{
if(elements == null) {
return false;
}
foreach(Element element in elements) {
if(element == null || !Remove(element)) {
return false;
}
}
return true;
}
public bool RemoveMany (params Element[] elements) {
if (elements == null) {
return false;
}
foreach (Element element in elements) {
if (element == null || !Remove (element)) {
return false;
}
}
return true;
}
return true;
}

View file

@ -1,6 +1,6 @@
//
// BindingHelper.cs: Utility methods to make creating
// element bindings by hand an easier task
// element bindings by hand an easier task
//
// Authors:
// Aaron Bockover (abockover@novell.com)
@ -11,45 +11,40 @@
using System;
using GLib;
namespace Gst
{
public static class BindingHelper
{
public static Delegate AddProxySignalDelegate(Element element, string signal,
DynamicSignalHandler baseHandler, Delegate existingHandler, Delegate addHandler)
{
if(existingHandler == null) {
element.Connect(signal, baseHandler);
}
return Delegate.Combine(existingHandler, addHandler);
}
public static Delegate RemoveProxySignalDelegate(Element element, string signal,
DynamicSignalHandler baseHandler, Delegate existingHandler, Delegate removeHandler)
{
Delegate temp_delegate = Delegate.Remove(existingHandler, removeHandler);
if(temp_delegate == null) {
element.Disconnect(signal, baseHandler);
}
return temp_delegate;
}
public static void InvokeProxySignalDelegate(Delegate raiseDelegate, Type type,
object o, GLib.SignalArgs args)
{
if(!type.IsSubclassOf(typeof(GLib.SignalArgs))) {
throw new ArgumentException("Args type must derive SignalArgs");
}
if(raiseDelegate != null) {
GLib.SignalArgs new_args = (GLib.SignalArgs) Activator.CreateInstance (type);
new_args.RetVal = args.RetVal;
new_args.Args = args.Args;
raiseDelegate.DynamicInvoke(new object [] { o, new_args });
}
}
namespace Gst {
public static class BindingHelper {
public static Delegate AddProxySignalDelegate (Element element, string signal,
DynamicSignalHandler baseHandler, Delegate existingHandler, Delegate addHandler) {
if (existingHandler == null) {
element.Connect (signal, baseHandler);
}
return Delegate.Combine (existingHandler, addHandler);
}
public static Delegate RemoveProxySignalDelegate (Element element, string signal,
DynamicSignalHandler baseHandler, Delegate existingHandler, Delegate removeHandler) {
Delegate temp_delegate = Delegate.Remove (existingHandler, removeHandler);
if (temp_delegate == null) {
element.Disconnect (signal, baseHandler);
}
return temp_delegate;
}
public static void InvokeProxySignalDelegate (Delegate raiseDelegate, Type type,
object o, GLib.SignalArgs args) {
if (!type.IsSubclassOf (typeof (GLib.SignalArgs))) {
throw new ArgumentException ("Args type must derive SignalArgs");
}
if (raiseDelegate != null) {
GLib.SignalArgs new_args = (GLib.SignalArgs) Activator.CreateInstance (type);
new_args.RetVal = args.RetVal;
new_args.Args = args.Args;
raiseDelegate.DynamicInvoke (new object [] { o, new_args });
}
}
}
}

View file

@ -1,25 +1,22 @@
[DllImport("gstreamer-0.10")]
static extern IntPtr gst_mini_object_ref (IntPtr buf);
[DllImport ("gstreamer-0.10") ]
static extern IntPtr gst_mini_object_ref (IntPtr buf);
public void Ref()
{
IntPtr tmp = gst_mini_object_ref(this.Handle);
}
public void Ref() {
IntPtr tmp = gst_mini_object_ref (this.Handle);
}
[DllImport("gstreamer-0.10")]
static extern void gst_mini_object_unref(IntPtr buf);
[DllImport ("gstreamer-0.10") ]
static extern void gst_mini_object_unref (IntPtr buf);
public void Unref()
{
gst_mini_object_unref(this.Handle);
}
public void Unref() {
gst_mini_object_unref (this.Handle);
}
[DllImport("gstreamersharpglue-0.10")]
static extern uint gstsharp_gst_buffer_refcount(IntPtr buf);
[DllImport ("gstreamersharpglue-0.10") ]
static extern uint gstsharp_gst_buffer_refcount (IntPtr buf);
public uint Refcount
{
get {
return gstsharp_gst_buffer_refcount(this.Handle);
}
}
public uint Refcount {
get {
return gstsharp_gst_buffer_refcount (this.Handle);
}
}

View file

@ -1,5 +1,4 @@
public uint AddWatch(BusFunc func)
{
return AddWatchFull(0, func);
}
public uint AddWatch (BusFunc func) {
return AddWatchFull (0, func);
}

View file

@ -1,34 +1,33 @@
[DllImport("gstreamersharpglue-0.10")]
private extern static ulong gstsharp_gst_clock_get_gst_second();
[DllImport ("gstreamersharpglue-0.10") ]
private extern static ulong gstsharp_gst_clock_get_gst_second();
public static readonly ulong Second = gstsharp_gst_clock_get_gst_second();
public static readonly ulong Second = gstsharp_gst_clock_get_gst_second();
[DllImport("gstreamersharpglue-0.10")]
private extern static ulong gstsharp_gst_clock_get_gst_msecond();
[DllImport ("gstreamersharpglue-0.10") ]
private extern static ulong gstsharp_gst_clock_get_gst_msecond();
public static readonly ulong MSecond = gstsharp_gst_clock_get_gst_second();
public static readonly ulong MSecond = gstsharp_gst_clock_get_gst_second();
[DllImport("gstreamersharpglue-0.10")]
private extern static ulong gstsharp_gst_clock_get_gst_usecond();
[DllImport ("gstreamersharpglue-0.10") ]
private extern static ulong gstsharp_gst_clock_get_gst_usecond();
public static readonly ulong USecond = gstsharp_gst_clock_get_gst_second();
public static readonly ulong USecond = gstsharp_gst_clock_get_gst_second();
[DllImport("gstreamersharpglue-0.10")]
private extern static ulong gstsharp_gst_clock_get_gst_nsecond();
[DllImport ("gstreamersharpglue-0.10") ]
private extern static ulong gstsharp_gst_clock_get_gst_nsecond();
public static readonly ulong NSecond = gstsharp_gst_clock_get_gst_second();
public static readonly ulong NSecond = gstsharp_gst_clock_get_gst_second();
[DllImport ("gstreamersharpglue-0.10") ]
private extern static ulong gstsharp_gst_clock_get_time_none();
public static readonly ulong TimeNone = gstsharp_gst_clock_get_time_none();
[DllImport ("gstreamersharpglue-0.10") ]
private extern static bool gstsharp_gst_clock_time_is_valid (ulong time);
public static bool TimeIsValid (ulong time) {
return gstsharp_gst_clock_time_is_valid (time);
}
[DllImport("gstreamersharpglue-0.10")]
private extern static ulong gstsharp_gst_clock_get_time_none();
public static readonly ulong TimeNone = gstsharp_gst_clock_get_time_none();
[DllImport("gstreamersharpglue-0.10")]
private extern static bool gstsharp_gst_clock_time_is_valid(ulong time);
public static bool TimeIsValid(ulong time)
{
return gstsharp_gst_clock_time_is_valid(time);
}

View file

@ -7,43 +7,41 @@
// (C) 2002 Alp Toker
//
namespace Gst
{
public sealed class CommonTags
{
public const string Title = "title";
public const string Artist = "artist";
public const string Album = "album";
public const string Date = "date";
public const string Genre = "genre";
public const string Comment = "comment";
public const string TrackNumber = "track-number";
public const string TrackCount = "track-count";
public const string AlbumVolumeNumber = "album-disc-number";
public const string AlbumVolumeCount = "album-disc-count";
public const string Location = "location";
public const string Description = "description";
public const string Version = "version";
public const string Isrc = "isrc";
public const string Organization = "organization";
public const string Copyright = "copyright";
public const string Contact = "contact";
public const string License = "license";
public const string Performer = "performer";
public const string Duration = "duration";
public const string Codec = "codec";
public const string VideoCodec = "video-codec";
public const string AudioCodec = "audio-codec";
public const string Bitrate = "bitrate";
public const string NominalBitrate = "nominal-bitrate";
public const string MinimumBitrate = "minimum-bitrate";
public const string MaximumBitrate = "maximum-bitrate";
public const string Serial = "serial";
public const string Encoder = "encoder";
public const string EncoderVersion = "encoder-version";
public const string TrackGain = "replaygain-track-gain";
public const string TrackPeak = "replaygain-track-peak";
public const string AlbumGain = "replaygain-album-gain";
public const string AlbumPeak = "replaygain-album-peak";
}
namespace Gst {
public sealed class CommonTags {
public const string Title = "title";
public const string Artist = "artist";
public const string Album = "album";
public const string Date = "date";
public const string Genre = "genre";
public const string Comment = "comment";
public const string TrackNumber = "track-number";
public const string TrackCount = "track-count";
public const string AlbumVolumeNumber = "album-disc-number";
public const string AlbumVolumeCount = "album-disc-count";
public const string Location = "location";
public const string Description = "description";
public const string Version = "version";
public const string Isrc = "isrc";
public const string Organization = "organization";
public const string Copyright = "copyright";
public const string Contact = "contact";
public const string License = "license";
public const string Performer = "performer";
public const string Duration = "duration";
public const string Codec = "codec";
public const string VideoCodec = "video-codec";
public const string AudioCodec = "audio-codec";
public const string Bitrate = "bitrate";
public const string NominalBitrate = "nominal-bitrate";
public const string MinimumBitrate = "minimum-bitrate";
public const string MaximumBitrate = "maximum-bitrate";
public const string Serial = "serial";
public const string Encoder = "encoder";
public const string EncoderVersion = "encoder-version";
public const string TrackGain = "replaygain-track-gain";
public const string TrackPeak = "replaygain-track-peak";
public const string AlbumGain = "replaygain-album-gain";
public const string AlbumPeak = "replaygain-album-peak";
}
}

View file

@ -1,9 +1,8 @@
[DllImport("gstreamer-0.10.dll")]
static extern void gst_debug_set_default_threshold(Gst.DebugLevel debug_level);
[DllImport ("gstreamer-0.10.dll") ]
static extern void gst_debug_set_default_threshold (Gst.DebugLevel debug_level);
public static void SetDefaultThreshold(Gst.DebugLevel debug_level)
{
gst_debug_set_default_threshold(debug_level);
}
public static void SetDefaultThreshold (Gst.DebugLevel debug_level) {
gst_debug_set_default_threshold (debug_level);
}

View file

@ -5,7 +5,7 @@
//
// This class implements functions to bind callbacks to GObject signals
// dynamically and to emit signals dynamically.
//
//
//
using GLib;
@ -14,304 +14,310 @@ using System.Runtime.InteropServices;
using System.Collections;
namespace Gst {
public delegate void DynamicSignalHandler(object o, SignalArgs args);
delegate void GClosureMarshal (IntPtr closure, ref GLib.Value retval, uint argc, IntPtr argsPtr,
IntPtr invocation_hint, IntPtr data);
public delegate void DynamicSignalHandler (object o, SignalArgs args);
public static class DynamicSignal {
private static readonly int gvalue_struct_size = Marshal.SizeOf(typeof(GLib.Value));
delegate void GClosureMarshal (IntPtr closure, ref GLib.Value retval, uint argc, IntPtr argsPtr,
IntPtr invocation_hint, IntPtr data);
class ObjectSignalKey {
object o;
string signal_name;
public static class DynamicSignal {
public ObjectSignalKey (object o, string name) {
this.o = o;
signal_name = name;
}
private static readonly int gvalue_struct_size = Marshal.SizeOf (typeof (GLib.Value));
public override bool Equals(object o) {
if(o is ObjectSignalKey) {
ObjectSignalKey k = (ObjectSignalKey) o;
return k.o.Equals(this.o) && signal_name.Equals(k.signal_name);
}
return base.Equals(o);
}
class ObjectSignalKey {
object o;
string signal_name;
public override int GetHashCode() {
return o.GetHashCode() ^ signal_name.GetHashCode();
}
}
public ObjectSignalKey (object o, string name) {
this.o = o;
signal_name = name;
}
class SignalInfo {
uint handlerId;
IntPtr closure;
Delegate registeredHandler;
public override bool Equals (object o) {
if (o is ObjectSignalKey) {
ObjectSignalKey k = (ObjectSignalKey) o;
return k.o.Equals (this.o) && signal_name.Equals (k.signal_name);
}
return base.Equals (o);
}
public IntPtr Closure {
get { return closure; }
set { closure = value; }
}
public override int GetHashCode() {
return o.GetHashCode() ^ signal_name.GetHashCode();
}
}
public uint HandlerId {
get { return handlerId; }
set { handlerId = value; }
}
class SignalInfo {
uint handlerId;
IntPtr closure;
Delegate registeredHandler;
public Delegate RegisteredHandler {
get { return registeredHandler; }
set { registeredHandler = value; }
}
public IntPtr Closure {
get {
return closure;
}
set {
closure = value;
}
}
public SignalInfo(uint handlerId, IntPtr closure, Delegate registeredHandler) {
this.handlerId = handlerId;
this.closure = closure;
this.registeredHandler = registeredHandler;
}
}
public uint HandlerId {
get {
return handlerId;
}
set {
handlerId = value;
}
}
static Hashtable SignalHandlers = new Hashtable();
public Delegate RegisteredHandler {
get {
return registeredHandler;
}
set {
registeredHandler = value;
}
}
static GClosureMarshal marshalHandler = new GClosureMarshal(OnMarshal);
public SignalInfo (uint handlerId, IntPtr closure, Delegate registeredHandler) {
this.handlerId = handlerId;
this.closure = closure;
this.registeredHandler = registeredHandler;
}
}
public static void Connect(GLib.Object o, string name, DynamicSignalHandler handler) {
Connect(o, name, false, handler);
}
static Hashtable SignalHandlers = new Hashtable();
static int g_closure_sizeof = gstsharp_g_closure_sizeof ();
static GClosureMarshal marshalHandler = new GClosureMarshal (OnMarshal);
public static void Connect(GLib.Object o, string name,
bool after, DynamicSignalHandler handler)
{
Delegate newHandler;
public static void Connect (GLib.Object o, string name, DynamicSignalHandler handler) {
Connect (o, name, false, handler);
}
ObjectSignalKey k = new ObjectSignalKey(o, name);
if(SignalHandlers[k] != null) {
SignalInfo si = (SignalInfo) SignalHandlers[k];
newHandler = Delegate.Combine(si.RegisteredHandler, handler);
si.RegisteredHandler = newHandler;
}
else {
IntPtr closure = g_closure_new_simple(g_closure_sizeof, IntPtr.Zero);
g_closure_set_meta_marshal(closure, (IntPtr) GCHandle.Alloc(k), marshalHandler);
uint signalId = g_signal_connect_closure(o.Handle, name, closure, after);
SignalHandlers.Add(k, new SignalInfo(signalId, closure, handler));
}
}
static int g_closure_sizeof = gstsharp_g_closure_sizeof ();
[DllImport("gstreamersharpglue-0.10")]
static extern int gstsharp_g_closure_sizeof ();
public static void Connect (GLib.Object o, string name,
bool after, DynamicSignalHandler handler) {
Delegate newHandler;
public static void Disconnect(GLib.Object o, string name, DynamicSignalHandler handler) {
ObjectSignalKey k = new ObjectSignalKey(o, name);
if(SignalHandlers[k] != null)
{
SignalInfo si = (SignalInfo) SignalHandlers[k];
Delegate newHandler = Delegate.Remove(si.RegisteredHandler, handler);
if(newHandler == null || handler == null) {
g_signal_handler_disconnect(o.Handle, si.HandlerId);
SignalHandlers.Remove(k);
} else {
si.RegisteredHandler = newHandler;
}
}
}
ObjectSignalKey k = new ObjectSignalKey (o, name);
[DllImport("libgobject-2.0-0.dll")]
static extern IntPtr g_value_peek_pointer(IntPtr ptr);
if (SignalHandlers[k] != null) {
SignalInfo si = (SignalInfo) SignalHandlers[k];
newHandler = Delegate.Combine (si.RegisteredHandler, handler);
si.RegisteredHandler = newHandler;
} else {
IntPtr closure = g_closure_new_simple (g_closure_sizeof, IntPtr.Zero);
g_closure_set_meta_marshal (closure, (IntPtr) GCHandle.Alloc (k), marshalHandler);
uint signalId = g_signal_connect_closure (o.Handle, name, closure, after);
SignalHandlers.Add (k, new SignalInfo (signalId, closure, handler));
}
}
static void OnMarshal(IntPtr closure, ref GLib.Value retval, uint argc, IntPtr argsPtr,
IntPtr ihint, IntPtr data)
{
object [] args = new object[argc - 1];
object o = ((GLib.Value) Marshal.PtrToStructure(argsPtr, typeof(GLib.Value))).Val;
[DllImport ("gstreamersharpglue-0.10") ]
static extern int gstsharp_g_closure_sizeof ();
for(int i=1; i < argc; i++) {
IntPtr struct_ptr = (IntPtr)((long) argsPtr + (i * gvalue_struct_size));
Type detectedType = GLib.GType.LookupType(Marshal.ReadIntPtr(struct_ptr));
if(detectedType.IsSubclassOf(typeof(Opaque))) {
args[i - 1] = (Opaque) Opaque.GetOpaque(g_value_peek_pointer(struct_ptr), detectedType, false);
}
else {
GLib.Value argument = (GLib.Value) Marshal.PtrToStructure(struct_ptr, typeof(GLib.Value));
args[i - 1] = argument.Val;
}
}
public static void Disconnect (GLib.Object o, string name, DynamicSignalHandler handler) {
ObjectSignalKey k = new ObjectSignalKey (o, name);
if (SignalHandlers[k] != null) {
SignalInfo si = (SignalInfo) SignalHandlers[k];
Delegate newHandler = Delegate.Remove (si.RegisteredHandler, handler);
if (newHandler == null || handler == null) {
g_signal_handler_disconnect (o.Handle, si.HandlerId);
SignalHandlers.Remove (k);
} else {
si.RegisteredHandler = newHandler;
}
}
}
if(data == IntPtr.Zero) {
Console.Error.WriteLine("No available data");
}
[DllImport ("libgobject-2.0-0.dll") ]
static extern IntPtr g_value_peek_pointer (IntPtr ptr);
ObjectSignalKey k = (ObjectSignalKey)((GCHandle) data).Target;
if(k != null) {
SignalArgs arg = new SignalArgs();
arg.Args = args;
SignalInfo si = (SignalInfo) SignalHandlers[k];
DynamicSignalHandler handler = (DynamicSignalHandler) si.RegisteredHandler;
handler(o, arg);
if(arg.RetVal != null) {
retval.Val = arg.RetVal;
}
}
}
static void OnMarshal (IntPtr closure, ref GLib.Value retval, uint argc, IntPtr argsPtr,
IntPtr ihint, IntPtr data) {
object [] args = new object[argc - 1];
object o = ( (GLib.Value) Marshal.PtrToStructure (argsPtr, typeof (GLib.Value))).Val;
[DllImport("gobject-2.0.dll")]
static extern IntPtr g_closure_new_simple(int size, IntPtr data);
for (int i = 1; i < argc; i++) {
IntPtr struct_ptr = (IntPtr) ( (long) argsPtr + (i * gvalue_struct_size));
Type detectedType = GLib.GType.LookupType (Marshal.ReadIntPtr (struct_ptr));
if (detectedType.IsSubclassOf (typeof (Opaque))) {
args[i - 1] = (Opaque) Opaque.GetOpaque (g_value_peek_pointer (struct_ptr), detectedType, false);
} else {
GLib.Value argument = (GLib.Value) Marshal.PtrToStructure (struct_ptr, typeof (GLib.Value));
args[i - 1] = argument.Val;
}
}
[DllImport("gobject-2.0.dll")]
static extern uint g_signal_connect_closure(IntPtr instance,
string name, IntPtr closure, bool after);
if (data == IntPtr.Zero) {
Console.Error.WriteLine ("No available data");
}
[DllImport("gobject-2.0.dll")]
static extern void g_closure_set_meta_marshal(IntPtr closure, IntPtr data, GClosureMarshal marshal);
ObjectSignalKey k = (ObjectSignalKey) ( (GCHandle) data).Target;
if (k != null) {
SignalArgs arg = new SignalArgs();
arg.Args = args;
SignalInfo si = (SignalInfo) SignalHandlers[k];
DynamicSignalHandler handler = (DynamicSignalHandler) si.RegisteredHandler;
handler (o, arg);
if (arg.RetVal != null) {
retval.Val = arg.RetVal;
}
}
}
class GTypeSignalKey {
GType type;
string signal_name;
public GTypeSignalKey (GType type, string name) {
this.type = type;
signal_name = name;
}
[DllImport ("gobject-2.0.dll") ]
static extern IntPtr g_closure_new_simple (int size, IntPtr data);
public override bool Equals(object o) {
if(o is GTypeSignalKey) {
GTypeSignalKey k = (GTypeSignalKey) o;
return k.type.Equals(this.type) && signal_name.Equals(k.signal_name);
}
return base.Equals(o);
}
[DllImport ("gobject-2.0.dll") ]
static extern uint g_signal_connect_closure (IntPtr instance,
string name, IntPtr closure, bool after);
public override int GetHashCode() {
return type.GetHashCode() ^ signal_name.GetHashCode();
}
}
[DllImport ("gobject-2.0.dll") ]
static extern void g_closure_set_meta_marshal (IntPtr closure, IntPtr data, GClosureMarshal marshal);
struct SignalQuery {
public uint signal_id;
public string signal_name;
public GType itype;
public uint signal_flags;
public GType return_type;
public uint n_params;
public Type[] param_types;
}
class GTypeSignalKey {
GType type;
string signal_name;
static Hashtable SignalEmitInfo = new Hashtable ();
public GTypeSignalKey (GType type, string name) {
this.type = type;
signal_name = name;
}
public static object Emit (GLib.Object o, string name, params object[] parameters)
{
SignalQuery query;
IntPtr type = gstsharp_g_type_from_instance (o.Handle);
GType gtype = new GType (type);
string signal_name, signal_detail;
uint signal_detail_quark = 0;
int colon;
colon = name.LastIndexOf ("::");
if (colon == -1) {
signal_name = name;
signal_detail = String.Empty;
} else {
signal_name = name.Substring (0, colon);
signal_detail = name.Substring (colon + 2);
}
GTypeSignalKey key = new GTypeSignalKey (gtype, signal_name);
if (SignalEmitInfo[key] == null) {
uint signal_id = g_signal_lookup (signal_name, type);
if (signal_id == 0)
throw new NotSupportedException (String.Format ("{0} has no signal of name {1}", o, name));
GSignalQuery q = new GSignalQuery ();
g_signal_query (signal_id, ref q);
if (q.signal_id == 0)
throw new NotSupportedException (String.Format ("{0} couldn't be queried for signal with name {1}", o, name));
query = new SignalQuery ();
query.signal_id = signal_id;
query.signal_name = Marshaller.Utf8PtrToString (q.signal_name);
query.itype = new GType (q.itype);
query.signal_flags = q.signal_flags;
query.return_type = new GType (q.return_type);
query.n_params = q.n_params;
query.param_types = new Type[q.n_params];
for (int i = 0; i < query.n_params; i++) {
IntPtr t = Marshal.ReadIntPtr (q.param_types, i);
GType g = new GType (t);
query.param_types[i] = (Type) g;
}
SignalEmitInfo.Add (key, query);
}
query = (SignalQuery) SignalEmitInfo[key];
GLib.Value[] signal_parameters = new GLib.Value[query.n_params + 1];
signal_parameters[0] = new GLib.Value (o);
if (parameters.Length != query.n_params)
throw new ApplicationException (String.Format ("Invalid number of parameters: expected {0}, got {1}", query.n_params, parameters.Length));
for (int i = 0; i < query.n_params; i++) {
Type expected_type = (Type) query.param_types[i];
Type given_type = parameters[i].GetType ();
if (expected_type != given_type && ! given_type.IsSubclassOf (given_type))
throw new ApplicationException (String.Format ("Invalid parameter type: expected {0}, got {1}", expected_type, given_type));
signal_parameters[i + 1] = new GLib.Value (parameters[i]);
}
GLib.Value return_value = new GLib.Value ();
if (query.return_type != GType.Invalid && query.return_type != GType.None)
return_value.Init (query.return_type);
if (signal_detail != String.Empty)
signal_detail_quark = g_quark_from_string (signal_detail);
g_signal_emitv (signal_parameters, query.signal_id, signal_detail_quark, ref return_value);
public override bool Equals (object o) {
if (o is GTypeSignalKey) {
GTypeSignalKey k = (GTypeSignalKey) o;
return k.type.Equals (this.type) && signal_name.Equals (k.signal_name);
}
return base.Equals (o);
}
return (query.return_type != GType.Invalid && query.return_type != GType.None) ? return_value.Val : null;
}
public override int GetHashCode() {
return type.GetHashCode() ^ signal_name.GetHashCode();
}
}
[DllImport ("gstreamersharpglue-0.10")]
static extern IntPtr gstsharp_g_type_from_instance (IntPtr o);
struct SignalQuery {
public uint signal_id;
public string signal_name;
public GType itype;
public uint signal_flags;
public GType return_type;
public uint n_params;
public Type[] param_types;
}
[DllImport("gobject-2.0.dll")]
static extern int g_signal_handler_disconnect(IntPtr o, uint handler_id);
static Hashtable SignalEmitInfo = new Hashtable ();
[DllImport("gobject-2.0.dll")]
static extern uint g_signal_lookup (string name, IntPtr itype);
[DllImport("glib-2.0.dll")]
static extern uint g_quark_from_string (string str);
public static object Emit (GLib.Object o, string name, params object[] parameters) {
SignalQuery query;
IntPtr type = gstsharp_g_type_from_instance (o.Handle);
GType gtype = new GType (type);
string signal_name, signal_detail;
uint signal_detail_quark = 0;
int colon;
[DllImport("gobject-2.0.dll")]
static extern void g_signal_emitv (GLib.Value[] parameters, uint signal_id, uint detail, ref GLib.Value return_value);
colon = name.LastIndexOf ("::");
[StructLayout(LayoutKind.Sequential)]
struct GSignalQuery {
public uint signal_id;
public IntPtr signal_name;
public IntPtr itype;
public uint signal_flags;
public IntPtr return_type;
public uint n_params;
public IntPtr param_types;
}
if (colon == -1) {
signal_name = name;
signal_detail = String.Empty;
} else {
signal_name = name.Substring (0, colon);
signal_detail = name.Substring (colon + 2);
}
[DllImport("gobject-2.0.dll")]
static extern void g_signal_query (uint signal_id, ref GSignalQuery query);
}
GTypeSignalKey key = new GTypeSignalKey (gtype, signal_name);
if (SignalEmitInfo[key] == null) {
uint signal_id = g_signal_lookup (signal_name, type);
if (signal_id == 0)
throw new NotSupportedException (String.Format ("{0} has no signal of name {1}", o, name));
GSignalQuery q = new GSignalQuery ();
g_signal_query (signal_id, ref q);
if (q.signal_id == 0)
throw new NotSupportedException (String.Format ("{0} couldn't be queried for signal with name {1}", o, name));
query = new SignalQuery ();
query.signal_id = signal_id;
query.signal_name = Marshaller.Utf8PtrToString (q.signal_name);
query.itype = new GType (q.itype);
query.signal_flags = q.signal_flags;
query.return_type = new GType (q.return_type);
query.n_params = q.n_params;
query.param_types = new Type[q.n_params];
for (int i = 0; i < query.n_params; i++) {
IntPtr t = Marshal.ReadIntPtr (q.param_types, i);
GType g = new GType (t);
query.param_types[i] = (Type) g;
}
SignalEmitInfo.Add (key, query);
}
query = (SignalQuery) SignalEmitInfo[key];
GLib.Value[] signal_parameters = new GLib.Value[query.n_params + 1];
signal_parameters[0] = new GLib.Value (o);
if (parameters.Length != query.n_params)
throw new ApplicationException (String.Format ("Invalid number of parameters: expected {0}, got {1}", query.n_params, parameters.Length));
for (int i = 0; i < query.n_params; i++) {
Type expected_type = (Type) query.param_types[i];
Type given_type = parameters[i].GetType ();
if (expected_type != given_type && ! given_type.IsSubclassOf (given_type))
throw new ApplicationException (String.Format ("Invalid parameter type: expected {0}, got {1}", expected_type, given_type));
signal_parameters[i + 1] = new GLib.Value (parameters[i]);
}
GLib.Value return_value = new GLib.Value ();
if (query.return_type != GType.Invalid && query.return_type != GType.None)
return_value.Init (query.return_type);
if (signal_detail != String.Empty)
signal_detail_quark = g_quark_from_string (signal_detail);
g_signal_emitv (signal_parameters, query.signal_id, signal_detail_quark, ref return_value);
return (query.return_type != GType.Invalid && query.return_type != GType.None) ? return_value.Val : null;
}
[DllImport ("gstreamersharpglue-0.10") ]
static extern IntPtr gstsharp_g_type_from_instance (IntPtr o);
[DllImport ("gobject-2.0.dll") ]
static extern int g_signal_handler_disconnect (IntPtr o, uint handler_id);
[DllImport ("gobject-2.0.dll") ]
static extern uint g_signal_lookup (string name, IntPtr itype);
[DllImport ("glib-2.0.dll") ]
static extern uint g_quark_from_string (string str);
[DllImport ("gobject-2.0.dll") ]
static extern void g_signal_emitv (GLib.Value[] parameters, uint signal_id, uint detail, ref GLib.Value return_value);
[StructLayout (LayoutKind.Sequential) ]
struct GSignalQuery {
public uint signal_id;
public IntPtr signal_name;
public IntPtr itype;
public uint signal_flags;
public IntPtr return_type;
public uint n_params;
public IntPtr param_types;
}
[DllImport ("gobject-2.0.dll") ]
static extern void g_signal_query (uint signal_id, ref GSignalQuery query);
}
}

View file

@ -1,99 +1,87 @@
public object this[string property] {
get { return GetProperty(property).Val; }
set { SetProperty(property, value); }
}
public new GLib.Value GetProperty(string propertyName)
{
return base.GetProperty(propertyName);
}
public object this[string property] {
get {
return GetProperty (property).Val;
}
set {
SetProperty (property, value);
}
}
public new void SetProperty(string propertyName, GLib.Value value)
{
base.SetProperty(propertyName, value);
}
public new GLib.Value GetProperty (string propertyName) {
return base.GetProperty (propertyName);
}
public void SetProperty(string propertyName, object value)
{
base.SetProperty(propertyName, new GLib.Value(value));
}
public new void SetProperty (string propertyName, GLib.Value value) {
base.SetProperty (propertyName, value);
}
public void SetProperty(string propertyName, string value)
{
base.SetProperty(propertyName, new GLib.Value(value));
}
public void SetProperty(string propertyName, int value)
{
base.SetProperty(propertyName, new GLib.Value(value));
}
public void SetProperty(string propertyName, double value)
{
base.SetProperty(propertyName, new GLib.Value(value));
}
public void SetProperty (string propertyName, object value) {
base.SetProperty (propertyName, new GLib.Value (value));
}
public void SetProperty(string propertyName, bool value)
{
base.SetProperty(propertyName, new GLib.Value(value));
}
public void SetProperty (string propertyName, string value) {
base.SetProperty (propertyName, new GLib.Value (value));
}
public void SetProperty (string propertyName, int value) {
base.SetProperty (propertyName, new GLib.Value (value));
}
public void SetProperty (string propertyName, double value) {
base.SetProperty (propertyName, new GLib.Value (value));
}
public void SetProperty (string propertyName, bool value) {
base.SetProperty (propertyName, new GLib.Value (value));
}
public bool QueryPosition(Gst.Format format, out long current)
{
return gst_element_query_position(Handle, ref format, out current);
}
public bool QueryPosition (Gst.Format format, out long current) {
return gst_element_query_position (Handle, ref format, out current);
}
public bool QueryDuration(Gst.Format format, out long duration)
{
return gst_element_query_duration(Handle, ref format, out duration);
}
public bool QueryDuration (Gst.Format format, out long duration) {
return gst_element_query_duration (Handle, ref format, out duration);
}
public void Connect(string signal, DynamicSignalHandler handler)
{
DynamicSignal.Connect(this, signal, handler);
}
public void Connect (string signal, DynamicSignalHandler handler) {
DynamicSignal.Connect (this, signal, handler);
}
public void Disconnect(string signal, DynamicSignalHandler handler)
{
DynamicSignal.Disconnect(this, signal, handler);
}
public void Disconnect (string signal, DynamicSignalHandler handler) {
DynamicSignal.Disconnect (this, signal, handler);
}
public bool AddPad(Pad p)
{
bool ret = gst_element_add_pad(this.Handle, p == null ? IntPtr.Zero : p.Handle);
if(ret)
Gst.Object.Ref(p.Handle);
return ret;
}
public static bool LinkMany(params Element [] elements)
{
for(int i=0; i < elements.Length - 1; i++)
{
if(!elements[i].Link(elements[i+1]))
return false;
}
return true;
}
public bool AddPad (Pad p) {
bool ret = gst_element_add_pad (this.Handle, p == null ? IntPtr.Zero : p.Handle);
if (ret)
Gst.Object.Ref (p.Handle);
return ret;
}
public static void UnlinkMany(params Element [] elements)
{
for(int i=0; i < elements.Length - 1; i++)
{
elements[i].Unlink(elements[i+1]);
}
}
public static bool LinkMany (params Element [] elements) {
for (int i = 0; i < elements.Length - 1; i++) {
if (!elements[i].Link (elements[i+1]))
return false;
}
return true;
}
public static void UnlinkMany (params Element [] elements) {
for (int i = 0; i < elements.Length - 1; i++) {
elements[i].Unlink (elements[i+1]);
}
}
[DllImport("gstreamer-0.10.dll")]
private static extern bool gst_element_query_position(IntPtr raw, ref Format format, out long cur);
[DllImport ("gstreamer-0.10.dll") ]
private static extern bool gst_element_query_position (IntPtr raw, ref Format format, out long cur);
[DllImport("gstreamer-0.10.dll")]
private static extern bool gst_element_query_duration(IntPtr raw, ref Format format, out long duration);
[DllImport ("gstreamer-0.10.dll") ]
private static extern bool gst_element_query_duration (IntPtr raw, ref Format format, out long duration);
[DllImport("gstreamer-0.10.dll")]
static extern bool gst_element_add_pad(IntPtr raw, IntPtr pad);
[DllImport ("gstreamer-0.10.dll") ]
static extern bool gst_element_add_pad (IntPtr raw, IntPtr pad);

View file

@ -8,30 +8,27 @@ using System;
using System.Runtime.InteropServices;
namespace Gst {
internal static class GError
{
public static string GetMessage (IntPtr error)
{
if (error == IntPtr.Zero)
return String.Empty;
internal static class GError {
public static string GetMessage (IntPtr error) {
if (error == IntPtr.Zero)
return String.Empty;
IntPtr message = gstsharp_g_error_get_message (error);
if (message == IntPtr.Zero)
return String.Empty;
return GLib.Marshaller.PtrToStringGFree (message);
}
IntPtr message = gstsharp_g_error_get_message (error);
if (message == IntPtr.Zero)
return String.Empty;
public static void Free (IntPtr error)
{
if (error != IntPtr.Zero)
g_error_free (error);
}
[DllImport("gstreamersharpglue-0.10")]
static extern IntPtr gstsharp_g_error_get_message (IntPtr error);
[DllImport("glib-2.0.dll")]
static extern void g_error_free (IntPtr error);
return GLib.Marshaller.PtrToStringGFree (message);
}
public static void Free (IntPtr error) {
if (error != IntPtr.Zero)
g_error_free (error);
}
[DllImport ("gstreamersharpglue-0.10") ]
static extern IntPtr gstsharp_g_error_get_message (IntPtr error);
[DllImport ("glib-2.0.dll") ]
static extern void g_error_free (IntPtr error);
}
}

View file

@ -1,18 +1,16 @@
[DllImport("gstreamersharpglue-0.10")]
private extern static IntPtr gstsharp_message_parse_error(IntPtr raw);
public void ParseError(out string error)
{
IntPtr err = gstsharp_message_parse_error(Handle);
error = GLib.Marshaller.PtrToStringGFree(err);
}
[DllImport ("gstreamersharpglue-0.10") ]
private extern static IntPtr gstsharp_message_parse_error (IntPtr raw);
[DllImport("gstreamersharpglue-0.10")]
private extern static IntPtr gstsharp_message_error_new();
public void ParseError (out string error) {
IntPtr err = gstsharp_message_parse_error (Handle);
error = GLib.Marshaller.PtrToStringGFree (err);
}
public Message(Gst.Object src, string debug)
{
IntPtr error = gstsharp_message_error_new();
Raw = gst_message_new_error(src == null ? IntPtr.Zero : src.Handle, error, GLib.Marshaller.StringToPtrGStrdup(debug));
}
[DllImport ("gstreamersharpglue-0.10") ]
private extern static IntPtr gstsharp_message_error_new();
public Message (Gst.Object src, string debug) {
IntPtr error = gstsharp_message_error_new();
Raw = gst_message_new_error (src == null ? IntPtr.Zero : src.Handle, error, GLib.Marshaller.StringToPtrGStrdup (debug));
}

View file

@ -1,3 +1,3 @@
protected MiniObject () : base (IntPtr.Zero)
{
}
protected MiniObject () : base (IntPtr.Zero)
{
}

View file

@ -1,6 +1,8 @@
public int Refcount {
get { return this.RefCount; }
}
public int Refcount {
get {
return this.RefCount;
}
}

View file

@ -1,113 +1,101 @@
[DllImport("gstreamer-0.10.dll")]
private static extern bool gst_pad_query_position(IntPtr raw, ref Format format, out long cur);
public bool QueryPosition(Gst.Format format, out long current)
{
return gst_pad_query_position(Handle, ref format, out current);
}
[DllImport ("gstreamer-0.10.dll") ]
private static extern bool gst_pad_query_position (IntPtr raw, ref Format format, out long cur);
[DllImport("gstreamer-0.10.dll")]
private static extern bool gst_pad_query_duration(IntPtr raw, ref Format format, out long duration);
public bool QueryPosition (Gst.Format format, out long current) {
return gst_pad_query_position (Handle, ref format, out current);
}
public bool QueryDuration(Gst.Format format, out long duration)
{
return gst_pad_query_duration(Handle, ref format, out duration);
}
[DllImport ("gstreamer-0.10.dll") ]
private static extern bool gst_pad_query_duration (IntPtr raw, ref Format format, out long duration);
public bool QueryDuration (Gst.Format format, out long duration) {
return gst_pad_query_duration (Handle, ref format, out duration);
}
public delegate bool BufferProbeDelegate(Pad pad, Gst.Buffer buffer);
internal delegate bool BufferProbeNativeDelegate(IntPtr pad, IntPtr buf, IntPtr data);
public delegate bool BufferProbeDelegate (Pad pad, Gst.Buffer buffer);
internal delegate bool BufferProbeNativeDelegate (IntPtr pad, IntPtr buf, IntPtr data);
internal class BufferProbeWrapper {
internal BufferProbeNativeDelegate NativeFunc;
BufferProbeDelegate managedFunc;
internal class BufferProbeWrapper {
internal BufferProbeNativeDelegate NativeFunc;
BufferProbeDelegate managedFunc;
public BufferProbeWrapper(BufferProbeDelegate func)
{
managedFunc = func;
if(func != null)
NativeFunc = new BufferProbeNativeDelegate(BufferProbeMarshaller);
}
public BufferProbeWrapper (BufferProbeDelegate func) {
managedFunc = func;
if (func != null)
NativeFunc = new BufferProbeNativeDelegate (BufferProbeMarshaller);
}
public bool BufferProbeMarshaller(IntPtr raw_pad, IntPtr buf, IntPtr data)
{
Pad pad = GLib.Object.GetObject(raw_pad) as Pad;
Gst.Buffer buffer = GLib.Opaque.GetOpaque(buf, typeof(Gst.Buffer), false) as Gst.Buffer;
return (bool) (managedFunc (pad, buffer));
}
}
public bool BufferProbeMarshaller (IntPtr raw_pad, IntPtr buf, IntPtr data) {
Pad pad = GLib.Object.GetObject (raw_pad) as Pad;
Gst.Buffer buffer = GLib.Opaque.GetOpaque (buf, typeof (Gst.Buffer), false) as Gst.Buffer;
return (bool) (managedFunc (pad, buffer));
}
}
[DllImport("gstreamer-0.10.dll")]
private static extern ulong gst_pad_add_buffer_probe(IntPtr pad, BufferProbeNativeDelegate func, IntPtr data);
[DllImport ("gstreamer-0.10.dll") ]
private static extern ulong gst_pad_add_buffer_probe (IntPtr pad, BufferProbeNativeDelegate func, IntPtr data);
public ulong AddBufferProbe(BufferProbeDelegate func)
{
BufferProbeWrapper func_wrapper;
if(PersistentData["AddBufferProbe"] != null) {
func_wrapper = PersistentData["AddBufferProbe"] as BufferProbeWrapper;
}
else
{
func_wrapper = new BufferProbeWrapper(func);
PersistentData["AddBufferProbe"] = func_wrapper;
}
public ulong AddBufferProbe (BufferProbeDelegate func) {
BufferProbeWrapper func_wrapper;
if (PersistentData["AddBufferProbe"] != null) {
func_wrapper = PersistentData["AddBufferProbe"] as BufferProbeWrapper;
} else {
func_wrapper = new BufferProbeWrapper (func);
PersistentData["AddBufferProbe"] = func_wrapper;
}
return gst_pad_add_buffer_probe(this.Handle, func_wrapper.NativeFunc, IntPtr.Zero);
}
return gst_pad_add_buffer_probe (this.Handle, func_wrapper.NativeFunc, IntPtr.Zero);
}
[DllImport("gstreamer-0.10.dll")]
private static extern void gst_pad_remove_buffer_probe(IntPtr pad, uint handler_id);
[DllImport ("gstreamer-0.10.dll") ]
private static extern void gst_pad_remove_buffer_probe (IntPtr pad, uint handler_id);
public void RemoveBufferProbe(uint handler_id)
{
gst_pad_remove_buffer_probe(this.Handle, handler_id);
PersistentData["AddBufferProbe"] = null;
}
public void RemoveBufferProbe (uint handler_id) {
gst_pad_remove_buffer_probe (this.Handle, handler_id);
PersistentData["AddBufferProbe"] = null;
}
public delegate bool DataProbeDelegate (Pad pad, GLib.Opaque miniobject);
internal delegate bool DataProbeNativeDelegate(IntPtr pad, IntPtr miniobj, IntPtr data);
public delegate bool DataProbeDelegate (Pad pad, GLib.Opaque miniobject);
internal delegate bool DataProbeNativeDelegate (IntPtr pad, IntPtr miniobj, IntPtr data);
internal class DataProbeWrapper {
internal DataProbeNativeDelegate NativeFunc;
DataProbeDelegate ManagedFunc;
internal class DataProbeWrapper {
internal DataProbeNativeDelegate NativeFunc;
DataProbeDelegate ManagedFunc;
public DataProbeWrapper(DataProbeDelegate func)
{
ManagedFunc = func;
if(func != null)
NativeFunc = new DataProbeNativeDelegate(DataProbeMarshaller);
}
public DataProbeWrapper (DataProbeDelegate func) {
ManagedFunc = func;
if (func != null)
NativeFunc = new DataProbeNativeDelegate (DataProbeMarshaller);
}
public bool DataProbeMarshaller (IntPtr raw_pad, IntPtr miniobj, IntPtr data)
{
Pad pad = GLib.Object.GetObject(raw_pad) as Pad;
GLib.Opaque opaque = GLib.Opaque.GetOpaque(miniobj, typeof(GLib.Opaque), true);
return ManagedFunc(pad, opaque);
}
}
public bool DataProbeMarshaller (IntPtr raw_pad, IntPtr miniobj, IntPtr data) {
Pad pad = GLib.Object.GetObject (raw_pad) as Pad;
GLib.Opaque opaque = GLib.Opaque.GetOpaque (miniobj, typeof (GLib.Opaque), true);
return ManagedFunc (pad, opaque);
}
}
[DllImport("gstreamer-0.10.dll")]
static extern uint gst_pad_add_data_probe(IntPtr pad, DataProbeNativeDelegate func, IntPtr data);
[DllImport ("gstreamer-0.10.dll") ]
static extern uint gst_pad_add_data_probe (IntPtr pad, DataProbeNativeDelegate func, IntPtr data);
public uint AddDataProbe(DataProbeDelegate func)
{
DataProbeWrapper func_wrapper;
if(PersistentData["AddDataProbe"] != null) {
func_wrapper = PersistentData["AddDataProbe"] as DataProbeWrapper;
} else {
func_wrapper = new DataProbeWrapper(func);
PersistentData["AddDataProbe"] = func_wrapper;
}
public uint AddDataProbe (DataProbeDelegate func) {
DataProbeWrapper func_wrapper;
if (PersistentData["AddDataProbe"] != null) {
func_wrapper = PersistentData["AddDataProbe"] as DataProbeWrapper;
} else {
func_wrapper = new DataProbeWrapper (func);
PersistentData["AddDataProbe"] = func_wrapper;
}
return gst_pad_add_data_probe(this.Handle, func_wrapper.NativeFunc, IntPtr.Zero);
}
return gst_pad_add_data_probe (this.Handle, func_wrapper.NativeFunc, IntPtr.Zero);
}
[DllImport("gstreamer-0.10.dll")]
static extern void gst_pad_remove_data_probe(IntPtr pad, uint handler_id);
[DllImport ("gstreamer-0.10.dll") ]
static extern void gst_pad_remove_data_probe (IntPtr pad, uint handler_id);
public void RemoveDataProbe(uint handler_id)
{
gst_pad_remove_data_probe(this.Handle, handler_id);
PersistentData["AddDataProbe"] = null;
}
public void RemoveDataProbe (uint handler_id) {
gst_pad_remove_data_probe (this.Handle, handler_id);
PersistentData["AddDataProbe"] = null;
}

View file

@ -10,52 +10,57 @@
using System;
using System.Runtime.InteropServices;
namespace Gst
{
public static class Version
{
private static uint major;
private static uint minor;
private static uint micro;
private static uint nano;
private static string version_string;
static Version()
{
gst_version(out major, out minor, out micro, out nano);
}
public static string Description {
get {
if (version_string == null) {
IntPtr version_string_ptr = gst_version_string();
version_string = GLib.Marshaller.Utf8PtrToString(version_string_ptr);
}
return version_string;
}
}
public static uint Major {
get { return major; }
}
public static uint Minor {
get { return minor; }
}
public static uint Micro {
get { return micro; }
}
public static uint Nano {
get { return nano; }
}
[DllImport("gstreamer-0.10")]
private static extern void gst_version(out uint major, out uint minor, out uint micro, out uint nano);
[DllImport("gstreamer-0.10")]
private static extern IntPtr gst_version_string();
namespace Gst {
public static class Version {
private static uint major;
private static uint minor;
private static uint micro;
private static uint nano;
private static string version_string;
static Version() {
gst_version (out major, out minor, out micro, out nano);
}
public static string Description {
get {
if (version_string == null) {
IntPtr version_string_ptr = gst_version_string();
version_string = GLib.Marshaller.Utf8PtrToString (version_string_ptr);
}
return version_string;
}
}
public static uint Major {
get {
return major;
}
}
public static uint Minor {
get {
return minor;
}
}
public static uint Micro {
get {
return micro;
}
}
public static uint Nano {
get {
return nano;
}
}
[DllImport ("gstreamer-0.10") ]
private static extern void gst_version (out uint major, out uint minor, out uint micro, out uint nano);
[DllImport ("gstreamer-0.10") ]
private static extern IntPtr gst_version_string();
}
}

View file

@ -2,9 +2,10 @@
#include <gst/gstpipeline.h>
#include <gst/gstsegment.h>
guint
gstsharp_gst_bin_get_children_offset (void);
guint gstsharp_gst_bin_get_children_offset (void);
guint gstsharp_gst_bin_get_children_offset (void) {
return (guint)G_STRUCT_OFFSET (GstBin, children);
guint
gstsharp_gst_bin_get_children_offset (void)
{
return (guint) G_STRUCT_OFFSET (GstBin, children);
}

View file

@ -1,7 +1,7 @@
#include <gst/gst.h>
guint
gstsharp_gst_buffer_refcount(GstBuffer * buf)
gstsharp_gst_buffer_refcount (GstBuffer * buf)
{
return GST_MINI_OBJECT_REFCOUNT_VALUE(buf);
return GST_MINI_OBJECT_REFCOUNT_VALUE (buf);
}

View file

@ -1,33 +1,38 @@
#include <glib.h>
#include <gst/gstclock.h>
guint64 gstsharp_gst_clock_get_gst_second()
guint64
gstsharp_gst_clock_get_gst_second ()
{
return GST_SECOND;
return GST_SECOND;
}
guint64 gstsharp_gst_clock_get_gst_msecond()
guint64
gstsharp_gst_clock_get_gst_msecond ()
{
return GST_MSECOND;
return GST_MSECOND;
}
guint64 gstsharp_gst_clock_get_gst_usecond()
guint64
gstsharp_gst_clock_get_gst_usecond ()
{
return GST_USECOND;
return GST_USECOND;
}
guint64 gstsharp_gst_clock_get_gst_nsecond()
guint64
gstsharp_gst_clock_get_gst_nsecond ()
{
return GST_NSECOND;
return GST_NSECOND;
}
guint64 gstsharp_gst_clock_get_time_none()
guint64
gstsharp_gst_clock_get_time_none ()
{
return GST_CLOCK_TIME_NONE;
return GST_CLOCK_TIME_NONE;
}
gboolean gstsharp_gst_clock_time_is_valid(GstClockTime time)
gboolean
gstsharp_gst_clock_time_is_valid (GstClockTime time)
{
return GST_CLOCK_TIME_IS_VALID(time);
return GST_CLOCK_TIME_IS_VALID (time);
}

View file

@ -7,7 +7,7 @@ gstsharp_g_closure_sizeof (void)
}
GType
gstsharp_g_type_from_instance (GTypeInstance *instance)
gstsharp_g_type_from_instance (GTypeInstance * instance)
{
return G_TYPE_FROM_INSTANCE (instance);
}

View file

@ -8,4 +8,3 @@ gstsharp_g_error_get_message (GError * error)
return NULL;
}

View file

@ -3,22 +3,22 @@
#include <glib/gquark.h>
gchar *
gstsharp_message_parse_error(GstMessage *message)
gstsharp_message_parse_error (GstMessage * message)
{
GError *gerror;
gchar *error;
GError *gerror;
gchar *error;
gst_message_parse_error(message, &gerror, NULL);
gst_message_parse_error (message, &gerror, NULL);
error = g_strdup(gerror->message);
g_error_free(gerror);
return error;
error = g_strdup (gerror->message);
g_error_free (gerror);
return error;
}
GError *
gstsharp_message_error_new()
gstsharp_message_error_new ()
{
GQuark domain = g_quark_from_string ("test");
return g_error_new (domain, 10, "test error");
GQuark domain = g_quark_from_string ("test");
return g_error_new (domain, 10, "test error");
}

View file

@ -5,21 +5,21 @@
#include <gst/gstminiobject.h>
GType
gstsharp_get_type_id(GObject *obj)
{
return G_TYPE_FROM_INSTANCE(obj);
gstsharp_get_type_id (GObject * obj)
{
return G_TYPE_FROM_INSTANCE (obj);
}
GType
gstsharp_register_type(gchar *name, GType parent)
{
GTypeQuery query;
GTypeInfo info = { 0, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL };
gstsharp_register_type (gchar * name, GType parent)
{
GTypeQuery query;
GTypeInfo info = { 0, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL };
g_type_query (parent, &query);
g_type_query (parent, &query);
info.class_size = query.class_size;
info.instance_size = query.instance_size;
info.class_size = query.class_size;
info.instance_size = query.instance_size;
return g_type_register_static(parent, name, &info, 0);
return g_type_register_static (parent, name, &info, 0);
}

View file

@ -21,196 +21,195 @@
namespace GtkSharp.Parsing {
using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
public class Fixup {
public class Fixup {
public static int Main (string[] args)
{
if (args.Length < 2) {
Console.WriteLine ("Usage: gst-gapi-fixup --metadata=<filename> --api=<filename> --symbols=<filename>");
return 0;
}
public static int Main (string[] args) {
if (args.Length < 2) {
Console.WriteLine ("Usage: gst-gapi-fixup --metadata=<filename> --api=<filename> --symbols=<filename>");
return 0;
}
string api_filename = "";
XmlDocument api_doc = new XmlDocument ();
XmlDocument meta_doc = new XmlDocument ();
XmlDocument symbol_doc = new XmlDocument ();
string api_filename = "";
XmlDocument api_doc = new XmlDocument ();
XmlDocument meta_doc = new XmlDocument ();
XmlDocument symbol_doc = new XmlDocument ();
foreach (string arg in args) {
foreach (string arg in args) {
if (arg.StartsWith("--metadata=")) {
if (arg.StartsWith ("--metadata=")) {
string meta_filename = arg.Substring (11);
string meta_filename = arg.Substring (11);
try {
Stream stream = File.OpenRead (meta_filename);
meta_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine ("Invalid meta file.");
Console.WriteLine (e);
return 1;
}
try {
Stream stream = File.OpenRead (meta_filename);
meta_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine ("Invalid meta file.");
Console.WriteLine (e);
return 1;
}
} else if (arg.StartsWith ("--api=")) {
} else if (arg.StartsWith ("--api=")) {
api_filename = arg.Substring (6);
api_filename = arg.Substring (6);
try {
Stream stream = File.OpenRead (api_filename);
api_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine ("Invalid api file.");
Console.WriteLine (e);
return 1;
}
try {
Stream stream = File.OpenRead (api_filename);
api_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine ("Invalid api file.");
Console.WriteLine (e);
return 1;
}
} else if (arg.StartsWith ("--symbols=")) {
} else if (arg.StartsWith ("--symbols=")) {
string symbol_filename = arg.Substring (10);
string symbol_filename = arg.Substring (10);
try {
Stream stream = File.OpenRead (symbol_filename);
symbol_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine ("Invalid api file.");
Console.WriteLine (e);
return 1;
}
try {
Stream stream = File.OpenRead (symbol_filename);
symbol_doc.Load (stream);
stream.Close ();
} catch (XmlException e) {
Console.WriteLine ("Invalid api file.");
Console.WriteLine (e);
return 1;
}
} else {
Console.WriteLine ("Usage: gapi-fixup --metadata=<filename> --api=<filename>");
return 1;
}
}
} else {
Console.WriteLine ("Usage: gapi-fixup --metadata=<filename> --api=<filename>");
return 1;
}
}
XPathNavigator meta_nav = meta_doc.CreateNavigator ();
XPathNavigator api_nav = api_doc.CreateNavigator ();
XPathNavigator meta_nav = meta_doc.CreateNavigator ();
XPathNavigator api_nav = api_doc.CreateNavigator ();
XPathNodeIterator change_node_type_iter = meta_nav.Select ("/metadata/change-node-type");
while (change_node_type_iter.MoveNext ()) {
string path = change_node_type_iter.Current.GetAttribute ("path", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement node = ((IHasXmlNode)api_iter.Current).GetNode () as XmlElement;
XmlElement parent = node.ParentNode as XmlElement;
XmlElement new_node = api_doc.CreateElement (change_node_type_iter.Current.Value);
XPathNodeIterator change_node_type_iter = meta_nav.Select ("/metadata/change-node-type");
while (change_node_type_iter.MoveNext ()) {
string path = change_node_type_iter.Current.GetAttribute ("path", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement node = ( (IHasXmlNode) api_iter.Current).GetNode () as XmlElement;
XmlElement parent = node.ParentNode as XmlElement;
XmlElement new_node = api_doc.CreateElement (change_node_type_iter.Current.Value);
foreach (XmlNode child in node.ChildNodes)
new_node.AppendChild (child.Clone ());
foreach (XmlAttribute attribute in node.Attributes)
new_node.Attributes.Append ((XmlAttribute) attribute.Clone ());
parent.ReplaceChild (new_node, node);
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <change-node-type path=\"{0}\"/> matched no nodes", path);
}
foreach (XmlNode child in node.ChildNodes)
new_node.AppendChild (child.Clone ());
foreach (XmlAttribute attribute in node.Attributes)
new_node.Attributes.Append ( (XmlAttribute) attribute.Clone ());
XPathNodeIterator move_iter = meta_nav.Select ("/metadata/move-node");
while (move_iter.MoveNext ()) {
string path = move_iter.Current.GetAttribute ("path", "");
XPathExpression expr = api_nav.Compile (path);
string parent = move_iter.Current.Value;
XPathNodeIterator parent_iter = api_nav.Select (parent);
bool matched = false;
while (parent_iter.MoveNext ()) {
XmlNode parent_node = ((IHasXmlNode)parent_iter.Current).GetNode ();
XPathNodeIterator path_iter = parent_iter.Current.Clone ().Select (expr);
while (path_iter.MoveNext ()) {
XmlNode node = ((IHasXmlNode)path_iter.Current).GetNode ();
parent_node.AppendChild (node.Clone ());
node.ParentNode.RemoveChild (node);
}
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <move-node path=\"{0}\"/> matched no nodes", path);
}
parent.ReplaceChild (new_node, node);
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <change-node-type path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator rmv_iter = meta_nav.Select ("/metadata/remove-node");
while (rmv_iter.MoveNext ()) {
string path = rmv_iter.Current.GetAttribute ("path", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement api_node = ((IHasXmlNode)api_iter.Current).GetNode () as XmlElement;
api_node.ParentNode.RemoveChild (api_node);
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <remove-node path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator move_iter = meta_nav.Select ("/metadata/move-node");
while (move_iter.MoveNext ()) {
string path = move_iter.Current.GetAttribute ("path", "");
XPathExpression expr = api_nav.Compile (path);
string parent = move_iter.Current.Value;
XPathNodeIterator parent_iter = api_nav.Select (parent);
bool matched = false;
while (parent_iter.MoveNext ()) {
XmlNode parent_node = ( (IHasXmlNode) parent_iter.Current).GetNode ();
XPathNodeIterator path_iter = parent_iter.Current.Clone ().Select (expr);
while (path_iter.MoveNext ()) {
XmlNode node = ( (IHasXmlNode) path_iter.Current).GetNode ();
parent_node.AppendChild (node.Clone ());
node.ParentNode.RemoveChild (node);
}
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <move-node path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator add_iter = meta_nav.Select ("/metadata/add-node");
while (add_iter.MoveNext ()) {
string path = add_iter.Current.GetAttribute ("path", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement api_node = ((IHasXmlNode)api_iter.Current).GetNode () as XmlElement;
foreach (XmlNode child in ((IHasXmlNode)add_iter.Current).GetNode().ChildNodes)
api_node.AppendChild (api_doc.ImportNode (child, true));
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <add-node path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator rmv_iter = meta_nav.Select ("/metadata/remove-node");
while (rmv_iter.MoveNext ()) {
string path = rmv_iter.Current.GetAttribute ("path", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement api_node = ( (IHasXmlNode) api_iter.Current).GetNode () as XmlElement;
api_node.ParentNode.RemoveChild (api_node);
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <remove-node path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator attr_iter = meta_nav.Select ("/metadata/attr");
while (attr_iter.MoveNext ()) {
string path = attr_iter.Current.GetAttribute ("path", "");
string attr_name = attr_iter.Current.GetAttribute ("name", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement node = ((IHasXmlNode)api_iter.Current).GetNode () as XmlElement;
node.SetAttribute (attr_name, attr_iter.Current.Value);
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <attr path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator add_iter = meta_nav.Select ("/metadata/add-node");
while (add_iter.MoveNext ()) {
string path = add_iter.Current.GetAttribute ("path", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement api_node = ( (IHasXmlNode) api_iter.Current).GetNode () as XmlElement;
foreach (XmlNode child in ( (IHasXmlNode) add_iter.Current).GetNode().ChildNodes)
api_node.AppendChild (api_doc.ImportNode (child, true));
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <add-node path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator remove_attr_iter = meta_nav.Select ("/metadata/remove-attr");
while (remove_attr_iter.MoveNext ()) {
string path = remove_attr_iter.Current.GetAttribute ("path", "");
string name = remove_attr_iter.Current.GetAttribute ("name", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement node = ((IHasXmlNode)api_iter.Current).GetNode () as XmlElement;
XPathNodeIterator attr_iter = meta_nav.Select ("/metadata/attr");
while (attr_iter.MoveNext ()) {
string path = attr_iter.Current.GetAttribute ("path", "");
string attr_name = attr_iter.Current.GetAttribute ("name", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement node = ( (IHasXmlNode) api_iter.Current).GetNode () as XmlElement;
node.SetAttribute (attr_name, attr_iter.Current.Value);
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <attr path=\"{0}\"/> matched no nodes", path);
}
node.RemoveAttribute (name);
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <remove-attr path=\"{0}\"/> matched no nodes", path);
}
XPathNodeIterator remove_attr_iter = meta_nav.Select ("/metadata/remove-attr");
while (remove_attr_iter.MoveNext ()) {
string path = remove_attr_iter.Current.GetAttribute ("path", "");
string name = remove_attr_iter.Current.GetAttribute ("name", "");
XPathNodeIterator api_iter = api_nav.Select (path);
bool matched = false;
while (api_iter.MoveNext ()) {
XmlElement node = ( (IHasXmlNode) api_iter.Current).GetNode () as XmlElement;
if (symbol_doc != null) {
XPathNavigator symbol_nav = symbol_doc.CreateNavigator ();
XPathNodeIterator iter = symbol_nav.Select ("/api/*");
while (iter.MoveNext ()) {
XmlNode sym_node = ((IHasXmlNode)iter.Current).GetNode ();
XPathNodeIterator parent_iter = api_nav.Select ("/api");
if (parent_iter.MoveNext ()) {
XmlNode parent_node = ((IHasXmlNode)parent_iter.Current).GetNode ();
parent_node.AppendChild (api_doc.ImportNode (sym_node, true));
}
}
}
node.RemoveAttribute (name);
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <remove-attr path=\"{0}\"/> matched no nodes", path);
}
api_doc.Save (api_filename);
return 0;
}
}
if (symbol_doc != null) {
XPathNavigator symbol_nav = symbol_doc.CreateNavigator ();
XPathNodeIterator iter = symbol_nav.Select ("/api/*");
while (iter.MoveNext ()) {
XmlNode sym_node = ( (IHasXmlNode) iter.Current).GetNode ();
XPathNodeIterator parent_iter = api_nav.Select ("/api");
if (parent_iter.MoveNext ()) {
XmlNode parent_node = ( (IHasXmlNode) parent_iter.Current).GetNode ();
parent_node.AppendChild (api_doc.ImportNode (sym_node, true));
}
}
}
api_doc.Save (api_filename);
return 0;
}
}
}