summaryrefslogtreecommitdiff
path: root/ext/srtp/gstsrtp.c
diff options
context:
space:
mode:
authorJan Alexander Steffens (heftig) <jan.steffens@gmail.com>2018-01-26 16:25:33 +0100
committerSebastian Dröge <sebastian@centricular.com>2018-01-29 09:58:11 +0200
commite9aa11720071f8a1d22b336395e66dd8cbca0c00 (patch)
tree79955955ae69c66817148b6feef8030a570957af /ext/srtp/gstsrtp.c
parent49d30c901d5ee7db1082432103cdce2fcbf99267 (diff)
downloadgstreamer-plugins-bad-e9aa11720071f8a1d22b336395e66dd8cbca0c00.tar.gz
srtp: Support libsrtp2
For libsrtp 1, add defines that translate the new namespaced identifiers to the old unnamespaced ones. Also move the code for setting and getting a stream's ROC into two compat functions that match libsrtp2's API. It seems that libsrtp2 properly supports changing the ROC without having to touch the sequence numbers afterwards, given that srtp_set_stream_roc sets a pending_roc field, so the entire roc_changed dance should not be needed anymore. The compat functions for libsrtp 1 just contain our preexisting hacks, however, so it's still needed there. libsrtp2 has no means of discovering the streams in the session, so to create the stats structure we need to iterate over our own set of SSRCs. For this we also need to re-add the previously removed ssrcs_set to the encoder. https://bugzilla.gnome.org/show_bug.cgi?id=776901
Diffstat (limited to 'ext/srtp/gstsrtp.c')
-rw-r--r--ext/srtp/gstsrtp.c58
1 files changed, 41 insertions, 17 deletions
diff --git a/ext/srtp/gstsrtp.c b/ext/srtp/gstsrtp.c
index 1f2d3015c..0c1e235ab 100644
--- a/ext/srtp/gstsrtp.c
+++ b/ext/srtp/gstsrtp.c
@@ -21,21 +21,46 @@
* Boston, MA 02111-1307, USA.
*/
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
#define GLIB_DISABLE_DEPRECATION_WARNINGS
#include "gstsrtp.h"
-#include <glib.h>
-
#include <gst/rtp/gstrtcpbuffer.h>
#include "gstsrtpenc.h"
#include "gstsrtpdec.h"
+#ifndef HAVE_SRTP2
+srtp_err_status_t
+srtp_set_stream_roc (srtp_t session, guint32 ssrc, guint32 roc)
+{
+ srtp_stream_t stream;
+
+ stream = srtp_get_stream (session, htonl (ssrc));
+ if (stream == NULL) {
+ return srtp_err_status_bad_param;
+ }
+
+ rdbx_set_roc (&stream->rtp_rdbx, roc);
+ return srtp_err_status_ok;
+}
+
+srtp_err_status_t
+srtp_get_stream_roc (srtp_t session, guint32 ssrc, guint32 * roc)
+{
+ srtp_stream_t stream;
+
+ stream = srtp_get_stream (session, htonl (ssrc));
+ if (stream == NULL) {
+ return srtp_err_status_bad_param;
+ }
+
+ *roc = stream->rtp_rdbx.index >> 16;
+ return srtp_err_status_ok;
+}
+#endif
+
static void free_reporter_data (gpointer data);
GPrivate current_callback = G_PRIVATE_INIT (free_reporter_data);
@@ -185,38 +210,37 @@ rtcp_buffer_get_ssrc (GstBuffer * buf, guint32 * ssrc)
void
set_crypto_policy_cipher_auth (GstSrtpCipherType cipher,
- GstSrtpAuthType auth, crypto_policy_t * policy)
+ GstSrtpAuthType auth, srtp_crypto_policy_t * policy)
{
switch (cipher) {
case GST_SRTP_CIPHER_AES_128_ICM:
- policy->cipher_type = AES_ICM;
- policy->cipher_key_len = 30;
+ policy->cipher_type = SRTP_AES_ICM_128;
break;
case GST_SRTP_CIPHER_AES_256_ICM:
- policy->cipher_type = AES_ICM;
- policy->cipher_key_len = 46;
+ policy->cipher_type = SRTP_AES_ICM_256;
break;
case GST_SRTP_CIPHER_NULL:
- policy->cipher_type = NULL_CIPHER;
- policy->cipher_key_len = 0;
+ policy->cipher_type = SRTP_NULL_CIPHER;
break;
default:
g_assert_not_reached ();
}
+ policy->cipher_key_len = cipher_key_size (cipher);
+
switch (auth) {
case GST_SRTP_AUTH_HMAC_SHA1_80:
- policy->auth_type = HMAC_SHA1;
+ policy->auth_type = SRTP_HMAC_SHA1;
policy->auth_key_len = 20;
policy->auth_tag_len = 10;
break;
case GST_SRTP_AUTH_HMAC_SHA1_32:
- policy->auth_type = HMAC_SHA1;
+ policy->auth_type = SRTP_HMAC_SHA1;
policy->auth_key_len = 20;
policy->auth_tag_len = 4;
break;
case GST_SRTP_AUTH_NULL:
- policy->auth_type = NULL_AUTH;
+ policy->auth_type = SRTP_NULL_AUTH;
policy->auth_key_len = 0;
policy->auth_tag_len = 0;
break;
@@ -239,10 +263,10 @@ cipher_key_size (GstSrtpCipherType cipher)
switch (cipher) {
case GST_SRTP_CIPHER_AES_128_ICM:
- size = 30;
+ size = SRTP_AES_ICM_128_KEY_LEN_WSALT;
break;
case GST_SRTP_CIPHER_AES_256_ICM:
- size = 46;
+ size = SRTP_AES_ICM_256_KEY_LEN_WSALT;
break;
case GST_SRTP_CIPHER_NULL:
size = 0;