Commit 6717c860 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller

rtp: depayloaders: implement process_rtp_packet() vfunc

For more optimised RTP packet handling: means we don't
need to map the input buffer again but can just re-use
the mapping the base class has already done.

https://bugzilla.gnome.org/show_bug.cgi?id=750235
parent fe787425
......@@ -84,7 +84,7 @@ G_DEFINE_TYPE (GstRtpL16Depay, gst_rtp_L16_depay, GST_TYPE_RTP_BASE_DEPAYLOAD);
static gboolean gst_rtp_L16_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
static GstBuffer *gst_rtp_L16_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
GstRTPBuffer * rtp);
static void
gst_rtp_L16_depay_class_init (GstRtpL16DepayClass * klass)
......@@ -96,7 +96,7 @@ gst_rtp_L16_depay_class_init (GstRtpL16DepayClass * klass)
gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
gstrtpbasedepayload_class->set_caps = gst_rtp_L16_depay_setcaps;
gstrtpbasedepayload_class->process = gst_rtp_L16_depay_process;
gstrtpbasedepayload_class->process_rtp_packet = gst_rtp_L16_depay_process;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_L16_depay_src_template));
......@@ -225,26 +225,24 @@ no_clockrate:
}
static GstBuffer *
gst_rtp_L16_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
gst_rtp_L16_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
{
GstRtpL16Depay *rtpL16depay;
GstBuffer *outbuf;
gint payload_len;
gboolean marker;
GstRTPBuffer rtp = { NULL };
rtpL16depay = GST_RTP_L16_DEPAY (depayload);
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
payload_len = gst_rtp_buffer_get_payload_len (rtp);
if (payload_len <= 0)
goto empty_packet;
GST_DEBUG_OBJECT (rtpL16depay, "got payload of %d bytes", payload_len);
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
marker = gst_rtp_buffer_get_marker (&rtp);
outbuf = gst_rtp_buffer_get_payload_buffer (rtp);
marker = gst_rtp_buffer_get_marker (rtp);
if (marker) {
/* mark talk spurt with RESYNC */
......@@ -259,8 +257,6 @@ gst_rtp_L16_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
goto reorder_failed;
}
gst_rtp_buffer_unmap (&rtp);
return outbuf;
/* ERRORS */
......@@ -268,14 +264,12 @@ empty_packet:
{
GST_ELEMENT_WARNING (rtpL16depay, STREAM, DECODE,
("Empty Payload."), (NULL));
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
reorder_failed:
{
GST_ELEMENT_ERROR (rtpL16depay, STREAM, DECODE,
("Channel reordering failed."), (NULL));
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}
......
......@@ -73,7 +73,7 @@ G_DEFINE_TYPE (GstRtpL24Depay, gst_rtp_L24_depay, GST_TYPE_RTP_BASE_DEPAYLOAD);
static gboolean gst_rtp_L24_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
static GstBuffer *gst_rtp_L24_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
GstRTPBuffer * rtp);
static void
gst_rtp_L24_depay_class_init (GstRtpL24DepayClass * klass)
......@@ -85,7 +85,7 @@ gst_rtp_L24_depay_class_init (GstRtpL24DepayClass * klass)
gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
gstrtpbasedepayload_class->set_caps = gst_rtp_L24_depay_setcaps;
gstrtpbasedepayload_class->process = gst_rtp_L24_depay_process;
gstrtpbasedepayload_class->process_rtp_packet = gst_rtp_L24_depay_process;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_L24_depay_src_template));
......@@ -203,26 +203,24 @@ no_clockrate:
}
static GstBuffer *
gst_rtp_L24_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
gst_rtp_L24_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
{
GstRtpL24Depay *rtpL24depay;
GstBuffer *outbuf;
gint payload_len;
gboolean marker;
GstRTPBuffer rtp = { NULL };
rtpL24depay = GST_RTP_L24_DEPAY (depayload);
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
payload_len = gst_rtp_buffer_get_payload_len (rtp);
if (payload_len <= 0)
goto empty_packet;
GST_DEBUG_OBJECT (rtpL24depay, "got payload of %d bytes", payload_len);
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
marker = gst_rtp_buffer_get_marker (&rtp);
outbuf = gst_rtp_buffer_get_payload_buffer (rtp);
marker = gst_rtp_buffer_get_marker (rtp);
if (marker) {
/* mark talk spurt with RESYNC */
......@@ -237,8 +235,6 @@ gst_rtp_L24_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
goto reorder_failed;
}
gst_rtp_buffer_unmap (&rtp);
return outbuf;
/* ERRORS */
......@@ -246,14 +242,12 @@ empty_packet:
{
GST_ELEMENT_WARNING (rtpL24depay, STREAM, DECODE,
("Empty Payload."), (NULL));
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
reorder_failed:
{
GST_ELEMENT_ERROR (rtpL24depay, STREAM, DECODE,
("Channel reordering failed."), (NULL));
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}
......
......@@ -67,7 +67,7 @@ G_DEFINE_TYPE (GstRtpAC3Depay, gst_rtp_ac3_depay, GST_TYPE_RTP_BASE_DEPAYLOAD);
static gboolean gst_rtp_ac3_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
static GstBuffer *gst_rtp_ac3_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
GstRTPBuffer * rtp);
static void
gst_rtp_ac3_depay_class_init (GstRtpAC3DepayClass * klass)
......@@ -89,7 +89,7 @@ gst_rtp_ac3_depay_class_init (GstRtpAC3DepayClass * klass)
"Wim Taymans <wim.taymans@gmail.com>");
gstrtpbasedepayload_class->set_caps = gst_rtp_ac3_depay_setcaps;
gstrtpbasedepayload_class->process = gst_rtp_ac3_depay_process;
gstrtpbasedepayload_class->process_rtp_packet = gst_rtp_ac3_depay_process;
GST_DEBUG_CATEGORY_INIT (rtpac3depay_debug, "rtpac3depay", 0,
"AC3 Audio RTP Depayloader");
......@@ -123,22 +123,19 @@ gst_rtp_ac3_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
}
static GstBuffer *
gst_rtp_ac3_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
gst_rtp_ac3_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
{
GstRtpAC3Depay *rtpac3depay;
GstBuffer *outbuf;
GstRTPBuffer rtp = { NULL, };
guint8 *payload;
guint16 FT, NF;
rtpac3depay = GST_RTP_AC3_DEPAY (depayload);
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
if (gst_rtp_buffer_get_payload_len (&rtp) < 2)
if (gst_rtp_buffer_get_payload_len (rtp) < 2)
goto empty_packet;
payload = gst_rtp_buffer_get_payload (&rtp);
payload = gst_rtp_buffer_get_payload (rtp);
/* strip off header
*
......@@ -154,9 +151,7 @@ gst_rtp_ac3_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
GST_DEBUG_OBJECT (rtpac3depay, "FT: %d, NF: %d", FT, NF);
/* We don't bother with fragmented packets yet */
outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, 2, -1);
gst_rtp_buffer_unmap (&rtp);
outbuf = gst_rtp_buffer_get_payload_subbuffer (rtp, 2, -1);
if (outbuf)
GST_DEBUG_OBJECT (rtpac3depay, "pushing buffer of size %" G_GSIZE_FORMAT,
......@@ -169,7 +164,6 @@ empty_packet:
{
GST_ELEMENT_WARNING (rtpac3depay, STREAM, DECODE,
("Empty Payload."), (NULL));
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}
......
......@@ -124,7 +124,7 @@ static GstStaticPadTemplate gst_rtp_amr_depay_src_template =
static gboolean gst_rtp_amr_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
static GstBuffer *gst_rtp_amr_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
GstRTPBuffer * rtp);
#define gst_rtp_amr_depay_parent_class parent_class
G_DEFINE_TYPE (GstRtpAMRDepay, gst_rtp_amr_depay, GST_TYPE_RTP_BASE_DEPAYLOAD);
......@@ -148,7 +148,7 @@ gst_rtp_amr_depay_class_init (GstRtpAMRDepayClass * klass)
"Extracts AMR or AMR-WB audio from RTP packets (RFC 3267)",
"Wim Taymans <wim.taymans@gmail.com>");
gstrtpbasedepayload_class->process = gst_rtp_amr_depay_process;
gstrtpbasedepayload_class->process_rtp_packet = gst_rtp_amr_depay_process;
gstrtpbasedepayload_class->set_caps = gst_rtp_amr_depay_setcaps;
GST_DEBUG_CATEGORY_INIT (rtpamrdepay_debug, "rtpamrdepay", 0,
......@@ -281,13 +281,12 @@ static const gint wb_frame_size[16] = {
};
static GstBuffer *
gst_rtp_amr_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
gst_rtp_amr_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
{
GstRtpAMRDepay *rtpamrdepay;
const gint *frame_size;
GstBuffer *outbuf = NULL;
gint payload_len;
GstRTPBuffer rtp = { NULL };
GstMapInfo map;
rtpamrdepay = GST_RTP_AMR_DEPAY (depayload);
......@@ -298,8 +297,6 @@ gst_rtp_amr_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
else
frame_size = wb_frame_size;
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
/* when we get here, 1 channel, 8000/16000 Hz, octet aligned, no CRC,
* no robust sorting, no interleaving data is to be depayloaded */
{
......@@ -308,13 +305,13 @@ gst_rtp_amr_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
gint amr_len;
gint ILL, ILP;
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
payload_len = gst_rtp_buffer_get_payload_len (rtp);
/* need at least 2 bytes for the header */
if (payload_len < 2)
goto too_small;
payload = gst_rtp_buffer_get_payload (&rtp);
payload = gst_rtp_buffer_get_payload (rtp);
/* depay CMR. The CMR is used by the sender to request
* a new encoding mode.
......@@ -419,7 +416,7 @@ gst_rtp_amr_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
/* we can set the duration because each packet is 20 milliseconds */
GST_BUFFER_DURATION (outbuf) = num_packets * 20 * GST_MSECOND;
if (gst_rtp_buffer_get_marker (&rtp)) {
if (gst_rtp_buffer_get_marker (rtp)) {
/* marker bit marks a buffer after a talkspurt. */
GST_DEBUG_OBJECT (depayload, "marker bit was set");
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_RESYNC);
......@@ -429,7 +426,6 @@ gst_rtp_amr_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
gst_buffer_get_size (outbuf));
}
gst_rtp_buffer_unmap (&rtp);
return outbuf;
/* ERRORS */
......@@ -466,7 +462,6 @@ wrong_length_2:
bad_packet:
{
/* no fatal error */
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}
......
......@@ -56,7 +56,7 @@ GST_STATIC_PAD_TEMPLATE ("src",
);
static GstBuffer *gst_rtp_bv_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
GstRTPBuffer * rtp);
static gboolean gst_rtp_bv_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
......@@ -82,7 +82,7 @@ gst_rtp_bv_depay_class_init (GstRTPBVDepayClass * klass)
"Extracts BroadcomVoice audio from RTP packets (RFC 4298)",
"Wim Taymans <wim.taymans@collabora.co.uk>");
gstrtpbasedepayload_class->process = gst_rtp_bv_depay_process;
gstrtpbasedepayload_class->process_rtp_packet = gst_rtp_bv_depay_process;
gstrtpbasedepayload_class->set_caps = gst_rtp_bv_depay_setcaps;
}
......@@ -155,22 +155,18 @@ wrong_rate:
}
static GstBuffer *
gst_rtp_bv_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
gst_rtp_bv_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
{
GstBuffer *outbuf;
gboolean marker;
GstRTPBuffer rtp = { NULL, };
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
marker = gst_rtp_buffer_get_marker (&rtp);
marker = gst_rtp_buffer_get_marker (rtp);
GST_DEBUG ("process : got %" G_GSIZE_FORMAT " bytes, mark %d ts %u seqn %d",
gst_buffer_get_size (buf), marker,
gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
gst_buffer_get_size (rtp->buffer), marker,
gst_rtp_buffer_get_timestamp (rtp), gst_rtp_buffer_get_seq (rtp));
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
gst_rtp_buffer_unmap (&rtp);
outbuf = gst_rtp_buffer_get_payload_buffer (rtp);
if (marker && outbuf) {
/* mark start of talkspurt with RESYNC */
......
......@@ -65,7 +65,7 @@ GST_STATIC_PAD_TEMPLATE ("src",
);
static GstBuffer *gst_rtp_celt_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
GstRTPBuffer * rtp);
static gboolean gst_rtp_celt_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
......@@ -95,7 +95,7 @@ gst_rtp_celt_depay_class_init (GstRtpCELTDepayClass * klass)
"Extracts CELT audio from RTP packets",
"Wim Taymans <wim.taymans@gmail.com>");
gstrtpbasedepayload_class->process = gst_rtp_celt_depay_process;
gstrtpbasedepayload_class->process_rtp_packet = gst_rtp_celt_depay_process;
gstrtpbasedepayload_class->set_caps = gst_rtp_celt_depay_setcaps;
}
......@@ -193,7 +193,7 @@ no_clockrate:
}
static GstBuffer *
gst_rtp_celt_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
gst_rtp_celt_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
{
GstBuffer *outbuf = NULL;
guint8 *payload;
......@@ -203,28 +203,25 @@ gst_rtp_celt_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
GstClockTime framesize_ns = 0, timestamp;
guint n = 0;
GstRtpCELTDepay *rtpceltdepay;
GstRTPBuffer rtp = { NULL, };
rtpceltdepay = GST_RTP_CELT_DEPAY (depayload);
clock_rate = depayload->clock_rate;
frame_size = rtpceltdepay->frame_size;
framesize_ns = gst_util_uint64_scale_int (frame_size, GST_SECOND, clock_rate);
timestamp = GST_BUFFER_PTS (buf);
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
timestamp = GST_BUFFER_PTS (rtp->buffer);
GST_LOG_OBJECT (depayload,
"got %" G_GSIZE_FORMAT " bytes, mark %d ts %u seqn %d",
gst_buffer_get_size (buf), gst_rtp_buffer_get_marker (&rtp),
gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
gst_buffer_get_size (rtp->buffer), gst_rtp_buffer_get_marker (rtp),
gst_rtp_buffer_get_timestamp (rtp), gst_rtp_buffer_get_seq (rtp));
GST_LOG_OBJECT (depayload, "got clock-rate=%d, frame_size=%d, "
"_ns=%" GST_TIME_FORMAT ", timestamp=%" GST_TIME_FORMAT, clock_rate,
frame_size, GST_TIME_ARGS (framesize_ns), GST_TIME_ARGS (timestamp));
payload = gst_rtp_buffer_get_payload (&rtp);
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
payload = gst_rtp_buffer_get_payload (rtp);
payload_len = gst_rtp_buffer_get_payload_len (rtp);
/* first count how many bytes are consumed by the size headers and make offset
* point to the first data byte */
......@@ -249,7 +246,7 @@ gst_rtp_celt_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
total_size += s + 1;
} while (s == 0xff);
outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, offset, size);
outbuf = gst_rtp_buffer_get_payload_subbuffer (rtp, offset, size);
offset += size;
if (frame_size != -1 && clock_rate != -1) {
......@@ -263,7 +260,6 @@ gst_rtp_celt_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
gst_rtp_base_depayload_push (depayload, outbuf);
}
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
......
......@@ -75,7 +75,7 @@ static GstStateChangeReturn
gst_rtp_dv_depay_change_state (GstElement * element, GstStateChange transition);
static GstBuffer *gst_rtp_dv_depay_process (GstRTPBaseDepayload * base,
GstBuffer * in);
GstRTPBuffer * rtp);
static gboolean gst_rtp_dv_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
......@@ -106,7 +106,7 @@ gst_rtp_dv_depay_class_init (GstRTPDVDepayClass * klass)
"Depayloads DV from RTP packets (RFC 3189)",
"Marcel Moreaux <marcelm@spacelabs.nl>, Wim Taymans <wim.taymans@gmail.com>");
gstrtpbasedepayload_class->process =
gstrtpbasedepayload_class->process_rtp_packet =
GST_DEBUG_FUNCPTR (gst_rtp_dv_depay_process);
gstrtpbasedepayload_class->set_caps =
GST_DEBUG_FUNCPTR (gst_rtp_dv_depay_setcaps);
......@@ -286,7 +286,7 @@ calculate_difblock_location (guint8 * block)
* NTSC.
*/
static GstBuffer *
gst_rtp_dv_depay_process (GstRTPBaseDepayload * base, GstBuffer * in)
gst_rtp_dv_depay_process (GstRTPBaseDepayload * base, GstRTPBuffer * rtp)
{
GstBuffer *out = NULL;
guint8 *payload;
......@@ -294,16 +294,13 @@ gst_rtp_dv_depay_process (GstRTPBaseDepayload * base, GstBuffer * in)
guint payload_len, location;
GstRTPDVDepay *dvdepay = GST_RTP_DV_DEPAY (base);
gboolean marker;
GstRTPBuffer rtp = { NULL, };
GstMapInfo map;
gst_rtp_buffer_map (in, GST_MAP_READ, &rtp);
marker = gst_rtp_buffer_get_marker (&rtp);
marker = gst_rtp_buffer_get_marker (rtp);
/* Check if the received packet contains (the start of) a new frame, we do
* this by checking the RTP timestamp. */
rtp_ts = gst_rtp_buffer_get_timestamp (&rtp);
rtp_ts = gst_rtp_buffer_get_timestamp (rtp);
/* we cannot copy the packet yet if the marker is set, we will do that below
* after taking out the data */
......@@ -317,8 +314,8 @@ gst_rtp_dv_depay_process (GstRTPBaseDepayload * base, GstBuffer * in)
}
/* Extract the payload */
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
payload = gst_rtp_buffer_get_payload (&rtp);
payload_len = gst_rtp_buffer_get_payload_len (rtp);
payload = gst_rtp_buffer_get_payload (rtp);
/* copy all DIF chunks in their place. */
gst_buffer_map (dvdepay->acc, &map, GST_MAP_READWRITE);
......@@ -350,7 +347,6 @@ gst_rtp_dv_depay_process (GstRTPBaseDepayload * base, GstBuffer * in)
payload += 80;
payload_len -= 80;
}
gst_rtp_buffer_unmap (&rtp);
gst_buffer_unmap (dvdepay->acc, &map);
if (marker) {
......
......@@ -66,7 +66,7 @@ G_DEFINE_TYPE (GstRtpG722Depay, gst_rtp_g722_depay,
static gboolean gst_rtp_g722_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
static GstBuffer *gst_rtp_g722_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
GstRTPBuffer * rtp);
static void
gst_rtp_g722_depay_class_init (GstRtpG722DepayClass * klass)
......@@ -91,7 +91,7 @@ gst_rtp_g722_depay_class_init (GstRtpG722DepayClass * klass)
"Wim Taymans <wim.taymans@gmail.com>");
gstrtpbasedepayload_class->set_caps = gst_rtp_g722_depay_setcaps;
gstrtpbasedepayload_class->process = gst_rtp_g722_depay_process;
gstrtpbasedepayload_class->process_rtp_packet = gst_rtp_g722_depay_process;
}
static void
......@@ -214,28 +214,24 @@ no_clockrate:
}
static GstBuffer *
gst_rtp_g722_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
gst_rtp_g722_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
{
GstRtpG722Depay *rtpg722depay;
GstBuffer *outbuf;
gint payload_len;
gboolean marker;
GstRTPBuffer rtp = { NULL };
rtpg722depay = GST_RTP_G722_DEPAY (depayload);
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
payload_len = gst_rtp_buffer_get_payload_len (&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 (&rtp);
marker = gst_rtp_buffer_get_marker (&rtp);
gst_rtp_buffer_unmap (&rtp);
outbuf = gst_rtp_buffer_get_payload_buffer (rtp);
marker = gst_rtp_buffer_get_marker (rtp);
if (marker && outbuf) {
/* mark talk spurt with RESYNC */
......@@ -249,7 +245,6 @@ empty_packet:
{
GST_ELEMENT_WARNING (rtpg722depay, STREAM, DECODE,
("Empty Payload."), (NULL));
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}
......
......@@ -75,7 +75,7 @@ GST_STATIC_PAD_TEMPLATE ("src",
static gboolean gst_rtp_g723_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
static GstBuffer *gst_rtp_g723_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
GstRTPBuffer * rtp);
#define gst_rtp_g723_depay_parent_class parent_class
G_DEFINE_TYPE (GstRtpG723Depay, gst_rtp_g723_depay,
......@@ -103,7 +103,7 @@ gst_rtp_g723_depay_class_init (GstRtpG723DepayClass * klass)
"Extracts G.723 audio from RTP packets (RFC 3551)",
"Wim Taymans <wim.taymans@gmail.com>");
gstrtpbasedepayload_class->process = gst_rtp_g723_depay_process;
gstrtpbasedepayload_class->process_rtp_packet = gst_rtp_g723_depay_process;
gstrtpbasedepayload_class->set_caps = gst_rtp_g723_depay_setcaps;
}
......@@ -171,19 +171,16 @@ wrong_clock_rate:
static GstBuffer *
gst_rtp_g723_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
gst_rtp_g723_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
{
GstRtpG723Depay *rtpg723depay;
GstBuffer *outbuf = NULL;
gint payload_len;
gboolean marker;
GstRTPBuffer rtp = { NULL };
rtpg723depay = GST_RTP_G723_DEPAY (depayload);
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
payload_len = gst_rtp_buffer_get_payload_len (rtp);
/* At least 4 bytes */
if (payload_len < 4)
......@@ -191,9 +188,8 @@ gst_rtp_g723_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
GST_LOG_OBJECT (rtpg723depay, "payload len %d", payload_len);
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
marker = gst_rtp_buffer_get_marker (&rtp);
gst_rtp_buffer_unmap (&rtp);
outbuf = gst_rtp_buffer_get_payload_buffer (rtp);
marker = gst_rtp_buffer_get_marker (rtp);
if (marker) {
/* marker bit starts talkspurt */
......@@ -215,7 +211,6 @@ too_small:
bad_packet:
{
/* no fatal error */
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}
......
......@@ -82,7 +82,7 @@ static void gst_rtp_g726_depay_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static GstBuffer *gst_rtp_g726_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
GstRTPBuffer * rtp);
static gboolean gst_rtp_g726_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
......@@ -122,7 +122,7 @@ gst_rtp_g726_depay_class_init (GstRtpG726DepayClass * klass)
"Extracts G.726 audio from RTP packets",
"Axis Communications <dev-gstreamer@axis.com>");
gstrtpbasedepayload_class->process = gst_rtp_g726_depay_process;
gstrtpbasedepayload_class->process_rtp_packet = gst_rtp_g726_depay_process;
gstrtpbasedepayload_class->set_caps = gst_rtp_g726_depay_setcaps;
}
......@@ -207,26 +207,23 @@ unknown_encoding:
static GstBuffer *
gst_rtp_g726_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
gst_rtp_g726_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
{
GstRtpG726Depay *depay;
GstBuffer *outbuf = NULL;
gboolean marker;
GstRTPBuffer rtp = { NULL };
depay = GST_RTP_G726_DEPAY (depayload);
gst_rtp_buffer_map (buf, GST_MAP_READWRITE, &rtp);
marker = gst_rtp_buffer_get_marker (&rtp);
marker = gst_rtp_buffer_get_marker (rtp);
GST_DEBUG ("process : got %" G_GSIZE_FORMAT " bytes, mark %d ts %u seqn %d",
gst_buffer_get_size (buf), marker,
gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
gst_buffer_get_size (rtp->buffer), 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 (&rtp);
outbuf = gst_rtp_buffer_get_payload_buffer (rtp);
if (!outbuf)
goto bad_len;
} else {
......@@ -234,10 +231,10 @@ gst_rtp_g726_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
guint len;
GstMapInfo map;
in = gst_rtp_buffer_get_payload (&rtp);
len = gst_rtp_buffer_get_payload_len (&rtp);
in = gst_rtp_buffer_get_payload (rtp);
len = gst_rtp_buffer_get_payload_len (rtp);
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
outbuf = gst_rtp_buffer_get_payload_buffer (rtp);
if (!outbuf)
goto bad_len;
outbuf = gst_buffer_make_writable (outbuf);
......@@ -334,8 +331,6 @@ gst_rtp_g726_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
gst_buffer_unmap (outbuf, &map);
}
gst_rtp_buffer_unmap (&rtp);
if (marker) {
/* mark start of talkspurt with RESYNC */
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_RESYNC);
......@@ -345,10 +340,8 @@ gst_rtp_g726_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
bad_len:
{
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}
static void
......
......@@ -73,7 +73,7 @@ GST_STATIC_PAD_TEMPLATE ("src",
static gboolean gst_rtp_g729_depay_setcaps (GstRTPBaseDepayload * depayload,
GstCaps * caps);
static GstBuffer *gst_rtp_g729_depay_process (GstRTPBaseDepayload * depayload,
GstBuffer * buf);
GstRTPBuffer * rtp);
#define gst_rtp_g729_depay_parent_class parent_class
G_DEFINE_TYPE (GstRtpG729Depay, gst_rtp_g729_depay,
......@@ -101,7 +101,7 @@ gst_rtp_g729_depay_class_init (GstRtpG729DepayClass * klass)
"Extracts G.729 audio from RTP packets (RFC 3551)",
"Laurent Glayal <spglegle@yahoo.fr>");
gstrtpbasedepayload_class->process = gst_rtp_g729_depay_process;
gstrtpbasedepayload_class->process_rtp_packet = gst_rtp_g729_depay_process;
gstrtpbasedepayload_class->set_caps = gst_rtp_g729_depay_setcaps;
}
......@@ -168,19 +168,16 @@ wrong_clock_rate:
}
static GstBuffer *
gst_rtp_g729_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
gst_rtp_g729_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
{
GstRtpG729Depay *rtpg729depay;
GstBuffer *outbuf = NULL;
gint payload_len;
gboolean marker;
GstRTPBuffer rtp = { NULL };
rtpg729depay = GST_RTP_G729_DEPAY (depayload);
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
payload_len = gst_rtp_buffer_get_payload_len (rtp);
/* At least 2 bytes (CNG from G729 Annex B) */
if (payload_len < 2) {
......@@ -195,10 +192,8 @@ gst_rtp_g729_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
GST_LOG_OBJECT (rtpg729depay, "G729 payload contains CNG frame");
}
outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
marker = gst_rtp_buffer_get_marker (&rtp);
gst_rtp_buffer_unmap (&rtp);
outbuf = gst_rtp_buffer_get_payload_buffer (rtp);
marker = gst_rtp_buffer_get_marker (rtp);
if (marker) {
/* marker bit starts talkspurt */
......@@ -214,7 +209,6 @@ gst_rtp_g729_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
bad_packet:
{
/* no fatal error */
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}
......
......@@ -57,7 +57,7 @@ static GstStaticPadTemplate gst_rtp_gsm_depay_sink_template =
);
static GstBuffer *gst_rtp_gsm_depay_process (GstRTPBaseDepayload * _depayload,
GstBuffer * buf);
GstRTPBuffer * rtp);
static gboolean gst_rtp_gsm_depay_setcaps (GstRTPBaseDepayload * _depayload,
GstCaps * caps);
......@@ -82,7 +82,7 @@ gst_rtp_gsm_depay_class_init (GstRTPGSMDepayClass * klass)
"RTP GSM depayloader", "Codec/Depayloader/Network/RTP"