Blame tests/check/elements/playsink.c

Packit 971217
/* GStreamer unit tests for playsink
Packit 971217
 * Copyright (C) 2015 Tim-Philipp Müller <tim centricular com>
Packit 971217
 *
Packit 971217
 * This library is free software; you can redistribute it and/or
Packit 971217
 * modify it under the terms of the GNU Library General Public
Packit 971217
 * License as published by the Free Software Foundation; either
Packit 971217
 * version 2 of the License, or (at your option) any later version.
Packit 971217
 *
Packit 971217
 * This library is distributed in the hope that it will be useful,
Packit 971217
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 971217
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 971217
 * Library General Public License for more details.
Packit 971217
 *
Packit 971217
 * You should have received a copy of the GNU Library General Public
Packit 971217
 * License along with this library; if not, write to the
Packit 971217
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Packit 971217
 * Boston, MA 02110-1301, USA.
Packit 971217
 */
Packit 971217
Packit 971217
#ifdef HAVE_CONFIG_H
Packit 971217
# include <config.h>
Packit 971217
#endif
Packit 971217
Packit 971217
#include <gst/check/gstcheck.h>
Packit 971217
Packit 971217
Packit 971217
GST_START_TEST (test_volume_in_sink)
Packit 971217
{
Packit 971217
  GstElement *pipe, *audiosink, *playsink, *fakesink, *volume, *src;
Packit 971217
  GstPad *sinkpad;
Packit 971217
  GstMessage *msg;
Packit 971217
Packit 971217
  pipe = gst_pipeline_new (NULL);
Packit 971217
  playsink = gst_element_factory_make ("playsink", NULL);
Packit 971217
Packit 971217
  audiosink = gst_bin_new ("audiosink");
Packit 971217
  volume = gst_element_factory_make ("volume", NULL);
Packit 971217
  fakesink = gst_element_factory_make ("fakesink", NULL);
Packit 971217
  gst_bin_add_many (GST_BIN (audiosink), volume, fakesink, NULL);
Packit 971217
  gst_element_link_many (volume, fakesink, NULL);
Packit 971217
  sinkpad = gst_element_get_static_pad (volume, "sink");
Packit 971217
  gst_element_add_pad (audiosink, gst_ghost_pad_new ("sink", sinkpad));
Packit 971217
  gst_object_unref (sinkpad);
Packit 971217
Packit 971217
  g_object_set (playsink, "audio-sink", audiosink, NULL);
Packit 971217
Packit 971217
  src = gst_element_factory_make ("audiotestsrc", NULL);
Packit 971217
  g_object_set (src, "num-buffers", 5, NULL);
Packit 971217
Packit 971217
Packit 971217
  gst_bin_add (GST_BIN (pipe), src);
Packit 971217
  gst_bin_add (GST_BIN (pipe), playsink);
Packit 971217
Packit 971217
  if (!gst_element_link (src, playsink))
Packit 971217
    g_error ("oops");
Packit 971217
Packit 971217
  fail_unless_equals_int (gst_element_set_state (pipe, GST_STATE_PLAYING),
Packit 971217
      GST_STATE_CHANGE_ASYNC);
Packit 971217
Packit 971217
  /* wait for eos */
Packit 971217
  msg = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (pipe), GST_CLOCK_TIME_NONE,
Packit 971217
      GST_MESSAGE_EOS | GST_MESSAGE_ERROR);
Packit 971217
  fail_if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
Packit 971217
  gst_message_unref (msg);
Packit 971217
Packit 971217
  fail_unless_equals_int (gst_element_set_state (pipe, GST_STATE_NULL),
Packit 971217
      GST_STATE_CHANGE_SUCCESS);
Packit 971217
Packit 971217
  gst_object_unref (pipe);
Packit 971217
}
Packit 971217
Packit 971217
GST_END_TEST;
Packit 971217
Packit 971217
Packit 971217
static Suite *
Packit 971217
playsink_suite (void)
Packit 971217
{
Packit 971217
  Suite *s = suite_create ("playsink");
Packit 971217
  TCase *tc_chain = tcase_create ("general");
Packit 971217
Packit 971217
  suite_add_tcase (s, tc_chain);
Packit 971217
Packit 971217
  tcase_add_test (tc_chain, test_volume_in_sink);
Packit 971217
Packit 971217
  return s;
Packit 971217
}
Packit 971217
Packit 971217
GST_CHECK_MAIN (playsink);