Chapter 22. Defining Parameter Specificiations

Table of Contents

Direct Method
Callback Method
Array Method

You can define the dparams you need anywhere within your element but will usually need to do so in only a couple of places:

There are three different ways the dparams subsystem can pass parameters into your element. Which one you use will depend on how that parameter is used within your element. Each of these methods has its own function to define a required dparam:

These functions will return TRUE if the required dparam was added successfully.

The following function will be used as an example.

  gboolean
  gst_dpman_add_required_dparam_direct (GstDParamManager *dpman,
                                        GParamSpec *param_spec,
                                        gboolean is_log,
                                        gboolean is_rate,
                                        gpointer update_data)
    

The common parameters to these functions are:

Direct Method

This method is the simplest and has the lowest overhead for parameters which change less frequently than the sample rate. First you need somewhere to store the parameter - this will usually be in your element's stuct.

  struct _GstExample {
    GstElement element;
    ...

    GstDParamManager *dpman;
    gfloat volume;
    ...
  };
    

Then to define the required dparam just call gst_dpman_add_required_dparam_direct and pass in the location of the parameter to change. In this case the location is &(example->volume).

  gst_dpman_add_required_dparam_direct (
    example->dpman,
    g_param_spec_float("volume","Volume","Volume of the audio",
                       0.0, 1.0, 0.8, G_PARAM_READWRITE),
    FALSE,
    FALSE,
    &(example->volume)
  );
    

You can now use example->volume anywhere in your element knowing that it will always contain the correct value to use.