Make everything compilable again

This commit is contained in:
Sebastian Dröge 2009-04-04 13:33:40 +02:00
parent a6ca2de622
commit 615b619bd0
7 changed files with 243 additions and 14 deletions

View file

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

View file

@ -144,6 +144,7 @@ fi
AC_OUTPUT([
source/Makefile
fixup/Makefile
gstreamer-sharp/Makefile
gstreamer-sharp/AssemblyInfo.cs
gstreamer-sharp/gstreamer-sharp.dll.config

219
fixup/gst-gapi-fixup.cs Normal file
View file

@ -0,0 +1,219 @@
// gst-gapi-fixup.cs - xml alteration engine.
//
// Author: Mike Kestner <mkestner@speakeasy.net>
//
// Copyright (c) 2003 Mike Kestner
// Copyright (c) 2009 Sebastian Dröge
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2 of the GNU General Public
// License as published by the Free Software Foundation.
//
// 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., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
namespace GtkSharp.Parsing {
using System;
using System.IO;
using System.Xml;
using System.Xml.XPath;
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;
}
string api_filename = "";
XmlDocument api_doc = new XmlDocument ();
XmlDocument meta_doc = new XmlDocument ();
XmlDocument symbol_doc = new XmlDocument ();
foreach (string arg in args) {
if (arg.StartsWith("--metadata=")) {
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;
}
} else if (arg.StartsWith ("--api=")) {
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;
}
} else if (arg.StartsWith ("--symbols=")) {
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;
}
} else {
Console.WriteLine ("Usage: gapi-fixup --metadata=<filename> --api=<filename>");
return 1;
}
}
XPathNavigator meta_nav = meta_doc.CreateNavigator ();
XPathNavigator api_nav = api_doc.CreateNavigator ();
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 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 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 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);
}
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;
XmlAttribute attr = node.Attributes[name];
Console.WriteLine (attr);
if (attr != null)
node.Attributes.Remove (attr);
matched = true;
}
if (!matched)
Console.WriteLine ("Warning: <remove-attr 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);
}
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;
}
}
}

View file

@ -47,18 +47,19 @@
<attr path="/api/namespace/object[@name='GhostPad']" name="parent">GstPad</attr>
<change-node-type path="/api/namespace/object[@name='Event']">boxed</change-node-type>
<remove-attr path="/api/namespace/object[@name='Event']" name="parent" />
<attr path="/api/namespace/object[@name='Event']" name="opaque">true</attr>
<change-node-type path="/api/namespace/object[@name='Buffer']">boxed</change-node-type>
<remove-attr path="/api/namespace/object[@name='Buffer']" name="parent" />
<attr path="/api/namespace/object[@name='Buffer']" name="opaque">true</attr>
<change-node-type path="/api/namespace/object[@name='Message']">boxed</change-node-type>
<remove-attr path="/api/namespace/object[@name='Message']" name="parent" />
<attr path="/api/namespace/object[@name='Message']" name="opaque">true</attr>
<change-node-type path="/api/namespace/object[@name='Query']">boxed</change-node-type>
<remove-attr path="/api/namespace/object[@name='Query']" name="parent" />
<attr path="/api/namespace/object[@name='Query']" name="opaque">true</attr>
<remove-node path="/api/namespace/object[@cname='GstMiniObject']" />
<change-node-type path="/api/namespace/object[@name='MiniObject']">boxed</change-node-type>
<attr path="/api/namespace/object[@name='MiniObject']" name="opaque">true</attr>
<remove-attr path="/api/namespace/boxed[@name='MiniObject']" name="parent" />
<remove-node path="/api/namespace/boxed[@name='MiniObject']/constructor[@cname='gst_mini_object_new']" />
<!-- <remove-node path="/api/namespace/object[@cname='GstMiniObject']" /> -->
<!-- We implement this ourselves, using the overload that keeps the callback from getting GCed -->
<attr path="/api/namespace/object[@name='Bus']/method[@name='AddWatch']" name="hidden">true</attr>
@ -190,6 +191,10 @@
<attr path="/api/namespace/boxed[@name='TagList']/method[@name='GetChar']/*/*[@name='value']" name="pass_as">out</attr>
<attr path="/api/namespace/boxed[@name='TagList']/method[@name='GetCharIndex']/*/*[@name='value']" name="pass_as">out</attr>
<attr path="/api/namespace/boxed[@name='TagList']/method[@name='GetUlong']/*/*[@name='value']" name="pass_as">out</attr>
<attr path="/api/namespace/interface[@name='ChildProxy']/method[@name='ChildAdded']" name="name">EmitChildAdded</attr>
<attr path="/api/namespace/interface[@name='ChildProxy']/method[@name='ChildRemoved']" name="name">EmitChildRemoved</attr>
<attr path="/api/namespace/callback[@name='IteratorNextFunction']/parameters/parameter[@name='result']" name="name">res</attr>
<!--
<attr path="/api/namespace/boxed[@name='Plugin']/field[@name='Filename']" name="hidden">1</attr>
<attr path="/api/namespace/boxed[@name='Structure']/field[@name='Name']" name="hidden">1</attr>

View file

@ -59,7 +59,8 @@ customs = \
Element.custom \
Message.custom \
Pad.custom \
Object.custom
Object.custom \
MiniObject.custom
build_customs = $(addprefix $(srcdir)/, $(customs))
@ -75,7 +76,7 @@ EXTRA_DIST = \
$(API): $(srcdir)/$(RAW_API) $(srcdir)/$(METADATA) $(srcdir)/$(SYMBOLS)
cp $(srcdir)/$(RAW_API) $(API)
chmod u+w $(API)
$(GAPI_FIXUP) --api=$(API) --metadata=$(srcdir)/$(METADATA) \
$(MONO) $(top_builddir)/fixup/gst-gapi-fixup.exe --api=$(API) --metadata=$(srcdir)/$(METADATA) \
--symbols=$(srcdir)/$(SYMBOLS)
generated-stamp: $(API) $(GAPI_CODEGEN) $(build_customs)

View file

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

View file

@ -170,8 +170,8 @@ public class DecodeBinTranscoder : IDisposable
DecodeBinTranscoder transcoder = new DecodeBinTranscoder();
transcoder.Error += delegate(object o, ErrorArgs args) {
Console.WriteLine("Error: {0}", args.Error);
transcoder.Error += delegate(object o, ErrorArgs eargs) {
Console.WriteLine("Error: {0}", eargs.Error);
transcoder.Dispose();
loop.Quit();
};
@ -182,11 +182,11 @@ public class DecodeBinTranscoder : IDisposable
loop.Quit();
};
transcoder.Progress += delegate(object o, ProgressArgs args) {
transcoder.Progress += delegate(object o, ProgressArgs pargs) {
Console.Write("\rEncoding: {0} / {1} ({2:00.00}%) ",
new TimeSpan((args.Position / (long) Clock.Second) * TimeSpan.TicksPerSecond),
new TimeSpan((args.Duration / (long) Clock.Second) * TimeSpan.TicksPerSecond),
((double)args.Position / (double)args.Duration) * 100.0);
new TimeSpan((pargs.Position / (long) Clock.Second) * TimeSpan.TicksPerSecond),
new TimeSpan((pargs.Duration / (long) Clock.Second) * TimeSpan.TicksPerSecond),
((double)pargs.Position / (double)pargs.Duration) * 100.0);
};
transcoder.Transcode(args[0], args[1]);