2006-05-20 Aaron Bockover <aaron@abock.org>

* autogen.sh: Fixed a left over configure.in to configure.ac

    * confiugre.ac: Added check foo for NUnit

    * gstreamer-sharp.mdp:
    * gstreamer-sharp.mds: Added MonoDevelop solution

    * source/Makefile.am: Cleaned and fixed

    * tests/ConsoleUi.cs:
    * tests/ApplicationTest.cs:
    * tests/BinTest.cs:
    * tests/Makefile.am: Added NUnit test framework and a few tests for
    Gst.Application and Gst.Bin

    * gstreamer-sharp/CommonTags.cs:
    * gstreamer-sharp/*.custom:
    * gstreamer-sharp/glue/*.c: Cleaned up

    * gstreamer-sharp/Application.cs: New application bindings; fixed
    to work properly with GStreamer 0.10

    * gstreamer-sharp/Version.cs: New Gst.Version class

    * gstreamer-sharp/Makefile.am: Added Version.cs

    * gstreamer-sharp/plugins-base/PlayBin.cs: Fixed and extended PlayBin
    element binding with new (but not all) properties

    * Makefile.am: Added tests



git-svn-id: svn://anonsvn.mono-project.com/source/branches/abock/gstreamer-sharp@60902 e3ebcda4-bce8-0310-ba0a-eca2169e7518
This commit is contained in:
Aaron Bockover 2006-05-20 22:35:40 +00:00
parent 67ba536cb1
commit 88b3b2c712
28 changed files with 1145 additions and 303 deletions

View file

@ -1,3 +1,36 @@
2006-05-20 Aaron Bockover <aaron@abock.org>
* autogen.sh: Fixed a left over configure.in to configure.ac
* confiugre.ac: Added check foo for NUnit
* gstreamer-sharp.mdp:
* gstreamer-sharp.mds: Added MonoDevelop solution
* source/Makefile.am: Cleaned and fixed
* tests/ConsoleUi.cs:
* tests/ApplicationTest.cs:
* tests/BinTest.cs:
* tests/Makefile.am: Added NUnit test framework and a few tests for
Gst.Application and Gst.Bin
* gstreamer-sharp/CommonTags.cs:
* gstreamer-sharp/*.custom:
* gstreamer-sharp/glue/*.c: Cleaned up
* gstreamer-sharp/Application.cs: New application bindings; fixed
to work properly with GStreamer 0.10
* gstreamer-sharp/Version.cs: New Gst.Version class
* gstreamer-sharp/Makefile.am: Added Version.cs
* gstreamer-sharp/plugins-base/PlayBin.cs: Fixed and extended PlayBin
element binding with new (but not all) properties
* Makefile.am: Added tests
2006-05-19 Aaron Bockover <aaron@abock.org>
* gstreamer-sharp: Initial import to Mono Subversion; all prior work

View file

@ -1,4 +1,4 @@
SUBDIRS = source gstreamer-sharp doc sample
SUBDIRS = source gstreamer-sharp doc tests sample
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = gstreamer-sharp-0.10.pc

View file

@ -22,7 +22,7 @@ if [ -z "$LIBTOOL" ]; then
fi
fi
(grep "^AM_PROG_LIBTOOL" $srcdir/configure.in >/dev/null) && {
(grep "^AM_PROG_LIBTOOL" $srcdir/configure.ac >/dev/null) && {
($LIBTOOL --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`libtool' installed to compile Gst#."

View file

@ -135,6 +135,13 @@ if test "x$GAPI_PARSER" = "xno"; then
AC_MSG_ERROR([You need to install gtk-sharp-gapi])
fi
PKG_CHECK_MODULES(MONO_NUNIT, mono-nunit >= 1.0, do_tests="yes", do_tests="no")
AC_SUBST(MONO_NUNIT_LIBS)
AM_CONDITIONAL(ENABLE_TESTS, test "x$do_tests" = "xyes")
if test "x$do_tests" = "xno"; then
AC_MSG_WARN([Could not find mono-nunit: tests will not be available])
fi
AC_OUTPUT([
source/Makefile
gstreamer-sharp/Makefile
@ -142,6 +149,7 @@ gstreamer-sharp/AssemblyInfo.cs
gstreamer-sharp/gstreamer-sharp.dll.config
gstreamer-sharp/glue/Makefile
doc/Makefile
tests/Makefile
sample/Makefile
gstreamer-sharp-0.10.pc
Makefile

40
gstreamer-sharp.mdp Normal file
View file

@ -0,0 +1,40 @@
<Project name="gstreamer-sharp" fileversion="2.0" language="C#" ctype="DotNetProject">
<Configurations active="Debug">
<Configuration name="Debug" ctype="DotNetProjectConfiguration">
<Output directory="./bin/Debug" assembly="gstreamer-sharp" />
<Build debugmode="True" target="Exe" />
<Execution runwithwarnings="True" consolepause="True" runtime="MsNet" />
<CodeGeneration compiler="Csc" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
</Configuration>
<Configuration name="Release" ctype="DotNetProjectConfiguration">
<Output directory="./bin/Release" assembly="gstreamer-sharp" />
<Build debugmode="False" target="Exe" />
<Execution runwithwarnings="True" consolepause="True" runtime="MsNet" />
<CodeGeneration compiler="Csc" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
</Configuration>
</Configurations>
<DeploymentInformation strategy="File">
<excludeFiles />
</DeploymentInformation>
<Contents>
<File name="./gstreamer-sharp/Application.cs" subtype="Code" buildaction="Compile" />
<File name="./gstreamer-sharp/Bin.custom" subtype="Code" buildaction="Nothing" />
<File name="./gstreamer-sharp/Bus.custom" subtype="Code" buildaction="Nothing" />
<File name="./gstreamer-sharp/Clock.custom" subtype="Code" buildaction="Nothing" />
<File name="./gstreamer-sharp/CommonTags.cs" subtype="Code" buildaction="Compile" />
<File name="./gstreamer-sharp/Debug.custom" subtype="Code" buildaction="Nothing" />
<File name="./gstreamer-sharp/Element.custom" subtype="Code" buildaction="Nothing" />
<File name="./gstreamer-sharp/Gstreamer.metadata" subtype="Code" buildaction="Nothing" />
<File name="./gstreamer-sharp/Message.custom" subtype="Code" buildaction="Nothing" />
<File name="./gstreamer-sharp/Pad.custom" subtype="Code" buildaction="Nothing" />
<File name="./gstreamer-sharp/Version.cs" subtype="Code" buildaction="Compile" />
<File name="./tests/ConsoleUi.cs" subtype="Code" buildaction="Compile" />
<File name="./tests/ApplicationTest.cs" subtype="Code" buildaction="Compile" />
<File name="./tests/BinTest.cs" subtype="Code" buildaction="Compile" />
<File name="./gstreamer-sharp/plugins-base/PlayBin.cs" subtype="Code" buildaction="Compile" />
<File name="./gstreamer-sharp/glue/clock.c" subtype="Code" buildaction="Nothing" />
<File name="./gstreamer-sharp/glue/message.c" subtype="Code" buildaction="Nothing" />
<File name="./gstreamer-sharp/glue/miniobject.c" subtype="Code" buildaction="Nothing" />
</Contents>
<References />
</Project>

16
gstreamer-sharp.mds Normal file
View file

@ -0,0 +1,16 @@
<Combine name="gstreamer-sharp" fileversion="2.0">
<Configurations active="Debug">
<Configuration name="Debug" ctype="CombineConfiguration">
<Entry configuration="Debug" build="True" name="gstreamer-sharp" />
</Configuration>
<Configuration name="Release" ctype="CombineConfiguration">
<Entry configuration="Debug" build="True" name="gstreamer-sharp" />
</Configuration>
</Configurations>
<StartMode startupentry="gstreamer-sharp" single="True">
<Execute type="None" entry="gstreamer-sharp" />
</StartMode>
<Entries>
<Entry filename="./gstreamer-sharp.mdp" />
</Entries>
</Combine>

View file

@ -1,93 +1,101 @@
//
// Application.cs - Gst initialization
// Application.cs: Framework initialization for GStreamer
//
// Author: Alp Toker <alp@atoker.com>
// Authors:
// Aaron Bockover (abockover@novell.com)
// Alp Toker (alp@atoker.com)
//
// 2002 (C) Copyright, Alp Toker
// (C) 2006 Novell, Inc.
// (C) 2002 Alp Toker
//
using System;
using System.Runtime.InteropServices;
namespace Gst {
namespace Gst
{
public static class Application
{
public static void Init()
{
IntPtr argv = new IntPtr(0);
int argc = 0;
using System;
using System.Runtime.InteropServices;
gst_init(ref argc, ref argv);
}
public class Application {
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];
//
// Disables creation of instances.
//
private Application ()
{
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) {
throw new ApplicationException("gst_init_check set error");
} else if(!result) {
throw new ApplicationException("gst_init_check failed, error not set");
}
[DllImport("gstreamer-0.10")]
static extern void gst_init (ref int argc, ref IntPtr argv);
[DllImport("gstreamer-0.10")]
static extern bool gst_init_check (ref int argc, ref IntPtr argv);
public static void Init ()
{
IntPtr argv = new IntPtr(0);
int argc = 0;
gst_init (ref argc, ref argv);
}
static bool do_init (string progname, ref string[] args, bool check)
{
bool res = false;
string[] progargs = new string[args.Length + 1];
progargs[0] = progname;
args.CopyTo (progargs, 1);
GLib.Argv argv = new GLib.Argv (progargs);
IntPtr buf = argv.Handle;
int argc = progargs.Length;
if (check)
res = gst_init_check (ref argc, ref buf);
else
gst_init (ref argc, ref buf);
if (buf != argv.Handle)
throw new Exception ("init returned new argv handle");
// copy back the resulting argv, minus argv[0], which we're
// not interested in.
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);
}
return res;
} 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);
}
}
private static Version version = null;
public static Version Version {
get {
if(version == null) {
version = new Version();
}
return version;
}
}
[DllImport("gstreamer-0.10")]
private static extern void gst_init(ref int argc, ref IntPtr argv);
public static void Init (string progname, ref string[] args)
{
do_init (progname, ref args, false);
}
public static bool InitCheck (string progname, ref string[] args)
{
return do_init (progname, ref args, true);
}
[DllImport("gstreamer-0.10")]
static extern void gst_version (out uint major, out uint minor, out uint micro);
public static string Version {
get {
uint major, minor, micro;
gst_version (out major, out minor, out micro);
return major + "." + minor + "." + micro;
}
}
}
[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,38 +1,42 @@
//
// Bin.custom
//
// This code is inserted after the automatically generated code.
//
[DllImport("gstreamer-0.10")]
static extern IntPtr gst_bin_get_list(IntPtr raw);
public Element[] List {
get {
IntPtr list_ptr = gst_bin_get_list (Handle);
if (list_ptr == IntPtr.Zero)
return new Element [0];
GLib.List list = new GLib.List (list_ptr);
Element[] result = new Element [list.Count];
for (int i = 0; i < list.Count; i++)
result [i] = list [i] as Element;
return result;
}
}
/*[DllImport ("gstreamersharpglue-0.10")]
private extern static uint gstsharp_gst_bin_get_children_offset();
public bool AddMany (params Element[] elements)
{
if (elements == null)
return false;
static uint children_offset = gstsharp_gst_bin_get_children_offset();*/
bool ret = true;
foreach (Element element in elements)
{
if (element == null || !Add (element)) {
ret = false;
continue;
}
}
/* TODO: This needs to be called 'Children' and the default version
needs to be hidden (see Gstreamer.metadata) */
return ret;
}
public Element [] List {
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 = 0; i < list.Count; i++) {
result[i] = list[i] as Element;
}
return result;
}
}
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;
}

View file

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

View file

@ -1,25 +1,20 @@
//
// Clock.custom
//
//
//
[DllImport ("gstsharpglue-0.10")]
extern static long gstsharp_gst_clock_get_gst_second ();
[DllImport("gstsharpglue-0.10")]
private extern static long gstsharp_gst_clock_get_gst_second();
public static readonly long GstSecond = gstsharp_gst_clock_get_gst_second ();
public static readonly long GstSecond = gstsharp_gst_clock_get_gst_second();
[DllImport ("gstsharpglue-0.10")]
extern static long gstsharp_gst_clock_get_gst_msecond ();
[DllImport("gstsharpglue-0.10")]
private extern static long gstsharp_gst_clock_get_gst_msecond();
public static readonly long GstMSecond = gstsharp_gst_clock_get_gst_second ();
public static readonly long GstMSecond = gstsharp_gst_clock_get_gst_second();
[DllImport ("gstsharpglue-0.10")]
extern static long gstsharp_gst_clock_get_gst_usecond ();
[DllImport("gstsharpglue-0.10")]
private extern static long gstsharp_gst_clock_get_gst_usecond();
public static readonly long GstUSecond = gstsharp_gst_clock_get_gst_second ();
public static readonly long GstUSecond = gstsharp_gst_clock_get_gst_second();
[DllImport ("gstsharpglue-0.10")]
extern static long gstsharp_gst_clock_get_gst_nsecond ();
[DllImport("gstsharpglue-0.10")]
private extern static long gstsharp_gst_clock_get_gst_nsecond();
public static readonly long GstNSecond = gstsharp_gst_clock_get_gst_second ();
public static readonly long GstNSecond = gstsharp_gst_clock_get_gst_second();

View file

@ -1,38 +1,49 @@
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";
}
//
// Commontags.cs: Constant tag strings
//
// Authors:
// Alp Toker (alp@atoker.com)
//
// (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";
}
}

View file

@ -1,9 +1,9 @@
[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

@ -1,42 +1,44 @@
//
// Element.custom
//
// This code is inserted after the automatically generated code.
//
public new GLib.Value GetProperty (string property_name) {
return base.GetProperty (property_name);
}
public new GLib.Value GetProperty(string propertyName)
{
return base.GetProperty(propertyName);
}
public new void SetProperty (string property_name, GLib.Value value) {
base.SetProperty (property_name, value);
}
public new void SetProperty(string propertyName, GLib.Value value)
{
base.SetProperty(propertyName, value);
}
public void SetProperty (string property_name, string value) {
GLib.Value val = new GLib.Value (value);
base.SetProperty (property_name, val);
}
public void SetProperty(string propertyName, string value)
{
GLib.Value val = new GLib.Value(value);
base.SetProperty(propertyName, val);
}
public void SetProperty (string property_name, double value) {
GLib.Value val = new GLib.Value (value);
base.SetProperty (property_name, val);
}
public void SetProperty(string propertyName, double value)
{
GLib.Value val = new GLib.Value(value);
base.SetProperty(propertyName, val);
}
public void SetProperty (string property_name, bool value) {
GLib.Value val = new GLib.Value (value);
base.SetProperty (property_name, val);
}
public void SetProperty(string propertyName, bool value)
{
GLib.Value val = new GLib.Value(value);
base.SetProperty(propertyName, val);
}
[DllImport("gstreamer-0.10.dll")]
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);
public bool QueryPosition(Gst.Format format, out long cur) {
return gst_element_query_position(Handle, ref format, out cur);
}
public bool QueryPosition(Gst.Format format, out long current)
{
return gst_element_query_position(Handle, ref format, out current);
}
[DllImport("gstreamer-0.10.dll")]
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);
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);
}

View file

@ -1,5 +1,12 @@
<?xml version="1.0"?>
<metadata>
<attr path="/api/namespace/object[@name='Bin']" name="disable_gtype_ctor">1</attr>
<attr path="/api/namespace/object[@name='Pipeline']" name="disable_gtype_ctor">1</attr>
<!-- TODO: Why doesn't this work? -->
<attr path="/api/namespace/class[@name='Bin']/property[@name='Children']" name="hidden">1</attr>
<attr path="/api/namespace/object[@name='Bin']/property[@name='ChildrenCount']" name="name">ChildCount</attr>
<attr path="/api/namespace/object[@name='Element']/signal[@name='NoMorePads']" name="name">HasNoMorePads</attr>
<!-- Hidden as the parameter name conflicts with generated code -->
<attr path="/api/namespace/object[@name='Element']/method[@name='ContinueState']/parameters/*[@name='ret']" name="name">state_change_ret</attr>

View file

@ -5,8 +5,8 @@ noinst_DATA = $(TARGET)
APIS = $(API)
API = gstreamer-api.xml
RAW_API = gstreamer-api.raw
SYMBOLS = gstreamer-symbols.xml
METADATA = Gstreamer.metadata
SYMBOLS=gstreamer-symbols.xml
ASSEMBLY_NAME = gstreamer-sharp
references = $(GLIBSHARP_LIBS)
KEYFILE = gstreamer-sharp.snk
@ -38,6 +38,7 @@ clean-local:
sources = \
Application.cs \
Version.cs \
AssemblyInfo.cs \
CommonTags.cs \
plugins-base/PlayBin.cs

View file

@ -1,10 +1,10 @@
[DllImport("gstsharpglue-0.10")]
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("gstsharpglue-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);
}

View file

@ -1,13 +1,16 @@
[DllImport("gstreamer-0.10.dll")]
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_position(IntPtr raw, ref Format format, out long cur);
public bool QueryPosition(Gst.Format format, out long cur) {
return gst_pad_query_position(Handle, ref format, out 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")]
static extern bool gst_pad_query_duration(IntPtr raw, ref Format format, out long 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 bool QueryDuration(Gst.Format format, out long duration)
{
return gst_pad_query_duration(Handle, ref format, out duration);
}

View file

@ -0,0 +1,66 @@
//
// Version.cs: Lightweight Version Object for GStreamer
//
// Authors:
// Aaron Bockover (abockover@novell.com)
//
// (C) 2006 Novell, Inc.
//
using System;
using System.Runtime.InteropServices;
namespace Gst
{
public class Version
{
private uint major;
private uint minor;
private uint micro;
private uint nano;
private string version_string;
internal Version()
{
gst_version(out major, out minor, out micro, out nano);
}
public override string ToString()
{
return String.Format("{0}.{1}.{2}.{3}", major, minor, micro, nano);
}
public 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 uint Major {
get { return major; }
}
public uint Minor {
get { return minor; }
}
public uint Micro {
get { return micro; }
}
public 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

@ -1,15 +1,15 @@
lib_LTLIBRARIES = libgstreamersharpglue-0.10.la
libgstreamersharpglue_0_10_la_SOURCES = \
clock.c \
message.c \
miniobject.c
libgstreamersharpglue_0_10_la_SOURCES = \
clock.c \
message.c \
miniobject.c
nodist_libgstreamersharpglue_0_10_la_SOURCES = generated.c
libgstreamersharpglue_0_10_la_LIBADD = $(GST_LIBS)
INCLUDES = $(GST_CFLAGS) -I$(top_srcdir)
INCLUDES = -Wall -D_FORTIFY_SOURCE=2 $(GST_CFLAGS) -I$(top_srcdir)
CLEANFILES= lib*.a lib*.la
MAINTAINERCLEANFILES = Makefile.in

View file

@ -1,24 +1,22 @@
#include <glib.h>
#include <gst/gstclock.h>
gint64 gstsharp_gst_clock_get_gst_second ()
gint64 gstsharp_gst_clock_get_gst_second()
{
return GST_SECOND;
return GST_SECOND;
}
gint64 gstsharp_gst_clock_get_gst_msecond ()
gint64 gstsharp_gst_clock_get_gst_msecond()
{
return GST_MSECOND;
return GST_MSECOND;
}
gint64 gstsharp_gst_clock_get_gst_usecond ()
gint64 gstsharp_gst_clock_get_gst_usecond()
{
return GST_USECOND;
return GST_USECOND;
}
gint64 gstsharp_gst_clock_get_gst_nsecond ()
gint64 gstsharp_gst_clock_get_gst_nsecond()
{
return GST_NSECOND;
return GST_NSECOND;
}

View file

@ -1,15 +1,16 @@
#include <glib/gerror.h>
#include <gst/gstmessage.h>
gchar* gstsharp_message_parse_error (GstMessage *message)
gchar *
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;
}

View file

@ -5,21 +5,21 @@
#include <gst/gstminiobject.h>
GType
gstsharp_get_type_id (GObject *obj)
gstsharp_get_type_id(GObject *obj)
{
return G_TYPE_FROM_INSTANCE (obj);
return G_TYPE_FROM_INSTANCE(obj);
}
GType
gstsharp_register_type (gchar *name, GType parent)
gstsharp_register_type(gchar *name, GType parent)
{
GTypeQuery query;
GTypeInfo info = {0, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL };
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

@ -1,42 +1,128 @@
//
// PlayBin.cs: playbin element binding
//
// Authors:
// Aaron Bockover (abockover@novell.com)
//
// (C) 2006 Novell, Inc.
//
using System;
using System.Collections;
using System.Runtime.InteropServices;
namespace Gst
{
using System;
using System.Collections;
using System.Runtime.InteropServices;
public class PlayBin : Pipeline
{
public PlayBin(IntPtr raw) : base(raw)
{
}
using Gst;
[GLib.Property("uri")]
public string Uri {
get {
GLib.Value val = GetProperty("uri");
string ret = val.Val as string;
val.Dispose();
return ret;
}
public class PlayBin : Pipeline {
[Obsolete]
protected PlayBin(GLib.GType gtype) : base(gtype) {}
public PlayBin(IntPtr raw) : base(raw) {}
set {
GLib.Value val = new GLib.Value(value);
SetProperty("uri", val);
val.Dispose();
}
}
[GLib.Property("suburi")]
public string SubUri {
get {
GLib.Value val = GetProperty("suburi");
string ret = val.Val as string;
val.Dispose();
return ret;
}
[GLib.Property ("uri")]
public string Uri {
get {
GLib.Value val = GetProperty ("uri");
string ret = val.Val as string;
val.Dispose ();
return ret;
}
set {
GLib.Value val = new GLib.Value(value);
SetProperty("suburi", val);
val.Dispose();
}
}
[GLib.Property("source")]
public Element Source {
get {
GLib.Value val = GetProperty("source");
Element element = val.Val as Element;
val.Dispose();
return element;
}
}
[GLib.Property("audio-sink")]
public Element AudioSink {
get {
GLib.Value val = GetProperty("audio-sink");
Element ret = val.Val as Element;
val.Dispose();
return ret;
}
set {
GLib.Value val = new GLib.Value (value);
SetProperty ("uri", val);
val.Dispose ();
}
set {
GLib.Value val = new GLib.Value(value);
SetProperty("audio-sink", val);
val.Dispose();
}
}
[GLib.Property("video-sink")]
public Element VideoSink {
get {
GLib.Value val = GetProperty("video-sink");
Element ret = val.Val as Element;
val.Dispose();
return ret;
}
}
set {
GLib.Value val = new GLib.Value(value);
SetProperty("video-sink", val);
val.Dispose();
}
}
[GLib.Property("vis-plugin")]
public Element VisPlugin {
get {
GLib.Value val = GetProperty("vis-plugin");
Element ret = val.Val as Element;
val.Dispose();
return ret;
}
[GLib.Property ("source")]
public Element Source {
get {
GLib.Value val = GetProperty ("source");
Element element = val.Val as Element;
val.Dispose ();
return element;
}
}
}
set {
GLib.Value val = new GLib.Value(value);
SetProperty("vis-plugin", val);
val.Dispose();
}
}
[GLib.Property("volume")]
public double Volume {
get {
GLib.Value val = GetProperty("volume");
double ret = (double)val.Val;
val.Dispose();
return ret;
}
set {
GLib.Value val = new GLib.Value(value);
SetProperty("volume", val);
val.Dispose();
}
}
}
}

View file

@ -1,10 +1,11 @@
EXTRA_DIST = \
gstreamer-parsable.diff
EXTRA_DIST = gstreamer-parsable.diff
MAINTAINERCLEANFILES = Makefile.in
get-source-code:
wget http://gstreamer.freedesktop.org/src/gstreamer/gstreamer-$(GSTREAMER_REQUIRED_VERSION).tar.gz --output-document=- | tar -xz
BASE_PATH="http://gstreamer.freedesktop.org/src"
update-source:
wget -O - $(BASE_PATH)/gstreamer/gstreamer-$(GSTREAMER_REQUIRED_VERSION).tar.gz | tar xz
wget -O - $(BASE_PATH)/gst-plugins-base/gst-plugins-base-$(GSTREAMER_REQUIRED_VERSION).tar.gz | tar xz
patch -p0 < gstreamer-parsable.diff
api:

57
tests/ApplicationTest.cs Normal file
View file

@ -0,0 +1,57 @@
//
// ApplicationTest.cs: NUnit Test Suite for gstreamer-sharp
//
// Authors:
// Aaron Bockover (abockover@novell.com)
//
// (C) 2006 Novell, Inc.
//
using System;
using NUnit.Framework;
[TestFixture]
public class ApplicationTest
{
[Test]
public void Init()
{
Gst.Application.Init();
Gst.Application.Deinit();
}
[Test]
public void InitArgs()
{
string [] args = { "arg_a", "arg_b" };
Gst.Application.Init("gstreamer-sharp-test", ref args);
Gst.Application.Deinit();
}
[Test]
public void InitArgsCheck()
{
string [] args = { "arg_a", "arg_b" };
Gst.Application.InitCheck("gstreamer-sharp-test", ref args);
Gst.Application.Deinit();
}
[Test]
public void TestVersion()
{
Assert.AreEqual(Gst.Application.Version.Minor, 10);
}
[Test]
public void TestVersionString()
{
Assert.IsNotNull(Gst.Application.Version.ToString());
}
[Test]
public void TestVersionDescription()
{
Assert.IsNotNull(Gst.Application.Version.Description);
}
}

61
tests/BinTest.cs Normal file
View file

@ -0,0 +1,61 @@
//
// BinTest.cs: NUnit Test Suite for gstreamer-sharp
//
// Authors:
// Aaron Bockover (abockover@novell.com)
//
// (C) 2006 Novell, Inc.
//
using System;
using NUnit.Framework;
using Gst;
[TestFixture]
public class BinTest
{
[TestFixtureSetUp]
public void Init()
{
Application.Init();
}
[TestFixtureTearDown]
public void Deinit()
{
Application.Deinit();
}
[Test]
public void TestAddMany()
{
Bin bin = new Bin("test-bin");
Element e1 = ElementFactory.Make("fakesrc", "fakesrc");
Element e2 = ElementFactory.Make("fakesink", "fakesink");
bin.AddMany(e1, e2);
Assert.AreEqual(bin.List.Length, 2);
e1.Dispose();
e2.Dispose();
bin.Dispose();
}
[Test]
public void TestGetByName()
{
Bin bin = new Bin("test-bin");
Element e1 = ElementFactory.Make("fakesrc", "element-name");
bin.Add(e1);
e1 = bin.GetByName("element-name");
Assert.IsNotNull(e1);
Assert.AreEqual(e1.Name, "element-name");
e1.Dispose();
bin.Dispose();
}
}

421
tests/ConsoleUi.cs Normal file
View file

@ -0,0 +1,421 @@
#region Copyright (c) 2002-2003, James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole, Philip A. Craig
/************************************************************************************
'
' Copyright © 2002-2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
' Copyright © 2000-2003 Philip A. Craig
'
' This software is provided 'as-is', without any express or implied warranty. In no
' event will the authors be held liable for any damages arising from the use of this
' software.
'
' Permission is granted to anyone to use this software for any purpose, including
' commercial applications, and to alter it and redistribute it freely, subject to the
' following restrictions:
'
' 1. The origin of this software must not be misrepresented; you must not claim that
' you wrote the original software. If you use this software in a product, an
' acknowledgment (see the following) in the product documentation is required.
'
' Portions Copyright © 2003 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov, Charlie Poole
' or Copyright © 2000-2003 Philip A. Craig
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
'
' 3. This notice may not be removed or altered from any source distribution.
'
'***********************************************************************************/
#endregion
namespace NUnit.Console
{
using System;
using System.Collections;
using System.Collections.Specialized;
using System.IO;
using System.Reflection;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;
using System.Resources;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using NUnit.Core;
using NUnit.Util;
/// <summary>
/// Summary description for ConsoleUi.
/// </summary>
public class ConsoleUi
{
[STAThread]
public static int Main(string[] args)
{
ConsoleOptions options = new ConsoleOptions(args);
if(!options.nologo)
WriteCopyright();
if(options.help)
{
options.Help();
return 0;
}
if(options.NoArgs)
{
Console.Error.WriteLine("fatal error: no inputs specified");
options.Help();
return 0;
}
if(!options.Validate())
{
Console.Error.WriteLine("fatal error: invalid arguments");
options.Help();
return 2;
}
try
{
ConsoleUi consoleUi = new ConsoleUi();
consoleUi.Execute( options );
return 0;
}
catch( FileNotFoundException ex )
{
Console.WriteLine( ex.Message );
return 2;
}
catch( BadImageFormatException ex )
{
Console.WriteLine( ex.Message );
return 2;
}
catch( Exception ex )
{
Console.WriteLine( "Unhandled Exception:\n{0}", ex.ToString() );
return 2;
}
finally
{
if(options.wait)
{
Console.Out.WriteLine("\nHit <enter> key to continue");
Console.ReadLine();
}
}
}
private static XmlTextReader GetTransformReader(ConsoleOptions parser)
{
XmlTextReader reader = null;
if(!parser.IsTransform)
{
Assembly assembly = Assembly.GetAssembly(typeof(XmlResultVisitor));
ResourceManager resourceManager = new ResourceManager("NUnit.Util.Transform",assembly);
string xmlData = (string)resourceManager.GetObject("Summary.xslt");
reader = new XmlTextReader(new StringReader(xmlData));
}
else
{
FileInfo xsltInfo = new FileInfo(parser.transform);
if(!xsltInfo.Exists)
{
Console.Error.WriteLine("Transform file: {0} does not exist", xsltInfo.FullName);
reader = null;
}
else
{
reader = new XmlTextReader(xsltInfo.FullName);
}
}
return reader;
}
private static void WriteCopyright()
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
System.Version version = executingAssembly.GetName().Version;
string clrPlatform = Type.GetType("Mono.Runtime", false) == null ? ".NET" : "Mono";
Console.WriteLine( string.Format("OS Version: {0} {1} Version: {2}",
Environment.OSVersion, clrPlatform, Environment.Version ) );
Console.WriteLine();
}
private static Test MakeTestFromCommandLine(TestDomain testDomain, ConsoleOptions parser)
{
NUnitProject project;
if ( parser.IsTestProject )
{
project = NUnitProject.LoadProject( (string)parser.Parameters[0] );
string configName = (string) parser.config;
if ( configName != null )
project.SetActiveConfig( configName );
}
else
project = NUnitProject.FromAssemblies( (string[])parser.Parameters.ToArray( typeof( string ) ) );
return testDomain.Load( project, parser.fixture );
}
public ConsoleUi()
{
}
public int Execute( ConsoleOptions options )
{
XmlTextReader transformReader = GetTransformReader(options);
if(transformReader == null) return 3;
ConsoleWriter outStream = options.isOut
? new ConsoleWriter( new StreamWriter( options.output ) )
: new ConsoleWriter(Console.Out);
ConsoleWriter errorStream = options.isErr
? new ConsoleWriter( new StreamWriter( options.err ) )
: new ConsoleWriter(Console.Error);
TestDomain testDomain = new TestDomain(outStream, errorStream);
if ( options.noshadow ) testDomain.ShadowCopyFiles = false;
Test test = MakeTestFromCommandLine(testDomain, options);
if(test == null)
{
Console.Error.WriteLine("Unable to locate fixture {0}", options.fixture);
return 2;
}
Directory.SetCurrentDirectory(new FileInfo((string)options.Parameters[0]).DirectoryName);
EventListener collector = new EventCollector( options, outStream );
string savedDirectory = Environment.CurrentDirectory;
if (options.HasInclude)
{
Console.WriteLine( "Included categories: " + options.include );
testDomain.SetFilter( new CategoryFilter( options.IncludedCategories ) );
}
else if ( options.HasExclude )
{
Console.WriteLine( "Excluded categories: " + options.exclude );
testDomain.SetFilter( new CategoryFilter( options.ExcludedCategories, true ) );
}
TestResult result = null;
if ( options.thread )
{
testDomain.RunTest( collector );
testDomain.Wait();
result = testDomain.Result;
}
else
{
result = testDomain.Run( collector );
}
Directory.SetCurrentDirectory( savedDirectory );
Console.WriteLine();
string xmlOutput = CreateXmlOutput( result );
if (options.xmlConsole)
Console.WriteLine(xmlOutput);
else
CreateSummaryDocument(xmlOutput, transformReader);
// Write xml output here
string xmlResultFile = options.IsXml ? options.xml : "TestResult.xml";
using ( StreamWriter writer = new StreamWriter( xmlResultFile ) )
{
writer.Write(xmlOutput);
}
if ( testDomain != null )
testDomain.Unload();
return result.IsFailure ? 1 : 0;
}
private string CreateXmlOutput( TestResult result )
{
StringBuilder builder = new StringBuilder();
XmlResultVisitor resultVisitor = new XmlResultVisitor(new StringWriter( builder ), result);
result.Accept(resultVisitor);
resultVisitor.Write();
return builder.ToString();
}
private void CreateSummaryDocument(string xmlOutput, XmlTextReader transformReader)
{
XPathDocument originalXPathDocument = new XPathDocument(new StringReader(xmlOutput));
XslTransform summaryXslTransform = new XslTransform();
// Using obsolete form for now, remove warning suppression from project after changing
summaryXslTransform.Load(transformReader);
// Using obsolete form for now, remove warning suppression from project after changing
summaryXslTransform.Transform(originalXPathDocument,null,Console.Out);
}
#region Nested Class to Handle Events
private class EventCollector : LongLivingMarshalByRefObject, EventListener
{
private int testRunCount;
private int testIgnoreCount;
private int failureCount;
private int level;
private ConsoleOptions options;
private ConsoleWriter writer;
StringCollection messages;
private bool debugger = false;
private string currentTestName;
public EventCollector( ConsoleOptions options, ConsoleWriter writer )
{
debugger = Debugger.IsAttached;
level = 0;
this.options = options;
this.writer = writer;
this.currentTestName = string.Empty;
}
public void RunStarted(Test[] tests)
{
}
public void RunFinished(TestResult[] results)
{
}
public void RunFinished(Exception exception)
{
}
public void TestFinished(TestCaseResult testResult)
{
if ( !options.xmlConsole && !options.labels )
{
if(testResult.Executed)
{
testRunCount++;
if(testResult.IsFailure)
{
failureCount++;
Console.Write("F");
if ( debugger )
{
messages.Add( string.Format( "{0}) {1} :", failureCount, testResult.Test.FullName ) );
messages.Add( testResult.Message.Trim( Environment.NewLine.ToCharArray() ) );
string stackTrace = StackTraceFilter.Filter( testResult.StackTrace );
string[] trace = stackTrace.Split( System.Environment.NewLine.ToCharArray() );
foreach( string s in trace )
{
if ( s != string.Empty )
{
string link = Regex.Replace( s.Trim(), @".* in (.*):line (.*)", "$1($2)");
messages.Add( string.Format( "at\n{0}", link ) );
}
}
}
}
}
else
{
testIgnoreCount++;
Console.Write("N");
}
}
currentTestName = string.Empty;
}
public void TestStarted(TestCase testCase)
{
currentTestName = testCase.FullName;
if ( options.labels )
writer.WriteLine("***** {0}", testCase.FullName );
else if ( !options.xmlConsole )
Console.Write(".");
}
public void SuiteStarted(TestSuite suite)
{
if ( debugger && level++ == 0 )
{
messages = new StringCollection();
testRunCount = 0;
testIgnoreCount = 0;
failureCount = 0;
Trace.WriteLine( "################################ UNIT TESTS ################################" );
Trace.WriteLine( "Running tests in '" + suite.FullName + "'..." );
}
}
public void SuiteFinished(TestSuiteResult suiteResult)
{
if ( debugger && --level == 0)
{
Trace.WriteLine( "############################################################################" );
if (messages.Count == 0)
{
Trace.WriteLine( "############## S U C C E S S #################" );
}
else
{
Trace.WriteLine( "############## F A I L U R E S #################" );
foreach ( string s in messages )
{
Trace.WriteLine(s);
}
}
Trace.WriteLine( "############################################################################" );
Trace.WriteLine( "Executed tests : " + testRunCount );
Trace.WriteLine( "Ignored tests : " + testIgnoreCount );
Trace.WriteLine( "Failed tests : " + failureCount );
Trace.WriteLine( "Total time : " + suiteResult.Time + " seconds" );
Trace.WriteLine( "############################################################################");
}
}
public void UnhandledException( Exception exception )
{
string msg = string.Format( "##### Unhandled Exception while running {0}", currentTestName );
// If we do labels, we already have a newline
if ( !options.labels ) writer.WriteLine();
writer.WriteLine( msg );
writer.WriteLine( exception.ToString() );
if ( debugger )
{
Trace.WriteLine( msg );
Trace.WriteLine( exception.ToString() );
}
}
}
#endregion
}
}

23
tests/Makefile.am Normal file
View file

@ -0,0 +1,23 @@
MCS_FLAGS = -debug
NUNIT_FLAGS = @MONO_NUNIT_LIBS@
ASSEMBLY_NAME = gstreamer-tests
ASSEMBLY = $(ASSEMBLY_NAME).dll
ASSEMBLY_CSFILES = $(srcdir)/ApplicationTest.cs $(srcdir)/BinTest.cs
NUNIT_TESTER_NAME = ConsoleUi
NUNIT_TESTER = $(NUNIT_TESTER_NAME).exe
NUNIT_TESTER_CSFILES = $(srcdir)/$(NUNIT_TESTER_NAME).cs
$(ASSEMBLY): $(ASSEMBLY_CSFILES)
$(CSC) $(MCS_FLAGS) $(NUNIT_FLAGS) -out:$@ -target:library -r:$(top_builddir)/gstreamer-sharp/gstreamer-sharp.dll $(ASSEMBLY_CSFILES)
$(NUNIT_TESTER): $(NUNIT_TESTER_CSFILES)
$(CSC) $(MCS_FLAGS) -out:$@ $(NUNIT_FLAGS) $(NUNIT_TESTER_CSFILES)
run-test: $(NUNIT_TESTER) $(ASSEMBLY)
MONO_PATH="../gstreamer-sharp/" mono --debug $(NUNIT_TESTER) $(ASSEMBLY)
CLEANFILES = $(ASSEMBLY) $(NUNIT_TESTER) TestResult.xml
DISTCLEANFILES = *.mdb Makefile.in *.dll *.exe