Hacked the G711 (de)payloader to try to make things right. rtpg711dec now inherits from the basertpdepayloader.

Original commit message from CVS:
Hacked the G711 (de)payloader to try to make things right. rtpg711dec now inherits from the basertpdepayloader.
This commit is contained in:
Zeeshan Ali 2005-10-26 14:50:59 +00:00
parent fbc72574b2
commit f2b394e1d9
13 changed files with 162 additions and 610 deletions

View File

@ -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> 2005-10-26 Julien MOUTTE <julien@moutte.net>
* gst/videobox/gstvideobox.c: (gst_video_box_class_init), * gst/videobox/gstvideobox.c: (gst_video_box_class_init),

View File

@ -1,5 +1,5 @@
/* GStreamer /* 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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
@ -25,7 +25,7 @@ static GstElementDetails gst_rtp_g711dec_details = {
"RTP packet parser", "RTP packet parser",
"Codec/Parser/Network", "Codec/Parser/Network",
"Extracts PCMU/PCMA audio from RTP packets", "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 */ /* RtpG711Dec signals and args */
@ -64,49 +64,16 @@ static GstStaticPadTemplate gst_rtpg711dec_src_template =
"audio/x-alaw, channels = (int) 1") "audio/x-alaw, channels = (int) 1")
); );
static void gst_rtpg711dec_class_init (GstRtpG711DecClass * klass); static GstBuffer *gst_rtpg711dec_process (GstBaseRTPDepayload * depayload,
static void gst_rtpg711dec_base_init (GstRtpG711DecClass * klass); GstBuffer * buf);
static void gst_rtpg711dec_init (GstRtpG711Dec * rtpg711dec); static gboolean gst_rtpg711dec_setcaps (GstBaseRTPDepayload * depayload,
static gboolean gst_rtpg711dec_sink_setcaps (GstPad * pad, GstCaps * caps); GstCaps * caps);
static GstFlowReturn gst_rtpg711dec_chain (GstPad * pad, GstBuffer * buffer);
static void gst_rtpg711dec_set_property (GObject * object, guint prop_id, GST_BOILERPLATE (GstRtpG711Dec, gst_rtpg711dec, GstBaseRTPDepayload,
const GValue * value, GParamSpec * pspec); GST_TYPE_BASE_RTP_DEPAYLOAD);
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;
}
static void static void
gst_rtpg711dec_base_init (GstRtpG711DecClass * klass) gst_rtpg711dec_base_init (gpointer klass)
{ {
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
@ -122,47 +89,38 @@ gst_rtpg711dec_class_init (GstRtpG711DecClass * klass)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class;
GstElementClass *gstelement_class; GstElementClass *gstelement_class;
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
gobject_class = (GObjectClass *) klass; gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass; gstelement_class = (GstElementClass *) klass;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_BASE_RTP_DEPAYLOAD);
gobject_class->set_property = gst_rtpg711dec_set_property; gstbasertpdepayload_class->process = gst_rtpg711dec_process;
gobject_class->get_property = gst_rtpg711dec_get_property; gstbasertpdepayload_class->set_caps = gst_rtpg711dec_setcaps;
gstelement_class->change_state = gst_rtpg711dec_change_state;
} }
static void static void
gst_rtpg711dec_init (GstRtpG711Dec * rtpg711dec) gst_rtpg711dec_init (GstRtpG711Dec * rtpg711dec, GstRtpG711DecClass * klass)
{ {
rtpg711dec->srcpad = GstBaseRTPDepayload *depayload;
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);
gst_pad_set_setcaps_function (rtpg711dec->sinkpad, depayload = GST_BASE_RTP_DEPAYLOAD (rtpg711dec);
gst_rtpg711dec_sink_setcaps);
gst_element_add_pad (GST_ELEMENT (rtpg711dec), rtpg711dec->sinkpad); depayload->clock_rate = 8000;
gst_pad_set_chain_function (rtpg711dec->sinkpad, gst_rtpg711dec_chain); gst_pad_use_fixed_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload));
} }
static gboolean static gboolean
gst_rtpg711dec_sink_setcaps (GstPad * pad, GstCaps * caps) gst_rtpg711dec_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
{ {
GstCaps *srccaps; GstCaps *srccaps;
GstRtpG711Dec *rtpg711dec;
const gchar *enc_name; const gchar *enc_name;
GstStructure *structure; GstStructure *structure;
gboolean ret;
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
enc_name = gst_structure_get_name (structure);
enc_name = gst_structure_get_string (structure, "encoding-name"); enc_name = gst_structure_get_string (structure, "encoding-name");
if (NULL == enc_name) { if (NULL == enc_name) {
@ -179,116 +137,30 @@ gst_rtpg711dec_sink_setcaps (GstPad * pad, GstCaps * caps)
return FALSE; return FALSE;
} }
rtpg711dec = GST_RTP_G711_DEC (GST_OBJECT_PARENT (pad)); ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
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);
gst_caps_unref (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; return ret;
bad_packet:
{
GST_DEBUG ("Packet did not validate");
gst_buffer_unref (buf);
return GST_FLOW_ERROR;
}
} }
static void static GstBuffer *
gst_rtpg711dec_set_property (GObject * object, guint prop_id, gst_rtpg711dec_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
const GValue * value, GParamSpec * pspec)
{ {
GstRtpG711Dec *rtpg711dec; GstBuffer *outbuf = NULL;
gint payload_len;
guint8 *payload;
rtpg711dec = GST_RTP_G711_DEC (object); 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));
switch (prop_id) { payload_len = gst_rtpbuffer_get_payload_len (buf);
default: payload = gst_rtpbuffer_get_payload (buf);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void outbuf = gst_buffer_new_and_alloc (payload_len);
gst_rtpg711dec_get_property (GObject * object, guint prop_id, GValue * value, memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
GParamSpec * pspec) return outbuf;
{
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)
{
GstRtpG711Dec *rtpg711dec;
GstStateChangeReturn ret;
rtpg711dec = GST_RTP_G711_DEC (element);
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
break;
default:
break;
}
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
case GST_STATE_CHANGE_READY_TO_NULL:
break;
default:
break;
}
return ret;
} }
gboolean gboolean

View File

@ -16,6 +16,7 @@
#define __GST_RTP_G711_DEC_H__ #define __GST_RTP_G711_DEC_H__
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/rtp/gstbasertpdepayload.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@ -35,15 +36,12 @@ typedef struct _GstRtpG711DecClass GstRtpG711DecClass;
struct _GstRtpG711Dec struct _GstRtpG711Dec
{ {
GstElement element; GstBaseRTPDepayload depayload;
GstPad *sinkpad;
GstPad *srcpad;
}; };
struct _GstRtpG711DecClass struct _GstRtpG711DecClass
{ {
GstElementClass parent_class; GstBaseRTPDepayloadClass parent_class;
}; };
gboolean gst_rtpg711dec_plugin_init (GstPlugin * plugin); gboolean gst_rtpg711dec_plugin_init (GstPlugin * plugin);

View File

@ -1,5 +1,5 @@
/* GStreamer /* 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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
@ -25,7 +25,7 @@ static GstElementDetails gst_rtp_g711dec_details = {
"RTP packet parser", "RTP packet parser",
"Codec/Parser/Network", "Codec/Parser/Network",
"Extracts PCMU/PCMA audio from RTP packets", "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 */ /* RtpG711Dec signals and args */
@ -64,49 +64,16 @@ static GstStaticPadTemplate gst_rtpg711dec_src_template =
"audio/x-alaw, channels = (int) 1") "audio/x-alaw, channels = (int) 1")
); );
static void gst_rtpg711dec_class_init (GstRtpG711DecClass * klass); static GstBuffer *gst_rtpg711dec_process (GstBaseRTPDepayload * depayload,
static void gst_rtpg711dec_base_init (GstRtpG711DecClass * klass); GstBuffer * buf);
static void gst_rtpg711dec_init (GstRtpG711Dec * rtpg711dec); static gboolean gst_rtpg711dec_setcaps (GstBaseRTPDepayload * depayload,
static gboolean gst_rtpg711dec_sink_setcaps (GstPad * pad, GstCaps * caps); GstCaps * caps);
static GstFlowReturn gst_rtpg711dec_chain (GstPad * pad, GstBuffer * buffer);
static void gst_rtpg711dec_set_property (GObject * object, guint prop_id, GST_BOILERPLATE (GstRtpG711Dec, gst_rtpg711dec, GstBaseRTPDepayload,
const GValue * value, GParamSpec * pspec); GST_TYPE_BASE_RTP_DEPAYLOAD);
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;
}
static void static void
gst_rtpg711dec_base_init (GstRtpG711DecClass * klass) gst_rtpg711dec_base_init (gpointer klass)
{ {
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
@ -122,47 +89,38 @@ gst_rtpg711dec_class_init (GstRtpG711DecClass * klass)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class;
GstElementClass *gstelement_class; GstElementClass *gstelement_class;
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
gobject_class = (GObjectClass *) klass; gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass; gstelement_class = (GstElementClass *) klass;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
parent_class = g_type_class_ref (GST_TYPE_ELEMENT); parent_class = g_type_class_ref (GST_TYPE_BASE_RTP_DEPAYLOAD);
gobject_class->set_property = gst_rtpg711dec_set_property; gstbasertpdepayload_class->process = gst_rtpg711dec_process;
gobject_class->get_property = gst_rtpg711dec_get_property; gstbasertpdepayload_class->set_caps = gst_rtpg711dec_setcaps;
gstelement_class->change_state = gst_rtpg711dec_change_state;
} }
static void static void
gst_rtpg711dec_init (GstRtpG711Dec * rtpg711dec) gst_rtpg711dec_init (GstRtpG711Dec * rtpg711dec, GstRtpG711DecClass * klass)
{ {
rtpg711dec->srcpad = GstBaseRTPDepayload *depayload;
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);
gst_pad_set_setcaps_function (rtpg711dec->sinkpad, depayload = GST_BASE_RTP_DEPAYLOAD (rtpg711dec);
gst_rtpg711dec_sink_setcaps);
gst_element_add_pad (GST_ELEMENT (rtpg711dec), rtpg711dec->sinkpad); depayload->clock_rate = 8000;
gst_pad_set_chain_function (rtpg711dec->sinkpad, gst_rtpg711dec_chain); gst_pad_use_fixed_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload));
} }
static gboolean static gboolean
gst_rtpg711dec_sink_setcaps (GstPad * pad, GstCaps * caps) gst_rtpg711dec_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
{ {
GstCaps *srccaps; GstCaps *srccaps;
GstRtpG711Dec *rtpg711dec;
const gchar *enc_name; const gchar *enc_name;
GstStructure *structure; GstStructure *structure;
gboolean ret;
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
enc_name = gst_structure_get_name (structure);
enc_name = gst_structure_get_string (structure, "encoding-name"); enc_name = gst_structure_get_string (structure, "encoding-name");
if (NULL == enc_name) { if (NULL == enc_name) {
@ -179,116 +137,30 @@ gst_rtpg711dec_sink_setcaps (GstPad * pad, GstCaps * caps)
return FALSE; return FALSE;
} }
rtpg711dec = GST_RTP_G711_DEC (GST_OBJECT_PARENT (pad)); ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
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);
gst_caps_unref (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; return ret;
bad_packet:
{
GST_DEBUG ("Packet did not validate");
gst_buffer_unref (buf);
return GST_FLOW_ERROR;
}
} }
static void static GstBuffer *
gst_rtpg711dec_set_property (GObject * object, guint prop_id, gst_rtpg711dec_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
const GValue * value, GParamSpec * pspec)
{ {
GstRtpG711Dec *rtpg711dec; GstBuffer *outbuf = NULL;
gint payload_len;
guint8 *payload;
rtpg711dec = GST_RTP_G711_DEC (object); 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));
switch (prop_id) { payload_len = gst_rtpbuffer_get_payload_len (buf);
default: payload = gst_rtpbuffer_get_payload (buf);
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void outbuf = gst_buffer_new_and_alloc (payload_len);
gst_rtpg711dec_get_property (GObject * object, guint prop_id, GValue * value, memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
GParamSpec * pspec) return outbuf;
{
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)
{
GstRtpG711Dec *rtpg711dec;
GstStateChangeReturn ret;
rtpg711dec = GST_RTP_G711_DEC (element);
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
break;
default:
break;
}
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
switch (transition) {
case GST_STATE_CHANGE_READY_TO_NULL:
break;
default:
break;
}
return ret;
} }
gboolean gboolean

View File

@ -16,6 +16,7 @@
#define __GST_RTP_G711_DEC_H__ #define __GST_RTP_G711_DEC_H__
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/rtp/gstbasertpdepayload.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@ -35,15 +36,12 @@ typedef struct _GstRtpG711DecClass GstRtpG711DecClass;
struct _GstRtpG711Dec struct _GstRtpG711Dec
{ {
GstElement element; GstBaseRTPDepayload depayload;
GstPad *sinkpad;
GstPad *srcpad;
}; };
struct _GstRtpG711DecClass struct _GstRtpG711DecClass
{ {
GstElementClass parent_class; GstBaseRTPDepayloadClass parent_class;
}; };
gboolean gst_rtpg711dec_plugin_init (GstPlugin * plugin); gboolean gst_rtpg711dec_plugin_init (GstPlugin * plugin);

View File

@ -1,5 +1,5 @@
/* GStreamer /* 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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * 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\"") "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, static gboolean gst_rtpg711enc_setcaps (GstBaseRTPPayload * payload,
GstCaps * caps); GstCaps * caps);
static GstFlowReturn gst_rtpg711enc_handle_buffer (GstBaseRTPPayload * payload, static GstFlowReturn gst_rtpg711enc_handle_buffer (GstBaseRTPPayload * payload,
GstBuffer * buffer); GstBuffer * buffer);
static GstBaseRTPPayloadClass *parent_class = NULL; GST_BOILERPLATE (GstRtpG711Enc, gst_rtpg711enc, GstBaseRTPPayload,
GST_TYPE_BASE_RTP_PAYLOAD);
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;
}
static void static void
gst_rtpg711enc_base_init (GstRtpG711EncClass * klass) gst_rtpg711enc_base_init (gpointer klass)
{ {
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
@ -120,8 +91,9 @@ gst_rtpg711enc_class_init (GstRtpG711EncClass * klass)
} }
static void static void
gst_rtpg711enc_init (GstRtpG711Enc * rtpg711enc) gst_rtpg711enc_init (GstRtpG711Enc * rtpg711enc, GstRtpG711EncClass * klass)
{ {
GST_BASE_RTP_PAYLOAD (rtpg711enc)->clock_rate = 8000;
} }
static gboolean static gboolean
@ -169,9 +141,7 @@ gst_rtpg711enc_handle_buffer (GstBaseRTPPayload * basepayload,
outbuf = gst_rtpbuffer_new_allocate (payload_len, 0, 0); outbuf = gst_rtpbuffer_new_allocate (payload_len, 0, 0);
/* FIXME, assert for now */ /* FIXME, assert for now */
g_assert (GST_BUFFER_SIZE (outbuf) < GST_BASE_RTP_PAYLOAD_MTU (rtpg711enc)); g_assert (payload_len <= GST_BASE_RTP_PAYLOAD_MTU (rtpg711enc));
gst_rtpbuffer_set_timestamp (outbuf, timestamp * 8000 / GST_SECOND);
/* copy timestamp */ /* copy timestamp */
GST_BUFFER_TIMESTAMP (outbuf) = timestamp; GST_BUFFER_TIMESTAMP (outbuf) = timestamp;

View File

@ -1,5 +1,5 @@
/* GStreamer /* 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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * 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\"") "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, static gboolean gst_rtpg711enc_setcaps (GstBaseRTPPayload * payload,
GstCaps * caps); GstCaps * caps);
static GstFlowReturn gst_rtpg711enc_handle_buffer (GstBaseRTPPayload * payload, static GstFlowReturn gst_rtpg711enc_handle_buffer (GstBaseRTPPayload * payload,
GstBuffer * buffer); GstBuffer * buffer);
static GstBaseRTPPayloadClass *parent_class = NULL; GST_BOILERPLATE (GstRtpG711Enc, gst_rtpg711enc, GstBaseRTPPayload,
GST_TYPE_BASE_RTP_PAYLOAD);
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;
}
static void static void
gst_rtpg711enc_base_init (GstRtpG711EncClass * klass) gst_rtpg711enc_base_init (gpointer klass)
{ {
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
@ -120,8 +91,9 @@ gst_rtpg711enc_class_init (GstRtpG711EncClass * klass)
} }
static void static void
gst_rtpg711enc_init (GstRtpG711Enc * rtpg711enc) gst_rtpg711enc_init (GstRtpG711Enc * rtpg711enc, GstRtpG711EncClass * klass)
{ {
GST_BASE_RTP_PAYLOAD (rtpg711enc)->clock_rate = 8000;
} }
static gboolean static gboolean
@ -169,9 +141,7 @@ gst_rtpg711enc_handle_buffer (GstBaseRTPPayload * basepayload,
outbuf = gst_rtpbuffer_new_allocate (payload_len, 0, 0); outbuf = gst_rtpbuffer_new_allocate (payload_len, 0, 0);
/* FIXME, assert for now */ /* FIXME, assert for now */
g_assert (GST_BUFFER_SIZE (outbuf) < GST_BASE_RTP_PAYLOAD_MTU (rtpg711enc)); g_assert (payload_len <= GST_BASE_RTP_PAYLOAD_MTU (rtpg711enc));
gst_rtpbuffer_set_timestamp (outbuf, timestamp * 8000 / GST_SECOND);
/* copy timestamp */ /* copy timestamp */
GST_BUFFER_TIMESTAMP (outbuf) = timestamp; GST_BUFFER_TIMESTAMP (outbuf) = timestamp;

View File

@ -25,7 +25,7 @@ static GstElementDetails gst_rtp_gsmparse_details = {
"RTP packet parser", "RTP packet parser",
"Codec/Parser/Network", "Codec/Parser/Network",
"Extracts GSM audio from RTP packets", "Extracts GSM audio from RTP packets",
"Zeeshan Ali <zak147@yahoo.com>" "Zeeshan Ali <zeenix@gmail.com>"
}; };
/* RTPGSMParse signals and args */ /* RTPGSMParse signals and args */
@ -52,43 +52,16 @@ GST_STATIC_PAD_TEMPLATE ("sink",
"clock-rate = (int) 8000, " "encoding-name = (string) \"GSM\"") "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, static GstBuffer *gst_rtpgsmparse_process (GstBaseRTPDepayload * depayload,
GstBuffer * buf); GstBuffer * buf);
static gboolean gst_rtpgsmparse_setcaps (GstBaseRTPDepayload * payload, static gboolean gst_rtpgsmparse_setcaps (GstBaseRTPDepayload * depayload,
GstCaps * caps); GstCaps * caps);
static void gst_rtpgsmparse_finalize (GObject * object);
static GstElementClass *parent_class = NULL;
static GType GST_BOILERPLATE (GstRTPGSMParse, gst_rtpgsmparse, GstBaseRTPDepayload,
gst_rtpgsmparse_get_type (void) GST_TYPE_BASE_RTP_DEPAYLOAD);
{
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;
}
static void static void
gst_rtpgsmparse_base_init (GstRTPGSMParseClass * klass) gst_rtpgsmparse_base_init (gpointer klass)
{ {
GstElementClass *element_class = GST_ELEMENT_CLASS (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->process = gst_rtpgsmparse_process;
gstbasertpdepayload_class->set_caps = gst_rtpgsmparse_setcaps; gstbasertpdepayload_class->set_caps = gst_rtpgsmparse_setcaps;
gobject_class->finalize = gst_rtpgsmparse_finalize;
} }
static void static void
gst_rtpgsmparse_init (GstRTPGSMParse * rtpgsmparse) gst_rtpgsmparse_init (GstRTPGSMParse * rtpgsmparse, GstRTPGSMParseClass * klass)
{ {
GST_BASE_RTP_DEPAYLOAD (rtpgsmparse)->clock_rate = 8000; GST_BASE_RTP_DEPAYLOAD (rtpgsmparse)->clock_rate = 8000;
} }
@ -127,20 +98,14 @@ gst_rtpgsmparse_init (GstRTPGSMParse * rtpgsmparse)
static gboolean static gboolean
gst_rtpgsmparse_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps) gst_rtpgsmparse_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
{ {
GstRTPGSMParse *rtpgsmparse;
GstCaps *srccaps; GstCaps *srccaps;
gboolean ret;
rtpgsmparse = GST_RTP_GSM_PARSE (depayload);
srccaps = gst_static_pad_template_get_caps (&gst_rtpgsmparse_src_template); 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_caps_unref (srccaps);
gst_rtpgsmparse_finalize (GObject * object) return ret;
{
if (G_OBJECT_CLASS (parent_class)->finalize)
G_OBJECT_CLASS (parent_class)->finalize (object);
} }
static GstBuffer * static GstBuffer *

View File

@ -42,11 +42,6 @@ typedef struct _GstRTPGSMParseClass GstRTPGSMParseClass;
struct _GstRTPGSMParse struct _GstRTPGSMParse
{ {
GstBaseRTPDepayload depayload; GstBaseRTPDepayload depayload;
GstPad *sinkpad;
GstPad *srcpad;
guint frequency;
}; };
struct _GstRTPGSMParseClass struct _GstRTPGSMParseClass

View File

@ -32,7 +32,7 @@ static GstElementDetails gst_rtpgsmenc_details = {
"RTP GSM Audio Encoder", "RTP GSM Audio Encoder",
"Codec/Encoder/Network", "Codec/Encoder/Network",
"Encodes GSM audio into a RTP packet", "Encodes GSM audio into a RTP packet",
"Zeeshan Ali <zak147@yahoo.com>" "Zeeshan Ali <zeenix@gmail.com>"
}; };
static GstStaticPadTemplate gst_rtpgsmenc_sink_template = static GstStaticPadTemplate gst_rtpgsmenc_sink_template =
@ -52,45 +52,16 @@ GST_STATIC_PAD_TEMPLATE ("src",
"clock-rate = (int) 8000, " "encoding-name = (string) \"GSM\"") "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, static gboolean gst_rtpgsmenc_setcaps (GstBaseRTPPayload * payload,
GstCaps * caps); GstCaps * caps);
static GstFlowReturn gst_rtpgsmenc_handle_buffer (GstBaseRTPPayload * payload, static GstFlowReturn gst_rtpgsmenc_handle_buffer (GstBaseRTPPayload * payload,
GstBuffer * buffer); GstBuffer * buffer);
static GstBaseRTPPayloadClass *parent_class = NULL; GST_BOILERPLATE (GstRTPGSMEnc, gst_rtpgsmenc, GstBaseRTPPayload,
GST_TYPE_BASE_RTP_PAYLOAD);
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;
}
static void static void
gst_rtpgsmenc_base_init (GstRTPGSMEncClass * klass) gst_rtpgsmenc_base_init (gpointer klass)
{ {
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
@ -119,7 +90,7 @@ gst_rtpgsmenc_class_init (GstRTPGSMEncClass * klass)
} }
static void 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 (rtpgsmenc)->clock_rate = 8000;
GST_BASE_RTP_PAYLOAD_PT (rtpgsmenc) = GST_RTP_PAYLOAD_GSM; GST_BASE_RTP_PAYLOAD_PT (rtpgsmenc) = GST_RTP_PAYLOAD_GSM;
@ -128,24 +99,20 @@ gst_rtpgsmenc_init (GstRTPGSMEnc * rtpgsmenc)
static gboolean static gboolean
gst_rtpgsmenc_setcaps (GstBaseRTPPayload * payload, GstCaps * caps) gst_rtpgsmenc_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
{ {
GstRTPGSMEnc *rtpgsmenc; const char *stname;
GstStructure *structure; GstStructure *structure;
gboolean ret;
GstCaps *srccaps;
rtpgsmenc = GST_RTP_GSM_ENC (payload);
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
ret = stname = gst_structure_get_name (structure);
gst_structure_get_int (structure, "rate",
(gint *) & (GST_BASE_RTP_PAYLOAD (rtpgsmenc)->clock_rate));
if (!ret)
return FALSE;
srccaps = gst_caps_new_simple ("application/x-rtp", NULL); if (0 == strcmp ("audio/x-gsm", stname)) {
gst_pad_set_caps (GST_BASE_RTP_PAYLOAD_SRCPAD (rtpgsmenc), srccaps); gst_basertppayload_set_options (payload, "audio", FALSE, "GSM", 8000);
gst_caps_unref (srccaps); } else {
return FALSE;
}
gst_basertppayload_set_outcaps (payload, NULL);
return TRUE; return TRUE;
} }
@ -171,7 +138,7 @@ gst_rtpgsmenc_handle_buffer (GstBaseRTPPayload * basepayload,
outbuf = gst_rtpbuffer_new_allocate (payload_len, 0, 0); outbuf = gst_rtpbuffer_new_allocate (payload_len, 0, 0);
/* FIXME, assert for now */ /* 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 */ /* copy timestamp */
GST_BUFFER_TIMESTAMP (outbuf) = timestamp; GST_BUFFER_TIMESTAMP (outbuf) = timestamp;

View File

@ -25,7 +25,7 @@ static GstElementDetails gst_rtp_gsmparse_details = {
"RTP packet parser", "RTP packet parser",
"Codec/Parser/Network", "Codec/Parser/Network",
"Extracts GSM audio from RTP packets", "Extracts GSM audio from RTP packets",
"Zeeshan Ali <zak147@yahoo.com>" "Zeeshan Ali <zeenix@gmail.com>"
}; };
/* RTPGSMParse signals and args */ /* RTPGSMParse signals and args */
@ -52,43 +52,16 @@ GST_STATIC_PAD_TEMPLATE ("sink",
"clock-rate = (int) 8000, " "encoding-name = (string) \"GSM\"") "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, static GstBuffer *gst_rtpgsmparse_process (GstBaseRTPDepayload * depayload,
GstBuffer * buf); GstBuffer * buf);
static gboolean gst_rtpgsmparse_setcaps (GstBaseRTPDepayload * payload, static gboolean gst_rtpgsmparse_setcaps (GstBaseRTPDepayload * depayload,
GstCaps * caps); GstCaps * caps);
static void gst_rtpgsmparse_finalize (GObject * object);
static GstElementClass *parent_class = NULL;
static GType GST_BOILERPLATE (GstRTPGSMParse, gst_rtpgsmparse, GstBaseRTPDepayload,
gst_rtpgsmparse_get_type (void) GST_TYPE_BASE_RTP_DEPAYLOAD);
{
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;
}
static void static void
gst_rtpgsmparse_base_init (GstRTPGSMParseClass * klass) gst_rtpgsmparse_base_init (gpointer klass)
{ {
GstElementClass *element_class = GST_ELEMENT_CLASS (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->process = gst_rtpgsmparse_process;
gstbasertpdepayload_class->set_caps = gst_rtpgsmparse_setcaps; gstbasertpdepayload_class->set_caps = gst_rtpgsmparse_setcaps;
gobject_class->finalize = gst_rtpgsmparse_finalize;
} }
static void static void
gst_rtpgsmparse_init (GstRTPGSMParse * rtpgsmparse) gst_rtpgsmparse_init (GstRTPGSMParse * rtpgsmparse, GstRTPGSMParseClass * klass)
{ {
GST_BASE_RTP_DEPAYLOAD (rtpgsmparse)->clock_rate = 8000; GST_BASE_RTP_DEPAYLOAD (rtpgsmparse)->clock_rate = 8000;
} }
@ -127,20 +98,14 @@ gst_rtpgsmparse_init (GstRTPGSMParse * rtpgsmparse)
static gboolean static gboolean
gst_rtpgsmparse_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps) gst_rtpgsmparse_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
{ {
GstRTPGSMParse *rtpgsmparse;
GstCaps *srccaps; GstCaps *srccaps;
gboolean ret;
rtpgsmparse = GST_RTP_GSM_PARSE (depayload);
srccaps = gst_static_pad_template_get_caps (&gst_rtpgsmparse_src_template); 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_caps_unref (srccaps);
gst_rtpgsmparse_finalize (GObject * object) return ret;
{
if (G_OBJECT_CLASS (parent_class)->finalize)
G_OBJECT_CLASS (parent_class)->finalize (object);
} }
static GstBuffer * static GstBuffer *

View File

@ -42,11 +42,6 @@ typedef struct _GstRTPGSMParseClass GstRTPGSMParseClass;
struct _GstRTPGSMParse struct _GstRTPGSMParse
{ {
GstBaseRTPDepayload depayload; GstBaseRTPDepayload depayload;
GstPad *sinkpad;
GstPad *srcpad;
guint frequency;
}; };
struct _GstRTPGSMParseClass struct _GstRTPGSMParseClass

View File

@ -32,7 +32,7 @@ static GstElementDetails gst_rtpgsmenc_details = {
"RTP GSM Audio Encoder", "RTP GSM Audio Encoder",
"Codec/Encoder/Network", "Codec/Encoder/Network",
"Encodes GSM audio into a RTP packet", "Encodes GSM audio into a RTP packet",
"Zeeshan Ali <zak147@yahoo.com>" "Zeeshan Ali <zeenix@gmail.com>"
}; };
static GstStaticPadTemplate gst_rtpgsmenc_sink_template = static GstStaticPadTemplate gst_rtpgsmenc_sink_template =
@ -52,45 +52,16 @@ GST_STATIC_PAD_TEMPLATE ("src",
"clock-rate = (int) 8000, " "encoding-name = (string) \"GSM\"") "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, static gboolean gst_rtpgsmenc_setcaps (GstBaseRTPPayload * payload,
GstCaps * caps); GstCaps * caps);
static GstFlowReturn gst_rtpgsmenc_handle_buffer (GstBaseRTPPayload * payload, static GstFlowReturn gst_rtpgsmenc_handle_buffer (GstBaseRTPPayload * payload,
GstBuffer * buffer); GstBuffer * buffer);
static GstBaseRTPPayloadClass *parent_class = NULL; GST_BOILERPLATE (GstRTPGSMEnc, gst_rtpgsmenc, GstBaseRTPPayload,
GST_TYPE_BASE_RTP_PAYLOAD);
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;
}
static void static void
gst_rtpgsmenc_base_init (GstRTPGSMEncClass * klass) gst_rtpgsmenc_base_init (gpointer klass)
{ {
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
@ -119,7 +90,7 @@ gst_rtpgsmenc_class_init (GstRTPGSMEncClass * klass)
} }
static void 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 (rtpgsmenc)->clock_rate = 8000;
GST_BASE_RTP_PAYLOAD_PT (rtpgsmenc) = GST_RTP_PAYLOAD_GSM; GST_BASE_RTP_PAYLOAD_PT (rtpgsmenc) = GST_RTP_PAYLOAD_GSM;
@ -128,24 +99,20 @@ gst_rtpgsmenc_init (GstRTPGSMEnc * rtpgsmenc)
static gboolean static gboolean
gst_rtpgsmenc_setcaps (GstBaseRTPPayload * payload, GstCaps * caps) gst_rtpgsmenc_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
{ {
GstRTPGSMEnc *rtpgsmenc; const char *stname;
GstStructure *structure; GstStructure *structure;
gboolean ret;
GstCaps *srccaps;
rtpgsmenc = GST_RTP_GSM_ENC (payload);
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
ret = stname = gst_structure_get_name (structure);
gst_structure_get_int (structure, "rate",
(gint *) & (GST_BASE_RTP_PAYLOAD (rtpgsmenc)->clock_rate));
if (!ret)
return FALSE;
srccaps = gst_caps_new_simple ("application/x-rtp", NULL); if (0 == strcmp ("audio/x-gsm", stname)) {
gst_pad_set_caps (GST_BASE_RTP_PAYLOAD_SRCPAD (rtpgsmenc), srccaps); gst_basertppayload_set_options (payload, "audio", FALSE, "GSM", 8000);
gst_caps_unref (srccaps); } else {
return FALSE;
}
gst_basertppayload_set_outcaps (payload, NULL);
return TRUE; return TRUE;
} }
@ -171,7 +138,7 @@ gst_rtpgsmenc_handle_buffer (GstBaseRTPPayload * basepayload,
outbuf = gst_rtpbuffer_new_allocate (payload_len, 0, 0); outbuf = gst_rtpbuffer_new_allocate (payload_len, 0, 0);
/* FIXME, assert for now */ /* 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 */ /* copy timestamp */
GST_BUFFER_TIMESTAMP (outbuf) = timestamp; GST_BUFFER_TIMESTAMP (outbuf) = timestamp;