How to set a volume property in audiomixer's sink pads?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to set a volume property in audiomixer's sink pads?

Natanael Mojica
Hi:

I have a audiomixer element in my pipeline, and others elements linked into that
but now I want to change de volume of any audiosource connected to a audiomixer

        gst_bin_add(GST_BIN(pipeline), source->get_bin());
        GstPad *mixer_pad = gst_element_request_pad (audiomixer, mix_template, NULL, NULL);
        GstPad *a_pad = gst_element_get_static_pad(source->get_bin(), "audiosrc");
        if (gst_pad_link (a_pad, mixer_pad) != GST_PAD_LINK_OK ){
                 g_critical ("link audio source to audiomixer failed.\n");
                 exit(1);
         }

for example

filesrc -> decodbin -> queue -> audiomixer (sink0)

filesrc2 .....                               -> audiomixer(sink1)
....
....
...                                               -> audiomixer (sinkn)
My question is , how to set mute all sink less sink2 o sink3 , or set a volume property in 4 of the sink2 pad

thanks


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to set a volume property in audiomixer's sink pads?

Michael Gruner
Hi Natanael

The audio mixer pads expose properties as objects they are. Let am_pad0, am_pad1, …, am_padN be the N pads of the audio mixer, then you can set their properties as:

Mute all sources except am_pad0:
g_object_set (am_pad0, “mute”, FALSE, NULL);
g_object_set (am_pad1, “mute”, TRUE, NULL);
...
g_object_set (am_padN, “mute”, TRUE, NULL);

Change volume of pads:
g_object_set (am_pad0, “volume”, 5.0, NULL);
g_object_set (am_pad1, “volume”, 1.0, NULL);
...
g_object_set (am_padN, “volume”, 10.0, NULL);

Refer to the video mixer’s documentation for more info:

Michael Gruner <[hidden email]>
Embedded Linux and GStreamer solutions
RidgeRun Engineering

On Jun 1, 2016, at 17:59, Natanael Mojica <[hidden email]> wrote:

Hi:

I have a audiomixer element in my pipeline, and others elements linked into that
but now I want to change de volume of any audiosource connected to a audiomixer

        gst_bin_add(GST_BIN(pipeline), source->get_bin());
        GstPad *mixer_pad = gst_element_request_pad (audiomixer, mix_template, NULL, NULL);
        GstPad *a_pad = gst_element_get_static_pad(source->get_bin(), "audiosrc");
        if (gst_pad_link (a_pad, mixer_pad) != GST_PAD_LINK_OK ){
                 g_critical ("link audio source to audiomixer failed.\n");
                 exit(1);
         }

for example

filesrc -> decodbin -> queue -> audiomixer (sink0)

filesrc2 .....                               -> audiomixer(sink1)
....
....
...                                               -> audiomixer (sinkn)
My question is , how to set mute all sink less sink2 o sink3 , or set a volume property in 4 of the sink2 pad

thanks

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to set a volume property in audiomixer's sink pads?

Natanael Mojica
In reply to this post by Natanael Mojica
Thanks Michael

I tried your recomendation but that not work, example:

GObject *pad =G_OBJECT(gst_element_get_static_pad(audiomixer,                        sink.toUtf8().constData()));

then:

        g_object_set(pad, "volume", x,NULL);

and in running time I get this error:

              g_object_set: assertion 'G_IS_OBJECT (object)' failed

and if in another way:

g_object_set(gst_element_get_static_pad(audiomixer,                        sink.toUtf8().constData()), "volume", x , NULL);

dont work ., getting same error message

So, whats is the correct way to do that??

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to set a volume property in audiomixer's sink pads?

Michael Gruner
Hi Natanael

The problem you are having now is because you are using get_element_get_static_pad to ask for the audiomixer pad. This function is for static pads only. The videomixer pads are request pads, hence this function will return NULL giving you the error on the next functions. 

Using your original code, it should look something like:

gst_bin_add(GST_BIN(pipeline), source->get_bin());
        GstPad *mixer_pad = gst_element_request_pad (audiomixer, mix_template, NULL, NULL);
        GstPad *a_pad = gst_element_get_static_pad(source->get_bin(), "audiosrc");
        if (gst_pad_link (a_pad, mixer_pad) != GST_PAD_LINK_OK ){
                 g_critical ("link audio source to audiomixer failed.\n");
                 exit(1);
         }
g_object_set(mixer_pad, “mute”, TRUE, NULL);

Note how I’m using the pad that was returned originally by gst_element_request_pad. You need to keep a reference of the pads in order to set the properties later.

Michael Gruner <[hidden email]>
Embedded Linux and GStreamer solutions
RidgeRun Engineering

On Jun 2, 2016, at 21:10, Natanael Mojica <[hidden email]> wrote:

Thanks Michael

I tried your recomendation but that not work, example:

GObject *pad =G_OBJECT(gst_element_get_static_pad(audiomixer,                        sink.toUtf8().constData()));

then:

        g_object_set(pad, "volume", x,NULL);

and in running time I get this error:

              g_object_set: assertion 'G_IS_OBJECT (object)' failed

and if in another way:

g_object_set(gst_element_get_static_pad(audiomixer,                        sink.toUtf8().constData()), "volume", x , NULL);

dont work ., getting same error message

So, whats is the correct way to do that??
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to set a volume property in audiomixer's sink pads?

Natanael Mojica
In reply to this post by Natanael Mojica
my error was a null pointer ..
now audio mixer set a volume on a sink0 but when i changed to  sink1, no audio and volume setting dont work, then I changed audiomixer by a adder, but when I added more audio signals the pipeline (video signal associated to a audio signal on sink) was freeze
bellow snipps of my code:

     gchar *name1 = g_strdup_printf ("sink_%u", audioItem);
     g_object_set(G_OBJECT(gst_element_get_static_pad(audiomixer, name1)), "volume", x,NULL);

whith this, no error messaged.
 but the audiomixer 's behavior was not the wanted

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to set a volume property in audiomixer's sink pads?

Sebastian Dröge-3
In reply to this post by Michael Gruner
On Do, 2016-06-02 at 21:45 -0600, Michael Gruner wrote:
> Hi Natanael
>
> The problem you are having now is because you are
> using get_element_get_static_pad to ask for the audiomixer pad. This
> function is for static pads only. The videomixer pads are request
> pads, hence this function will return NULL giving you the error on
> the next functions. 

Small correction. The name is misleading and it's more a
gst_element_get_existing_pad(). If a request pad with that name, or a
sometimes pad, exists on the element then it will return that too.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment