<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >Autoplugging</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="GStreamer Application Development Manual" HREF="index.html"><LINK REL="UP" TITLE="Advanced GStreamer concepts" HREF="part-advanced.html"><LINK REL="PREVIOUS" TITLE="Type Detection" HREF="chapter-typedetection.html"><LINK REL="NEXT" TITLE="Using the GstAutoplugCache element" HREF="section-autoplug-cache.html"></HEAD ><BODY CLASS="chapter" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" ><SPAN CLASS="application" >GStreamer</SPAN > Application Development Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="chapter-typedetection.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="section-autoplug-cache.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="chapter" ><H1 ><A NAME="chapter-autoplug" ></A >Chapter 28. Autoplugging</H1 ><P > <SPAN CLASS="application" >GStreamer</SPAN > provides an API to automatically construct complex pipelines based on source and destination capabilities. This feature is very useful if you want to convert type X to type Y but don't care about the plugins needed to accomplish this task. The autoplugger will consult the plugin repository, select and link the elements needed for the conversion. </P ><P > The autoplugger API is implemented in an abstract class. Autoplugger implementations reside in plugins and are therefore optional and can be optimized for a specific task. Two types of autopluggers exist: renderer ones and non-renderer ones. The renderer autopluggers will not have any source pads while the non-renderer ones do. The renderer autopluggers are mainly used for media playback while the non renderer ones are used for arbitrary format conversion. </P ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="AEN947" >28.1. Using autoplugging</A ></H1 ><P > You first need to create a suitable autoplugger with gst_autoplug_factory_make(). The name of the autoplugger must be one of the registered autopluggers.. </P ><P > A list of all available autopluggers can be obtained with gst_autoplug_factory_get_list(). </P ><P > If the autoplugger supports the RENDERER API, use the gst_autoplug_to_renderers() function to create a bin that links the source caps to the specified render elements. You can then add the bin to a pipeline and run it. <PRE CLASS="programlisting" > GstAutoplug *autoplug; GstElement *element; GstElement *sink; /* create a static autoplugger */ autoplug = gst_autoplug_factory_make ("staticrender"); /* create an osssink */ sink = gst_element_factory_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 link the sink pad */ ... </PRE > </P ><P > If the autoplugger supports the CAPS API, use the gst_autoplug_to_caps() function to link the source caps to the destination caps. The created bin will have source and sink pads compatible with the provided caps. <PRE CLASS="programlisting" > GstAutoplug *autoplug; GstElement *element; /* create a static autoplugger */ autoplug = gst_autoplug_factory_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 link the src/sink pads */ ... </PRE > </P ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="chapter-typedetection.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="section-autoplug-cache.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Type Detection</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="part-advanced.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Using the <CODE CLASS="classname" >GstAutoplugCache</CODE > element</TD ></TR ></TABLE ></DIV ></BODY ></HTML >