Next: , Previous: GstVersion, Up: Top


45 Gst

Media library supporting arbitrary formats and filter graphs.

45.1 Overview

GStreamer is a framework for constructing graphs of various filters (termed elements here) that will handle streaming media. Any discreet (packetizable) media type is supported, with provisions for automatically determining source type. Formatting/framing information is provided with a powerful negotiation framework. Plugins are heavily used to provide for all elements, allowing one to construct plugins outside of the GST library, even released binary-only if license require (please don't).

GStreamer borrows heavily from both the OGI media pipeline and Microsoft's DirectShow, hopefully taking the best of both and leaving the cruft behind. Its interface is slowly getting stable.

The GStreamer library should be initialized with gst-init before it can be used. You should pass pointers to the main argc and argv variables so that GStreamer can process its own command line options, as shown in the following example.

     
     int
     main (int argc, char *argv[])
     {
       // initialize the GStreamer library
       gst_init (&argc, &argv);
       ...
     }

It's allowed to pass two NULL pointers to gst-init in case you don't want to pass the command line args to GStreamer.

You can also use GOption to initialize your own parameters as shown in the next code fragment:

     
     static gboolean stats = FALSE;
     ...
     int
     main (int argc, char *argv[])
     {
      GOptionEntry options[] = {
       {"tags", 't', 0, G_OPTION_ARG_NONE, &tags,
           N_("Output tags (also known as metadata)"), NULL},
       {NULL}
      };
      // must initialise the threading system before using any other GLib funtion
      if (!g_thread_supported ())
        g_thread_init (NULL);
      ctx = g_option_context_new ("[ADDITIONAL ARGUMENTS]");
      g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
      g_option_context_add_group (ctx, gst_init_get_option_group ());
      if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
        g_print ("Error initializing: %s\n", GST_STR_NULL (err->message));
        exit (1);
      }
      g_option_context_free (ctx);
     ...
     }

Use gst-version to query the library version at runtime or use the GST_VERSION_* macros to find the version at compile time. Optionally gst-version-string returns a printable string.

The gst-deinit call is used to clean up all internal resources used by GStreamer. It is mostly used in unit tests to check for leaks.

Last reviewed on 2006-08-11 (0.10.10)

45.2 Usage

— Function: gst-init (argv <char***>)   (argc int)

Initializes the GStreamer library, setting up internal path lists, registering built-in elements, and loading standard plugins.

This function should be called before calling any other GLib functions. If this is not an option, your program must initialise the GLib thread system using g-thread-init before any other GLib functions are called.

This function will terminate your program if it was unable to initialize GStreamer for some reason. If you want your program to fall back, use gst-init-check instead.

WARNING: This function does not work in the same way as corresponding functions in other glib-style libraries, such as gtk-init. In particular, unknown command line options cause this function to abort program execution.

argc
pointer to application's argc
argv
pointer to application's argv
— Function: gst-init-check (argv <char***>)   (ret bool) (argc int)

Initializes the GStreamer library, setting up internal path lists, registering built-in elements, and loading standard plugins.

This function will return ‘#f’ if GStreamer could not be initialized for some reason. If you want your program to fail fatally, use gst-init instead.

This function should be called before calling any other GLib functions. If this is not an option, your program must initialise the GLib thread system using g-thread-init before any other GLib functions are called.

argc
pointer to application's argc
argv
pointer to application's argv
err
pointer to a <g-error> to which a message will be posted on error
ret
#t’ if GStreamer could be initialized.
— Function: gst-init-get-option-group   (ret <g-option-group*>)

Returns a <g-option-group> with GStreamer's argument specifications. The group is set up to use standard GOption callbacks, so when using this group in combination with GOption parsing methods, all argument parsing and initialization is automated.

This function is useful if you want to integrate GStreamer with other libraries that use GOption (see g-option-context-add-group ).

If you use this function, you should make sure you initialise the GLib threading system as one of the very first things in your program (see the example at the beginning of this section).

ret
a pointer to GStreamer's option group.
— Function: gst-deinit

Clean up any resources created by GStreamer in gst-init.

It is normally not needed to call this function in a normal application as the resources will automatically be freed when the program terminates. This function is therefore mostly used by testsuites and other memory profiling tools.

After this call GStreamer (including this method) should not be used anymore.

— Function: gst-version   (major unsigned-int) (minor unsigned-int) (micro unsigned-int) (nano unsigned-int)

Gets the version number of the GStreamer library.

major
pointer to a guint to store the major version number
minor
pointer to a guint to store the minor version number
micro
pointer to a guint to store the micro version number
nano
pointer to a guint to store the nano version number
— Function: gst-version-string   (ret mchars)

This function returns a string that is useful for describing this version of GStreamer to the outside world: user agent strings, logging, ...

ret
a newly allocated string describing this version of GStreamer.
— Function: gst-segtrap-is-enabled   (ret bool)

Some functions in the GStreamer core might install a custom SIGSEGV handler to better catch and report errors to the application. Currently this feature is enabled by default when loading plugins.

Applications might want to disable this behaviour with the gst-segtrap-set-enabled function. This is typically done if the application wants to install its own handler without GStreamer interfering.

ret
#t’ if GStreamer is allowed to install a custom SIGSEGV handler.

Since 0.10.10

— Function: gst-segtrap-set-enabled (enabled bool)

Applications might want to disable/enable the SIGSEGV handling of the GStreamer core. See gst-segtrap-is-enabled for more information.

enabled
whether a custom SIGSEGV handler should be installed.

Since 0.10.10

— Function: gst-registry-fork-is-enabled   (ret bool)

By default GStreamer will perform a fork when scanning and rebuilding the registry file.

Applications might want to disable this behaviour with the gst-registry-fork-set-enabled function.

ret
#t’ if GStreamer will use fork when rebuilding the registry. On platforms without fork, this function will always return ‘#f’.

Since 0.10.10

— Function: gst-registry-fork-set-enabled (enabled bool)

Applications might want to disable/enable the usage of fork when rebuilding the registry. See gst-registry-fork-is-enabled for more information.

On platforms without fork, this function will have no effect on the return value of gst-registry-fork-is-enabled.

enabled
whether rebuilding the registry may fork

Since 0.10.10