diff --git a/ChangeLog b/ChangeLog index a890cb6358..a1c1cd6cc7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-08-31 Wim Taymans + + * gst/base/gstbasetransform.c: (gst_base_transform_configure_caps), + (gst_base_transform_setcaps), (gst_base_transform_handle_buffer), + (gst_base_transform_chain), (gst_base_transform_change_state): + * gst/base/gstbasetransform.h: + Handle the case where we are not negotiated more gracefully. + 2005-08-31 Tim-Philipp Müller * gst/elements/gstfilesrc.c: (gst_mmap_buffer_init), diff --git a/gst/base/gstbasetransform.c b/gst/base/gstbasetransform.c index 3a253713e5..39b0c1ee3d 100644 --- a/gst/base/gstbasetransform.c +++ b/gst/base/gstbasetransform.c @@ -368,6 +368,8 @@ gst_base_transform_configure_caps (GstBaseTransform * trans, GstCaps * in, ret = klass->set_caps (trans, in, out); } + trans->negotiated = ret; + return ret; } @@ -381,12 +383,8 @@ gst_base_transform_setcaps (GstPad * pad, GstCaps * caps) gboolean ret = TRUE; gboolean peer_checked = FALSE; - /* caps must be fixed here */ - g_return_val_if_fail (gst_caps_is_fixed (caps), FALSE); - trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad)); klass = GST_BASE_TRANSFORM_GET_CLASS (trans); - g_return_val_if_fail (gst_caps_is_fixed (caps), FALSE); otherpad = (pad == trans->srcpad) ? trans->sinkpad : trans->srcpad; otherpeer = gst_pad_get_peer (otherpad); @@ -396,6 +394,10 @@ gst_base_transform_setcaps (GstPad * pad, GstCaps * caps) if (GST_PAD_IS_IN_SETCAPS (otherpad)) goto done; + /* caps must be fixed here */ + if (!gst_caps_is_fixed (caps)) + goto unfixed_caps; + /* see how we can transform the input caps. */ othercaps = gst_base_transform_transform_caps (trans, GST_PAD_DIRECTION (pad), caps); @@ -543,11 +545,19 @@ done: if (othercaps) gst_caps_unref (othercaps); + trans->negotiated = ret; + gst_object_unref (trans); return ret; /* ERRORS */ +unfixed_caps: + { + GST_DEBUG_OBJECT (trans, "caps are not fixed %" GST_PTR_FORMAT, caps); + ret = FALSE; + goto done; + } no_transform: { GST_DEBUG_OBJECT (trans, @@ -948,6 +958,9 @@ gst_base_transform_chain (GstPad * pad, GstBuffer * buffer) trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad)); + if (!trans->negotiated) + goto not_negotiated; + ret = gst_base_transform_handle_buffer (trans, buffer, &outbuf); if (ret == GST_FLOW_OK) { ret = gst_pad_push (trans->srcpad, outbuf); @@ -956,6 +969,11 @@ gst_base_transform_chain (GstPad * pad, GstBuffer * buffer) gst_object_unref (trans); return ret; + +not_negotiated: + { + return GST_FLOW_NOT_NEGOTIATED; + } } static void @@ -1054,6 +1072,7 @@ gst_base_transform_change_state (GstElement * element) GST_DEBUG_OBJECT (trans, "in_place %d", trans->in_place); gst_caps_replace (&trans->cache_caps1, NULL); gst_caps_replace (&trans->cache_caps2, NULL); + trans->negotiated = FALSE; GST_UNLOCK (trans); break; case GST_STATE_PAUSED_TO_PLAYING: diff --git a/gst/base/gstbasetransform.h b/gst/base/gstbasetransform.h index d3426075d0..db3c16ce04 100644 --- a/gst/base/gstbasetransform.h +++ b/gst/base/gstbasetransform.h @@ -58,6 +58,7 @@ struct _GstBaseTransform { gboolean delay_configure; gboolean pending_configure; + gboolean negotiated; gboolean have_newsegment; diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c index 3a253713e5..39b0c1ee3d 100644 --- a/libs/gst/base/gstbasetransform.c +++ b/libs/gst/base/gstbasetransform.c @@ -368,6 +368,8 @@ gst_base_transform_configure_caps (GstBaseTransform * trans, GstCaps * in, ret = klass->set_caps (trans, in, out); } + trans->negotiated = ret; + return ret; } @@ -381,12 +383,8 @@ gst_base_transform_setcaps (GstPad * pad, GstCaps * caps) gboolean ret = TRUE; gboolean peer_checked = FALSE; - /* caps must be fixed here */ - g_return_val_if_fail (gst_caps_is_fixed (caps), FALSE); - trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad)); klass = GST_BASE_TRANSFORM_GET_CLASS (trans); - g_return_val_if_fail (gst_caps_is_fixed (caps), FALSE); otherpad = (pad == trans->srcpad) ? trans->sinkpad : trans->srcpad; otherpeer = gst_pad_get_peer (otherpad); @@ -396,6 +394,10 @@ gst_base_transform_setcaps (GstPad * pad, GstCaps * caps) if (GST_PAD_IS_IN_SETCAPS (otherpad)) goto done; + /* caps must be fixed here */ + if (!gst_caps_is_fixed (caps)) + goto unfixed_caps; + /* see how we can transform the input caps. */ othercaps = gst_base_transform_transform_caps (trans, GST_PAD_DIRECTION (pad), caps); @@ -543,11 +545,19 @@ done: if (othercaps) gst_caps_unref (othercaps); + trans->negotiated = ret; + gst_object_unref (trans); return ret; /* ERRORS */ +unfixed_caps: + { + GST_DEBUG_OBJECT (trans, "caps are not fixed %" GST_PTR_FORMAT, caps); + ret = FALSE; + goto done; + } no_transform: { GST_DEBUG_OBJECT (trans, @@ -948,6 +958,9 @@ gst_base_transform_chain (GstPad * pad, GstBuffer * buffer) trans = GST_BASE_TRANSFORM (gst_pad_get_parent (pad)); + if (!trans->negotiated) + goto not_negotiated; + ret = gst_base_transform_handle_buffer (trans, buffer, &outbuf); if (ret == GST_FLOW_OK) { ret = gst_pad_push (trans->srcpad, outbuf); @@ -956,6 +969,11 @@ gst_base_transform_chain (GstPad * pad, GstBuffer * buffer) gst_object_unref (trans); return ret; + +not_negotiated: + { + return GST_FLOW_NOT_NEGOTIATED; + } } static void @@ -1054,6 +1072,7 @@ gst_base_transform_change_state (GstElement * element) GST_DEBUG_OBJECT (trans, "in_place %d", trans->in_place); gst_caps_replace (&trans->cache_caps1, NULL); gst_caps_replace (&trans->cache_caps2, NULL); + trans->negotiated = FALSE; GST_UNLOCK (trans); break; case GST_STATE_PAUSED_TO_PLAYING: diff --git a/libs/gst/base/gstbasetransform.h b/libs/gst/base/gstbasetransform.h index d3426075d0..db3c16ce04 100644 --- a/libs/gst/base/gstbasetransform.h +++ b/libs/gst/base/gstbasetransform.h @@ -58,6 +58,7 @@ struct _GstBaseTransform { gboolean delay_configure; gboolean pending_configure; + gboolean negotiated; gboolean have_newsegment;