From 83a7075f8a0f943176abc1cadb24e5e5af0485e7 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Tue, 5 Jul 2005 08:47:40 +0000 Subject: [PATCH] check/: Application message API change. Original commit message from CVS: 2005-07-05 Andy Wingo * check/gst/gstbus.c (pound_bus_with_messages): * check/gst/gstmessage.c (START_TEST): * check/pipelines/simple_launch_lines.c (got_handoff): Application message API change. * gst/base/gstbasetransform.c (gst_base_transform_setcaps): More logic weaks here: always run transform_caps, trying passthrough operation only if the original caps intersects with the transform. * gst/gstpad.c (gst_pad_link_check_compatible_unlocked): Debug source and sink caps. * gst/base/gstbasetransform.c (gst_base_transform_getcaps): Intersect the peer caps with the pad template before going into transform_caps. (gst_base_transform_transform_caps): More debugging. * gst/gstmessage.h (gst_message_new_application): Take a GstObject src argument. --- ChangeLog | 22 +++++ check/gst/gstbus.c | 2 +- check/gst/gstmessage.c | 2 +- check/pipelines/simple_launch_lines.c | 3 +- docs/gst/tmpl/gstpad.sgml | 3 + gst/base/gstbasetransform.c | 129 ++++++++++++++++------------ gst/gstmessage.c | 5 +- gst/gstmessage.h | 2 +- gst/gstpad.c | 3 +- libs/gst/base/gstbasetransform.c | 129 ++++++++++++++++------------ tests/check/gst/gstbus.c | 2 +- tests/check/gst/gstmessage.c | 2 +- tests/check/pipelines/simple-launch-lines.c | 3 +- 13 files changed, 189 insertions(+), 118 deletions(-) diff --git a/ChangeLog b/ChangeLog index 874b8a2..257f6f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2005-07-05 Andy Wingo + + * check/gst/gstbus.c (pound_bus_with_messages): + * check/gst/gstmessage.c (START_TEST): + * check/pipelines/simple_launch_lines.c (got_handoff): Application + message API change. + + * gst/base/gstbasetransform.c (gst_base_transform_setcaps): More + logic weaks here: always run transform_caps, trying passthrough + operation only if the original caps intersects with the transform. + + * gst/gstpad.c (gst_pad_link_check_compatible_unlocked): Debug + source and sink caps. + + * gst/base/gstbasetransform.c (gst_base_transform_getcaps): + Intersect the peer caps with the pad template before going into + transform_caps. + (gst_base_transform_transform_caps): More debugging. + + * gst/gstmessage.h (gst_message_new_application): Take a GstObject + src argument. + 2005-07-04 Edward Hervey * gst/gstutils.c: diff --git a/check/gst/gstbus.c b/check/gst/gstbus.c index 6bf8525..8440af0 100644 --- a/check/gst/gstbus.c +++ b/check/gst/gstbus.c @@ -40,7 +40,7 @@ pound_bus_with_messages (gpointer data) s = gst_structure_new ("test_message", "thread_id", G_TYPE_INT, thread_id, "msg_id", G_TYPE_INT, i, NULL); - m = gst_message_new_application (s); + m = gst_message_new_application (NULL, s); gst_bus_post (test_bus, m); } return NULL; diff --git a/check/gst/gstmessage.c b/check/gst/gstmessage.c index 84c0e8e..aeda1b5 100644 --- a/check/gst/gstmessage.c +++ b/check/gst/gstmessage.c @@ -148,7 +148,7 @@ START_TEST (test_parsing) "some_int", G_TYPE_INT, 10, "a_double", G_TYPE_DOUBLE, (gdouble) 1.8, NULL); fail_if (structure == NULL); - message = gst_message_new_application (structure); + message = gst_message_new_application (NULL, structure); fail_if (message == NULL); struc = gst_message_get_structure (message); fail_if (struc == NULL); diff --git a/check/pipelines/simple_launch_lines.c b/check/pipelines/simple_launch_lines.c index eeef985..be20fb2 100644 --- a/check/pipelines/simple_launch_lines.c +++ b/check/pipelines/simple_launch_lines.c @@ -103,7 +103,8 @@ END_TEST static void got_handoff (GstElement * sink, GstBuffer * buf, GstPad * pad, gpointer unused) { gst_element_post_message - (sink, gst_message_new_application (gst_structure_new ("foo", NULL))); + (sink, gst_message_new_application (NULL, gst_structure_new ("foo", + NULL))); } static void diff --git a/docs/gst/tmpl/gstpad.sgml b/docs/gst/tmpl/gstpad.sgml index fc15412..2b2c7cd 100644 --- a/docs/gst/tmpl/gstpad.sgml +++ b/docs/gst/tmpl/gstpad.sgml @@ -822,6 +822,7 @@ Checks if the pad is a sink pad. @pad: @handler: @data: +@Returns: @@ -832,6 +833,7 @@ Checks if the pad is a sink pad. @pad: @handler: @data: +@Returns: @@ -842,6 +844,7 @@ Checks if the pad is a sink pad. @pad: @handler: @data: +@Returns: diff --git a/gst/base/gstbasetransform.c b/gst/base/gstbasetransform.c index feff3a1..8f5cdee 100644 --- a/gst/base/gstbasetransform.c +++ b/gst/base/gstbasetransform.c @@ -180,14 +180,21 @@ static GstCaps * gst_base_transform_transform_caps (GstBaseTransform * trans, GstPad * pad, GstCaps * caps) { + GstCaps *ret; GstBaseTransformClass *klass; klass = GST_BASE_TRANSFORM_GET_CLASS (trans); + GST_DEBUG_OBJECT (trans, "from: %" GST_PTR_FORMAT, caps); + if (klass->transform_caps) - return klass->transform_caps (trans, pad, caps); + ret = klass->transform_caps (trans, pad, caps); else - return gst_caps_ref (caps); + ret = gst_caps_ref (caps); + + GST_DEBUG_OBJECT (trans, "to: %" GST_PTR_FORMAT, ret); + + return ret; } static GstCaps * @@ -207,10 +214,13 @@ gst_base_transform_getcaps (GstPad * pad) if (caps) { GstCaps *temp; - temp = gst_base_transform_transform_caps (trans, otherpad, caps); + temp = gst_caps_intersect (caps, gst_pad_get_pad_template_caps (otherpad)); gst_caps_unref (caps); - caps = gst_caps_intersect (temp, gst_pad_get_pad_template_caps (pad)); + caps = gst_base_transform_transform_caps (trans, otherpad, temp); gst_caps_unref (temp); + temp = gst_caps_intersect (caps, gst_pad_get_pad_template_caps (pad)); + gst_caps_unref (caps); + caps = temp; } else { /* no peer, our padtemplate is enough then */ caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); @@ -224,9 +234,9 @@ gst_base_transform_setcaps (GstPad * pad, GstCaps * caps) { GstBaseTransform *trans; GstBaseTransformClass *klass; - GstStructure *structure; GstPad *otherpad, *otherpeer; - gboolean ret = TRUE; + GstCaps *othercaps = NULL; + gboolean ret = FALSE; trans = GST_BASE_TRANSFORM (GST_PAD_PARENT (pad)); klass = GST_BASE_TRANSFORM_GET_CLASS (trans); @@ -234,70 +244,78 @@ gst_base_transform_setcaps (GstPad * pad, GstCaps * caps) otherpad = (pad == trans->srcpad) ? trans->sinkpad : trans->srcpad; otherpeer = gst_pad_get_peer (otherpad); - if (GST_PAD_IS_IN_SETCAPS (otherpad)) + if (GST_PAD_IS_IN_SETCAPS (otherpad)) { + ret = TRUE; goto done; + } - if (otherpeer == NULL || gst_pad_accept_caps (otherpeer, caps)) { - - /* the peer accepts the caps as they are */ - gst_pad_set_caps (otherpad, caps); - - /* let the element know */ - if (klass->set_caps) - klass->set_caps (trans, caps, caps); - - ret = TRUE; - } else { - GstCaps *peercaps; - GstCaps *intersect; - GstCaps *transform = NULL; - GstCaps *othercaps; + /* see how we can transform the input caps */ + othercaps = gst_base_transform_transform_caps (trans, pad, caps); + if (!othercaps) { ret = FALSE; + goto done; + } - /* other pad has a peer, so we have to figure out how to do the conversion - */ - /* see how we can transform the input caps */ - transform = gst_base_transform_transform_caps (trans, pad, caps); - - if (!transform) - goto done; + if (!gst_caps_is_fixed (othercaps)) { + GstCaps *temp; - /* see what the peer can do */ - peercaps = gst_pad_get_caps (otherpeer); + temp = gst_caps_intersect (othercaps, caps); + if (temp) { + /* try passthrough. we know it's fixed, because caps is fixed */ + if (gst_pad_accept_caps (otherpeer, caps)) { + gst_caps_unref (othercaps); + othercaps = gst_caps_ref (caps); + /* will fall though. calls accept_caps again, should fix that. */ + } + gst_caps_unref (temp); + } + } - GST_DEBUG ("icaps %" GST_PTR_FORMAT, peercaps); - GST_DEBUG ("transform %" GST_PTR_FORMAT, transform); + if (!gst_caps_is_fixed (othercaps) && otherpeer) { + /* intersect against what the peer can do */ + if (otherpeer) { + GstCaps *peercaps; + GstCaps *intersect; - /* filter against our possibilities */ - intersect = gst_caps_intersect (peercaps, transform); - gst_caps_unref (peercaps); - gst_caps_unref (transform); + peercaps = gst_pad_get_caps (otherpeer); + intersect = gst_caps_intersect (peercaps, othercaps); + gst_caps_unref (peercaps); + gst_caps_unref (othercaps); + othercaps = intersect; - GST_DEBUG ("intersect %" GST_PTR_FORMAT, intersect); + GST_DEBUG ("filtering against peer yields %" GST_PTR_FORMAT, othercaps); + } + } - /* take first possibility */ - othercaps = gst_caps_copy_nth (intersect, 0); - gst_caps_unref (intersect); - structure = gst_caps_get_structure (othercaps, 0); + if (!gst_caps_is_fixed (othercaps)) { + GstCaps *temp; - /* and fixate if necessary */ + /* take first possibility and fixate if necessary */ + temp = gst_caps_copy_nth (othercaps, 0); + gst_caps_unref (othercaps); + othercaps = temp; gst_pad_fixate_caps (otherpad, othercaps); + } - g_return_val_if_fail (gst_caps_is_fixed (othercaps), FALSE); + g_return_val_if_fail (gst_caps_is_fixed (othercaps), FALSE); - gst_pad_set_caps (otherpad, othercaps); + if (otherpeer && !gst_pad_accept_caps (otherpeer, othercaps)) { + GST_DEBUG ("FAILED to get peer of %" GST_PTR_FORMAT + " to accept %" GST_PTR_FORMAT, otherpad, othercaps); + ret = FALSE; + goto done; + } - /* let the element know */ - if (klass->set_caps) { - if (pad == trans->sinkpad) { - klass->set_caps (trans, caps, othercaps); - } else { - klass->set_caps (trans, othercaps, caps); - } - } + /* we know this will work, we implement the setcaps */ + gst_pad_set_caps (otherpad, othercaps); - ret = TRUE; + /* success, let the element know */ + if (klass->set_caps) { + if (pad == trans->sinkpad) + ret = klass->set_caps (trans, caps, othercaps); + else + ret = klass->set_caps (trans, othercaps, caps); } done: @@ -305,6 +323,9 @@ done: if (otherpeer) gst_object_unref (otherpeer); + if (othercaps) + gst_caps_unref (othercaps); + return ret; } diff --git a/gst/gstmessage.c b/gst/gstmessage.c index fd43540..7b764e3 100644 --- a/gst/gstmessage.c +++ b/gst/gstmessage.c @@ -310,6 +310,7 @@ gst_message_new_state_changed (GstObject * src, GstElementState old, /** * gst_message_new_application: + * @src: The object originating the message. * @structure: The structure for the message. The message will take ownership of * the structure. * @@ -321,13 +322,13 @@ gst_message_new_state_changed (GstObject * src, GstElementState old, * MT safe. */ GstMessage * -gst_message_new_application (GstStructure * structure) +gst_message_new_application (GstObject * src, GstStructure * structure) { GstMessage *message; g_return_val_if_fail (GST_IS_STRUCTURE (structure), NULL); - message = gst_message_new (GST_MESSAGE_APPLICATION, NULL); + message = gst_message_new (GST_MESSAGE_APPLICATION, src); gst_structure_set_parent_refcount (structure, &message->mini_object.refcount); message->structure = structure; diff --git a/gst/gstmessage.h b/gst/gstmessage.h index 935362c..f527a3c 100644 --- a/gst/gstmessage.h +++ b/gst/gstmessage.h @@ -133,7 +133,7 @@ GstMessage * gst_message_new_warning (GstObject * src, GError * error, gchar * GstMessage * gst_message_new_tag (GstObject * src, GstTagList * tag_list); GstMessage * gst_message_new_state_changed (GstObject * src, GstElementState old_state, GstElementState new_state); -GstMessage * gst_message_new_application (GstStructure *structure); +GstMessage * gst_message_new_application (GstObject * src, GstStructure *structure); void gst_message_parse_error (GstMessage *message, GError **gerror, gchar **debug); void gst_message_parse_warning (GstMessage *message, GError **gerror, gchar **debug); diff --git a/gst/gstpad.c b/gst/gstpad.c index cf420b9..040b80e 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -1367,7 +1367,8 @@ gst_pad_link_check_compatible_unlocked (GstPad * src, GstPad * sink) srccaps = gst_pad_get_caps_unlocked (src); sinkcaps = gst_pad_get_caps_unlocked (sink); - GST_CAT_DEBUG (GST_CAT_CAPS, "got caps %p and %p", srccaps, sinkcaps); + GST_CAT_DEBUG (GST_CAT_CAPS, " src caps %" GST_PTR_FORMAT, srccaps); + GST_CAT_DEBUG (GST_CAT_CAPS, "sink caps %" GST_PTR_FORMAT, sinkcaps); if (srccaps && sinkcaps) { GstCaps *icaps; diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c index feff3a1..8f5cdee 100644 --- a/libs/gst/base/gstbasetransform.c +++ b/libs/gst/base/gstbasetransform.c @@ -180,14 +180,21 @@ static GstCaps * gst_base_transform_transform_caps (GstBaseTransform * trans, GstPad * pad, GstCaps * caps) { + GstCaps *ret; GstBaseTransformClass *klass; klass = GST_BASE_TRANSFORM_GET_CLASS (trans); + GST_DEBUG_OBJECT (trans, "from: %" GST_PTR_FORMAT, caps); + if (klass->transform_caps) - return klass->transform_caps (trans, pad, caps); + ret = klass->transform_caps (trans, pad, caps); else - return gst_caps_ref (caps); + ret = gst_caps_ref (caps); + + GST_DEBUG_OBJECT (trans, "to: %" GST_PTR_FORMAT, ret); + + return ret; } static GstCaps * @@ -207,10 +214,13 @@ gst_base_transform_getcaps (GstPad * pad) if (caps) { GstCaps *temp; - temp = gst_base_transform_transform_caps (trans, otherpad, caps); + temp = gst_caps_intersect (caps, gst_pad_get_pad_template_caps (otherpad)); gst_caps_unref (caps); - caps = gst_caps_intersect (temp, gst_pad_get_pad_template_caps (pad)); + caps = gst_base_transform_transform_caps (trans, otherpad, temp); gst_caps_unref (temp); + temp = gst_caps_intersect (caps, gst_pad_get_pad_template_caps (pad)); + gst_caps_unref (caps); + caps = temp; } else { /* no peer, our padtemplate is enough then */ caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); @@ -224,9 +234,9 @@ gst_base_transform_setcaps (GstPad * pad, GstCaps * caps) { GstBaseTransform *trans; GstBaseTransformClass *klass; - GstStructure *structure; GstPad *otherpad, *otherpeer; - gboolean ret = TRUE; + GstCaps *othercaps = NULL; + gboolean ret = FALSE; trans = GST_BASE_TRANSFORM (GST_PAD_PARENT (pad)); klass = GST_BASE_TRANSFORM_GET_CLASS (trans); @@ -234,70 +244,78 @@ gst_base_transform_setcaps (GstPad * pad, GstCaps * caps) otherpad = (pad == trans->srcpad) ? trans->sinkpad : trans->srcpad; otherpeer = gst_pad_get_peer (otherpad); - if (GST_PAD_IS_IN_SETCAPS (otherpad)) + if (GST_PAD_IS_IN_SETCAPS (otherpad)) { + ret = TRUE; goto done; + } - if (otherpeer == NULL || gst_pad_accept_caps (otherpeer, caps)) { - - /* the peer accepts the caps as they are */ - gst_pad_set_caps (otherpad, caps); - - /* let the element know */ - if (klass->set_caps) - klass->set_caps (trans, caps, caps); - - ret = TRUE; - } else { - GstCaps *peercaps; - GstCaps *intersect; - GstCaps *transform = NULL; - GstCaps *othercaps; + /* see how we can transform the input caps */ + othercaps = gst_base_transform_transform_caps (trans, pad, caps); + if (!othercaps) { ret = FALSE; + goto done; + } - /* other pad has a peer, so we have to figure out how to do the conversion - */ - /* see how we can transform the input caps */ - transform = gst_base_transform_transform_caps (trans, pad, caps); - - if (!transform) - goto done; + if (!gst_caps_is_fixed (othercaps)) { + GstCaps *temp; - /* see what the peer can do */ - peercaps = gst_pad_get_caps (otherpeer); + temp = gst_caps_intersect (othercaps, caps); + if (temp) { + /* try passthrough. we know it's fixed, because caps is fixed */ + if (gst_pad_accept_caps (otherpeer, caps)) { + gst_caps_unref (othercaps); + othercaps = gst_caps_ref (caps); + /* will fall though. calls accept_caps again, should fix that. */ + } + gst_caps_unref (temp); + } + } - GST_DEBUG ("icaps %" GST_PTR_FORMAT, peercaps); - GST_DEBUG ("transform %" GST_PTR_FORMAT, transform); + if (!gst_caps_is_fixed (othercaps) && otherpeer) { + /* intersect against what the peer can do */ + if (otherpeer) { + GstCaps *peercaps; + GstCaps *intersect; - /* filter against our possibilities */ - intersect = gst_caps_intersect (peercaps, transform); - gst_caps_unref (peercaps); - gst_caps_unref (transform); + peercaps = gst_pad_get_caps (otherpeer); + intersect = gst_caps_intersect (peercaps, othercaps); + gst_caps_unref (peercaps); + gst_caps_unref (othercaps); + othercaps = intersect; - GST_DEBUG ("intersect %" GST_PTR_FORMAT, intersect); + GST_DEBUG ("filtering against peer yields %" GST_PTR_FORMAT, othercaps); + } + } - /* take first possibility */ - othercaps = gst_caps_copy_nth (intersect, 0); - gst_caps_unref (intersect); - structure = gst_caps_get_structure (othercaps, 0); + if (!gst_caps_is_fixed (othercaps)) { + GstCaps *temp; - /* and fixate if necessary */ + /* take first possibility and fixate if necessary */ + temp = gst_caps_copy_nth (othercaps, 0); + gst_caps_unref (othercaps); + othercaps = temp; gst_pad_fixate_caps (otherpad, othercaps); + } - g_return_val_if_fail (gst_caps_is_fixed (othercaps), FALSE); + g_return_val_if_fail (gst_caps_is_fixed (othercaps), FALSE); - gst_pad_set_caps (otherpad, othercaps); + if (otherpeer && !gst_pad_accept_caps (otherpeer, othercaps)) { + GST_DEBUG ("FAILED to get peer of %" GST_PTR_FORMAT + " to accept %" GST_PTR_FORMAT, otherpad, othercaps); + ret = FALSE; + goto done; + } - /* let the element know */ - if (klass->set_caps) { - if (pad == trans->sinkpad) { - klass->set_caps (trans, caps, othercaps); - } else { - klass->set_caps (trans, othercaps, caps); - } - } + /* we know this will work, we implement the setcaps */ + gst_pad_set_caps (otherpad, othercaps); - ret = TRUE; + /* success, let the element know */ + if (klass->set_caps) { + if (pad == trans->sinkpad) + ret = klass->set_caps (trans, caps, othercaps); + else + ret = klass->set_caps (trans, othercaps, caps); } done: @@ -305,6 +323,9 @@ done: if (otherpeer) gst_object_unref (otherpeer); + if (othercaps) + gst_caps_unref (othercaps); + return ret; } diff --git a/tests/check/gst/gstbus.c b/tests/check/gst/gstbus.c index 6bf8525..8440af0 100644 --- a/tests/check/gst/gstbus.c +++ b/tests/check/gst/gstbus.c @@ -40,7 +40,7 @@ pound_bus_with_messages (gpointer data) s = gst_structure_new ("test_message", "thread_id", G_TYPE_INT, thread_id, "msg_id", G_TYPE_INT, i, NULL); - m = gst_message_new_application (s); + m = gst_message_new_application (NULL, s); gst_bus_post (test_bus, m); } return NULL; diff --git a/tests/check/gst/gstmessage.c b/tests/check/gst/gstmessage.c index 84c0e8e..aeda1b5 100644 --- a/tests/check/gst/gstmessage.c +++ b/tests/check/gst/gstmessage.c @@ -148,7 +148,7 @@ START_TEST (test_parsing) "some_int", G_TYPE_INT, 10, "a_double", G_TYPE_DOUBLE, (gdouble) 1.8, NULL); fail_if (structure == NULL); - message = gst_message_new_application (structure); + message = gst_message_new_application (NULL, structure); fail_if (message == NULL); struc = gst_message_get_structure (message); fail_if (struc == NULL); diff --git a/tests/check/pipelines/simple-launch-lines.c b/tests/check/pipelines/simple-launch-lines.c index eeef985..be20fb2 100644 --- a/tests/check/pipelines/simple-launch-lines.c +++ b/tests/check/pipelines/simple-launch-lines.c @@ -103,7 +103,8 @@ END_TEST static void got_handoff (GstElement * sink, GstBuffer * buf, GstPad * pad, gpointer unused) { gst_element_post_message - (sink, gst_message_new_application (gst_structure_new ("foo", NULL))); + (sink, gst_message_new_application (NULL, gst_structure_new ("foo", + NULL))); } static void -- 2.7.4