]> git.sesse.net Git - mlt/commitdiff
Add C# bindings.
authorDan Dennedy <dan@dennedy.org>
Thu, 8 Apr 2010 08:12:48 +0000 (01:12 -0700)
committerDan Dennedy <dan@dennedy.org>
Thu, 8 Apr 2010 08:12:48 +0000 (01:12 -0700)
Thank you to Steeve Descarpentries for the initial contribution.

src/swig/configure
src/swig/csharp/build [new file with mode: 0755]
src/swig/csharp/play.cs [new file with mode: 0644]
src/swig/csharp/play.sh [new file with mode: 0755]

index 2587bf90206548b3f65cc111296d7c17894349b3..639b08f1864b4299363950c63348bc4eb641a280 100755 (executable)
@@ -5,7 +5,7 @@ then
        cat << EOF
 SWIG options:
 
-  --swig-languages=[all | [java | lua | perl | php | python | ruby | tcl]*]
+  --swig-languages=[all | [csharp | java | lua | perl | php | python | ruby | tcl]*]
                           - High level language bindings (default: none)
 
 EOF
@@ -27,7 +27,7 @@ else
                                fi
                                which swig > /dev/null 2>&1
                                [ $? != 0 ] && echo "Please install swig" && exit 1
-                               [ "$languages" = "all" ] && languages="java lua perl php python ruby tcl"
+                               [ "$languages" = "all" ] && languages="csharp java lua perl php python ruby tcl"
                                echo SUBDIRS = $languages > config.mak
                        ;;
                esac
diff --git a/src/swig/csharp/build b/src/swig/csharp/build
new file mode 100755 (executable)
index 0000000..5769110
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+if [ "$1" = "clean" ]
+then
+       ( cd `dirname $0`; rm -rf *.cxx *.snk *.so *.o *.exe *.dll mlt.i ../.cs src_swig )
+       exit 0
+fi
+
+path=`which mcs 2> /dev/null`
+
+if [ $? = 0 ]
+then
+       ln -sf ../mlt.i
+
+       # Invoke swig
+       mkdir src_swig
+       swig -c++ -I../../mlt++ -I../.. -csharp -dllimport libmltsharp -outdir src_swig -namespace Mlt mlt.i || exit $?
+
+       # Compile the wrapper
+       g++ -D_GNU_SOURCE -c -rdynamic -pthread -I../.. mlt_wrap.cxx -fPIC || exit $?
+       
+       # Create the module
+       gcc -shared mlt_wrap.o -L../../mlt++ -lmlt++ -o libmltsharp.so || exit $?
+
+       # Compile the library assembly
+       mcs -out:mlt-sharp.dll -target:library src_swig/*.cs
+       # uncomment the below if you want to sign the assembly
+       # sn -k mlt-sharp.snk
+       # mcs -out:mlt-sharp.dll -target:library -keyfile:mlt-sharp.snk src_swig/*.cs
+
+       # Compile the example
+       mcs -r:mlt-sharp.dll play.cs
+       
+else
+       echo Mono C# compiler not installed.
+       exit 1
+fi
diff --git a/src/swig/csharp/play.cs b/src/swig/csharp/play.cs
new file mode 100644 (file)
index 0000000..5ab85af
--- /dev/null
@@ -0,0 +1,21 @@
+using System;
+using System.Threading;
+using Mlt;
+
+public class Play {
+       public static void Main(String[] args) {
+               Console.WriteLine("Welcome to MLT.");
+               Factory.init();
+               Profile profile = new Profile("");
+               Producer p = new Producer(profile, args[0], null);
+               if (p.is_valid()) {
+                       Consumer c = new Consumer(profile, "sdl", null);
+                       c.set("rescale", "none");
+                       c.connect(p);
+                       c.start();
+                       while (!c.is_stopped())
+                               Thread.Sleep(300);
+                       c.stop();
+               }
+       }
+}
diff --git a/src/swig/csharp/play.sh b/src/swig/csharp/play.sh
new file mode 100755 (executable)
index 0000000..e80947e
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+mono play.exe "$@"