diff --git a/ext/srtp/gstsrtpdec.c b/ext/srtp/gstsrtpdec.c index 31999cb052..588b43d235 100644 --- a/ext/srtp/gstsrtpdec.c +++ b/ext/srtp/gstsrtpdec.c @@ -126,6 +126,8 @@ GST_DEBUG_CATEGORY_STATIC (gst_srtp_dec_debug); #define GST_CAT_DEFAULT gst_srtp_dec_debug +#define DEFAULT_REPLAY_WINDOW_SIZE 128 + /* Filter signals and args */ enum { @@ -139,7 +141,8 @@ enum enum { - PROP_0 + PROP_0, + PROP_REPLAY_WINDOW_SIZE }; typedef struct _ValidateBufferItData @@ -194,6 +197,11 @@ static guint gst_srtp_dec_signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE (GstSrtpDec, gst_srtp_dec, GST_TYPE_ELEMENT); +static void gst_srtp_dec_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_srtp_dec_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); + static void gst_srtp_dec_clear_streams (GstSrtpDec * filter); static void gst_srtp_dec_remove_stream (GstSrtpDec * filter, guint ssrc); @@ -252,10 +260,15 @@ struct _GstSrtpDecSsrcStream static void gst_srtp_dec_class_init (GstSrtpDecClass * klass) { + GObjectClass *gobject_class; GstElementClass *gstelement_class; + gobject_class = (GObjectClass *) klass; gstelement_class = (GstElementClass *) klass; + gobject_class->set_property = gst_srtp_dec_set_property; + gobject_class->get_property = gst_srtp_dec_get_property; + gst_element_class_add_pad_template (gstelement_class, gst_static_pad_template_get (&rtp_src_template)); gst_element_class_add_pad_template (gstelement_class, @@ -277,6 +290,13 @@ gst_srtp_dec_class_init (GstSrtpDecClass * klass) klass->clear_streams = GST_DEBUG_FUNCPTR (gst_srtp_dec_clear_streams); klass->remove_stream = GST_DEBUG_FUNCPTR (gst_srtp_dec_remove_stream); + /* Install properties */ + g_object_class_install_property (gobject_class, PROP_REPLAY_WINDOW_SIZE, + g_param_spec_uint ("replay-window-size", "Replay window size", + "Size of the replay protection window", + 64, 0x8000, DEFAULT_REPLAY_WINDOW_SIZE, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + /* Install signals */ /** * GstSrtpDec::request-key: @@ -358,6 +378,8 @@ gst_srtp_dec_class_init (GstSrtpDecClass * klass) static void gst_srtp_dec_init (GstSrtpDec * filter) { + filter->replay_window_size = DEFAULT_REPLAY_WINDOW_SIZE; + filter->rtp_sinkpad = gst_pad_new_from_static_template (&rtp_sink_template, "rtp_sink"); gst_pad_set_event_function (filter->rtp_sinkpad, @@ -411,6 +433,46 @@ gst_srtp_dec_init (GstSrtpDec * filter) filter->roc_changed = FALSE; } +static void +gst_srtp_dec_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) +{ + GstSrtpDec *filter = GST_SRTP_DEC (object); + + GST_OBJECT_LOCK (filter); + + switch (prop_id) { + case PROP_REPLAY_WINDOW_SIZE: + filter->replay_window_size = g_value_get_uint (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } + + GST_OBJECT_UNLOCK (filter); +} + +static void +gst_srtp_dec_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) +{ + GstSrtpDec *filter = GST_SRTP_DEC (object); + + GST_OBJECT_LOCK (filter); + + switch (prop_id) { + case PROP_REPLAY_WINDOW_SIZE: + g_value_set_uint (value, filter->replay_window_size); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } + + GST_OBJECT_UNLOCK (filter); +} + static void gst_srtp_dec_remove_stream (GstSrtpDec * filter, guint ssrc) { @@ -545,6 +607,7 @@ init_session_stream (GstSrtpDec * filter, guint32 ssrc, policy.ssrc.value = ssrc; policy.ssrc.type = ssrc_specific; + policy.window_size = filter->replay_window_size; policy.next = NULL; /* If it is the first stream, create the session diff --git a/ext/srtp/gstsrtpdec.h b/ext/srtp/gstsrtpdec.h index 41862e032a..644092a50e 100644 --- a/ext/srtp/gstsrtpdec.h +++ b/ext/srtp/gstsrtpdec.h @@ -71,6 +71,8 @@ struct _GstSrtpDec { GstElement element; + guint replay_window_size; + GstPad *rtp_sinkpad, *rtp_srcpad; GstPad *rtcp_sinkpad, *rtcp_srcpad;