rtp: port some more (de)payloader

This commit is contained in:
Wim Taymans 2011-06-13 17:14:00 +02:00
parent eed80e2dd3
commit 3c889415a3
4 changed files with 153 additions and 113 deletions

View file

@ -709,9 +709,11 @@ gst_rtp_h264_pay_payload_nal (GstBaseRTPPayload * basepayload,
guint packet_len, payload_len, mtu;
GstBuffer *outbuf;
guint8 *payload;
#if 0
GstBufferList *list = NULL;
GstBufferListIterator *it = NULL;
#endif
gboolean send_spspps;
GstRTPBuffer rtp = { NULL };
rtph264pay = GST_RTP_H264_PAY (basepayload);
mtu = GST_BASE_RTP_PAYLOAD_MTU (rtph264pay);
@ -768,25 +770,31 @@ gst_rtp_h264_pay_payload_nal (GstBaseRTPPayload * basepayload,
"NAL Unit fit in one packet datasize=%d mtu=%d", size, mtu);
/* will fit in one packet */
#if 0
if (rtph264pay->buffer_list) {
/* use buffer lists
* first create buffer without payload containing only the RTP header
* and then another buffer containing the payload. both buffers will
* be then added to the list */
outbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
} else {
} else
#endif
{
/* use the old-fashioned way with a single buffer and memcpy */
outbuf = gst_rtp_buffer_new_allocate (size, 0, 0);
}
gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
/* only set the marker bit on packets containing access units */
if (IS_ACCESS_UNIT (nalType)) {
gst_rtp_buffer_set_marker (outbuf, 1);
gst_rtp_buffer_set_marker (&rtp, 1);
}
/* timestamp the outbuffer */
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
#if 0
if (rtph264pay->buffer_list) {
GstBuffer *paybuf;
@ -796,25 +804,24 @@ gst_rtp_h264_pay_payload_nal (GstBaseRTPPayload * basepayload,
GST_BUFFER_DATA (buffer_orig), size);
else {
paybuf = gst_buffer_new_and_alloc (size);
memcpy (GST_BUFFER_DATA (paybuf), data, size);
gst_buffer_fill (paybuf, 0, data, size);
}
list = gst_buffer_list_new ();
it = gst_buffer_list_iterate (list);
/* add both buffers to the buffer list */
gst_buffer_list_iterator_add_group (it);
gst_buffer_list_iterator_add (it, outbuf);
gst_buffer_list_iterator_add (it, paybuf);
gst_buffer_list_iterator_free (it);
gst_buffer_list_add (list, outbuf);
gst_buffer_list_add (list, paybuf);
/* push the list to the next element in the pipe */
ret = gst_basertppayload_push_list (basepayload, list);
} else {
payload = gst_rtp_buffer_get_payload (outbuf);
} else
#endif
{
payload = gst_rtp_buffer_get_payload (&rtp);
GST_DEBUG_OBJECT (basepayload, "Copying %d bytes to outbuf", size);
memcpy (payload, data, size);
gst_rtp_buffer_unmap (&rtp);
ret = gst_basertppayload_push (basepayload, outbuf);
}
@ -839,10 +846,12 @@ gst_rtp_h264_pay_payload_nal (GstBaseRTPPayload * basepayload,
/* We keep 2 bytes for FU indicator and FU Header */
payload_len = gst_rtp_buffer_calc_payload_len (mtu - 2, 0, 0);
#if 0
if (rtph264pay->buffer_list) {
list = gst_buffer_list_new ();
it = gst_buffer_list_iterate (list);
}
#endif
while (end == 0) {
limitedSize = size < payload_len ? size : payload_len;
@ -850,27 +859,32 @@ gst_rtp_h264_pay_payload_nal (GstBaseRTPPayload * basepayload,
"Inside FU-A fragmentation limitedSize=%d iteration=%d", limitedSize,
ii);
#if 0
if (rtph264pay->buffer_list) {
/* use buffer lists
* first create buffer without payload containing only the RTP header
* and then another buffer containing the payload. both buffers will
* be then added to the list */
outbuf = gst_rtp_buffer_new_allocate (2, 0, 0);
} else {
} else
#endif
{
/* use the old-fashioned way with a single buffer and memcpy
* first create buffer to hold the payload */
outbuf = gst_rtp_buffer_new_allocate (limitedSize + 2, 0, 0);
}
gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
payload = gst_rtp_buffer_get_payload (outbuf);
payload = gst_rtp_buffer_get_payload (&rtp);
if (limitedSize == size) {
GST_DEBUG_OBJECT (basepayload, "end size=%d iteration=%d", size, ii);
end = 1;
}
if (IS_ACCESS_UNIT (nalType)) {
gst_rtp_buffer_set_marker (outbuf, end);
gst_rtp_buffer_set_marker (&rtp, end);
}
/* FU indicator */
@ -879,6 +893,7 @@ gst_rtp_h264_pay_payload_nal (GstBaseRTPPayload * basepayload,
/* FU Header */
payload[1] = (start << 7) | (end << 6) | (nalHeader & 0x1f);
#if 0
if (rtph264pay->buffer_list) {
GstBuffer *paybuf;
@ -898,8 +913,11 @@ gst_rtp_h264_pay_payload_nal (GstBaseRTPPayload * basepayload,
gst_buffer_list_iterator_add (it, outbuf);
gst_buffer_list_iterator_add (it, paybuf);
} else {
} else
#endif
{
memcpy (&payload[2], data + pos, limitedSize);
gst_rtp_buffer_unmap (&rtp);
GST_DEBUG_OBJECT (basepayload,
"recorded %d payload bytes into packet iteration=%d",
limitedSize + 2, ii);
@ -915,11 +933,13 @@ gst_rtp_h264_pay_payload_nal (GstBaseRTPPayload * basepayload,
start = 0;
}
#if 0
if (rtph264pay->buffer_list) {
/* free iterator and push the whole buffer list at once */
gst_buffer_list_iterator_free (it);
ret = gst_basertppayload_push_list (basepayload, list);
}
#endif
}
return ret;
}
@ -930,29 +950,36 @@ gst_rtp_h264_pay_handle_buffer (GstBaseRTPPayload * basepayload,
{
GstRtpH264Pay *rtph264pay;
GstFlowReturn ret;
guint size, nal_len, i;
gsize size;
guint nal_len, i;
guint8 *bdata = NULL;
gsize bsize;
const guint8 *data, *nal_data;
GstClockTime timestamp;
GArray *nal_queue;
guint pushed = 0;
gboolean bytestream;
rtph264pay = GST_RTP_H264_PAY (basepayload);
/* the input buffer contains one or more NAL units */
if (rtph264pay->scan_mode == GST_H264_SCAN_MODE_BYTESTREAM) {
bytestream = (rtph264pay->scan_mode == GST_H264_SCAN_MODE_BYTESTREAM);
if (bytestream) {
timestamp = gst_adapter_prev_timestamp (rtph264pay->adapter, NULL);
gst_adapter_push (rtph264pay->adapter, buffer);
size = gst_adapter_available (rtph264pay->adapter);
data = gst_adapter_peek (rtph264pay->adapter, size);
data = gst_adapter_map (rtph264pay->adapter, size);
GST_DEBUG_OBJECT (basepayload, "got %d bytes (%d)", size,
GST_BUFFER_SIZE (buffer));
gst_buffer_get_size (buffer));
if (!GST_CLOCK_TIME_IS_VALID (timestamp))
timestamp = GST_BUFFER_TIMESTAMP (buffer);
} else {
size = GST_BUFFER_SIZE (buffer);
data = GST_BUFFER_DATA (buffer);
bdata = gst_buffer_map (buffer, &bsize, NULL, GST_MAP_READ);
data = bdata;
size = bsize;
timestamp = GST_BUFFER_TIMESTAMP (buffer);
GST_DEBUG_OBJECT (basepayload, "got %d bytes", size);
}
@ -1123,10 +1150,13 @@ gst_rtp_h264_pay_handle_buffer (GstBaseRTPPayload * basepayload,
g_array_set_size (nal_queue, 0);
}
if (rtph264pay->scan_mode == GST_H264_SCAN_MODE_BYTESTREAM)
gst_adapter_flush (rtph264pay->adapter, pushed);
else
done:
if (bytestream) {
gst_adapter_unmap (rtph264pay->adapter, pushed);
} else {
gst_buffer_unmap (buffer, bdata, bsize);
gst_buffer_unref (buffer);
}
return ret;
@ -1134,8 +1164,8 @@ caps_rejected:
{
GST_WARNING_OBJECT (basepayload, "Could not set outcaps");
g_array_set_size (nal_queue, 0);
gst_buffer_unref (buffer);
return GST_FLOW_NOT_NEGOTIATED;
ret = GST_FLOW_NOT_NEGOTIATED;
goto done;
}
}

View file

@ -65,8 +65,8 @@ enum
PROP_LAST
};
GST_BOILERPLATE (GstRtpJ2KDepay, gst_rtp_j2k_depay, GstBaseRTPDepayload,
GST_TYPE_BASE_RTP_DEPAYLOAD);
#define gst_rtp_j2k_depay_parent_class parent_class
G_DEFINE_TYPE (GstRtpJ2KDepay, gst_rtp_j2k_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
static void gst_rtp_j2k_depay_finalize (GObject * object);
@ -84,22 +84,6 @@ static gboolean gst_rtp_j2k_depay_setcaps (GstBaseRTPDepayload * depayload,
static GstBuffer *gst_rtp_j2k_depay_process (GstBaseRTPDepayload * depayload,
GstBuffer * buf);
static void
gst_rtp_j2k_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_j2k_depay_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_j2k_depay_sink_template));
gst_element_class_set_details_simple (element_class,
"RTP JPEG 2000 depayloader", "Codec/Depayloader/Network/RTP",
"Extracts JPEG 2000 video from RTP packets (RFC 5371)",
"Wim Taymans <wim.taymans@gmail.com>");
}
static void
gst_rtp_j2k_depay_class_init (GstRtpJ2KDepayClass * klass)
{
@ -121,6 +105,16 @@ gst_rtp_j2k_depay_class_init (GstRtpJ2KDepayClass * klass)
"Use Buffer Lists",
DEFAULT_BUFFER_LIST, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_j2k_depay_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_j2k_depay_sink_template));
gst_element_class_set_details_simple (gstelement_class,
"RTP JPEG 2000 depayloader", "Codec/Depayloader/Network/RTP",
"Extracts JPEG 2000 video from RTP packets (RFC 5371)",
"Wim Taymans <wim.taymans@gmail.com>");
gstelement_class->change_state = gst_rtp_j2k_depay_change_state;
gstbasertpdepayload_class->set_caps = gst_rtp_j2k_depay_setcaps;
@ -131,8 +125,7 @@ gst_rtp_j2k_depay_class_init (GstRtpJ2KDepayClass * klass)
}
static void
gst_rtp_j2k_depay_init (GstRtpJ2KDepay * rtpj2kdepay,
GstRtpJ2KDepayClass * klass)
gst_rtp_j2k_depay_init (GstRtpJ2KDepay * rtpj2kdepay)
{
rtpj2kdepay->buffer_list = DEFAULT_BUFFER_LIST;
@ -246,7 +239,7 @@ gst_rtp_j2k_depay_flush_pu (GstBaseRTPDepayload * depayload)
for (walk = packets; walk; walk = g_list_next (walk)) {
GstBuffer *buf = GST_BUFFER_CAST (walk->data);
GST_DEBUG_OBJECT (rtpj2kdepay, "append pu packet of size %u",
GST_BUFFER_SIZE (buf));
gst_buffer_get_size (buf));
gst_adapter_push (rtpj2kdepay->t_adapter, buf);
}
g_list_free (packets);
@ -274,6 +267,9 @@ gst_rtp_j2k_depay_flush_tile (GstBaseRTPDepayload * depayload)
GList *packets, *walk;
guint8 end[2];
GstFlowReturn ret = GST_FLOW_OK;
guint8 *data;
gsize size;
GstBuffer *buf;
rtpj2kdepay = GST_RTP_J2K_DEPAY (depayload);
@ -307,15 +303,11 @@ gst_rtp_j2k_depay_flush_tile (GstBaseRTPDepayload * depayload)
/* now append the tile packets to the frame */
packets = gst_adapter_take_list (rtpj2kdepay->t_adapter, avail);
for (walk = packets; walk; walk = g_list_next (walk)) {
GstBuffer *buf = GST_BUFFER_CAST (walk->data);
buf = GST_BUFFER_CAST (walk->data);
if (walk == packets) {
guint8 *data;
guint size;
/* first buffer should contain the SOT */
data = GST_BUFFER_DATA (buf);
size = GST_BUFFER_SIZE (buf);
data = gst_buffer_map (buf, &size, NULL, GST_MAP_READ);
if (size < 12)
goto invalid_tile;
@ -332,15 +324,19 @@ gst_rtp_j2k_depay_flush_tile (GstBaseRTPDepayload * depayload)
if (Psot != nPsot && Psot != 0) {
/* Psot must match the size of the tile */
GST_DEBUG_OBJECT (rtpj2kdepay, "set Psot from %u to %u", Psot, nPsot);
gst_buffer_unmap (buf, data, size);
buf = gst_buffer_make_writable (buf);
data = GST_BUFFER_DATA (buf);
data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
GST_WRITE_UINT32_BE (&data[6], nPsot);
}
}
gst_buffer_unmap (buf, data, size);
}
GST_DEBUG_OBJECT (rtpj2kdepay, "append pu packet of size %u",
GST_BUFFER_SIZE (buf));
gst_buffer_get_size (buf));
gst_adapter_push (rtpj2kdepay->f_adapter, buf);
}
g_list_free (packets);
@ -361,6 +357,7 @@ waiting_header:
invalid_tile:
{
GST_ELEMENT_WARNING (rtpj2kdepay, STREAM, DECODE, ("Invalid tile"), (NULL));
gst_buffer_unmap (buf, data, size);
gst_adapter_clear (rtpj2kdepay->t_adapter);
rtpj2kdepay->last_tile = -1;
return ret;
@ -372,7 +369,6 @@ gst_rtp_j2k_depay_flush_frame (GstBaseRTPDepayload * depayload)
{
GstRtpJ2KDepay *rtpj2kdepay;
guint8 end[2];
guint8 *data;
guint avail;
GstFlowReturn ret = GST_FLOW_OK;
@ -395,18 +391,19 @@ gst_rtp_j2k_depay_flush_frame (GstBaseRTPDepayload * depayload)
gst_adapter_copy (rtpj2kdepay->f_adapter, end, avail - 2, 2);
if (end[0] != 0xff && end[1] != 0xd9) {
end[0] = 0xff;
end[1] = 0xd9;
GST_DEBUG_OBJECT (rtpj2kdepay, "no EOC marker, adding one");
/* no EOI marker, add one */
outbuf = gst_buffer_new_and_alloc (2);
data = GST_BUFFER_DATA (outbuf);
data[0] = 0xff;
data[1] = 0xd9;
gst_buffer_fill (outbuf, 0, end, 2);
gst_adapter_push (rtpj2kdepay->f_adapter, outbuf);
avail += 2;
}
#if 0
if (rtpj2kdepay->buffer_list) {
GList *list;
GstBufferList *buflist;
@ -422,7 +419,9 @@ gst_rtp_j2k_depay_flush_frame (GstBaseRTPDepayload * depayload)
gst_buffer_list_iterator_free (it);
ret = gst_base_rtp_depayload_push_list (depayload, buflist);
} else {
} else
#endif
{
GST_DEBUG_OBJECT (rtpj2kdepay, "pushing buffer of %u bytes", avail);
outbuf = gst_adapter_take_buffer (rtpj2kdepay->f_adapter, avail);
ret = gst_base_rtp_depayload_push (depayload, outbuf);
@ -454,17 +453,20 @@ gst_rtp_j2k_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
guint MHF, mh_id, frag_offset, tile, payload_len, j2klen;
gint gap;
guint32 rtptime;
GstRTPBuffer rtp = { NULL };
rtpj2kdepay = GST_RTP_J2K_DEPAY (depayload);
payload = gst_rtp_buffer_get_payload (buf);
payload_len = gst_rtp_buffer_get_payload_len (buf);
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
payload = gst_rtp_buffer_get_payload (&rtp);
payload_len = gst_rtp_buffer_get_payload_len (&rtp);
/* we need at least a header */
if (payload_len < 8)
goto empty_packet;
rtptime = gst_rtp_buffer_get_timestamp (buf);
rtptime = gst_rtp_buffer_get_timestamp (&rtp);
/* new timestamp marks new frame */
if (rtpj2kdepay->last_rtptime != rtptime) {
@ -561,7 +563,7 @@ gst_rtp_j2k_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
}
/* and push in pu adapter */
GST_DEBUG_OBJECT (rtpj2kdepay, "push pu of size %u in adapter", j2klen);
pu_frag = gst_rtp_buffer_get_payload_subbuffer (buf, 8, -1);
pu_frag = gst_rtp_buffer_get_payload_subbuffer (&rtp, 8, -1);
gst_adapter_push (rtpj2kdepay->pu_adapter, pu_frag);
if (MHF & 2) {
@ -574,11 +576,13 @@ gst_rtp_j2k_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
}
/* marker bit finishes the frame */
if (gst_rtp_buffer_get_marker (buf)) {
if (gst_rtp_buffer_get_marker (&rtp)) {
GST_DEBUG_OBJECT (rtpj2kdepay, "marker set, last buffer");
/* then flush frame */
gst_rtp_j2k_depay_flush_frame (depayload);
}
gst_rtp_buffer_unmap (&rtp);
return NULL;
/* ERRORS */
@ -586,6 +590,7 @@ empty_packet:
{
GST_ELEMENT_WARNING (rtpj2kdepay, STREAM, DECODE,
("Empty Payload."), (NULL));
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
wrong_mh_id:
@ -594,6 +599,7 @@ wrong_mh_id:
("Invalid mh_id %u, expected %u", mh_id, rtpj2kdepay->last_mh_id),
(NULL));
gst_rtp_j2k_depay_clear_pu (rtpj2kdepay);
gst_rtp_buffer_unmap (&rtp);
return NULL;
}
}

View file

@ -111,32 +111,18 @@ static gboolean gst_rtp_j2k_pay_setcaps (GstBaseRTPPayload * basepayload,
static GstFlowReturn gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * pad,
GstBuffer * buffer);
GST_BOILERPLATE (GstRtpJ2KPay, gst_rtp_j2k_pay, GstBaseRTPPayload,
GST_TYPE_BASE_RTP_PAYLOAD);
static void
gst_rtp_j2k_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_j2k_pay_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_j2k_pay_sink_template));
gst_element_class_set_details_simple (element_class,
"RTP JPEG 2000 payloader", "Codec/Payloader/Network/RTP",
"Payload-encodes JPEG 2000 pictures into RTP packets (RFC 5371)",
"Wim Taymans <wim.taymans@gmail.com>");
}
#define gst_rtp_j2k_pay_parent_class parent_class
G_DEFINE_TYPE (GstRtpJ2KPay, gst_rtp_j2k_pay, GST_TYPE_BASE_RTP_PAYLOAD);
static void
gst_rtp_j2k_pay_class_init (GstRtpJ2KPayClass * 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_j2k_pay_set_property;
@ -147,6 +133,16 @@ gst_rtp_j2k_pay_class_init (GstRtpJ2KPayClass * klass)
"Use Buffer Lists",
DEFAULT_BUFFER_LIST, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_j2k_pay_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_j2k_pay_sink_template));
gst_element_class_set_details_simple (gstelement_class,
"RTP JPEG 2000 payloader", "Codec/Payloader/Network/RTP",
"Payload-encodes JPEG 2000 pictures into RTP packets (RFC 5371)",
"Wim Taymans <wim.taymans@gmail.com>");
gstbasertppayload_class->set_caps = gst_rtp_j2k_pay_setcaps;
gstbasertppayload_class->handle_buffer = gst_rtp_j2k_pay_handle_buffer;
@ -155,7 +151,7 @@ gst_rtp_j2k_pay_class_init (GstRtpJ2KPayClass * klass)
}
static void
gst_rtp_j2k_pay_init (GstRtpJ2KPay * pay, GstRtpJ2KPayClass * klass)
gst_rtp_j2k_pay_init (GstRtpJ2KPay * pay)
{
pay->buffer_list = DEFAULT_BUFFER_LIST;
}
@ -336,10 +332,11 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
GstClockTime timestamp;
GstFlowReturn ret = GST_FLOW_ERROR;
RtpJ2KState state;
#if 0
GstBufferList *list = NULL;
GstBufferListIterator *it = NULL;
#endif
guint8 *data;
guint size;
gsize size;
guint mtu, max_size;
guint offset;
guint end, pos;
@ -347,8 +344,7 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
pay = GST_RTP_J2K_PAY (basepayload);
mtu = GST_BASE_RTP_PAYLOAD_MTU (pay);
size = GST_BUFFER_SIZE (buffer);
data = GST_BUFFER_DATA (buffer);
data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
timestamp = GST_BUFFER_TIMESTAMP (buffer);
offset = pos = end = 0;
@ -368,10 +364,12 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
state.next_sot = 0;
state.force_packet = FALSE;
#if 0
if (pay->buffer_list) {
list = gst_buffer_list_new ();
it = gst_buffer_list_iterate (list);
}
#endif
/* get max packet length */
max_size = gst_rtp_buffer_calc_payload_len (mtu - HEADER_SIZE, 0, 0);
@ -381,6 +379,7 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
guint8 *header;
guint payload_size;
guint pu_size;
GstRTPBuffer rtp = { NULL };
/* try to pack as much as we can */
do {
@ -440,17 +439,22 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
payload_size = gst_rtp_buffer_calc_payload_len (packet_size, 0, 0);
data_size = payload_size - HEADER_SIZE;
#if 0
if (pay->buffer_list) {
/* make buffer for header */
outbuf = gst_rtp_buffer_new_allocate (HEADER_SIZE, 0, 0);
} else {
} else
#endif
{
/* make buffer for header and data */
outbuf = gst_rtp_buffer_new_allocate (payload_size, 0, 0);
}
GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
/* get pointer to header */
header = gst_rtp_buffer_get_payload (outbuf);
header = gst_rtp_buffer_get_payload (&rtp);
pu_size -= data_size;
if (pu_size == 0) {
@ -464,7 +468,7 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
state.header.MHF = 2;
}
if (end >= size)
gst_rtp_buffer_set_marker (outbuf, TRUE);
gst_rtp_buffer_set_marker (&rtp, TRUE);
}
/*
@ -496,6 +500,7 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
header[6] = (state.header.offset >> 8) & 0xff;
header[7] = state.header.offset & 0xff;
#if 0
if (pay->buffer_list) {
GstBuffer *paybuf;
@ -508,9 +513,12 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
/* add both buffers to the buffer list */
gst_buffer_list_iterator_add (it, outbuf);
gst_buffer_list_iterator_add (it, paybuf);
} else {
} else
#endif
{
/* copy payload */
memcpy (header + HEADER_SIZE, &data[offset], data_size);
gst_rtp_buffer_unmap (&rtp);
ret = gst_basertppayload_push (basepayload, outbuf);
if (ret != GST_FLOW_OK)
@ -530,11 +538,13 @@ gst_rtp_j2k_pay_handle_buffer (GstBaseRTPPayload * basepayload,
done:
gst_buffer_unref (buffer);
#if 0
if (pay->buffer_list) {
/* free iterator and push the whole buffer list at once */
gst_buffer_list_iterator_free (it);
ret = gst_basertppayload_push_list (basepayload, list);
}
#endif
return ret;
}

View file

@ -66,7 +66,8 @@ static GstStaticPadTemplate gst_rtp_jpeg_depay_sink_template =
)
);
GST_BOILERPLATE (GstRtpJPEGDepay, gst_rtp_jpeg_depay, GstBaseRTPDepayload,
#define gst_rtp_jpeg_depay_parent_class parent_class
G_DEFINE_TYPE (GstRtpJPEGDepay, gst_rtp_jpeg_depay,
GST_TYPE_BASE_RTP_DEPAYLOAD);
static void gst_rtp_jpeg_depay_finalize (GObject * object);
@ -79,22 +80,6 @@ static gboolean gst_rtp_jpeg_depay_setcaps (GstBaseRTPDepayload * depayload,
static GstBuffer *gst_rtp_jpeg_depay_process (GstBaseRTPDepayload * depayload,
GstBuffer * buf);
static void
gst_rtp_jpeg_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_jpeg_depay_src_template));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&gst_rtp_jpeg_depay_sink_template));
gst_element_class_set_details_simple (element_class, "RTP JPEG depayloader",
"Codec/Depayloader/Network/RTP",
"Extracts JPEG video from RTP packets (RFC 2435)",
"Wim Taymans <wim.taymans@gmail.com>");
}
static void
gst_rtp_jpeg_depay_class_init (GstRtpJPEGDepayClass * klass)
{
@ -108,6 +93,16 @@ gst_rtp_jpeg_depay_class_init (GstRtpJPEGDepayClass * klass)
gobject_class->finalize = gst_rtp_jpeg_depay_finalize;
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_jpeg_depay_src_template));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_jpeg_depay_sink_template));
gst_element_class_set_details_simple (gstelement_class,
"RTP JPEG depayloader", "Codec/Depayloader/Network/RTP",
"Extracts JPEG video from RTP packets (RFC 2435)",
"Wim Taymans <wim.taymans@gmail.com>");
gstelement_class->change_state = gst_rtp_jpeg_depay_change_state;
gstbasertpdepayload_class->set_caps = gst_rtp_jpeg_depay_setcaps;
@ -118,8 +113,7 @@ gst_rtp_jpeg_depay_class_init (GstRtpJPEGDepayClass * klass)
}
static void
gst_rtp_jpeg_depay_init (GstRtpJPEGDepay * rtpjpegdepay,
GstRtpJPEGDepayClass * klass)
gst_rtp_jpeg_depay_init (GstRtpJPEGDepay * rtpjpegdepay)
{
rtpjpegdepay->adapter = gst_adapter_new ();
}