• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer unit tests for playsink
2  * Copyright (C) 2015 Tim-Philipp Müller <tim centricular com>
3  *
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.
8  *
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.
13  *
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.
18  */
19 
20 #ifdef HAVE_CONFIG_H
21 # include <config.h>
22 #endif
23 
24 #include <gst/check/gstcheck.h>
25 
26 
GST_START_TEST(test_volume_in_sink)27 GST_START_TEST (test_volume_in_sink)
28 {
29   GstElement *pipe, *audiosink, *playsink, *fakesink, *volume, *src;
30   GstPad *sinkpad;
31   GstMessage *msg;
32 
33   pipe = gst_pipeline_new (NULL);
34   playsink = gst_element_factory_make ("playsink", NULL);
35 
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);
44 
45   g_object_set (playsink, "audio-sink", audiosink, NULL);
46 
47   src = gst_element_factory_make ("audiotestsrc", NULL);
48   g_object_set (src, "num-buffers", 5, NULL);
49 
50 
51   gst_bin_add (GST_BIN (pipe), src);
52   gst_bin_add (GST_BIN (pipe), playsink);
53 
54   if (!gst_element_link (src, playsink))
55     g_error ("oops");
56 
57   fail_unless_equals_int (gst_element_set_state (pipe, GST_STATE_PLAYING),
58       GST_STATE_CHANGE_ASYNC);
59 
60   /* wait for eos */
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);
65 
66   fail_unless_equals_int (gst_element_set_state (pipe, GST_STATE_NULL),
67       GST_STATE_CHANGE_SUCCESS);
68 
69   gst_object_unref (pipe);
70 }
71 
72 GST_END_TEST;
73 
74 
75 static Suite *
playsink_suite(void)76 playsink_suite (void)
77 {
78   Suite *s = suite_create ("playsink");
79   TCase *tc_chain = tcase_create ("general");
80 
81   suite_add_tcase (s, tc_chain);
82 
83   tcase_add_test (tc_chain, test_volume_in_sink);
84 
85   return s;
86 }
87 
88 GST_CHECK_MAIN (playsink);
89