From: Olivier CrĂȘte Date: Mon, 5 May 2014 21:00:02 +0000 (-0400) Subject: srtpdec: Add "remove-key" action signal to remove a single key X-Git-Tag: 1.19.3~507^2~11213 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b2a6490626c23e2cd698b174a8b7c17ad57d1a46;p=platform%2Fupstream%2Fgstreamer.git srtpdec: Add "remove-key" action signal to remove a single key Removing all the keys can be a problem as it also resets the various counters, so instead add an option to remove a single key. --- diff --git a/ext/srtp/gstsrtpdec.c b/ext/srtp/gstsrtpdec.c index 52756a4..4c5f023 100644 --- a/ext/srtp/gstsrtpdec.c +++ b/ext/srtp/gstsrtpdec.c @@ -124,6 +124,7 @@ enum SIGNAL_CLEAR_KEYS, SIGNAL_SOFT_LIMIT, SIGNAL_HARD_LIMIT, + SIGNAL_REMOVE_KEY, LAST_SIGNAL }; @@ -169,6 +170,7 @@ static guint gst_srtp_dec_signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE (GstSrtpDec, gst_srtp_dec, GST_TYPE_ELEMENT); static void gst_srtp_dec_clear_streams (GstSrtpDec * filter); +static void gst_srtp_dec_remove_stream (GstSrtpDec * filter, guint ssrc); static gboolean gst_srtp_dec_sink_event_rtp (GstPad * pad, GstObject * parent, GstEvent * event); @@ -239,6 +241,7 @@ gst_srtp_dec_class_init (GstSrtpDecClass * klass) gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_srtp_dec_change_state); klass->clear_streams = GST_DEBUG_FUNCPTR (gst_srtp_dec_clear_streams); + klass->remove_stream = GST_DEBUG_FUNCPTR (gst_srtp_dec_remove_stream); /** * GstSrtpDec::request-key: @@ -296,6 +299,20 @@ gst_srtp_dec_class_init (GstSrtpDecClass * klass) gst_srtp_dec_signals[SIGNAL_HARD_LIMIT] = g_signal_new ("hard-limit", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, GST_TYPE_CAPS, 1, G_TYPE_UINT); + + /** + * GstSrtpDec::remove-key: + * @gstsrtpdec: the element on which the signal is emitted + * @ssrc: The SSRC for which to remove the key. + * + * Removes keys for a specific SSRC + */ + gst_srtp_dec_signals[SIGNAL_REMOVE_KEY] = + g_signal_new ("remove-key", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (GstSrtpDecClass, remove_stream), NULL, NULL, NULL, + G_TYPE_NONE, 1, G_TYPE_UINT); + } /* initialize the new element @@ -355,10 +372,13 @@ gst_srtp_dec_init (GstSrtpDec * filter) } static void -remove_stream_by_ssrc (GstSrtpDec * filter, guint32 ssrc) +gst_srtp_dec_remove_stream (GstSrtpDec * filter, guint ssrc) { GstSrtpDecSsrcStream *stream = NULL; + if (filter->streams == NULL) + return; + stream = g_hash_table_lookup (filter->streams, GUINT_TO_POINTER (ssrc)); if (stream) { @@ -559,7 +579,7 @@ update_session_stream_from_caps (GstSrtpDec * filter, guint32 ssrc, g_return_val_if_fail (GST_IS_CAPS (caps), NULL); /* Remove existing stream, if any */ - remove_stream_by_ssrc (filter, ssrc); + gst_srtp_dec_remove_stream (filter, ssrc); stream = get_stream_from_caps (filter, caps, ssrc); if (stream) { diff --git a/ext/srtp/gstsrtpdec.h b/ext/srtp/gstsrtpdec.h index 9d210fa..8129dc0 100644 --- a/ext/srtp/gstsrtpdec.h +++ b/ext/srtp/gstsrtpdec.h @@ -88,6 +88,7 @@ struct _GstSrtpDecClass GstElementClass parent_class; void (*clear_streams) (GstSrtpDec * filter); + void (*remove_stream) (GstSrtpDec * filter, guint ssrc); }; GType gst_srtp_dec_get_type (void);