mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
Added a simple function gst_pad_recover_caps_error that a plugin should call from now on (instead of gst_element_erro...
Original commit message from CVS: Added a simple function gst_pad_recover_caps_error that a plugin should call from now on (instead of gst_element_error). This function will emit a caps_nego_failed signal that the app can catch to resolve the negotiation failure.
This commit is contained in:
parent
8365acd9b6
commit
9811bb9aad
2 changed files with 51 additions and 4 deletions
44
gst/gstpad.c
44
gst/gstpad.c
|
@ -1987,6 +1987,50 @@ gst_pad_recalc_allowed_caps (GstPad *pad)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_pad_recover_caps_error:
|
||||
* @pad: a #GstPad that had a failed capsnego
|
||||
* @allowed: possible caps for the link
|
||||
*
|
||||
* Attempt to recover from a failed caps negotiation. This function
|
||||
* is typically called by a plugin that exhausted its list of caps
|
||||
* and wants the application to resolve the issue. The application
|
||||
* should connect to the pad's caps_nego_failed signal and should
|
||||
* resolve the issue by connecting another element for example.
|
||||
*
|
||||
* Returns: TRUE when the issue was resolved, dumps detailed information
|
||||
* on the console and returns FALSE otherwise.
|
||||
*/
|
||||
gboolean
|
||||
gst_pad_recover_caps_error (GstPad *pad, GstCaps *allowed)
|
||||
{
|
||||
GstElement *parent;
|
||||
|
||||
g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
|
||||
|
||||
/* see if someone can resolve this */
|
||||
if (g_signal_has_handler_pending (G_OBJECT (pad),
|
||||
gst_real_pad_signals[REAL_CAPS_NEGO_FAILED], 0, FALSE))
|
||||
{
|
||||
/* clear pad caps first */
|
||||
gst_caps_replace (&GST_PAD_CAPS (pad), NULL);
|
||||
|
||||
/* lets hope some signal manages to set the caps again */
|
||||
g_signal_emit (G_OBJECT (pad), gst_real_pad_signals[REAL_CAPS_NEGO_FAILED], 0, allowed);
|
||||
|
||||
/* if the pad has caps now or is disabled, it's ok */
|
||||
if (GST_PAD_CAPS (pad) != NULL || !GST_PAD_IS_ACTIVE (pad))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* report error */
|
||||
parent = gst_pad_get_parent (pad);
|
||||
gst_element_error (parent, "negotiation failed on pad %s:%s",
|
||||
GST_DEBUG_PAD_NAME (pad));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_pad_get_bufferpool:
|
||||
* @pad: a #GstPad to get the bufferpool from.
|
||||
|
|
|
@ -220,7 +220,8 @@ struct _GstRealPadClass {
|
|||
GstPadClass parent_class;
|
||||
|
||||
/* signal callbacks */
|
||||
void (*caps_nego_failed) (GstPad *pad);
|
||||
void (*caps_nego_failed) (GstPad *pad, GstCaps *caps);
|
||||
|
||||
void (*linked) (GstPad *pad, GstPad *peer);
|
||||
void (*unlinked) (GstPad *pad, GstPad *peer);
|
||||
};
|
||||
|
@ -446,6 +447,8 @@ gboolean gst_pad_try_relink_filtered (GstPad *srcpad, GstPad *sinkpad, GstCaps
|
|||
GstCaps* gst_pad_get_allowed_caps (GstPad *pad);
|
||||
gboolean gst_pad_recalc_allowed_caps (GstPad *pad);
|
||||
|
||||
gboolean gst_pad_recover_caps_error (GstPad *pad, GstCaps *allowed);
|
||||
|
||||
/* data passing functions */
|
||||
void gst_pad_push (GstPad *pad, GstBuffer *buf);
|
||||
GstBuffer* gst_pad_pull (GstPad *pad);
|
||||
|
|
Loading…
Reference in a new issue