mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 11:41:09 +00:00
Make it possible to extract example code from separate blocks.
Original commit message from CVS: * docs/manual/dynamic.xml: * docs/manual/elements-api.xml: * docs/manual/gnome.xml: * docs/manual/helloworld2.xml: * docs/manual/init-api.xml: * docs/manual/queues.xml: * docs/manual/threads.xml: * docs/manual/xml.xml: * examples/manual/extract.pl: Make it possible to extract example code from separate blocks. Should make Ronald happy.
This commit is contained in:
parent
d960f7f99e
commit
c1ab023379
16 changed files with 167 additions and 96 deletions
26
ChangeLog
26
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2004-12-15 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* docs/manual/dynamic.xml:
|
||||
* docs/manual/elements-api.xml:
|
||||
* docs/manual/gnome.xml:
|
||||
* docs/manual/helloworld2.xml:
|
||||
* docs/manual/init-api.xml:
|
||||
* docs/manual/queues.xml:
|
||||
* docs/manual/threads.xml:
|
||||
* docs/manual/xml.xml:
|
||||
* examples/manual/extract.pl:
|
||||
Make it possible to extract example code from separate blocks.
|
||||
Should make Ronald happy.
|
||||
|
||||
2004-12-15 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* gst/schedulers/gstoptimalscheduler.c: (add_to_group),
|
||||
|
@ -215,8 +229,8 @@
|
|||
2004-11-29 Stefan Kost <ensonic@users.sf.net>
|
||||
|
||||
* docs/manual/programs.xml:
|
||||
Added a first batch of gst-launch examples, as provided by Ronald
|
||||
and others from the devel-mlist
|
||||
Added a first batch of gst-launch examples, as provided by Ronald
|
||||
and others from the devel-mlist
|
||||
|
||||
2004-11-28 Benjamin Otte <otte@gnome.org>
|
||||
|
||||
|
@ -368,7 +382,7 @@
|
|||
* testsuite/schedulers/.cvsignore:
|
||||
* testsuite/schedulers/Makefile.am:
|
||||
* testsuite/schedulers/queue_link.c: (main):
|
||||
Added testcase for schduler segfault.
|
||||
Added testcase for scheduler segfault.
|
||||
Fix scheduler segfault when removing a decoupled
|
||||
entry point as the last element from a group.
|
||||
|
||||
|
@ -402,7 +416,7 @@
|
|||
* docs/gst/tmpl/gstutils.sgml:
|
||||
* docs/random/ensonic/interfaces.txt:
|
||||
* gst/gstinfo.h:
|
||||
added some more docs, removed two obsolete defines
|
||||
added some more docs, removed two obsolete defines
|
||||
|
||||
2004-11-02 Kjartan Maraas <as at gnome.org>
|
||||
|
||||
|
@ -438,7 +452,7 @@
|
|||
|
||||
* gst/schedulers/gstoptimalscheduler.c: (add_to_group),
|
||||
(gst_opt_scheduler_iterate):
|
||||
Aplied patch #154061. Running a pipeline in which an element
|
||||
Applied patch #154061. Running a pipeline in which an element
|
||||
calls GST_ELEMENT_ERROR in the chain function, the opt
|
||||
scheduler doesn't unref the chain so it never gets freed.
|
||||
|
||||
|
@ -472,7 +486,7 @@
|
|||
2004-10-22 Stefan Kost <ensonic@users.sf.net>
|
||||
|
||||
* docs/pwg/building-boiler.xml:
|
||||
exchanged GTK_ macros with G_TYPE macros (as pointed out by mathrick)
|
||||
exchanged GTK_ macros with G_TYPE macros (as pointed out by mathrick)
|
||||
|
||||
2004-10-19 Wim Taymans <wim at fluendo dot com>
|
||||
|
||||
|
|
|
@ -82,8 +82,9 @@
|
|||
|
||||
<para>
|
||||
<programlisting>
|
||||
/* example-begin threads.c */
|
||||
#include <gst/gst.h>
|
||||
<!-- example-begin threads.c a -->
|
||||
<![CDATA[
|
||||
#include <gst/gst.h>
|
||||
|
||||
/* we set this to TRUE right before gst_main (), but there could still
|
||||
be a race condition between setting it and entering the function */
|
||||
|
@ -161,7 +162,8 @@ main (int argc, char *argv[])
|
|||
|
||||
exit (0);
|
||||
}
|
||||
/* example-end threads.c */
|
||||
]]>
|
||||
<!-- example-end threads.c a -->
|
||||
</programlisting>
|
||||
</para>
|
||||
</sect1>
|
||||
|
|
|
@ -23,9 +23,10 @@
|
|||
</para>
|
||||
|
||||
<programlisting>
|
||||
/* example-begin gnome.c */
|
||||
#include <gnome.h>
|
||||
#include <gst/gst.h>
|
||||
<!-- example-begin gnome.c a -->
|
||||
<![CDATA[
|
||||
#include <gnome.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
|
@ -78,7 +79,8 @@ main (int argc, char **argv)
|
|||
|
||||
return 0;
|
||||
}
|
||||
/* example-end gnome.c */
|
||||
]]>
|
||||
<!-- example-end gnome.c a -->
|
||||
</programlisting>
|
||||
<para>
|
||||
If you try out this program, you will see that when called with
|
||||
|
|
|
@ -23,9 +23,10 @@
|
|||
</para>
|
||||
|
||||
<programlisting>
|
||||
/* example-begin gnome.c */
|
||||
#include <gnome.h>
|
||||
#include <gst/gst.h>
|
||||
<!-- example-begin gnome.c a -->
|
||||
<![CDATA[
|
||||
#include <gnome.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
|
@ -78,7 +79,8 @@ main (int argc, char **argv)
|
|||
|
||||
return 0;
|
||||
}
|
||||
/* example-end gnome.c */
|
||||
]]>
|
||||
<!-- example-end gnome.c a -->
|
||||
</programlisting>
|
||||
<para>
|
||||
If you try out this program, you will see that when called with
|
||||
|
|
|
@ -19,9 +19,8 @@
|
|||
</para>
|
||||
|
||||
<programlisting>
|
||||
<!-- example-begin init.c a -->
|
||||
<![CDATA[
|
||||
/* example-begin init.c */
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
int
|
||||
|
@ -37,8 +36,8 @@ main (int argc, char *argv[])
|
|||
|
||||
return 0;
|
||||
}
|
||||
/* example-end init.c */
|
||||
]]>
|
||||
<!-- example-end init.c a -->
|
||||
</programlisting>
|
||||
<para>
|
||||
Use the <symbol>GST_VERSION_MAJOR</symbol>,
|
||||
|
@ -60,9 +59,9 @@ You can also use a popt table to initialize your own parameters as shown in the
|
|||
next example:
|
||||
</para>
|
||||
<programlisting>
|
||||
/* example-begin popt.c */
|
||||
|
||||
#include <gst/gst.h>
|
||||
<!-- example-begin popt.c a -->
|
||||
<![CDATA[
|
||||
#include <gst/gst.h>
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
|
@ -83,7 +82,9 @@ main(int argc, char *argv[])
|
|||
|
||||
return 0;
|
||||
}
|
||||
/* example-end popt.c */
|
||||
]]>
|
||||
<!-- example-end popt.c a -->
|
||||
|
||||
</programlisting>
|
||||
<para>
|
||||
As shown in this fragment, you can use a <ulink
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
We'll start with a simple main function:
|
||||
</para>
|
||||
<programlisting>
|
||||
|
||||
/* example-begin dynamic.c */
|
||||
#include <string.h>
|
||||
#include <gst/gst.h>
|
||||
<!-- example-begin dynamic.c a -->
|
||||
<![CDATA[
|
||||
#include <string.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
void
|
||||
eof (GstElement *src)
|
||||
|
@ -164,7 +164,8 @@ main (int argc, char *argv[])
|
|||
|
||||
return 0;
|
||||
}
|
||||
/* example-end dynamic.c */
|
||||
]]>
|
||||
<!-- example-end dynamic.c a -->
|
||||
</programlisting>
|
||||
<para>
|
||||
We create two elements: a file source and an MPEG demuxer.
|
||||
|
|
|
@ -31,8 +31,8 @@ The following example &EXAFOOT; shows how to create an element named
|
|||
After checking, it unrefs the element.
|
||||
</para>
|
||||
<programlisting>
|
||||
<!-- example-begin elementmake.c a -->
|
||||
<![CDATA[
|
||||
/* example-begin elementmake.c */
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
|
@ -44,7 +44,11 @@ main (int argc, char *argv[])
|
|||
gst_init (&argc, &argv);
|
||||
|
||||
element = gst_element_factory_make ("fakesrc", "source");
|
||||
]]>
|
||||
<!-- example-end elementmake.c a -->
|
||||
|
||||
<!-- example-begin elementmake.c b -->
|
||||
<![CDATA[
|
||||
if (!element) {
|
||||
g_error ("Could not create an element from 'fakesrc' factory.\n");
|
||||
}
|
||||
|
@ -53,9 +57,8 @@ main (int argc, char *argv[])
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* example-end elementmake.c */
|
||||
]]>
|
||||
<!-- example-end elementmake.c b -->
|
||||
</programlisting>
|
||||
<para>
|
||||
<function>gst_element_factory_make</function> is actually a shorthand
|
||||
|
@ -121,9 +124,8 @@ will use the element factory to create an element with the given name.
|
|||
<classname>GObject</classname> property mechanism as shown below.
|
||||
</para>
|
||||
<programlisting>
|
||||
<!-- example-begin elementget.c a -->
|
||||
<![CDATA[
|
||||
/* example-begin elementget.c */
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
int
|
||||
|
@ -143,9 +145,8 @@ main (int argc, char *argv[])
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* example-end elementget.c */
|
||||
]]>
|
||||
<!-- example-end elementget.c a -->
|
||||
</programlisting>
|
||||
<para>
|
||||
Most plugins provide additional properties to provide more information
|
||||
|
|
|
@ -23,9 +23,10 @@
|
|||
</para>
|
||||
|
||||
<programlisting>
|
||||
/* example-begin gnome.c */
|
||||
#include <gnome.h>
|
||||
#include <gst/gst.h>
|
||||
<!-- example-begin gnome.c a -->
|
||||
<![CDATA[
|
||||
#include <gnome.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
|
@ -78,7 +79,8 @@ main (int argc, char **argv)
|
|||
|
||||
return 0;
|
||||
}
|
||||
/* example-end gnome.c */
|
||||
]]>
|
||||
<!-- example-end gnome.c a -->
|
||||
</programlisting>
|
||||
<para>
|
||||
If you try out this program, you will see that when called with
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
</para>
|
||||
|
||||
<programlisting>
|
||||
/* example-begin helloworld2.c */
|
||||
#include <gst/gst.h>
|
||||
<!-- example-begin helloworld2.c a -->
|
||||
<![CDATA[
|
||||
#include <gst/gst.h>
|
||||
|
||||
static void gst_play_have_type (GstElement *typefind, GstCaps *caps, GstElement *pipeline);
|
||||
static void gst_play_cache_empty (GstElement *element, GstElement *pipeline);
|
||||
|
@ -156,7 +157,8 @@ main (int argc, char *argv[])
|
|||
|
||||
exit(0);
|
||||
}
|
||||
/* example-end helloworld2.c */
|
||||
]]>
|
||||
<!-- example-end helloworld2.c a -->
|
||||
</programlisting>
|
||||
<para>
|
||||
We start by constructing a 'filesrc' element and an 'autobin' element that
|
||||
|
|
|
@ -24,9 +24,11 @@
|
|||
</para>
|
||||
|
||||
<programlisting>
|
||||
/* example-begin xml-mp3.c */
|
||||
#include <stdlib.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
<!-- example-begin xml-mp3.c a -->
|
||||
<![CDATA[
|
||||
#include <stdlib.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
gboolean playing;
|
||||
|
||||
|
@ -88,7 +90,8 @@ main (int argc, char *argv[])
|
|||
|
||||
exit (0);
|
||||
}
|
||||
/* example-end xml-mp3.c */
|
||||
]]>
|
||||
<!-- example-end xml-mp3.c a -->
|
||||
</programlisting>
|
||||
<para>
|
||||
The most important line is:
|
||||
|
|
|
@ -19,9 +19,8 @@
|
|||
</para>
|
||||
|
||||
<programlisting>
|
||||
<!-- example-begin init.c a -->
|
||||
<![CDATA[
|
||||
/* example-begin init.c */
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
int
|
||||
|
@ -37,8 +36,8 @@ main (int argc, char *argv[])
|
|||
|
||||
return 0;
|
||||
}
|
||||
/* example-end init.c */
|
||||
]]>
|
||||
<!-- example-end init.c a -->
|
||||
</programlisting>
|
||||
<para>
|
||||
Use the <symbol>GST_VERSION_MAJOR</symbol>,
|
||||
|
@ -60,9 +59,9 @@ You can also use a popt table to initialize your own parameters as shown in the
|
|||
next example:
|
||||
</para>
|
||||
<programlisting>
|
||||
/* example-begin popt.c */
|
||||
|
||||
#include <gst/gst.h>
|
||||
<!-- example-begin popt.c a -->
|
||||
<![CDATA[
|
||||
#include <gst/gst.h>
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
|
@ -83,7 +82,9 @@ main(int argc, char *argv[])
|
|||
|
||||
return 0;
|
||||
}
|
||||
/* example-end popt.c */
|
||||
]]>
|
||||
<!-- example-end popt.c a -->
|
||||
|
||||
</programlisting>
|
||||
<para>
|
||||
As shown in this fragment, you can use a <ulink
|
||||
|
|
|
@ -46,9 +46,10 @@
|
|||
</para>
|
||||
|
||||
<programlisting>
|
||||
/* example-begin queue.c */
|
||||
#include <stdlib.h>
|
||||
#include <gst/gst.h>
|
||||
<!-- example-begin queue.c a -->
|
||||
<![CDATA[
|
||||
#include <stdlib.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
gboolean playing;
|
||||
|
||||
|
@ -121,9 +122,7 @@ main (int argc, char *argv[])
|
|||
|
||||
return 0;
|
||||
}
|
||||
/* example-end queue.c */
|
||||
]]>
|
||||
<!-- example-end queue.c a -->
|
||||
</programlisting>
|
||||
|
||||
|
||||
|
||||
</chapter>
|
||||
|
|
|
@ -82,8 +82,9 @@
|
|||
|
||||
<para>
|
||||
<programlisting>
|
||||
/* example-begin threads.c */
|
||||
#include <gst/gst.h>
|
||||
<!-- example-begin threads.c a -->
|
||||
<![CDATA[
|
||||
#include <gst/gst.h>
|
||||
|
||||
/* we set this to TRUE right before gst_main (), but there could still
|
||||
be a race condition between setting it and entering the function */
|
||||
|
@ -161,7 +162,8 @@ main (int argc, char *argv[])
|
|||
|
||||
exit (0);
|
||||
}
|
||||
/* example-end threads.c */
|
||||
]]>
|
||||
<!-- example-end threads.c a -->
|
||||
</programlisting>
|
||||
</para>
|
||||
</sect1>
|
||||
|
|
|
@ -24,9 +24,11 @@
|
|||
</para>
|
||||
|
||||
<programlisting>
|
||||
/* example-begin xml-mp3.c */
|
||||
#include <stdlib.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
<!-- example-begin xml-mp3.c a -->
|
||||
<![CDATA[
|
||||
#include <stdlib.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
gboolean playing;
|
||||
|
||||
|
@ -88,7 +90,8 @@ main (int argc, char *argv[])
|
|||
|
||||
exit (0);
|
||||
}
|
||||
/* example-end xml-mp3.c */
|
||||
]]>
|
||||
<!-- example-end xml-mp3.c a -->
|
||||
</programlisting>
|
||||
<para>
|
||||
The most important line is:
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
# main
|
||||
|
||||
# decodes xml by translating & < > back to what they should be
|
||||
# and also ignore
|
||||
# <![CDATA[
|
||||
# and
|
||||
# ]]>
|
||||
sub
|
||||
xml_decode ($)
|
||||
{
|
||||
|
@ -16,6 +20,10 @@ xml_decode ($)
|
|||
$input =~ s/</</g;
|
||||
$input =~ s/>/>/g;
|
||||
|
||||
if ($input =~ /<!\[CDATA\[/) { $input = ""; }
|
||||
if ($input =~ /]]>/) { $input = ""; }
|
||||
|
||||
#print "Returning line $input";
|
||||
return $input;
|
||||
}
|
||||
|
||||
|
@ -23,6 +31,7 @@ xml_decode ($)
|
|||
my $output = shift @ARGV;
|
||||
|
||||
$found = 0;
|
||||
%blocks = ();
|
||||
|
||||
foreach $file (@ARGV)
|
||||
{
|
||||
|
@ -30,31 +39,40 @@ foreach $file (@ARGV)
|
|||
|
||||
while ($line = <FILE>)
|
||||
{
|
||||
if ($line =~ /\/\* example-begin $output \*\//)
|
||||
if ($line =~ /<!-- example-begin $output (.*) -->/)
|
||||
{
|
||||
print "Extracting $output from $file\n";
|
||||
$found = 1;
|
||||
open OUTPUT, ">$output";
|
||||
print OUTPUT xml_decode ($line);
|
||||
my $example = 1;
|
||||
while (($line = <FILE>) && $example)
|
||||
$block_id = $1;
|
||||
$block = "\n/*** block $block_id from $file ***/\n";
|
||||
|
||||
print "Extracting $output block $block_id from $file\n";
|
||||
|
||||
while ($line = <FILE>)
|
||||
{
|
||||
if ($line =~ /\/\* example-end/)
|
||||
if ($line =~ /<!-- example-end $output (.*) -->/)
|
||||
{
|
||||
print OUTPUT xml_decode ($line);
|
||||
close OUTPUT;
|
||||
$example = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
print OUTPUT xml_decode ($line);
|
||||
last;
|
||||
}
|
||||
$block .= xml_decode ($line);
|
||||
}
|
||||
$blocks{$block_id} = $block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$found)
|
||||
{
|
||||
print "Could not find $output example !\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
# now output all the blocks in the right order
|
||||
open OUTPUT, ">$output";
|
||||
@block_ids = keys %blocks;
|
||||
foreach $block_id (sort @block_ids)
|
||||
{
|
||||
print "Writing block with id $block_id\n";
|
||||
print OUTPUT $blocks{$block_id};
|
||||
}
|
||||
close OUTPUT;
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
# main
|
||||
|
||||
# decodes xml by translating & < > back to what they should be
|
||||
# and also ignore
|
||||
# <![CDATA[
|
||||
# and
|
||||
# ]]>
|
||||
sub
|
||||
xml_decode ($)
|
||||
{
|
||||
|
@ -16,6 +20,10 @@ xml_decode ($)
|
|||
$input =~ s/</</g;
|
||||
$input =~ s/>/>/g;
|
||||
|
||||
if ($input =~ /<!\[CDATA\[/) { $input = ""; }
|
||||
if ($input =~ /]]>/) { $input = ""; }
|
||||
|
||||
#print "Returning line $input";
|
||||
return $input;
|
||||
}
|
||||
|
||||
|
@ -23,6 +31,7 @@ xml_decode ($)
|
|||
my $output = shift @ARGV;
|
||||
|
||||
$found = 0;
|
||||
%blocks = ();
|
||||
|
||||
foreach $file (@ARGV)
|
||||
{
|
||||
|
@ -30,31 +39,40 @@ foreach $file (@ARGV)
|
|||
|
||||
while ($line = <FILE>)
|
||||
{
|
||||
if ($line =~ /\/\* example-begin $output \*\//)
|
||||
if ($line =~ /<!-- example-begin $output (.*) -->/)
|
||||
{
|
||||
print "Extracting $output from $file\n";
|
||||
$found = 1;
|
||||
open OUTPUT, ">$output";
|
||||
print OUTPUT xml_decode ($line);
|
||||
my $example = 1;
|
||||
while (($line = <FILE>) && $example)
|
||||
$block_id = $1;
|
||||
$block = "\n/*** block $block_id from $file ***/\n";
|
||||
|
||||
print "Extracting $output block $block_id from $file\n";
|
||||
|
||||
while ($line = <FILE>)
|
||||
{
|
||||
if ($line =~ /\/\* example-end/)
|
||||
if ($line =~ /<!-- example-end $output (.*) -->/)
|
||||
{
|
||||
print OUTPUT xml_decode ($line);
|
||||
close OUTPUT;
|
||||
$example = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
print OUTPUT xml_decode ($line);
|
||||
last;
|
||||
}
|
||||
$block .= xml_decode ($line);
|
||||
}
|
||||
$blocks{$block_id} = $block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$found)
|
||||
{
|
||||
print "Could not find $output example !\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
# now output all the blocks in the right order
|
||||
open OUTPUT, ">$output";
|
||||
@block_ids = keys %blocks;
|
||||
foreach $block_id (sort @block_ids)
|
||||
{
|
||||
print "Writing block with id $block_id\n";
|
||||
print OUTPUT $blocks{$block_id};
|
||||
}
|
||||
close OUTPUT;
|
||||
|
|
Loading…
Reference in a new issue