Commit bf9b4f83 authored by Wim Taymans's avatar Wim Taymans

rtp: port more to 0.11

parent 60db07b4
......@@ -62,7 +62,8 @@ static GstStaticPadTemplate gst_rtp_g722_depay_sink_template =
)
);
GST_BOILERPLATE (GstRtpG722Depay, gst_rtp_g722_depay, GstBaseRTPDepayload,
#define gst_rtp_g722_depay_parent_class parent_class
G_DEFINE_TYPE (GstRtpG722Depay, gst_rtp_g722_depay,
GST_TYPE_BASE_RTP_DEPAYLOAD);
static gboolean gst_rtp_g722_depay_setcaps (GstBaseRTPDepayload * depayload,
......@@ -71,40 +72,34 @@ static GstBuffer *gst_rtp_g722_depay_process (GstBaseRTPDepayload * depayload,
GstBuffer * buf);
static void
gst_rtp_g722_depay_base_init (gpointer klass)
gst_rtp_g722_depay_class_init (GstRtpG722DepayClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstElementClass *gstelement_class;
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
GST_DEBUG_CATEGORY_INIT (rtpg722depay_debug, "rtpg722depay", 0,
"G722 RTP Depayloader");
gst_element_class_add_pad_template (element_class,
gstelement_class = (GstElementClass *) klass;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_g722_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_g722_depay_sink_template));
gst_element_class_set_details_simple (element_class, "RTP audio depayloader",
"Codec/Depayloader/Network/RTP",
gst_element_class_set_details_simple (gstelement_class,
"RTP audio depayloader", "Codec/Depayloader/Network/RTP",
"Extracts G722 audio from RTP packets",
"Wim Taymans <wim.taymans@gmail.com>");
}
static void
gst_rtp_g722_depay_class_init (GstRtpG722DepayClass * klass)
{
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
gstbasertpdepayload_class->set_caps = gst_rtp_g722_depay_setcaps;
gstbasertpdepayload_class->process = gst_rtp_g722_depay_process;
GST_DEBUG_CATEGORY_INIT (rtpg722depay_debug, "rtpg722depay", 0,
"G722 RTP Depayloader");
}
static void
gst_rtp_g722_depay_init (GstRtpG722Depay * rtpg722depay,
GstRtpG722DepayClass * klass)
gst_rtp_g722_depay_init (GstRtpG722Depay * rtpg722depay)
{
/* needed because of GST_BOILERPLATE */
}
static gint
......@@ -223,18 +218,22 @@ gst_rtp_g722_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
GstBuffer *outbuf;
gint payload_len;
gboolean marker;
GstRTPBuffer rtp = { NULL };
rtpg722depay = GST_RTP_G722_DEPAY (depayload);
payload_len = gst_rtp_buffer_get_payload_len (buf);
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
if (payload_len <= 0)
goto empty_packet;
GST_DEBUG_OBJECT (rtpg722depay, "got payload of %d bytes", payload_len);
outbuf = gst_rtp_buffer_get_payload_buffer (buf);
marker = gst_rtp_buffer_get_marker (buf);
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
marker = gst_rtp_buffer_get_marker (&rtp);
gst_rtp_buffer_unmap (&rtp);
if (marker) {
/* mark talk spurt with DISCONT */
......@@ -248,6 +247,7 @@ empty_packet:
{
GST_ELEMENT_WARNING (rtpg722depay, STREAM, DECODE,
("Empty Payload."), (NULL));
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}
......
......@@ -56,41 +56,38 @@ static gboolean gst_rtp_g722_pay_setcaps (GstBaseRTPPayload * basepayload,
static GstCaps *gst_rtp_g722_pay_getcaps (GstBaseRTPPayload * rtppayload,
GstPad * pad);
GST_BOILERPLATE (GstRtpG722Pay, gst_rtp_g722_pay, GstBaseRTPAudioPayload,
#define gst_rtp_g722_pay_parent_class parent_class
G_DEFINE_TYPE (GstRtpG722Pay, gst_rtp_g722_pay,
GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
static void
gst_rtp_g722_pay_base_init (gpointer klass)
gst_rtp_g722_pay_class_init (GstRtpG722PayClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstElementClass *gstelement_class;
GstBaseRTPPayloadClass *gstbasertppayload_class;
GST_DEBUG_CATEGORY_INIT (rtpg722pay_debug, "rtpg722pay", 0,
"G722 RTP Payloader");
gst_element_class_add_pad_template (element_class,
gstelement_class = (GstElementClass *) klass;
gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_g722_pay_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_g722_pay_sink_template));
gst_element_class_set_details_simple (element_class, "RTP audio payloader",
gst_element_class_set_details_simple (gstelement_class, "RTP audio payloader",
"Codec/Payloader/Network/RTP",
"Payload-encode Raw audio into RTP packets (RFC 3551)",
"Wim Taymans <wim.taymans@gmail.com>");
}
static void
gst_rtp_g722_pay_class_init (GstRtpG722PayClass * klass)
{
GstBaseRTPPayloadClass *gstbasertppayload_class;
gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
gstbasertppayload_class->set_caps = gst_rtp_g722_pay_setcaps;
gstbasertppayload_class->get_caps = gst_rtp_g722_pay_getcaps;
GST_DEBUG_CATEGORY_INIT (rtpg722pay_debug, "rtpg722pay", 0,
"G722 RTP Payloader");
}
static void
gst_rtp_g722_pay_init (GstRtpG722Pay * rtpg722pay, GstRtpG722PayClass * klass)
gst_rtp_g722_pay_init (GstRtpG722Pay * rtpg722pay)
{
GstBaseRTPAudioPayload *basertpaudiopayload;
......
......@@ -78,42 +78,38 @@ static gboolean gst_rtp_g723_depay_setcaps (GstBaseRTPDepayload * depayload,
static GstBuffer *gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload,
GstBuffer * buf);
GST_BOILERPLATE (GstRtpG723Depay, gst_rtp_g723_depay, GstBaseRTPDepayload,
#define gst_rtp_g723_depay_parent_class parent_class
G_DEFINE_TYPE (GstRtpG723Depay, gst_rtp_g723_depay,
GST_TYPE_BASE_RTP_DEPAYLOAD);
static void
gst_rtp_g723_depay_base_init (gpointer klass)
gst_rtp_g723_depay_class_init (GstRtpG723DepayClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstElementClass *gstelement_class;
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
GST_DEBUG_CATEGORY_INIT (rtpg723depay_debug, "rtpg723depay", 0,
"G.723 RTP Depayloader");
gst_element_class_add_pad_template (element_class,
gstelement_class = (GstElementClass *) klass;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_g723_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_g723_depay_sink_template));
gst_element_class_set_details_simple (element_class, "RTP G.723 depayloader",
"Codec/Depayloader/Network/RTP",
gst_element_class_set_details_simple (gstelement_class,
"RTP G.723 depayloader", "Codec/Depayloader/Network/RTP",
"Extracts G.723 audio from RTP packets (RFC 3551)",
"Wim Taymans <wim.taymans@gmail.com>");
GST_DEBUG_CATEGORY_INIT (rtpg723depay_debug, "rtpg723depay", 0,
"G.723 RTP Depayloader");
}
static void
gst_rtp_g723_depay_class_init (GstRtpG723DepayClass * klass)
{
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
gstbasertpdepayload_class->process = gst_rtp_g723_depay_process;
gstbasertpdepayload_class->set_caps = gst_rtp_g723_depay_setcaps;
}
static void
gst_rtp_g723_depay_init (GstRtpG723Depay * rtpg723depay,
GstRtpG723DepayClass * klass)
gst_rtp_g723_depay_init (GstRtpG723Depay * rtpg723depay)
{
GstBaseRTPDepayload *depayload;
......@@ -182,10 +178,13 @@ gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
GstBuffer *outbuf = NULL;
gint payload_len;
gboolean marker;
GstRTPBuffer rtp = { NULL };
rtpg723depay = GST_RTP_G723_DEPAY (depayload);
payload_len = gst_rtp_buffer_get_payload_len (buf);
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
/* At least 4 bytes */
if (payload_len < 4)
......@@ -193,8 +192,9 @@ gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
GST_LOG_OBJECT (rtpg723depay, "payload len %d", payload_len);
outbuf = gst_rtp_buffer_get_payload_buffer (buf);
marker = gst_rtp_buffer_get_marker (buf);
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
marker = gst_rtp_buffer_get_marker (&rtp);
gst_rtp_buffer_unmap (&rtp);
if (marker) {
/* marker bit starts talkspurt */
......@@ -202,7 +202,7 @@ gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
}
GST_LOG_OBJECT (depayload, "pushing buffer of size %d",
GST_BUFFER_SIZE (outbuf));
gst_buffer_get_size (outbuf));
return outbuf;
......@@ -216,6 +216,7 @@ too_small:
bad_packet:
{
/* no fatal error */
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}
......
......@@ -67,23 +67,8 @@ static void gst_rtp_g723_pay_finalize (GObject * object);
static GstStateChangeReturn gst_rtp_g723_pay_change_state (GstElement * element,
GstStateChange transition);
GST_BOILERPLATE (GstRTPG723Pay, gst_rtp_g723_pay, GstBaseRTPPayload,
GST_TYPE_BASE_RTP_PAYLOAD);
static void
gst_rtp_g723_pay_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_g723_pay_sink_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_g723_pay_src_template));
gst_element_class_set_details_simple (element_class, "RTP G.723 payloader",
"Codec/Payloader/Network/RTP",
"Packetize G.723 audio into RTP packets",
"Wim Taymans <wim.taymans@gmail.com>");
}
#define gst_rtp_g723_pay_parent_class parent_class
G_DEFINE_TYPE (GstRTPG723Pay, gst_rtp_g723_pay, GST_TYPE_BASE_RTP_PAYLOAD);
static void
gst_rtp_g723_pay_class_init (GstRTPG723PayClass * klass)
......@@ -100,12 +85,22 @@ gst_rtp_g723_pay_class_init (GstRTPG723PayClass * klass)
gstelement_class->change_state = gst_rtp_g723_pay_change_state;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_g723_pay_sink_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_g723_pay_src_template));
gst_element_class_set_details_simple (gstelement_class, "RTP G.723 payloader",
"Codec/Payloader/Network/RTP",
"Packetize G.723 audio into RTP packets",
"Wim Taymans <wim.taymans@gmail.com>");
payload_class->set_caps = gst_rtp_g723_pay_set_caps;
payload_class->handle_buffer = gst_rtp_g723_pay_handle_buffer;
}
static void
gst_rtp_g723_pay_init (GstRTPG723Pay * pay, GstRTPG723PayClass * klass)
gst_rtp_g723_pay_init (GstRTPG723Pay * pay)
{
GstBaseRTPPayload *payload = GST_BASE_RTP_PAYLOAD (pay);
......@@ -155,11 +150,14 @@ gst_rtp_g723_pay_flush (GstRTPG723Pay * pay)
GstFlowReturn ret;
guint8 *payload;
guint avail;
GstRTPBuffer rtp = { NULL };
avail = gst_adapter_available (pay->adapter);
outbuf = gst_rtp_buffer_new_allocate (avail, 0, 0);
payload = gst_rtp_buffer_get_payload (outbuf);
gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
payload = gst_rtp_buffer_get_payload (&rtp);
GST_BUFFER_TIMESTAMP (outbuf) = pay->timestamp;
GST_BUFFER_DURATION (outbuf) = pay->duration;
......@@ -175,9 +173,10 @@ gst_rtp_g723_pay_flush (GstRTPG723Pay * pay)
/* set discont and marker */
if (pay->discont) {
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
gst_rtp_buffer_set_marker (outbuf, TRUE);
gst_rtp_buffer_set_marker (&rtp, TRUE);
pay->discont = FALSE;
}
gst_rtp_buffer_unmap (&rtp);
ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (pay), outbuf);
......@@ -197,7 +196,7 @@ gst_rtp_g723_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
{
GstFlowReturn ret = GST_FLOW_OK;
guint8 *data;
guint size;
gsize size;
guint8 HDR;
GstRTPG723Pay *pay;
GstClockTime packet_dur, timestamp;
......@@ -205,8 +204,7 @@ gst_rtp_g723_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
pay = GST_RTP_G723_PAY (payload);
size = GST_BUFFER_SIZE (buf);
data = GST_BUFFER_DATA (buf);
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
timestamp = GST_BUFFER_TIMESTAMP (buf);
if (GST_BUFFER_IS_DISCONT (buf)) {
......@@ -244,6 +242,7 @@ gst_rtp_g723_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
else
pay->timestamp = 0;
}
gst_buffer_unmap (buf, data, size);
/* add packet to the queue */
gst_adapter_push (pay->adapter, buf);
......@@ -262,6 +261,7 @@ invalid_size:
GST_ELEMENT_WARNING (pay, STREAM, WRONG_TYPE,
("Invalid input buffer size"),
("Input size should be 4, 20 or 24, got %u", size));
gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
return GST_FLOW_OK;
}
......@@ -270,6 +270,7 @@ wrong_size:
GST_ELEMENT_WARNING (pay, STREAM, WRONG_TYPE,
("Wrong input buffer size"),
("Expected input buffer size %u but got %u", size_tab[HDR], size));
gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf);
return GST_FLOW_OK;
}
......
......@@ -87,31 +87,22 @@ static GstBuffer *gst_rtp_g726_depay_process (GstBaseRTPDepayload * depayload,
static gboolean gst_rtp_g726_depay_setcaps (GstBaseRTPDepayload * depayload,
GstCaps * caps);
GST_BOILERPLATE (GstRtpG726Depay, gst_rtp_g726_depay, GstBaseRTPDepayload,
#define gst_rtp_g726_depay_parent_class parent_class
G_DEFINE_TYPE (GstRtpG726Depay, gst_rtp_g726_depay,
GST_TYPE_BASE_RTP_DEPAYLOAD);
static void
gst_rtp_g726_depay_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_g726_depay_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_g726_depay_sink_template));
gst_element_class_set_details_simple (element_class, "RTP G.726 depayloader",
"Codec/Depayloader/Network/RTP",
"Extracts G.726 audio from RTP packets",
"Axis Communications <dev-gstreamer@axis.com>");
}
static void
gst_rtp_g726_depay_class_init (GstRtpG726DepayClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
GST_DEBUG_CATEGORY_INIT (rtpg726depay_debug, "rtpg726depay", 0,
"G.726 RTP Depayloader");
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
gobject_class->set_property = gst_rtp_g726_depay_set_property;
......@@ -122,16 +113,22 @@ gst_rtp_g726_depay_class_init (GstRtpG726DepayClass * klass)
"Force AAL2 decoding for compatibility with bad payloaders",
DEFAULT_FORCE_AAL2, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_g726_depay_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_g726_depay_sink_template));
gst_element_class_set_details_simple (gstelement_class,
"RTP G.726 depayloader", "Codec/Depayloader/Network/RTP",
"Extracts G.726 audio from RTP packets",
"Axis Communications <dev-gstreamer@axis.com>");
gstbasertpdepayload_class->process = gst_rtp_g726_depay_process;
gstbasertpdepayload_class->set_caps = gst_rtp_g726_depay_setcaps;
GST_DEBUG_CATEGORY_INIT (rtpg726depay_debug, "rtpg726depay", 0,
"G.726 RTP Depayloader");
}
static void
gst_rtp_g726_depay_init (GstRtpG726Depay * rtpG726depay,
GstRtpG726DepayClass * klass)
gst_rtp_g726_depay_init (GstRtpG726Depay * rtpG726depay)
{
GstBaseRTPDepayload *depayload;
......@@ -210,36 +207,34 @@ gst_rtp_g726_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
GstRtpG726Depay *depay;
GstBuffer *outbuf = NULL;
gboolean marker;
GstRTPBuffer rtp = { NULL };
depay = GST_RTP_G726_DEPAY (depayload);
marker = gst_rtp_buffer_get_marker (buf);
gst_rtp_buffer_map (buf, GST_MAP_READWRITE, &rtp);
marker = gst_rtp_buffer_get_marker (&rtp);
GST_DEBUG ("process : got %d bytes, mark %d ts %u seqn %d",
GST_BUFFER_SIZE (buf), marker,
gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf));
gst_buffer_get_size (buf), marker,
gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
if (depay->aal2 || depay->force_aal2) {
/* AAL2, we can just copy the bytes */
outbuf = gst_rtp_buffer_get_payload_buffer (buf);
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
} else {
guint8 *in, *out, tmp;
guint8 *in, *out, tmp, *odata;
guint len;
gsize osize;
in = gst_rtp_buffer_get_payload (buf);
len = gst_rtp_buffer_get_payload_len (buf);
in = gst_rtp_buffer_get_payload (&rtp);
len = gst_rtp_buffer_get_payload_len (&rtp);
if (gst_buffer_is_writable (buf)) {
outbuf = gst_rtp_buffer_get_payload_buffer (buf);
} else {
GstBuffer *copy;
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
outbuf = gst_buffer_make_writable (outbuf);
/* copy buffer */
copy = gst_buffer_copy (buf);
outbuf = gst_rtp_buffer_get_payload_buffer (copy);
gst_buffer_unref (copy);
}
out = GST_BUFFER_DATA (outbuf);
odata = gst_buffer_map (outbuf, &osize, NULL, GST_MAP_WRITE);
out = odata;
/* we need to reshuffle the bytes, input is always of the form
* A B C D ... with the number of bits depending on the bitrate. */
......@@ -327,6 +322,7 @@ gst_rtp_g726_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
break;
}
}
gst_buffer_unmap (outbuf, odata, osize);
}
if (marker) {
......
......@@ -75,31 +75,19 @@ static gboolean gst_rtp_g726_pay_setcaps (GstBaseRTPPayload * payload,
static GstFlowReturn gst_rtp_g726_pay_handle_buffer (GstBaseRTPPayload *
payload, GstBuffer * buffer);
GST_BOILERPLATE (GstRtpG726Pay, gst_rtp_g726_pay, GstBaseRTPAudioPayload,
#define gst_rtp_g726_pay_parent_class parent_class
G_DEFINE_TYPE (GstRtpG726Pay, gst_rtp_g726_pay,
GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
static void
gst_rtp_g726_pay_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_g726_pay_sink_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_g726_pay_src_template));
gst_element_class_set_details_simple (element_class, "RTP G.726 payloader",
"Codec/Payloader/Network/RTP",
"Payload-encodes G.726 audio into a RTP packet",
"Axis Communications <dev-gstreamer@axis.com>");
}
static void
gst_rtp_g726_pay_class_init (GstRtpG726PayClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseRTPPayloadClass *gstbasertppayload_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
gobject_class->set_property = gst_rtp_g726_pay_set_property;
......@@ -110,6 +98,16 @@ gst_rtp_g726_pay_class_init (GstRtpG726PayClass * klass)
"Force AAL2 encoding for compatibility with bad depayloaders",
DEFAULT_FORCE_AAL2, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_g726_pay_sink_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_g726_pay_src_template));
gst_element_class_set_details_simple (gstelement_class, "RTP G.726 payloader",
"Codec/Payloader/Network/RTP",
"Payload-encodes G.726 audio into a RTP packet",
"Axis Communications <dev-gstreamer@axis.com>");
gstbasertppayload_class->set_caps = gst_rtp_g726_pay_setcaps;
gstbasertppayload_class->handle_buffer = gst_rtp_g726_pay_handle_buffer;
......@@ -118,7 +116,7 @@ gst_rtp_g726_pay_class_init (GstRtpG726PayClass * klass)
}
static void
gst_rtp_g726_pay_init (GstRtpG726Pay * rtpg726pay, GstRtpG726PayClass * klass)
gst_rtp_g726_pay_init (GstRtpG726Pay * rtpg726pay)
{
GstBaseRTPAudioPayload *basertpaudiopayload;
......@@ -269,14 +267,13 @@ gst_rtp_g726_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
if (!pay->aal2) {
guint8 *data, tmp;
guint len;
gsize len;
/* for non AAL2, we need to reshuffle the bytes, we can do this in-place
* when the buffer is writable. */
buffer = gst_buffer_make_writable (buffer);
data = GST_BUFFER_DATA (buffer);
len = GST_BUFFER_SIZE (buffer);
data = gst_buffer_map (buffer, &len, NULL, GST_MAP_READWRITE);
GST_LOG_OBJECT (pay, "packing %u bytes of data", len);
......@@ -366,6 +363,7 @@ gst_rtp_g726_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
break;
}
}
gst_buffer_unmap (buffer, data, len);
}
res =
......
......@@ -76,42 +76,38 @@ static gboolean gst_rtp_g729_depay_setcaps (GstBaseRTPDepayload * depayload,
static GstBuffer *gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload,
GstBuffer * buf);
GST_BOILERPLATE (GstRtpG729Depay, gst_rtp_g729_depay, GstBaseRTPDepayload,
#define gst_rtp_g729_depay_parent_class parent_class
G_DEFINE_TYPE (GstRtpG729Depay, gst_rtp_g729_depay,
GST_TYPE_BASE_RTP_DEPAYLOAD);
static void
gst_rtp_g729_depay_base_init (gpointer klass)
gst_rtp_g729_depay_class_init (GstRtpG729DepayClass * klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GstElementClass *gstelement_class;
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
GST_DEBUG_CATEGORY_INIT (rtpg729depay_debug, "rtpg729depay", 0,
"G.729 RTP Depayloader");
gst_element_class_add_pad_template (element_class,
gstelement_class = (GstElementClass *) klass;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_g729_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_g729_depay_sink_template));
gst_element_class_set_details_simple (element_class, "RTP G.729 depayloader",
"Codec/Depayloader/Network/RTP",
gst_element_class_set_details_simple (gstelement_class,
"RTP G.729 depayloader", "Codec/Depayloader/Network/RTP",
"Extracts G.729 audio from RTP packets (RFC 3551)",
"Laurent Glayal <spglegle@yahoo.fr>");
GST_DEBUG_CATEGORY_INIT (rtpg729depay_debug, "rtpg729depay", 0,
"G.729 RTP Depayloader");
}
static void
gst_rtp_g729_depay_class_init (GstRtpG729DepayClass * klass)
{
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
gstbasertpdepayload_class->process = gst_rtp_g729_depay_process;
gstbasertpdepayload_class->set_caps = gst_rtp_g729_depay_setcaps;
}
static void
gst_rtp_g729_depay_init (GstRtpG729Depay * rtpg729depay,
GstRtpG729DepayClass * klass)
gst_rtp_g729_depay_init (GstRtpG729Depay * rtpg729depay)
{
GstBaseRTPDepayload *depayload;
......@@ -172,7 +168,6 @@ wrong_clock_rate:
}
}
static GstBuffer *
gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
{
......@@ -180,10 +175,13 @@ gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
GstBuffer *outbuf = NULL;
gint payload_len;
gboolean marker;
GstRTPBuffer rtp = { NULL };
rtpg729depay = GST_RTP_G729_DEPAY (depayload);
payload_len = gst_rtp_buffer_get_payload_len (buf);
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
/* At least 2 bytes (CNG from G729 Annex B) */
if (payload_len < 2) {
......@@ -198,8 +196,10 @@ gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
GST_LOG_OBJECT (rtpg729depay, "G729 payload contains CNG frame");
}
outbuf = gst_rtp_buffer_get_payload_buffer (buf);
marker = gst_rtp_buffer_get_marker (buf);
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
marker = gst_rtp_buffer_get_marker (&rtp);
gst_rtp_buffer_unmap (&rtp);
if (marker) {
/* marker bit starts talkspurt */
......@@ -207,7 +207,7 @@ gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
}
GST_LOG_OBJECT (depayload, "pushing buffer of size %d",
GST_BUFFER_SIZE (outbuf));
gst_buffer_get_size (outbuf));
return outbuf;
......
......@@ -74,26 +74,8 @@ static GstStaticPadTemplate gst_rtp_g729_pay_src_template =
"clock-rate = (int) 8000, " "encoding-name = (string) \"G729\"")
);
GST_BOILERPLATE (GstRTPG729Pay, gst_rtp_g729_pay, GstBaseRTPPayload,
GST_TYPE_BASE_RTP_PAYLOAD);
static void
gst_rtp_g729_pay_base_init (gpointer klass)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_g729_pay_sink_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_g729_pay_src_template));
gst_element_class_set_details_simple (element_class, "RTP G.729 payloader",
"Codec/Payloader/Network/RTP",
"Packetize G.729 audio into RTP packets",
"Olivier Crete <olivier.crete@collabora.co.uk>");
GST_DEBUG_CATEGORY_INIT (rtpg729pay_debug, "rtpg729pay", 0,
"G.729 RTP Payloader");
}
#define gst_rtp_g729_pay_parent_class parent_class
G_DEFINE_TYPE (GstRTPG729Pay, gst_rtp_g729_pay, GST_TYPE_BASE_RTP_PAYLOAD);
static void
gst_rtp_g729_pay_finalize (GObject * object)
......@@ -112,16 +94,29 @@ gst_rtp_g729_pay_class_init (GstRTPG729PayClass * klass)
GstElementClass *gstelement_class = (GstElementClass *) klass;
GstBaseRTPPayloadClass *payload_class = GST_BASE_RTP_PAYLOAD_CLASS (klass);
GST_DEBUG_CATEGORY_INIT (rtpg729pay_debug, "rtpg729pay", 0,
"G.729 RTP Payloader");
gobject_class->finalize = gst_rtp_g729_pay_finalize;
gstelement_class->change_state = gst_rtp_g729_pay_change_state;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_g729_pay_sink_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_g729_pay_src_template));
gst_element_class_set_details_simple (gstelement_class, "RTP G.729 payloader",
"Codec/Payloader/Network/RTP",
"Packetize G.729 audio into RTP packets",
"Olivier Crete <olivier.crete@collabora.co.uk>");
payload_class->set_caps = gst_rtp_g729_pay_set_caps;
payload_class->handle_buffer = gst_rtp_g729_pay_handle_buffer;
}
static void
gst_rtp_g729_pay_init (GstRTPG729Pay * pay, GstRTPG729PayClass * klass)
gst_rtp_g729_pay_init (GstRTPG729Pay * pay)
{
GstBaseRTPPayload *payload = GST_BASE_RTP_PAYLOAD (pay);
...