summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--gst/dtmf/gstdtmfdetect.c54
-rw-r--r--gst/dtmf/gstdtmfsrc.c78
-rw-r--r--gst/dtmf/gstrtpdtmfdepay.c94
-rw-r--r--gst/dtmf/gstrtpdtmfdepay.h6
-rw-r--r--gst/dtmf/gstrtpdtmfsrc.c84
6 files changed, 146 insertions, 172 deletions
diff --git a/configure.ac b/configure.ac
index 0b1daf97a..035cf1944 100644
--- a/configure.ac
+++ b/configure.ac
@@ -311,7 +311,7 @@ dnl Non ported plugins (non-dependant, then dependant)
dnl Make sure you have a space before and after all plugins
GST_PLUGINS_NONPORTED=" adpcmdec adpcmenc aiff asfmux \
autoconvert camerabin cdxaparse coloreffects \
- dccp debugutils dtmf faceoverlay festival \
+ dccp debugutils faceoverlay festival \
fieldanalysis freeverb freeze frei0r gaudieffects geometrictransform h264parse \
hdvparse hls id3tag inter interlace ivfparse jpegformat jp2kdecimator \
kate liveadder legacyresample librfb mpegdemux mpegtsmux \
diff --git a/gst/dtmf/gstdtmfdetect.c b/gst/dtmf/gstdtmfdetect.c
index 0bb924264..5bc98af17 100644
--- a/gst/dtmf/gstdtmfdetect.c
+++ b/gst/dtmf/gstdtmfdetect.c
@@ -101,50 +101,42 @@ static gboolean gst_dtmf_detect_set_caps (GstBaseTransform * trans,
GstCaps * incaps, GstCaps * outcaps);
static GstFlowReturn gst_dtmf_detect_transform_ip (GstBaseTransform * trans,
GstBuffer * buf);
-static gboolean gst_dtmf_detect_event (GstBaseTransform * trans,
+static gboolean gst_dtmf_detect_sink_event (GstBaseTransform * trans,
GstEvent * event);
+G_DEFINE_TYPE (GstDtmfDetect, gst_dtmf_detect, GST_TYPE_BASE_TRANSFORM);
+
static void
-_do_init (GType type)
+gst_dtmf_detect_class_init (GstDtmfDetectClass * klass)
{
- GST_DEBUG_CATEGORY_INIT (dtmf_detect_debug, "dtmfdetect", 0, "dtmfdetect");
-}
+ GstElementClass *gstelement_class;
+ GstBaseTransformClass *gstbasetransform_class;
-GST_BOILERPLATE_FULL (GstDtmfDetect, gst_dtmf_detect, GstBaseTransform,
- GST_TYPE_BASE_TRANSFORM, _do_init);
+ gstelement_class = GST_ELEMENT_CLASS (klass);
+ gstbasetransform_class = (GstBaseTransformClass *) klass;
-static void
-gst_dtmf_detect_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+ GST_DEBUG_CATEGORY_INIT (dtmf_detect_debug, "dtmfdetect", 0, "dtmfdetect");
- gst_element_class_add_pad_template (element_class,
+ gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&srctemplate));
- gst_element_class_add_pad_template (element_class,
+ gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&sinktemplate));
- gst_element_class_set_details_simple (element_class, "DTMF detector element",
+ gst_element_class_set_metadata (gstelement_class, "DTMF detector element",
"Filter/Analyzer/Audio",
"This element detects DTMF tones",
- "Olivier Crete <olivier.crete@collabora.co.uk>");
-}
-
-static void
-gst_dtmf_detect_class_init (GstDtmfDetectClass * klass)
-{
- GstBaseTransformClass *gstbasetransform_class;
-
- gstbasetransform_class = (GstBaseTransformClass *) klass;
+ "Olivier Crete <olivier.crete@collabora.com>");
gstbasetransform_class->set_caps =
GST_DEBUG_FUNCPTR (gst_dtmf_detect_set_caps);
gstbasetransform_class->transform_ip =
GST_DEBUG_FUNCPTR (gst_dtmf_detect_transform_ip);
- gstbasetransform_class->event = GST_DEBUG_FUNCPTR (gst_dtmf_detect_event);
+ gstbasetransform_class->sink_event =
+ GST_DEBUG_FUNCPTR (gst_dtmf_detect_sink_event);
}
static void
-gst_dtmf_detect_init (GstDtmfDetect * dtmfdetect, GstDtmfDetectClass * klass)
+gst_dtmf_detect_init (GstDtmfDetect * dtmfdetect)
{
gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (dtmfdetect), TRUE);
gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM (dtmfdetect), TRUE);
@@ -169,14 +161,17 @@ gst_dtmf_detect_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
gint dtmf_count;
gchar dtmfbuf[MAX_DTMF_DIGITS] = "";
gint i;
+ gpointer data;
+ gsize size;
if (GST_BUFFER_IS_DISCONT (buf))
zap_dtmf_detect_init (&self->dtmf_state);
if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_GAP))
return GST_FLOW_OK;
- zap_dtmf_detect (&self->dtmf_state, (gint16 *) GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf) / 2, FALSE);
+ data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
+
+ zap_dtmf_detect (&self->dtmf_state, (gint16 *) data, size / 2, FALSE);
dtmf_count = zap_dtmf_get (&self->dtmf_state, dtmfbuf, MAX_DTMF_DIGITS);
@@ -185,6 +180,8 @@ gst_dtmf_detect_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
else
GST_LOG_OBJECT (self, "Got no DTMF events");
+ gst_buffer_unmap (buf, data, size);
+
for (i = 0; i < dtmf_count; i++) {
GstMessage *dtmf_message = NULL;
GstStructure *structure;
@@ -258,7 +255,7 @@ gst_dtmf_detect_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
static gboolean
-gst_dtmf_detect_event (GstBaseTransform * trans, GstEvent * event)
+gst_dtmf_detect_sink_event (GstBaseTransform * trans, GstEvent * event)
{
GstDtmfDetect *self = GST_DTMF_DETECT (trans);
@@ -270,8 +267,7 @@ gst_dtmf_detect_event (GstBaseTransform * trans, GstEvent * event)
break;
}
- return GST_CALL_PARENT_WITH_DEFAULT (GST_BASE_TRANSFORM_CLASS, event,
- (trans, event), TRUE);
+ return GST_BASE_TRANSFORM_GET_CLASS (trans)->sink_event (trans, event);
}
diff --git a/gst/dtmf/gstdtmfsrc.c b/gst/dtmf/gstdtmfsrc.c
index 929147fe0..80583fbc8 100644
--- a/gst/dtmf/gstdtmfsrc.c
+++ b/gst/dtmf/gstdtmfsrc.c
@@ -211,7 +211,7 @@ GST_STATIC_PAD_TEMPLATE ("src",
"signed = (bool) true, rate = (int) [1, MAX], channels = (int) 1")
);
-GST_BOILERPLATE (GstDTMFSrc, gst_dtmf_src, GstBaseSrc, GST_TYPE_BASE_SRC);
+G_DEFINE_TYPE (GstDTMFSrc, gst_dtmf_src, GST_TYPE_BASE_SRC);
static void gst_dtmf_src_finalize (GObject * object);
@@ -234,21 +234,6 @@ static gboolean gst_dtmf_src_unlock (GstBaseSrc * src);
static gboolean gst_dtmf_src_unlock_stop (GstBaseSrc * src);
static gboolean gst_dtmf_src_negotiate (GstBaseSrc * basesrc);
-static void
-gst_dtmf_src_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- GST_DEBUG_CATEGORY_INIT (gst_dtmf_src_debug, "dtmfsrc", 0, "dtmfsrc element");
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_dtmf_src_template));
-
- gst_element_class_set_details_simple (element_class, "DTMF tone generator",
- "Source/Audio",
- "Generates DTMF tones",
- "Youness Alaoui <youness.alaoui@collabora.co.uk>");
-}
static void
gst_dtmf_src_class_init (GstDTMFSrcClass * klass)
@@ -262,6 +247,17 @@ gst_dtmf_src_class_init (GstDTMFSrcClass * klass)
gstelement_class = GST_ELEMENT_CLASS (klass);
+ GST_DEBUG_CATEGORY_INIT (gst_dtmf_src_debug, "dtmfsrc", 0, "dtmfsrc element");
+
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_dtmf_src_template));
+
+ gst_element_class_set_details_simple (gstelement_class, "DTMF tone generator",
+ "Source/Audio",
+ "Generates DTMF tones",
+ "Youness Alaoui <youness.alaoui@collabora.co.uk>");
+
+
gobject_class->finalize = gst_dtmf_src_finalize;
gobject_class->set_property = gst_dtmf_src_set_property;
gobject_class->get_property = gst_dtmf_src_get_property;
@@ -291,7 +287,7 @@ event_free (GstDTMFSrcEvent * event)
}
static void
-gst_dtmf_src_init (GstDTMFSrc * dtmfsrc, GstDTMFSrcClass * g_class)
+gst_dtmf_src_init (GstDTMFSrc * dtmfsrc)
{
/* we operate in time */
gst_base_src_set_format (GST_BASE_SRC (dtmfsrc), GST_FORMAT_TIME);
@@ -319,7 +315,7 @@ gst_dtmf_src_finalize (GObject * object)
dtmfsrc->event_queue = NULL;
}
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (gst_dtmf_src_parent_class)->finalize (object);
}
static gboolean
@@ -426,7 +422,8 @@ gst_dtmf_src_send_event (GstElement * element, GstEvent * event)
if (gst_dtmf_src_handle_event (GST_BASE_SRC (element), event))
return TRUE;
- return GST_ELEMENT_CLASS (parent_class)->send_event (element, event);
+ return GST_ELEMENT_CLASS (gst_dtmf_src_parent_class)->send_event
+ (element, event);
}
static void
@@ -528,24 +525,22 @@ gst_dtmf_src_add_stop_event (GstDTMFSrc * dtmfsrc)
g_async_queue_push (dtmfsrc->event_queue, event);
}
-static void
-gst_dtmf_src_generate_silence (GstBuffer * buffer, float duration,
- gint sample_rate)
+static GstBuffer *
+gst_dtmf_src_generate_silence (float duration, gint sample_rate)
{
gint buf_size;
/* Create a buffer with data set to 0 */
buf_size = ((duration / 1000) * sample_rate * SAMPLE_SIZE * CHANNELS) / 8;
- GST_BUFFER_SIZE (buffer) = buf_size;
- GST_BUFFER_MALLOCDATA (buffer) = g_malloc0 (buf_size);
- GST_BUFFER_DATA (buffer) = GST_BUFFER_MALLOCDATA (buffer);
+ return gst_buffer_new_wrapped (g_malloc0 (buf_size), buf_size);
}
-static void
+static GstBuffer *
gst_dtmf_src_generate_tone (GstDTMFSrcEvent * event, DTMF_KEY key,
- float duration, GstBuffer * buffer, gint sample_rate)
+ float duration, gint sample_rate)
{
+ GstBuffer *buffer;
gint16 *p;
gint tone_size;
double i = 0;
@@ -554,11 +549,10 @@ gst_dtmf_src_generate_tone (GstDTMFSrcEvent * event, DTMF_KEY key,
/* Create a buffer for the tone */
tone_size = ((duration / 1000) * sample_rate * SAMPLE_SIZE * CHANNELS) / 8;
- GST_BUFFER_SIZE (buffer) = tone_size;
- GST_BUFFER_MALLOCDATA (buffer) = g_malloc (tone_size);
- GST_BUFFER_DATA (buffer) = GST_BUFFER_MALLOCDATA (buffer);
- p = (gint16 *) GST_BUFFER_MALLOCDATA (buffer);
+ buffer = gst_buffer_new_allocate (NULL, tone_size, 1);
+
+ p = (gint16 *) gst_buffer_map (buffer, NULL, NULL, GST_MAP_READWRITE);
volume_factor = pow (10, (-event->volume) / 20);
@@ -586,6 +580,10 @@ gst_dtmf_src_generate_tone (GstDTMFSrcEvent * event, DTMF_KEY key,
(event->sample)++;
}
+
+ gst_buffer_unmap (buffer, p, tone_size);
+
+ return buffer;
}
@@ -596,26 +594,22 @@ gst_dtmf_src_create_next_tone_packet (GstDTMFSrc * dtmfsrc,
{
GstBuffer *buf = NULL;
gboolean send_silence = FALSE;
- GstPad *srcpad = GST_BASE_SRC_PAD (dtmfsrc);
GST_LOG_OBJECT (dtmfsrc, "Creating buffer for tone %s",
DTMF_KEYS[event->event_number].event_name);
- /* create buffer to hold the tone */
- buf = gst_buffer_new ();
-
if (event->packet_count * dtmfsrc->interval < MIN_INTER_DIGIT_INTERVAL) {
send_silence = TRUE;
}
if (send_silence) {
GST_LOG_OBJECT (dtmfsrc, "Generating silence");
- gst_dtmf_src_generate_silence (buf, dtmfsrc->interval,
+ buf = gst_dtmf_src_generate_silence (dtmfsrc->interval,
dtmfsrc->sample_rate);
} else {
GST_LOG_OBJECT (dtmfsrc, "Generating tone");
- gst_dtmf_src_generate_tone (event, DTMF_KEYS[event->event_number],
- dtmfsrc->interval, buf, dtmfsrc->sample_rate);
+ buf = gst_dtmf_src_generate_tone (event, DTMF_KEYS[event->event_number],
+ dtmfsrc->interval, dtmfsrc->sample_rate);
}
event->packet_count++;
@@ -631,9 +625,6 @@ gst_dtmf_src_create_next_tone_packet (GstDTMFSrc * dtmfsrc,
dtmfsrc->timestamp += GST_BUFFER_DURATION (buf);
- /* Set caps on the buffer before pushing it */
- gst_buffer_set_caps (buf, GST_PAD_CAPS (srcpad));
-
return buf;
}
@@ -787,7 +778,8 @@ gst_dtmf_src_create (GstBaseSrc * basesrc, guint64 offset,
buf = gst_dtmf_src_create_next_tone_packet (dtmfsrc, dtmfsrc->last_event);
- GST_LOG_OBJECT (dtmfsrc, "Created buffer of size %d", GST_BUFFER_SIZE (buf));
+ GST_LOG_OBJECT (dtmfsrc, "Created buffer of size %d",
+ gst_buffer_get_size (buf));
*buffer = buf;
return GST_FLOW_OK;
@@ -912,7 +904,7 @@ gst_dtmf_src_change_state (GstElement * element, GstStateChange transition)
}
if ((result =
- GST_ELEMENT_CLASS (parent_class)->change_state (element,
+ GST_ELEMENT_CLASS (gst_dtmf_src_parent_class)->change_state (element,
transition)) == GST_STATE_CHANGE_FAILURE)
goto failure;
diff --git a/gst/dtmf/gstrtpdtmfdepay.c b/gst/dtmf/gstrtpdtmfdepay.c
index 603416dd6..9d470f5f9 100644
--- a/gst/dtmf/gstrtpdtmfdepay.c
+++ b/gst/dtmf/gstrtpdtmfdepay.c
@@ -199,47 +199,40 @@ GST_STATIC_PAD_TEMPLATE ("sink",
"encoding-name = (string) \"TELEPHONE-EVENT\"")
);
-GST_BOILERPLATE (GstRtpDTMFDepay, gst_rtp_dtmf_depay, GstBaseRTPDepayload,
- GST_TYPE_BASE_RTP_DEPAYLOAD);
+G_DEFINE_TYPE (GstRtpDTMFDepay, gst_rtp_dtmf_depay,
+ GST_TYPE_RTP_BASE_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,
+static GstBuffer *gst_rtp_dtmf_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
-gboolean gst_rtp_dtmf_depay_setcaps (GstBaseRTPDepayload * filter,
+gboolean gst_rtp_dtmf_depay_setcaps (GstRTPBaseDepayload * filter,
GstCaps * caps);
static void
-gst_rtp_dtmf_depay_base_init (gpointer klass)
+gst_rtp_dtmf_depay_class_init (GstRtpDTMFDepayClass * klass)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+ GObjectClass *gobject_class;
+ GstElementClass *gstelement_class;
+ GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ gstelement_class = GST_ELEMENT_CLASS (klass);
+ gstrtpbasedepayload_class = GST_RTP_BASE_DEPAYLOAD_CLASS (klass);
- gst_element_class_add_pad_template (element_class,
+ gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_dtmf_depay_src_template));
- gst_element_class_add_pad_template (element_class,
+ gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_dtmf_depay_sink_template));
-
GST_DEBUG_CATEGORY_INIT (gst_rtp_dtmf_depay_debug,
"rtpdtmfdepay", 0, "rtpdtmfdepay element");
- gst_element_class_set_details_simple (element_class,
+ gst_element_class_set_details_simple (gstelement_class,
"RTP DTMF packet depayloader", "Codec/Depayloader/Network",
"Generates DTMF Sound from telephone-event RTP packets",
"Youness Alaoui <youness.alaoui@collabora.co.uk>");
-}
-
-static void
-gst_rtp_dtmf_depay_class_init (GstRtpDTMFDepayClass * klass)
-{
- GObjectClass *gobject_class;
- GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
-
- gobject_class = (GObjectClass *) klass;
- gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
-
- parent_class = g_type_class_peek_parent (klass);
gobject_class->set_property =
GST_DEBUG_FUNCPTR (gst_rtp_dtmf_depay_set_property);
@@ -258,16 +251,15 @@ gst_rtp_dtmf_depay_class_init (GstRtpDTMFDepayClass * klass)
"(0 = no limit)", 0, G_MAXUINT, DEFAULT_MAX_DURATION,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- gstbasertpdepayload_class->process =
+ gstrtpbasedepayload_class->process =
GST_DEBUG_FUNCPTR (gst_rtp_dtmf_depay_process);
- gstbasertpdepayload_class->set_caps =
+ gstrtpbasedepayload_class->set_caps =
GST_DEBUG_FUNCPTR (gst_rtp_dtmf_depay_setcaps);
}
static void
-gst_rtp_dtmf_depay_init (GstRtpDTMFDepay * rtpdtmfdepay,
- GstRtpDTMFDepayClass * klass)
+gst_rtp_dtmf_depay_init (GstRtpDTMFDepay * rtpdtmfdepay)
{
rtpdtmfdepay->unit_time = DEFAULT_UNIT_TIME;
}
@@ -315,7 +307,7 @@ gst_rtp_dtmf_depay_get_property (GObject * object, guint prop_id,
}
gboolean
-gst_rtp_dtmf_depay_setcaps (GstBaseRTPDepayload * filter, GstCaps * caps)
+gst_rtp_dtmf_depay_setcaps (GstRTPBaseDepayload * filter, GstCaps * caps)
{
GstCaps *srccaps;
GstStructure *structure = gst_caps_get_structure (caps, 0);
@@ -330,16 +322,17 @@ gst_rtp_dtmf_depay_setcaps (GstBaseRTPDepayload * filter, GstCaps * caps)
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"signed", G_TYPE_BOOLEAN, TRUE,
"channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, clock_rate, NULL);
- gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (filter), srccaps);
+ gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (filter), srccaps);
gst_caps_unref (srccaps);
return TRUE;
}
-static void
+static GstBuffer *
gst_dtmf_src_generate_tone (GstRtpDTMFDepay * rtpdtmfdepay,
- GstRTPDTMFPayload payload, GstBuffer * buffer)
+ GstRTPDTMFPayload payload)
{
+ GstBuffer *buf;
gint16 *p;
gint tone_size;
double i = 0;
@@ -347,20 +340,18 @@ gst_dtmf_src_generate_tone (GstRtpDTMFDepay * rtpdtmfdepay,
double volume_factor;
DTMF_KEY key = DTMF_KEYS[payload.event];
guint32 clock_rate = 8000 /* default */ ;
- GstBaseRTPDepayload *depayload = GST_BASE_RTP_DEPAYLOAD (rtpdtmfdepay);
+ GstRTPBaseDepayload *depayload = GST_RTP_BASE_DEPAYLOAD (rtpdtmfdepay);
gint volume;
clock_rate = depayload->clock_rate;
/* Create a buffer for the tone */
tone_size = (payload.duration * SAMPLE_SIZE * CHANNELS) / 8;
- GST_BUFFER_SIZE (buffer) = tone_size;
- GST_BUFFER_MALLOCDATA (buffer) = g_malloc (tone_size);
- GST_BUFFER_DATA (buffer) = GST_BUFFER_MALLOCDATA (buffer);
- GST_BUFFER_DURATION (buffer) = payload.duration * GST_SECOND / clock_rate;
+ buf = gst_buffer_new_allocate (NULL, tone_size, 1);
+ GST_BUFFER_DURATION (buf) = payload.duration * GST_SECOND / clock_rate;
volume = payload.volume;
- p = (gint16 *) GST_BUFFER_MALLOCDATA (buffer);
+ p = (gint16 *) gst_buffer_map (buf, NULL, NULL, GST_MAP_WRITE);
volume_factor = pow (10, (-volume) / 20);
@@ -390,11 +381,15 @@ gst_dtmf_src_generate_tone (GstRtpDTMFDepay * rtpdtmfdepay,
(rtpdtmfdepay->sample)++;
}
+
+ gst_buffer_unmap (buf, p, tone_size);
+
+ return buf;
}
static GstBuffer *
-gst_rtp_dtmf_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_dtmf_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpDTMFDepay *rtpdtmfdepay = NULL;
@@ -406,14 +401,17 @@ gst_rtp_dtmf_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
gboolean marker;
GstStructure *structure = NULL;
GstMessage *dtmf_message = NULL;
+ GstRTPBuffer rtpbuffer = GST_RTP_BUFFER_INIT;
rtpdtmfdepay = GST_RTP_DTMF_DEPAY (depayload);
if (!gst_rtp_buffer_validate (buf))
goto bad_packet;
- payload_len = gst_rtp_buffer_get_payload_len (buf);
- payload = gst_rtp_buffer_get_payload (buf);
+ gst_rtp_buffer_map (buf, GST_MAP_READ, &rtpbuffer);
+
+ payload_len = gst_rtp_buffer_get_payload_len (&rtpbuffer);
+ payload = gst_rtp_buffer_get_payload (&rtpbuffer);
if (payload_len != sizeof (GstRTPDTMFPayload))
goto bad_packet;
@@ -424,9 +422,9 @@ gst_rtp_dtmf_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
goto bad_packet;
- marker = gst_rtp_buffer_get_marker (buf);
+ marker = gst_rtp_buffer_get_marker (&rtpbuffer);
- timestamp = gst_rtp_buffer_get_timestamp (buf);
+ timestamp = gst_rtp_buffer_get_timestamp (&rtpbuffer);
dtmf_payload.duration = g_ntohs (dtmf_payload.duration);
@@ -467,7 +465,7 @@ gst_rtp_dtmf_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
rtpdtmfdepay->sample = 0;
rtpdtmfdepay->previous_ts = timestamp;
rtpdtmfdepay->previous_duration = dtmf_payload.duration;
- rtpdtmfdepay->first_gst_ts = GST_BUFFER_TIMESTAMP (buf);
+ rtpdtmfdepay->first_gst_ts = GST_BUFFER_PTS (buf);
structure = gst_structure_new ("dtmf-event",
"number", G_TYPE_INT, dtmf_payload.event,
@@ -503,11 +501,10 @@ gst_rtp_dtmf_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
/* If late or duplicate packet (like the redundant end packet). Ignore */
if (dtmf_payload.duration > 0) {
- outbuf = gst_buffer_new ();
- gst_dtmf_src_generate_tone (rtpdtmfdepay, dtmf_payload, outbuf);
+ outbuf = gst_dtmf_src_generate_tone (rtpdtmfdepay, dtmf_payload);
- GST_BUFFER_TIMESTAMP (outbuf) = rtpdtmfdepay->first_gst_ts +
+ GST_BUFFER_PTS (outbuf) = rtpdtmfdepay->first_gst_ts +
(rtpdtmfdepay->previous_duration - dtmf_payload.duration) *
GST_SECOND / depayload->clock_rate;
GST_BUFFER_OFFSET (outbuf) =
@@ -522,12 +519,17 @@ gst_rtp_dtmf_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
}
- return outbuf;
+ gst_rtp_buffer_unmap (&rtpbuffer);
+ return outbuf;
bad_packet:
GST_ELEMENT_WARNING (rtpdtmfdepay, STREAM, DECODE,
("Packet did not validate"), (NULL));
+
+ if (rtpbuffer.buffer != NULL)
+ gst_rtp_buffer_unmap (&rtpbuffer);
+
return NULL;
}
diff --git a/gst/dtmf/gstrtpdtmfdepay.h b/gst/dtmf/gstrtpdtmfdepay.h
index 65d94549f..f5fe6b984 100644
--- a/gst/dtmf/gstrtpdtmfdepay.h
+++ b/gst/dtmf/gstrtpdtmfdepay.h
@@ -25,7 +25,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
-#include <gst/rtp/gstbasertpdepayload.h>
+#include <gst/rtp/gstrtpbasedepayload.h>
#include "gstdtmfcommon.h"
@@ -46,7 +46,7 @@ typedef struct _GstRtpDTMFDepayClass GstRtpDTMFDepayClass;
struct _GstRtpDTMFDepay
{
/*< private >*/
- GstBaseRTPDepayload depayload;
+ GstRTPBaseDepayload depayload;
double sample;
guint32 previous_ts;
guint16 previous_duration;
@@ -57,7 +57,7 @@ struct _GstRtpDTMFDepay
struct _GstRtpDTMFDepayClass
{
- GstBaseRTPDepayloadClass parent_class;
+ GstRTPBaseDepayloadClass parent_class;
};
GType gst_rtp_dtmf_depay_get_type (void);
diff --git a/gst/dtmf/gstrtpdtmfsrc.c b/gst/dtmf/gstrtpdtmfsrc.c
index ee8703563..f97261ef6 100644
--- a/gst/dtmf/gstrtpdtmfsrc.c
+++ b/gst/dtmf/gstrtpdtmfsrc.c
@@ -176,8 +176,7 @@ GST_STATIC_PAD_TEMPLATE ("src",
);
-GST_BOILERPLATE (GstRTPDTMFSrc, gst_rtp_dtmf_src, GstBaseSrc,
- GST_TYPE_BASE_SRC);
+G_DEFINE_TYPE (GstRTPDTMFSrc, gst_rtp_dtmf_src, GST_TYPE_BASE_SRC);
static void gst_rtp_dtmf_src_finalize (GObject * object);
@@ -201,22 +200,6 @@ static gboolean gst_rtp_dtmf_src_negotiate (GstBaseSrc * basesrc);
static void
-gst_rtp_dtmf_src_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-
- GST_DEBUG_CATEGORY_INIT (gst_rtp_dtmf_src_debug,
- "rtpdtmfsrc", 0, "rtpdtmfsrc element");
-
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&gst_rtp_dtmf_src_template));
-
- gst_element_class_set_details_simple (element_class,
- "RTP DTMF packet generator", "Source/Network",
- "Generates RTP DTMF packets", "Zeeshan Ali <zeeshan.ali@nokia.com>");
-}
-
-static void
gst_rtp_dtmf_src_class_init (GstRTPDTMFSrcClass * klass)
{
GObjectClass *gobject_class;
@@ -227,7 +210,15 @@ gst_rtp_dtmf_src_class_init (GstRTPDTMFSrcClass * klass)
gstbasesrc_class = GST_BASE_SRC_CLASS (klass);
gstelement_class = GST_ELEMENT_CLASS (klass);
- parent_class = g_type_class_peek_parent (klass);
+ GST_DEBUG_CATEGORY_INIT (gst_rtp_dtmf_src_debug,
+ "rtpdtmfsrc", 0, "rtpdtmfsrc element");
+
+ gst_element_class_add_pad_template (gstelement_class,
+ gst_static_pad_template_get (&gst_rtp_dtmf_src_template));
+
+ gst_element_class_set_metadata (gstelement_class,
+ "RTP DTMF packet generator", "Source/Network",
+ "Generates RTP DTMF packets", "Zeeshan Ali <zeeshan.ali@nokia.com>");
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_rtp_dtmf_src_finalize);
gobject_class->set_property =
@@ -297,7 +288,7 @@ gst_rtp_dtmf_src_event_free (GstRTPDTMFSrcEvent * event)
}
static void
-gst_rtp_dtmf_src_init (GstRTPDTMFSrc * object, GstRTPDTMFSrcClass * g_class)
+gst_rtp_dtmf_src_init (GstRTPDTMFSrc * object)
{
gst_base_src_set_format (GST_BASE_SRC (object), GST_FORMAT_TIME);
gst_base_src_set_live (GST_BASE_SRC (object), TRUE);
@@ -330,7 +321,7 @@ gst_rtp_dtmf_src_finalize (GObject * object)
}
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (gst_rtp_dtmf_src_parent_class)->finalize (object);
}
static gboolean
@@ -577,30 +568,37 @@ gst_rtp_dtmf_src_add_stop_event (GstRTPDTMFSrc * dtmfsrc)
static void
-gst_rtp_dtmf_prepare_rtp_headers (GstRTPDTMFSrc * dtmfsrc, GstBuffer * buf)
+gst_rtp_dtmf_prepare_rtp_headers (GstRTPDTMFSrc * dtmfsrc,
+ GstRTPBuffer * rtpbuf)
{
- gst_rtp_buffer_set_ssrc (buf, dtmfsrc->current_ssrc);
- gst_rtp_buffer_set_payload_type (buf, dtmfsrc->pt);
+ gst_rtp_buffer_set_ssrc (rtpbuf, dtmfsrc->current_ssrc);
+ gst_rtp_buffer_set_payload_type (rtpbuf, dtmfsrc->pt);
/* Only the very first packet gets a marker */
if (dtmfsrc->first_packet) {
- gst_rtp_buffer_set_marker (buf, TRUE);
+ gst_rtp_buffer_set_marker (rtpbuf, TRUE);
} else if (dtmfsrc->last_packet) {
dtmfsrc->payload->e = 1;
}
dtmfsrc->seqnum++;
- gst_rtp_buffer_set_seq (buf, dtmfsrc->seqnum);
+ gst_rtp_buffer_set_seq (rtpbuf, dtmfsrc->seqnum);
/* timestamp of RTP header */
- gst_rtp_buffer_set_timestamp (buf, dtmfsrc->rtp_timestamp);
+ gst_rtp_buffer_set_timestamp (rtpbuf, dtmfsrc->rtp_timestamp);
}
-static void
-gst_rtp_dtmf_prepare_buffer_data (GstRTPDTMFSrc * dtmfsrc, GstBuffer * buf)
+static GstBuffer *
+gst_rtp_dtmf_src_create_next_rtp_packet (GstRTPDTMFSrc * dtmfsrc)
{
+ GstBuffer *buf;
GstRTPDTMFPayload *payload;
+ GstRTPBuffer rtpbuffer = GST_RTP_BUFFER_INIT;
- gst_rtp_dtmf_prepare_rtp_headers (dtmfsrc, buf);
+ buf = gst_rtp_buffer_new_allocate (sizeof (GstRTPDTMFPayload), 0, 0);
+
+ gst_rtp_buffer_map (buf, GST_MAP_READWRITE, &rtpbuffer);
+
+ gst_rtp_dtmf_prepare_rtp_headers (dtmfsrc, &rtpbuffer);
/* timestamp and duration of GstBuffer */
/* Redundant buffer have no duration ... */
@@ -608,10 +606,9 @@ gst_rtp_dtmf_prepare_buffer_data (GstRTPDTMFSrc * dtmfsrc, GstBuffer * buf)
GST_BUFFER_DURATION (buf) = 0;
else
GST_BUFFER_DURATION (buf) = dtmfsrc->ptime * GST_MSECOND;
- GST_BUFFER_TIMESTAMP (buf) = dtmfsrc->timestamp;
+ GST_BUFFER_PTS (buf) = dtmfsrc->timestamp;
-
- payload = (GstRTPDTMFPayload *) gst_rtp_buffer_get_payload (buf);
+ payload = (GstRTPDTMFPayload *) gst_rtp_buffer_get_payload (&rtpbuffer);
/* copy payload and convert to network-byte order */
g_memmove (payload, dtmfsrc->payload, sizeof (GstRTPDTMFPayload));
@@ -642,20 +639,7 @@ gst_rtp_dtmf_prepare_buffer_data (GstRTPDTMFSrc * dtmfsrc, GstBuffer * buf)
if (GST_CLOCK_TIME_IS_VALID (dtmfsrc->timestamp))
dtmfsrc->timestamp += GST_BUFFER_DURATION (buf);
-}
-
-static GstBuffer *
-gst_rtp_dtmf_src_create_next_rtp_packet (GstRTPDTMFSrc * dtmfsrc)
-{
- GstBuffer *buf = NULL;
-
- /* create buffer to hold the payload */
- buf = gst_rtp_buffer_new_allocate (sizeof (GstRTPDTMFPayload), 0, 0);
-
- gst_rtp_dtmf_prepare_buffer_data (dtmfsrc, buf);
-
- /* Set caps on the buffer before pushing it */
- gst_buffer_set_caps (buf, GST_PAD_CAPS (GST_BASE_SRC_PAD (dtmfsrc)));
+ gst_rtp_buffer_unmap (&rtpbuffer);
return buf;
}
@@ -884,7 +868,7 @@ gst_rtp_dtmf_src_negotiate (GstBaseSrc * basesrc)
"encoding-name", G_TYPE_STRING, "TELEPHONE-EVENT", NULL);
/* the peer caps can override some of the defaults */
- peercaps = gst_pad_peer_get_caps (GST_BASE_SRC_PAD (basesrc));
+ peercaps = gst_pad_peer_query_caps (GST_BASE_SRC_PAD (basesrc), NULL);
if (peercaps == NULL) {
/* no peer caps, just add the other properties */
gst_caps_set_simple (srccaps,
@@ -1068,8 +1052,8 @@ gst_rtp_dtmf_src_change_state (GstElement * element, GstStateChange transition)
}
if ((result =
- GST_ELEMENT_CLASS (parent_class)->change_state (element,
- transition)) == GST_STATE_CHANGE_FAILURE)
+ GST_ELEMENT_CLASS (gst_rtp_dtmf_src_parent_class)->change_state
+ (element, transition)) == GST_STATE_CHANGE_FAILURE)
goto failure;
switch (transition) {