diff options
Diffstat (limited to 'ext/srtp/gstsrtpdec.c')
-rw-r--r-- | ext/srtp/gstsrtpdec.c | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/ext/srtp/gstsrtpdec.c b/ext/srtp/gstsrtpdec.c index 4ad989fb2..d44086fd0 100644 --- a/ext/srtp/gstsrtpdec.c +++ b/ext/srtp/gstsrtpdec.c @@ -108,21 +108,11 @@ * */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif +#include "gstsrtpdec.h" -#include <gst/gst.h> #include <gst/rtp/gstrtpbuffer.h> #include <string.h> -#include "gstsrtp.h" -#include "gstsrtp-enumtypes.h" - -#include "gstsrtpdec.h" - -#include <srtp/srtp_priv.h> - GST_DEBUG_CATEGORY_STATIC (gst_srtp_dec_debug); #define GST_CAT_DEFAULT gst_srtp_dec_debug @@ -409,7 +399,10 @@ gst_srtp_dec_init (GstSrtpDec * filter) gst_element_add_pad (GST_ELEMENT (filter), filter->rtcp_srcpad); filter->first_session = TRUE; + +#ifndef HAVE_SRTP2 filter->roc_changed = FALSE; +#endif } static GstStructure * @@ -425,19 +418,26 @@ gst_srtp_dec_create_stats (GstSrtpDec * filter) g_value_init (&v, GST_TYPE_STRUCTURE); if (filter->session) { - srtp_stream_t stream = filter->session->stream_list; - while (stream) { + GHashTableIter iter; + gpointer key; + + g_hash_table_iter_init (&iter, filter->streams); + while (g_hash_table_iter_next (&iter, &key, NULL)) { GstStructure *ss; - guint32 ssrc = GUINT32_FROM_BE (stream->ssrc); - guint32 roc = stream->rtp_rdbx.index >> 16; + guint32 ssrc = GPOINTER_TO_UINT (key); + srtp_err_status_t status; + guint32 roc; + + status = srtp_get_stream_roc (filter->session, ssrc, &roc); + if (status != srtp_err_status_ok) { + continue; + } ss = gst_structure_new ("application/x-srtp-stream", "ssrc", G_TYPE_UINT, ssrc, "roc", G_TYPE_UINT, roc, NULL); g_value_take_boxed (&v, ss); gst_value_array_append_value (&va, &v); - - stream = stream->next; } } @@ -556,7 +556,8 @@ get_stream_from_caps (GstSrtpDec * filter, GstCaps * caps, guint32 ssrc) goto error; } - if (stream->rtcp_cipher != NULL_CIPHER && stream->rtcp_auth == NULL_AUTH) { + if (stream->rtcp_cipher != SRTP_NULL_CIPHER && + stream->rtcp_auth == SRTP_NULL_AUTH) { GST_WARNING_OBJECT (filter, "Cannot have SRTP NULL authentication with a not-NULL encryption" " cipher."); @@ -594,11 +595,11 @@ signal_get_srtp_params (GstSrtpDec * filter, guint32 ssrc, gint signal) /* Create a stream in the session */ -static err_status_t +static srtp_err_status_t init_session_stream (GstSrtpDec * filter, guint32 ssrc, GstSrtpDecSsrcStream * stream) { - err_status_t ret; + srtp_err_status_t ret; srtp_policy_t policy; GstMapInfo map; guchar tmp[1]; @@ -606,7 +607,7 @@ init_session_stream (GstSrtpDec * filter, guint32 ssrc, memset (&policy, 0, sizeof (srtp_policy_t)); if (!stream) - return err_status_bad_param; + return srtp_err_status_bad_param; GST_INFO_OBJECT (filter, "Setting RTP policy..."); set_crypto_policy_cipher_auth (stream->rtp_cipher, stream->rtp_auth, @@ -638,17 +639,20 @@ init_session_stream (GstSrtpDec * filter, guint32 ssrc, if (stream->key) gst_buffer_unmap (stream->key, &map); - if (ret == err_status_ok) { - srtp_stream_t srtp_stream; + if (ret == srtp_err_status_ok) { + srtp_err_status_t status; - srtp_stream = srtp_get_stream (filter->session, htonl (ssrc)); - if (srtp_stream) { + status = srtp_set_stream_roc (filter->session, ssrc, stream->roc); +#ifdef HAVE_SRTP2 + (void) status; /* Ignore unused variable */ +#else + if (status == srtp_err_status_ok) { /* Here, we just set the ROC, but we also need to set the initial * RTP sequence number later, otherwise libsrtp will not be able * to get the right packet index. */ - rdbx_set_roc (&srtp_stream->rtp_rdbx, stream->roc); filter->roc_changed = TRUE; } +#endif filter->first_session = FALSE; g_hash_table_insert (filter->streams, GUINT_TO_POINTER (stream->ssrc), @@ -713,7 +717,7 @@ update_session_stream_from_caps (GstSrtpDec * filter, guint32 ssrc, { GstSrtpDecSsrcStream *stream = NULL; GstSrtpDecSsrcStream *old_stream = NULL; - err_status_t err; + srtp_err_status_t err; g_return_val_if_fail (GST_IS_SRTP_DEC (filter), NULL); g_return_val_if_fail (GST_IS_CAPS (caps), NULL); @@ -751,7 +755,7 @@ update_session_stream_from_caps (GstSrtpDec * filter, guint32 ssrc, /* Create new session stream */ err = init_session_stream (filter, ssrc, stream); - if (err != err_status_ok) { + if (err != srtp_err_status_ok) { if (stream->key) gst_buffer_unref (stream->key); g_slice_free (GstSrtpDecSsrcStream, stream); @@ -1139,7 +1143,7 @@ gst_srtp_dec_decode_buffer (GstSrtpDec * filter, GstPad * pad, GstBuffer * buf, gboolean is_rtcp, guint32 ssrc) { GstMapInfo map; - err_status_t err; + srtp_err_status_t err; gint size; GST_LOG_OBJECT (pad, "Received %s buffer of size %" G_GSIZE_FORMAT @@ -1159,6 +1163,7 @@ unprotect: if (is_rtcp) err = srtp_unprotect_rtcp (filter->session, map.data, &size); else { +#ifndef HAVE_SRTP2 /* If ROC has changed, we know we need to set the initial RTP * sequence number too. */ if (filter->roc_changed) { @@ -1183,18 +1188,19 @@ unprotect: filter->roc_changed = FALSE; } +#endif err = srtp_unprotect (filter->session, map.data, &size); } GST_OBJECT_UNLOCK (filter); - if (err != err_status_ok) { + if (err != srtp_err_status_ok) { GST_WARNING_OBJECT (pad, "Unable to unprotect buffer (unprotect failed code %d)", err); /* Signal user depending on type of error */ switch (err) { - case err_status_key_expired: + case srtp_err_status_key_expired: GST_OBJECT_LOCK (filter); /* Update stream */ @@ -1212,10 +1218,10 @@ unprotect: "dropping"); } break; - case err_status_auth_fail: + case srtp_err_status_auth_fail: GST_WARNING_OBJECT (filter, "Error authentication packet, dropping"); break; - case err_status_cipher_fail: + case srtp_err_status_cipher_fail: GST_WARNING_OBJECT (filter, "Error while decrypting packet, dropping"); break; default: |