mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 03:00:35 +00:00
58cc2ede0a
Original commit message from CVS: * gst/gstelementfactory.h: * tests/check/elements/fakesink.c: * tests/check/elements/fakesrc.c: (setup_fakesrc): * tests/check/elements/fdsrc.c: (setup_fdsrc): * tests/check/elements/filesink.c: (setup_filesink): * tests/check/elements/filesrc.c: (setup_filesrc): * tests/check/elements/identity.c: (setup_identity): * tests/check/elements/tee.c: * tests/check/generic/sinks.c: * tests/check/generic/states.c: (setup), (teardown): * tests/check/gst/gst.c: * tests/check/gst/gstabi.c: * tests/check/gst/gstbin.c: * tests/check/gst/gstbus.c: (pull_messages): * tests/check/gst/gstcaps.c: * tests/check/gst/gstelement.c: * tests/check/gst/gstevent.c: * tests/check/gst/gstghostpad.c: * tests/check/gst/gstiterator.c: * tests/check/gst/gstmessage.c: * tests/check/gst/gstminiobject.c: (my_foo_init): * tests/check/gst/gstobject.c: (thread_name_object), (gst_object_suite): * tests/check/gst/gstpad.c: * tests/check/gst/gstplugin.c: * tests/check/gst/gstpoll.c: * tests/check/gst/gstquery.c: * tests/check/gst/gstsegment.c: * tests/check/gst/gststructure.c: * tests/check/gst/gstsystemclock.c: * tests/check/gst/gsttask.c: * tests/check/gst/gstutils.c: * tests/check/gst/gstvalue.c: * tests/check/gst/struct_hppa.h: * tests/check/gst/struct_i386.h: * tests/check/gst/struct_ppc32.h: * tests/check/gst/struct_ppc64.h: * tests/check/gst/struct_x86_64.h: * tests/check/libs/adapter.c: (create_and_fill_adapter): * tests/check/libs/basesrc.c: * tests/check/libs/controller.c: (GST_START_TEST): * tests/check/libs/gdp.c: * tests/check/libs/gstnetclientclock.c: * tests/check/libs/gstnettimeprovider.c: * tests/check/libs/libsabi.c: * tests/check/libs/struct_hppa.h: * tests/check/libs/struct_i386.h: * tests/check/libs/struct_ppc32.h: * tests/check/libs/struct_ppc64.h: * tests/check/libs/struct_x86_64.h: * tests/check/pipelines/cleanup.c: * tests/check/pipelines/simple-launch-lines.c: * tests/check/pipelines/stress.c: And correct even more valid sparse warnings. * win32/common/libgstreamer.def: Add gst_poll_fd_init to the list of symbols.
127 lines
3.5 KiB
C
127 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>
|
|
|
|
static 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 */
|
|
static 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);
|
|
|
|
static 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;
|
|
}
|
|
|
|
static GstElement *
|
|
setup_identity (void)
|
|
{
|
|
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;
|
|
}
|
|
|
|
static void
|
|
cleanup_identity (GstElement * identity)
|
|
{
|
|
GST_DEBUG ("cleanup_identity");
|
|
|
|
gst_pad_set_active (mysrcpad, FALSE);
|
|
gst_pad_set_active (mysinkpad, FALSE);
|
|
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 ... */
|
|
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK,
|
|
"Failed pushing buffer to identity");
|
|
|
|
/* ... 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;
|
|
|
|
static 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;
|
|
}
|
|
|
|
GST_CHECK_MAIN (identity);
|