<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML ><HEAD ><TITLE >Creating and Attaching Dynamic Parameters</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="Dynamic Parameters" HREF="chapter-dparams.html"><LINK REL="PREVIOUS" TITLE="Dynamic Parameters" HREF="chapter-dparams.html"><LINK REL="NEXT" TITLE="Changing Dynamic Parameter Values" HREF="section-dparams-changing.html"></HEAD ><BODY CLASS="sect1" 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-dparams.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 30. Dynamic Parameters</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="section-dparams-changing.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="section-dparams-creating" >30.2. Creating and Attaching Dynamic Parameters</A ></H1 ><P > Once you have created your elements you can create and attach dparams to them. First you need to get the element's dparams manager. If you know exactly what kind of element you have, you may be able to get the dparams manager directly. However if this is not possible, you can get the dparams manager by calling <TT CLASS="filename" >gst_dpman_get_manager</TT >. </P ><P > Once you have the dparams manager, you must set the mode that the manager will run in. There is currently only one mode implemented called <TT CLASS="filename" >"synchronous"</TT > - this is used for real-time applications where the dparam value cannot be known ahead of time (such as a slider in a GUI). The mode is called <TT CLASS="filename" >"synchronous"</TT > because the dparams are polled by the element for changes before each buffer is processed. Another yet-to-be-implemented mode is <TT CLASS="filename" >"asynchronous"</TT >. This is used when parameter changes are known ahead of time - such as with a timelined editor. The mode is called <TT CLASS="filename" >"asynchronous"</TT > because parameter changes may happen in the middle of a buffer being processed. </P ><PRE CLASS="programlisting" > GstElement *sinesrc; GstDParamManager *dpman; ... sinesrc = gst_element_factory_make("sinesrc","sine-source"); ... dpman = gst_dpman_get_manager (sinesrc); gst_dpman_set_mode(dpman, "synchronous"); </PRE ><P > If you don't know the names of the required dparams for your element you can call <TT CLASS="filename" >gst_dpman_list_dparam_specs(dpman)</TT > to get a NULL terminated array of param specs. This array should be freed after use. You can find the name of the required dparam by calling <TT CLASS="filename" >g_param_spec_get_name</TT > on each param spec in the array. In our example, <TT CLASS="filename" >"volume"</TT > will be the name of our required dparam. </P ><P > Each type of dparam currently has its own <TT CLASS="filename" >new</TT > function. This may eventually be replaced by a factory method for creating new instances. A default dparam instance can be created with the <TT CLASS="filename" >gst_dparam_new</TT > function. Once it is created it can be attached to a required dparam in the element. </P ><PRE CLASS="programlisting" > GstDParam *volume; ... volume = gst_dparam_new(G_TYPE_FLOAT); if (gst_dpman_attach_dparam (dpman, "volume", volume)){ /* the dparam was successfully attached */ ... } </PRE ></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-dparams.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-dparams-changing.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Dynamic Parameters</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="chapter-dparams.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Changing Dynamic Parameter Values</TD ></TR ></TABLE ></DIV ></BODY ></HTML >