From ddfa9961c6139d8ce1fb56e1ec87b350a7385157 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 3 Aug 2009 18:59:32 +0200 Subject: rtph264pay: use array instead of queue --- gst/rtp/gstrtph264pay.c | 19 +++++++++++-------- gst/rtp/gstrtph264pay.h | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'gst/rtp') 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; -- cgit