mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
rtp: port more to 0.11
This commit is contained in:
parent
60db07b4bb
commit
bf9b4f8362
19 changed files with 472 additions and 453 deletions
|
@ -62,7 +62,8 @@ static GstStaticPadTemplate gst_rtp_g722_depay_sink_template =
|
|||
)
|
||||
);
|
||||
|
||||
GST_BOILERPLATE (GstRtpG722Depay, gst_rtp_g722_depay, GstBaseRTPDepayload,
|
||||
#define gst_rtp_g722_depay_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstRtpG722Depay, gst_rtp_g722_depay,
|
||||
GST_TYPE_BASE_RTP_DEPAYLOAD);
|
||||
|
||||
static gboolean gst_rtp_g722_depay_setcaps (GstBaseRTPDepayload * depayload,
|
||||
|
@ -70,41 +71,35 @@ static gboolean gst_rtp_g722_depay_setcaps (GstBaseRTPDepayload * depayload,
|
|||
static GstBuffer *gst_rtp_g722_depay_process (GstBaseRTPDepayload * depayload,
|
||||
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
|
||||
gst_rtp_g722_depay_class_init (GstRtpG722DepayClass * klass)
|
||||
{
|
||||
GstElementClass *gstelement_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,
|
||||
"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
|
||||
gst_rtp_g722_depay_init (GstRtpG722Depay * rtpg722depay,
|
||||
GstRtpG722DepayClass * klass)
|
||||
gst_rtp_g722_depay_init (GstRtpG722Depay * rtpg722depay)
|
||||
{
|
||||
/* needed because of GST_BOILERPLATE */
|
||||
}
|
||||
|
||||
static gint
|
||||
|
@ -223,18 +218,22 @@ gst_rtp_g722_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
GstBuffer *outbuf;
|
||||
gint payload_len;
|
||||
gboolean marker;
|
||||
GstRTPBuffer rtp = { NULL };
|
||||
|
||||
rtpg722depay = GST_RTP_G722_DEPAY (depayload);
|
||||
|
||||
payload_len = gst_rtp_buffer_get_payload_len (buf);
|
||||
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
|
||||
|
||||
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
|
||||
|
||||
if (payload_len <= 0)
|
||||
goto empty_packet;
|
||||
|
||||
GST_DEBUG_OBJECT (rtpg722depay, "got payload of %d bytes", payload_len);
|
||||
|
||||
outbuf = gst_rtp_buffer_get_payload_buffer (buf);
|
||||
marker = gst_rtp_buffer_get_marker (buf);
|
||||
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
|
||||
marker = gst_rtp_buffer_get_marker (&rtp);
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
||||
if (marker) {
|
||||
/* mark talk spurt with DISCONT */
|
||||
|
@ -248,6 +247,7 @@ empty_packet:
|
|||
{
|
||||
GST_ELEMENT_WARNING (rtpg722depay, STREAM, DECODE,
|
||||
("Empty Payload."), (NULL));
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,41 +56,38 @@ static gboolean gst_rtp_g722_pay_setcaps (GstBaseRTPPayload * basepayload,
|
|||
static GstCaps *gst_rtp_g722_pay_getcaps (GstBaseRTPPayload * rtppayload,
|
||||
GstPad * pad);
|
||||
|
||||
GST_BOILERPLATE (GstRtpG722Pay, gst_rtp_g722_pay, GstBaseRTPAudioPayload,
|
||||
#define gst_rtp_g722_pay_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstRtpG722Pay, gst_rtp_g722_pay,
|
||||
GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
|
||||
|
||||
static void
|
||||
gst_rtp_g722_pay_base_init (gpointer klass)
|
||||
{
|
||||
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
|
||||
gst_rtp_g722_pay_class_init (GstRtpG722PayClass * klass)
|
||||
{
|
||||
GstElementClass *gstelement_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,
|
||||
"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
|
||||
gst_rtp_g722_pay_init (GstRtpG722Pay * rtpg722pay, GstRtpG722PayClass * klass)
|
||||
gst_rtp_g722_pay_init (GstRtpG722Pay * rtpg722pay)
|
||||
{
|
||||
GstBaseRTPAudioPayload *basertpaudiopayload;
|
||||
|
||||
|
|
|
@ -78,42 +78,38 @@ static gboolean gst_rtp_g723_depay_setcaps (GstBaseRTPDepayload * depayload,
|
|||
static GstBuffer *gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload,
|
||||
GstBuffer * buf);
|
||||
|
||||
GST_BOILERPLATE (GstRtpG723Depay, gst_rtp_g723_depay, GstBaseRTPDepayload,
|
||||
#define gst_rtp_g723_depay_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstRtpG723Depay, gst_rtp_g723_depay,
|
||||
GST_TYPE_BASE_RTP_DEPAYLOAD);
|
||||
|
||||
static void
|
||||
gst_rtp_g723_depay_base_init (gpointer klass)
|
||||
{
|
||||
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
|
||||
gst_rtp_g723_depay_class_init (GstRtpG723DepayClass * klass)
|
||||
{
|
||||
GstElementClass *gstelement_class;
|
||||
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (rtpg723depay_debug, "rtpg723depay", 0,
|
||||
"G.723 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_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->set_caps = gst_rtp_g723_depay_setcaps;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_g723_depay_init (GstRtpG723Depay * rtpg723depay,
|
||||
GstRtpG723DepayClass * klass)
|
||||
gst_rtp_g723_depay_init (GstRtpG723Depay * rtpg723depay)
|
||||
{
|
||||
GstBaseRTPDepayload *depayload;
|
||||
|
||||
|
@ -182,10 +178,13 @@ gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
GstBuffer *outbuf = NULL;
|
||||
gint payload_len;
|
||||
gboolean marker;
|
||||
GstRTPBuffer rtp = { NULL };
|
||||
|
||||
rtpg723depay = GST_RTP_G723_DEPAY (depayload);
|
||||
|
||||
payload_len = gst_rtp_buffer_get_payload_len (buf);
|
||||
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
|
||||
|
||||
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
|
||||
|
||||
/* At least 4 bytes */
|
||||
if (payload_len < 4)
|
||||
|
@ -193,8 +192,9 @@ gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
|
||||
GST_LOG_OBJECT (rtpg723depay, "payload len %d", payload_len);
|
||||
|
||||
outbuf = gst_rtp_buffer_get_payload_buffer (buf);
|
||||
marker = gst_rtp_buffer_get_marker (buf);
|
||||
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
|
||||
marker = gst_rtp_buffer_get_marker (&rtp);
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
||||
if (marker) {
|
||||
/* marker bit starts talkspurt */
|
||||
|
@ -202,7 +202,7 @@ gst_rtp_g723_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
}
|
||||
|
||||
GST_LOG_OBJECT (depayload, "pushing buffer of size %d",
|
||||
GST_BUFFER_SIZE (outbuf));
|
||||
gst_buffer_get_size (outbuf));
|
||||
|
||||
return outbuf;
|
||||
|
||||
|
@ -216,6 +216,7 @@ too_small:
|
|||
bad_packet:
|
||||
{
|
||||
/* no fatal error */
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,23 +67,8 @@ static void gst_rtp_g723_pay_finalize (GObject * object);
|
|||
static GstStateChangeReturn gst_rtp_g723_pay_change_state (GstElement * element,
|
||||
GstStateChange transition);
|
||||
|
||||
GST_BOILERPLATE (GstRTPG723Pay, gst_rtp_g723_pay, GstBaseRTPPayload,
|
||||
GST_TYPE_BASE_RTP_PAYLOAD);
|
||||
|
||||
static void
|
||||
gst_rtp_g723_pay_base_init (gpointer klass)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_rtp_g723_pay_sink_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_rtp_g723_pay_src_template));
|
||||
gst_element_class_set_details_simple (element_class, "RTP G.723 payloader",
|
||||
"Codec/Payloader/Network/RTP",
|
||||
"Packetize G.723 audio into RTP packets",
|
||||
"Wim Taymans <wim.taymans@gmail.com>");
|
||||
}
|
||||
#define gst_rtp_g723_pay_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstRTPG723Pay, gst_rtp_g723_pay, GST_TYPE_BASE_RTP_PAYLOAD);
|
||||
|
||||
static void
|
||||
gst_rtp_g723_pay_class_init (GstRTPG723PayClass * klass)
|
||||
|
@ -100,12 +85,22 @@ gst_rtp_g723_pay_class_init (GstRTPG723PayClass * klass)
|
|||
|
||||
gstelement_class->change_state = gst_rtp_g723_pay_change_state;
|
||||
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
gst_static_pad_template_get (&gst_rtp_g723_pay_sink_template));
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
gst_static_pad_template_get (&gst_rtp_g723_pay_src_template));
|
||||
|
||||
gst_element_class_set_details_simple (gstelement_class, "RTP G.723 payloader",
|
||||
"Codec/Payloader/Network/RTP",
|
||||
"Packetize G.723 audio into RTP packets",
|
||||
"Wim Taymans <wim.taymans@gmail.com>");
|
||||
|
||||
payload_class->set_caps = gst_rtp_g723_pay_set_caps;
|
||||
payload_class->handle_buffer = gst_rtp_g723_pay_handle_buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_g723_pay_init (GstRTPG723Pay * pay, GstRTPG723PayClass * klass)
|
||||
gst_rtp_g723_pay_init (GstRTPG723Pay * pay)
|
||||
{
|
||||
GstBaseRTPPayload *payload = GST_BASE_RTP_PAYLOAD (pay);
|
||||
|
||||
|
@ -155,11 +150,14 @@ gst_rtp_g723_pay_flush (GstRTPG723Pay * pay)
|
|||
GstFlowReturn ret;
|
||||
guint8 *payload;
|
||||
guint avail;
|
||||
GstRTPBuffer rtp = { NULL };
|
||||
|
||||
avail = gst_adapter_available (pay->adapter);
|
||||
|
||||
outbuf = gst_rtp_buffer_new_allocate (avail, 0, 0);
|
||||
payload = gst_rtp_buffer_get_payload (outbuf);
|
||||
|
||||
gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
|
||||
payload = gst_rtp_buffer_get_payload (&rtp);
|
||||
|
||||
GST_BUFFER_TIMESTAMP (outbuf) = pay->timestamp;
|
||||
GST_BUFFER_DURATION (outbuf) = pay->duration;
|
||||
|
@ -175,9 +173,10 @@ gst_rtp_g723_pay_flush (GstRTPG723Pay * pay)
|
|||
/* set discont and marker */
|
||||
if (pay->discont) {
|
||||
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
|
||||
gst_rtp_buffer_set_marker (outbuf, TRUE);
|
||||
gst_rtp_buffer_set_marker (&rtp, TRUE);
|
||||
pay->discont = FALSE;
|
||||
}
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
||||
ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (pay), outbuf);
|
||||
|
||||
|
@ -197,7 +196,7 @@ gst_rtp_g723_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
|
|||
{
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
guint8 *data;
|
||||
guint size;
|
||||
gsize size;
|
||||
guint8 HDR;
|
||||
GstRTPG723Pay *pay;
|
||||
GstClockTime packet_dur, timestamp;
|
||||
|
@ -205,8 +204,7 @@ gst_rtp_g723_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
|
|||
|
||||
pay = GST_RTP_G723_PAY (payload);
|
||||
|
||||
size = GST_BUFFER_SIZE (buf);
|
||||
data = GST_BUFFER_DATA (buf);
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||
|
||||
if (GST_BUFFER_IS_DISCONT (buf)) {
|
||||
|
@ -244,6 +242,7 @@ gst_rtp_g723_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
|
|||
else
|
||||
pay->timestamp = 0;
|
||||
}
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
|
||||
/* add packet to the queue */
|
||||
gst_adapter_push (pay->adapter, buf);
|
||||
|
@ -262,6 +261,7 @@ invalid_size:
|
|||
GST_ELEMENT_WARNING (pay, STREAM, WRONG_TYPE,
|
||||
("Invalid input buffer size"),
|
||||
("Input size should be 4, 20 or 24, got %u", size));
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unref (buf);
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
@ -270,6 +270,7 @@ wrong_size:
|
|||
GST_ELEMENT_WARNING (pay, STREAM, WRONG_TYPE,
|
||||
("Wrong input buffer size"),
|
||||
("Expected input buffer size %u but got %u", size_tab[HDR], size));
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unref (buf);
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
|
|
|
@ -87,31 +87,22 @@ static GstBuffer *gst_rtp_g726_depay_process (GstBaseRTPDepayload * depayload,
|
|||
static gboolean gst_rtp_g726_depay_setcaps (GstBaseRTPDepayload * depayload,
|
||||
GstCaps * caps);
|
||||
|
||||
GST_BOILERPLATE (GstRtpG726Depay, gst_rtp_g726_depay, GstBaseRTPDepayload,
|
||||
#define gst_rtp_g726_depay_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstRtpG726Depay, gst_rtp_g726_depay,
|
||||
GST_TYPE_BASE_RTP_DEPAYLOAD);
|
||||
|
||||
static void
|
||||
gst_rtp_g726_depay_base_init (gpointer klass)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_rtp_g726_depay_src_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_rtp_g726_depay_sink_template));
|
||||
gst_element_class_set_details_simple (element_class, "RTP G.726 depayloader",
|
||||
"Codec/Depayloader/Network/RTP",
|
||||
"Extracts G.726 audio from RTP packets",
|
||||
"Axis Communications <dev-gstreamer@axis.com>");
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_g726_depay_class_init (GstRtpG726DepayClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (rtpg726depay_debug, "rtpg726depay", 0,
|
||||
"G.726 RTP Depayloader");
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
gstelement_class = (GstElementClass *) klass;
|
||||
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
|
||||
|
||||
gobject_class->set_property = gst_rtp_g726_depay_set_property;
|
||||
|
@ -122,16 +113,22 @@ gst_rtp_g726_depay_class_init (GstRtpG726DepayClass * klass)
|
|||
"Force AAL2 decoding for compatibility with bad payloaders",
|
||||
DEFAULT_FORCE_AAL2, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
gst_static_pad_template_get (&gst_rtp_g726_depay_src_template));
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
gst_static_pad_template_get (&gst_rtp_g726_depay_sink_template));
|
||||
|
||||
gst_element_class_set_details_simple (gstelement_class,
|
||||
"RTP G.726 depayloader", "Codec/Depayloader/Network/RTP",
|
||||
"Extracts G.726 audio from RTP packets",
|
||||
"Axis Communications <dev-gstreamer@axis.com>");
|
||||
|
||||
gstbasertpdepayload_class->process = gst_rtp_g726_depay_process;
|
||||
gstbasertpdepayload_class->set_caps = gst_rtp_g726_depay_setcaps;
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (rtpg726depay_debug, "rtpg726depay", 0,
|
||||
"G.726 RTP Depayloader");
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_g726_depay_init (GstRtpG726Depay * rtpG726depay,
|
||||
GstRtpG726DepayClass * klass)
|
||||
gst_rtp_g726_depay_init (GstRtpG726Depay * rtpG726depay)
|
||||
{
|
||||
GstBaseRTPDepayload *depayload;
|
||||
|
||||
|
@ -210,36 +207,34 @@ gst_rtp_g726_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
GstRtpG726Depay *depay;
|
||||
GstBuffer *outbuf = NULL;
|
||||
gboolean marker;
|
||||
GstRTPBuffer rtp = { NULL };
|
||||
|
||||
depay = GST_RTP_G726_DEPAY (depayload);
|
||||
|
||||
marker = gst_rtp_buffer_get_marker (buf);
|
||||
gst_rtp_buffer_map (buf, GST_MAP_READWRITE, &rtp);
|
||||
|
||||
marker = gst_rtp_buffer_get_marker (&rtp);
|
||||
|
||||
GST_DEBUG ("process : got %d bytes, mark %d ts %u seqn %d",
|
||||
GST_BUFFER_SIZE (buf), marker,
|
||||
gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf));
|
||||
gst_buffer_get_size (buf), marker,
|
||||
gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
|
||||
|
||||
if (depay->aal2 || depay->force_aal2) {
|
||||
/* AAL2, we can just copy the bytes */
|
||||
outbuf = gst_rtp_buffer_get_payload_buffer (buf);
|
||||
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
|
||||
} else {
|
||||
guint8 *in, *out, tmp;
|
||||
guint8 *in, *out, tmp, *odata;
|
||||
guint len;
|
||||
gsize osize;
|
||||
|
||||
in = gst_rtp_buffer_get_payload (buf);
|
||||
len = gst_rtp_buffer_get_payload_len (buf);
|
||||
in = gst_rtp_buffer_get_payload (&rtp);
|
||||
len = gst_rtp_buffer_get_payload_len (&rtp);
|
||||
|
||||
if (gst_buffer_is_writable (buf)) {
|
||||
outbuf = gst_rtp_buffer_get_payload_buffer (buf);
|
||||
} else {
|
||||
GstBuffer *copy;
|
||||
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
|
||||
outbuf = gst_buffer_make_writable (outbuf);
|
||||
|
||||
/* copy buffer */
|
||||
copy = gst_buffer_copy (buf);
|
||||
outbuf = gst_rtp_buffer_get_payload_buffer (copy);
|
||||
gst_buffer_unref (copy);
|
||||
}
|
||||
out = GST_BUFFER_DATA (outbuf);
|
||||
odata = gst_buffer_map (outbuf, &osize, NULL, GST_MAP_WRITE);
|
||||
out = odata;
|
||||
|
||||
/* we need to reshuffle the bytes, input is always of the form
|
||||
* A B C D ... with the number of bits depending on the bitrate. */
|
||||
|
@ -327,6 +322,7 @@ gst_rtp_g726_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
break;
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (outbuf, odata, osize);
|
||||
}
|
||||
|
||||
if (marker) {
|
||||
|
|
|
@ -75,31 +75,19 @@ static gboolean gst_rtp_g726_pay_setcaps (GstBaseRTPPayload * payload,
|
|||
static GstFlowReturn gst_rtp_g726_pay_handle_buffer (GstBaseRTPPayload *
|
||||
payload, GstBuffer * buffer);
|
||||
|
||||
GST_BOILERPLATE (GstRtpG726Pay, gst_rtp_g726_pay, GstBaseRTPAudioPayload,
|
||||
#define gst_rtp_g726_pay_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstRtpG726Pay, gst_rtp_g726_pay,
|
||||
GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
|
||||
|
||||
static void
|
||||
gst_rtp_g726_pay_base_init (gpointer klass)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_rtp_g726_pay_sink_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_rtp_g726_pay_src_template));
|
||||
gst_element_class_set_details_simple (element_class, "RTP G.726 payloader",
|
||||
"Codec/Payloader/Network/RTP",
|
||||
"Payload-encodes G.726 audio into a RTP packet",
|
||||
"Axis Communications <dev-gstreamer@axis.com>");
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_g726_pay_class_init (GstRtpG726PayClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
GstBaseRTPPayloadClass *gstbasertppayload_class;
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
gstelement_class = (GstElementClass *) klass;
|
||||
gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
|
||||
|
||||
gobject_class->set_property = gst_rtp_g726_pay_set_property;
|
||||
|
@ -110,6 +98,16 @@ gst_rtp_g726_pay_class_init (GstRtpG726PayClass * klass)
|
|||
"Force AAL2 encoding for compatibility with bad depayloaders",
|
||||
DEFAULT_FORCE_AAL2, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
gst_static_pad_template_get (&gst_rtp_g726_pay_sink_template));
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
gst_static_pad_template_get (&gst_rtp_g726_pay_src_template));
|
||||
|
||||
gst_element_class_set_details_simple (gstelement_class, "RTP G.726 payloader",
|
||||
"Codec/Payloader/Network/RTP",
|
||||
"Payload-encodes G.726 audio into a RTP packet",
|
||||
"Axis Communications <dev-gstreamer@axis.com>");
|
||||
|
||||
gstbasertppayload_class->set_caps = gst_rtp_g726_pay_setcaps;
|
||||
gstbasertppayload_class->handle_buffer = gst_rtp_g726_pay_handle_buffer;
|
||||
|
||||
|
@ -118,7 +116,7 @@ gst_rtp_g726_pay_class_init (GstRtpG726PayClass * klass)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_rtp_g726_pay_init (GstRtpG726Pay * rtpg726pay, GstRtpG726PayClass * klass)
|
||||
gst_rtp_g726_pay_init (GstRtpG726Pay * rtpg726pay)
|
||||
{
|
||||
GstBaseRTPAudioPayload *basertpaudiopayload;
|
||||
|
||||
|
@ -269,14 +267,13 @@ gst_rtp_g726_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
|
|||
|
||||
if (!pay->aal2) {
|
||||
guint8 *data, tmp;
|
||||
guint len;
|
||||
gsize len;
|
||||
|
||||
/* for non AAL2, we need to reshuffle the bytes, we can do this in-place
|
||||
* when the buffer is writable. */
|
||||
buffer = gst_buffer_make_writable (buffer);
|
||||
|
||||
data = GST_BUFFER_DATA (buffer);
|
||||
len = GST_BUFFER_SIZE (buffer);
|
||||
data = gst_buffer_map (buffer, &len, NULL, GST_MAP_READWRITE);
|
||||
|
||||
GST_LOG_OBJECT (pay, "packing %u bytes of data", len);
|
||||
|
||||
|
@ -366,6 +363,7 @@ gst_rtp_g726_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buffer)
|
|||
break;
|
||||
}
|
||||
}
|
||||
gst_buffer_unmap (buffer, data, len);
|
||||
}
|
||||
|
||||
res =
|
||||
|
|
|
@ -76,42 +76,38 @@ static gboolean gst_rtp_g729_depay_setcaps (GstBaseRTPDepayload * depayload,
|
|||
static GstBuffer *gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload,
|
||||
GstBuffer * buf);
|
||||
|
||||
GST_BOILERPLATE (GstRtpG729Depay, gst_rtp_g729_depay, GstBaseRTPDepayload,
|
||||
#define gst_rtp_g729_depay_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstRtpG729Depay, gst_rtp_g729_depay,
|
||||
GST_TYPE_BASE_RTP_DEPAYLOAD);
|
||||
|
||||
static void
|
||||
gst_rtp_g729_depay_base_init (gpointer klass)
|
||||
{
|
||||
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
|
||||
gst_rtp_g729_depay_class_init (GstRtpG729DepayClass * klass)
|
||||
{
|
||||
GstElementClass *gstelement_class;
|
||||
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (rtpg729depay_debug, "rtpg729depay", 0,
|
||||
"G.729 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_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->set_caps = gst_rtp_g729_depay_setcaps;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_g729_depay_init (GstRtpG729Depay * rtpg729depay,
|
||||
GstRtpG729DepayClass * klass)
|
||||
gst_rtp_g729_depay_init (GstRtpG729Depay * rtpg729depay)
|
||||
{
|
||||
GstBaseRTPDepayload *depayload;
|
||||
|
||||
|
@ -172,7 +168,6 @@ wrong_clock_rate:
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static GstBuffer *
|
||||
gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
||||
{
|
||||
|
@ -180,10 +175,13 @@ gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
GstBuffer *outbuf = NULL;
|
||||
gint payload_len;
|
||||
gboolean marker;
|
||||
GstRTPBuffer rtp = { NULL };
|
||||
|
||||
rtpg729depay = GST_RTP_G729_DEPAY (depayload);
|
||||
|
||||
payload_len = gst_rtp_buffer_get_payload_len (buf);
|
||||
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
|
||||
|
||||
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
|
||||
|
||||
/* At least 2 bytes (CNG from G729 Annex B) */
|
||||
if (payload_len < 2) {
|
||||
|
@ -198,8 +196,10 @@ gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
GST_LOG_OBJECT (rtpg729depay, "G729 payload contains CNG frame");
|
||||
}
|
||||
|
||||
outbuf = gst_rtp_buffer_get_payload_buffer (buf);
|
||||
marker = gst_rtp_buffer_get_marker (buf);
|
||||
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
|
||||
marker = gst_rtp_buffer_get_marker (&rtp);
|
||||
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
||||
if (marker) {
|
||||
/* marker bit starts talkspurt */
|
||||
|
@ -207,7 +207,7 @@ gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
}
|
||||
|
||||
GST_LOG_OBJECT (depayload, "pushing buffer of size %d",
|
||||
GST_BUFFER_SIZE (outbuf));
|
||||
gst_buffer_get_size (outbuf));
|
||||
|
||||
return outbuf;
|
||||
|
||||
|
|
|
@ -74,26 +74,8 @@ static GstStaticPadTemplate gst_rtp_g729_pay_src_template =
|
|||
"clock-rate = (int) 8000, " "encoding-name = (string) \"G729\"")
|
||||
);
|
||||
|
||||
GST_BOILERPLATE (GstRTPG729Pay, gst_rtp_g729_pay, GstBaseRTPPayload,
|
||||
GST_TYPE_BASE_RTP_PAYLOAD);
|
||||
|
||||
static void
|
||||
gst_rtp_g729_pay_base_init (gpointer klass)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_rtp_g729_pay_sink_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&gst_rtp_g729_pay_src_template));
|
||||
gst_element_class_set_details_simple (element_class, "RTP G.729 payloader",
|
||||
"Codec/Payloader/Network/RTP",
|
||||
"Packetize G.729 audio into RTP packets",
|
||||
"Olivier Crete <olivier.crete@collabora.co.uk>");
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (rtpg729pay_debug, "rtpg729pay", 0,
|
||||
"G.729 RTP Payloader");
|
||||
}
|
||||
#define gst_rtp_g729_pay_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstRTPG729Pay, gst_rtp_g729_pay, GST_TYPE_BASE_RTP_PAYLOAD);
|
||||
|
||||
static void
|
||||
gst_rtp_g729_pay_finalize (GObject * object)
|
||||
|
@ -112,16 +94,29 @@ gst_rtp_g729_pay_class_init (GstRTPG729PayClass * klass)
|
|||
GstElementClass *gstelement_class = (GstElementClass *) klass;
|
||||
GstBaseRTPPayloadClass *payload_class = GST_BASE_RTP_PAYLOAD_CLASS (klass);
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (rtpg729pay_debug, "rtpg729pay", 0,
|
||||
"G.729 RTP Payloader");
|
||||
|
||||
gobject_class->finalize = gst_rtp_g729_pay_finalize;
|
||||
|
||||
gstelement_class->change_state = gst_rtp_g729_pay_change_state;
|
||||
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
gst_static_pad_template_get (&gst_rtp_g729_pay_sink_template));
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
gst_static_pad_template_get (&gst_rtp_g729_pay_src_template));
|
||||
|
||||
gst_element_class_set_details_simple (gstelement_class, "RTP G.729 payloader",
|
||||
"Codec/Payloader/Network/RTP",
|
||||
"Packetize G.729 audio into RTP packets",
|
||||
"Olivier Crete <olivier.crete@collabora.co.uk>");
|
||||
|
||||
payload_class->set_caps = gst_rtp_g729_pay_set_caps;
|
||||
payload_class->handle_buffer = gst_rtp_g729_pay_handle_buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_g729_pay_init (GstRTPG729Pay * pay, GstRTPG729PayClass * klass)
|
||||
gst_rtp_g729_pay_init (GstRTPG729Pay * pay)
|
||||
{
|
||||
GstBaseRTPPayload *payload = GST_BASE_RTP_PAYLOAD (pay);
|
||||
|
||||
|
@ -170,6 +165,7 @@ gst_rtp_g729_pay_push (GstRTPG729Pay * rtpg729pay,
|
|||
GstBuffer *outbuf;
|
||||
guint8 *payload;
|
||||
GstFlowReturn ret;
|
||||
GstRTPBuffer rtp = { NULL };
|
||||
|
||||
basepayload = GST_BASE_RTP_PAYLOAD (rtpg729pay);
|
||||
|
||||
|
@ -179,8 +175,10 @@ gst_rtp_g729_pay_push (GstRTPG729Pay * rtpg729pay,
|
|||
/* create buffer to hold the payload */
|
||||
outbuf = gst_rtp_buffer_new_allocate (payload_len, 0, 0);
|
||||
|
||||
gst_rtp_buffer_map (outbuf, GST_MAP_READWRITE, &rtp);
|
||||
|
||||
/* copy payload */
|
||||
payload = gst_rtp_buffer_get_payload (outbuf);
|
||||
payload = gst_rtp_buffer_get_payload (&rtp);
|
||||
memcpy (payload, data, payload_len);
|
||||
|
||||
/* set metadata */
|
||||
|
@ -196,9 +194,10 @@ gst_rtp_g729_pay_push (GstRTPG729Pay * rtpg729pay,
|
|||
if (G_UNLIKELY (rtpg729pay->discont)) {
|
||||
GST_DEBUG_OBJECT (basepayload, "discont, setting marker bit");
|
||||
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;
|
||||
}
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
||||
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 min_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 &&
|
||||
available % G729_FRAME_SIZE != G729B_CN_FRAME_SIZE)
|
||||
if (size % G729_FRAME_SIZE != 0 &&
|
||||
size % G729_FRAME_SIZE != G729B_CN_FRAME_SIZE)
|
||||
goto invalid_size;
|
||||
|
||||
/* 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;
|
||||
available = gst_adapter_available (adapter);
|
||||
|
||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||
|
||||
/* resync rtp time on discont or a discontinuous cn packet */
|
||||
if (GST_BUFFER_IS_DISCONT (buf)) {
|
||||
/* flush remainder */
|
||||
|
@ -311,26 +314,27 @@ gst_rtp_g729_pay_handle_buffer (GstBaseRTPPayload * payload, GstBuffer * buf)
|
|||
available = 0;
|
||||
}
|
||||
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)
|
||||
gst_rtp_g729_pay_recalc_rtp_time (rtpg729pay, GST_BUFFER_TIMESTAMP (buf));
|
||||
if (size < G729_FRAME_SIZE)
|
||||
gst_rtp_g729_pay_recalc_rtp_time (rtpg729pay, timestamp);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* let's reset the base timestamp when the adapter is empty */
|
||||
if (available == 0)
|
||||
rtpg729pay->next_ts = GST_BUFFER_TIMESTAMP (buf);
|
||||
rtpg729pay->next_ts = timestamp;
|
||||
|
||||
if (available == 0 &&
|
||||
GST_BUFFER_SIZE (buf) >= min_payload_len &&
|
||||
GST_BUFFER_SIZE (buf) <= max_payload_len) {
|
||||
ret = gst_rtp_g729_pay_push (rtpg729pay,
|
||||
GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
|
||||
if (available == 0 && size >= min_payload_len && size <= max_payload_len) {
|
||||
guint8 *data;
|
||||
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
ret = gst_rtp_g729_pay_push (rtpg729pay, data, size);
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
gst_buffer_unref (buf);
|
||||
return ret;
|
||||
}
|
||||
|
@ -364,7 +368,7 @@ invalid_size:
|
|||
("Invalid input buffer size"),
|
||||
("Invalid buffer size, should be a multiple of"
|
||||
" 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);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
|
|
|
@ -62,30 +62,27 @@ static GstBuffer *gst_rtp_gsm_depay_process (GstBaseRTPDepayload * _depayload,
|
|||
static gboolean gst_rtp_gsm_depay_setcaps (GstBaseRTPDepayload * _depayload,
|
||||
GstCaps * caps);
|
||||
|
||||
GST_BOILERPLATE (GstRTPGSMDepay, gst_rtp_gsm_depay, GstBaseRTPDepayload,
|
||||
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>");
|
||||
}
|
||||
#define gst_rtp_gsm_depay_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstRTPGSMDepay, gst_rtp_gsm_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
|
||||
|
||||
static void
|
||||
gst_rtp_gsm_depay_class_init (GstRTPGSMDepayClass * klass)
|
||||
{
|
||||
GstElementClass *gstelement_class;
|
||||
GstBaseRTPDepayloadClass *gstbasertp_depayload_class;
|
||||
|
||||
gstelement_class = (GstElementClass *) 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->set_caps = gst_rtp_gsm_depay_setcaps;
|
||||
|
||||
|
@ -94,10 +91,8 @@ gst_rtp_gsm_depay_class_init (GstRTPGSMDepayClass * klass)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_rtp_gsm_depay_init (GstRTPGSMDepay * rtpgsmdepay,
|
||||
GstRTPGSMDepayClass * klass)
|
||||
gst_rtp_gsm_depay_init (GstRTPGSMDepay * rtpgsmdepay)
|
||||
{
|
||||
/* needed because of GST_BOILERPLATE */
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -127,14 +122,19 @@ gst_rtp_gsm_depay_process (GstBaseRTPDepayload * _depayload, GstBuffer * buf)
|
|||
{
|
||||
GstBuffer *outbuf = NULL;
|
||||
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_BUFFER_SIZE (buf), marker,
|
||||
gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf));
|
||||
gst_buffer_get_size (buf), marker,
|
||||
gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
|
||||
|
||||
outbuf = gst_rtp_buffer_get_payload_buffer (buf);
|
||||
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
|
||||
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
||||
if (marker) {
|
||||
/* mark start of talkspurt with DISCONT */
|
||||
|
|
|
@ -57,40 +57,37 @@ static gboolean gst_rtp_gsm_pay_setcaps (GstBaseRTPPayload * payload,
|
|||
static GstFlowReturn gst_rtp_gsm_pay_handle_buffer (GstBaseRTPPayload * payload,
|
||||
GstBuffer * buffer);
|
||||
|
||||
GST_BOILERPLATE (GstRTPGSMPay, gst_rtp_gsm_pay, GstBaseRTPPayload,
|
||||
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>");
|
||||
}
|
||||
#define gst_rtp_gsm_pay_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstRTPGSMPay, gst_rtp_gsm_pay, GST_TYPE_BASE_RTP_PAYLOAD);
|
||||
|
||||
static void
|
||||
gst_rtp_gsm_pay_class_init (GstRTPGSMPayClass * klass)
|
||||
{
|
||||
GstElementClass *gstelement_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,
|
||||
"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
|
||||
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_PT (rtpgsmpay) = GST_RTP_PAYLOAD_GSM;
|
||||
|
@ -128,15 +125,18 @@ gst_rtp_gsm_pay_handle_buffer (GstBaseRTPPayload * basepayload,
|
|||
GstBuffer * buffer)
|
||||
{
|
||||
GstRTPGSMPay *rtpgsmpay;
|
||||
guint size, payload_len;
|
||||
guint payload_len;
|
||||
GstBuffer *outbuf;
|
||||
guint8 *payload, *data;
|
||||
GstClockTime timestamp, duration;
|
||||
GstFlowReturn ret;
|
||||
gsize size;
|
||||
GstRTPBuffer rtp = { NULL };
|
||||
|
||||
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);
|
||||
duration = GST_BUFFER_DURATION (buffer);
|
||||
|
||||
|
@ -144,12 +144,8 @@ gst_rtp_gsm_pay_handle_buffer (GstBaseRTPPayload * basepayload,
|
|||
payload_len = size;
|
||||
|
||||
/* FIXME, just error out for now */
|
||||
if (payload_len > GST_BASE_RTP_PAYLOAD_MTU (rtpgsmpay)) {
|
||||
GST_ELEMENT_ERROR (rtpgsmpay, STREAM, ENCODE, (NULL),
|
||||
("payload_len %u > mtu %u", payload_len,
|
||||
GST_BASE_RTP_PAYLOAD_MTU (rtpgsmpay)));
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
if (payload_len > GST_BASE_RTP_PAYLOAD_MTU (rtpgsmpay))
|
||||
goto too_big;
|
||||
|
||||
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;
|
||||
|
||||
/* get payload */
|
||||
payload = gst_rtp_buffer_get_payload (outbuf);
|
||||
|
||||
data = GST_BUFFER_DATA (buffer);
|
||||
gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
|
||||
|
||||
/* 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_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);
|
||||
|
||||
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
|
||||
|
|
|
@ -890,9 +890,8 @@ gst_rtp_h263_pay_move_window_right (GstRtpH263PayContext * context, guint n,
|
|||
} else {
|
||||
if (n > rest_bits) {
|
||||
context->window =
|
||||
(context->
|
||||
window << rest_bits) | (*context->win_end & (((guint) pow (2.0,
|
||||
(double) rest_bits)) - 1));
|
||||
(context->window << rest_bits) | (*context->
|
||||
win_end & (((guint) pow (2.0, (double) rest_bits)) - 1));
|
||||
n -= rest_bits;
|
||||
rest_bits = 0;
|
||||
} 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);
|
||||
context->gobs =
|
||||
(GstRtpH263PayGob **) g_malloc0 (format_props[context->
|
||||
piclayer->ptype_srcformat][0] * sizeof (GstRtpH263PayGob *));
|
||||
(GstRtpH263PayGob **) g_malloc0 (format_props[context->piclayer->
|
||||
ptype_srcformat][0] * sizeof (GstRtpH263PayGob *));
|
||||
|
||||
|
||||
for (i = 0; i < format_props[context->piclayer->ptype_srcformat][0]; i++) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* 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
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
|
|
@ -69,8 +69,9 @@ typedef struct _GstADUFrame
|
|||
GstBuffer *buffer;
|
||||
} GstADUFrame;
|
||||
|
||||
GST_BOILERPLATE (GstRtpMPARobustDepay, gst_rtp_mpa_robust_depay,
|
||||
GstBaseRTPDepayload, GST_TYPE_BASE_RTP_DEPAYLOAD);
|
||||
#define gst_rtp_mpa_robust_depay_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstRtpMPARobustDepay, gst_rtp_mpa_robust_depay,
|
||||
GST_TYPE_BASE_RTP_DEPAYLOAD);
|
||||
|
||||
static GstStateChangeReturn gst_rtp_mpa_robust_change_state (GstElement *
|
||||
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 *
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
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;
|
||||
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (rtpmparobustdepay_debug, "rtpmparobustdepay", 0,
|
||||
"Robust MPEG Audio RTP Depayloader");
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
gstelement_class = (GstElementClass *) klass;
|
||||
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
|
||||
|
@ -126,16 +113,22 @@ gst_rtp_mpa_robust_depay_class_init (GstRtpMPARobustDepayClass * klass)
|
|||
gstelement_class->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->process = gst_rtp_mpa_robust_depay_process;
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (rtpmparobustdepay_debug, "rtpmparobustdepay", 0,
|
||||
"Robust MPEG Audio RTP Depayloader");
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_mpa_robust_depay_init (GstRtpMPARobustDepay * rtpmpadepay,
|
||||
GstRtpMPARobustDepayClass * klass)
|
||||
gst_rtp_mpa_robust_depay_init (GstRtpMPARobustDepay * rtpmpadepay)
|
||||
{
|
||||
rtpmpadepay->adapter = gst_adapter_new ();
|
||||
rtpmpadepay->adu_frames = g_queue_new ();
|
||||
|
@ -280,6 +273,8 @@ gst_rtp_mpa_robust_depay_generate_dummy_frame (GstRtpMPARobustDepay *
|
|||
rtpmpadepay, GstADUFrame * frame)
|
||||
{
|
||||
GstADUFrame *dummy;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
|
||||
dummy = g_slice_dup (GstADUFrame, frame);
|
||||
|
||||
|
@ -292,8 +287,12 @@ gst_rtp_mpa_robust_depay_generate_dummy_frame (GstRtpMPARobustDepay *
|
|||
dummy->backpointer = 0;
|
||||
|
||||
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);
|
||||
|
||||
return dummy;
|
||||
|
@ -309,15 +308,18 @@ gst_rtp_mpa_robust_depay_queue_frame (GstRtpMPARobustDepay * rtpmpadepay,
|
|||
GstADUFrame *frame = NULL;
|
||||
guint version, layer, channels, size;
|
||||
guint crc;
|
||||
guint8 *bdata;
|
||||
gsize bsize;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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),
|
||||
frame->header, &version, &layer, &channels, NULL, NULL, NULL, &crc);
|
||||
|
@ -339,7 +341,7 @@ gst_rtp_mpa_robust_depay_queue_frame (GstRtpMPARobustDepay * rtpmpadepay,
|
|||
|
||||
/* backpointer */
|
||||
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;
|
||||
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;
|
||||
|
||||
/* some size validation checks */
|
||||
if (4 + frame->side_info > GST_BUFFER_SIZE (buf))
|
||||
if (4 + frame->side_info > bsize)
|
||||
goto corrupt_frame;
|
||||
|
||||
/* ADU data would then extend past MP3 frame,
|
||||
* 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;
|
||||
|
||||
gst_buffer_unmap (buf, bdata, bsize);
|
||||
|
||||
/* ok, take buffer and queue */
|
||||
frame->buffer = buf;
|
||||
g_queue_push_tail (rtpmpadepay->adu_frames, frame);
|
||||
|
@ -369,6 +373,7 @@ gst_rtp_mpa_robust_depay_queue_frame (GstRtpMPARobustDepay * rtpmpadepay,
|
|||
corrupt_frame:
|
||||
{
|
||||
GST_DEBUG_OBJECT (rtpmpadepay, "frame is corrupt");
|
||||
gst_buffer_unmap (buf, bdata, bsize);
|
||||
gst_buffer_unref (buf);
|
||||
if (frame)
|
||||
g_slice_free (GstADUFrame, frame);
|
||||
|
@ -409,10 +414,13 @@ gst_rtp_mpa_robust_depay_deinterleave (GstRtpMPARobustDepay * rtpmpadepay,
|
|||
{
|
||||
gboolean ret = FALSE;
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
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;
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
|
||||
iindex = val >> 3;
|
||||
icc = val & 0x7;
|
||||
|
||||
|
@ -468,6 +476,8 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
|
|||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
|
||||
while (1) {
|
||||
guint8 *data;
|
||||
gsize size;
|
||||
|
||||
if (G_UNLIKELY (!rtpmpadepay->cur_adu_frame)) {
|
||||
rtpmpadepay->cur_adu_frame = rtpmpadepay->adu_frames->head;
|
||||
|
@ -495,7 +505,7 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
|
|||
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)) {
|
||||
GST_LOG_OBJECT (rtpmpadepay,
|
||||
"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);
|
||||
/* bytewriter corresponds to head frame,
|
||||
* 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_BUFFER_DATA (head->buffer), 4 + head->side_info);
|
||||
data, 4 + head->side_info);
|
||||
gst_buffer_unmap (head->buffer, data, size);
|
||||
}
|
||||
|
||||
buf = frame->buffer;
|
||||
|
@ -534,15 +546,17 @@ gst_rtp_mpa_robust_depay_push_mp3_frames (GstRtpMPARobustDepay * rtpmpadepay)
|
|||
rtpmpadepay->size);
|
||||
|
||||
if (rtpmpadepay->offset) {
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
/* no need to position, simply append */
|
||||
g_assert (GST_BUFFER_SIZE (buf) > rtpmpadepay->offset);
|
||||
av = MIN (av, GST_BUFFER_SIZE (buf) - rtpmpadepay->offset);
|
||||
g_assert (size > rtpmpadepay->offset);
|
||||
av = MIN (av, size - rtpmpadepay->offset);
|
||||
GST_LOG_OBJECT (rtpmpadepay,
|
||||
"appending %d bytes from ADU frame at offset %d", av,
|
||||
rtpmpadepay->offset);
|
||||
gst_byte_writer_put_data (rtpmpadepay->mp3_frame,
|
||||
GST_BUFFER_DATA (buf) + rtpmpadepay->offset, av);
|
||||
data + rtpmpadepay->offset, av);
|
||||
rtpmpadepay->offset += av;
|
||||
gst_buffer_unmap (buf, data, size);
|
||||
} else {
|
||||
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);
|
||||
} else {
|
||||
/* position and append */
|
||||
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
|
||||
GST_LOG_OBJECT (rtpmpadepay, "adding to current MP3 frame");
|
||||
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_BUFFER_DATA (buf) + 4 + frame->side_info, av);
|
||||
data + 4 + frame->side_info, av);
|
||||
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;
|
||||
guint av, size;
|
||||
GstClockTime timestamp;
|
||||
GstRTPBuffer rtp = { NULL };
|
||||
|
||||
rtpmpadepay = GST_RTP_MPA_ROBUST_DEPAY (depayload);
|
||||
|
||||
payload_len = gst_rtp_buffer_get_payload_len (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)
|
||||
goto short_read;
|
||||
|
||||
payload = gst_rtp_buffer_get_payload (buf);
|
||||
payload = gst_rtp_buffer_get_payload (&rtp);
|
||||
offset = 0;
|
||||
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",
|
||||
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));
|
||||
|
||||
if (cont) {
|
||||
|
@ -693,7 +712,7 @@ gst_rtp_mpa_robust_depay_process (GstBaseRTPDepayload * depayload,
|
|||
"discarding continuation fragment without prior fragment");
|
||||
gst_buffer_unref (buf);
|
||||
} else {
|
||||
av += GST_BUFFER_SIZE (buf);
|
||||
av += gst_buffer_get_size (buf);
|
||||
gst_adapter_push (rtpmpadepay->adapter, buf);
|
||||
if (av == size) {
|
||||
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 = GST_CLOCK_TIME_NONE;
|
||||
}
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
||||
return NULL;
|
||||
|
||||
|
@ -735,6 +755,7 @@ short_read:
|
|||
{
|
||||
GST_ELEMENT_WARNING (rtpmpadepay, STREAM, DECODE,
|
||||
(NULL), ("Packet contains invalid data"));
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,8 +53,7 @@ static GstStaticPadTemplate gst_rtp_mpv_depay_sink_template =
|
|||
"clock-rate = (int) 90000")
|
||||
);
|
||||
|
||||
GST_BOILERPLATE (GstRtpMPVDepay, gst_rtp_mpv_depay, GstBaseRTPDepayload,
|
||||
GST_TYPE_BASE_RTP_DEPAYLOAD);
|
||||
G_DEFINE_TYPE (GstRtpMPVDepay, gst_rtp_mpv_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
|
||||
|
||||
static gboolean gst_rtp_mpv_depay_setcaps (GstBaseRTPDepayload * depayload,
|
||||
GstCaps * caps);
|
||||
|
@ -62,27 +61,23 @@ static GstBuffer *gst_rtp_mpv_depay_process (GstBaseRTPDepayload * depayload,
|
|||
GstBuffer * buf);
|
||||
|
||||
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_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_element_class_set_details_simple (element_class,
|
||||
gst_element_class_set_details_simple (gstelement_class,
|
||||
"RTP MPEG video depayloader", "Codec/Depayloader/Network/RTP",
|
||||
"Extracts MPEG video from RTP packets (RFC 2250)",
|
||||
"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->process = gst_rtp_mpv_depay_process;
|
||||
|
@ -92,10 +87,8 @@ gst_rtp_mpv_depay_class_init (GstRtpMPVDepayClass * klass)
|
|||
}
|
||||
|
||||
static void
|
||||
gst_rtp_mpv_depay_init (GstRtpMPVDepay * rtpmpvdepay,
|
||||
GstRtpMPVDepayClass * klass)
|
||||
gst_rtp_mpv_depay_init (GstRtpMPVDepay * rtpmpvdepay)
|
||||
{
|
||||
/* needed because of GST_BOILERPLATE */
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -126,16 +119,19 @@ gst_rtp_mpv_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
{
|
||||
GstRtpMPVDepay *rtpmpvdepay;
|
||||
GstBuffer *outbuf;
|
||||
GstRTPBuffer rtp = { NULL };
|
||||
|
||||
rtpmpvdepay = GST_RTP_MPV_DEPAY (depayload);
|
||||
|
||||
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
|
||||
|
||||
{
|
||||
gint payload_len, payload_header;
|
||||
guint8 *payload;
|
||||
guint8 T;
|
||||
|
||||
payload_len = gst_rtp_buffer_get_payload_len (buf);
|
||||
payload = gst_rtp_buffer_get_payload (buf);
|
||||
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
|
||||
payload = gst_rtp_buffer_get_payload (&rtp);
|
||||
payload_header = 0;
|
||||
|
||||
if (payload_len <= 4)
|
||||
|
@ -174,11 +170,11 @@ gst_rtp_mpv_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
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_rtp_mpv_depay_chain: pushing buffer of size %d",
|
||||
GST_BUFFER_SIZE (outbuf));
|
||||
gst_buffer_get_size (outbuf));
|
||||
|
||||
return outbuf;
|
||||
}
|
||||
|
|
|
@ -60,23 +60,8 @@ static GstFlowReturn gst_rtp_mpv_pay_handle_buffer (GstBaseRTPPayload *
|
|||
payload, GstBuffer * buffer);
|
||||
static gboolean gst_rtp_mpv_pay_handle_event (GstPad * pad, GstEvent * event);
|
||||
|
||||
GST_BOILERPLATE (GstRTPMPVPay, gst_rtp_mpv_pay, GstBaseRTPPayload,
|
||||
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>");
|
||||
}
|
||||
#define gst_rtp_mpv_pay_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstRTPMPVPay, gst_rtp_mpv_pay, GST_TYPE_BASE_RTP_PAYLOAD);
|
||||
|
||||
static void
|
||||
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;
|
||||
|
||||
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->handle_buffer = gst_rtp_mpv_pay_handle_buffer;
|
||||
gstbasertppayload_class->handle_event = gst_rtp_mpv_pay_handle_event;
|
||||
|
@ -102,7 +97,7 @@ gst_rtp_mpv_pay_class_init (GstRTPMPVPayClass * klass)
|
|||
}
|
||||
|
||||
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_PT (rtpmpvpay) = GST_RTP_PAYLOAD_MPV;
|
||||
|
@ -181,6 +176,7 @@ gst_rtp_mpv_pay_flush (GstRTPMPVPay * rtpmpvpay)
|
|||
guint towrite;
|
||||
guint packet_len;
|
||||
guint payload_len;
|
||||
GstRTPBuffer rtp = { NULL };
|
||||
|
||||
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);
|
||||
|
||||
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
|
||||
*
|
||||
* 0 1 2 3
|
||||
|
@ -211,7 +209,8 @@ gst_rtp_mpv_pay_flush (GstRTPMPVPay * rtpmpvpay)
|
|||
|
||||
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;
|
||||
|
||||
|
|
|
@ -65,38 +65,35 @@ static GstBuffer *gst_rtp_pcma_depay_process (GstBaseRTPDepayload * depayload,
|
|||
static gboolean gst_rtp_pcma_depay_setcaps (GstBaseRTPDepayload * depayload,
|
||||
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);
|
||||
|
||||
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
|
||||
gst_rtp_pcma_depay_class_init (GstRtpPcmaDepayClass * klass)
|
||||
{
|
||||
GstElementClass *gstelement_class;
|
||||
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
|
||||
|
||||
gstelement_class = (GstElementClass *) 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->set_caps = gst_rtp_pcma_depay_setcaps;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_pcma_depay_init (GstRtpPcmaDepay * rtppcmadepay,
|
||||
GstRtpPcmaDepayClass * klass)
|
||||
gst_rtp_pcma_depay_init (GstRtpPcmaDepay * rtppcmadepay)
|
||||
{
|
||||
GstBaseRTPDepayload *depayload;
|
||||
|
||||
|
@ -133,15 +130,19 @@ gst_rtp_pcma_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
GstBuffer *outbuf = NULL;
|
||||
gboolean marker;
|
||||
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_BUFFER_SIZE (buf), marker,
|
||||
gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf));
|
||||
gst_buffer_get_size (buf), marker,
|
||||
gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
|
||||
|
||||
len = gst_rtp_buffer_get_payload_len (buf);
|
||||
outbuf = gst_rtp_buffer_get_payload_buffer (buf);
|
||||
len = gst_rtp_buffer_get_payload_len (&rtp);
|
||||
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
||||
GST_BUFFER_DURATION (outbuf) =
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
return outbuf;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,36 +53,34 @@ static GstStaticPadTemplate gst_rtp_pcma_pay_src_template =
|
|||
static gboolean gst_rtp_pcma_pay_setcaps (GstBaseRTPPayload * payload,
|
||||
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);
|
||||
|
||||
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
|
||||
gst_rtp_pcma_pay_class_init (GstRtpPcmaPayClass * klass)
|
||||
{
|
||||
GstElementClass *gstelement_class;
|
||||
GstBaseRTPPayloadClass *gstbasertppayload_class;
|
||||
|
||||
gstelement_class = (GstElementClass *) 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;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_pcma_pay_init (GstRtpPcmaPay * rtppcmapay, GstRtpPcmaPayClass * klass)
|
||||
gst_rtp_pcma_pay_init (GstRtpPcmaPay * rtppcmapay)
|
||||
{
|
||||
GstBaseRTPAudioPayload *basertpaudiopayload;
|
||||
|
||||
|
|
|
@ -65,38 +65,35 @@ static GstBuffer *gst_rtp_pcmu_depay_process (GstBaseRTPDepayload * depayload,
|
|||
static gboolean gst_rtp_pcmu_depay_setcaps (GstBaseRTPDepayload * depayload,
|
||||
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);
|
||||
|
||||
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
|
||||
gst_rtp_pcmu_depay_class_init (GstRtpPcmuDepayClass * klass)
|
||||
{
|
||||
GstElementClass *gstelement_class;
|
||||
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
|
||||
|
||||
gstelement_class = (GstElementClass *) 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->set_caps = gst_rtp_pcmu_depay_setcaps;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_pcmu_depay_init (GstRtpPcmuDepay * rtppcmudepay,
|
||||
GstRtpPcmuDepayClass * klass)
|
||||
gst_rtp_pcmu_depay_init (GstRtpPcmuDepay * rtppcmudepay)
|
||||
{
|
||||
GstBaseRTPDepayload *depayload;
|
||||
|
||||
|
@ -133,15 +130,19 @@ gst_rtp_pcmu_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
GstBuffer *outbuf = NULL;
|
||||
guint len;
|
||||
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_BUFFER_SIZE (buf), marker,
|
||||
gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf));
|
||||
gst_buffer_get_size (buf), marker,
|
||||
gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
|
||||
|
||||
len = gst_rtp_buffer_get_payload_len (buf);
|
||||
outbuf = gst_rtp_buffer_get_payload_buffer (buf);
|
||||
len = gst_rtp_buffer_get_payload_len (&rtp);
|
||||
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
||||
GST_BUFFER_DURATION (outbuf) =
|
||||
gst_util_uint64_scale_int (len, GST_SECOND, depayload->clock_rate);
|
||||
|
|
|
@ -53,36 +53,34 @@ static GstStaticPadTemplate gst_rtp_pcmu_pay_src_template =
|
|||
static gboolean gst_rtp_pcmu_pay_setcaps (GstBaseRTPPayload * payload,
|
||||
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);
|
||||
|
||||
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
|
||||
gst_rtp_pcmu_pay_class_init (GstRtpPcmuPayClass * klass)
|
||||
{
|
||||
GstElementClass *gstelement_class;
|
||||
GstBaseRTPPayloadClass *gstbasertppayload_class;
|
||||
|
||||
gstelement_class = (GstElementClass *) 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;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_rtp_pcmu_pay_init (GstRtpPcmuPay * rtppcmupay, GstRtpPcmuPayClass * klass)
|
||||
gst_rtp_pcmu_pay_init (GstRtpPcmuPay * rtppcmupay)
|
||||
{
|
||||
GstBaseRTPAudioPayload *basertpaudiopayload;
|
||||
|
||||
|
|
Loading…
Reference in a new issue