sctp: Add logging and missing cleanup on errors when creating pads

This commit is contained in:
Sebastian Dröge 2020-01-30 16:00:33 +02:00
parent 16ec86faf0
commit bff33f3b21
2 changed files with 21 additions and 7 deletions

View file

@ -539,11 +539,13 @@ get_pad_for_stream_id (GstSctpDec * self, guint16 stream_id)
g_object_get (self->sctp_association, "state", &state, NULL); g_object_get (self->sctp_association, "state", &state, NULL);
if (state != GST_SCTP_ASSOCIATION_STATE_CONNECTED) { if (state != GST_SCTP_ASSOCIATION_STATE_CONNECTED) {
GST_WARNING_OBJECT (self, GST_ERROR_OBJECT (self,
"The SCTP association must be established before a new stream can be created"); "The SCTP association must be established before a new stream can be created");
return NULL; return NULL;
} }
GST_DEBUG_OBJECT (self, "Creating new pad for stream id %u", stream_id);
if (stream_id > MAX_STREAM_ID) if (stream_id > MAX_STREAM_ID)
return NULL; return NULL;
@ -566,7 +568,7 @@ get_pad_for_stream_id (GstSctpDec * self, guint16 stream_id)
gst_pad_sticky_events_foreach (self->sink_pad, copy_sticky_events, new_pad); gst_pad_sticky_events_foreach (self->sink_pad, copy_sticky_events, new_pad);
if (!gst_element_add_pad (GST_ELEMENT (self), new_pad)) if (!gst_element_add_pad (GST_ELEMENT (self), new_pad))
goto error_cleanup; goto error_add;
GST_OBJECT_LOCK (self); GST_OBJECT_LOCK (self);
gst_flow_combiner_add_pad (self->flow_combiner, new_pad); gst_flow_combiner_add_pad (self->flow_combiner, new_pad);
@ -578,7 +580,8 @@ get_pad_for_stream_id (GstSctpDec * self, guint16 stream_id)
gst_object_ref (new_pad); gst_object_ref (new_pad);
return new_pad; return new_pad;
error_add:
gst_pad_set_active (new_pad, FALSE);
error_cleanup: error_cleanup:
gst_object_unref (new_pad); gst_object_unref (new_pad);
return NULL; return NULL;

View file

@ -393,25 +393,32 @@ gst_sctp_enc_request_new_pad (GstElement * element, GstPadTemplate * template,
g_object_get (self->sctp_association, "state", &state, NULL); g_object_get (self->sctp_association, "state", &state, NULL);
if (state != GST_SCTP_ASSOCIATION_STATE_CONNECTED) { if (state != GST_SCTP_ASSOCIATION_STATE_CONNECTED) {
g_warning GST_ERROR_OBJECT
("The SCTP association must be established before a new stream can be created"); (self,
"The SCTP association must be established before a new stream can be created");
goto invalid_state; goto invalid_state;
} }
if (!template) if (!template)
goto invalid_parameter; goto invalid_parameter;
/* 65535 is not a valid stream id */
if (!new_pad_name || (sscanf (new_pad_name, "sink_%u", &stream_id) != 1) if (!new_pad_name || (sscanf (new_pad_name, "sink_%u", &stream_id) != 1)
|| stream_id > 65534) /* 65535 is not a valid stream id */ || stream_id > 65534) {
GST_ERROR_OBJECT
(self, "Invalid sink pad name %s", GST_STR_NULL (new_pad_name));
goto invalid_parameter; goto invalid_parameter;
}
new_pad = gst_element_get_static_pad (element, new_pad_name); new_pad = gst_element_get_static_pad (element, new_pad_name);
if (new_pad) { if (new_pad) {
gst_object_unref (new_pad); gst_object_unref (new_pad);
new_pad = NULL; new_pad = NULL;
GST_ERROR_OBJECT (self, "Pad %s already exists", new_pad_name);
goto invalid_parameter; goto invalid_parameter;
} }
GST_DEBUG_OBJECT (self, "Creating new pad %s", new_pad_name);
new_pad = new_pad =
g_object_new (GST_TYPE_SCTP_ENC_PAD, "name", new_pad_name, "direction", g_object_new (GST_TYPE_SCTP_ENC_PAD, "name", new_pad_name, "direction",
template->direction, "template", template, NULL); template->direction, "template", template, NULL);
@ -425,6 +432,8 @@ gst_sctp_enc_request_new_pad (GstElement * element, GstPadTemplate * template,
sctpenc_pad->ppid = DEFAULT_SCTP_PPID; sctpenc_pad->ppid = DEFAULT_SCTP_PPID;
if (caps) { if (caps) {
GST_DEBUG_OBJECT (self, "Pad %s requested with caps %" GST_PTR_FORMAT,
new_pad_name, caps);
get_config_from_caps (caps, &sctpenc_pad->ordered, get_config_from_caps (caps, &sctpenc_pad->ordered,
&sctpenc_pad->reliability, &sctpenc_pad->reliability_param, &new_ppid, &sctpenc_pad->reliability, &sctpenc_pad->reliability_param, &new_ppid,
&is_new_ppid); &is_new_ppid);
@ -439,11 +448,13 @@ gst_sctp_enc_request_new_pad (GstElement * element, GstPadTemplate * template,
goto error_cleanup; goto error_cleanup;
if (!gst_element_add_pad (element, new_pad)) if (!gst_element_add_pad (element, new_pad))
goto error_cleanup; goto error_add_pad;
invalid_state: invalid_state:
invalid_parameter: invalid_parameter:
return new_pad; return new_pad;
error_add_pad:
gst_pad_set_active (new_pad, FALSE);
error_cleanup: error_cleanup:
gst_object_unref (new_pad); gst_object_unref (new_pad);
return NULL; return NULL;