## GStreamer GStreamer — Media library supporting arbitrary formats and filter graphs. |

## Synopsis

    #include <gst/gst.h>

    void        gst_init                        (int *argc,
                                                 char **argv[]);
    gboolean    gst_init_check                  (int *argc,
                                                 char **argv[]);
    void        gst_init_with_popt_table        (int *argc,
                                                 char **argv[],
                                                 const GstPoptOption *popt_options);
    gboolean    gst_init_check_with_popt_table  (int *argc,
                                                 char **argv[],
                                                 const GstPoptOption *popt_options);
    const GstPoptOption* gst_init_get_popt_table
                                                (void);
    void        gst_use_threads                 (gboolean use_threads);
    gboolean    gst_has_threads                 (void);
    void        gst_main                        (void);
    void        gst_main_quit                   (void);

## Description

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 still very fluid and thus can be changed to increase the sanity/noise ratio.

The GStreamer library should be initialized with `gst_init()` before it can be used. You should pass a pointer to the main argc and argv variables so that GStreamer can process its own command line options, as shown in the following example.

Example 1. Initializing the GStreamer library

      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 a popt table to initialize your own parameters as shown in the next code fragment:

Example 2. Initializing own parameters when initializing GStreamer

      static gboolean stats = FALSE;
      ...

      int
      main (int argc, char *argv[])
      {
        struct poptOption options[] = {
          { "stats",  's',  POPT_ARG_NONE|POPT_ARGFLAG_STRIP,   &stats,   0,
              "Show pad stats", NULL},
            POPT_TABLEEND
          };

        /* initialize the GStreamer library */
        gst_init_with_popt_table (&argc, &argv, options);

        ...
      }

Use `gst_version()` to query the library version at runtime or use the GST_VERSION_* macros to find the version at compile time.

`gst_main()` and `gst_main_quit()` enter and exit the main loop. GStreamer doesn't currently require you to us a mainloop but can intergrate with it without problems.

## Details

### gst_init ()

    void        gst_init                        (int *argc,
                                                 char **argv[]);

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

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

### gst_init_check ()

    gboolean    gst_init_check                  (int *argc,
                                                 char **argv[]);

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

This function will return `FALSE` if GStreamer could not be initialized for some reason. If you want your program to fail fatally, use `gst_init()` instead.

`argc` : | pointer to application's argc
`argv` : | pointer to application's argv
Returns : | `TRUE` if GStreamer could be initialized.

### gst_init_with_popt_table ()

    void        gst_init_with_popt_table        (int *argc,
                                                 char **argv[],
                                                 const GstPoptOption *popt_options);

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

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_with_popt_table()` instead.

`argc` : | pointer to application's argc
`argv` : | pointer to application's argv
`popt_options` : | pointer to a popt table to append

### gst_init_check_with_popt_table ()

    gboolean    gst_init_check_with_popt_table  (int *argc,
                                                 char **argv[],
                                                 const GstPoptOption *popt_options);

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

`argc` : | pointer to application's argc
`argv` : | pointer to application's argv
`popt_options` : | pointer to a popt table to append
Returns : | `TRUE` if GStreamer could be initialized.

### gst_init_get_popt_table ()

    const GstPoptOption* gst_init_get_popt_table
                                                (void);

Returns a popt option table with GStreamer's argument specifications. The table is set up to use popt's callback method, so whenever the parsing is actually performed (via poptGetContext), the GStreamer libraries will be initialized.

This function is useful if you want to integrate GStreamer with other libraries that use popt.

Returns : | a pointer to the static GStreamer option table. No free is necessary.

### gst_use_threads ()

    void        gst_use_threads                 (gboolean use_threads);

### Warning

`gst_use_threads` is deprecated and should not be used in newly-written code. This function is deprecated and should not be used in new code.

Does nothing anymore. GStreamer requires threads to be enabled at all times.

`use_threads` : | a gboolean indicating whether threads should be used

### gst_has_threads ()

    gboolean    gst_has_threads                 (void);

### Warning

`gst_has_threads` is deprecated and should not be used in newly-written code. This function is deprecated and should not be used in new code.

Queries if GStreamer has threads enabled.

Returns : | `TRUE` if threads are enabled.

### gst_main ()

    void        gst_main                        (void);

Enters the main GStreamer processing loop.

This function duplicates functionality in glib, and will be removed during the 0.9 development series.

### gst_main_quit ()

    void        gst_main_quit                   (void);

Exits the main GStreamer processing loop.

This function duplicates functionality in glib, and will be removed during the 0.9 development series.

## See Also

Check out both OGI's pipeline and Microsoft's DirectShow for some background.