diff options
author | Olivier CrĂȘte <olivier.crete@collabora.co.uk> | 2008-12-01 18:31:48 -0500 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2009-02-21 17:48:07 +0100 |
commit | 1468b2e2b061ad1924f51e3630b99623e38b44b9 (patch) | |
tree | 277fc017180ada5edc20494c13619c28609c0644 /gst/dtmf/gstrtpdtmfdepay.c | |
parent | 3f7d5d70a81a1d1167a8b4ef31df1422d9c9f05e (diff) |
[MOVED FROM GST-P-FARSIGHT] Allow setting a minimum size of a sound quanta in the dtmf depayloader
Diffstat (limited to 'gst/dtmf/gstrtpdtmfdepay.c')
-rw-r--r-- | gst/dtmf/gstrtpdtmfdepay.c | 72 |
1 files changed, 69 insertions, 3 deletions
diff --git a/gst/dtmf/gstrtpdtmfdepay.c b/gst/dtmf/gstrtpdtmfdepay.c index fad657920..8e82865a7 100644 --- a/gst/dtmf/gstrtpdtmfdepay.c +++ b/gst/dtmf/gstrtpdtmfdepay.c @@ -49,6 +49,9 @@ #define MIN_PULSE_DURATION 250 #define MIN_DUTY_CYCLE (MIN_INTER_DIGIT_INTERVAL + MIN_PULSE_DURATION) +#define MIN_UNIT_TIME 0 +#define MAX_UNIT_TIME 1000 +#define DEFAULT_UNIT_TIME 0 typedef struct st_dtmf_key { char *event_name; @@ -109,12 +112,20 @@ GST_DEBUG_CATEGORY_STATIC (gst_rtp_dtmf_depay_debug); enum { + + /* FILL ME */ LAST_SIGNAL }; enum { + PROP_0, + PROP_UNIT_TIME +}; + +enum +{ ARG_0 }; @@ -145,7 +156,10 @@ GST_STATIC_PAD_TEMPLATE ("sink", GST_BOILERPLATE (GstRtpDTMFDepay, gst_rtp_dtmf_depay, GstBaseRTPDepayload, GST_TYPE_BASE_RTP_DEPAYLOAD); - +static void gst_rtp_dtmf_depay_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec); +static void gst_rtp_dtmf_depay_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec); static GstBuffer *gst_rtp_dtmf_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf); gboolean gst_rtp_dtmf_depay_setcaps (GstBaseRTPDepayload * filter, @@ -180,8 +194,20 @@ gst_rtp_dtmf_depay_class_init (GstRtpDTMFDepayClass * klass) parent_class = g_type_class_peek_parent (klass); - gstbasertpdepayload_class->process = gst_rtp_dtmf_depay_process; - gstbasertpdepayload_class->set_caps = gst_rtp_dtmf_depay_setcaps; + gobject_class->set_property = + GST_DEBUG_FUNCPTR (gst_rtp_dtmf_depay_set_property); + gobject_class->get_property = + GST_DEBUG_FUNCPTR (gst_rtp_dtmf_depay_get_property); + + g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_UNIT_TIME, + g_param_spec_uint ("unit-time", "Duration unittime", + "The smallest unit (ms) the duration must be a multiple of (0 disables it)", MIN_UNIT_TIME, + MAX_UNIT_TIME, DEFAULT_UNIT_TIME, G_PARAM_READWRITE)); + + gstbasertpdepayload_class->process = + GST_DEBUG_FUNCPTR (gst_rtp_dtmf_depay_process); + gstbasertpdepayload_class->set_caps = + GST_DEBUG_FUNCPTR (gst_rtp_dtmf_depay_setcaps); } @@ -189,9 +215,44 @@ static void gst_rtp_dtmf_depay_init (GstRtpDTMFDepay * rtpdtmfdepay, GstRtpDTMFDepayClass * klass) { + rtpdtmfdepay->unit_time = DEFAULT_UNIT_TIME; +} + +static void +gst_rtp_dtmf_depay_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) +{ + GstRtpDTMFDepay * rtpdtmfdepay; + + rtpdtmfdepay = GST_RTP_DTMF_DEPAY (object); + switch (prop_id) { + case PROP_UNIT_TIME: + rtpdtmfdepay->unit_time = g_value_get_uint (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } +static void +gst_rtp_dtmf_depay_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) +{ + GstRtpDTMFDepay * rtpdtmfdepay; + + rtpdtmfdepay = GST_RTP_DTMF_DEPAY (object); + + switch (prop_id) { + case PROP_UNIT_TIME: + g_value_set_uint (value, rtpdtmfdepay->unit_time); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} gboolean gst_rtp_dtmf_depay_setcaps (GstBaseRTPDepayload * filter, GstCaps * caps) @@ -308,6 +369,11 @@ gst_rtp_dtmf_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) dtmf_payload.duration = g_ntohs (dtmf_payload.duration); + /* clip to whole units of unit_time */ + if (rtpdtmfdepay->unit_time) + dtmf_payload.duration -= dtmf_payload.duration % + ((rtpdtmfdepay->unit_time * depayload->clock_rate) / 1000); + GST_DEBUG_OBJECT (depayload, "Received new RTP DTMF packet : " "marker=%d - timestamp=%u - event=%d - duration=%d", marker, timestamp, dtmf_payload.event, dtmf_payload.duration); |