Commit 4b920221 authored by Wim Taymans's avatar Wim Taymans
Browse files

rtp: always use buffer lists

parent 3dd99f06
...@@ -56,12 +56,9 @@ typedef enum ...@@ -56,12 +56,9 @@ typedef enum
J2K_MARKER_EOC = 0xD9 J2K_MARKER_EOC = 0xD9
} RtpJ2KMarker; } RtpJ2KMarker;
#define DEFAULT_BUFFER_LIST TRUE
enum enum
{ {
PROP_0, PROP_0,
PROP_BUFFER_LIST,
PROP_LAST PROP_LAST
}; };
...@@ -100,11 +97,6 @@ gst_rtp_j2k_depay_class_init (GstRtpJ2KDepayClass * klass) ...@@ -100,11 +97,6 @@ gst_rtp_j2k_depay_class_init (GstRtpJ2KDepayClass * klass)
gobject_class->set_property = gst_rtp_j2k_depay_set_property; gobject_class->set_property = gst_rtp_j2k_depay_set_property;
gobject_class->get_property = gst_rtp_j2k_depay_get_property; gobject_class->get_property = gst_rtp_j2k_depay_get_property;
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BUFFER_LIST,
g_param_spec_boolean ("buffer-list", "Buffer List",
"Use Buffer Lists",
DEFAULT_BUFFER_LIST, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_add_pad_template (gstelement_class, gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_j2k_depay_src_template)); gst_static_pad_template_get (&gst_rtp_j2k_depay_src_template));
gst_element_class_add_pad_template (gstelement_class, gst_element_class_add_pad_template (gstelement_class,
...@@ -127,8 +119,6 @@ gst_rtp_j2k_depay_class_init (GstRtpJ2KDepayClass * klass) ...@@ -127,8 +119,6 @@ gst_rtp_j2k_depay_class_init (GstRtpJ2KDepayClass * klass)
static void static void
gst_rtp_j2k_depay_init (GstRtpJ2KDepay * rtpj2kdepay) gst_rtp_j2k_depay_init (GstRtpJ2KDepay * rtpj2kdepay)
{ {
rtpj2kdepay->buffer_list = DEFAULT_BUFFER_LIST;
rtpj2kdepay->pu_adapter = gst_adapter_new (); rtpj2kdepay->pu_adapter = gst_adapter_new ();
rtpj2kdepay->t_adapter = gst_adapter_new (); rtpj2kdepay->t_adapter = gst_adapter_new ();
rtpj2kdepay->f_adapter = gst_adapter_new (); rtpj2kdepay->f_adapter = gst_adapter_new ();
...@@ -383,13 +373,16 @@ gst_rtp_j2k_depay_flush_frame (GstRTPBaseDepayload * depayload) ...@@ -383,13 +373,16 @@ gst_rtp_j2k_depay_flush_frame (GstRTPBaseDepayload * depayload)
goto done; goto done;
if (avail > 2) { if (avail > 2) {
GstBuffer *outbuf; GList *list, *walk;
GstBufferList *buflist;
/* take the last bytes of the JPEG 2000 data to see if there is an EOC /* take the last bytes of the JPEG 2000 data to see if there is an EOC
* marker */ * marker */
gst_adapter_copy (rtpj2kdepay->f_adapter, end, avail - 2, 2); gst_adapter_copy (rtpj2kdepay->f_adapter, end, avail - 2, 2);
if (end[0] != 0xff && end[1] != 0xd9) { if (end[0] != 0xff && end[1] != 0xd9) {
GstBuffer *outbuf;
end[0] = 0xff; end[0] = 0xff;
end[1] = 0xd9; end[1] = 0xd9;
...@@ -402,29 +395,18 @@ gst_rtp_j2k_depay_flush_frame (GstRTPBaseDepayload * depayload) ...@@ -402,29 +395,18 @@ gst_rtp_j2k_depay_flush_frame (GstRTPBaseDepayload * depayload)
gst_adapter_push (rtpj2kdepay->f_adapter, outbuf); gst_adapter_push (rtpj2kdepay->f_adapter, outbuf);
avail += 2; avail += 2;
} }
#if 0
if (rtpj2kdepay->buffer_list) { GST_DEBUG_OBJECT (rtpj2kdepay, "pushing buffer list of %u bytes", avail);
GList *list; list = gst_adapter_take_list (rtpj2kdepay->f_adapter, avail);
GstBufferList *buflist;
GstBufferListIterator *it; buflist = gst_buffer_list_new ();
GST_DEBUG_OBJECT (rtpj2kdepay, "pushing buffer list of %u bytes", avail); for (walk = list; walk; walk = g_list_next (walk))
list = gst_adapter_take_list (rtpj2kdepay->f_adapter, avail); gst_buffer_list_add (buflist, GST_BUFFER_CAST (walk->data));
buflist = gst_buffer_list_new (); g_list_free (list);
it = gst_buffer_list_iterate (buflist);
gst_buffer_list_iterator_add_group (it); ret = gst_rtp_base_depayload_push_list (depayload, buflist);
gst_buffer_list_iterator_add_list (it, list);
gst_buffer_list_iterator_free (it);
ret = gst_rtp_base_depayload_push_list (depayload, buflist);
} else
#endif
{
GST_DEBUG_OBJECT (rtpj2kdepay, "pushing buffer of %u bytes", avail);
outbuf = gst_adapter_take_buffer (rtpj2kdepay->f_adapter, avail);
ret = gst_rtp_base_depayload_push (depayload, outbuf);
}
} else { } else {
GST_WARNING_OBJECT (rtpj2kdepay, "empty packet"); GST_WARNING_OBJECT (rtpj2kdepay, "empty packet");
gst_adapter_clear (rtpj2kdepay->f_adapter); gst_adapter_clear (rtpj2kdepay->f_adapter);
...@@ -607,14 +589,7 @@ static void ...@@ -607,14 +589,7 @@ static void
gst_rtp_j2k_depay_set_property (GObject * object, guint prop_id, gst_rtp_j2k_depay_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec) const GValue * value, GParamSpec * pspec)
{ {
GstRtpJ2KDepay *rtpj2kdepay;
rtpj2kdepay = GST_RTP_J2K_DEPAY (object);
switch (prop_id) { switch (prop_id) {
case PROP_BUFFER_LIST:
rtpj2kdepay->buffer_list = g_value_get_boolean (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
...@@ -625,14 +600,7 @@ static void ...@@ -625,14 +600,7 @@ static void
gst_rtp_j2k_depay_get_property (GObject * object, guint prop_id, gst_rtp_j2k_depay_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec) GValue * value, GParamSpec * pspec)
{ {
GstRtpJ2KDepay *rtpj2kdepay;
rtpj2kdepay = GST_RTP_J2K_DEPAY (object);
switch (prop_id) { switch (prop_id) {
case PROP_BUFFER_LIST:
g_value_set_boolean (value, rtpj2kdepay->buffer_list);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
......
...@@ -58,7 +58,6 @@ struct _GstRtpJ2KDepay ...@@ -58,7 +58,6 @@ struct _GstRtpJ2KDepay
guint next_frag; guint next_frag;
gboolean have_sync; gboolean have_sync;
gboolean buffer_list;
gint width, height; gint width, height;
}; };
......
...@@ -78,12 +78,9 @@ typedef enum ...@@ -78,12 +78,9 @@ typedef enum
J2K_MARKER_EOC = 0xD9 J2K_MARKER_EOC = 0xD9
} RtpJ2KMarker; } RtpJ2KMarker;
#define DEFAULT_BUFFER_LIST TRUE
enum enum
{ {
PROP_0, PROP_0,
PROP_BUFFER_LIST,
PROP_LAST PROP_LAST
}; };
...@@ -128,11 +125,6 @@ gst_rtp_j2k_pay_class_init (GstRtpJ2KPayClass * klass) ...@@ -128,11 +125,6 @@ gst_rtp_j2k_pay_class_init (GstRtpJ2KPayClass * klass)
gobject_class->set_property = gst_rtp_j2k_pay_set_property; gobject_class->set_property = gst_rtp_j2k_pay_set_property;
gobject_class->get_property = gst_rtp_j2k_pay_get_property; gobject_class->get_property = gst_rtp_j2k_pay_get_property;
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_BUFFER_LIST,
g_param_spec_boolean ("buffer-list", "Buffer List",
"Use Buffer Lists",
DEFAULT_BUFFER_LIST, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_add_pad_template (gstelement_class, gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&gst_rtp_j2k_pay_src_template)); gst_static_pad_template_get (&gst_rtp_j2k_pay_src_template));
gst_element_class_add_pad_template (gstelement_class, gst_element_class_add_pad_template (gstelement_class,
...@@ -153,7 +145,6 @@ gst_rtp_j2k_pay_class_init (GstRtpJ2KPayClass * klass) ...@@ -153,7 +145,6 @@ gst_rtp_j2k_pay_class_init (GstRtpJ2KPayClass * klass)
static void static void
gst_rtp_j2k_pay_init (GstRtpJ2KPay * pay) gst_rtp_j2k_pay_init (GstRtpJ2KPay * pay)
{ {
pay->buffer_list = DEFAULT_BUFFER_LIST;
} }
static gboolean static gboolean
...@@ -332,9 +323,7 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload, ...@@ -332,9 +323,7 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
GstClockTime timestamp; GstClockTime timestamp;
GstFlowReturn ret = GST_FLOW_ERROR; GstFlowReturn ret = GST_FLOW_ERROR;
RtpJ2KState state; RtpJ2KState state;
#if 0
GstBufferList *list = NULL; GstBufferList *list = NULL;
#endif
GstMapInfo map; GstMapInfo map;
guint mtu, max_size; guint mtu, max_size;
guint offset; guint offset;
...@@ -364,12 +353,7 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload, ...@@ -364,12 +353,7 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
state.next_sot = 0; state.next_sot = 0;
state.force_packet = FALSE; state.force_packet = FALSE;
#if 0 list = gst_buffer_list_new ();
if (pay->buffer_list) {
list = gst_buffer_list_new ();
it = gst_buffer_list_iterate (list);
}
#endif
/* get max packet length */ /* get max packet length */
max_size = gst_rtp_buffer_calc_payload_len (mtu - HEADER_SIZE, 0, 0); max_size = gst_rtp_buffer_calc_payload_len (mtu - HEADER_SIZE, 0, 0);
...@@ -421,6 +405,7 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload, ...@@ -421,6 +405,7 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
while (pu_size > 0) { while (pu_size > 0) {
guint packet_size, data_size; guint packet_size, data_size;
GstBuffer *paybuf;
/* calculate the packet size */ /* calculate the packet size */
packet_size = packet_size =
...@@ -439,16 +424,9 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload, ...@@ -439,16 +424,9 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
payload_size = gst_rtp_buffer_calc_payload_len (packet_size, 0, 0); payload_size = gst_rtp_buffer_calc_payload_len (packet_size, 0, 0);
data_size = payload_size - HEADER_SIZE; data_size = payload_size - HEADER_SIZE;
#if 0 /* make buffer for header */
if (pay->buffer_list) { outbuf = gst_rtp_buffer_new_allocate (HEADER_SIZE, 0, 0);
/* make buffer for header */
outbuf = gst_rtp_buffer_new_allocate (HEADER_SIZE, 0, 0);
} else
#endif
{
/* make buffer for header and data */
outbuf = gst_rtp_buffer_new_allocate (payload_size, 0, 0);
}
GST_BUFFER_TIMESTAMP (outbuf) = timestamp; GST_BUFFER_TIMESTAMP (outbuf) = timestamp;
gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp); gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
...@@ -500,30 +478,15 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload, ...@@ -500,30 +478,15 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
header[6] = (state.header.offset >> 8) & 0xff; header[6] = (state.header.offset >> 8) & 0xff;
header[7] = state.header.offset & 0xff; header[7] = state.header.offset & 0xff;
#if 0 gst_rtp_buffer_unmap (&rtp);
if (pay->buffer_list) {
GstBuffer *paybuf;
/* make subbuffer of j2k data */ /* make subbuffer of j2k data */
paybuf = gst_buffer_create_sub (buffer, offset, data_size); paybuf = gst_buffer_copy_region (buffer, GST_BUFFER_COPY_MEMORY,
offset, data_size);
/* create a new group to hold the header and the payload */ outbuf = gst_buffer_append (outbuf, paybuf);
gst_buffer_list_iterator_add_group (it);
/* add both buffers to the buffer list */ gst_buffer_list_add (list, outbuf);
gst_buffer_list_iterator_add (it, outbuf);
gst_buffer_list_iterator_add (it, paybuf);
} else
#endif
{
/* copy payload */
memcpy (header + HEADER_SIZE, &map.data[offset], data_size);
gst_rtp_buffer_unmap (&rtp);
ret = gst_rtp_base_payload_push (basepayload, outbuf);
if (ret != GST_FLOW_OK)
goto done;
}
/* reset header for next round */ /* reset header for next round */
state.header.MHF = 0; state.header.MHF = 0;
...@@ -535,16 +498,10 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload, ...@@ -535,16 +498,10 @@ gst_rtp_j2k_pay_handle_buffer (GstRTPBasePayload * basepayload,
offset = pos; offset = pos;
} while (offset < map.size); } while (offset < map.size);
done:
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
#if 0 /* push the whole buffer list at once */
if (pay->buffer_list) { ret = gst_rtp_base_payload_push_list (basepayload, list);
/* free iterator and push the whole buffer list at once */
gst_buffer_list_iterator_free (it);
ret = gst_rtp_base_payload_push_list (basepayload, list);
}
#endif
return ret; return ret;
} }
...@@ -553,14 +510,7 @@ static void ...@@ -553,14 +510,7 @@ static void
gst_rtp_j2k_pay_set_property (GObject * object, guint prop_id, gst_rtp_j2k_pay_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec) const GValue * value, GParamSpec * pspec)
{ {
GstRtpJ2KPay *rtpj2kpay;
rtpj2kpay = GST_RTP_J2K_PAY (object);
switch (prop_id) { switch (prop_id) {
case PROP_BUFFER_LIST:
rtpj2kpay->buffer_list = g_value_get_boolean (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
...@@ -571,14 +521,7 @@ static void ...@@ -571,14 +521,7 @@ static void
gst_rtp_j2k_pay_get_property (GObject * object, guint prop_id, gst_rtp_j2k_pay_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec) GValue * value, GParamSpec * pspec)
{ {
GstRtpJ2KPay *rtpj2kpay;
rtpj2kpay = GST_RTP_J2K_PAY (object);
switch (prop_id) { switch (prop_id) {
case PROP_BUFFER_LIST:
g_value_set_boolean (value, rtpj2kpay->buffer_list);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
......
...@@ -43,8 +43,6 @@ struct _GstRtpJ2KPay ...@@ -43,8 +43,6 @@ struct _GstRtpJ2KPay
{ {
GstRTPBasePayload payload; GstRTPBasePayload payload;
gboolean buffer_list;
gint height; gint height;
gint width; gint width;
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment