GstAutoplug

Name

GstAutoplug -- Automatically create and connect elements

Synopsis


#include <gst/gst.h>


struct      GstAutoplug;
enum        GstAutoplugFlags;
struct      GstAutoplugFactory;
void        gst_autoplug_signal_new_object  (GstAutoplug *autoplug,
                                             GstObject *object);
GstElement* gst_autoplug_to_caps            (GstAutoplug *autoplug,
                                             GstCaps *srccaps,
                                             GstCaps *sinkcaps,
                                             ...);
GstElement* gst_autoplug_to_renderers       (GstAutoplug *autoplug,
                                             GstCaps *srccaps,
                                             GstElement *target,
                                             ...);
GstAutoplugFactory* gst_autoplugfactory_new (const gchar *name,
                                             const gchar *longdesc,
                                             GtkType type);
void        gst_autoplugfactory_destroy     (GstAutoplugFactory *factory);
GstAutoplugFactory* gst_autoplugfactory_find
                                            (const gchar *name);
GList*      gst_autoplugfactory_get_list    (void);
GstAutoplug* gst_autoplugfactory_create     (GstAutoplugFactory *factory);
GstAutoplug* gst_autoplugfactory_make       (const gchar *name);
xmlNodePtr  gst_autoplugfactory_save_thyself
                                            (GstAutoplugFactory *factory,
                                             xmlNodePtr parent);
GstAutoplugFactory* gst_autoplugfactory_load_thyself
                                            (xmlNodePtr parent);

Description

GstAutoplug is an abstract class that is used for constructing and connecting elements. Two types og autopluggers exist: renderer ones and non renderer ones. the renderer autopluggers will not have any src pads while the non renderer ones do.

You first need to create a suitable autoplugger with gst_autoplugfactory_make(). The name of the autoplugger must be one of the registered autopluggers (see GstStaticAutoplug and GstStaticAutoplugRender).

A list of all available autopluggers can be obtained with gst_autoplugfactory_get_list().

If the autoplugger supports the RENDERER API, use gst_autoplug_to_renderers() call to create a bin that connectes the src caps to the specified rendrer elements. You can then add the bin to a pipeline and run it.
  GstAutoplug *autoplug;
  GstElement  *element;
  GstElement  *sink;

  /* create a static autoplugger */
  autoplug = gst_autoplugfactory_make ("staticrender");

  /* create an osssink */
  sink = gst_elementfactory_make ("osssink", "our_sink");

  /* create an element that can play audio/mp3 through osssink */
  element = gst_autoplug_to_renderers (autoplug, 
   				       gst_caps_new (
				         "sink_audio_caps",
				         "audio/mp3",
					 NULL
				       ),
				       sink,
				       NULL);

  /* add the element to a bin and connect the sink pad */
  ...
  

If the autoplugger supports the CAPS API, use gst_autoplug_to_caps() call to connect the src caps to the destination caps. The created bin will have src pads compatible with the provided sink caps.
  GstAutoplug *autoplug;
  GstElement  *element;

  /* create a static autoplugger */
  autoplug = gst_autoplugfactory_make ("static");

  /* create an element that converts audio/mp3 to audio/raw */
  element = gst_autoplug_to_caps (autoplug, 
   				  gst_caps_new (
				    "sink_audio_caps",
				    "audio/mp3",
				    NULL
				  ),
   				  gst_caps_new (
				    "src_audio_caps",
				    "audio/raw",
				    NULL
				  ),
				  NULL);

  /* add the element to a bin and connect the src/sink pads */
  ...
  

Optionally you can get a notification when a new object is added to the created pipeline with a gtk_signal_connect to the "new_object" signal.

Use the regular gst_object_destroy() call to destroy the autoplugger.

Details

struct GstAutoplug

struct GstAutoplug {
  GstObject object;
};


enum GstAutoplugFlags

typedef enum {
  GST_AUTOPLUG_TO_CAPS 		= GST_OBJECT_FLAG_LAST,
  GST_AUTOPLUG_TO_RENDERER,

  GST_AUTOPLUG_FLAG_LAST	= GST_OBJECT_FLAG_LAST + 8,
} GstAutoplugFlags;

The type of the autoplugger.


struct GstAutoplugFactory

struct GstAutoplugFactory {
  gchar *name;                  /* name of autoplugger */
  gchar *longdesc;              /* long description of the autoplugger (well, don't overdo it..) */
  GtkType type;                 /* unique GtkType of the autoplugger */
};


gst_autoplug_signal_new_object ()

void        gst_autoplug_signal_new_object  (GstAutoplug *autoplug,
                                             GstObject *object);

Emit a new_object signal. autopluggers are supposed to emit this signal whenever a new object has been added to the autoplugged pipeline.

autoplug : The autoplugger to emit the signal
object : The object that is passed to the signal


gst_autoplug_to_caps ()

GstElement* gst_autoplug_to_caps            (GstAutoplug *autoplug,
                                             GstCaps *srccaps,
                                             GstCaps *sinkcaps,
                                             ...);

Perform the autoplugging procedure on the given autoplugger. The src caps will be connected to the sink caps.

autoplug : The autoplugger perform the autoplugging
srccaps : The source cpabilities
sinkcaps : The target capabilities
... : more target capabilities
Returns : A new Element that connects the src caps to the sink caps.


gst_autoplug_to_renderers ()

GstElement* gst_autoplug_to_renderers       (GstAutoplug *autoplug,
                                             GstCaps *srccaps,
                                             GstElement *target,
                                             ...);

Perform the autoplugging procedure on the given autoplugger. The src caps will be connected to the target elements.

autoplug : The autoplugger perform the autoplugging
srccaps : The source cpabilities
target : The target element
... : more target elements
Returns : A new Element that connects the src caps to the target elements.


gst_autoplugfactory_new ()

GstAutoplugFactory* gst_autoplugfactory_new (const gchar *name,
                                             const gchar *longdesc,
                                             GtkType type);

Create a new autoplugfactory with the given parameters

name : name of autoplugfactory to create
longdesc : long description of autoplugfactory to create
type : the gtk type of the GstAutoplug element of this factory
Returns : a new GstAutoplugFactory.


gst_autoplugfactory_destroy ()

void        gst_autoplugfactory_destroy     (GstAutoplugFactory *factory);

Removes the autoplug from the global list.

factory : factory to destroy


gst_autoplugfactory_find ()

GstAutoplugFactory* gst_autoplugfactory_find
                                            (const gchar *name);

Search for an autoplugfactory of the given name.

name : name of autoplugfactory to find
Returns : GstAutoplugFactory if found, NULL otherwise


gst_autoplugfactory_get_list ()

GList*      gst_autoplugfactory_get_list    (void);

Get the global list of autoplugfactories.

Returns : GList of type GstAutoplugFactory


gst_autoplugfactory_create ()

GstAutoplug* gst_autoplugfactory_create     (GstAutoplugFactory *factory);

Create a new GstAutoplug instance from the given autoplugfactory.

factory : the factory used to create the instance
Returns : A new GstAutoplug instance.


gst_autoplugfactory_make ()

GstAutoplug* gst_autoplugfactory_make       (const gchar *name);

Create a new GstAutoplug instance from the autoplugfactory with the given name.

name : the name of the factory used to create the instance
Returns : A new GstAutoplug instance.


gst_autoplugfactory_save_thyself ()

xmlNodePtr  gst_autoplugfactory_save_thyself
                                            (GstAutoplugFactory *factory,
                                             xmlNodePtr parent);

Save the autoplugfactory into an XML representation

factory : The facory to save
parent : the parent XML node pointer
Returns : The new XML parent.


gst_autoplugfactory_load_thyself ()

GstAutoplugFactory* gst_autoplugfactory_load_thyself
                                            (xmlNodePtr parent);

Load an autoplugfactory from the given XML parent node.

parent : the parent XML node pointer
Returns : A new factory based on the XML node.

See Also

GstStaticAutoplug, GstStaticAutoplugRender