[longomatch] Add bindings for the remuxer and itegrate with the build



commit 76b022eafb92e86f49422b30d7982e53ab456892
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Fri Oct 5 02:06:45 2012 +0200

    Add bindings for the remuxer and itegrate with the build

 LongoMatch.Multimedia/LongoMatch.Multimedia.mdp |    3 +
 LongoMatch.Multimedia/Makefile.am               |    2 +
 LongoMatch.Multimedia/Remuxer/GstRemuxer.cs     |  199 +++++++++++++++++++++++
 LongoMatch.Multimedia/Remuxer/ObjectManager.cs  |   39 +++++
 libcesarplayer/gst-remuxer.c                    |    2 +-
 libcesarplayer/liblongomatch.mdp                |    4 +-
 libcesarplayer/test-remuxer.c                   |    2 +-
 7 files changed, 248 insertions(+), 3 deletions(-)
---
diff --git a/LongoMatch.Multimedia/LongoMatch.Multimedia.mdp b/LongoMatch.Multimedia/LongoMatch.Multimedia.mdp
index f12d30f..3498a7d 100644
--- a/LongoMatch.Multimedia/LongoMatch.Multimedia.mdp
+++ b/LongoMatch.Multimedia/LongoMatch.Multimedia.mdp
@@ -55,6 +55,9 @@
     <File subtype="Directory" buildaction="Compile" name="Interfaces" />
     <File subtype="Directory" buildaction="Compile" name="Interfaces" />
     <File subtype="Code" buildaction="Compile" name="Common/Handlers.cs" />
+    <File subtype="Directory" buildaction="Compile" name="Remuxer" />
+    <File subtype="Code" buildaction="Compile" name="Remuxer/GstRemuxer.cs" />
+    <File subtype="Code" buildaction="Compile" name="Remuxer/ObjectManager.cs" />
   </Contents>
   <References>
     <ProjectReference type="Project" localcopy="True" refto="libcesarplayer" />
diff --git a/LongoMatch.Multimedia/Makefile.am b/LongoMatch.Multimedia/Makefile.am
index 0f8e995..a3d3ee2 100644
--- a/LongoMatch.Multimedia/Makefile.am
+++ b/LongoMatch.Multimedia/Makefile.am
@@ -17,6 +17,8 @@ SOURCES = \
 	Interfaces/IPlayer.cs \
 	Player/GstPlayer.cs \
 	Player/ObjectManager.cs \
+	Remuxer/GstRemuxer.cs \
+	Remuxer/ObjectManager.cs \
 	Utils/FramesCapturer.cs \
 	Utils/GStreamer.cs \
 	Utils/IMetadataReader.cs \
diff --git a/LongoMatch.Multimedia/Remuxer/GstRemuxer.cs b/LongoMatch.Multimedia/Remuxer/GstRemuxer.cs
new file mode 100644
index 0000000..1b3aeb3
--- /dev/null
+++ b/LongoMatch.Multimedia/Remuxer/GstRemuxer.cs
@@ -0,0 +1,199 @@
+//  Copyright (C) 2007-2009 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//
+
+namespace LongoMatch.Video.Remuxer {
+
+	using System;
+	using System.Runtime.InteropServices;
+	using Mono.Unix;
+	
+	using LongoMatch.Common;
+	using LongoMatch.Multimedia.Interfaces;
+	using LongoMatch.Video.Common;
+	
+
+	#region Autogenerated code
+	public  class GstRemuxer : GLib.Object {
+
+		public event ProgressHandler Progress;
+
+		[DllImport("libcesarplayer.dll")]
+		static extern unsafe IntPtr gst_remuxer_new(IntPtr input_file, IntPtr output_file, out IntPtr err);
+
+		public unsafe GstRemuxer(string inputFile, string outputFile) : base(IntPtr.Zero)
+		{
+			if(GetType() != typeof(GstRemuxer)) {
+				throw new InvalidOperationException("Can't override this constructor.");
+			}
+			IntPtr error = IntPtr.Zero;
+			Raw = gst_remuxer_new(GLib.Marshaller.StringToPtrGStrdup(inputFile),
+			                              GLib.Marshaller.StringToPtrGStrdup(outputFile), out error);
+			if(error != IntPtr.Zero) throw new GLib.GException(error);
+			
+			PercentCompleted += delegate(object o, PercentCompletedArgs args) {
+				if(Progress!= null)
+					Progress(args.Percent);
+			};
+		}
+
+#pragma warning disable 0169
+#region Error
+		[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+		delegate void ErrorSignalDelegate(IntPtr arg0, IntPtr arg1, IntPtr gch);
+
+		static void ErrorSignalCallback(IntPtr arg0, IntPtr arg1, IntPtr gch)
+		{
+			ErrorArgs args = new ErrorArgs();
+			try {
+				GLib.Signal sig = ((GCHandle) gch).Target as GLib.Signal;
+				if(sig == null)
+					throw new Exception("Unknown signal GC handle received " + gch);
+
+				args.Args = new object[1];
+				args.Args[0] = GLib.Marshaller.Utf8PtrToString(arg1);
+				ErrorHandler handler = (ErrorHandler) sig.Handler;
+				handler(GLib.Object.GetObject(arg0), args);
+			} catch(Exception e) {
+				GLib.ExceptionManager.RaiseUnhandledException(e, false);
+			}
+		}
+
+		[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+		delegate void ErrorVMDelegate(IntPtr remuxer, IntPtr message);
+
+		static ErrorVMDelegate ErrorVMCallback;
+
+		static void error_cb(IntPtr remuxer, IntPtr message)
+		{
+			try {
+				GstRemuxer remuxer_managed = GLib.Object.GetObject(remuxer, false) as GstRemuxer;
+				remuxer_managed.OnError(GLib.Marshaller.Utf8PtrToString(message));
+			} catch(Exception e) {
+				GLib.ExceptionManager.RaiseUnhandledException(e, false);
+			}
+		}
+
+		private static void OverrideError(GLib.GType gtype)
+		{
+			if(ErrorVMCallback == null)
+				ErrorVMCallback = new ErrorVMDelegate(error_cb);
+			OverrideVirtualMethod(gtype, "error", ErrorVMCallback);
+		}
+
+		[GLib.DefaultSignalHandler(Type=typeof(LongoMatch.Video.Remuxer.GstRemuxer), ConnectionMethod="OverrideError")]
+		protected virtual void OnError(string message)
+		{
+			GLib.Value ret = GLib.Value.Empty;
+			GLib.ValueArray inst_and_params = new GLib.ValueArray(2);
+			GLib.Value[] vals = new GLib.Value [2];
+			vals [0] = new GLib.Value(this);
+			inst_and_params.Append(vals [0]);
+			vals [1] = new GLib.Value(message);
+			inst_and_params.Append(vals [1]);
+			g_signal_chain_from_overridden(inst_and_params.ArrayPtr, ref ret);
+			foreach(GLib.Value v in vals)
+				v.Dispose();
+		}
+
+		[GLib.Signal("error")]
+		public event ErrorHandler Error {
+			add {
+				GLib.Signal sig = GLib.Signal.Lookup(this, "error", new ErrorSignalDelegate(ErrorSignalCallback));
+				sig.AddDelegate(value);
+			}
+			remove {
+				GLib.Signal sig = GLib.Signal.Lookup(this, "error", new ErrorSignalDelegate(ErrorSignalCallback));
+				sig.RemoveDelegate(value);
+			}
+		}
+#endregion
+		
+#region Percent-completed
+		[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+		delegate void PercentCompletedVMDelegate(IntPtr gvc, float percent);
+
+		static PercentCompletedVMDelegate PercentCompletedVMCallback;
+
+		static void percentcompleted_cb(IntPtr remuxer, float percent)
+		{
+			try {
+				GstRemuxer remuxer_managed = GLib.Object.GetObject(remuxer, false) as GstRemuxer;
+				remuxer_managed.OnPercentCompleted(percent);
+			} catch(Exception e) {
+				GLib.ExceptionManager.RaiseUnhandledException(e, false);
+			}
+		}
+
+		private static void OverridePercentCompleted(GLib.GType gtype)
+		{
+			if(PercentCompletedVMCallback == null)
+				PercentCompletedVMCallback = new PercentCompletedVMDelegate(percentcompleted_cb);
+			OverrideVirtualMethod(gtype, "percent_completed", PercentCompletedVMCallback);
+		}
+
+		[GLib.DefaultSignalHandler(Type=typeof(LongoMatch.Video.Remuxer.GstRemuxer), ConnectionMethod="OverridePercentCompleted")]
+		protected virtual void OnPercentCompleted(float percent)
+		{
+			GLib.Value ret = GLib.Value.Empty;
+			GLib.ValueArray inst_and_params = new GLib.ValueArray(2);
+			GLib.Value[] vals = new GLib.Value [2];
+			vals [0] = new GLib.Value(this);
+			inst_and_params.Append(vals [0]);
+			vals [1] = new GLib.Value(percent);
+			inst_and_params.Append(vals [1]);
+			g_signal_chain_from_overridden(inst_and_params.ArrayPtr, ref ret);
+			foreach(GLib.Value v in vals)
+				v.Dispose();
+		}
+
+		[GLib.Signal("percent_completed")]
+		public event PercentCompletedHandler PercentCompleted {
+			add {
+				GLib.Signal sig = GLib.Signal.Lookup(this, "percent_completed", typeof(PercentCompletedArgs));
+				sig.AddDelegate(value);
+			}
+			remove {
+				GLib.Signal sig = GLib.Signal.Lookup(this, "percent_completed", typeof(PercentCompletedArgs));
+				sig.RemoveDelegate(value);
+			}
+		}
+#endregion
+		
+		[DllImport("libcesarplayer.dll")]
+		static extern void gst_remuxer_cancel(IntPtr raw);
+
+		public void Cancel() {
+			gst_remuxer_cancel(Handle);
+		}
+
+
+		[DllImport("libcesarplayer.dll")]
+		static extern void gst_camera_capturer_start(IntPtr raw);
+
+		public void Start() {
+			gst_camera_capturer_start(Handle);
+		}
+
+		static GstRemuxer()
+		{
+			LongoMatch.GtkSharp.Remuxer.ObjectManager.Initialize();
+		}
+		#endregion
+		
+	}
+}
diff --git a/LongoMatch.Multimedia/Remuxer/ObjectManager.cs b/LongoMatch.Multimedia/Remuxer/ObjectManager.cs
new file mode 100644
index 0000000..f1ddc7a
--- /dev/null
+++ b/LongoMatch.Multimedia/Remuxer/ObjectManager.cs
@@ -0,0 +1,39 @@
+// ObjectManager.cs
+//
+//  Copyright (C) 2007-2009 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//
+// This file was generated by the Gtk# code generator.
+// Any changes made will be lost if regenerated.
+
+namespace LongoMatch.GtkSharp.Remuxer {
+
+	public class ObjectManager {
+
+		static bool initialized = false;
+		// Call this method from the appropriate module init function.
+		public static void Initialize()
+		{
+			if(initialized)
+				return;
+
+			initialized = true;
+
+			GLib.GType.Register(LongoMatch.Video.Remuxer.GstRemuxer.GType, typeof(LongoMatch.Video.Remuxer.GstRemuxer));
+		}
+	}
+}
diff --git a/libcesarplayer/gst-remuxer.c b/libcesarplayer/gst-remuxer.c
index bad08a7..1c5798a 100644
--- a/libcesarplayer/gst-remuxer.c
+++ b/libcesarplayer/gst-remuxer.c
@@ -156,7 +156,7 @@ gst_remuxer_class_init (GstRemuxerClass * klass)
         g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
 
   remuxer_signals[SIGNAL_PERCENT] =
-      g_signal_new ("percent-completed",
+      g_signal_new ("percent_completed",
         G_TYPE_FROM_CLASS (object_class),
         G_SIGNAL_RUN_LAST,
         G_STRUCT_OFFSET (GstRemuxerClass, percent_completed),
diff --git a/libcesarplayer/liblongomatch.mdp b/libcesarplayer/liblongomatch.mdp
index 74c14e9..a745b4c 100644
--- a/libcesarplayer/liblongomatch.mdp
+++ b/libcesarplayer/liblongomatch.mdp
@@ -35,6 +35,8 @@
     <File subtype="Code" buildaction="Nothing" name="video-utils.h" />
     <File subtype="Code" buildaction="Compile" name="baconvideowidget-marshal.c" />
     <File subtype="Code" buildaction="Nothing" name="baconvideowidget-marshal.h" />
+    <File subtype="Code" buildaction="Compile" name="gst-remuxer.c" />
+    <File subtype="Code" buildaction="Nothing" name="gst-remuxer.h" />
   </Contents>
   <MonoDevelop.Autotools.MakefileInfo RelativeMakefileName="Makefile.am" IsAutotoolsProject="True" RelativeConfigureInPath=".">
     <BuildFilesVar />
@@ -57,4 +59,4 @@
     <Package file="/usr/lib/pkgconfig/gstreamer-app-0.10.pc" name="GStreamer APP" IsProject="False" />
   </Packages>
   <compiler ctype="GccCompiler" />
-</Project>
+</Project>
\ No newline at end of file
diff --git a/libcesarplayer/test-remuxer.c b/libcesarplayer/test-remuxer.c
index 27eb4f2..02a18bf 100644
--- a/libcesarplayer/test-remuxer.c
+++ b/libcesarplayer/test-remuxer.c
@@ -60,7 +60,7 @@ main (int argc, char *argv[])
 
   loop = g_main_loop_new (NULL, FALSE);
 
-  g_signal_connect (remuxer, "percent-completed",
+  g_signal_connect (remuxer, "percent_completed",
       G_CALLBACK (percent_done_cb), loop);
   g_signal_connect (remuxer, "error",
       G_CALLBACK (error_cb), loop);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]