srtpdec: Separate buffer encoding functionality into a different function
https://bugzilla.gnome.org/show_bug.cgi?id=746387
This commit is contained in:
parent
f295beda07
commit
8d2e98bc3f
@ -1003,33 +1003,16 @@ gst_srtp_dec_push_early_events (GstSrtpDec * filter, GstPad * pad,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
/*
|
||||||
gst_srtp_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf,
|
* This function should be called while holding the filter lock
|
||||||
gboolean is_rtcp)
|
*/
|
||||||
|
static gboolean
|
||||||
|
gst_srtp_dec_decode_buffer (GstSrtpDec * filter, GstPad * pad, GstBuffer * buf,
|
||||||
|
gboolean is_rtcp, guint32 ssrc)
|
||||||
{
|
{
|
||||||
GstSrtpDec *filter = GST_SRTP_DEC (parent);
|
|
||||||
GstPad *otherpad;
|
|
||||||
err_status_t err = err_status_ok;
|
|
||||||
GstSrtpDecSsrcStream *stream = NULL;
|
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
|
||||||
gint size;
|
|
||||||
guint32 ssrc = 0;
|
|
||||||
GstMapInfo map;
|
GstMapInfo map;
|
||||||
|
err_status_t err;
|
||||||
GST_OBJECT_LOCK (filter);
|
gint size;
|
||||||
|
|
||||||
/* Check if this stream exists, if not create a new stream */
|
|
||||||
|
|
||||||
if (!(stream = validate_buffer (filter, buf, &ssrc, &is_rtcp))) {
|
|
||||||
GST_OBJECT_UNLOCK (filter);
|
|
||||||
GST_WARNING_OBJECT (filter, "Invalid buffer, dropping");
|
|
||||||
goto drop_buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!STREAM_HAS_CRYPTO (stream)) {
|
|
||||||
GST_OBJECT_UNLOCK (filter);
|
|
||||||
goto push_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_LOG_OBJECT (pad, "Received %s buffer of size %" G_GSIZE_FORMAT
|
GST_LOG_OBJECT (pad, "Received %s buffer of size %" G_GSIZE_FORMAT
|
||||||
" with SSRC = %u", is_rtcp ? "RTCP" : "RTP", gst_buffer_get_size (buf),
|
" with SSRC = %u", is_rtcp ? "RTCP" : "RTP", gst_buffer_get_size (buf),
|
||||||
@ -1038,11 +1021,11 @@ gst_srtp_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf,
|
|||||||
/* Change buffer to remove protection */
|
/* Change buffer to remove protection */
|
||||||
buf = gst_buffer_make_writable (buf);
|
buf = gst_buffer_make_writable (buf);
|
||||||
|
|
||||||
unprotect:
|
|
||||||
|
|
||||||
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
gst_buffer_map (buf, &map, GST_MAP_READWRITE);
|
||||||
size = map.size;
|
size = map.size;
|
||||||
|
|
||||||
|
unprotect:
|
||||||
|
|
||||||
gst_srtp_init_event_reporter ();
|
gst_srtp_init_event_reporter ();
|
||||||
|
|
||||||
if (is_rtcp)
|
if (is_rtcp)
|
||||||
@ -1074,8 +1057,6 @@ unprotect:
|
|||||||
err = srtp_unprotect (filter->session, map.data, &size);
|
err = srtp_unprotect (filter->session, map.data, &size);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unmap (buf, &map);
|
|
||||||
|
|
||||||
GST_OBJECT_UNLOCK (filter);
|
GST_OBJECT_UNLOCK (filter);
|
||||||
|
|
||||||
if (err != err_status_ok) {
|
if (err != err_status_ok) {
|
||||||
@ -1113,10 +1094,51 @@ unprotect:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (filter);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_buffer_unmap (buf, &map);
|
||||||
|
|
||||||
|
gst_buffer_set_size (buf, size);
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (filter);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GstFlowReturn
|
||||||
|
gst_srtp_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf,
|
||||||
|
gboolean is_rtcp)
|
||||||
|
{
|
||||||
|
GstSrtpDec *filter = GST_SRTP_DEC (parent);
|
||||||
|
GstPad *otherpad;
|
||||||
|
GstSrtpDecSsrcStream *stream = NULL;
|
||||||
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
|
guint32 ssrc = 0;
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (filter);
|
||||||
|
|
||||||
|
/* Check if this stream exists, if not create a new stream */
|
||||||
|
|
||||||
|
if (!(stream = validate_buffer (filter, buf, &ssrc, &is_rtcp))) {
|
||||||
|
GST_OBJECT_UNLOCK (filter);
|
||||||
|
GST_WARNING_OBJECT (filter, "Invalid buffer, dropping");
|
||||||
goto drop_buffer;
|
goto drop_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_set_size (buf, size);
|
if (!STREAM_HAS_CRYPTO (stream)) {
|
||||||
|
GST_OBJECT_UNLOCK (filter);
|
||||||
|
goto push_out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gst_srtp_dec_decode_buffer (filter, pad, buf, is_rtcp, ssrc)) {
|
||||||
|
GST_OBJECT_UNLOCK (filter);
|
||||||
|
goto drop_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_OBJECT_UNLOCK (filter);
|
||||||
|
|
||||||
/* If all is well, we may have reached soft limit */
|
/* If all is well, we may have reached soft limit */
|
||||||
if (gst_srtp_get_soft_limit_reached ())
|
if (gst_srtp_get_soft_limit_reached ())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user