GstPadTemplate * tmpl, const gchar * name, const GstCaps * caps)
{
GstDtlsDec *self = GST_DTLS_DEC (element);
+ GstPad *pad;
GST_DEBUG_OBJECT (element, "requesting pad");
g_return_val_if_fail (tmpl->direction == GST_PAD_SRC, NULL);
g_mutex_lock (&self->src_mutex);
+ if (self->src) {
+ GST_ERROR_OBJECT (self, "Pad %s:%s exists already",
+ GST_DEBUG_PAD_NAME (self->src));
+ g_mutex_unlock (&self->src_mutex);
+ return NULL;
+ }
- self->src = gst_pad_new_from_template (tmpl, name);
- g_return_val_if_fail (self->src, NULL);
+ self->src = pad = gst_pad_new_from_template (tmpl, name);
+ gst_object_ref (pad);
+ g_mutex_unlock (&self->src_mutex);
- if (caps) {
- g_object_set (self->src, "caps", caps, NULL);
- }
+ gst_pad_set_active (pad, TRUE);
- gst_pad_set_active (self->src, TRUE);
- gst_element_add_pad (element, self->src);
+ if (caps)
+ gst_pad_set_caps (pad, (GstCaps *) caps);
- g_mutex_unlock (&self->src_mutex);
+ gst_element_add_pad (element, pad);
+ gst_object_unref (pad);
- return self->src;
+ return pad;
}
static void
{
GstDtlsDec *self = GST_DTLS_DEC (element);
- g_mutex_lock (&self->src_mutex);
-
g_return_if_fail (self->src == pad);
- gst_element_remove_pad (element, self->src);
+
+ g_mutex_lock (&self->src_mutex);
+ gst_object_unref (self->src);
self->src = NULL;
+ g_mutex_unlock (&self->src_mutex);
- GST_DEBUG_OBJECT (self, "releasing src pad");
+ gst_element_remove_pad (element, pad);
- g_mutex_unlock (&self->src_mutex);
+ GST_DEBUG_OBJECT (self, "releasing src pad");
GST_ELEMENT_GET_CLASS (element)->release_pad (element, pad);
}
{
GstDtlsDec *self = GST_DTLS_DEC (parent);
GstFlowReturn ret = GST_FLOW_OK;
+ GstPad *other_pad;
list = gst_buffer_list_make_writable (list);
gst_buffer_list_foreach (list, process_buffer_from_list, self);
}
g_mutex_lock (&self->src_mutex);
+ other_pad = self->src;
+ if (other_pad)
+ gst_object_ref (other_pad);
+ g_mutex_unlock (&self->src_mutex);
- if (self->src) {
+ if (other_pad) {
GST_LOG_OBJECT (self, "decoded buffer list with length %u, pushing",
gst_buffer_list_length (list));
- ret = gst_pad_push_list (self->src, list);
+ ret = gst_pad_push_list (other_pad, list);
+ gst_object_unref (other_pad);
} else {
GST_LOG_OBJECT (self, "dropped buffer list with length %d, not linked",
gst_buffer_list_length (list));
gst_buffer_list_unref (list);
}
- g_mutex_unlock (&self->src_mutex);
-
return ret;
}
GstDtlsDec *self = GST_DTLS_DEC (parent);
GstFlowReturn ret = GST_FLOW_OK;
gint size;
+ GstPad *other_pad;
if (!self->agent) {
gst_buffer_unref (buffer);
}
g_mutex_lock (&self->src_mutex);
+ other_pad = self->src;
+ if (other_pad)
+ gst_object_ref (other_pad);
+ g_mutex_unlock (&self->src_mutex);
- if (self->src) {
+ if (other_pad) {
GST_LOG_OBJECT (self, "decoded buffer with length %d, pushing", size);
- ret = gst_pad_push (self->src, buffer);
+ ret = gst_pad_push (other_pad, buffer);
+ gst_object_unref (other_pad);
} else {
GST_LOG_OBJECT (self, "dropped buffer with length %d, not linked", size);
gst_buffer_unref (buffer);
}
- g_mutex_unlock (&self->src_mutex);
-
return ret;
}