check: Update gst_check_element_push_buffer to 0.11 style caps

Pass the desired caps explicitely
This commit is contained in:
Olivier Crête 2012-01-28 08:38:03 +01:00
parent 4e108ee92a
commit 8f8335a7f4
2 changed files with 59 additions and 39 deletions

View file

@ -375,11 +375,32 @@ gst_check_buffer_data (GstBuffer * buffer, gconstpointer data, gsize size)
gst_buffer_unmap (buffer, &info); gst_buffer_unmap (buffer, &info);
} }
static gboolean
buffer_event_function (GstPad * pad, GstObject * noparent, GstEvent * event)
{
if (GST_EVENT_TYPE (event) == GST_EVENT_CAPS) {
GstCaps *event_caps, *current_caps;
current_caps = gst_pad_get_current_caps (pad);
gst_event_parse_caps (event, &event_caps);
fail_unless (gst_caps_is_fixed (current_caps));
fail_unless (gst_caps_is_fixed (event_caps));
fail_unless (gst_caps_is_equal_fixed (event_caps, current_caps));
gst_caps_unref (current_caps);
gst_event_unref (event);
return TRUE;
}
return gst_pad_event_default (pad, noparent, event);
}
/** /**
* gst_check_element_push_buffer_list: * gst_check_element_push_buffer_list:
* @element_name: name of the element that needs to be created * @element_name: name of the element that needs to be created
* @buffer_in: a list of buffers that needs to be puched to the element * @buffer_in: (element-type GstBuffer) (transfer full): a list of buffers that needs to be
* @buffer_out: a list of buffers that we expect from the element * puched to the element
* @buffer_out: (element-type GstBuffer) (transfer full): a list of buffers that we expect from
* the element
* @last_flow_return: the last buffer push needs to give this GstFlowReturn * @last_flow_return: the last buffer push needs to give this GstFlowReturn
* *
* Create an @element with the factory with the name and push the buffers in * Create an @element with the factory with the name and push the buffers in
@ -396,12 +417,9 @@ gst_check_buffer_data (GstBuffer * buffer, gconstpointer data, gsize size)
/* FIXME 0.11: rename this function now that there's GstBufferList? */ /* FIXME 0.11: rename this function now that there's GstBufferList? */
void void
gst_check_element_push_buffer_list (const gchar * element_name, gst_check_element_push_buffer_list (const gchar * element_name,
GList * buffer_in, GList * buffer_out, GstFlowReturn last_flow_return) GList * buffer_in, GstCaps * caps_in, GList * buffer_out,
GstCaps * caps_out, GstFlowReturn last_flow_return)
{ {
#if 0
GstCaps *sink_caps;
GstCaps *src_caps = NULL;
#endif
GstElement *element; GstElement *element;
GstPad *pad_peer; GstPad *pad_peer;
GstPad *sink_pad = NULL; GstPad *sink_pad = NULL;
@ -418,52 +436,50 @@ gst_check_element_push_buffer_list (const gchar * element_name,
buffer = GST_BUFFER (buffer_in->data); buffer = GST_BUFFER (buffer_in->data);
fail_unless (GST_IS_BUFFER (buffer), "There should be a buffer in buffer_in"); fail_unless (GST_IS_BUFFER (buffer), "There should be a buffer in buffer_in");
#if 0 src_pad = gst_pad_new ("src", GST_PAD_SRC);
src_caps = GST_BUFFER_CAPS (buffer); if (caps_in) {
#endif fail_unless (gst_caps_is_fixed (caps_in));
src_pad = gst_pad_new (NULL, GST_PAD_SRC); gst_pad_use_fixed_caps (src_pad);
#if 0 }
gst_pad_set_caps (src_pad, src_caps); /* activate the pad */
#endif gst_pad_set_active (src_pad, TRUE);
GST_DEBUG ("src pad activated");
if (caps_in)
fail_unless (gst_pad_set_caps (src_pad, caps_in));
pad_peer = gst_element_get_static_pad (element, "sink"); pad_peer = gst_element_get_static_pad (element, "sink");
fail_if (pad_peer == NULL); fail_if (pad_peer == NULL);
fail_unless (gst_pad_link (src_pad, pad_peer) == GST_PAD_LINK_OK, fail_unless (gst_pad_link (src_pad, pad_peer) == GST_PAD_LINK_OK,
"Could not link source and %s sink pads", GST_ELEMENT_NAME (element)); "Could not link source and %s sink pads", GST_ELEMENT_NAME (element));
gst_object_unref (pad_peer); gst_object_unref (pad_peer);
/* activate the pad */
gst_pad_set_active (src_pad, TRUE);
GST_DEBUG ("src pad activated");
/* don't create the sink_pad if there is no buffer_out list */ /* don't create the sink_pad if there is no buffer_out list */
if (buffer_out != NULL) { if (buffer_out != NULL) {
#if 0
gchar *temp;
#endif
GST_DEBUG ("buffer out detected, creating the sink pad"); GST_DEBUG ("buffer out detected, creating the sink pad");
/* get the sink caps */ /* get the sink caps */
#if 0 if (caps_out) {
sink_caps = GST_BUFFER_CAPS (GST_BUFFER (buffer_out->data)); gchar *temp;
fail_unless (GST_IS_CAPS (sink_caps), "buffer out don't have caps");
temp = gst_caps_to_string (sink_caps); fail_unless (gst_caps_is_fixed (caps_out));
temp = gst_caps_to_string (caps_out);
GST_DEBUG ("sink caps requested by buffer out: '%s'", temp);
g_free (temp);
}
GST_DEBUG ("sink caps requested by buffer out: '%s'", temp);
g_free (temp);
fail_unless (gst_caps_is_fixed (sink_caps), "we need fixed caps");
#endif
/* get the sink pad */ /* get the sink pad */
sink_pad = gst_pad_new (NULL, GST_PAD_SINK); sink_pad = gst_pad_new ("sink", GST_PAD_SINK);
fail_unless (GST_IS_PAD (sink_pad)); fail_unless (GST_IS_PAD (sink_pad));
#if 0 /* configure the sink pad */
gst_pad_set_caps (sink_pad, sink_caps); gst_pad_set_chain_function (sink_pad, gst_check_chain_func);
#endif gst_pad_set_active (sink_pad, TRUE);
gst_pad_set_caps (sink_pad, caps_out);
if (caps_out)
gst_pad_set_event_function (sink_pad, buffer_event_function);
/* get the peer pad */ /* get the peer pad */
pad_peer = gst_element_get_static_pad (element, "src"); pad_peer = gst_element_get_static_pad (element, "src");
fail_unless (gst_pad_link (pad_peer, sink_pad) == GST_PAD_LINK_OK, fail_unless (gst_pad_link (pad_peer, sink_pad) == GST_PAD_LINK_OK,
"Could not link sink and %s source pads", GST_ELEMENT_NAME (element)); "Could not link sink and %s source pads", GST_ELEMENT_NAME (element));
gst_object_unref (pad_peer); gst_object_unref (pad_peer);
/* configure the sink pad */
gst_pad_set_chain_function (sink_pad, gst_check_chain_func);
gst_pad_set_active (sink_pad, TRUE);
} }
fail_unless (gst_element_set_state (element, fail_unless (gst_element_set_state (element,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
@ -543,7 +559,8 @@ gst_check_element_push_buffer_list (const gchar * element_name,
*/ */
void void
gst_check_element_push_buffer (const gchar * element_name, gst_check_element_push_buffer (const gchar * element_name,
GstBuffer * buffer_in, GstBuffer * buffer_out) GstBuffer * buffer_in, GstCaps * caps_in, GstBuffer * buffer_out,
GstCaps * caps_out)
{ {
GList *in = NULL; GList *in = NULL;
GList *out = NULL; GList *out = NULL;
@ -551,7 +568,8 @@ gst_check_element_push_buffer (const gchar * element_name,
in = g_list_append (in, buffer_in); in = g_list_append (in, buffer_in);
out = g_list_append (out, buffer_out); out = g_list_append (out, buffer_out);
gst_check_element_push_buffer_list (element_name, in, out, GST_FLOW_OK); gst_check_element_push_buffer_list (element_name, in, caps_in, out, caps_out,
GST_FLOW_OK);
} }
void void

View file

@ -83,9 +83,11 @@ void gst_check_drop_buffers (void);
void gst_check_caps_equal (GstCaps * caps1, GstCaps * caps2); void gst_check_caps_equal (GstCaps * caps1, GstCaps * caps2);
void gst_check_buffer_data (GstBuffer * buffer, gconstpointer data, gsize size); void gst_check_buffer_data (GstBuffer * buffer, gconstpointer data, gsize size);
void gst_check_element_push_buffer_list (const gchar * element_name, void gst_check_element_push_buffer_list (const gchar * element_name,
GList * buffer_in, GList * buffer_out, GstFlowReturn last_flow_return); GList * buffer_in, GstCaps * caps_in, GList * buffer_out,
GstCaps * caps_out, GstFlowReturn last_flow_return);
void gst_check_element_push_buffer (const gchar * element_name, void gst_check_element_push_buffer (const gchar * element_name,
GstBuffer * buffer_in, GstBuffer * buffer_out); GstBuffer * buffer_in, GstCaps * caps_in, GstBuffer * buffer_out,
GstCaps *caps_out);
GstPad *gst_check_setup_sink_pad (GstElement * element, GstPad *gst_check_setup_sink_pad (GstElement * element,
GstStaticPadTemplate * tmpl); GstStaticPadTemplate * tmpl);
void gst_check_teardown_sink_pad (GstElement * element); void gst_check_teardown_sink_pad (GstElement * element);