2005-08-20 12:14:28 +00:00
|
|
|
/* 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
|
2012-11-03 20:44:48 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2005-08-20 12:14:28 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <gst/check/gstcheck.h>
|
|
|
|
|
2008-02-29 13:59:24 +00:00
|
|
|
static gboolean have_eos = FALSE;
|
2005-08-20 12:14:28 +00:00
|
|
|
|
|
|
|
/* 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 */
|
2008-02-29 13:59:24 +00:00
|
|
|
static GstPad *mysrcpad, *mysinkpad;
|
2005-08-20 12:14:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2008-02-29 13:59:24 +00:00
|
|
|
static gboolean
|
2011-11-17 11:40:45 +00:00
|
|
|
event_func (GstPad * pad, GstObject * parent, GstEvent * event)
|
2005-08-20 12:14:28 +00:00
|
|
|
{
|
|
|
|
if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
|
|
|
|
have_eos = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_event_unref (event);
|
2013-05-09 11:32:07 +00:00
|
|
|
return TRUE;
|
2005-08-20 12:14:28 +00:00
|
|
|
}
|
|
|
|
|
2008-02-29 13:59:24 +00:00
|
|
|
static GstElement *
|
|
|
|
setup_identity (void)
|
2005-08-20 12:14:28 +00:00
|
|
|
{
|
|
|
|
GstElement *identity;
|
|
|
|
|
|
|
|
GST_DEBUG ("setup_identity");
|
|
|
|
|
check/Makefile.am: don't valgrind the controller test - it's leaking - Stefan, HELP
Original commit message from CVS:
* check/Makefile.am:
don't valgrind the controller test - it's leaking - Stefan, HELP
* gst/check/gstcheck.c: (gst_check_message_error),
(gst_check_chain_func), (gst_check_setup_element),
(gst_check_teardown_element), (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
* gst/check/gstcheck.h:
add a bunch of methods to set up elements, and src and sink pads
* check/elements/fakesrc.c: (setup_fakesrc), (cleanup_fakesrc):
* check/elements/identity.c: (setup_identity), (cleanup_identity),
(GST_START_TEST):
use them
* gst/gstmessage.c:
* gst/gsttag.h:
whitespace/doc fixes
2005-08-21 10:39:39 +00:00
|
|
|
identity = gst_check_setup_element ("identity");
|
2011-11-24 20:36:12 +00:00
|
|
|
mysrcpad = gst_check_setup_src_pad (identity, &srctemplate);
|
|
|
|
mysinkpad = gst_check_setup_sink_pad (identity, &sinktemplate);
|
2005-08-20 12:14:28 +00:00
|
|
|
gst_pad_set_event_function (mysinkpad, event_func);
|
2005-08-30 19:45:38 +00:00
|
|
|
gst_pad_set_active (mysrcpad, TRUE);
|
|
|
|
gst_pad_set_active (mysinkpad, TRUE);
|
2005-08-20 12:14:28 +00:00
|
|
|
|
|
|
|
return identity;
|
|
|
|
}
|
|
|
|
|
2008-02-29 13:59:24 +00:00
|
|
|
static void
|
2005-08-20 12:14:28 +00:00
|
|
|
cleanup_identity (GstElement * identity)
|
|
|
|
{
|
|
|
|
GST_DEBUG ("cleanup_identity");
|
|
|
|
|
libs/gst/check/gstcheck.c: do not automatically (de)activate pads
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
do not automatically (de)activate pads
* tests/check/Makefile.am:
* tests/check/elements/queue.c: (queue_overrun), (queue_underrun),
(setup_queue), (cleanup_queue), (GST_START_TEST), (queue_suite):
add new, yet simple tests for queue
* tests/check/elements/fakesrc.c: (cleanup_fakesrc):
* tests/check/elements/fdsrc.c: (cleanup_fdsrc):
* tests/check/elements/filesrc.c: (cleanup_filesrc),
(GST_START_TEST):
* tests/check/elements/identity.c: (cleanup_identity):
consistent pad (de)activation
2006-12-21 08:12:28 +00:00
|
|
|
gst_pad_set_active (mysrcpad, FALSE);
|
|
|
|
gst_pad_set_active (mysinkpad, FALSE);
|
check/Makefile.am: don't valgrind the controller test - it's leaking - Stefan, HELP
Original commit message from CVS:
* check/Makefile.am:
don't valgrind the controller test - it's leaking - Stefan, HELP
* gst/check/gstcheck.c: (gst_check_message_error),
(gst_check_chain_func), (gst_check_setup_element),
(gst_check_teardown_element), (gst_check_setup_src_pad),
(gst_check_teardown_src_pad), (gst_check_setup_sink_pad),
(gst_check_teardown_sink_pad):
* gst/check/gstcheck.h:
add a bunch of methods to set up elements, and src and sink pads
* check/elements/fakesrc.c: (setup_fakesrc), (cleanup_fakesrc):
* check/elements/identity.c: (setup_identity), (cleanup_identity),
(GST_START_TEST):
use them
* gst/gstmessage.c:
* gst/gsttag.h:
whitespace/doc fixes
2005-08-21 10:39:39 +00:00
|
|
|
gst_check_teardown_src_pad (identity);
|
|
|
|
gst_check_teardown_sink_pad (identity);
|
|
|
|
gst_check_teardown_element (identity);
|
2005-08-20 12:14:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_one_buffer)
|
|
|
|
{
|
|
|
|
GstElement *identity;
|
|
|
|
GstBuffer *buffer;
|
2013-05-09 11:32:07 +00:00
|
|
|
GstSegment segment;
|
2005-08-20 12:14:28 +00:00
|
|
|
|
|
|
|
identity = setup_identity ();
|
|
|
|
fail_unless (gst_element_set_state (identity,
|
2005-09-02 15:42:00 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
2005-08-20 12:14:28 +00:00
|
|
|
|
2013-05-09 11:32:07 +00:00
|
|
|
gst_segment_init (&segment, GST_FORMAT_BYTES);
|
|
|
|
gst_pad_push_event (mysrcpad, gst_event_new_stream_start ("test"));
|
|
|
|
gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment));
|
|
|
|
|
2005-08-20 12:14:28 +00:00
|
|
|
buffer = gst_buffer_new_and_alloc (4);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
|
2011-03-21 18:15:27 +00:00
|
|
|
|
2012-01-20 13:23:57 +00:00
|
|
|
gst_buffer_fill (buffer, 0, "data", 4);
|
2008-01-12 20:22:30 +00:00
|
|
|
|
2005-08-20 12:14:28 +00:00
|
|
|
/* pushing gives away my reference ... */
|
2008-01-12 20:22:30 +00:00
|
|
|
fail_unless (gst_pad_push (mysrcpad, buffer) == GST_FLOW_OK,
|
|
|
|
"Failed pushing buffer to identity");
|
|
|
|
|
check/elements/identity.c: Make the error a little clearer when the test fails because identity made a copy of the bu...
Original commit message from CVS:
* check/elements/identity.c: (GST_START_TEST):
Make the error a little clearer when the test fails because
identity made a copy of the buffer.
* docs/gst/gstreamer-sections.txt:
New symbols in gstbasetransform.h
* gst/base/gstbasetransform.c: (gst_base_transform_class_init),
(gst_base_transform_init), (gst_base_transform_transform_size),
(gst_base_transform_configure_caps), (gst_base_transform_setcaps),
(gst_base_transform_default_prepare_buf),
(gst_base_transform_get_unit_size),
(gst_base_transform_buffer_alloc),
(gst_base_transform_handle_buffer), (gst_base_transform_chain),
(gst_base_transform_change_state),
(gst_base_transform_set_passthrough),
(gst_base_transform_set_in_place),
(gst_base_transform_is_in_place):
* gst/base/gstbasetransform.h:
Change BaseTransform to separate in_place operate from same_caps
output. in_place implies that the element can perform the transform
on incoming buffers in-place, even if the caps on the output are
different.
Sub-class elements can now implement special buffer allocation
methods for outgoing buffers if they wish to.
Big documentation addition.
* gst/elements/gstcapsfilter.c: (gst_capsfilter_transform_ip):
* gst/elements/gstelements.c:
Changes for basetransform modifications.
* gst/elements/Makefile.am:
* gst/elements/gstfdsrc.c: (gst_fdsrc_init), (gst_fdsrc_create):
Compile fix. Extra debug output.
2005-09-09 17:42:20 +00:00
|
|
|
/* ... 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);
|
2005-08-20 12:14:28 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (buffer, "buffer", 1);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_identity (identity);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2008-02-29 13:59:24 +00:00
|
|
|
static Suite *
|
2005-08-20 12:14:28 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2006-07-01 20:56:56 +00:00
|
|
|
GST_CHECK_MAIN (identity);
|