check: Added gst_check_setup_events_with_stream_id()

Added a new function gst_check_setup_events_with_stream_id(), since
gst_check_setup_events() does not work with multiple pads.

https://bugzilla.gnome.org/show_bug.cgi?id=703377
This commit is contained in:
Jonas Holmberg 2013-07-01 11:10:00 +02:00 committed by Sebastian Dröge
parent 948a9d2f2b
commit 0ea8748c6b
5 changed files with 37 additions and 18 deletions

View file

@ -908,6 +908,7 @@ gst_check_element_push_buffer_list
gst_check_element_push_buffer
gst_check_run_suite
gst_check_setup_events
gst_check_setup_events_with_stream_id
<SUBSECTION Private>
MAIN_INIT

View file

@ -80,6 +80,7 @@ LIBGSTCHECK_EXPORTED_FUNCS = \
gst_check_run_suite \
gst_check_setup_element \
gst_check_setup_events \
gst_check_setup_events_with_stream_id \
gst_check_setup_sink_pad \
gst_check_setup_sink_pad_by_name \
gst_check_setup_src_pad \

View file

@ -719,23 +719,23 @@ _gst_check_run_test_func (const gchar * func_name)
}
/**
* gst_check_setup_events:
* gst_check_setup_events_with_stream_id:
* @srcpad: The src #GstPad to push on
* @element: The #GstElement use to create the stream id
* @caps: (allow-none): #GstCaps in case caps event must be sent
* @format: The #GstFormat of the default segment to send
* @stream_id: A unique identifier for the stream
*
* Push stream-start, caps and segment event, which concist of the minimum required
* events to allow streaming. Caps is optional to allow raw src testing.
* Push stream-start, caps and segment event, which concist of the minimum
* required events to allow streaming. Caps is optional to allow raw src
* testing.
*/
void
gst_check_setup_events (GstPad * srcpad, GstElement * element,
GstCaps * caps, GstFormat format)
gst_check_setup_events_with_stream_id (GstPad * srcpad, GstElement * element,
GstCaps * caps, GstFormat format, const gchar * stream_id)
{
gchar *stream_id;
GstSegment segment;
stream_id = gst_pad_create_stream_id (srcpad, element, NULL);
gst_segment_init (&segment, format);
fail_unless (gst_pad_push_event (srcpad,
@ -743,6 +743,28 @@ gst_check_setup_events (GstPad * srcpad, GstElement * element,
if (caps)
fail_unless (gst_pad_push_event (srcpad, gst_event_new_caps (caps)));
fail_unless (gst_pad_push_event (srcpad, gst_event_new_segment (&segment)));
}
/**
* gst_check_setup_events:
* @srcpad: The src #GstPad to push on
* @element: The #GstElement use to create the stream id
* @caps: (allow-none): #GstCaps in case caps event must be sent
* @format: The #GstFormat of the default segment to send
*
* Push stream-start, caps and segment event, which concist of the minimum
* required events to allow streaming. Caps is optional to allow raw src
* testing. If @element has more than one src or sink pad, use
* gst_check_setup_events_with_stream_id() instead.
*/
void
gst_check_setup_events (GstPad * srcpad, GstElement * element,
GstCaps * caps, GstFormat format)
{
gchar *stream_id;
stream_id = gst_pad_create_stream_id (srcpad, element, NULL);
gst_check_setup_events_with_stream_id (srcpad, element, caps, format,
stream_id);
g_free (stream_id);
}

View file

@ -96,6 +96,8 @@ gint gst_check_run_suite (Suite * suite, const gchar * name,
const gchar * fname);
void gst_check_setup_events (GstPad * srcpad, GstElement * element,
GstCaps * caps, GstFormat format);
void gst_check_setup_events_with_stream_id (GstPad * srcpad,
GstElement * element, GstCaps * caps, GstFormat format, const gchar * id);
#define fail_unless_message_error(msg, domain, code) \
gst_check_message_error (msg, GST_MESSAGE_ERROR, \

View file

@ -36,10 +36,6 @@ struct TestData
static void
setup_test_objects (struct TestData *td, GstPadChainFunction chain_func)
{
GstSegment segment;
gst_segment_init (&segment, GST_FORMAT_BYTES);
td->mycaps = gst_caps_new_empty_simple ("test/test");
td->funnel = gst_element_factory_make ("funnel", NULL);
@ -64,16 +60,13 @@ setup_test_objects (struct TestData *td, GstPadChainFunction chain_func)
td->mysrc1 = gst_pad_new ("src1", GST_PAD_SRC);
gst_pad_set_active (td->mysrc1, TRUE);
gst_pad_push_event (td->mysrc1, gst_event_new_stream_start ("test"));
gst_pad_set_caps (td->mysrc1, td->mycaps);
gst_pad_push_event (td->mysrc1, gst_event_new_segment (&segment));
gst_check_setup_events_with_stream_id (td->mysrc1, td->funnel, td->mycaps,
GST_FORMAT_BYTES, "test1");
td->mysrc2 = gst_pad_new ("src2", GST_PAD_SRC);
gst_pad_set_active (td->mysrc2, TRUE);
gst_pad_push_event (td->mysrc2, gst_event_new_stream_start ("test"));
gst_pad_set_caps (td->mysrc2, td->mycaps);
gst_pad_push_event (td->mysrc2, gst_event_new_segment (&segment));
gst_check_setup_events_with_stream_id (td->mysrc2, td->funnel, td->mycaps,
GST_FORMAT_BYTES, "test2");
fail_unless (GST_PAD_LINK_SUCCESSFUL (gst_pad_link (td->funnelsrc,
td->mysink)));