rtp: port more to 0.11

This commit is contained in:
Wim Taymans 2011-04-25 17:27:40 +02:00
parent 60db07b4bb
commit bf9b4f8362
19 changed files with 472 additions and 453 deletions

View file

@ -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,
@ -70,41 +71,35 @@ static gboolean gst_rtp_g722_depay_setcaps (GstBaseRTPDepayload * depayload,
static GstBuffer *gst_rtp_g722_depay_process (GstBaseRTPDepayload * depayload, static GstBuffer *gst_rtp_g722_depay_process (GstBaseRTPDepayload * depayload,
GstBuffer * buf); GstBuffer * buf);
static void
gst_rtp_g722_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_g722_depay_src_template));
gst_element_class_add_pad_template (element_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",
"Extracts G722 audio from RTP packets",
"Wim Taymans <wim.taymans@gmail.com>");
}
static void static void
gst_rtp_g722_depay_class_init (GstRtpG722DepayClass * klass) gst_rtp_g722_depay_class_init (GstRtpG722DepayClass * klass)
{ {
GstElementClass *gstelement_class;
GstBaseRTPDepayloadClass *gstbasertpdepayload_class; 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, GST_DEBUG_CATEGORY_INIT (rtpg722depay_debug, "rtpg722depay", 0,
"G722 RTP Depayloader"); "G722 RTP Depayloader");
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 (gstelement_class,
gst_static_pad_template_get (&gst_rtp_g722_depay_sink_template));
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>");
gstbasertpdepayload_class->set_caps = gst_rtp_g722_depay_setcaps;
gstbasertpdepayload_class->process = gst_rtp_g722_depay_process;
} }
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)
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:
{ {
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;
} }
} }

View file

@ -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
gst_rtp_g722_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_g722_pay_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_g722_pay_sink_template));
gst_element_class_set_details_simple (element_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 static void
gst_rtp_g722_pay_class_init (GstRtpG722PayClass * klass) gst_rtp_g722_pay_class_init (GstRtpG722PayClass * klass)
{ {
GstElementClass *gstelement_class;
GstBaseRTPPayloadClass *gstbasertppayload_class; 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, GST_DEBUG_CATEGORY_INIT (rtpg722pay_debug, "rtpg722pay", 0,
"G722 RTP Payloader"); "G722 RTP Payloader");
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 (gstelement_class,
gst_static_pad_template_get (&gst_rtp_g722_pay_sink_template));
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>");
gstbasertppayload_class->set_caps = gst_rtp_g722_pay_setcaps;
gstbasertppayload_class->get_caps = gst_rtp_g722_pay_getcaps;
} }
static void static void
gst_rtp_g722_pay_init (GstRtpG722Pay * rtpg722pay, GstRtpG722PayClass * klass) gst_rtp_g722_pay_init (GstRtpG722Pay * rtpg722pay)
{ {
GstBaseRTPAudioPayload *basertpaudiopayload; GstBaseRTPAudioPayload *basertpaudiopayload;

View file

@ -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
gst_rtp_g723_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_g723_depay_src_template));
gst_element_class_add_pad_template (element_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",
"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 static void
gst_rtp_g723_depay_class_init (GstRtpG723DepayClass * klass) gst_rtp_g723_depay_class_init (GstRtpG723DepayClass * klass)
{ {
GstElementClass *gstelement_class;
GstBaseRTPDepayloadClass *gstbasertpdepayload_class; GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
GST_DEBUG_CATEGORY_INIT (rtpg723depay_debug, "rtpg723depay", 0,
"G.723 RTP Depayloader");
gstelement_class = (GstElementClass *) klass;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) 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 (gstelement_class,
gst_static_pad_template_get (&gst_rtp_g723_depay_sink_template));
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>");
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)
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)
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)
} }
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:
bad_packet: bad_packet:
{ {
/* no fatal error */ /* no fatal error */
gst_rtp_buffer_unmap (&rtp);
return NULL; return NULL;
} }
} }

View file

@ -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)
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)
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)
/* 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)
{ {
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)
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)
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:
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:
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;
} }

View file

@ -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)
"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)
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)
break; break;
} }
} }
gst_buffer_unmap (outbuf, odata, osize);
} }
if (marker) { if (marker) {

View file

@ -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)
"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)
} }
static void static void
gst_rtp_g726_pay_init (GstRtpG726Pay * rtpg726pay, GstRtpG726PayClass * klass) gst_rtp_g726_pay_init (GstRtpG726Pay * rtpg726pay)
{ {
GstBaseRTPAudioPayload *basertpaudiopayload; GstBaseRTPAudioPayload *basertpaudiopayload;
@ -269,14 +267,13 @@ gst_rtp_g726_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
if (!pay->aal2) { if (!pay->aal2) {
guint8 *data, tmp; guint8 *data, tmp;
guint len; gsize len;
/* for non AAL2, we need to reshuffle the bytes, we can do this in-place /* for non AAL2, we need to reshuffle the bytes, we can do this in-place
* when the buffer is writable. */ * when the buffer is writable. */
buffer = gst_buffer_make_writable (buffer); buffer = gst_buffer_make_writable (buffer);
data = GST_BUFFER_DATA (buffer); data = gst_buffer_map (buffer, &len, NULL, GST_MAP_READWRITE);
len = GST_BUFFER_SIZE (buffer);
GST_LOG_OBJECT (pay, "packing %u bytes of data", len); 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; break;
} }
} }
gst_buffer_unmap (buffer, data, len);
} }
res = res =

View file

@ -76,42 +76,38 @@ static gboolean gst_rtp_g729_depay_setcaps (GstBaseRTPDepayload * depayload,
static GstBuffer *gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload, static GstBuffer *gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload,
GstBuffer * buf); 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); GST_TYPE_BASE_RTP_DEPAYLOAD);
static void
gst_rtp_g729_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_g729_depay_src_template));
gst_element_class_add_pad_template (element_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",
"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 static void
gst_rtp_g729_depay_class_init (GstRtpG729DepayClass * klass) gst_rtp_g729_depay_class_init (GstRtpG729DepayClass * klass)
{ {
GstElementClass *gstelement_class;
GstBaseRTPDepayloadClass *gstbasertpdepayload_class; GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
GST_DEBUG_CATEGORY_INIT (rtpg729depay_debug, "rtpg729depay", 0,
"G.729 RTP Depayloader");
gstelement_class = (GstElementClass *) klass;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) 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 (gstelement_class,
gst_static_pad_template_get (&gst_rtp_g729_depay_sink_template));
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>");
gstbasertpdepayload_class->process = gst_rtp_g729_depay_process; gstbasertpdepayload_class->process = gst_rtp_g729_depay_process;
gstbasertpdepayload_class->set_caps = gst_rtp_g729_depay_setcaps; gstbasertpdepayload_class->set_caps = gst_rtp_g729_depay_setcaps;
} }
static void static void
gst_rtp_g729_depay_init (GstRtpG729Depay * rtpg729depay, gst_rtp_g729_depay_init (GstRtpG729Depay * rtpg729depay)
GstRtpG729DepayClass * klass)
{ {
GstBaseRTPDepayload *depayload; GstBaseRTPDepayload *depayload;
@ -172,7 +168,6 @@ wrong_clock_rate:
} }
} }
static GstBuffer * static GstBuffer *
gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) 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; GstBuffer *outbuf = NULL;
gint payload_len; gint payload_len;
gboolean marker; gboolean marker;
GstRTPBuffer rtp = { NULL };
rtpg729depay = GST_RTP_G729_DEPAY (depayload); 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) */ /* At least 2 bytes (CNG from G729 Annex B) */
if (payload_len < 2) { 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"); GST_LOG_OBJECT (rtpg729depay, "G729 payload contains CNG frame");
} }
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 */
@ -207,7 +207,7 @@ gst_rtp_g729_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;

View file

@ -74,26 +74,8 @@ static GstStaticPadTemplate gst_rtp_g729_pay_src_template =
"clock-rate = (int) 8000, " "encoding-name = (string) \"G729\"") "clock-rate = (int) 8000, " "encoding-name = (string) \"G729\"")
); );
GST_BOILERPLATE (GstRTPG729Pay, gst_rtp_g729_pay, GstBaseRTPPayload, #define gst_rtp_g729_pay_parent_class parent_class
GST_TYPE_BASE_RTP_PAYLOAD); G_DEFINE_TYPE (GstRTPG729Pay, gst_rtp_g729_pay, 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");
}
static void static void
gst_rtp_g729_pay_finalize (GObject * object) gst_rtp_g729_pay_finalize (GObject * object)
@ -112,16 +94,29 @@ gst_rtp_g729_pay_class_init (GstRTPG729PayClass * klass)
GstElementClass *gstelement_class = (GstElementClass *) klass; GstElementClass *gstelement_class = (GstElementClass *) klass;
GstBaseRTPPayloadClass *payload_class = GST_BASE_RTP_PAYLOAD_CLASS (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; gobject_class->finalize = gst_rtp_g729_pay_finalize;
gstelement_class->change_state = gst_rtp_g729_pay_change_state; 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->set_caps = gst_rtp_g729_pay_set_caps;
payload_class->handle_buffer = gst_rtp_g729_pay_handle_buffer; payload_class->handle_buffer = gst_rtp_g729_pay_handle_buffer;
} }
static void 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); GstBaseRTPPayload *payload = GST_BASE_RTP_PAYLOAD (pay);
@ -170,6 +165,7 @@ gst_rtp_g729_pay_push (GstRTPG729Pay * rtpg729pay,
GstBuffer *outbuf; GstBuffer *outbuf;
guint8 *payload; guint8 *payload;
GstFlowReturn ret; GstFlowReturn ret;
GstRTPBuffer rtp = { NULL };
basepayload = GST_BASE_RTP_PAYLOAD (rtpg729pay); basepayload = GST_BASE_RTP_PAYLOAD (rtpg729pay);
@ -179,8 +175,10 @@ gst_rtp_g729_pay_push (GstRTPG729Pay * rtpg729pay,
/* create buffer to hold the payload */ /* create buffer to hold the payload */
outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0); outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
gst_rtp_buffer_map (outbuf, GST_MAP_READWRITE, &rtp);
/* copy payload */ /* copy payload */
payload = gst_rtp_buffer_get_payload (outbuf); payload = gst_rtp_buffer_get_payload (&rtp);
memcpy (payload, data, payload_len); memcpy (payload, data, payload_len);
/* set metadata */ /* set metadata */
@ -196,9 +194,10 @@ gst_rtp_g729_pay_push (GstRTPG729Pay * rtpg729pay,
if (G_UNLIKELY (rtpg729pay->discont)) { if (G_UNLIKELY (rtpg729pay->discont)) {
GST_DEBUG_OBJECT (basepayload, "discont, setting marker bit"); GST_DEBUG_OBJECT (basepayload, "discont, setting marker bit");
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);
rtpg729pay->discont = FALSE; rtpg729pay->discont = FALSE;
} }
gst_rtp_buffer_unmap (&rtp);
ret = gst_basertppayload_push (basepayload, outbuf); ret = gst_basertppayload_push (basepayload, outbuf);
@ -235,11 +234,13 @@ gst_rtp_g729_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
guint minptime_octets = 0; guint minptime_octets = 0;
guint min_payload_len; guint min_payload_len;
guint max_payload_len; guint max_payload_len;
gsize size;
GstClockTime timestamp;
available = GST_BUFFER_SIZE (buf); size = gst_buffer_get_size (buf);
if (available % G729_FRAME_SIZE != 0 && if (size % G729_FRAME_SIZE != 0 &&
available % G729_FRAME_SIZE != G729B_CN_FRAME_SIZE) size % G729_FRAME_SIZE != G729B_CN_FRAME_SIZE)
goto invalid_size; goto invalid_size;
/* max number of bytes based on given ptime, has to be multiple of /* max number of bytes based on given ptime, has to be multiple of
@ -302,6 +303,8 @@ gst_rtp_g729_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
adapter = rtpg729pay->adapter; adapter = rtpg729pay->adapter;
available = gst_adapter_available (adapter); available = gst_adapter_available (adapter);
timestamp = GST_BUFFER_TIMESTAMP (buf);
/* resync rtp time on discont or a discontinuous cn packet */ /* resync rtp time on discont or a discontinuous cn packet */
if (GST_BUFFER_IS_DISCONT (buf)) { if (GST_BUFFER_IS_DISCONT (buf)) {
/* flush remainder */ /* flush remainder */
@ -311,26 +314,27 @@ gst_rtp_g729_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
available = 0; available = 0;
} }
rtpg729pay->discont = TRUE; rtpg729pay->discont = TRUE;
gst_rtp_g729_pay_recalc_rtp_time (rtpg729pay, GST_BUFFER_TIMESTAMP (buf)); gst_rtp_g729_pay_recalc_rtp_time (rtpg729pay, timestamp);
} }
if (GST_BUFFER_SIZE (buf) < G729_FRAME_SIZE) if (size < G729_FRAME_SIZE)
gst_rtp_g729_pay_recalc_rtp_time (rtpg729pay, GST_BUFFER_TIMESTAMP (buf)); gst_rtp_g729_pay_recalc_rtp_time (rtpg729pay, timestamp);
if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (rtpg729pay->first_ts))) { if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (rtpg729pay->first_ts))) {
rtpg729pay->first_ts = GST_BUFFER_TIMESTAMP (buf); rtpg729pay->first_ts = timestamp;
rtpg729pay->first_rtp_time = rtpg729pay->next_rtp_time; rtpg729pay->first_rtp_time = rtpg729pay->next_rtp_time;
} }
/* let's reset the base timestamp when the adapter is empty */ /* let's reset the base timestamp when the adapter is empty */
if (available == 0) if (available == 0)
rtpg729pay->next_ts = GST_BUFFER_TIMESTAMP (buf); rtpg729pay->next_ts = timestamp;
if (available == 0 && if (available == 0 && size >= min_payload_len && size <= max_payload_len) {
GST_BUFFER_SIZE (buf) >= min_payload_len && guint8 *data;
GST_BUFFER_SIZE (buf) <= max_payload_len) {
ret = gst_rtp_g729_pay_push (rtpg729pay, data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); ret = gst_rtp_g729_pay_push (rtpg729pay, data, size);
gst_buffer_unmap (buf, data, size);
gst_buffer_unref (buf); gst_buffer_unref (buf);
return ret; return ret;
} }
@ -364,7 +368,7 @@ invalid_size:
("Invalid input buffer size"), ("Invalid input buffer size"),
("Invalid buffer size, should be a multiple of" ("Invalid buffer size, should be a multiple of"
" G729_FRAME_SIZE(10) with an optional G729B_CN_FRAME_SIZE(2)" " G729_FRAME_SIZE(10) with an optional G729B_CN_FRAME_SIZE(2)"
" added to it, but it is %u", available)); " added to it, but it is %u", size));
gst_buffer_unref (buf); gst_buffer_unref (buf);
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }

View file

@ -62,30 +62,27 @@ static GstBuffer *gst_rtp_gsm_depay_process (GstBaseRTPDepayload * _depayload,
static gboolean gst_rtp_gsm_depay_setcaps (GstBaseRTPDepayload * _depayload, static gboolean gst_rtp_gsm_depay_setcaps (GstBaseRTPDepayload * _depayload,
GstCaps * caps); GstCaps * caps);
GST_BOILERPLATE (GstRTPGSMDepay, gst_rtp_gsm_depay, GstBaseRTPDepayload, #define gst_rtp_gsm_depay_parent_class parent_class
GST_TYPE_BASE_RTP_DEPAYLOAD); G_DEFINE_TYPE (GstRTPGSMDepay, gst_rtp_gsm_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
static void
gst_rtp_gsm_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_gsm_depay_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_gsm_depay_sink_template));
gst_element_class_set_details_simple (element_class, "RTP GSM depayloader",
"Codec/Depayloader/Network/RTP",
"Extracts GSM audio from RTP packets", "Zeeshan Ali <zeenix@gmail.com>");
}
static void static void
gst_rtp_gsm_depay_class_init (GstRTPGSMDepayClass * klass) gst_rtp_gsm_depay_class_init (GstRTPGSMDepayClass * klass)
{ {
GstElementClass *gstelement_class;
GstBaseRTPDepayloadClass *gstbasertp_depayload_class; GstBaseRTPDepayloadClass *gstbasertp_depayload_class;
gstelement_class = (GstElementClass *) klass;
gstbasertp_depayload_class = (GstBaseRTPDepayloadClass *) klass; gstbasertp_depayload_class = (GstBaseRTPDepayloadClass *) klass;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_gsm_depay_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_gsm_depay_sink_template));
gst_element_class_set_details_simple (gstelement_class, "RTP GSM depayloader",
"Codec/Depayloader/Network/RTP",
"Extracts GSM audio from RTP packets", "Zeeshan Ali <zeenix@gmail.com>");
gstbasertp_depayload_class->process = gst_rtp_gsm_depay_process; gstbasertp_depayload_class->process = gst_rtp_gsm_depay_process;
gstbasertp_depayload_class->set_caps = gst_rtp_gsm_depay_setcaps; gstbasertp_depayload_class->set_caps = gst_rtp_gsm_depay_setcaps;
@ -94,10 +91,8 @@ gst_rtp_gsm_depay_class_init (GstRTPGSMDepayClass * klass)
} }
static void static void
gst_rtp_gsm_depay_init (GstRTPGSMDepay * rtpgsmdepay, gst_rtp_gsm_depay_init (GstRTPGSMDepay * rtpgsmdepay)
GstRTPGSMDepayClass * klass)
{ {
/* needed because of GST_BOILERPLATE */
} }
static gboolean static gboolean
@ -127,14 +122,19 @@ gst_rtp_gsm_depay_process (GstBaseRTPDepayload * _depayload, GstBuffer * buf)
{ {
GstBuffer *outbuf = NULL; GstBuffer *outbuf = NULL;
gboolean marker; gboolean marker;
GstRTPBuffer rtp = { NULL };
marker = gst_rtp_buffer_get_marker (buf); gst_rtp_buffer_map (buf, GST_MAP_READ, &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));
outbuf = gst_rtp_buffer_get_payload_buffer (buf); outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
gst_rtp_buffer_unmap (&rtp);
if (marker) { if (marker) {
/* mark start of talkspurt with DISCONT */ /* mark start of talkspurt with DISCONT */

View file

@ -57,40 +57,37 @@ static gboolean gst_rtp_gsm_pay_setcaps (GstBaseRTPPayload * payload,
static GstFlowReturn gst_rtp_gsm_pay_handle_buffer (GstBaseRTPPayload * payload, static GstFlowReturn gst_rtp_gsm_pay_handle_buffer (GstBaseRTPPayload * payload,
GstBuffer * buffer); GstBuffer * buffer);
GST_BOILERPLATE (GstRTPGSMPay, gst_rtp_gsm_pay, GstBaseRTPPayload, #define gst_rtp_gsm_pay_parent_class parent_class
GST_TYPE_BASE_RTP_PAYLOAD); G_DEFINE_TYPE (GstRTPGSMPay, gst_rtp_gsm_pay, GST_TYPE_BASE_RTP_PAYLOAD);
static void
gst_rtp_gsm_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_gsm_pay_sink_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_gsm_pay_src_template));
gst_element_class_set_details_simple (element_class, "RTP GSM payloader",
"Codec/Payloader/Network/RTP",
"Payload-encodes GSM audio into a RTP packet",
"Zeeshan Ali <zeenix@gmail.com>");
}
static void static void
gst_rtp_gsm_pay_class_init (GstRTPGSMPayClass * klass) gst_rtp_gsm_pay_class_init (GstRTPGSMPayClass * klass)
{ {
GstElementClass *gstelement_class;
GstBaseRTPPayloadClass *gstbasertppayload_class; GstBaseRTPPayloadClass *gstbasertppayload_class;
gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
gstbasertppayload_class->set_caps = gst_rtp_gsm_pay_setcaps;
gstbasertppayload_class->handle_buffer = gst_rtp_gsm_pay_handle_buffer;
GST_DEBUG_CATEGORY_INIT (rtpgsmpay_debug, "rtpgsmpay", 0, GST_DEBUG_CATEGORY_INIT (rtpgsmpay_debug, "rtpgsmpay", 0,
"GSM Audio RTP Payloader"); "GSM Audio RTP Payloader");
gstelement_class = (GstElementClass *) klass;
gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_gsm_pay_sink_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_gsm_pay_src_template));
gst_element_class_set_details_simple (gstelement_class, "RTP GSM payloader",
"Codec/Payloader/Network/RTP",
"Payload-encodes GSM audio into a RTP packet",
"Zeeshan Ali <zeenix@gmail.com>");
gstbasertppayload_class->set_caps = gst_rtp_gsm_pay_setcaps;
gstbasertppayload_class->handle_buffer = gst_rtp_gsm_pay_handle_buffer;
} }
static void static void
gst_rtp_gsm_pay_init (GstRTPGSMPay * rtpgsmpay, GstRTPGSMPayClass * klass) gst_rtp_gsm_pay_init (GstRTPGSMPay * rtpgsmpay)
{ {
GST_BASE_RTP_PAYLOAD (rtpgsmpay)->clock_rate = 8000; GST_BASE_RTP_PAYLOAD (rtpgsmpay)->clock_rate = 8000;
GST_BASE_RTP_PAYLOAD_PT (rtpgsmpay) = GST_RTP_PAYLOAD_GSM; GST_BASE_RTP_PAYLOAD_PT (rtpgsmpay) = GST_RTP_PAYLOAD_GSM;
@ -128,15 +125,18 @@ gst_rtp_gsm_pay_handle_buffer (GstBaseRTPPayload * basepayload,
GstBuffer * buffer) GstBuffer * buffer)
{ {
GstRTPGSMPay *rtpgsmpay; GstRTPGSMPay *rtpgsmpay;
guint size, payload_len; guint payload_len;
GstBuffer *outbuf; GstBuffer *outbuf;
guint8 *payload, *data; guint8 *payload, *data;
GstClockTime timestamp, duration; GstClockTime timestamp, duration;
GstFlowReturn ret; GstFlowReturn ret;
gsize size;
GstRTPBuffer rtp = { NULL };
rtpgsmpay = GST_RTP_GSM_PAY (basepayload); rtpgsmpay = GST_RTP_GSM_PAY (basepayload);
size = GST_BUFFER_SIZE (buffer); data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
timestamp = GST_BUFFER_TIMESTAMP (buffer); timestamp = GST_BUFFER_TIMESTAMP (buffer);
duration = GST_BUFFER_DURATION (buffer); duration = GST_BUFFER_DURATION (buffer);
@ -144,12 +144,8 @@ gst_rtp_gsm_pay_handle_buffer (GstBaseRTPPayload * basepayload,
payload_len = size; payload_len = size;
/* FIXME, just error out for now */ /* FIXME, just error out for now */
if (payload_len > GST_BASE_RTP_PAYLOAD_MTU (rtpgsmpay)) { if (payload_len > GST_BASE_RTP_PAYLOAD_MTU (rtpgsmpay))
GST_ELEMENT_ERROR (rtpgsmpay, STREAM, ENCODE, (NULL), goto too_big;
("payload_len %u > mtu %u", payload_len,
GST_BASE_RTP_PAYLOAD_MTU (rtpgsmpay)));
return GST_FLOW_ERROR;
}
outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0); outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
@ -158,21 +154,33 @@ gst_rtp_gsm_pay_handle_buffer (GstBaseRTPPayload * basepayload,
GST_BUFFER_DURATION (outbuf) = duration; GST_BUFFER_DURATION (outbuf) = duration;
/* get payload */ /* get payload */
payload = gst_rtp_buffer_get_payload (outbuf); gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
data = GST_BUFFER_DATA (buffer);
/* copy data in payload */ /* copy data in payload */
memcpy (&payload[0], data, size); payload = gst_rtp_buffer_get_payload (&rtp);
memcpy (payload, data, size);
gst_rtp_buffer_unmap (&rtp);
gst_buffer_unmap (buffer, data, size);
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
GST_DEBUG ("gst_rtp_gsm_pay_chain: pushing buffer of size %d", GST_DEBUG ("gst_rtp_gsm_pay_chain: pushing buffer of size %d",
GST_BUFFER_SIZE (outbuf)); gst_buffer_get_size (outbuf));
ret = gst_basertppayload_push (basepayload, outbuf); ret = gst_basertppayload_push (basepayload, outbuf);
return ret; return ret;
/* ERRORS */
too_big:
{
GST_ELEMENT_ERROR (rtpgsmpay, STREAM, ENCODE, (NULL),
("payload_len %u > mtu %u", payload_len,
GST_BASE_RTP_PAYLOAD_MTU (rtpgsmpay)));
gst_buffer_unmap (buffer, data, size);
return GST_FLOW_ERROR;
}
} }
gboolean gboolean

View file

@ -890,9 +890,8 @@ gst_rtp_h263_pay_move_window_right (GstRtpH263PayContext * context, guint n,
} else { } else {
if (n > rest_bits) { if (n > rest_bits) {
context->window = context->window =
(context-> (context->window << rest_bits) | (*context->
window << rest_bits) | (*context->win_end & (((guint) pow (2.0, win_end & (((guint) pow (2.0, (double) rest_bits)) - 1));
(double) rest_bits)) - 1));
n -= rest_bits; n -= rest_bits;
rest_bits = 0; rest_bits = 0;
} else { } else {
@ -1654,8 +1653,8 @@ gst_rtp_h263_pay_flush (GstRtpH263Pay * rtph263pay)
gst_rtp_h263_pay_boundry_init (&bound, NULL, rtph263pay->data - 1, 0, 0); gst_rtp_h263_pay_boundry_init (&bound, NULL, rtph263pay->data - 1, 0, 0);
context->gobs = context->gobs =
(GstRtpH263PayGob **) g_malloc0 (format_props[context-> (GstRtpH263PayGob **) g_malloc0 (format_props[context->piclayer->
piclayer->ptype_srcformat][0] * sizeof (GstRtpH263PayGob *)); ptype_srcformat][0] * sizeof (GstRtpH263PayGob *));
for (i = 0; i < format_props[context->piclayer->ptype_srcformat][0]; i++) { for (i = 0; i < format_props[context->piclayer->ptype_srcformat][0]; i++) {

View file

@ -1,5 +1,5 @@
/* GStreamer /* GStreamer
* Copyright (C) <2005> Wim Taymans <wim@fluendo.com> * Copyright (C) <2005> Wim Taymans <wim.taymans@gmail.com>
* *
* 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

View file

@ -69,8 +69,9 @@ typedef struct _GstADUFrame
GstBuffer *buffer; GstBuffer *buffer;
} GstADUFrame; } GstADUFrame;
GST_BOILERPLATE (GstRtpMPARobustDepay, gst_rtp_mpa_robust_depay, #define gst_rtp_mpa_robust_depay_parent_class parent_class
GstBaseRTPDepayload, GST_TYPE_BASE_RTP_DEPAYLOAD); G_DEFINE_TYPE (GstRtpMPARobustDepay, gst_rtp_mpa_robust_depay,
GST_TYPE_BASE_RTP_DEPAYLOAD);
static GstStateChangeReturn gst_rtp_mpa_robust_change_state (GstElement * static GstStateChangeReturn gst_rtp_mpa_robust_change_state (GstElement *
element, GstStateChange transition); element, GstStateChange transition);
@ -80,22 +81,6 @@ static gboolean gst_rtp_mpa_robust_depay_setcaps (GstBaseRTPDepayload *
static GstBuffer *gst_rtp_mpa_robust_depay_process (GstBaseRTPDepayload * static GstBuffer *gst_rtp_mpa_robust_depay_process (GstBaseRTPDepayload *
depayload, GstBuffer * buf); depayload, GstBuffer * buf);
static void
gst_rtp_mpa_robust_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_mpa_robust_depay_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_mpa_robust_depay_sink_template));
gst_element_class_set_details_simple (element_class,
"RTP MPEG audio depayloader", "Codec/Depayloader/Network/RTP",
"Extracts MPEG audio from RTP packets (RFC 5219)",
"Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>");
}
static void static void
gst_rtp_mpa_robust_depay_finalize (GObject * object) gst_rtp_mpa_robust_depay_finalize (GObject * object)
{ {
@ -109,7 +94,6 @@ gst_rtp_mpa_robust_depay_finalize (GObject * object)
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
static void static void
gst_rtp_mpa_robust_depay_class_init (GstRtpMPARobustDepayClass * klass) gst_rtp_mpa_robust_depay_class_init (GstRtpMPARobustDepayClass * klass)
{ {
@ -117,6 +101,9 @@ gst_rtp_mpa_robust_depay_class_init (GstRtpMPARobustDepayClass * klass)
GstElementClass *gstelement_class; GstElementClass *gstelement_class;
GstBaseRTPDepayloadClass *gstbasertpdepayload_class; GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
GST_DEBUG_CATEGORY_INIT (rtpmparobustdepay_debug, "rtpmparobustdepay", 0,
"Robust MPEG Audio RTP Depayloader");
gobject_class = (GObjectClass *) klass; gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass; gstelement_class = (GstElementClass *) klass;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass; gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
@ -126,16 +113,22 @@ gst_rtp_mpa_robust_depay_class_init (GstRtpMPARobustDepayClass * klass)
gstelement_class->change_state = gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_rtp_mpa_robust_change_state); GST_DEBUG_FUNCPTR (gst_rtp_mpa_robust_change_state);
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_mpa_robust_depay_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_mpa_robust_depay_sink_template));
gst_element_class_set_details_simple (gstelement_class,
"RTP MPEG audio depayloader", "Codec/Depayloader/Network/RTP",
"Extracts MPEG audio from RTP packets (RFC 5219)",
"Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>");
gstbasertpdepayload_class->set_caps = gst_rtp_mpa_robust_depay_setcaps; gstbasertpdepayload_class->set_caps = gst_rtp_mpa_robust_depay_setcaps;
gstbasertpdepayload_class->process = gst_rtp_mpa_robust_depay_process; gstbasertpdepayload_class->process = gst_rtp_mpa_robust_depay_process;
GST_DEBUG_CATEGORY_INIT (rtpmparobustdepay_debug, "rtpmparobustdepay", 0,
"Robust MPEG Audio RTP Depayloader");
} }
static void static void
gst_rtp_mpa_robust_depay_init (GstRtpMPARobustDepay * rtpmpadepay, gst_rtp_mpa_robust_depay_init (GstRtpMPARobustDepay * rtpmpadepay)
GstRtpMPARobustDepayClass * klass)
{ {
rtpmpadepay->adapter = gst_adapter_new (); rtpmpadepay->adapter = gst_adapter_new ();
rtpmpadepay->adu_frames = g_queue_new (); rtpmpadepay->adu_frames = g_queue_new ();
@ -280,6 +273,8 @@ gst_rtp_mpa_robust_depay_generate_dummy_frame (GstRtpMPARobustDepay *
rtpmpadepay, GstADUFrame * frame) rtpmpadepay, GstADUFrame * frame)
{ {
GstADUFrame *dummy; GstADUFrame *dummy;
guint8 *data;
gsize size;
dummy = g_slice_dup (GstADUFrame, frame); dummy = g_slice_dup (GstADUFrame, frame);
@ -292,8 +287,12 @@ gst_rtp_mpa_robust_depay_generate_dummy_frame (GstRtpMPARobustDepay *
dummy->backpointer = 0; dummy->backpointer = 0;
dummy->buffer = gst_buffer_new_and_alloc (dummy->side_info + 4); dummy->buffer = gst_buffer_new_and_alloc (dummy->side_info + 4);
memset (GST_BUFFER_DATA (dummy->buffer), 0, dummy->side_info + 4);
GST_WRITE_UINT32_BE (GST_BUFFER_DATA (dummy->buffer), dummy->header); data = gst_buffer_map (dummy->buffer, &size, NULL, GST_MAP_WRITE);
memset (data, 0, size);
GST_WRITE_UINT32_BE (data, dummy->header);
gst_buffer_unmap (dummy->buffer, data, size);
GST_BUFFER_TIMESTAMP (dummy->buffer) = GST_BUFFER_TIMESTAMP (frame->buffer); GST_BUFFER_TIMESTAMP (dummy->buffer) = GST_BUFFER_TIMESTAMP (frame->buffer);
return dummy; return dummy;
@ -309,15 +308,18 @@ gst_rtp_mpa_robust_depay_queue_frame (GstRtpMPARobustDepay * rtpmpadepay,
GstADUFrame *frame = NULL; GstADUFrame *frame = NULL;
guint version, layer, channels, size; guint version, layer, channels, size;
guint crc; guint crc;
guint8 *bdata;
gsize bsize;
g_return_val_if_fail (buf != NULL, FALSE); g_return_val_if_fail (buf != NULL, FALSE);
if (GST_BUFFER_SIZE (buf) < 6) { bdata = gst_buffer_map (buf, &bsize, NULL, GST_MAP_READ);
if (bsize < 6)
goto corrupt_frame; goto corrupt_frame;
}
frame = g_slice_new0 (GstADUFrame); frame = g_slice_new0 (GstADUFrame);
frame->header = GST_READ_UINT32_BE (GST_BUFFER_DATA (buf)); frame->header = GST_READ_UINT32_BE (bdata);
size = mp3_type_frame_length_from_header (GST_ELEMENT_CAST (rtpmpadepay), size = mp3_type_frame_length_from_header (GST_ELEMENT_CAST (rtpmpadepay),
frame->header, &version, &layer, &channels, NULL, NULL, NULL, &crc); frame->header, &version, &layer, &channels, NULL, NULL, NULL, &crc);
@ -339,7 +341,7 @@ gst_rtp_mpa_robust_depay_queue_frame (GstRtpMPARobustDepay * rtpmpadepay,
/* backpointer */ /* backpointer */
if (layer == 3) { if (layer == 3) {
frame->backpointer = GST_READ_UINT16_BE (GST_BUFFER_DATA (buf) + 4); frame->backpointer = GST_READ_UINT16_BE (bdata + 4);
frame->backpointer >>= 7; frame->backpointer >>= 7;
GST_LOG_OBJECT (rtpmpadepay, "backpointer: %d", frame->backpointer); GST_LOG_OBJECT (rtpmpadepay, "backpointer: %d", frame->backpointer);
} }
@ -351,14 +353,16 @@ gst_rtp_mpa_robust_depay_queue_frame (GstRtpMPARobustDepay * rtpmpadepay,
frame->data_size = frame->size - 4 - frame->side_info; frame->data_size = frame->size - 4 - frame->side_info;
/* some size validation checks */ /* some size validation checks */
if (4 + frame->side_info > GST_BUFFER_SIZE (buf)) if (4 + frame->side_info > bsize)
goto corrupt_frame; goto corrupt_frame;
/* ADU data would then extend past MP3 frame, /* ADU data would then extend past MP3 frame,
* even using past byte reservoir */ * even using past byte reservoir */
if (-frame->backpointer + (gint) (GST_BUFFER_SIZE (buf)) > frame->size) if (-frame->backpointer + (gint) (bsize) > frame->size)
goto corrupt_frame; goto corrupt_frame;
gst_buffer_unmap (buf, bdata, bsize);
/* ok, take buffer and queue */ /* ok, take buffer and queue */
frame->buffer = buf; frame->buffer = buf;
g_queue_push_tail (rtpmpadepay->adu_frames, frame); g_queue_push_tail (rtpmpadepay->adu_frames, frame);
@ -369,6 +373,7 @@ gst_rtp_mpa_robust_depay_queue_frame (GstRtpMPARobustDepay * rtpmpadepay,
corrupt_frame: corrupt_frame:
{ {
GST_DEBUG_OBJECT (rtpmpadepay, "frame is corrupt"); GST_DEBUG_OBJECT (rtpmpadepay, "frame is corrupt");
gst_buffer_unmap (buf, bdata, bsize);
gst_buffer_unref (buf); gst_buffer_unref (buf);
if (frame) if (frame)
g_slice_free (GstADUFrame, frame); g_slice_free (GstADUFrame, frame);
@ -409,10 +414,13 @@ gst_rtp_mpa_robust_depay_deinterleave (GstRtpMPARobustDepay * rtpmpadepay,
{ {
gboolean ret = FALSE; gboolean ret = FALSE;
guint8 *data; guint8 *data;
gsize size;
guint val, iindex, icc; guint val, iindex, icc;
data = GST_BUFFER_DATA (buf); data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
val = GST_READ_UINT16_BE (data) >> 5; val = GST_READ_UINT16_BE (data) >> 5;
gst_buffer_unmap (buf, data, size);
iindex = val >> 3; iindex = val >> 3;
icc = val & 0x7; icc = val & 0x7;
@ -468,6 +476,8 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
GstFlowReturn ret = GST_FLOW_OK; GstFlowReturn ret = GST_FLOW_OK;
while (1) { while (1) {
guint8 *data;
gsize size;
if (G_UNLIKELY (!rtpmpadepay->cur_adu_frame)) { if (G_UNLIKELY (!rtpmpadepay->cur_adu_frame)) {
rtpmpadepay->cur_adu_frame = rtpmpadepay->adu_frames->head; rtpmpadepay->cur_adu_frame = rtpmpadepay->adu_frames->head;
@ -495,7 +505,7 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
continue; continue;
} }
if (rtpmpadepay->offset == GST_BUFFER_SIZE (frame->buffer)) { if (rtpmpadepay->offset == gst_buffer_get_size (frame->buffer)) {
if (g_list_next (rtpmpadepay->cur_adu_frame)) { if (g_list_next (rtpmpadepay->cur_adu_frame)) {
GST_LOG_OBJECT (rtpmpadepay, GST_LOG_OBJECT (rtpmpadepay,
"moving to next ADU frame, size %d, side_info %d", "moving to next ADU frame, size %d, side_info %d",
@ -523,8 +533,10 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
gst_byte_writer_set_pos (rtpmpadepay->mp3_frame, 0); gst_byte_writer_set_pos (rtpmpadepay->mp3_frame, 0);
/* bytewriter corresponds to head frame, /* bytewriter corresponds to head frame,
* i.e. the header and the side info must match */ * i.e. the header and the side info must match */
data = gst_buffer_map (head->buffer, &size, NULL, GST_MAP_READ);
gst_byte_writer_put_data (rtpmpadepay->mp3_frame, gst_byte_writer_put_data (rtpmpadepay->mp3_frame,
GST_BUFFER_DATA (head->buffer), 4 + head->side_info); data, 4 + head->side_info);
gst_buffer_unmap (head->buffer, data, size);
} }
buf = frame->buffer; buf = frame->buffer;
@ -534,15 +546,17 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
rtpmpadepay->size); rtpmpadepay->size);
if (rtpmpadepay->offset) { if (rtpmpadepay->offset) {
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
/* no need to position, simply append */ /* no need to position, simply append */
g_assert (GST_BUFFER_SIZE (buf) > rtpmpadepay->offset); g_assert (size > rtpmpadepay->offset);
av = MIN (av, GST_BUFFER_SIZE (buf) - rtpmpadepay->offset); av = MIN (av, size - rtpmpadepay->offset);
GST_LOG_OBJECT (rtpmpadepay, GST_LOG_OBJECT (rtpmpadepay,
"appending %d bytes from ADU frame at offset %d", av, "appending %d bytes from ADU frame at offset %d", av,
rtpmpadepay->offset); rtpmpadepay->offset);
gst_byte_writer_put_data (rtpmpadepay->mp3_frame, gst_byte_writer_put_data (rtpmpadepay->mp3_frame,
GST_BUFFER_DATA (buf) + rtpmpadepay->offset, av); data + rtpmpadepay->offset, av);
rtpmpadepay->offset += av; rtpmpadepay->offset += av;
gst_buffer_unmap (buf, data, size);
} else { } else {
gint pos, tpos; gint pos, tpos;
@ -580,12 +594,14 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
gst_byte_writer_set_pos (rtpmpadepay->mp3_frame, pos + av); gst_byte_writer_set_pos (rtpmpadepay->mp3_frame, pos + av);
} else { } else {
/* position and append */ /* position and append */
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
GST_LOG_OBJECT (rtpmpadepay, "adding to current MP3 frame"); GST_LOG_OBJECT (rtpmpadepay, "adding to current MP3 frame");
gst_byte_writer_set_pos (rtpmpadepay->mp3_frame, tpos); gst_byte_writer_set_pos (rtpmpadepay->mp3_frame, tpos);
av = MIN (av, GST_BUFFER_SIZE (buf) - 4 - frame->side_info); av = MIN (av, size - 4 - frame->side_info);
gst_byte_writer_put_data (rtpmpadepay->mp3_frame, gst_byte_writer_put_data (rtpmpadepay->mp3_frame,
GST_BUFFER_DATA (buf) + 4 + frame->side_info, av); data + 4 + frame->side_info, av);
rtpmpadepay->offset += av + 4 + frame->side_info; rtpmpadepay->offset += av + 4 + frame->side_info;
gst_buffer_unmap (buf, data, size);
} }
} }
@ -634,16 +650,19 @@ gst_rtp_mpa_robust_depay_process (GstBaseRTPDepayload * depayload,
gboolean cont, dtype; gboolean cont, dtype;
guint av, size; guint av, size;
GstClockTime timestamp; GstClockTime timestamp;
GstRTPBuffer rtp = { NULL };
rtpmpadepay = GST_RTP_MPA_ROBUST_DEPAY (depayload); rtpmpadepay = GST_RTP_MPA_ROBUST_DEPAY (depayload);
payload_len = gst_rtp_buffer_get_payload_len (buf);
timestamp = GST_BUFFER_TIMESTAMP (buf); timestamp = GST_BUFFER_TIMESTAMP (buf);
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
if (payload_len <= 1) if (payload_len <= 1)
goto short_read; goto short_read;
payload = gst_rtp_buffer_get_payload (buf); payload = gst_rtp_buffer_get_payload (&rtp);
offset = 0; offset = 0;
GST_LOG_OBJECT (rtpmpadepay, "payload_len: %d", payload_len); GST_LOG_OBJECT (rtpmpadepay, "payload_len: %d", payload_len);
@ -683,7 +702,7 @@ gst_rtp_mpa_robust_depay_process (GstBaseRTPDepayload * depayload,
GST_LOG_OBJECT (rtpmpadepay, "offset %d has cont: %d, dtype: %d, size: %d", GST_LOG_OBJECT (rtpmpadepay, "offset %d has cont: %d, dtype: %d, size: %d",
offset, cont, dtype, size); offset, cont, dtype, size);
buf = gst_rtp_buffer_get_payload_subbuffer (buf, offset, buf = gst_rtp_buffer_get_payload_subbuffer (&rtp, offset,
MIN (size, payload_len)); MIN (size, payload_len));
if (cont) { if (cont) {
@ -693,7 +712,7 @@ gst_rtp_mpa_robust_depay_process (GstBaseRTPDepayload * depayload,
"discarding continuation fragment without prior fragment"); "discarding continuation fragment without prior fragment");
gst_buffer_unref (buf); gst_buffer_unref (buf);
} else { } else {
av += GST_BUFFER_SIZE (buf); av += gst_buffer_get_size (buf);
gst_adapter_push (rtpmpadepay->adapter, buf); gst_adapter_push (rtpmpadepay->adapter, buf);
if (av == size) { if (av == size) {
timestamp = gst_adapter_prev_timestamp (rtpmpadepay->adapter, NULL); timestamp = gst_adapter_prev_timestamp (rtpmpadepay->adapter, NULL);
@ -727,6 +746,7 @@ gst_rtp_mpa_robust_depay_process (GstBaseRTPDepayload * depayload,
/* timestamp applies to first payload, no idea for subsequent ones */ /* timestamp applies to first payload, no idea for subsequent ones */
timestamp = GST_CLOCK_TIME_NONE; timestamp = GST_CLOCK_TIME_NONE;
} }
gst_rtp_buffer_unmap (&rtp);
return NULL; return NULL;
@ -735,6 +755,7 @@ short_read:
{ {
GST_ELEMENT_WARNING (rtpmpadepay, STREAM, DECODE, GST_ELEMENT_WARNING (rtpmpadepay, STREAM, DECODE,
(NULL), ("Packet contains invalid data")); (NULL), ("Packet contains invalid data"));
gst_rtp_buffer_unmap (&rtp);
return NULL; return NULL;
} }
} }

View file

@ -53,8 +53,7 @@ static GstStaticPadTemplate gst_rtp_mpv_depay_sink_template =
"clock-rate = (int) 90000") "clock-rate = (int) 90000")
); );
GST_BOILERPLATE (GstRtpMPVDepay, gst_rtp_mpv_depay, GstBaseRTPDepayload, G_DEFINE_TYPE (GstRtpMPVDepay, gst_rtp_mpv_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
GST_TYPE_BASE_RTP_DEPAYLOAD);
static gboolean gst_rtp_mpv_depay_setcaps (GstBaseRTPDepayload * depayload, static gboolean gst_rtp_mpv_depay_setcaps (GstBaseRTPDepayload * depayload,
GstCaps * caps); GstCaps * caps);
@ -62,27 +61,23 @@ static GstBuffer *gst_rtp_mpv_depay_process (GstBaseRTPDepayload * depayload,
GstBuffer * buf); GstBuffer * buf);
static void static void
gst_rtp_mpv_depay_base_init (gpointer klass) gst_rtp_mpv_depay_class_init (GstRtpMPVDepayClass * klass)
{ {
GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstElementClass *gstelement_class;
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
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_mpv_depay_src_template)); gst_static_pad_template_get (&gst_rtp_mpv_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_mpv_depay_sink_template)); gst_static_pad_template_get (&gst_rtp_mpv_depay_sink_template));
gst_element_class_set_details_simple (element_class, gst_element_class_set_details_simple (gstelement_class,
"RTP MPEG video depayloader", "Codec/Depayloader/Network/RTP", "RTP MPEG video depayloader", "Codec/Depayloader/Network/RTP",
"Extracts MPEG video from RTP packets (RFC 2250)", "Extracts MPEG video from RTP packets (RFC 2250)",
"Wim Taymans <wim.taymans@gmail.com>"); "Wim Taymans <wim.taymans@gmail.com>");
}
static void
gst_rtp_mpv_depay_class_init (GstRtpMPVDepayClass * klass)
{
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
gstbasertpdepayload_class->set_caps = gst_rtp_mpv_depay_setcaps; gstbasertpdepayload_class->set_caps = gst_rtp_mpv_depay_setcaps;
gstbasertpdepayload_class->process = gst_rtp_mpv_depay_process; gstbasertpdepayload_class->process = gst_rtp_mpv_depay_process;
@ -92,10 +87,8 @@ gst_rtp_mpv_depay_class_init (GstRtpMPVDepayClass * klass)
} }
static void static void
gst_rtp_mpv_depay_init (GstRtpMPVDepay * rtpmpvdepay, gst_rtp_mpv_depay_init (GstRtpMPVDepay * rtpmpvdepay)
GstRtpMPVDepayClass * klass)
{ {
/* needed because of GST_BOILERPLATE */
} }
static gboolean static gboolean
@ -126,16 +119,19 @@ gst_rtp_mpv_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
{ {
GstRtpMPVDepay *rtpmpvdepay; GstRtpMPVDepay *rtpmpvdepay;
GstBuffer *outbuf; GstBuffer *outbuf;
GstRTPBuffer rtp = { NULL };
rtpmpvdepay = GST_RTP_MPV_DEPAY (depayload); rtpmpvdepay = GST_RTP_MPV_DEPAY (depayload);
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
{ {
gint payload_len, payload_header; gint payload_len, payload_header;
guint8 *payload; guint8 *payload;
guint8 T; guint8 T;
payload_len = gst_rtp_buffer_get_payload_len (buf); payload_len = gst_rtp_buffer_get_payload_len (&rtp);
payload = gst_rtp_buffer_get_payload (buf); payload = gst_rtp_buffer_get_payload (&rtp);
payload_header = 0; payload_header = 0;
if (payload_len <= 4) if (payload_len <= 4)
@ -174,11 +170,11 @@ gst_rtp_mpv_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
payload += 4; payload += 4;
} }
outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, payload_header, -1); outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, payload_header, -1);
GST_DEBUG_OBJECT (rtpmpvdepay, GST_DEBUG_OBJECT (rtpmpvdepay,
"gst_rtp_mpv_depay_chain: pushing buffer of size %d", "gst_rtp_mpv_depay_chain: pushing buffer of size %d",
GST_BUFFER_SIZE (outbuf)); gst_buffer_get_size (outbuf));
return outbuf; return outbuf;
} }

View file

@ -60,23 +60,8 @@ static GstFlowReturn gst_rtp_mpv_pay_handle_buffer (GstBaseRTPPayload *
payload, GstBuffer * buffer); payload, GstBuffer * buffer);
static gboolean gst_rtp_mpv_pay_handle_event (GstPad * pad, GstEvent * event); static gboolean gst_rtp_mpv_pay_handle_event (GstPad * pad, GstEvent * event);
GST_BOILERPLATE (GstRTPMPVPay, gst_rtp_mpv_pay, GstBaseRTPPayload, #define gst_rtp_mpv_pay_parent_class parent_class
GST_TYPE_BASE_RTP_PAYLOAD); G_DEFINE_TYPE (GstRTPMPVPay, gst_rtp_mpv_pay, GST_TYPE_BASE_RTP_PAYLOAD);
static void
gst_rtp_mpv_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_mpv_pay_sink_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_mpv_pay_src_template));
gst_element_class_set_details_simple (element_class,
"RTP MPEG2 ES video payloader", "Codec/Payloader/Network/RTP",
"Payload-encodes MPEG2 ES into RTP packets (RFC 2250)",
"Thijs Vermeir <thijsvermeir@gmail.com>");
}
static void static void
gst_rtp_mpv_pay_class_init (GstRTPMPVPayClass * klass) gst_rtp_mpv_pay_class_init (GstRTPMPVPayClass * klass)
@ -93,6 +78,16 @@ gst_rtp_mpv_pay_class_init (GstRTPMPVPayClass * klass)
gstelement_class->change_state = gst_rtp_mpv_pay_change_state; gstelement_class->change_state = gst_rtp_mpv_pay_change_state;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_mpv_pay_sink_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_mpv_pay_src_template));
gst_element_class_set_details_simple (gstelement_class,
"RTP MPEG2 ES video payloader", "Codec/Payloader/Network/RTP",
"Payload-encodes MPEG2 ES into RTP packets (RFC 2250)",
"Thijs Vermeir <thijsvermeir@gmail.com>");
gstbasertppayload_class->set_caps = gst_rtp_mpv_pay_setcaps; gstbasertppayload_class->set_caps = gst_rtp_mpv_pay_setcaps;
gstbasertppayload_class->handle_buffer = gst_rtp_mpv_pay_handle_buffer; gstbasertppayload_class->handle_buffer = gst_rtp_mpv_pay_handle_buffer;
gstbasertppayload_class->handle_event = gst_rtp_mpv_pay_handle_event; gstbasertppayload_class->handle_event = gst_rtp_mpv_pay_handle_event;
@ -102,7 +97,7 @@ gst_rtp_mpv_pay_class_init (GstRTPMPVPayClass * klass)
} }
static void static void
gst_rtp_mpv_pay_init (GstRTPMPVPay * rtpmpvpay, GstRTPMPVPayClass * klass) gst_rtp_mpv_pay_init (GstRTPMPVPay * rtpmpvpay)
{ {
GST_BASE_RTP_PAYLOAD (rtpmpvpay)->clock_rate = 90000; GST_BASE_RTP_PAYLOAD (rtpmpvpay)->clock_rate = 90000;
GST_BASE_RTP_PAYLOAD_PT (rtpmpvpay) = GST_RTP_PAYLOAD_MPV; GST_BASE_RTP_PAYLOAD_PT (rtpmpvpay) = GST_RTP_PAYLOAD_MPV;
@ -181,6 +176,7 @@ gst_rtp_mpv_pay_flush (GstRTPMPVPay * rtpmpvpay)
guint towrite; guint towrite;
guint packet_len; guint packet_len;
guint payload_len; guint payload_len;
GstRTPBuffer rtp = { NULL };
packet_len = gst_rtp_buffer_calc_packet_len (avail, 4, 0); packet_len = gst_rtp_buffer_calc_packet_len (avail, 4, 0);
@ -190,7 +186,9 @@ gst_rtp_mpv_pay_flush (GstRTPMPVPay * rtpmpvpay)
outbuf = gst_rtp_buffer_new_allocate (payload_len, 4, 0); outbuf = gst_rtp_buffer_new_allocate (payload_len, 4, 0);
payload = gst_rtp_buffer_get_payload (outbuf); gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
payload = gst_rtp_buffer_get_payload (&rtp);
/* enable MPEG Video-specific header /* enable MPEG Video-specific header
* *
* 0 1 2 3 * 0 1 2 3
@ -211,7 +209,8 @@ gst_rtp_mpv_pay_flush (GstRTPMPVPay * rtpmpvpay)
avail -= payload_len; avail -= payload_len;
gst_rtp_buffer_set_marker (outbuf, avail == 0); gst_rtp_buffer_set_marker (&rtp, avail == 0);
gst_rtp_buffer_unmap (&rtp);
GST_BUFFER_TIMESTAMP (outbuf) = rtpmpvpay->first_ts; GST_BUFFER_TIMESTAMP (outbuf) = rtpmpvpay->first_ts;

View file

@ -65,38 +65,35 @@ static GstBuffer *gst_rtp_pcma_depay_process (GstBaseRTPDepayload * depayload,
static gboolean gst_rtp_pcma_depay_setcaps (GstBaseRTPDepayload * depayload, static gboolean gst_rtp_pcma_depay_setcaps (GstBaseRTPDepayload * depayload,
GstCaps * caps); GstCaps * caps);
GST_BOILERPLATE (GstRtpPcmaDepay, gst_rtp_pcma_depay, GstBaseRTPDepayload, #define gst_rtp_pcma_depay_parent_class parent_class
G_DEFINE_TYPE (GstRtpPcmaDepay, gst_rtp_pcma_depay,
GST_TYPE_BASE_RTP_DEPAYLOAD); GST_TYPE_BASE_RTP_DEPAYLOAD);
static void
gst_rtp_pcma_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_pcma_depay_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_pcma_depay_sink_template));
gst_element_class_set_details_simple (element_class, "RTP PCMA depayloader",
"Codec/Depayloader/Network/RTP",
"Extracts PCMA audio from RTP packets",
"Edgard Lima <edgard.lima@indt.org.br>, Zeeshan Ali <zeenix@gmail.com>");
}
static void static void
gst_rtp_pcma_depay_class_init (GstRtpPcmaDepayClass * klass) gst_rtp_pcma_depay_class_init (GstRtpPcmaDepayClass * klass)
{ {
GstElementClass *gstelement_class;
GstBaseRTPDepayloadClass *gstbasertpdepayload_class; GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
gstelement_class = (GstElementClass *) klass;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass; gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_pcma_depay_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_pcma_depay_sink_template));
gst_element_class_set_details_simple (gstelement_class,
"RTP PCMA depayloader", "Codec/Depayloader/Network/RTP",
"Extracts PCMA audio from RTP packets",
"Edgard Lima <edgard.lima@indt.org.br>, Zeeshan Ali <zeenix@gmail.com>");
gstbasertpdepayload_class->process = gst_rtp_pcma_depay_process; gstbasertpdepayload_class->process = gst_rtp_pcma_depay_process;
gstbasertpdepayload_class->set_caps = gst_rtp_pcma_depay_setcaps; gstbasertpdepayload_class->set_caps = gst_rtp_pcma_depay_setcaps;
} }
static void static void
gst_rtp_pcma_depay_init (GstRtpPcmaDepay * rtppcmadepay, gst_rtp_pcma_depay_init (GstRtpPcmaDepay * rtppcmadepay)
GstRtpPcmaDepayClass * klass)
{ {
GstBaseRTPDepayload *depayload; GstBaseRTPDepayload *depayload;
@ -133,15 +130,19 @@ gst_rtp_pcma_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
GstBuffer *outbuf = NULL; GstBuffer *outbuf = NULL;
gboolean marker; gboolean marker;
guint len; guint len;
GstRTPBuffer rtp = { NULL };
marker = gst_rtp_buffer_get_marker (buf); gst_rtp_buffer_map (buf, GST_MAP_READ, &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));
len = gst_rtp_buffer_get_payload_len (buf); len = gst_rtp_buffer_get_payload_len (&rtp);
outbuf = gst_rtp_buffer_get_payload_buffer (buf); outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
gst_rtp_buffer_unmap (&rtp);
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (outbuf) =
gst_util_uint64_scale_int (len, GST_SECOND, depayload->clock_rate); gst_util_uint64_scale_int (len, GST_SECOND, depayload->clock_rate);
@ -151,6 +152,7 @@ gst_rtp_pcma_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT); GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
} }
return outbuf; return outbuf;
} }

View file

@ -53,36 +53,34 @@ static GstStaticPadTemplate gst_rtp_pcma_pay_src_template =
static gboolean gst_rtp_pcma_pay_setcaps (GstBaseRTPPayload * payload, static gboolean gst_rtp_pcma_pay_setcaps (GstBaseRTPPayload * payload,
GstCaps * caps); GstCaps * caps);
GST_BOILERPLATE (GstRtpPcmaPay, gst_rtp_pcma_pay, GstBaseRTPAudioPayload, #define gst_rtp_pcma_pay_parent_class parent_class
G_DEFINE_TYPE (GstRtpPcmaPay, gst_rtp_pcma_pay,
GST_TYPE_BASE_RTP_AUDIO_PAYLOAD); GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
static void
gst_rtp_pcma_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_pcma_pay_sink_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_pcma_pay_src_template));
gst_element_class_set_details_simple (element_class, "RTP PCMA payloader",
"Codec/Payloader/Network/RTP",
"Payload-encodes PCMA audio into a RTP packet",
"Edgard Lima <edgard.lima@indt.org.br>");
}
static void static void
gst_rtp_pcma_pay_class_init (GstRtpPcmaPayClass * klass) gst_rtp_pcma_pay_class_init (GstRtpPcmaPayClass * klass)
{ {
GstElementClass *gstelement_class;
GstBaseRTPPayloadClass *gstbasertppayload_class; GstBaseRTPPayloadClass *gstbasertppayload_class;
gstelement_class = (GstElementClass *) klass;
gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass; gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_pcma_pay_sink_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_pcma_pay_src_template));
gst_element_class_set_details_simple (gstelement_class, "RTP PCMA payloader",
"Codec/Payloader/Network/RTP",
"Payload-encodes PCMA audio into a RTP packet",
"Edgard Lima <edgard.lima@indt.org.br>");
gstbasertppayload_class->set_caps = gst_rtp_pcma_pay_setcaps; gstbasertppayload_class->set_caps = gst_rtp_pcma_pay_setcaps;
} }
static void static void
gst_rtp_pcma_pay_init (GstRtpPcmaPay * rtppcmapay, GstRtpPcmaPayClass * klass) gst_rtp_pcma_pay_init (GstRtpPcmaPay * rtppcmapay)
{ {
GstBaseRTPAudioPayload *basertpaudiopayload; GstBaseRTPAudioPayload *basertpaudiopayload;

View file

@ -65,38 +65,35 @@ static GstBuffer *gst_rtp_pcmu_depay_process (GstBaseRTPDepayload * depayload,
static gboolean gst_rtp_pcmu_depay_setcaps (GstBaseRTPDepayload * depayload, static gboolean gst_rtp_pcmu_depay_setcaps (GstBaseRTPDepayload * depayload,
GstCaps * caps); GstCaps * caps);
GST_BOILERPLATE (GstRtpPcmuDepay, gst_rtp_pcmu_depay, GstBaseRTPDepayload, #define gst_rtp_pcmu_depay_parent_class parent_class
G_DEFINE_TYPE (GstRtpPcmuDepay, gst_rtp_pcmu_depay,
GST_TYPE_BASE_RTP_DEPAYLOAD); GST_TYPE_BASE_RTP_DEPAYLOAD);
static void
gst_rtp_pcmu_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_pcmu_depay_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_pcmu_depay_sink_template));
gst_element_class_set_details_simple (element_class, "RTP PCMU depayloader",
"Codec/Depayloader/Network/RTP",
"Extracts PCMU audio from RTP packets",
"Edgard Lima <edgard.lima@indt.org.br>, Zeeshan Ali <zeenix@gmail.com>");
}
static void static void
gst_rtp_pcmu_depay_class_init (GstRtpPcmuDepayClass * klass) gst_rtp_pcmu_depay_class_init (GstRtpPcmuDepayClass * klass)
{ {
GstElementClass *gstelement_class;
GstBaseRTPDepayloadClass *gstbasertpdepayload_class; GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
gstelement_class = (GstElementClass *) klass;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass; gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_pcmu_depay_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_pcmu_depay_sink_template));
gst_element_class_set_details_simple (gstelement_class,
"RTP PCMU depayloader", "Codec/Depayloader/Network/RTP",
"Extracts PCMU audio from RTP packets",
"Edgard Lima <edgard.lima@indt.org.br>, Zeeshan Ali <zeenix@gmail.com>");
gstbasertpdepayload_class->process = gst_rtp_pcmu_depay_process; gstbasertpdepayload_class->process = gst_rtp_pcmu_depay_process;
gstbasertpdepayload_class->set_caps = gst_rtp_pcmu_depay_setcaps; gstbasertpdepayload_class->set_caps = gst_rtp_pcmu_depay_setcaps;
} }
static void static void
gst_rtp_pcmu_depay_init (GstRtpPcmuDepay * rtppcmudepay, gst_rtp_pcmu_depay_init (GstRtpPcmuDepay * rtppcmudepay)
GstRtpPcmuDepayClass * klass)
{ {
GstBaseRTPDepayload *depayload; GstBaseRTPDepayload *depayload;
@ -133,15 +130,19 @@ gst_rtp_pcmu_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
GstBuffer *outbuf = NULL; GstBuffer *outbuf = NULL;
guint len; guint len;
gboolean marker; gboolean marker;
GstRTPBuffer rtp = { NULL };
marker = gst_rtp_buffer_get_marker (buf); gst_rtp_buffer_map (buf, GST_MAP_READ, &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));
len = gst_rtp_buffer_get_payload_len (buf); len = gst_rtp_buffer_get_payload_len (&rtp);
outbuf = gst_rtp_buffer_get_payload_buffer (buf); outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
gst_rtp_buffer_unmap (&rtp);
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (outbuf) =
gst_util_uint64_scale_int (len, GST_SECOND, depayload->clock_rate); gst_util_uint64_scale_int (len, GST_SECOND, depayload->clock_rate);

View file

@ -53,36 +53,34 @@ static GstStaticPadTemplate gst_rtp_pcmu_pay_src_template =
static gboolean gst_rtp_pcmu_pay_setcaps (GstBaseRTPPayload * payload, static gboolean gst_rtp_pcmu_pay_setcaps (GstBaseRTPPayload * payload,
GstCaps * caps); GstCaps * caps);
GST_BOILERPLATE (GstRtpPcmuPay, gst_rtp_pcmu_pay, GstBaseRTPAudioPayload, #define gst_rtp_pcmu_pay_parent_class parent_class
G_DEFINE_TYPE (GstRtpPcmuPay, gst_rtp_pcmu_pay,
GST_TYPE_BASE_RTP_AUDIO_PAYLOAD); GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
static void
gst_rtp_pcmu_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_pcmu_pay_sink_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_pcmu_pay_src_template));
gst_element_class_set_details_simple (element_class, "RTP PCMU payloader",
"Codec/Payloader/Network/RTP",
"Payload-encodes PCMU audio into a RTP packet",
"Edgard Lima <edgard.lima@indt.org.br>");
}
static void static void
gst_rtp_pcmu_pay_class_init (GstRtpPcmuPayClass * klass) gst_rtp_pcmu_pay_class_init (GstRtpPcmuPayClass * klass)
{ {
GstElementClass *gstelement_class;
GstBaseRTPPayloadClass *gstbasertppayload_class; GstBaseRTPPayloadClass *gstbasertppayload_class;
gstelement_class = (GstElementClass *) klass;
gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass; gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_pcmu_pay_sink_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_pcmu_pay_src_template));
gst_element_class_set_details_simple (gstelement_class, "RTP PCMU payloader",
"Codec/Payloader/Network/RTP",
"Payload-encodes PCMU audio into a RTP packet",
"Edgard Lima <edgard.lima@indt.org.br>");
gstbasertppayload_class->set_caps = gst_rtp_pcmu_pay_setcaps; gstbasertppayload_class->set_caps = gst_rtp_pcmu_pay_setcaps;
} }
static void static void
gst_rtp_pcmu_pay_init (GstRtpPcmuPay * rtppcmupay, GstRtpPcmuPayClass * klass) gst_rtp_pcmu_pay_init (GstRtpPcmuPay * rtppcmupay)
{ {
GstBaseRTPAudioPayload *basertpaudiopayload; GstBaseRTPAudioPayload *basertpaudiopayload;