summaryrefslogtreecommitdiffstats
path: root/gst/rtp
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-08-03 18:59:32 +0200
committerWim Taymans <wim.taymans@collabora.co.uk>2009-08-06 11:14:44 +0200
commitddfa9961c6139d8ce1fb56e1ec87b350a7385157 (patch)
tree235848d87608a02d8be65837de3b53dc0eab2104 /gst/rtp
parent2bfb42c5f8ffec7fa15666b1e6072ae11700a427 (diff)
rtph264pay: use array instead of queue
Diffstat (limited to 'gst/rtp')
-rw-r--r--gst/rtp/gstrtph264pay.c19
-rw-r--r--gst/rtp/gstrtph264pay.h2
2 files changed, 12 insertions, 9 deletions
diff --git a/gst/rtp/gstrtph264pay.c b/gst/rtp/gstrtph264pay.c
index 77bce728..eda69f40 100644
--- a/gst/rtp/gstrtph264pay.c
+++ b/gst/rtp/gstrtph264pay.c
@@ -184,7 +184,7 @@ gst_rtp_h264_pay_class_init (GstRtpH264PayClass * klass)
static void
gst_rtp_h264_pay_init (GstRtpH264Pay * rtph264pay, GstRtpH264PayClass * klass)
{
- rtph264pay->queue = g_queue_new ();
+ rtph264pay->queue = g_array_new (FALSE, FALSE, sizeof (guint));
rtph264pay->profile = 0;
rtph264pay->sps = NULL;
rtph264pay->pps = NULL;
@@ -199,7 +199,7 @@ gst_rtp_h264_pay_finalize (GObject * object)
rtph264pay = GST_RTP_H264_PAY (object);
- g_queue_free (rtph264pay->queue);
+ g_array_free (rtph264pay->queue, TRUE);
g_free (rtph264pay->sps);
g_free (rtph264pay->pps);
@@ -732,10 +732,10 @@ gst_rtp_h264_pay_handle_buffer (GstBaseRTPPayload * basepayload,
{
GstRtpH264Pay *rtph264pay;
GstFlowReturn ret;
- guint size, nal_len;
+ guint size, nal_len, i;
guint8 *data, *nal_data;
GstClockTime timestamp;
- GQueue *nal_queue;
+ GArray *nal_queue;
rtph264pay = GST_RTP_H264_PAY (basepayload);
@@ -799,6 +799,9 @@ gst_rtp_h264_pay_handle_buffer (GstBaseRTPPayload * basepayload,
nal_data = data;
nal_queue = rtph264pay->queue;
+ /* array must be empty when we get here */
+ g_assert (nal_queue->len == 0);
+
GST_DEBUG_OBJECT (basepayload, "found first start at %u, bytes left %u",
next, size);
@@ -849,12 +852,11 @@ gst_rtp_h264_pay_handle_buffer (GstBaseRTPPayload * basepayload,
update = gst_rtp_h264_pay_decode_nal (rtph264pay, data, nal_len) ||
update;
}
-
/* move to next NAL packet */
data += nal_len;
size -= nal_len;
- g_queue_push_tail (nal_queue, GUINT_TO_POINTER (nal_len));
+ g_array_append_val (nal_queue, nal_len);
}
/* if has new SPS & PPS, update the output caps */
@@ -863,7 +865,8 @@ gst_rtp_h264_pay_handle_buffer (GstBaseRTPPayload * basepayload,
/* second pass to payload and push */
data = nal_data;
- while ((nal_len = GPOINTER_TO_UINT (g_queue_pop_head (nal_queue))) > 0) {
+ for (i = 0; i < nal_queue->len; i++) {
+ nal_len = g_array_index (nal_queue, guint, i);
/* skip start code */
data += 4;
@@ -872,7 +875,6 @@ gst_rtp_h264_pay_handle_buffer (GstBaseRTPPayload * basepayload,
gst_rtp_h264_pay_payload_nal (basepayload, data, nal_len, timestamp,
buffer);
if (ret != GST_FLOW_OK) {
- g_queue_clear (nal_queue);
break;
}
@@ -880,6 +882,7 @@ gst_rtp_h264_pay_handle_buffer (GstBaseRTPPayload * basepayload,
data += nal_len;
size -= nal_len;
}
+ g_array_set_size (nal_queue, 0);
}
gst_buffer_unref (buffer);
diff --git a/gst/rtp/gstrtph264pay.h b/gst/rtp/gstrtph264pay.h
index 3865b42e..f3eb5543 100644
--- a/gst/rtp/gstrtph264pay.h
+++ b/gst/rtp/gstrtph264pay.h
@@ -56,7 +56,7 @@ struct _GstRtpH264Pay
gboolean packetized;
guint nal_length_size;
- GQueue *queue;
+ GArray *queue;
gchar *profile_level_id;
gchar *sprop_parameter_sets;