<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Autoplugging</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79;charset=UTF-8"><LINK REL="HOME" TITLE="GStreamer Application Development Manual (0.10.36)" HREF="index.html"><LINK REL="UP" TITLE="Advanced GStreamer concepts" HREF="part-advanced.html"><LINK REL="PREVIOUS" TITLE="Scheduling in GStreamer" HREF="section-threads-scheduling.html"><LINK REL="NEXT" TITLE="Media stream type detection" HREF="section-typefinding.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 (0.10.36)</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="section-threads-scheduling.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="section-typefinding.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="chapter" ><H1 ><A NAME="chapter-autoplugging" ></A >Chapter 17. Autoplugging</H1 ><P > In <A HREF="chapter-helloworld.html" >Chapter 10</A >, you've learned to build a simple media player for Ogg/Vorbis files. By using alternative elements, you are able to build media players for other media types, such as Ogg/Speex, MP3 or even video formats. However, you would rather want to build an application that can automatically detect the media type of a stream and automatically generate the best possible pipeline by looking at all available elements in a system. This process is called autoplugging, and <SPAN CLASS="application" >GStreamer</SPAN > contains high-quality autopluggers. If you're looking for an autoplugger, don't read any further and go to <A HREF="chapter-components.html" >Chapter 19</A >. This chapter will explain the <SPAN CLASS="emphasis" ><I CLASS="emphasis" >concept</I ></SPAN > of autoplugging and typefinding. It will explain what systems <SPAN CLASS="application" >GStreamer</SPAN > includes to dynamically detect the type of a media stream, and how to generate a pipeline of decoder elements to playback this media. The same principles can also be used for transcoding. Because of the full dynamicity of this concept, <SPAN CLASS="application" >GStreamer</SPAN > can be automatically extended to support new media types without needing any adaptations to its autopluggers. </P ><P > We will first introduce the concept of MIME types as a dynamic and extendible way of identifying media streams. After that, we will introduce the concept of typefinding to find the type of a media stream. Lastly, we will explain how autoplugging and the <SPAN CLASS="application" >GStreamer</SPAN > registry can be used to setup a pipeline that will convert media from one mimetype to another, for example for media decoding. </P ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="section-mime" >17.1. MIME-types as a way to identify streams</A ></H1 ><P > We have previously introduced the concept of capabilities as a way for elements (or, rather, pads) to agree on a media type when streaming data from one element to the next (see <A HREF="section-caps.html" >Section 8.2</A >). We have explained that a capability is a combination of a mimetype and a set of properties. For most container formats (those are the files that you will find on your hard disk; Ogg, for example, is a container format), no properties are needed to describe the stream. Only a MIME-type is needed. A full list of MIME-types and accompanying properties can be found in <A HREF="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/section-types-definitions.html" TARGET="_top" >the Plugin Writer's Guide</A >. </P ><P > An element must associate a MIME-type to its source and sink pads when it is loaded into the system. <SPAN CLASS="application" >GStreamer</SPAN > knows about the different elements and what type of data they expect and emit through the <SPAN CLASS="application" >GStreamer</SPAN > registry. This allows for very dynamic and extensible element creation as we will see. </P ><P > In <A HREF="chapter-helloworld.html" >Chapter 10</A >, we've learned to build a music player for Ogg/Vorbis files. Let's look at the MIME-types associated with each pad in this pipeline. <A HREF="chapter-autoplugging.html#section-mime-img" >Figure 17-1</A > shows what MIME-type belongs to each pad in this pipeline. </P ><DIV CLASS="figure" ><A NAME="section-mime-img" ></A ><P ><B >Figure 17-1. The Hello world pipeline with MIME types</B ></P ><DIV CLASS="mediaobject" ><P ><IMG SRC="images/mime-world.png"></P ></DIV ></DIV ><P > Now that we have an idea how <SPAN CLASS="application" >GStreamer</SPAN > identifies known media streams, we can look at methods <SPAN CLASS="application" >GStreamer</SPAN > uses to setup pipelines for media handling and for media type detection. </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="section-threads-scheduling.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-typefinding.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Scheduling in <SPAN CLASS="application" >GStreamer</SPAN ></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" >Media stream type detection</TD ></TR ></TABLE ></DIV ></BODY ></HTML >