1 /* GStreamer unit tests for playsink
2 * Copyright (C) 2015 Tim-Philipp Müller <tim centricular com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
24 #include <gst/check/gstcheck.h>
27 GST_START_TEST (test_volume_in_sink)
29 GstElement *pipe, *audiosink, *playsink, *fakesink, *volume, *src;
33 pipe = gst_pipeline_new (NULL);
34 playsink = gst_element_factory_make ("playsink", NULL);
36 audiosink = gst_bin_new ("audiosink");
37 volume = gst_element_factory_make ("volume", NULL);
38 fakesink = gst_element_factory_make ("fakesink", NULL);
39 gst_bin_add_many (GST_BIN (audiosink), volume, fakesink, NULL);
40 gst_element_link_many (volume, fakesink, NULL);
41 sinkpad = gst_element_get_static_pad (volume, "sink");
42 gst_element_add_pad (audiosink, gst_ghost_pad_new ("sink", sinkpad));
43 gst_object_unref (sinkpad);
45 g_object_set (playsink, "audio-sink", audiosink, NULL);
47 src = gst_element_factory_make ("audiotestsrc", NULL);
48 g_object_set (src, "num-buffers", 5, NULL);
51 gst_bin_add (GST_BIN (pipe), src);
52 gst_bin_add (GST_BIN (pipe), playsink);
54 if (!gst_element_link (src, playsink))
57 fail_unless_equals_int (gst_element_set_state (pipe, GST_STATE_PLAYING),
58 GST_STATE_CHANGE_ASYNC);
61 msg = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (pipe), GST_CLOCK_TIME_NONE,
62 GST_MESSAGE_EOS | GST_MESSAGE_ERROR);
63 fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
64 gst_message_unref (msg);
66 fail_unless_equals_int (gst_element_set_state (pipe, GST_STATE_NULL),
67 GST_STATE_CHANGE_SUCCESS);
69 gst_object_unref (pipe);
78 Suite *s = suite_create ("playsink");
79 TCase *tc_chain = tcase_create ("general");
81 suite_add_tcase (s, tc_chain);
83 tcase_add_test (tc_chain, test_volume_in_sink);
88 GST_CHECK_MAIN (playsink);