3 int main(int argc, char *argv[]) {
4 GstElement *pipeline, *bin, *equalizer, *convert, *sink;
5 GstPad *pad, *ghost_pad;
9 /* Initialize GStreamer */
10 gst_init (&argc, &argv);
12 /* Build the pipeline */
13 pipeline = gst_parse_launch ("playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm", NULL);
15 /* Create the elements inside the sink bin */
16 equalizer = gst_element_factory_make ("equalizer-3bands", "equalizer");
17 convert = gst_element_factory_make ("audioconvert", "convert");
18 sink = gst_element_factory_make ("autoaudiosink", "audio_sink");
19 if (!equalizer || !convert || !sink) {
20 g_printerr ("Not all elements could be created.\n");
24 /* Create the sink bin, add the elements and link them */
25 bin = gst_bin_new ("audio_sink_bin");
26 gst_bin_add_many (GST_BIN (bin), equalizer, convert, sink, NULL);
27 gst_element_link_many (equalizer, convert, sink, NULL);
28 pad = gst_element_get_static_pad (equalizer, "sink");
29 ghost_pad = gst_ghost_pad_new ("sink", pad);
30 gst_pad_set_active (ghost_pad, TRUE);
31 gst_element_add_pad (bin, ghost_pad);
32 gst_object_unref (pad);
34 /* Configure the equalizer */
35 g_object_set (G_OBJECT (equalizer), "band1", (gdouble)-24.0, NULL);
36 g_object_set (G_OBJECT (equalizer), "band2", (gdouble)-24.0, NULL);
38 /* Set playbin2's audio sink to be our sink bin */
39 g_object_set (GST_OBJECT (pipeline), "audio-sink", bin, NULL);
42 gst_element_set_state (pipeline, GST_STATE_PLAYING);
44 /* Wait until error or EOS */
45 bus = gst_element_get_bus (pipeline);
46 msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
50 gst_message_unref (msg);
51 gst_object_unref (bus);
52 gst_element_set_state (pipeline, GST_STATE_NULL);
53 gst_object_unref (pipeline);