mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 16:26:39 +00:00
f8e79bdf86
Original commit message from CVS: 2005-06-28 Andy Wingo <wingo@pobox.com> * *.c: Don't cast to GST_OBJECT when reffing or unreffing. Large source-munging commit!!!
206 lines
6.7 KiB
C
206 lines
6.7 KiB
C
/* GStreamer
|
|
*
|
|
* unit test for sinks
|
|
*
|
|
* Copyright (C) <2005> Wim Taymans <wim at fluendo dot com>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
* Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#include "../gstcheck.h"
|
|
|
|
/* a sink should go ASYNC to PAUSE. forcing PLAYING is possible */
|
|
START_TEST (test_sink)
|
|
{
|
|
GstElement *sink;
|
|
GstElementStateReturn ret;
|
|
GstElementState current, pending;
|
|
|
|
sink = gst_element_factory_make ("fakesink", "sink");
|
|
|
|
ret = gst_element_set_state (sink, GST_STATE_PAUSED);
|
|
fail_unless (ret == GST_STATE_ASYNC, "no async state return");
|
|
|
|
ret = gst_element_set_state (sink, GST_STATE_PLAYING);
|
|
fail_unless (ret == GST_STATE_SUCCESS, "cannot force play");
|
|
|
|
ret = gst_element_get_state (sink, ¤t, &pending, NULL);
|
|
fail_unless (ret == GST_STATE_SUCCESS, "not playing");
|
|
fail_unless (current == GST_STATE_PLAYING, "not playing");
|
|
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
|
}
|
|
|
|
END_TEST
|
|
/* a sink should go ASYNC to PAUSE. PAUSE should complete when
|
|
* prerolled. */
|
|
START_TEST (test_src_sink)
|
|
{
|
|
GstElement *sink, *src, *pipeline;
|
|
GstElementStateReturn ret;
|
|
GstElementState current, pending;
|
|
GstPad *srcpad, *sinkpad;
|
|
|
|
pipeline = gst_pipeline_new ("pipeline");
|
|
src = gst_element_factory_make ("fakesrc", "src");
|
|
sink = gst_element_factory_make ("fakesink", "sink");
|
|
|
|
gst_bin_add (GST_BIN (pipeline), src);
|
|
gst_bin_add (GST_BIN (pipeline), sink);
|
|
|
|
srcpad = gst_element_get_pad (src, "src");
|
|
sinkpad = gst_element_get_pad (sink, "sink");
|
|
gst_pad_link (srcpad, sinkpad);
|
|
gst_object_unref (srcpad);
|
|
gst_object_unref (sinkpad);
|
|
|
|
ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
|
ret = gst_element_get_state (pipeline, NULL, NULL, NULL);
|
|
fail_unless (ret == GST_STATE_SUCCESS, "no success state return");
|
|
|
|
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
fail_unless (ret == GST_STATE_SUCCESS, "cannot start play");
|
|
|
|
ret = gst_element_get_state (pipeline, ¤t, &pending, NULL);
|
|
fail_unless (ret == GST_STATE_SUCCESS, "not playing");
|
|
fail_unless (current == GST_STATE_PLAYING, "not playing");
|
|
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
|
}
|
|
|
|
END_TEST
|
|
/* a pipeline with live source should return NO_PREROLL in
|
|
* PAUSE. When removing the live source it should return ASYNC
|
|
* from the sink */
|
|
START_TEST (test_livesrc_remove)
|
|
{
|
|
GstElement *sink, *src, *pipeline;
|
|
GstElementStateReturn ret;
|
|
GstElementState current, pending;
|
|
GstPad *srcpad, *sinkpad;
|
|
GTimeVal tv;
|
|
|
|
pipeline = gst_pipeline_new ("pipeline");
|
|
src = gst_element_factory_make ("fakesrc", "src");
|
|
g_object_set (G_OBJECT (src), "is-live", TRUE, NULL);
|
|
sink = gst_element_factory_make ("fakesink", "sink");
|
|
|
|
gst_bin_add (GST_BIN (pipeline), src);
|
|
gst_bin_add (GST_BIN (pipeline), sink);
|
|
|
|
srcpad = gst_element_get_pad (src, "src");
|
|
sinkpad = gst_element_get_pad (sink, "sink");
|
|
gst_pad_link (srcpad, sinkpad);
|
|
gst_object_unref (srcpad);
|
|
gst_object_unref (sinkpad);
|
|
|
|
ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
|
fail_unless (ret == GST_STATE_NO_PREROLL, "no no_preroll state return");
|
|
|
|
ret = gst_element_get_state (src, ¤t, &pending, NULL);
|
|
fail_unless (ret == GST_STATE_NO_PREROLL, "not paused");
|
|
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
|
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
|
|
|
gst_bin_remove (GST_BIN (pipeline), src);
|
|
|
|
GST_TIME_TO_TIMEVAL (0, tv);
|
|
ret = gst_element_get_state (pipeline, ¤t, &pending, &tv);
|
|
fail_unless (ret == GST_STATE_ASYNC, "not async");
|
|
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
|
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
|
|
|
}
|
|
|
|
END_TEST
|
|
/* a sink should go ASYNC to PAUSE. PAUSE does not complete
|
|
* since we have a live source. */
|
|
START_TEST (test_livesrc_sink)
|
|
{
|
|
GstElement *sink, *src, *pipeline;
|
|
GstElementStateReturn ret;
|
|
GstElementState current, pending;
|
|
GstPad *srcpad, *sinkpad;
|
|
|
|
pipeline = gst_pipeline_new ("pipeline");
|
|
src = gst_element_factory_make ("fakesrc", "src");
|
|
g_object_set (G_OBJECT (src), "is-live", TRUE, NULL);
|
|
sink = gst_element_factory_make ("fakesink", "sink");
|
|
|
|
gst_bin_add (GST_BIN (pipeline), src);
|
|
gst_bin_add (GST_BIN (pipeline), sink);
|
|
|
|
srcpad = gst_element_get_pad (src, "src");
|
|
sinkpad = gst_element_get_pad (sink, "sink");
|
|
gst_pad_link (srcpad, sinkpad);
|
|
gst_object_unref (srcpad);
|
|
gst_object_unref (sinkpad);
|
|
|
|
ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
|
fail_unless (ret == GST_STATE_NO_PREROLL, "no no_preroll state return");
|
|
|
|
ret = gst_element_get_state (src, ¤t, &pending, NULL);
|
|
fail_unless (ret == GST_STATE_NO_PREROLL, "not paused");
|
|
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
|
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
|
|
|
ret = gst_element_get_state (pipeline, ¤t, &pending, NULL);
|
|
fail_unless (ret == GST_STATE_NO_PREROLL, "not paused");
|
|
fail_unless (current == GST_STATE_PAUSED, "not paused");
|
|
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
|
|
|
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
fail_unless (ret == GST_STATE_SUCCESS, "cannot force play");
|
|
|
|
ret = gst_element_get_state (pipeline, ¤t, &pending, NULL);
|
|
fail_unless (ret == GST_STATE_SUCCESS, "not playing");
|
|
fail_unless (current == GST_STATE_PLAYING, "not playing");
|
|
fail_unless (pending == GST_STATE_VOID_PENDING, "not playing");
|
|
}
|
|
|
|
END_TEST
|
|
/* test: try changing state of sinks */
|
|
Suite * gst_object_suite (void)
|
|
{
|
|
Suite *s = suite_create ("Sinks");
|
|
TCase *tc_chain = tcase_create ("general");
|
|
|
|
/* turn off timeout */
|
|
tcase_set_timeout (tc_chain, 60);
|
|
|
|
suite_add_tcase (s, tc_chain);
|
|
tcase_add_test (tc_chain, test_sink);
|
|
tcase_add_test (tc_chain, test_src_sink);
|
|
tcase_add_test (tc_chain, test_livesrc_remove);
|
|
tcase_add_test (tc_chain, test_livesrc_sink);
|
|
|
|
return s;
|
|
}
|
|
|
|
int
|
|
main (int argc, char **argv)
|
|
{
|
|
int nf;
|
|
|
|
Suite *s = gst_object_suite ();
|
|
SRunner *sr = srunner_create (s);
|
|
|
|
gst_check_init (&argc, &argv);
|
|
|
|
srunner_run_all (sr, CK_NORMAL);
|
|
nf = srunner_ntests_failed (sr);
|
|
srunner_free (sr);
|
|
|
|
return nf;
|
|
}
|