summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog18
-rw-r--r--gst/rtp/gstrtpg711dec.c202
-rw-r--r--gst/rtp/gstrtpg711dec.h8
-rw-r--r--gst/rtp/gstrtpg711depay.c202
-rw-r--r--gst/rtp/gstrtpg711depay.h8
-rw-r--r--gst/rtp/gstrtpg711enc.c44
-rw-r--r--gst/rtp/gstrtpg711pay.c44
-rw-r--r--gst/rtp/gstrtpgsmdepay.c55
-rw-r--r--gst/rtp/gstrtpgsmdepay.h5
-rw-r--r--gst/rtp/gstrtpgsmenc.c61
-rw-r--r--gst/rtp/gstrtpgsmparse.c55
-rw-r--r--gst/rtp/gstrtpgsmparse.h5
-rw-r--r--gst/rtp/gstrtpgsmpay.c61
13 files changed, 160 insertions, 608 deletions
diff --git a/ChangeLog b/ChangeLog
index fd520f88..10af17d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2005-10-26 Zeeshan Ali <zeenix@gmail.com>
+
+ * gst/rtp/gstrtpg711dec.c: (gst_rtpg711dec_base_init),
+ (gst_rtpg711dec_class_init), (gst_rtpg711dec_init),
+ (gst_rtpg711dec_setcaps), (gst_rtpg711dec_process):
+ * gst/rtp/gstrtpg711dec.h:
+ * gst/rtp/gstrtpg711enc.c: (gst_rtpg711enc_base_init),
+ (gst_rtpg711enc_init), (gst_rtpg711enc_handle_buffer):
+ * gst/rtp/gstrtpgsmenc.c: (gst_rtpgsmenc_base_init),
+ (gst_rtpgsmenc_init), (gst_rtpgsmenc_setcaps),
+ (gst_rtpgsmenc_handle_buffer):
+ * gst/rtp/gstrtpgsmparse.c: (gst_rtpgsmparse_base_init),
+ (gst_rtpgsmparse_class_init), (gst_rtpgsmparse_init),
+ (gst_rtpgsmparse_setcaps), (gst_rtpgsmparse_process):
+ * gst/rtp/gstrtpgsmparse.h:
+ Hacked the G711 (de)payloader to try to make things right. rtpg711dec now
+ inherits from the basertpdepayloader.
+
2005-10-26 Julien MOUTTE <julien@moutte.net>
* gst/videobox/gstvideobox.c: (gst_video_box_class_init),
diff --git a/gst/rtp/gstrtpg711dec.c b/gst/rtp/gstrtpg711dec.c
index d1feeba4..4a2e7df8 100644
--- a/gst/rtp/gstrtpg711dec.c
+++ b/gst/rtp/gstrtpg711dec.c
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Edgard Lima <edgard.lima@indt.org.br>
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -25,7 +25,7 @@ static GstElementDetails gst_rtp_g711dec_details = {
"RTP packet parser",
"Codec/Parser/Network",
"Extracts PCMU/PCMA audio from RTP packets",
- "Edgard Lima <edgard.lima@indt.org.br>"
+ "Edgard Lima <edgard.lima@indt.org.br>, Zeeshan Ali <zeenix@gmail.com>"
};
/* RtpG711Dec signals and args */
@@ -64,49 +64,16 @@ static GstStaticPadTemplate gst_rtpg711dec_src_template =
"audio/x-alaw, channels = (int) 1")
);
-static void gst_rtpg711dec_class_init (GstRtpG711DecClass * klass);
-static void gst_rtpg711dec_base_init (GstRtpG711DecClass * klass);
-static void gst_rtpg711dec_init (GstRtpG711Dec * rtpg711dec);
-static gboolean gst_rtpg711dec_sink_setcaps (GstPad * pad, GstCaps * caps);
-static GstFlowReturn gst_rtpg711dec_chain (GstPad * pad, GstBuffer * buffer);
+static GstBuffer *gst_rtpg711dec_process (GstBaseRTPDepayload * depayload,
+ GstBuffer * buf);
+static gboolean gst_rtpg711dec_setcaps (GstBaseRTPDepayload * depayload,
+ GstCaps * caps);
-static void gst_rtpg711dec_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_rtpg711dec_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static GstStateChangeReturn gst_rtpg711dec_change_state (GstElement * element,
- GstStateChange transition);
-
-static GstElementClass *parent_class = NULL;
-
-static GType
-gst_rtpg711dec_get_type (void)
-{
- static GType rtpg711dec_type = 0;
-
- if (!rtpg711dec_type) {
- static const GTypeInfo rtpg711dec_info = {
- sizeof (GstRtpG711DecClass),
- (GBaseInitFunc) gst_rtpg711dec_base_init,
- NULL,
- (GClassInitFunc) gst_rtpg711dec_class_init,
- NULL,
- NULL,
- sizeof (GstRtpG711Dec),
- 0,
- (GInstanceInitFunc) gst_rtpg711dec_init,
- };
-
- rtpg711dec_type =
- g_type_register_static (GST_TYPE_ELEMENT, "GstRtpG711Dec",
- &rtpg711dec_info, 0);
- }
- return rtpg711dec_type;
-}
+GST_BOILERPLATE (GstRtpG711Dec, gst_rtpg711dec, GstBaseRTPDepayload,
+ GST_TYPE_BASE_RTP_DEPAYLOAD);
static void
-gst_rtpg711dec_base_init (GstRtpG711DecClass * klass)
+gst_rtpg711dec_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
@@ -122,47 +89,38 @@ gst_rtpg711dec_class_init (GstRtpG711DecClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
+ GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
+ gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
- parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
-
- gobject_class->set_property = gst_rtpg711dec_set_property;
- gobject_class->get_property = gst_rtpg711dec_get_property;
+ parent_class = g_type_class_ref (GST_TYPE_BASE_RTP_DEPAYLOAD);
- gstelement_class->change_state = gst_rtpg711dec_change_state;
+ gstbasertpdepayload_class->process = gst_rtpg711dec_process;
+ gstbasertpdepayload_class->set_caps = gst_rtpg711dec_setcaps;
}
static void
-gst_rtpg711dec_init (GstRtpG711Dec * rtpg711dec)
+gst_rtpg711dec_init (GstRtpG711Dec * rtpg711dec, GstRtpG711DecClass * klass)
{
- rtpg711dec->srcpad =
- gst_pad_new_from_template (gst_static_pad_template_get
- (&gst_rtpg711dec_src_template), "src");
- rtpg711dec->sinkpad =
- gst_pad_new_from_template (gst_static_pad_template_get
- (&gst_rtpg711dec_sink_template), "sink");
- gst_element_add_pad (GST_ELEMENT (rtpg711dec), rtpg711dec->srcpad);
+ GstBaseRTPDepayload *depayload;
- gst_pad_set_setcaps_function (rtpg711dec->sinkpad,
- gst_rtpg711dec_sink_setcaps);
- gst_element_add_pad (GST_ELEMENT (rtpg711dec), rtpg711dec->sinkpad);
- gst_pad_set_chain_function (rtpg711dec->sinkpad, gst_rtpg711dec_chain);
+ depayload = GST_BASE_RTP_DEPAYLOAD (rtpg711dec);
+
+ depayload->clock_rate = 8000;
+ gst_pad_use_fixed_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload));
}
static gboolean
-gst_rtpg711dec_sink_setcaps (GstPad * pad, GstCaps * caps)
+gst_rtpg711dec_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
{
GstCaps *srccaps;
- GstRtpG711Dec *rtpg711dec;
const gchar *enc_name;
GstStructure *structure;
+ gboolean ret;
structure = gst_caps_get_structure (caps, 0);
-
- enc_name = gst_structure_get_name (structure);
-
enc_name = gst_structure_get_string (structure, "encoding-name");
if (NULL == enc_name) {
@@ -179,116 +137,30 @@ gst_rtpg711dec_sink_setcaps (GstPad * pad, GstCaps * caps)
return FALSE;
}
- rtpg711dec = GST_RTP_G711_DEC (GST_OBJECT_PARENT (pad));
-
- srccaps = gst_caps_new_simple ("audio/x-mulaw",
- "channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL);
- gst_pad_set_caps (rtpg711dec->srcpad, srccaps);
+ ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
gst_caps_unref (srccaps);
- return TRUE;
-}
-
-static GstFlowReturn
-gst_rtpg711dec_chain (GstPad * pad, GstBuffer * buf)
-{
- GstRtpG711Dec *rtpg711dec;
- GstBuffer *outbuf;
- GstFlowReturn ret;
-
- rtpg711dec = GST_RTP_G711_DEC (gst_pad_get_parent (pad));
-
- if (!gst_rtpbuffer_validate (buf))
- goto bad_packet;
-
- {
- gint payload_len;
- guint8 *payload;
-
- payload_len = gst_rtpbuffer_get_payload_len (buf);
- payload = gst_rtpbuffer_get_payload (buf);
-
- outbuf = gst_buffer_new_and_alloc (payload_len);
-
- GST_BUFFER_TIMESTAMP (outbuf) =
- gst_rtpbuffer_get_timestamp (buf) * GST_SECOND / 8000;
-
- memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
-
- GST_DEBUG ("pushing buffer of size %d", GST_BUFFER_SIZE (outbuf));
-
- gst_buffer_set_caps (outbuf, GST_PAD_CAPS (rtpg711dec->srcpad));
- gst_buffer_unref (buf);
-
- ret = gst_pad_push (rtpg711dec->srcpad, outbuf);
- }
-
return ret;
-
-bad_packet:
- {
- GST_DEBUG ("Packet did not validate");
- gst_buffer_unref (buf);
- return GST_FLOW_ERROR;
- }
-}
-
-static void
-gst_rtpg711dec_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstRtpG711Dec *rtpg711dec;
-
- rtpg711dec = GST_RTP_G711_DEC (object);
-
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_rtpg711dec_get_property (GObject * object, guint prop_id, GValue * value,
- GParamSpec * pspec)
-{
- GstRtpG711Dec *rtpg711dec;
-
- rtpg711dec = GST_RTP_G711_DEC (object);
-
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
}
-static GstStateChangeReturn
-gst_rtpg711dec_change_state (GstElement * element, GstStateChange transition)
+static GstBuffer *
+gst_rtpg711dec_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
{
- GstRtpG711Dec *rtpg711dec;
- GstStateChangeReturn ret;
-
- rtpg711dec = GST_RTP_G711_DEC (element);
+ GstBuffer *outbuf = NULL;
+ gint payload_len;
+ guint8 *payload;
- switch (transition) {
- case GST_STATE_CHANGE_NULL_TO_READY:
- break;
- case GST_STATE_CHANGE_READY_TO_PAUSED:
- break;
- default:
- break;
- }
+ GST_DEBUG ("process : got %d bytes, mark %d ts %u seqn %d",
+ GST_BUFFER_SIZE (buf),
+ gst_rtpbuffer_get_marker (buf),
+ gst_rtpbuffer_get_timestamp (buf), gst_rtpbuffer_get_seq (buf));
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+ payload_len = gst_rtpbuffer_get_payload_len (buf);
+ payload = gst_rtpbuffer_get_payload (buf);
- switch (transition) {
- case GST_STATE_CHANGE_READY_TO_NULL:
- break;
- default:
- break;
- }
- return ret;
+ outbuf = gst_buffer_new_and_alloc (payload_len);
+ memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
+ return outbuf;
}
gboolean
diff --git a/gst/rtp/gstrtpg711dec.h b/gst/rtp/gstrtpg711dec.h
index 4be76e38..51dcdbd9 100644
--- a/gst/rtp/gstrtpg711dec.h
+++ b/gst/rtp/gstrtpg711dec.h
@@ -16,6 +16,7 @@
#define __GST_RTP_G711_DEC_H__
#include <gst/gst.h>
+#include <gst/rtp/gstbasertpdepayload.h>
G_BEGIN_DECLS
@@ -35,15 +36,12 @@ typedef struct _GstRtpG711DecClass GstRtpG711DecClass;
struct _GstRtpG711Dec
{
- GstElement element;
-
- GstPad *sinkpad;
- GstPad *srcpad;
+ GstBaseRTPDepayload depayload;
};
struct _GstRtpG711DecClass
{
- GstElementClass parent_class;
+ GstBaseRTPDepayloadClass parent_class;
};
gboolean gst_rtpg711dec_plugin_init (GstPlugin * plugin);
diff --git a/gst/rtp/gstrtpg711depay.c b/gst/rtp/gstrtpg711depay.c
index d1feeba4..4a2e7df8 100644
--- a/gst/rtp/gstrtpg711depay.c
+++ b/gst/rtp/gstrtpg711depay.c
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Edgard Lima <edgard.lima@indt.org.br>
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -25,7 +25,7 @@ static GstElementDetails gst_rtp_g711dec_details = {
"RTP packet parser",
"Codec/Parser/Network",
"Extracts PCMU/PCMA audio from RTP packets",
- "Edgard Lima <edgard.lima@indt.org.br>"
+ "Edgard Lima <edgard.lima@indt.org.br>, Zeeshan Ali <zeenix@gmail.com>"
};
/* RtpG711Dec signals and args */
@@ -64,49 +64,16 @@ static GstStaticPadTemplate gst_rtpg711dec_src_template =
"audio/x-alaw, channels = (int) 1")
);
-static void gst_rtpg711dec_class_init (GstRtpG711DecClass * klass);
-static void gst_rtpg711dec_base_init (GstRtpG711DecClass * klass);
-static void gst_rtpg711dec_init (GstRtpG711Dec * rtpg711dec);
-static gboolean gst_rtpg711dec_sink_setcaps (GstPad * pad, GstCaps * caps);
-static GstFlowReturn gst_rtpg711dec_chain (GstPad * pad, GstBuffer * buffer);
+static GstBuffer *gst_rtpg711dec_process (GstBaseRTPDepayload * depayload,
+ GstBuffer * buf);
+static gboolean gst_rtpg711dec_setcaps (GstBaseRTPDepayload * depayload,
+ GstCaps * caps);
-static void gst_rtpg711dec_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_rtpg711dec_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-static GstStateChangeReturn gst_rtpg711dec_change_state (GstElement * element,
- GstStateChange transition);
-
-static GstElementClass *parent_class = NULL;
-
-static GType
-gst_rtpg711dec_get_type (void)
-{
- static GType rtpg711dec_type = 0;
-
- if (!rtpg711dec_type) {
- static const GTypeInfo rtpg711dec_info = {
- sizeof (GstRtpG711DecClass),
- (GBaseInitFunc) gst_rtpg711dec_base_init,
- NULL,
- (GClassInitFunc) gst_rtpg711dec_class_init,
- NULL,
- NULL,
- sizeof (GstRtpG711Dec),
- 0,
- (GInstanceInitFunc) gst_rtpg711dec_init,
- };
-
- rtpg711dec_type =
- g_type_register_static (GST_TYPE_ELEMENT, "GstRtpG711Dec",
- &rtpg711dec_info, 0);
- }
- return rtpg711dec_type;
-}
+GST_BOILERPLATE (GstRtpG711Dec, gst_rtpg711dec, GstBaseRTPDepayload,
+ GST_TYPE_BASE_RTP_DEPAYLOAD);
static void
-gst_rtpg711dec_base_init (GstRtpG711DecClass * klass)
+gst_rtpg711dec_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
@@ -122,47 +89,38 @@ gst_rtpg711dec_class_init (GstRtpG711DecClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
+ GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
+ gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
- parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
-
- gobject_class->set_property = gst_rtpg711dec_set_property;
- gobject_class->get_property = gst_rtpg711dec_get_property;
+ parent_class = g_type_class_ref (GST_TYPE_BASE_RTP_DEPAYLOAD);
- gstelement_class->change_state = gst_rtpg711dec_change_state;
+ gstbasertpdepayload_class->process = gst_rtpg711dec_process;
+ gstbasertpdepayload_class->set_caps = gst_rtpg711dec_setcaps;
}
static void
-gst_rtpg711dec_init (GstRtpG711Dec * rtpg711dec)
+gst_rtpg711dec_init (GstRtpG711Dec * rtpg711dec, GstRtpG711DecClass * klass)
{
- rtpg711dec->srcpad =
- gst_pad_new_from_template (gst_static_pad_template_get
- (&gst_rtpg711dec_src_template), "src");
- rtpg711dec->sinkpad =
- gst_pad_new_from_template (gst_static_pad_template_get
- (&gst_rtpg711dec_sink_template), "sink");
- gst_element_add_pad (GST_ELEMENT (rtpg711dec), rtpg711dec->srcpad);
+ GstBaseRTPDepayload *depayload;
- gst_pad_set_setcaps_function (rtpg711dec->sinkpad,
- gst_rtpg711dec_sink_setcaps);
- gst_element_add_pad (GST_ELEMENT (rtpg711dec), rtpg711dec->sinkpad);
- gst_pad_set_chain_function (rtpg711dec->sinkpad, gst_rtpg711dec_chain);
+ depayload = GST_BASE_RTP_DEPAYLOAD (rtpg711dec);
+
+ depayload->clock_rate = 8000;
+ gst_pad_use_fixed_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload));
}
static gboolean
-gst_rtpg711dec_sink_setcaps (GstPad * pad, GstCaps * caps)
+gst_rtpg711dec_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
{
GstCaps *srccaps;
- GstRtpG711Dec *rtpg711dec;
const gchar *enc_name;
GstStructure *structure;
+ gboolean ret;
structure = gst_caps_get_structure (caps, 0);
-
- enc_name = gst_structure_get_name (structure);
-
enc_name = gst_structure_get_string (structure, "encoding-name");
if (NULL == enc_name) {
@@ -179,116 +137,30 @@ gst_rtpg711dec_sink_setcaps (GstPad * pad, GstCaps * caps)
return FALSE;
}
- rtpg711dec = GST_RTP_G711_DEC (GST_OBJECT_PARENT (pad));
-
- srccaps = gst_caps_new_simple ("audio/x-mulaw",
- "channels", G_TYPE_INT, 1, "rate", G_TYPE_INT, 8000, NULL);
- gst_pad_set_caps (rtpg711dec->srcpad, srccaps);
+ ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
gst_caps_unref (srccaps);
- return TRUE;
-}
-
-static GstFlowReturn
-gst_rtpg711dec_chain (GstPad * pad, GstBuffer * buf)
-{
- GstRtpG711Dec *rtpg711dec;
- GstBuffer *outbuf;
- GstFlowReturn ret;
-
- rtpg711dec = GST_RTP_G711_DEC (gst_pad_get_parent (pad));
-
- if (!gst_rtpbuffer_validate (buf))
- goto bad_packet;
-
- {
- gint payload_len;
- guint8 *payload;
-
- payload_len = gst_rtpbuffer_get_payload_len (buf);
- payload = gst_rtpbuffer_get_payload (buf);
-
- outbuf = gst_buffer_new_and_alloc (payload_len);
-
- GST_BUFFER_TIMESTAMP (outbuf) =
- gst_rtpbuffer_get_timestamp (buf) * GST_SECOND / 8000;
-
- memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
-
- GST_DEBUG ("pushing buffer of size %d", GST_BUFFER_SIZE (outbuf));
-
- gst_buffer_set_caps (outbuf, GST_PAD_CAPS (rtpg711dec->srcpad));
- gst_buffer_unref (buf);
-
- ret = gst_pad_push (rtpg711dec->srcpad, outbuf);
- }
-
return ret;
-
-bad_packet:
- {
- GST_DEBUG ("Packet did not validate");
- gst_buffer_unref (buf);
- return GST_FLOW_ERROR;
- }
-}
-
-static void
-gst_rtpg711dec_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstRtpG711Dec *rtpg711dec;
-
- rtpg711dec = GST_RTP_G711_DEC (object);
-
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_rtpg711dec_get_property (GObject * object, guint prop_id, GValue * value,
- GParamSpec * pspec)
-{
- GstRtpG711Dec *rtpg711dec;
-
- rtpg711dec = GST_RTP_G711_DEC (object);
-
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
}
-static GstStateChangeReturn
-gst_rtpg711dec_change_state (GstElement * element, GstStateChange transition)
+static GstBuffer *
+gst_rtpg711dec_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
{
- GstRtpG711Dec *rtpg711dec;
- GstStateChangeReturn ret;
-
- rtpg711dec = GST_RTP_G711_DEC (element);
+ GstBuffer *outbuf = NULL;
+ gint payload_len;
+ guint8 *payload;
- switch (transition) {
- case GST_STATE_CHANGE_NULL_TO_READY:
- break;
- case GST_STATE_CHANGE_READY_TO_PAUSED:
- break;
- default:
- break;
- }
+ GST_DEBUG ("process : got %d bytes, mark %d ts %u seqn %d",
+ GST_BUFFER_SIZE (buf),
+ gst_rtpbuffer_get_marker (buf),
+ gst_rtpbuffer_get_timestamp (buf), gst_rtpbuffer_get_seq (buf));
- ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+ payload_len = gst_rtpbuffer_get_payload_len (buf);
+ payload = gst_rtpbuffer_get_payload (buf);
- switch (transition) {
- case GST_STATE_CHANGE_READY_TO_NULL:
- break;
- default:
- break;
- }
- return ret;
+ outbuf = gst_buffer_new_and_alloc (payload_len);
+ memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
+ return outbuf;
}
gboolean
diff --git a/gst/rtp/gstrtpg711depay.h b/gst/rtp/gstrtpg711depay.h
index 4be76e38..51dcdbd9 100644
--- a/gst/rtp/gstrtpg711depay.h
+++ b/gst/rtp/gstrtpg711depay.h
@@ -16,6 +16,7 @@
#define __GST_RTP_G711_DEC_H__
#include <gst/gst.h>
+#include <gst/rtp/gstbasertpdepayload.h>
G_BEGIN_DECLS
@@ -35,15 +36,12 @@ typedef struct _GstRtpG711DecClass GstRtpG711DecClass;
struct _GstRtpG711Dec
{
- GstElement element;
-
- GstPad *sinkpad;
- GstPad *srcpad;
+ GstBaseRTPDepayload depayload;
};
struct _GstRtpG711DecClass
{
- GstElementClass parent_class;
+ GstBaseRTPDepayloadClass parent_class;
};
gboolean gst_rtpg711dec_plugin_init (GstPlugin * plugin);
diff --git a/gst/rtp/gstrtpg711enc.c b/gst/rtp/gstrtpg711enc.c
index 2067ffd6..55fdf1d8 100644
--- a/gst/rtp/gstrtpg711enc.c
+++ b/gst/rtp/gstrtpg711enc.c
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Edgard Lima <edgard.lima@indt.org.br>
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -53,45 +53,16 @@ static GstStaticPadTemplate gst_rtpg711enc_src_template =
"clock-rate = (int) 8000, " "encoding-name = (string) \"PCMA\"")
);
-
-static void gst_rtpg711enc_class_init (GstRtpG711EncClass * klass);
-static void gst_rtpg711enc_base_init (GstRtpG711EncClass * klass);
-static void gst_rtpg711enc_init (GstRtpG711Enc * rtpg711enc);
-
static gboolean gst_rtpg711enc_setcaps (GstBaseRTPPayload * payload,
GstCaps * caps);
static GstFlowReturn gst_rtpg711enc_handle_buffer (GstBaseRTPPayload * payload,
GstBuffer * buffer);
-static GstBaseRTPPayloadClass *parent_class = NULL;
-
-static GType
-gst_rtpg711enc_get_type (void)
-{
- static GType rtpg711enc_type = 0;
-
- if (!rtpg711enc_type) {
- static const GTypeInfo rtpg711enc_info = {
- sizeof (GstRtpG711EncClass),
- (GBaseInitFunc) gst_rtpg711enc_base_init,
- NULL,
- (GClassInitFunc) gst_rtpg711enc_class_init,
- NULL,
- NULL,
- sizeof (GstRtpG711Enc),
- 0,
- (GInstanceInitFunc) gst_rtpg711enc_init,
- };
-
- rtpg711enc_type =
- g_type_register_static (GST_TYPE_BASE_RTP_PAYLOAD, "GstRtpG711Enc",
- &rtpg711enc_info, 0);
- }
- return rtpg711enc_type;
-}
+GST_BOILERPLATE (GstRtpG711Enc, gst_rtpg711enc, GstBaseRTPPayload,
+ GST_TYPE_BASE_RTP_PAYLOAD);
static void
-gst_rtpg711enc_base_init (GstRtpG711EncClass * klass)
+gst_rtpg711enc_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
@@ -120,8 +91,9 @@ gst_rtpg711enc_class_init (GstRtpG711EncClass * klass)
}
static void
-gst_rtpg711enc_init (GstRtpG711Enc * rtpg711enc)
+gst_rtpg711enc_init (GstRtpG711Enc * rtpg711enc, GstRtpG711EncClass * klass)
{
+ GST_BASE_RTP_PAYLOAD (rtpg711enc)->clock_rate = 8000;
}
static gboolean
@@ -169,9 +141,7 @@ gst_rtpg711enc_handle_buffer (GstBaseRTPPayload * basepayload,
outbuf = gst_rtpbuffer_new_allocate (payload_len, 0, 0);
/* FIXME, assert for now */
- g_assert (GST_BUFFER_SIZE (outbuf) < GST_BASE_RTP_PAYLOAD_MTU (rtpg711enc));
-
- gst_rtpbuffer_set_timestamp (outbuf, timestamp * 8000 / GST_SECOND);
+ g_assert (payload_len <= GST_BASE_RTP_PAYLOAD_MTU (rtpg711enc));
/* copy timestamp */
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
diff --git a/gst/rtp/gstrtpg711pay.c b/gst/rtp/gstrtpg711pay.c
index 2067ffd6..55fdf1d8 100644
--- a/gst/rtp/gstrtpg711pay.c
+++ b/gst/rtp/gstrtpg711pay.c
@@ -1,5 +1,5 @@
/* GStreamer
- * Copyright (C) <2005> Edgard Lima <edgard.lima@indt.org.br>
+ * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -53,45 +53,16 @@ static GstStaticPadTemplate gst_rtpg711enc_src_template =
"clock-rate = (int) 8000, " "encoding-name = (string) \"PCMA\"")
);
-
-static void gst_rtpg711enc_class_init (GstRtpG711EncClass * klass);
-static void gst_rtpg711enc_base_init (GstRtpG711EncClass * klass);
-static void gst_rtpg711enc_init (GstRtpG711Enc * rtpg711enc);
-
static gboolean gst_rtpg711enc_setcaps (GstBaseRTPPayload * payload,
GstCaps * caps);
static GstFlowReturn gst_rtpg711enc_handle_buffer (GstBaseRTPPayload * payload,
GstBuffer * buffer);
-static GstBaseRTPPayloadClass *parent_class = NULL;
-
-static GType
-gst_rtpg711enc_get_type (void)
-{
- static GType rtpg711enc_type = 0;
-
- if (!rtpg711enc_type) {
- static const GTypeInfo rtpg711enc_info = {
- sizeof (GstRtpG711EncClass),
- (GBaseInitFunc) gst_rtpg711enc_base_init,
- NULL,
- (GClassInitFunc) gst_rtpg711enc_class_init,
- NULL,
- NULL,
- sizeof (GstRtpG711Enc),
- 0,
- (GInstanceInitFunc) gst_rtpg711enc_init,
- };
-
- rtpg711enc_type =
- g_type_register_static (GST_TYPE_BASE_RTP_PAYLOAD, "GstRtpG711Enc",
- &rtpg711enc_info, 0);
- }
- return rtpg711enc_type;
-}
+GST_BOILERPLATE (GstRtpG711Enc, gst_rtpg711enc, GstBaseRTPPayload,
+ GST_TYPE_BASE_RTP_PAYLOAD);
static void
-gst_rtpg711enc_base_init (GstRtpG711EncClass * klass)
+gst_rtpg711enc_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
@@ -120,8 +91,9 @@ gst_rtpg711enc_class_init (GstRtpG711EncClass * klass)
}
static void
-gst_rtpg711enc_init (GstRtpG711Enc * rtpg711enc)
+gst_rtpg711enc_init (GstRtpG711Enc * rtpg711enc, GstRtpG711EncClass * klass)
{
+ GST_BASE_RTP_PAYLOAD (rtpg711enc)->clock_rate = 8000;
}
static gboolean
@@ -169,9 +141,7 @@ gst_rtpg711enc_handle_buffer (GstBaseRTPPayload * basepayload,
outbuf = gst_rtpbuffer_new_allocate (payload_len, 0, 0);
/* FIXME, assert for now */
- g_assert (GST_BUFFER_SIZE (outbuf) < GST_BASE_RTP_PAYLOAD_MTU (rtpg711enc));
-
- gst_rtpbuffer_set_timestamp (outbuf, timestamp * 8000 / GST_SECOND);
+ g_assert (payload_len <= GST_BASE_RTP_PAYLOAD_MTU (rtpg711enc));
/* copy timestamp */
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
diff --git a/gst/rtp/gstrtpgsmdepay.c b/gst/rtp/gstrtpgsmdepay.c
index 9ec4441a..d80217dc 100644
--- a/gst/rtp/gstrtpgsmdepay.c
+++ b/gst/rtp/gstrtpgsmdepay.c
@@ -25,7 +25,7 @@ static GstElementDetails gst_rtp_gsmparse_details = {
"RTP packet parser",
"Codec/Parser/Network",
"Extracts GSM audio from RTP packets",
- "Zeeshan Ali <zak147@yahoo.com>"
+ "Zeeshan Ali <zeenix@gmail.com>"
};
/* RTPGSMParse signals and args */
@@ -52,43 +52,16 @@ GST_STATIC_PAD_TEMPLATE ("sink",
"clock-rate = (int) 8000, " "encoding-name = (string) \"GSM\"")
);
-static void gst_rtpgsmparse_class_init (GstRTPGSMParseClass * klass);
-static void gst_rtpgsmparse_base_init (GstRTPGSMParseClass * klass);
-static void gst_rtpgsmparse_init (GstRTPGSMParse * rtpgsmparse);
static GstBuffer *gst_rtpgsmparse_process (GstBaseRTPDepayload * depayload,
GstBuffer * buf);
-static gboolean gst_rtpgsmparse_setcaps (GstBaseRTPDepayload * payload,
+static gboolean gst_rtpgsmparse_setcaps (GstBaseRTPDepayload * depayload,
GstCaps * caps);
-static void gst_rtpgsmparse_finalize (GObject * object);
-static GstElementClass *parent_class = NULL;
-static GType
-gst_rtpgsmparse_get_type (void)
-{
- static GType rtpgsmparse_type = 0;
-
- if (!rtpgsmparse_type) {
- static const GTypeInfo rtpgsmparse_info = {
- sizeof (GstRTPGSMParseClass),
- (GBaseInitFunc) gst_rtpgsmparse_base_init,
- NULL,
- (GClassInitFunc) gst_rtpgsmparse_class_init,
- NULL,
- NULL,
- sizeof (GstRTPGSMParse),
- 0,
- (GInstanceInitFunc) gst_rtpgsmparse_init,
- };
-
- rtpgsmparse_type =
- g_type_register_static (GST_TYPE_BASE_RTP_DEPAYLOAD, "GstRTPGSMParse",
- &rtpgsmparse_info, 0);
- }
- return rtpgsmparse_type;
-}
+GST_BOILERPLATE (GstRTPGSMParse, gst_rtpgsmparse, GstBaseRTPDepayload,
+ GST_TYPE_BASE_RTP_DEPAYLOAD);
static void
-gst_rtpgsmparse_base_init (GstRTPGSMParseClass * klass)
+gst_rtpgsmparse_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
@@ -114,12 +87,10 @@ gst_rtpgsmparse_class_init (GstRTPGSMParseClass * klass)
gstbasertpdepayload_class->process = gst_rtpgsmparse_process;
gstbasertpdepayload_class->set_caps = gst_rtpgsmparse_setcaps;
-
- gobject_class->finalize = gst_rtpgsmparse_finalize;
}
static void
-gst_rtpgsmparse_init (GstRTPGSMParse * rtpgsmparse)
+gst_rtpgsmparse_init (GstRTPGSMParse * rtpgsmparse, GstRTPGSMParseClass * klass)
{
GST_BASE_RTP_DEPAYLOAD (rtpgsmparse)->clock_rate = 8000;
}
@@ -127,20 +98,14 @@ gst_rtpgsmparse_init (GstRTPGSMParse * rtpgsmparse)
static gboolean
gst_rtpgsmparse_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
{
- GstRTPGSMParse *rtpgsmparse;
GstCaps *srccaps;
-
- rtpgsmparse = GST_RTP_GSM_PARSE (depayload);
+ gboolean ret;
srccaps = gst_static_pad_template_get_caps (&gst_rtpgsmparse_src_template);
- return gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
-}
+ ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
-static void
-gst_rtpgsmparse_finalize (GObject * object)
-{
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ gst_caps_unref (srccaps);
+ return ret;
}
static GstBuffer *
diff --git a/gst/rtp/gstrtpgsmdepay.h b/gst/rtp/gstrtpgsmdepay.h
index 5cb5162d..e5882097 100644
--- a/gst/rtp/gstrtpgsmdepay.h
+++ b/gst/rtp/gstrtpgsmdepay.h
@@ -42,11 +42,6 @@ typedef struct _GstRTPGSMParseClass GstRTPGSMParseClass;
struct _GstRTPGSMParse
{
GstBaseRTPDepayload depayload;
-
- GstPad *sinkpad;
- GstPad *srcpad;
-
- guint frequency;
};
struct _GstRTPGSMParseClass
diff --git a/gst/rtp/gstrtpgsmenc.c b/gst/rtp/gstrtpgsmenc.c
index 692f3883..e0b08785 100644
--- a/gst/rtp/gstrtpgsmenc.c
+++ b/gst/rtp/gstrtpgsmenc.c
@@ -32,7 +32,7 @@ static GstElementDetails gst_rtpgsmenc_details = {
"RTP GSM Audio Encoder",
"Codec/Encoder/Network",
"Encodes GSM audio into a RTP packet",
- "Zeeshan Ali <zak147@yahoo.com>"
+ "Zeeshan Ali <zeenix@gmail.com>"
};
static GstStaticPadTemplate gst_rtpgsmenc_sink_template =
@@ -52,45 +52,16 @@ GST_STATIC_PAD_TEMPLATE ("src",
"clock-rate = (int) 8000, " "encoding-name = (string) \"GSM\"")
);
-
-static void gst_rtpgsmenc_class_init (GstRTPGSMEncClass * klass);
-static void gst_rtpgsmenc_base_init (GstRTPGSMEncClass * klass);
-static void gst_rtpgsmenc_init (GstRTPGSMEnc * rtpgsmenc);
-
static gboolean gst_rtpgsmenc_setcaps (GstBaseRTPPayload * payload,
GstCaps * caps);
static GstFlowReturn gst_rtpgsmenc_handle_buffer (GstBaseRTPPayload * payload,
GstBuffer * buffer);
-static GstBaseRTPPayloadClass *parent_class = NULL;
-
-static GType
-gst_rtpgsmenc_get_type (void)
-{
- static GType rtpgsmenc_type = 0;
-
- if (!rtpgsmenc_type) {
- static const GTypeInfo rtpgsmenc_info = {
- sizeof (GstRTPGSMEncClass),
- (GBaseInitFunc) gst_rtpgsmenc_base_init,
- NULL,
- (GClassInitFunc) gst_rtpgsmenc_class_init,
- NULL,
- NULL,
- sizeof (GstRTPGSMEnc),
- 0,
- (GInstanceInitFunc) gst_rtpgsmenc_init,
- };
-
- rtpgsmenc_type =
- g_type_register_static (GST_TYPE_BASE_RTP_PAYLOAD, "GstRTPGSMEnc",
- &rtpgsmenc_info, 0);
- }
- return rtpgsmenc_type;
-}
+GST_BOILERPLATE (GstRTPGSMEnc, gst_rtpgsmenc, GstBaseRTPPayload,
+ GST_TYPE_BASE_RTP_PAYLOAD);
static void
-gst_rtpgsmenc_base_init (GstRTPGSMEncClass * klass)
+gst_rtpgsmenc_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
@@ -119,7 +90,7 @@ gst_rtpgsmenc_class_init (GstRTPGSMEncClass * klass)
}
static void
-gst_rtpgsmenc_init (GstRTPGSMEnc * rtpgsmenc)
+gst_rtpgsmenc_init (GstRTPGSMEnc * rtpgsmenc, GstRTPGSMEncClass * klass)
{
GST_BASE_RTP_PAYLOAD (rtpgsmenc)->clock_rate = 8000;
GST_BASE_RTP_PAYLOAD_PT (rtpgsmenc) = GST_RTP_PAYLOAD_GSM;
@@ -128,24 +99,20 @@ gst_rtpgsmenc_init (GstRTPGSMEnc * rtpgsmenc)
static gboolean
gst_rtpgsmenc_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
{
- GstRTPGSMEnc *rtpgsmenc;
+ const char *stname;
GstStructure *structure;
- gboolean ret;
- GstCaps *srccaps;
-
- rtpgsmenc = GST_RTP_GSM_ENC (payload);
structure = gst_caps_get_structure (caps, 0);
- ret =
- gst_structure_get_int (structure, "rate",
- (gint *) & (GST_BASE_RTP_PAYLOAD (rtpgsmenc)->clock_rate));
- if (!ret)
+ stname = gst_structure_get_name (structure);
+
+ if (0 == strcmp ("audio/x-gsm", stname)) {
+ gst_basertppayload_set_options (payload, "audio", FALSE, "GSM", 8000);
+ } else {
return FALSE;
+ }
- srccaps = gst_caps_new_simple ("application/x-rtp", NULL);
- gst_pad_set_caps (GST_BASE_RTP_PAYLOAD_SRCPAD (rtpgsmenc), srccaps);
- gst_caps_unref (srccaps);
+ gst_basertppayload_set_outcaps (payload, NULL);
return TRUE;
}
@@ -171,7 +138,7 @@ gst_rtpgsmenc_handle_buffer (GstBaseRTPPayload * basepayload,
outbuf = gst_rtpbuffer_new_allocate (payload_len, 0, 0);
/* FIXME, assert for now */
- g_assert (GST_BUFFER_SIZE (outbuf) < GST_BASE_RTP_PAYLOAD_MTU (rtpgsmenc));
+ g_assert (payload_len <= GST_BASE_RTP_PAYLOAD_MTU (rtpgsmenc));
/* copy timestamp */
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
diff --git a/gst/rtp/gstrtpgsmparse.c b/gst/rtp/gstrtpgsmparse.c
index 9ec4441a..d80217dc 100644
--- a/gst/rtp/gstrtpgsmparse.c
+++ b/gst/rtp/gstrtpgsmparse.c
@@ -25,7 +25,7 @@ static GstElementDetails gst_rtp_gsmparse_details = {
"RTP packet parser",
"Codec/Parser/Network",
"Extracts GSM audio from RTP packets",
- "Zeeshan Ali <zak147@yahoo.com>"
+ "Zeeshan Ali <zeenix@gmail.com>"
};
/* RTPGSMParse signals and args */
@@ -52,43 +52,16 @@ GST_STATIC_PAD_TEMPLATE ("sink",
"clock-rate = (int) 8000, " "encoding-name = (string) \"GSM\"")
);
-static void gst_rtpgsmparse_class_init (GstRTPGSMParseClass * klass);
-static void gst_rtpgsmparse_base_init (GstRTPGSMParseClass * klass);
-static void gst_rtpgsmparse_init (GstRTPGSMParse * rtpgsmparse);
static GstBuffer *gst_rtpgsmparse_process (GstBaseRTPDepayload * depayload,
GstBuffer * buf);
-static gboolean gst_rtpgsmparse_setcaps (GstBaseRTPDepayload * payload,
+static gboolean gst_rtpgsmparse_setcaps (GstBaseRTPDepayload * depayload,
GstCaps * caps);
-static void gst_rtpgsmparse_finalize (GObject * object);
-static GstElementClass *parent_class = NULL;
-static GType
-gst_rtpgsmparse_get_type (void)
-{
- static GType rtpgsmparse_type = 0;
-
- if (!rtpgsmparse_type) {
- static const GTypeInfo rtpgsmparse_info = {
- sizeof (GstRTPGSMParseClass),
- (GBaseInitFunc) gst_rtpgsmparse_base_init,
- NULL,
- (GClassInitFunc) gst_rtpgsmparse_class_init,
- NULL,
- NULL,
- sizeof (GstRTPGSMParse),
- 0,
- (GInstanceInitFunc) gst_rtpgsmparse_init,
- };
-
- rtpgsmparse_type =
- g_type_register_static (GST_TYPE_BASE_RTP_DEPAYLOAD, "GstRTPGSMParse",
- &rtpgsmparse_info, 0);
- }
- return rtpgsmparse_type;
-}
+GST_BOILERPLATE (GstRTPGSMParse, gst_rtpgsmparse, GstBaseRTPDepayload,
+ GST_TYPE_BASE_RTP_DEPAYLOAD);
static void
-gst_rtpgsmparse_base_init (GstRTPGSMParseClass * klass)
+gst_rtpgsmparse_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
@@ -114,12 +87,10 @@ gst_rtpgsmparse_class_init (GstRTPGSMParseClass * klass)
gstbasertpdepayload_class->process = gst_rtpgsmparse_process;
gstbasertpdepayload_class->set_caps = gst_rtpgsmparse_setcaps;
-
- gobject_class->finalize = gst_rtpgsmparse_finalize;
}
static void
-gst_rtpgsmparse_init (GstRTPGSMParse * rtpgsmparse)
+gst_rtpgsmparse_init (GstRTPGSMParse * rtpgsmparse, GstRTPGSMParseClass * klass)
{
GST_BASE_RTP_DEPAYLOAD (rtpgsmparse)->clock_rate = 8000;
}
@@ -127,20 +98,14 @@ gst_rtpgsmparse_init (GstRTPGSMParse * rtpgsmparse)
static gboolean
gst_rtpgsmparse_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
{
- GstRTPGSMParse *rtpgsmparse;
GstCaps *srccaps;
-
- rtpgsmparse = GST_RTP_GSM_PARSE (depayload);
+ gboolean ret;
srccaps = gst_static_pad_template_get_caps (&gst_rtpgsmparse_src_template);
- return gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
-}
+ ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
-static void
-gst_rtpgsmparse_finalize (GObject * object)
-{
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ gst_caps_unref (srccaps);
+ return ret;
}
static GstBuffer *
diff --git a/gst/rtp/gstrtpgsmparse.h b/gst/rtp/gstrtpgsmparse.h
index 5cb5162d..e5882097 100644
--- a/gst/rtp/gstrtpgsmparse.h
+++ b/gst/rtp/gstrtpgsmparse.h
@@ -42,11 +42,6 @@ typedef struct _GstRTPGSMParseClass GstRTPGSMParseClass;
struct _GstRTPGSMParse
{
GstBaseRTPDepayload depayload;
-
- GstPad *sinkpad;
- GstPad *srcpad;
-
- guint frequency;
};
struct _GstRTPGSMParseClass
diff --git a/gst/rtp/gstrtpgsmpay.c b/gst/rtp/gstrtpgsmpay.c
index 692f3883..e0b08785 100644
--- a/gst/rtp/gstrtpgsmpay.c
+++ b/gst/rtp/gstrtpgsmpay.c
@@ -32,7 +32,7 @@ static GstElementDetails gst_rtpgsmenc_details = {
"RTP GSM Audio Encoder",
"Codec/Encoder/Network",
"Encodes GSM audio into a RTP packet",
- "Zeeshan Ali <zak147@yahoo.com>"
+ "Zeeshan Ali <zeenix@gmail.com>"
};
static GstStaticPadTemplate gst_rtpgsmenc_sink_template =
@@ -52,45 +52,16 @@ GST_STATIC_PAD_TEMPLATE ("src",
"clock-rate = (int) 8000, " "encoding-name = (string) \"GSM\"")
);
-
-static void gst_rtpgsmenc_class_init (GstRTPGSMEncClass * klass);
-static void gst_rtpgsmenc_base_init (GstRTPGSMEncClass * klass);
-static void gst_rtpgsmenc_init (GstRTPGSMEnc * rtpgsmenc);
-
static gboolean gst_rtpgsmenc_setcaps (GstBaseRTPPayload * payload,
GstCaps * caps);
static GstFlowReturn gst_rtpgsmenc_handle_buffer (GstBaseRTPPayload * payload,
GstBuffer * buffer);
-static GstBaseRTPPayloadClass *parent_class = NULL;
-
-static GType
-gst_rtpgsmenc_get_type (void)
-{
- static GType rtpgsmenc_type = 0;
-
- if (!rtpgsmenc_type) {
- static const GTypeInfo rtpgsmenc_info = {
- sizeof (GstRTPGSMEncClass),
- (GBaseInitFunc) gst_rtpgsmenc_base_init,
- NULL,
- (GClassInitFunc) gst_rtpgsmenc_class_init,
- NULL,
- NULL,
- sizeof (GstRTPGSMEnc),
- 0,
- (GInstanceInitFunc) gst_rtpgsmenc_init,
- };
-
- rtpgsmenc_type =
- g_type_register_static (GST_TYPE_BASE_RTP_PAYLOAD, "GstRTPGSMEnc",
- &rtpgsmenc_info, 0);
- }
- return rtpgsmenc_type;
-}
+GST_BOILERPLATE (GstRTPGSMEnc, gst_rtpgsmenc, GstBaseRTPPayload,
+ GST_TYPE_BASE_RTP_PAYLOAD);
static void
-gst_rtpgsmenc_base_init (GstRTPGSMEncClass * klass)
+gst_rtpgsmenc_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
@@ -119,7 +90,7 @@ gst_rtpgsmenc_class_init (GstRTPGSMEncClass * klass)
}
static void
-gst_rtpgsmenc_init (GstRTPGSMEnc * rtpgsmenc)
+gst_rtpgsmenc_init (GstRTPGSMEnc * rtpgsmenc, GstRTPGSMEncClass * klass)
{
GST_BASE_RTP_PAYLOAD (rtpgsmenc)->clock_rate = 8000;
GST_BASE_RTP_PAYLOAD_PT (rtpgsmenc) = GST_RTP_PAYLOAD_GSM;
@@ -128,24 +99,20 @@ gst_rtpgsmenc_init (GstRTPGSMEnc * rtpgsmenc)
static gboolean
gst_rtpgsmenc_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
{
- GstRTPGSMEnc *rtpgsmenc;
+ const char *stname;
GstStructure *structure;
- gboolean ret;
- GstCaps *srccaps;
-
- rtpgsmenc = GST_RTP_GSM_ENC (payload);
structure = gst_caps_get_structure (caps, 0);
- ret =
- gst_structure_get_int (structure, "rate",
- (gint *) & (GST_BASE_RTP_PAYLOAD (rtpgsmenc)->clock_rate));
- if (!ret)
+ stname = gst_structure_get_name (structure);
+
+ if (0 == strcmp ("audio/x-gsm", stname)) {
+ gst_basertppayload_set_options (payload, "audio", FALSE, "GSM", 8000);
+ } else {
return FALSE;
+ }
- srccaps = gst_caps_new_simple ("application/x-rtp", NULL);
- gst_pad_set_caps (GST_BASE_RTP_PAYLOAD_SRCPAD (rtpgsmenc), srccaps);
- gst_caps_unref (srccaps);
+ gst_basertppayload_set_outcaps (payload, NULL);
return TRUE;
}
@@ -171,7 +138,7 @@ gst_rtpgsmenc_handle_buffer (GstBaseRTPPayload * basepayload,
outbuf = gst_rtpbuffer_new_allocate (payload_len, 0, 0);
/* FIXME, assert for now */
- g_assert (GST_BUFFER_SIZE (outbuf) < GST_BASE_RTP_PAYLOAD_MTU (rtpgsmenc));
+ g_assert (payload_len <= GST_BASE_RTP_PAYLOAD_MTU (rtpgsmenc));
/* copy timestamp */
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;