mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 02:31:03 +00:00
srtpenc: Do not drop all buffers in buffer list if one fails
https://bugzilla.gnome.org/show_bug.cgi?id=746387
This commit is contained in:
parent
fd3c60de34
commit
8f8b0f5478
1 changed files with 67 additions and 25 deletions
|
@ -162,6 +162,20 @@ enum
|
||||||
PROP_ALLOW_REPEAT_TX
|
PROP_ALLOW_REPEAT_TX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct ValidateBufferItData
|
||||||
|
{
|
||||||
|
GstSrtpEnc *filter;
|
||||||
|
gboolean is_rtcp;
|
||||||
|
} ValidateBufferItData;
|
||||||
|
|
||||||
|
typedef struct ProcessBufferItData
|
||||||
|
{
|
||||||
|
GstSrtpEnc *filter;
|
||||||
|
GstPad *pad;
|
||||||
|
GstBufferList *out_list;
|
||||||
|
gboolean is_rtcp;
|
||||||
|
} ProcessBufferItData;
|
||||||
|
|
||||||
/* the capabilities of the inputs and outputs.
|
/* the capabilities of the inputs and outputs.
|
||||||
*
|
*
|
||||||
* describe the real formats here.
|
* describe the real formats here.
|
||||||
|
@ -1150,6 +1164,36 @@ fail:
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
validate_buffer_it (GstBuffer ** buffer, guint index, gpointer user_data)
|
||||||
|
{
|
||||||
|
ValidateBufferItData *data = user_data;
|
||||||
|
|
||||||
|
if (!gst_srtp_enc_check_buffer (data->filter, *buffer, data->is_rtcp)) {
|
||||||
|
GST_WARNING_OBJECT (data->filter, "Invalid buffer, dropping");
|
||||||
|
gst_buffer_replace (buffer, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
process_buffer_it (GstBuffer ** buffer, guint index, gpointer user_data)
|
||||||
|
{
|
||||||
|
ProcessBufferItData *data = user_data;
|
||||||
|
GstBuffer *bufout;
|
||||||
|
|
||||||
|
if ((bufout =
|
||||||
|
gst_srtp_enc_process_buffer (data->filter, data->pad, *buffer,
|
||||||
|
data->is_rtcp))) {
|
||||||
|
gst_buffer_list_add (data->out_list, bufout);
|
||||||
|
} else {
|
||||||
|
GST_WARNING_OBJECT (data->filter, "Error encoding buffer, dropping");
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_srtp_enc_chain_list (GstPad * pad, GstObject * parent,
|
gst_srtp_enc_chain_list (GstPad * pad, GstObject * parent,
|
||||||
GstBufferList * buf_list, gboolean is_rtcp)
|
GstBufferList * buf_list, gboolean is_rtcp)
|
||||||
|
@ -1158,23 +1202,22 @@ gst_srtp_enc_chain_list (GstPad * pad, GstObject * parent,
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
GstPad *otherpad;
|
GstPad *otherpad;
|
||||||
GstBufferList *out_list = NULL;
|
GstBufferList *out_list = NULL;
|
||||||
guint i, num_buffers;
|
ValidateBufferItData validate_data;
|
||||||
|
ProcessBufferItData process_data;
|
||||||
|
|
||||||
num_buffers = gst_buffer_list_length (buf_list);
|
validate_data.filter = filter;
|
||||||
|
validate_data.is_rtcp = is_rtcp;
|
||||||
|
|
||||||
GST_LOG_OBJECT (pad, "Buffer chain with list of %d", num_buffers);
|
GST_LOG_OBJECT (pad, "Buffer chain with list of %d",
|
||||||
|
gst_buffer_list_length (buf_list));
|
||||||
|
|
||||||
for (i = 0; i < num_buffers; i++) {
|
gst_buffer_list_foreach (buf_list, validate_buffer_it, &validate_data);
|
||||||
GstBuffer *buf = gst_buffer_list_get (buf_list, i);
|
|
||||||
|
|
||||||
if (!gst_srtp_enc_check_buffer (filter, buf, is_rtcp)) {
|
if (!gst_buffer_list_length (buf_list))
|
||||||
goto fail;
|
goto out;
|
||||||
}
|
|
||||||
}
|
if ((ret = gst_srtp_enc_check_set_caps (filter, pad, is_rtcp)) != GST_FLOW_OK)
|
||||||
|
|
||||||
if ((ret = gst_srtp_enc_check_set_caps (filter, pad, is_rtcp)) != GST_FLOW_OK) {
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
GST_OBJECT_LOCK (filter);
|
GST_OBJECT_LOCK (filter);
|
||||||
|
|
||||||
|
@ -1188,20 +1231,23 @@ gst_srtp_enc_chain_list (GstPad * pad, GstObject * parent,
|
||||||
|
|
||||||
out_list = gst_buffer_list_new ();
|
out_list = gst_buffer_list_new ();
|
||||||
|
|
||||||
for (i = 0; i < num_buffers; i++) {
|
process_data.filter = filter;
|
||||||
GstBuffer *bufout;
|
process_data.pad = pad;
|
||||||
GstBuffer *buf = gst_buffer_list_get (buf_list, i);
|
process_data.is_rtcp = is_rtcp;
|
||||||
|
process_data.out_list = out_list;
|
||||||
|
|
||||||
if ((bufout = gst_srtp_enc_process_buffer (filter, pad, buf, is_rtcp))) {
|
gst_buffer_list_foreach (buf_list, process_buffer_it, &process_data);
|
||||||
gst_buffer_list_add (out_list, bufout);
|
|
||||||
} else {
|
if (!gst_buffer_list_length (out_list)) {
|
||||||
gst_buffer_list_unref (out_list);
|
gst_buffer_list_unref (out_list);
|
||||||
goto fail;
|
ret = GST_FLOW_OK;
|
||||||
}
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Push buffer to source pad */
|
/* Push buffer to source pad */
|
||||||
otherpad = get_rtp_other_pad (pad);
|
otherpad = get_rtp_other_pad (pad);
|
||||||
|
GST_LOG_OBJECT (pad, "Pushing buffer chain of %d",
|
||||||
|
gst_buffer_list_length (buf_list));
|
||||||
ret = gst_pad_push_list (otherpad, out_list);
|
ret = gst_pad_push_list (otherpad, out_list);
|
||||||
|
|
||||||
if (ret != GST_FLOW_OK) {
|
if (ret != GST_FLOW_OK) {
|
||||||
|
@ -1225,10 +1271,6 @@ out:
|
||||||
gst_buffer_list_unref (buf_list);
|
gst_buffer_list_unref (buf_list);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
fail:
|
|
||||||
ret = GST_FLOW_ERROR;
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
|
|
Loading…
Reference in a new issue