mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
srtpenc: Set the SRTP key as a shared key for all SSRCs
This is already how it was used.
This commit is contained in:
parent
a73a42b10f
commit
5a38ae5a83
2 changed files with 15 additions and 34 deletions
|
@ -319,8 +319,6 @@ gst_srtp_enc_init (GstSrtpEnc * filter)
|
||||||
filter->rtp_auth = DEFAULT_RTP_AUTH;
|
filter->rtp_auth = DEFAULT_RTP_AUTH;
|
||||||
filter->rtcp_cipher = DEFAULT_RTCP_CIPHER;
|
filter->rtcp_cipher = DEFAULT_RTCP_CIPHER;
|
||||||
filter->rtcp_auth = DEFAULT_RTCP_AUTH;
|
filter->rtcp_auth = DEFAULT_RTCP_AUTH;
|
||||||
|
|
||||||
filter->ssrcs_set = g_hash_table_new (g_direct_hash, g_direct_equal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static guint
|
static guint
|
||||||
|
@ -336,8 +334,8 @@ max_cipher_key_size (GstSrtpEnc * filter)
|
||||||
|
|
||||||
/* Create stream
|
/* Create stream
|
||||||
*/
|
*/
|
||||||
static gboolean
|
static err_status_t
|
||||||
check_new_stream_locked (GstSrtpEnc * filter, guint32 ssrc)
|
gst_srtp_enc_create_session (GstSrtpEnc * filter)
|
||||||
{
|
{
|
||||||
err_status_t ret;
|
err_status_t ret;
|
||||||
srtp_policy_t policy;
|
srtp_policy_t policy;
|
||||||
|
@ -346,10 +344,6 @@ check_new_stream_locked (GstSrtpEnc * filter, guint32 ssrc)
|
||||||
|
|
||||||
memset (&policy, 0, sizeof (srtp_policy_t));
|
memset (&policy, 0, sizeof (srtp_policy_t));
|
||||||
|
|
||||||
/* check if we already have that stream */
|
|
||||||
if (g_hash_table_lookup (filter->ssrcs_set, GUINT_TO_POINTER (ssrc)))
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
GST_OBJECT_LOCK (filter);
|
GST_OBJECT_LOCK (filter);
|
||||||
|
|
||||||
if (HAS_CRYPTO (filter)) {
|
if (HAS_CRYPTO (filter)) {
|
||||||
|
@ -391,29 +385,22 @@ check_new_stream_locked (GstSrtpEnc * filter, guint32 ssrc)
|
||||||
policy.key = tmp;
|
policy.key = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
policy.ssrc.value = ssrc;
|
policy.ssrc.value = 0;
|
||||||
policy.ssrc.type = ssrc_specific;
|
policy.ssrc.type = ssrc_any_outbound;
|
||||||
policy.next = NULL;
|
policy.next = NULL;
|
||||||
|
|
||||||
/* If it is the first stream, create the session
|
/* If it is the first stream, create the session
|
||||||
* If not, add the stream to the session
|
* If not, add the stream to the session
|
||||||
*/
|
*/
|
||||||
if (filter->first_session)
|
ret = srtp_create (&filter->session, &policy);
|
||||||
ret = srtp_create (&filter->session, &policy);
|
|
||||||
else
|
|
||||||
ret = srtp_add_stream (filter->session, &policy);
|
|
||||||
|
|
||||||
filter->first_session = FALSE;
|
filter->first_session = FALSE;
|
||||||
|
|
||||||
if (HAS_CRYPTO (filter))
|
if (HAS_CRYPTO (filter))
|
||||||
gst_buffer_unmap (filter->key, &map);
|
gst_buffer_unmap (filter->key, &map);
|
||||||
|
|
||||||
g_hash_table_insert (filter->ssrcs_set, GUINT_TO_POINTER (ssrc),
|
|
||||||
GUINT_TO_POINTER (1));
|
|
||||||
|
|
||||||
GST_OBJECT_UNLOCK (filter);
|
GST_OBJECT_UNLOCK (filter);
|
||||||
|
|
||||||
return ret == err_status_ok;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release ressources and set default values
|
/* Release ressources and set default values
|
||||||
|
@ -429,8 +416,6 @@ gst_srtp_enc_reset (GstSrtpEnc * filter)
|
||||||
filter->first_session = TRUE;
|
filter->first_session = TRUE;
|
||||||
filter->key_changed = FALSE;
|
filter->key_changed = FALSE;
|
||||||
|
|
||||||
g_hash_table_remove_all (filter->ssrcs_set);
|
|
||||||
|
|
||||||
GST_OBJECT_UNLOCK (filter);
|
GST_OBJECT_UNLOCK (filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,10 +561,6 @@ gst_srtp_enc_dispose (GObject * object)
|
||||||
gst_buffer_unref (filter->key);
|
gst_buffer_unref (filter->key);
|
||||||
filter->key = NULL;
|
filter->key = NULL;
|
||||||
|
|
||||||
if (filter->ssrcs_set)
|
|
||||||
g_hash_table_unref (filter->ssrcs_set);
|
|
||||||
filter->ssrcs_set = NULL;
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (gst_srtp_enc_parent_class)->dispose (object);
|
G_OBJECT_CLASS (gst_srtp_enc_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -956,13 +937,15 @@ gst_srtp_enc_chain (GstPad * pad, GstObject * parent, GstBuffer * buf,
|
||||||
do_setcaps = filter->key_changed;
|
do_setcaps = filter->key_changed;
|
||||||
if (filter->key_changed)
|
if (filter->key_changed)
|
||||||
gst_srtp_enc_reset (filter);
|
gst_srtp_enc_reset (filter);
|
||||||
|
if (filter->first_session) {
|
||||||
if (!check_new_stream_locked (filter, ssrc)) {
|
err_status_t status = gst_srtp_enc_create_session (filter);
|
||||||
GST_ELEMENT_ERROR (filter, LIBRARY, INIT,
|
if (status != err_status_ok) {
|
||||||
("Could not initialize SRTP encoder"),
|
GST_ELEMENT_ERROR (filter, LIBRARY, INIT,
|
||||||
("Failed to add stream to SRTP encoder"));
|
("Could not initialize SRTP encoder"),
|
||||||
ret = GST_FLOW_ERROR;
|
("Failed to add stream to SRTP encoder (err: %d)", status));
|
||||||
goto out;
|
ret = GST_FLOW_ERROR;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
priv->ssrc = ssrc;
|
priv->ssrc = ssrc;
|
||||||
|
|
||||||
|
|
|
@ -85,8 +85,6 @@ struct _GstSrtpEnc
|
||||||
gboolean hard_limit_reached;
|
gboolean hard_limit_reached;
|
||||||
gboolean soft_limit_reached;
|
gboolean soft_limit_reached;
|
||||||
|
|
||||||
GHashTable *ssrcs_set;
|
|
||||||
|
|
||||||
GType key_type;
|
GType key_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue