mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 23:36:38 +00:00
153931fa86
Original commit message from CVS: 2005-11-21 Andy Wingo <wingo@pobox.com> * check/gst/gstevent.c (create_custom_events): Check that FLUSH_STOP is serialized. * check/elements/identity.c (event_func): * check/elements/fakesrc.c (event_func): No stream lock, the core takes it. * gst/base/gstbasetransform.c (gst_base_transform_event): No more stream lock taking, yay. * gst/gstevent.h (GST_EVENT_FLUSH_STOP): Marked as serialized to ensure that core takes the stream lock. * gst/base/gstbasesrc.c (gst_base_src_do_seek): Update for stream lock name change. * gst/base/gstbasesink.c (gst_base_sink_event): No need to take the stream lock for EOS, NEWSEGMENT, or FLUSH_STOP, the core does it already. For the flush start we do take it though so we get the right preroll state change messages. * gst/gstqueue.c (gst_queue_sink_activate_push): No need to take the stream lock here, the core does it for us. * gst/gstpad.h (GST_PAD_GET_STREAM_LOCK): Renamed from GST_STREAM_GET_LOCK. (GST_PAD_STREAM_LOCK, GST_PAD_STREAM_TRYLOCK) (GST_PAD_STREAM_UNLOCK, GST_PAD_STREAM_UNLOCK_FULL) (GST_PAD_STREAM_LOCK_FULL): Renamed from GST_STREAM_*. (GST_PAD_GET_PREROLL_LOCK): Renamed from GST_PREROLL_GET_LOCK. (GST_PAD_PREROLL_LOCK, GST_PAD_PREROLL_TRYLOCK) (GST_PAD_PREROLL_UNLOCK): Renamed from GST_PREROLL_*. * gst/gstpad.c: Update for stream lock name change. * gst/base/gstbasesink.c: Update for preroll lock name change.
138 lines
3.5 KiB
C
138 lines
3.5 KiB
C
/* GStreamer
|
|
*
|
|
* unit test for identity
|
|
*
|
|
* Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
|
|
*
|
|
* 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 <unistd.h>
|
|
|
|
#include <gst/check/gstcheck.h>
|
|
|
|
GList *buffers = NULL;
|
|
gboolean have_eos = FALSE;
|
|
|
|
/* For ease of programming we use globals to keep refs for our floating
|
|
* src and sink pads we create; otherwise we always have to do get_pad,
|
|
* get_peer, and then remove references in every test function */
|
|
GstPad *mysrcpad, *mysinkpad;
|
|
|
|
|
|
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
GST_PAD_SINK,
|
|
GST_PAD_ALWAYS,
|
|
GST_STATIC_CAPS_ANY);
|
|
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
|
GST_PAD_SRC,
|
|
GST_PAD_ALWAYS,
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
gboolean
|
|
event_func (GstPad * pad, GstEvent * event)
|
|
{
|
|
if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
|
|
have_eos = TRUE;
|
|
gst_event_unref (event);
|
|
return TRUE;
|
|
}
|
|
|
|
gst_event_unref (event);
|
|
return FALSE;
|
|
}
|
|
|
|
GstElement *
|
|
setup_identity ()
|
|
{
|
|
GstElement *identity;
|
|
|
|
GST_DEBUG ("setup_identity");
|
|
|
|
identity = gst_check_setup_element ("identity");
|
|
mysrcpad = gst_check_setup_src_pad (identity, &srctemplate, NULL);
|
|
mysinkpad = gst_check_setup_sink_pad (identity, &sinktemplate, NULL);
|
|
gst_pad_set_event_function (mysinkpad, event_func);
|
|
gst_pad_set_active (mysrcpad, TRUE);
|
|
gst_pad_set_active (mysinkpad, TRUE);
|
|
|
|
return identity;
|
|
}
|
|
|
|
void
|
|
cleanup_identity (GstElement * identity)
|
|
{
|
|
GST_DEBUG ("cleanup_identity");
|
|
|
|
gst_check_teardown_src_pad (identity);
|
|
gst_check_teardown_sink_pad (identity);
|
|
gst_check_teardown_element (identity);
|
|
}
|
|
|
|
GST_START_TEST (test_one_buffer)
|
|
{
|
|
GstElement *identity;
|
|
GstBuffer *buffer;
|
|
|
|
identity = setup_identity ();
|
|
fail_unless (gst_element_set_state (identity,
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
"could not set to playing");
|
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
|
|
memcpy (GST_BUFFER_DATA (buffer), "data", 4);
|
|
/* pushing gives away my reference ... */
|
|
gst_pad_push (mysrcpad, buffer);
|
|
/* ... but it should end up being collected on the global buffer list */
|
|
fail_unless (g_list_length (buffers) == 1);
|
|
fail_unless ((GstBuffer *) (g_list_first (buffers)->data) == buffer);
|
|
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
|
|
|
|
/* cleanup */
|
|
cleanup_identity (identity);
|
|
}
|
|
|
|
GST_END_TEST;
|
|
|
|
Suite *
|
|
identity_suite (void)
|
|
{
|
|
Suite *s = suite_create ("identity");
|
|
TCase *tc_chain = tcase_create ("general");
|
|
|
|
suite_add_tcase (s, tc_chain);
|
|
tcase_add_test (tc_chain, test_one_buffer);
|
|
|
|
return s;
|
|
}
|
|
|
|
int
|
|
main (int argc, char **argv)
|
|
{
|
|
int nf;
|
|
|
|
Suite *s = identity_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;
|
|
}
|