Commit eb82a50b authored by Mark Nauwelaerts's avatar Mark Nauwelaerts

rtp: port remaining to 0.11

parent 9e276e4f
......@@ -83,6 +83,7 @@ endif
libgstrtp_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
libgstrtp_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
-lgstaudio-@GST_MAJORMINOR@ \
-lgstvideo-@GST_MAJORMINOR@ \
-lgsttag-@GST_MAJORMINOR@ \
-lgstrtp-@GST_MAJORMINOR@ \
$(GST_BASE_LIBS) $(GST_LIBS) \
......
......@@ -44,8 +44,8 @@ typedef struct _GstAsteriskH263Header
guint16 length; /* Length */
} GstAsteriskH263Header;
#define GST_ASTERISKH263_HEADER_TIMESTAMP(buf) (((GstAsteriskH263Header *)(GST_BUFFER_DATA (buf)))->timestamp)
#define GST_ASTERISKH263_HEADER_LENGTH(buf) (((GstAsteriskH263Header *)(GST_BUFFER_DATA (buf)))->length)
#define GST_ASTERISKH263_HEADER_TIMESTAMP(data) (((GstAsteriskH263Header *)(data))->timestamp)
#define GST_ASTERISKH263_HEADER_LENGTH(data) (((GstAsteriskH263Header *)(data))->length)
static GstStaticPadTemplate gst_asteriskh263_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
......@@ -71,24 +71,8 @@ static GstFlowReturn gst_asteriskh263_chain (GstPad * pad, GstBuffer * buffer);
static GstStateChangeReturn gst_asteriskh263_change_state (GstElement *
element, GstStateChange transition);
GST_BOILERPLATE (GstAsteriskh263, gst_asteriskh263, GstElement,
GST_TYPE_ELEMENT);
static void
gst_asteriskh263_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_asteriskh263_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_asteriskh263_sink_template));
gst_element_class_set_details_simple (element_class,
"RTP Asterisk H263 depayloader", "Codec/Depayloader/Network/RTP",
"Extracts H263 video from RTP and encodes in Asterisk H263 format",
"Neil Stratford <neils@vipadia.com>");
}
#define gst_asteriskh263_parent_class parent_class
G_DEFINE_TYPE (GstAsteriskh263, gst_asteriskh263, GST_TYPE_ELEMENT);
static void
gst_asteriskh263_class_init (GstAsteriskh263Class * klass)
......@@ -102,11 +86,20 @@ gst_asteriskh263_class_init (GstAsteriskh263Class * klass)
gobject_class->finalize = gst_asteriskh263_finalize;
gstelement_class->change_state = gst_asteriskh263_change_state;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_asteriskh263_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_asteriskh263_sink_template));
gst_element_class_set_details_simple (gstelement_class,
"RTP Asterisk H263 depayloader", "Codec/Depayloader/Network/RTP",
"Extracts H263 video from RTP and encodes in Asterisk H263 format",
"Neil Stratford <neils@vipadia.com>");
}
static void
gst_asteriskh263_init (GstAsteriskh263 * asteriskh263,
GstAsteriskh263Class * klass)
gst_asteriskh263_init (GstAsteriskh263 * asteriskh263)
{
asteriskh263->srcpad =
gst_pad_new_from_static_template (&gst_asteriskh263_src_template, "src");
......@@ -153,12 +146,18 @@ gst_asteriskh263_chain (GstPad * pad, GstBuffer * buf)
guint32 timestamp;
guint32 samples;
guint16 asterisk_len;
GstRTPBuffer rtp;
guint8 *data;
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
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);
M = gst_rtp_buffer_get_marker (buf);
timestamp = gst_rtp_buffer_get_timestamp (buf);
M = gst_rtp_buffer_get_marker (&rtp);
timestamp = gst_rtp_buffer_get_timestamp (&rtp);
gst_rtp_buffer_unmap (&rtp);
outbuf = gst_buffer_new_and_alloc (payload_len +
GST_ASTERISKH263_HEADER_LEN);
......@@ -172,16 +171,24 @@ gst_asteriskh263_chain (GstPad * pad, GstBuffer * buf)
samples = timestamp - asteriskh263->lastts;
asteriskh263->lastts = timestamp;
GST_ASTERISKH263_HEADER_TIMESTAMP (outbuf) = g_htonl (samples);
GST_ASTERISKH263_HEADER_LENGTH (outbuf) = g_htons (asterisk_len);
data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
GST_ASTERISKH263_HEADER_TIMESTAMP (data) = g_htonl (samples);
GST_ASTERISKH263_HEADER_LENGTH (data) = g_htons (asterisk_len);
/* copy the data into place */
memcpy (GST_BUFFER_DATA (outbuf) + GST_ASTERISKH263_HEADER_LEN, payload,
payload_len);
memcpy (data + GST_ASTERISKH263_HEADER_LEN, payload, payload_len);
gst_buffer_unmap (outbuf, data, -1);
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
gst_buffer_set_caps (outbuf,
(GstCaps *) gst_pad_get_pad_template_caps (asteriskh263->srcpad));
if (!gst_pad_has_current_caps (asteriskh263->srcpad)) {
GstCaps *caps;
caps = gst_caps_copy
(gst_pad_get_pad_template_caps (asteriskh263->srcpad));
gst_pad_set_caps (asteriskh263->srcpad, caps);
gst_caps_unref (caps);
}
ret = gst_pad_push (asteriskh263->srcpad, outbuf);
......
......@@ -67,47 +67,42 @@ static GstStaticPadTemplate gst_rtp_L16_depay_sink_template =
)
);
GST_BOILERPLATE (GstRtpL16Depay, gst_rtp_L16_depay, GstBaseRTPDepayload,
GST_TYPE_BASE_RTP_DEPAYLOAD);
#define gst_rtp_L16_depay_parent_class parent_class
G_DEFINE_TYPE (GstRtpL16Depay, gst_rtp_L16_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
static gboolean gst_rtp_L16_depay_setcaps (GstBaseRTPDepayload * depayload,
GstCaps * caps);
static GstBuffer *gst_rtp_L16_depay_process (GstBaseRTPDepayload * depayload,
GstBuffer * buf);
static void
gst_rtp_L16_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_L16_depay_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_L16_depay_sink_template));
gst_element_class_set_details_simple (element_class, "RTP audio depayloader",
"Codec/Depayloader/Network/RTP",
"Extracts raw audio from RTP packets",
"Zeeshan Ali <zak147@yahoo.com>," "Wim Taymans <wim.taymans@gmail.com>");
}
static void
gst_rtp_L16_depay_class_init (GstRtpL16DepayClass * klass)
{
GstElementClass *gstelement_class;
GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
gstelement_class = (GstElementClass *) klass;
gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
gstbasertpdepayload_class->set_caps = gst_rtp_L16_depay_setcaps;
gstbasertpdepayload_class->process = gst_rtp_L16_depay_process;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_L16_depay_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_L16_depay_sink_template));
gst_element_class_set_details_simple (gstelement_class,
"RTP audio depayloader", "Codec/Depayloader/Network/RTP",
"Extracts raw audio from RTP packets",
"Zeeshan Ali <zak147@yahoo.com>," "Wim Taymans <wim.taymans@gmail.com>");
GST_DEBUG_CATEGORY_INIT (rtpL16depay_debug, "rtpL16depay", 0,
"Raw Audio RTP Depayloader");
}
static void
gst_rtp_L16_depay_init (GstRtpL16Depay * rtpL16depay,
GstRtpL16DepayClass * klass)
gst_rtp_L16_depay_init (GstRtpL16Depay * rtpL16depay)
{
/* needed because of GST_BOILERPLATE */
}
......@@ -228,24 +223,28 @@ gst_rtp_L16_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
GstBuffer *outbuf;
gint payload_len;
gboolean marker;
GstRTPBuffer rtp;
rtpL16depay = GST_RTP_L16_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 (rtpL16depay, "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);
if (marker) {
/* mark talk spurt with DISCONT */
GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
}
gst_rtp_buffer_unmap (&rtp);
return outbuf;
/* ERRORS */
......@@ -253,6 +252,7 @@ empty_packet:
{
GST_ELEMENT_WARNING (rtpL16depay, STREAM, DECODE,
("Empty Payload."), (NULL));
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}
......
......@@ -70,43 +70,39 @@ static GstStaticPadTemplate gst_rtp_L16_pay_src_template =
static gboolean gst_rtp_L16_pay_setcaps (GstBaseRTPPayload * basepayload,
GstCaps * caps);
static GstCaps *gst_rtp_L16_pay_getcaps (GstBaseRTPPayload * rtppayload,
GstPad * pad);
GstPad * pad, GstCaps * filter);
GST_BOILERPLATE (GstRtpL16Pay, gst_rtp_L16_pay, GstBaseRTPAudioPayload,
GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
static void
gst_rtp_L16_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_L16_pay_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_L16_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>");
}
#define gst_rtp_L16_pay_parent_class parent_class
G_DEFINE_TYPE (GstRtpL16Pay, gst_rtp_L16_pay, GST_TYPE_BASE_RTP_AUDIO_PAYLOAD);
static void
gst_rtp_L16_pay_class_init (GstRtpL16PayClass * klass)
{
GstElementClass *gstelement_class;
GstBaseRTPPayloadClass *gstbasertppayload_class;
gstelement_class = (GstElementClass *) klass;
gstbasertppayload_class = (GstBaseRTPPayloadClass *) klass;
gstbasertppayload_class->set_caps = gst_rtp_L16_pay_setcaps;
gstbasertppayload_class->get_caps = gst_rtp_L16_pay_getcaps;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_L16_pay_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_L16_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>");
GST_DEBUG_CATEGORY_INIT (rtpL16pay_debug, "rtpL16pay", 0,
"L16 RTP Payloader");
}
static void
gst_rtp_L16_pay_init (GstRtpL16Pay * rtpL16pay, GstRtpL16PayClass * klass)
gst_rtp_L16_pay_init (GstRtpL16Pay * rtpL16pay)
{
GstBaseRTPAudioPayload *basertpaudiopayload;
......@@ -191,7 +187,8 @@ no_channels:
}
static GstCaps *
gst_rtp_L16_pay_getcaps (GstBaseRTPPayload * rtppayload, GstPad * pad)
gst_rtp_L16_pay_getcaps (GstBaseRTPPayload * rtppayload, GstPad * pad,
GstCaps * filter)
{
GstCaps *otherpadcaps;
GstCaps *caps;
......@@ -227,6 +224,14 @@ gst_rtp_L16_pay_getcaps (GstBaseRTPPayload * rtppayload, GstPad * pad)
}
gst_caps_unref (otherpadcaps);
}
if (filter) {
GstCaps *tcaps = caps;
caps = gst_caps_intersect_full (filter, tcaps, GST_CAPS_INTERSECT_FIRST);
gst_caps_unref (tcaps);
}
return caps;
}
......
......@@ -887,8 +887,9 @@ 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 {
......@@ -1655,8 +1656,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++) {
......
......@@ -488,6 +488,7 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
guint type, width, height;
guint16 dri, precision, length;
guint8 *qtable;
GstRTPBuffer rtp;
rtpjpegdepay = GST_RTP_JPEG_DEPAY (depayload);
......@@ -496,12 +497,13 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
rtpjpegdepay->discont = TRUE;
}
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 < 8)
goto empty_packet;
payload = gst_rtp_buffer_get_payload (buf);
payload = gst_rtp_buffer_get_payload (&rtp);
header_len = 0;
/* 0 1 2 3
......@@ -601,6 +603,7 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
if (frag_offset == 0) {
guint size;
guint8 *data;
if (rtpjpegdepay->width != width || rtpjpegdepay->height != height) {
GstCaps *outcaps;
......@@ -642,23 +645,23 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
}
/* max header length, should be big enough */
outbuf = gst_buffer_new_and_alloc (1000);
size = MakeHeaders (GST_BUFFER_DATA (outbuf), type,
width, height, qtable, precision, dri);
GST_DEBUG_OBJECT (rtpjpegdepay, "pushing %u bytes of header", size);
data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
size = MakeHeaders (data, type, width, height, qtable, precision, dri);
gst_buffer_unmap (outbuf, data, size);
GST_BUFFER_SIZE (outbuf) = size;
GST_DEBUG_OBJECT (rtpjpegdepay,
"pushing %" G_GSIZE_FORMAT " bytes of header", size);
gst_adapter_push (rtpjpegdepay->adapter, outbuf);
}
/* take JPEG data, push in the adapter */
GST_DEBUG_OBJECT (rtpjpegdepay, "pushing data at offset %d", header_len);
outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, header_len, -1);
outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, header_len, -1);
gst_adapter_push (rtpjpegdepay->adapter, outbuf);
outbuf = NULL;
if (gst_rtp_buffer_get_marker (buf)) {
if (gst_rtp_buffer_get_marker (&rtp)) {
guint avail;
guint8 end[2];
guint8 *data;
......@@ -676,9 +679,10 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
/* no EOI marker, add one */
outbuf = gst_buffer_new_and_alloc (2);
data = GST_BUFFER_DATA (outbuf);
data = gst_buffer_map (outbuf, NULL, NULL, GST_MAP_WRITE);
data[0] = 0xff;
data[1] = 0xd9;
gst_buffer_unmap (outbuf, data, -1);
gst_adapter_push (rtpjpegdepay->adapter, outbuf);
avail += 2;
......@@ -693,6 +697,8 @@ gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
GST_DEBUG_OBJECT (rtpjpegdepay, "returning %u bytes", avail);
}
gst_rtp_buffer_unmap (&rtp);
return outbuf;
/* ERRORS */
......@@ -700,17 +706,20 @@ empty_packet:
{
GST_ELEMENT_WARNING (rtpjpegdepay, STREAM, DECODE,
("Empty Payload."), (NULL));
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
invalid_dimension:
{
GST_ELEMENT_WARNING (rtpjpegdepay, STREAM, FORMAT,
("Invalid Dimension %dx%d.", width, height), (NULL));
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
no_qtable:
{
GST_WARNING_OBJECT (rtpjpegdepay, "no qtable");
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}
......
......@@ -234,37 +234,33 @@ static gboolean gst_rtp_jpeg_pay_setcaps (GstBaseRTPPayload * basepayload,
static GstFlowReturn gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * pad,
GstBuffer * buffer);
GST_BOILERPLATE (GstRtpJPEGPay, gst_rtp_jpeg_pay, GstBaseRTPPayload,
GST_TYPE_BASE_RTP_PAYLOAD);
static void
gst_rtp_jpeg_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_jpeg_pay_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_jpeg_pay_sink_template));
gst_element_class_set_details_simple (element_class, "RTP JPEG payloader",
"Codec/Payloader/Network/RTP",
"Payload-encodes JPEG pictures into RTP packets (RFC 2435)",
"Axis Communications <dev-gstreamer@axis.com>");
}
#define gst_rtp_jpeg_pay_parent_class parent_class
G_DEFINE_TYPE (GstRtpJPEGPay, gst_rtp_jpeg_pay, GST_TYPE_BASE_RTP_PAYLOAD);
static void
gst_rtp_jpeg_pay_class_init (GstRtpJPEGPayClass * 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_jpeg_pay_set_property;
gobject_class->get_property = gst_rtp_jpeg_pay_get_property;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_jpeg_pay_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_jpeg_pay_sink_template));
gst_element_class_set_details_simple (gstelement_class, "RTP JPEG payloader",
"Codec/Payloader/Network/RTP",
"Payload-encodes JPEG pictures into RTP packets (RFC 2435)",
"Axis Communications <dev-gstreamer@axis.com>");
gstbasertppayload_class->set_caps = gst_rtp_jpeg_pay_setcaps;
gstbasertppayload_class->handle_buffer = gst_rtp_jpeg_pay_handle_buffer;
......@@ -288,7 +284,7 @@ gst_rtp_jpeg_pay_class_init (GstRtpJPEGPayClass * klass)
}
static void
gst_rtp_jpeg_pay_init (GstRtpJPEGPay * pay, GstRtpJPEGPayClass * klass)
gst_rtp_jpeg_pay_init (GstRtpJPEGPay * pay)
{
pay->quality = DEFAULT_JPEG_QUALITY;
pay->quant = DEFAULT_JPEG_QUANT;
......@@ -609,8 +605,8 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
RtpQuantTable tables[15] = { {0, NULL}, };
CompInfo info[3] = { {0,}, };
guint quant_data_size;
guint8 *data;
guint size;
guint8 *data, *bdata;
gsize size;
guint mtu;
guint bytes_left;
guint jpeg_header_size = 0;
......@@ -619,18 +615,16 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
gboolean sos_found, sof_found, dqt_found, dri_found;
gint i;
GstBufferList *list = NULL;
GstBufferListIterator *it = NULL;
pay = GST_RTP_JPEG_PAY (basepayload);
mtu = GST_BASE_RTP_PAYLOAD_MTU (pay);
size = GST_BUFFER_SIZE (buffer);
data = GST_BUFFER_DATA (buffer);
data = bdata = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
timestamp = GST_BUFFER_TIMESTAMP (buffer);
offset = 0;
GST_LOG_OBJECT (pay, "got buffer size %u, timestamp %" GST_TIME_FORMAT, size,
GST_TIME_ARGS (timestamp));
GST_LOG_OBJECT (pay, "got buffer size %" G_GSIZE_FORMAT
" , timestamp %" GST_TIME_FORMAT, size, GST_TIME_ARGS (timestamp));
/* parse the jpeg header for 'start of scan' and read quant tables if needed */
sos_found = FALSE;
......@@ -734,7 +728,6 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
if (pay->buffer_list) {
list = gst_buffer_list_new ();
it = gst_buffer_list_iterate (list);
}
bytes_left = sizeof (jpeg_header) + quant_data_size + size;
......@@ -747,27 +740,25 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
GstBuffer *outbuf;
guint8 *payload;
guint payload_size = (bytes_left < mtu ? bytes_left : mtu);
guint header_size;
GstBuffer *paybuf;
GstRTPBuffer rtp;
if (pay->buffer_list) {
guint header_size;
header_size = sizeof (jpeg_header) + quant_data_size;
if (dri_found)
header_size += sizeof (restart_marker_header);
header_size = sizeof (jpeg_header) + quant_data_size;
if (dri_found)
header_size += sizeof (restart_marker_header);
outbuf = gst_rtp_buffer_new_allocate (header_size, 0, 0);
outbuf = gst_rtp_buffer_new_allocate (header_size, 0, 0);
} else {
outbuf = gst_rtp_buffer_new_allocate (payload_size, 0, 0);
}
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
if (payload_size == bytes_left) {
GST_LOG_OBJECT (pay, "last packet of frame");
frame_done = TRUE;
gst_rtp_buffer_set_marker (outbuf, 1);
gst_rtp_buffer_set_marker (&rtp, 1);
}
payload = gst_rtp_buffer_get_payload (outbuf);
payload = gst_rtp_buffer_get_payload (&rtp);
/* update offset */
#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
......@@ -810,20 +801,21 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
quant_data_size = 0;
}
GST_LOG_OBJECT (pay, "sending payload size %d", payload_size);
gst_rtp_buffer_unmap (&rtp);
if (pay->buffer_list) {
GstBuffer *paybuf;
/* create a new buf to hold the payload */
paybuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_MEMORY,
jpeg_header_size + offset, payload_size);
/* create a new buf to hold the payload */
paybuf = gst_buffer_create_sub (buffer, jpeg_header_size + offset,
payload_size);
/* join memory parts */
outbuf = gst_buffer_join (outbuf, paybuf);
/* create a new group to hold the rtp header and the payload */
gst_buffer_list_iterator_add_group (it);
gst_buffer_list_iterator_add (it, outbuf);
gst_buffer_list_iterator_add (it, paybuf);
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
if (pay->buffer_list) {
/* and add to list */
gst_buffer_list_insert (list, -1, outbuf);
} else {
memcpy (payload, data, payload_size);
ret = gst_basertppayload_push (basepayload, outbuf);
if (ret != GST_FLOW_OK)
break;
......@@ -836,11 +828,11 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
while (!frame_done);
if (pay->buffer_list) {
gst_buffer_list_iterator_free (it);
/* push the whole buffer list at once */
ret = gst_basertppayload_push_list (basepayload, list);
}
gst_buffer_unmap (buffer, bdata, -1);
gst_buffer_unref (buffer);
return ret;
......@@ -849,24 +841,28 @@ gst_rtp_jpeg_pay_handle_buffer (GstBaseRTPPayload * basepayload,
unsupported_jpeg:
{
GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("Unsupported JPEG"), (NULL));
gst_buffer_unmap (buffer, bdata, -1);
gst_buffer_unref (buffer);
return GST_FLOW_NOT_SUPPORTED;
}
no_dimension:
{
GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("No size given"), (NULL));
gst_buffer_unmap (buffer, bdata, -1);
gst_buffer_unref (buffer);
return GST_FLOW_NOT_NEGOTIATED;
}
invalid_format:
{
/* error was posted */
gst_buffer_unmap (buffer, bdata, -1);
gst_buffer_unref (buffer);
return GST_FLOW_ERROR;
}
invalid_quant:
{
GST_ELEMENT_ERROR (pay, STREAM, FORMAT, ("Invalid quant tables"), (NULL));
gst_buffer_unmap (buffer, bdata, -1);