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 = ...@@ -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); GST_TYPE_BASE_RTP_DEPAYLOAD);
static gboolean gst_rtp_g722_depay_setcaps (GstBaseRTPDepayload * depayload, static gboolean gst_rtp_g722_depay_setcaps (GstBaseRTPDepayload * depayload,
...@@ -71,40 +72,34 @@ static GstBuffer *gst_rtp_g722_depay_process (GstBaseRTPDepayload * depayload, ...@@ -71,40 +72,34 @@ static GstBuffer *gst_rtp_g722_depay_process (GstBaseRTPDepayload * depayload,
GstBuffer * buf); GstBuffer * buf);
static void 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_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_static_pad_template_get (&gst_rtp_g722_depay_sink_template));
gst_element_class_set_details_simple (element_class, "RTP audio depayloader", gst_element_class_set_details_simple (gstelement_class,
"Codec/Depayloader/Network/RTP", "RTP audio depayloader", "Codec/Depayloader/Network/RTP",
"Extracts G722 audio from RTP packets", "Extracts G722 audio from RTP packets",
"Wim Taymans <wim.taymans@gmail.com>"); "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->set_caps = gst_rtp_g722_depay_setcaps;
gstbasertpdepayload_class->process = gst_rtp_g722_depay_process; gstbasertpdepayload_class->process = gst_rtp_g722_depay_process;
GST_DEBUG_CATEGORY_INIT (rtpg722depay_debug, "rtpg722depay", 0,
"G722 RTP Depayloader");
} }
static void static void
gst_rtp_g722_depay_init (GstRtpG722Depay * rtpg722depay, gst_rtp_g722_depay_init (GstRtpG722Depay * rtpg722depay)
GstRtpG722DepayClass * klass)
{ {
/* needed because of GST_BOILERPLATE */
} }
static gint static gint
...@@ -223,18 +218,22 @@ gst_rtp_g722_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) ...@@ -223,18 +218,22 @@ gst_rtp_g722_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
GstBuffer *outbuf; GstBuffer *outbuf;
gint payload_len; gint payload_len;
gboolean marker; gboolean marker;
GstRTPBuffer rtp = { NULL };
rtpg722depay = GST_RTP_G722_DEPAY (depayload); 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) if (payload_len <= 0)
goto empty_packet; goto empty_packet;
GST_DEBUG_OBJECT (rtpg722depay, "got payload of %d bytes", payload_len); GST_DEBUG_OBJECT (rtpg722depay, "got payload of %d bytes", payload_len);
outbuf = gst_rtp_buffer_get_payload_buffer (buf); outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
marker = gst_rtp_buffer_get_marker (buf); marker = gst_rtp_buffer_get_marker (&rtp);
gst_rtp_buffer_unmap (&rtp);
if (marker) { if (marker) {
/* mark talk spurt with DISCONT */ /* mark talk spurt with DISCONT */
...@@ -248,6 +247,7 @@ empty_packet: ...@@ -248,6 +247,7 @@ empty_packet:
{ {
GST_ELEMENT_WARNING (rtpg722depay, STREAM, DECODE, GST_ELEMENT_WARNING (rtpg722depay, STREAM, DECODE,
("Empty Payload."), (NULL)); ("Empty Payload."), (NULL));
gst_rtp_buffer_unmap (&rtp);
return NULL; return NULL;
} }
} }
......
...@@ -56,41 +56,38 @@ static gboolean gst_rtp_g722_pay_setcaps (GstBaseRTPPayload * basepayload, ...@@ -56,41 +56,38 @@ static gboolean gst_rtp_g722_pay_setcaps (GstBaseRTPPayload * basepayload,
static GstCaps *gst_rtp_g722_pay_getcaps (GstBaseRTPPayload * rtppayload, static GstCaps *gst_rtp_g722_pay_getcaps (GstBaseRTPPayload * rtppayload,
GstPad * pad); 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); GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
static void 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_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_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", "Codec/Payloader/Network/RTP",
"Payload-encode Raw audio into RTP packets (RFC 3551)", "Payload-encode Raw audio into RTP packets (RFC 3551)",
"Wim Taymans <wim.taymans@gmail.com>"); "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->set_caps = gst_rtp_g722_pay_setcaps;
gstbasertppayload_class->get_caps = gst_rtp_g722_pay_getcaps; gstbasertppayload_class->get_caps = gst_rtp_g722_pay_getcaps;
GST_DEBUG_CATEGORY_INIT (rtpg722pay_debug, "rtpg722pay", 0,
"G722 RTP Payloader");
} }
static void static void
gst_rtp_g722_pay_init (GstRtpG722Pay * rtpg722pay, GstRtpG722PayClass * klass) gst_rtp_g722_pay_init (GstRtpG722Pay * rtpg722pay)
{ {
GstBaseRTPAudioPayload *basertpaudiopayload; GstBaseRTPAudioPayload *basertpaudiopayload;
......
...@@ -78,42 +78,38 @@ static gboolean gst_rtp_g723_depay_setcaps (GstBaseRTPDepayload * depayload, ...@@ -78,42 +78,38 @@ static gboolean gst_rtp_g723_depay_setcaps (GstBaseRTPDepayload * depayload,
static GstBuffer *gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload, static GstBuffer *gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload,
GstBuffer * buf); 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); GST_TYPE_BASE_RTP_DEPAYLOAD);
static void 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_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_static_pad_template_get (&gst_rtp_g723_depay_sink_template));
gst_element_class_set_details_simple (element_class, "RTP G.723 depayloader", gst_element_class_set_details_simple (gstelement_class,
"Codec/Depayloader/Network/RTP", "RTP G.723 depayloader", "Codec/Depayloader/Network/RTP",
"Extracts G.723 audio from RTP packets (RFC 3551)", "Extracts G.723 audio from RTP packets (RFC 3551)",
"Wim Taymans <wim.taymans@gmail.com>"); "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->process = gst_rtp_g723_depay_process;
gstbasertpdepayload_class->set_caps = gst_rtp_g723_depay_setcaps; gstbasertpdepayload_class->set_caps = gst_rtp_g723_depay_setcaps;
} }
static void static void
gst_rtp_g723_depay_init (GstRtpG723Depay * rtpg723depay, gst_rtp_g723_depay_init (GstRtpG723Depay * rtpg723depay)
GstRtpG723DepayClass * klass)
{ {
GstBaseRTPDepayload *depayload; GstBaseRTPDepayload *depayload;
...@@ -182,10 +178,13 @@ gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) ...@@ -182,10 +178,13 @@ gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
GstBuffer *outbuf = NULL; GstBuffer *outbuf = NULL;
gint payload_len; gint payload_len;
gboolean marker; gboolean marker;
GstRTPBuffer rtp = { NULL };
rtpg723depay = GST_RTP_G723_DEPAY (depayload); 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 */ /* At least 4 bytes */
if (payload_len < 4) if (payload_len < 4)
...@@ -193,8 +192,9 @@ gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) ...@@ -193,8 +192,9 @@ gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
GST_LOG_OBJECT (rtpg723depay, "payload len %d", payload_len); GST_LOG_OBJECT (rtpg723depay, "payload len %d", payload_len);
outbuf = gst_rtp_buffer_get_payload_buffer (buf); outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
marker = gst_rtp_buffer_get_marker (buf); marker = gst_rtp_buffer_get_marker (&rtp);
gst_rtp_buffer_unmap (&rtp);
if (marker) { if (marker) {
/* marker bit starts talkspurt */ /* marker bit starts talkspurt */
...@@ -202,7 +202,7 @@ gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) ...@@ -202,7 +202,7 @@ gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
} }
GST_LOG_OBJECT (depayload, "pushing buffer of size %d", GST_LOG_OBJECT (depayload, "pushing buffer of size %d",
GST_BUFFER_SIZE (outbuf)); gst_buffer_get_size (outbuf));
return outbuf; return outbuf;
...@@ -216,6 +216,7 @@ too_small: ...@@ -216,6 +216,7 @@ too_small:
bad_packet: bad_packet:
{ {
/* no fatal error */ /* no fatal error */
gst_rtp_buffer_unmap (&rtp);
return NULL; return NULL;
} }
} }
......
...@@ -67,23 +67,8 @@ static void gst_rtp_g723_pay_finalize (GObject * object); ...@@ -67,23 +67,8 @@ static void gst_rtp_g723_pay_finalize (GObject * object);
static GstStateChangeReturn gst_rtp_g723_pay_change_state (GstElement * element, static GstStateChangeReturn gst_rtp_g723_pay_change_state (GstElement * element,
GstStateChange transition); GstStateChange transition);
GST_BOILERPLATE (GstRTPG723Pay, gst_rtp_g723_pay, GstBaseRTPPayload, #define gst_rtp_g723_pay_parent_class parent_class
GST_TYPE_BASE_RTP_PAYLOAD); G_DEFINE_TYPE (GstRTPG723Pay, gst_rtp_g723_pay, 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>");
}
static void static void
gst_rtp_g723_pay_class_init (GstRTPG723PayClass * klass) gst_rtp_g723_pay_class_init (GstRTPG723PayClass * klass)
...@@ -100,12 +85,22 @@ 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; 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->set_caps = gst_rtp_g723_pay_set_caps;
payload_class->handle_buffer = gst_rtp_g723_pay_handle_buffer; payload_class->handle_buffer = gst_rtp_g723_pay_handle_buffer;
} }
static void 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); GstBaseRTPPayload *payload = GST_BASE_RTP_PAYLOAD (pay);
...@@ -155,11 +150,14 @@ gst_rtp_g723_pay_flush (GstRTPG723Pay * pay) ...@@ -155,11 +150,14 @@ gst_rtp_g723_pay_flush (GstRTPG723Pay * pay)
GstFlowReturn ret; GstFlowReturn ret;
guint8 *payload; guint8 *payload;
guint avail; guint avail;
GstRTPBuffer rtp = { NULL };
avail = gst_adapter_available (pay->adapter); avail = gst_adapter_available (pay->adapter);
outbuf = gst_rtp_buffer_new_allocate (avail, 0, 0); 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_TIMESTAMP (outbuf) = pay->timestamp;
GST_BUFFER_DURATION (outbuf) = pay->duration; GST_BUFFER_DURATION (outbuf) = pay->duration;
...@@ -175,9 +173,10 @@ gst_rtp_g723_pay_flush (GstRTPG723Pay * pay) ...@@ -175,9 +173,10 @@ gst_rtp_g723_pay_flush (GstRTPG723Pay * pay)
/* set discont and marker */ /* set discont and marker */
if (pay->discont) { if (pay->discont) {
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_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; pay->discont = FALSE;
} }
gst_rtp_buffer_unmap (&rtp);
ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (pay), outbuf); ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (pay), outbuf);
...@@ -197,7 +196,7 @@ gst_rtp_g723_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf) ...@@ -197,7 +196,7 @@ gst_rtp_g723_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
{ {
GstFlowReturn ret = GST_FLOW_OK; GstFlowReturn ret = GST_FLOW_OK;
guint8 *data; guint8 *data;
guint size; gsize size;
guint8 HDR; guint8 HDR;
GstRTPG723Pay *pay; GstRTPG723Pay *pay;
GstClockTime packet_dur, timestamp; GstClockTime packet_dur, timestamp;
...@@ -205,8 +204,7 @@ gst_rtp_g723_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf) ...@@ -205,8 +204,7 @@ gst_rtp_g723_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
pay = GST_RTP_G723_PAY (payload); pay = GST_RTP_G723_PAY (payload);
size = GST_BUFFER_SIZE (buf); data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
data = GST_BUFFER_DATA (buf);
timestamp = GST_BUFFER_TIMESTAMP (buf); timestamp = GST_BUFFER_TIMESTAMP (buf);
if (GST_BUFFER_IS_DISCONT (buf)) { if (GST_BUFFER_IS_DISCONT (buf)) {
...@@ -244,6 +242,7 @@ gst_rtp_g723_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf) ...@@ -244,6 +242,7 @@ gst_rtp_g723_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
else else
pay->timestamp = 0; pay->timestamp = 0;
} }
gst_buffer_unmap (buf, data, size);
/* add packet to the queue */ /* add packet to the queue */
gst_adapter_push (pay->adapter, buf); gst_adapter_push (pay->adapter, buf);
...@@ -262,6 +261,7 @@ invalid_size: ...@@ -262,6 +261,7 @@ invalid_size:
GST_ELEMENT_WARNING (pay, STREAM, WRONG_TYPE, GST_ELEMENT_WARNING (pay, STREAM, WRONG_TYPE,
("Invalid input buffer size"), ("Invalid input buffer size"),
("Input size should be 4, 20 or 24, got %u", size)); ("Input size should be 4, 20 or 24, got %u", size));
gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf); gst_buffer_unref (buf);
return GST_FLOW_OK; return GST_FLOW_OK;
} }
...@@ -270,6 +270,7 @@ wrong_size: ...@@ -270,6 +270,7 @@ wrong_size:
GST_ELEMENT_WARNING (pay, STREAM, WRONG_TYPE, GST_ELEMENT_WARNING (pay, STREAM, WRONG_TYPE,
("Wrong input buffer size"), ("Wrong input buffer size"),
("Expected input buffer size %u but got %u", size_tab[HDR], size)); ("Expected input buffer size %u but got %u", size_tab[HDR], size));
gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf); gst_buffer_unref (buf);
return GST_FLOW_OK; return GST_FLOW_OK;
} }
......
...@@ -87,31 +87,22 @@ static GstBuffer *gst_rtp_g726_depay_process (GstBaseRTPDepayload * depayload, ...@@ -87,31 +87,22 @@ static GstBuffer *gst_rtp_g726_depay_process (GstBaseRTPDepayload * depayload,
static gboolean gst_rtp_g726_depay_setcaps (GstBaseRTPDepayload * depayload, static gboolean gst_rtp_g726_depay_setcaps (GstBaseRTPDepayload * depayload,
GstCaps * caps); 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); 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 static void
gst_rtp_g726_depay_class_init (GstRtpG726DepayClass * klass) gst_rtp_g726_depay_class_init (GstRtpG726DepayClass * klass)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseRTPDepayloadClass *gstbasertpdepayload_class; GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
GST_DEBUG_CATEGORY_INIT (rtpg726depay_debug, "rtpg726depay", 0,
"G.726 RTP Depayloader");
gobject_class = (GObjectClass *) klass; gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass; gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
gobject_class->set_property = gst_rtp_g726_depay_set_property; gobject_class->set_property = gst_rtp_g726_depay_set_property;
...@@ -122,16 +113,22 @@ gst_rtp_g726_depay_class_init (GstRtpG726DepayClass * klass) ...@@ -122,16 +113,22 @@ gst_rtp_g726_depay_class_init (GstRtpG726DepayClass * klass)
"Force AAL2 decoding for compatibility with bad payloaders", "Force AAL2 decoding for compatibility with bad payloaders",
DEFAULT_FORCE_AAL2, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); 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->process = gst_rtp_g726_depay_process;
gstbasertpdepayload_class->set_caps = gst_rtp_g726_depay_setcaps; gstbasertpdepayload_class->set_caps = gst_rtp_g726_depay_setcaps;
GST_DEBUG_CATEGORY_INIT (rtpg726depay_debug, "rtpg726depay", 0,
"G.726 RTP Depayloader");
} }
static void static void
gst_rtp_g726_depay_init (GstRtpG726Depay * rtpG726depay, gst_rtp_g726_depay_init (GstRtpG726Depay * rtpG726depay)
GstRtpG726DepayClass * klass)
{ {
GstBaseRTPDepayload *depayload; GstBaseRTPDepayload *depayload;
...@@ -210,36 +207,34 @@ gst_rtp_g726_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) ...@@ -210,36 +207,34 @@ gst_rtp_g726_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
GstRtpG726Depay *depay; GstRtpG726Depay *depay;
GstBuffer *outbuf = NULL; GstBuffer *outbuf = NULL;
gboolean marker; gboolean marker;
GstRTPBuffer rtp = { NULL };
depay = GST_RTP_G726_DEPAY (depayload); 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_DEBUG ("process : got %d bytes, mark %d ts %u seqn %d",
GST_BUFFER_SIZE (buf), marker, gst_buffer_get_size (buf), marker,
gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf)); gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
if (depay->aal2 || depay->force_aal2) { if (depay->aal2 || depay->force_aal2) {
/* AAL2, we can just copy the bytes */ /* AAL2, we can just copy the bytes */
outbuf = gst_rtp_buffer_get_payload_buffer (buf); outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
} else { } else {
guint8 *in, *out, tmp; guint8 *in, *out, tmp, *odata;
guint len; guint len;
gsize osize;
in = gst_rtp_buffer_get_payload (buf); in = gst_rtp_buffer_get_payload (&rtp);
len = gst_rtp_buffer_get_payload_len (buf); len = gst_rtp_buffer_get_payload_len (&rtp);
if (gst_buffer_is_writable (buf)) { outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
outbuf = gst_rtp_buffer_get_payload_buffer (buf); outbuf = gst_buffer_make_writable (outbuf);
} else {
GstBuffer *copy;
/* copy buffer */ odata = gst_buffer_map (outbuf, &osize, NULL, GST_MAP_WRITE);
copy = gst_buffer_copy (buf); out = odata;
outbuf = gst_rtp_buffer_get_payload_buffer (copy);
gst_buffer_unref (copy);
}
out = GST_BUFFER_DATA (outbuf);
/* we need to reshuffle the bytes, input is always of the form /* 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. */ * 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) ...@@ -327,6 +322,7 @@ gst_rtp_g726_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
break; break;
} }
} }
gst_buffer_unmap (outbuf, odata, osize);
} }
if (marker) { if (marker) {
......
...@@ -75,31 +75,19 @@ static gboolean gst_rtp_g726_pay_setcaps (GstBaseRTPPayload * payload, ...@@ -75,31 +75,19 @@ static gboolean gst_rtp_g726_pay_setcaps (GstBaseRTPPayload * payload,
static GstFlowReturn gst_rtp_g726_pay_handle_buffer (GstBaseRTPPayload * static GstFlowReturn gst_rtp_g726_pay_handle_buffer (GstBaseRTPPayload *
payload, GstBuffer * buffer); 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); 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 static void
gst_rtp_g726_pay_class_init (GstRtpG726PayClass * klass) gst_rtp_g726_pay_class_init (GstRtpG726PayClass * klass)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseRTPPayloadClass *gstbasertppayload_class; GstBaseRTPPayloadClass *gstbasertppayload_class;
gobject_class = (GObjectClass *) klass; gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass; gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
gobject_class->set_property = gst_rtp_g726_pay_set_property; gobject_class->set_property = gst_rtp_g726_pay_set_property;
...@@ -110,6 +98,16 @@ gst_rtp_g726_pay_class_init (GstRtpG726PayClass * klass) ...@@ -110,6 +98,16 @@ gst_rtp_g726_pay_class_init (GstRtpG726PayClass * klass)
"Force AAL2 encoding for compatibility with bad depayloaders", "Force AAL2 encoding for compatibility with bad depayloaders",
DEFAULT_FORCE_AAL2, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); 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->set_caps = gst_rtp_g726_pay_setcaps;
gstbasertppayload_class->handle_buffer = gst_rtp_g726_pay_handle_buffer; gstbasertppayload_class->handle_buffer = gst_rtp_g726_pay_handle_buffer;
...@@ -118,7 +116,7 @@ gst_rtp_g726_pay_class_init (GstRtpG726PayClass * klass) ...@@ -118,7 +116,7 @@ gst_rtp_g726_pay_class_init (GstRtpG726PayClass * klass)
} }