summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Crete <olivier.crete@collabora.co.uk>2007-04-24 19:31:55 +0000
committerEdward Hervey <bilboed@bilboed.com>2009-02-21 17:47:58 +0100
commit2a8042fa72ad8000fdfbc5f583b970a63ba0d65a (patch)
tree5569cb52915564e159635a33b1b89cdfb24a1e02
parenteb74905991f8ec104e4f76f47a8b5805310a9485 (diff)
downloadgst-plugins-bad-2a8042fa72ad8000fdfbc5f583b970a63ba0d65a.tar.gz
gst-plugins-bad-2a8042fa72ad8000fdfbc5f583b970a63ba0d65a.tar.bz2
gst-plugins-bad-2a8042fa72ad8000fdfbc5f583b970a63ba0d65a.zip
[MOVED FROM GST-P-FARSIGHT] Add redundancy and interval properties to rtpdtmfsrc (patch by SP GLE <spglegle@yahoo.fr>)
20070424193155-3e2dc-66688001e7b529c46f108633cd9520347c3c8c3e.gz
-rw-r--r--gst/rtpdtmf/gstrtpdtmfsrc.c79
-rw-r--r--gst/rtpdtmf/gstrtpdtmfsrc.h3
2 files changed, 70 insertions, 12 deletions
diff --git a/gst/rtpdtmf/gstrtpdtmfsrc.c b/gst/rtpdtmf/gstrtpdtmfsrc.c
index d716b219..109343b6 100644
--- a/gst/rtpdtmf/gstrtpdtmfsrc.c
+++ b/gst/rtpdtmf/gstrtpdtmfsrc.c
@@ -130,7 +130,9 @@
#include "gstrtpdtmfsrc.h"
#define GST_RTP_DTMF_TYPE_EVENT 1
-#define DEFAULT_PACKET_INTERVAL ((guint16) 50) /* ms */
+#define DEFAULT_PACKET_INTERVAL 50 /* ms */
+#define MIN_PACKET_INTERVAL 10 /* ms */
+#define MAX_PACKET_INTERVAL 50 /* ms */
#define DEFAULT_SSRC -1
#define DEFAULT_PT 96
#define DEFAULT_TIMESTAMP_OFFSET -1
@@ -143,6 +145,10 @@
#define MIN_VOLUME 0
#define MAX_VOLUME 36
+#define DEFAULT_PACKET_REDUNDANCY 1
+#define MIN_PACKET_REDUNDANCY 1
+#define MAX_PACKET_REDUNDANCY 5
+
/* elementfactory information */
static const GstElementDetails gst_rtp_dtmf_src_details =
GST_ELEMENT_DETAILS ("RTP DTMF packet generator",
@@ -169,7 +175,9 @@ enum
PROP_PT,
PROP_CLOCK_RATE,
PROP_TIMESTAMP,
- PROP_SEQNUM
+ PROP_SEQNUM,
+ PROP_INTERVAL,
+ PROP_REDUNDANCY
};
static GstStaticPadTemplate gst_rtp_dtmf_src_template =
@@ -289,6 +297,15 @@ gst_rtp_dtmf_src_class_init (GstRTPDTMFSrcClass * klass)
g_param_spec_uint ("pt", "payload type",
"The payload type of the packets",
0, 0x80, DEFAULT_PT, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_INTERVAL,
+ g_param_spec_int ("interval", "Interval between rtp packets",
+ "Interval in ms between two rtp packets", MIN_PACKET_INTERVAL,
+ MAX_PACKET_INTERVAL, DEFAULT_PACKET_INTERVAL, G_PARAM_READWRITE));
+ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_REDUNDANCY,
+ g_param_spec_int ("packet-redundancy", "Packet Redundancy",
+ "Number of packets to send to indicate start and stop dtmf events",
+ MIN_PACKET_REDUNDANCY, MAX_PACKET_REDUNDANCY,
+ DEFAULT_PACKET_REDUNDANCY, G_PARAM_READWRITE));
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_rtp_dtmf_src_change_state);
@@ -309,6 +326,9 @@ gst_rtp_dtmf_src_init (GstRTPDTMFSrc * dtmfsrc, gpointer g_class)
dtmfsrc->ts_offset = DEFAULT_TIMESTAMP_OFFSET;
dtmfsrc->pt = DEFAULT_PT;
dtmfsrc->clock_rate = DEFAULT_CLOCK_RATE;
+ dtmfsrc->payload = NULL;
+ dtmfsrc->interval = DEFAULT_PACKET_INTERVAL;
+ dtmfsrc->packet_redundancy = DEFAULT_PACKET_REDUNDANCY;
GST_DEBUG_OBJECT (dtmfsrc, "init done");
}
@@ -457,6 +477,12 @@ gst_rtp_dtmf_src_set_property (GObject * object, guint prop_id,
dtmfsrc->pt = g_value_get_uint (value);
gst_rtp_dtmf_src_set_caps (dtmfsrc);
break;
+ case PROP_INTERVAL :
+ dtmfsrc->interval = g_value_get_int (value);
+ break;
+ case PROP_REDUNDANCY :
+ dtmfsrc->packet_redundancy = g_value_get_int (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -493,6 +519,12 @@ gst_rtp_dtmf_src_get_property (GObject * object, guint prop_id, GValue * value,
case PROP_SEQNUM:
g_value_set_uint (value, dtmfsrc->seqnum);
break;
+ case PROP_INTERVAL:
+ g_value_set_uint (value, dtmfsrc->interval);
+ break;
+ case PROP_REDUNDANCY:
+ g_value_set_uint (value, dtmfsrc->packet_redundancy);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -616,7 +648,7 @@ gst_rtp_dtmf_prepare_rtp_headers (GstRTPDTMFSrc *dtmfsrc, GstBuffer *buf)
/* timestamp of RTP header */
gst_rtp_buffer_set_timestamp (buf, dtmfsrc->rtp_timestamp);
dtmfsrc->rtp_timestamp +=
- DEFAULT_PACKET_INTERVAL * dtmfsrc->clock_rate / 1000;
+ dtmfsrc->interval * dtmfsrc->clock_rate / 1000;
}
static void
@@ -628,10 +660,10 @@ gst_rtp_dtmf_prepare_buffer_data (GstRTPDTMFSrc *dtmfsrc, GstBuffer *buf)
/* duration of DTMF payload */
dtmfsrc->payload->duration +=
- DEFAULT_PACKET_INTERVAL * dtmfsrc->clock_rate / 1000;
+ dtmfsrc->interval * dtmfsrc->clock_rate / 1000;
/* timestamp and duration of GstBuffer */
- GST_BUFFER_DURATION (buf) = DEFAULT_PACKET_INTERVAL * GST_MSECOND;
+ GST_BUFFER_DURATION (buf) = dtmfsrc->interval * GST_MSECOND;
GST_BUFFER_TIMESTAMP (buf) = dtmfsrc->timestamp;
dtmfsrc->timestamp += GST_BUFFER_DURATION (buf);
@@ -666,17 +698,40 @@ gst_rtp_dtmf_src_push_next_rtp_packet (GstRTPDTMFSrc *dtmfsrc)
{
GstBuffer *buf = NULL;
GstFlowReturn ret;
+ gint redundancy_count = 1;
+
+ if (dtmfsrc->first_packet == TRUE || dtmfsrc->payload->e) {
+ redundancy_count = dtmfsrc->packet_redundancy;
+
+ if(dtmfsrc->first_packet == TRUE) {
+ GST_DEBUG_OBJECT (dtmfsrc,
+ "redundancy count set to %d due to dtmf start",
+ redundancy_count);
+ }
+ if(dtmfsrc->payload->e) {
+ GST_DEBUG_OBJECT (dtmfsrc,
+ "redundancy count set to %d due to dtmf stop",
+ redundancy_count);
+ }
+
+ }
/* create buffer to hold the payload */
buf = gst_rtp_dtmf_src_create_next_rtp_packet (dtmfsrc);
- GST_DEBUG_OBJECT (dtmfsrc,
- "pushing buffer on src pad of size %d", GST_BUFFER_SIZE (buf));
- ret = gst_pad_push (dtmfsrc->srcpad, buf);
- if (ret != GST_FLOW_OK)
- GST_ERROR_OBJECT (dtmfsrc,
- "Failed to push buffer on src pad", GST_BUFFER_SIZE (buf));
-
+ while ( redundancy_count-- ) {
+ gst_buffer_ref(buf);
+
+ GST_DEBUG_OBJECT (dtmfsrc,
+ "pushing buffer on src pad of size %d with redundancy count %d",
+ GST_BUFFER_SIZE (buf), redundancy_count);
+ ret = gst_pad_push (dtmfsrc->srcpad, buf);
+ if (ret != GST_FLOW_OK)
+ GST_ERROR_OBJECT (dtmfsrc,
+ "Failed to push buffer on src pad", GST_BUFFER_SIZE (buf));
+ }
+
+ gst_buffer_unref(buf);
GST_DEBUG_OBJECT (dtmfsrc,
"pushed DTMF event '%d' on src pad", dtmfsrc->payload->event);
}
diff --git a/gst/rtpdtmf/gstrtpdtmfsrc.h b/gst/rtpdtmf/gstrtpdtmfsrc.h
index 6d012f42..81187665 100644
--- a/gst/rtpdtmf/gstrtpdtmfsrc.h
+++ b/gst/rtpdtmf/gstrtpdtmfsrc.h
@@ -84,6 +84,9 @@ struct _GstRTPDTMFSrc {
GstClockTime timestamp;
GstSegment segment;
+
+ guint16 interval;
+ guint16 packet_redundancy;
};
struct _GstRTPDTMFSrcClass {