2006-05-19 19:24:35 +00:00
|
|
|
//
|
2006-05-20 22:35:40 +00:00
|
|
|
// Application.cs: Framework initialization for GStreamer
|
2006-05-19 19:24:35 +00:00
|
|
|
//
|
2006-05-20 22:35:40 +00:00
|
|
|
// Authors:
|
|
|
|
// Aaron Bockover (abockover@novell.com)
|
|
|
|
// Alp Toker (alp@atoker.com)
|
2006-05-19 19:24:35 +00:00
|
|
|
//
|
2009-04-08 08:16:48 +00:00
|
|
|
// Copyright (C) 2002 Alp Toker
|
|
|
|
// Copyright (C) 2006 Novell, Inc.
|
2006-05-19 19:24:35 +00:00
|
|
|
//
|
|
|
|
|
2006-05-20 22:35:40 +00:00
|
|
|
using System;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
2009-04-07 09:27:20 +00:00
|
|
|
namespace Gst {
|
|
|
|
public static class Application {
|
|
|
|
public static void Init() {
|
|
|
|
IntPtr argv = new IntPtr (0);
|
|
|
|
int argc = 0;
|
2006-05-20 22:35:40 +00:00
|
|
|
|
2009-04-07 09:27:20 +00:00
|
|
|
gst_init (ref argc, ref argv);
|
2009-04-21 17:27:05 +00:00
|
|
|
RegisterManagedTypes ();
|
2009-04-07 09:27:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2009-04-21 17:27:05 +00:00
|
|
|
private static void RegisterManagedTypes() {
|
|
|
|
GLib.GType t;
|
|
|
|
|
|
|
|
t = Gst.Fraction.GType;
|
|
|
|
t = Gst.DoubleRange.GType;
|
|
|
|
t = Gst.IntRange.GType;
|
|
|
|
t = Gst.FractionRange.GType;
|
|
|
|
t = Gst.Fourcc.GType;
|
|
|
|
t = Gst.Date.GType;
|
|
|
|
t = Gst.List.GType;
|
|
|
|
t = Gst.Array.GType;
|
|
|
|
t = Gst.Caps.GType;
|
|
|
|
t = Gst.Structure.GType;
|
|
|
|
t = Gst.TagList.GType;
|
|
|
|
t = Gst.MiniObject.GType;
|
2009-05-08 15:23:55 +00:00
|
|
|
|
|
|
|
GtkSharp.GstreamerSharp.ObjectManager.Initialize ();
|
2009-04-21 17:27:05 +00:00
|
|
|
}
|
|
|
|
|
2009-04-07 09:27:20 +00:00
|
|
|
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) {
|
2009-04-16 20:19:59 +00:00
|
|
|
throw new GLib.GException (error_ptr);
|
2009-04-07 09:27:20 +00:00
|
|
|
} else if (!result) {
|
|
|
|
throw new ApplicationException ("gst_init_check() failed: Reason unknown");
|
2006-05-20 22:35:40 +00:00
|
|
|
}
|
2009-04-07 09:27:20 +00:00
|
|
|
} else {
|
|
|
|
gst_init (ref argc, ref argv_ptr);
|
|
|
|
}
|
2009-04-07 09:02:08 +00:00
|
|
|
|
2009-04-07 09:27:20 +00:00
|
|
|
if (argv_ptr != argv.Handle) {
|
|
|
|
string init_call = check ? "gst_init_check()" : "gst_init()";
|
|
|
|
throw new ApplicationException (init_call + " returned a new argv handle");
|
|
|
|
}
|
2006-05-20 22:35:40 +00:00
|
|
|
|
2009-04-07 09:27:20 +00:00
|
|
|
if (argc <= 1) {
|
|
|
|
args = new string[0];
|
|
|
|
} else {
|
|
|
|
progargs = argv.GetArgs (argc);
|
|
|
|
args = new string[argc - 1];
|
2009-04-11 15:52:50 +00:00
|
|
|
System.Array.Copy (progargs, 1, args, 0, argc - 1);
|
2009-04-07 09:27:20 +00:00
|
|
|
}
|
2009-04-21 17:27:05 +00:00
|
|
|
RegisterManagedTypes ();
|
2006-05-20 22:35:40 +00:00
|
|
|
}
|
2009-04-07 09:27:20 +00:00
|
|
|
|
2009-04-07 09:37:11 +00:00
|
|
|
[DllImport ("gstreamer-0.10.dll") ]
|
2009-04-07 09:27:20 +00:00
|
|
|
private static extern void gst_init (ref int argc, ref IntPtr argv);
|
|
|
|
|
2009-04-07 09:37:11 +00:00
|
|
|
[DllImport ("gstreamer-0.10.dll") ]
|
2009-04-07 09:27:20 +00:00
|
|
|
private static extern bool gst_init_check (ref int argc, ref IntPtr argv, out IntPtr error);
|
|
|
|
|
2009-04-07 09:37:11 +00:00
|
|
|
[DllImport ("gstreamer-0.10.dll") ]
|
2009-04-07 09:27:20 +00:00
|
|
|
private static extern void gst_deinit();
|
|
|
|
}
|
2006-05-19 19:24:35 +00:00
|
|
|
}
|