mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 04:56:24 +00:00
[MOVED FROM GST-P-FARSIGHT] Allow setting a maximum duration to a RTP DTMF event
This commit is contained in:
parent
853337f1cc
commit
c50e962be0
2 changed files with 28 additions and 2 deletions
|
@ -53,6 +53,8 @@
|
||||||
#define MAX_UNIT_TIME 1000
|
#define MAX_UNIT_TIME 1000
|
||||||
#define DEFAULT_UNIT_TIME 0
|
#define DEFAULT_UNIT_TIME 0
|
||||||
|
|
||||||
|
#define DEFAULT_MAX_DURATION 0
|
||||||
|
|
||||||
typedef struct st_dtmf_key {
|
typedef struct st_dtmf_key {
|
||||||
char *event_name;
|
char *event_name;
|
||||||
int event_encoding;
|
int event_encoding;
|
||||||
|
@ -121,7 +123,8 @@ enum
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_UNIT_TIME
|
PROP_UNIT_TIME,
|
||||||
|
PROP_MAX_DURATION
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -204,6 +207,12 @@ gst_rtp_dtmf_depay_class_init (GstRtpDTMFDepayClass * klass)
|
||||||
"The smallest unit (ms) the duration must be a multiple of (0 disables it)", MIN_UNIT_TIME,
|
"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));
|
MAX_UNIT_TIME, DEFAULT_UNIT_TIME, G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MAX_DURATION,
|
||||||
|
g_param_spec_uint ("max-duration", "Maximum duration",
|
||||||
|
"The maxumimum duration (ms) of the outgoing soundpacket. "
|
||||||
|
"(0 = no limit)", 0, G_MAXUINT, DEFAULT_MAX_DURATION,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
gstbasertpdepayload_class->process =
|
gstbasertpdepayload_class->process =
|
||||||
GST_DEBUG_FUNCPTR (gst_rtp_dtmf_depay_process);
|
GST_DEBUG_FUNCPTR (gst_rtp_dtmf_depay_process);
|
||||||
gstbasertpdepayload_class->set_caps =
|
gstbasertpdepayload_class->set_caps =
|
||||||
|
@ -230,6 +239,9 @@ gst_rtp_dtmf_depay_set_property (GObject * object, guint prop_id,
|
||||||
case PROP_UNIT_TIME:
|
case PROP_UNIT_TIME:
|
||||||
rtpdtmfdepay->unit_time = g_value_get_uint (value);
|
rtpdtmfdepay->unit_time = g_value_get_uint (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_MAX_DURATION:
|
||||||
|
rtpdtmfdepay->max_duration = g_value_get_uint (value);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -248,6 +260,9 @@ gst_rtp_dtmf_depay_get_property (GObject * object, guint prop_id,
|
||||||
case PROP_UNIT_TIME:
|
case PROP_UNIT_TIME:
|
||||||
g_value_set_uint (value, rtpdtmfdepay->unit_time);
|
g_value_set_uint (value, rtpdtmfdepay->unit_time);
|
||||||
break;
|
break;
|
||||||
|
case PROP_MAX_DURATION:
|
||||||
|
g_value_set_uint (value, rtpdtmfdepay->max_duration);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
|
@ -385,6 +400,17 @@ gst_rtp_dtmf_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* clip to max duration */
|
||||||
|
if (rtpdtmfdepay->max_duration)
|
||||||
|
{
|
||||||
|
guint max_duration_clock =
|
||||||
|
(rtpdtmfdepay->max_duration * depayload->clock_rate) / 1000;
|
||||||
|
|
||||||
|
if (max_duration_clock < G_MAXUINT16 &&
|
||||||
|
dtmf_payload.duration > max_duration_clock)
|
||||||
|
dtmf_payload.duration = max_duration_clock;
|
||||||
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (depayload, "Received new RTP DTMF packet : "
|
GST_DEBUG_OBJECT (depayload, "Received new RTP DTMF packet : "
|
||||||
"marker=%d - timestamp=%u - event=%d - duration=%d",
|
"marker=%d - timestamp=%u - event=%d - duration=%d",
|
||||||
marker, timestamp, dtmf_payload.event, dtmf_payload.duration);
|
marker, timestamp, dtmf_payload.event, dtmf_payload.duration);
|
||||||
|
|
|
@ -54,7 +54,7 @@ struct _GstRtpDTMFDepay
|
||||||
guint16 previous_duration;
|
guint16 previous_duration;
|
||||||
GstClockTime first_gst_ts;
|
GstClockTime first_gst_ts;
|
||||||
guint unit_time;
|
guint unit_time;
|
||||||
|
guint max_duration;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstRtpDTMFDepayClass
|
struct _GstRtpDTMFDepayClass
|
||||||
|
|
Loading…
Reference in a new issue