mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 00:31:13 +00:00
d0bcc34dad
Original commit message from CVS: * docs/manual/advanced-autoplugging.xml: * docs/manual/advanced-clocks.xml: * docs/manual/advanced-interfaces.xml: * docs/manual/advanced-metadata.xml: * docs/manual/advanced-position.xml: * docs/manual/advanced-schedulers.xml: * docs/manual/advanced-threads.xml: * docs/manual/appendix-gnome.xml: * docs/manual/appendix-programs.xml: * docs/manual/appendix-quotes.xml: * docs/manual/autoplugging.xml: * docs/manual/basics-bins.xml: * docs/manual/basics-data.xml: * docs/manual/basics-elements.xml: * docs/manual/basics-helloworld.xml: * docs/manual/basics-init.xml: * docs/manual/basics-pads.xml: * docs/manual/basics-plugins.xml: * docs/manual/bins-api.xml: * docs/manual/bins.xml: * docs/manual/buffers-api.xml: * docs/manual/buffers.xml: * docs/manual/clocks.xml: * docs/manual/components.xml: * docs/manual/cothreads.xml: * docs/manual/debugging.xml: * docs/manual/dparams-app.xml: * docs/manual/dynamic.xml: * docs/manual/elements-api.xml: * docs/manual/elements.xml: * docs/manual/factories.xml: * docs/manual/gnome.xml: * docs/manual/goals.xml: * docs/manual/helloworld.xml: * docs/manual/helloworld2.xml: * docs/manual/highlevel-components.xml: * docs/manual/highlevel-xml.xml: * docs/manual/init-api.xml: * docs/manual/intro-basics.xml: * docs/manual/intro-motivation.xml: * docs/manual/intro-preface.xml: * docs/manual/intro.xml: * docs/manual/links-api.xml: * docs/manual/links.xml: * docs/manual/manual.xml: * docs/manual/motivation.xml: * docs/manual/pads-api.xml: * docs/manual/pads.xml: * docs/manual/plugins-api.xml: * docs/manual/plugins.xml: * docs/manual/programs.xml: * docs/manual/queues.xml: * docs/manual/quotes.xml: * docs/manual/schedulers.xml: * docs/manual/states-api.xml: * docs/manual/states.xml: * docs/manual/threads.xml: * docs/manual/typedetection.xml: * docs/manual/win32.xml: * docs/manual/xml.xml: Try 2. This time, include a short preface as a "general introduction", also add code blocks around all code samples so they get compiled. We still need a way to tell readers the filename of the code sample. In some cases, don't show all code in the documentation, but do include it in the generated code. This allows for focussing on specific bits in the docs, while still having a full test application available. * examples/manual/Makefile.am: Fix up examples for new ADM. Add several of the new examples that were either added or were missing from the build system. * examples/manual/extract.pl: Allow nameless blocks.
95 lines
3.2 KiB
XML
95 lines
3.2 KiB
XML
<chapter id="chapter-gnome">
|
|
<title>GNOME integration</title>
|
|
<para>
|
|
GStreamer is fairly easy to integrate with GNOME applications.
|
|
GStreamer uses libxml 2.0, GLib 2.0 and popt, as do all other
|
|
GNOME applications.
|
|
There are however some basic issues you need to address in your GNOME
|
|
applications.
|
|
</para>
|
|
|
|
<sect1>
|
|
<title>Command line options</title>
|
|
<para>
|
|
GNOME applications call gnome_program_init () to parse command-line
|
|
options and initialize the necessary gnome modules.
|
|
GStreamer applications normally call gst_init (&argc, &argv) to
|
|
do the same for GStreamer.
|
|
</para>
|
|
<para>
|
|
Each of these two swallows the program options passed to the program,
|
|
so we need a different way to allow both GNOME and GStreamer to parse
|
|
the command-line options. This is shown in the following example.
|
|
</para>
|
|
|
|
<programlisting>
|
|
<!-- example-begin gnome.c -->
|
|
#include <gnome.h>
|
|
#include <gst/gst.h>
|
|
|
|
int
|
|
main (int argc, char **argv)
|
|
{
|
|
GstPoptOption options[] = {
|
|
{ NULL, '\0', POPT_ARG_INCLUDE_TABLE, NULL, 0, "GStreamer", NULL },
|
|
POPT_TABLEEND
|
|
};
|
|
GnomeProgram *program;
|
|
poptContext context;
|
|
const gchar **argvn;
|
|
|
|
GstElement *pipeline;
|
|
GstElement *src, *sink;
|
|
|
|
options[0].arg = (void *) gst_init_get_popt_table ();
|
|
g_print ("Calling gnome_program_init with the GStreamer popt table\n");
|
|
/* gnome_program_init will initialize GStreamer now
|
|
* as a side effect of having the GStreamer popt table passed. */
|
|
if (! (program = gnome_program_init ("my_package", "0.1", LIBGNOMEUI_MODULE,
|
|
argc, argv,
|
|
GNOME_PARAM_POPT_TABLE, options,
|
|
NULL)))
|
|
g_error ("gnome_program_init failed");
|
|
|
|
g_print ("Getting gnome-program popt context\n");
|
|
g_object_get (program, "popt-context", &context, NULL);
|
|
argvn = poptGetArgs (context);
|
|
if (!argvn) {
|
|
g_print ("Run this example with some arguments to see how it works.\n");
|
|
return 0;
|
|
}
|
|
|
|
g_print ("Printing rest of arguments\n");
|
|
while (*argvn) {
|
|
g_print ("argument: %s\n", *argvn);
|
|
++argvn;
|
|
}
|
|
|
|
/* do some GStreamer things to show everything's initialized properly */
|
|
g_print ("Doing some GStreamer stuff to show that everything works\n");
|
|
pipeline = gst_pipeline_new ("pipeline");
|
|
src = gst_element_factory_make ("fakesrc", "src");
|
|
sink = gst_element_factory_make ("fakesink", "sink");
|
|
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
|
|
gst_element_link (src, sink);
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
gst_bin_iterate (GST_BIN (pipeline));
|
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
return 0;
|
|
}
|
|
<!-- example-end gnome.c -->
|
|
</programlisting>
|
|
<para>
|
|
If you try out this program, you will see that when called with
|
|
--help, it will print out both GStreamer and GNOME help arguments.
|
|
All of the arguments that didn't belong to either end up in the
|
|
argvn pointer array.
|
|
</para>
|
|
<para>
|
|
FIXME: flesh this out more. How do we get the GStreamer arguments
|
|
at the end ?
|
|
FIXME: add a GConf bit.
|
|
</para>
|
|
</sect1>
|
|
</chapter>
|