From 03992b877955b247b93c7b5d1b49233cc5f926d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 7 Sep 2007 17:37:03 +0000 Subject: [PATCH] Fix gst_rtp_buffer_set_csrc() and enable csrc-related unit test checks. Original commit message from CVS: * gst-libs/gst/rtp/gstrtpbuffer.c: * tests/check/libs/rtp.c: Fix gst_rtp_buffer_set_csrc() and enable csrc-related unit test checks. --- ChangeLog | 6 ++++ gst-libs/gst/rtp/gstrtpbuffer.c | 5 ++- tests/check/libs/rtp.c | 59 +++++++++++++++------------------ 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index d33376db7e..b6d5397d6c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-09-07 Tim-Philipp Müller + + * gst-libs/gst/rtp/gstrtpbuffer.c: + * tests/check/libs/rtp.c: + Fix gst_rtp_buffer_set_csrc() and enable csrc-related unit test checks. + 2007-09-07 Tim-Philipp Müller Based on patch by: Haakon Sporsheim diff --git a/gst-libs/gst/rtp/gstrtpbuffer.c b/gst-libs/gst/rtp/gstrtpbuffer.c index 9ace6bd77f..97c9cbbc0d 100644 --- a/gst-libs/gst/rtp/gstrtpbuffer.c +++ b/gst-libs/gst/rtp/gstrtpbuffer.c @@ -37,6 +37,7 @@ #include "gstrtpbuffer.h" #include +#include #define GST_RTP_HEADER_LEN 12 @@ -115,7 +116,9 @@ gst_rtp_buffer_allocate_data (GstBuffer * buffer, guint payload_len, GST_RTP_HEADER_VERSION (buffer) = GST_RTP_VERSION; GST_RTP_HEADER_PADDING (buffer) = FALSE; GST_RTP_HEADER_EXTENSION (buffer) = FALSE; - GST_RTP_HEADER_CSRC_COUNT (buffer) = 0; /* FIXME: not csrc_count? */ + GST_RTP_HEADER_CSRC_COUNT (buffer) = csrc_count; + memset (GST_RTP_HEADER_CSRC_LIST_OFFSET (buffer, 0), 0, + csrc_count * sizeof (guint32)); GST_RTP_HEADER_MARKER (buffer) = FALSE; GST_RTP_HEADER_PAYLOAD_TYPE (buffer) = 0; GST_RTP_HEADER_SEQ (buffer) = 0; diff --git a/tests/check/libs/rtp.c b/tests/check/libs/rtp.c index a3a0e6a771..c6a5e8f697 100644 --- a/tests/check/libs/rtp.c +++ b/tests/check/libs/rtp.c @@ -35,10 +35,9 @@ GST_START_TEST (test_rtp_buffer) guint8 *data; /* check GstRTPHeader structure alignment and packing */ - buf = gst_rtp_buffer_new_allocate (16, 4, 3); + buf = gst_rtp_buffer_new_allocate (16, 4, 0); fail_unless (buf != NULL); - fail_unless_equals_int (GST_BUFFER_SIZE (buf), - RTP_HEADER_LEN + 16 + 4 + 4 * 3); + fail_unless_equals_int (GST_BUFFER_SIZE (buf), RTP_HEADER_LEN + 16 + 4); data = GST_BUFFER_DATA (buf); /* check version in bitfield */ @@ -72,41 +71,37 @@ GST_START_TEST (test_rtp_buffer) gst_rtp_buffer_set_ssrc (buf, 0); fail_unless_equals_int (gst_rtp_buffer_get_ssrc (buf), 0); fail_unless_equals_int (GST_READ_UINT32_BE (data + 4 + 4), 0); + + /* check csrc bits */ + fail_unless_equals_int (gst_rtp_buffer_get_csrc_count (buf), 0); + ASSERT_CRITICAL (gst_rtp_buffer_get_csrc (buf, 0)); + fail_unless_equals_int (data[0] & 0xf, 0); gst_buffer_unref (buf); - /* FIXME: this is broken, the _set_csrc doesn't work because the csrc count - * is initialised to 0 and _set_csrc() then has an assertion to make sure - * index is < the value in the struct ... */ -#if 0 /* and again, this time with CSRCs */ - { - volatile guint32 ret; + buf = gst_rtp_buffer_new_allocate (16, 4, 3); + fail_unless (buf != NULL); + fail_unless_equals_int (GST_BUFFER_SIZE (buf), + RTP_HEADER_LEN + 16 + 4 + 4 * 3); - buf = gst_rtp_buffer_new_allocate (16, 4, 3); - fail_unless (buf != NULL); - fail_unless_equals_int (GST_BUFFER_SIZE (buf), - RTP_HEADER_LEN + 16 + 4 + 4 * 3); + data = GST_BUFFER_DATA (buf); - data = GST_BUFFER_DATA (buf); + fail_unless_equals_int (gst_rtp_buffer_get_csrc_count (buf), 3); + ASSERT_CRITICAL (gst_rtp_buffer_get_csrc (buf, 3)); + fail_unless_equals_int (data[0] & 0xf, 3); + fail_unless_equals_int (gst_rtp_buffer_get_csrc (buf, 0), 0); + fail_unless_equals_int (gst_rtp_buffer_get_csrc (buf, 1), 0); + fail_unless_equals_int (gst_rtp_buffer_get_csrc (buf, 2), 0); - /* the default value is 0, because we haven't set any yet (FIXME?) */ - fail_unless_equals_int (gst_rtp_buffer_get_csrc_count (buf), 0); - ASSERT_CRITICAL (ret = gst_rtp_buffer_get_csrc (buf, 0)); - - data += RTP_HEADER_LEN; /* skip the other header stuff */ - gst_rtp_buffer_set_csrc (buf, 0, 0xf7c0); - fail_unless_equals_int (GST_READ_UINT32_BE (data + 0 * 4), 0xf7c0); - fail_unless_equals_int (gst_rtp_buffer_get_csrc_count (buf), 1); /* FIXME? */ - gst_rtp_buffer_set_csrc (buf, 1, 0xf7c1); - fail_unless_equals_int (GST_READ_UINT32_BE (data + 1 * 4), 0xf7c1); - fail_unless_equals_int (gst_rtp_buffer_get_csrc_count (buf), 2); /* FIXME? */ - gst_rtp_buffer_set_csrc (buf, 2, 0xf7c2); - fail_unless_equals_int (GST_READ_UINT32_BE (data + 2 * 4), 0xf7c2); - fail_unless_equals_int (gst_rtp_buffer_get_csrc_count (buf), 3); /* FIXME? */ - ASSERT_CRITICAL (gst_rtp_buffer_set_csrc (buf, 3, 0xf123)); - gst_buffer_unref (buf); - } -#endif + data += RTP_HEADER_LEN; /* skip the other header stuff */ + gst_rtp_buffer_set_csrc (buf, 0, 0xf7c0); + fail_unless_equals_int (GST_READ_UINT32_BE (data + 0 * 4), 0xf7c0); + gst_rtp_buffer_set_csrc (buf, 1, 0xf7c1); + fail_unless_equals_int (GST_READ_UINT32_BE (data + 1 * 4), 0xf7c1); + gst_rtp_buffer_set_csrc (buf, 2, 0xf7c2); + fail_unless_equals_int (GST_READ_UINT32_BE (data + 2 * 4), 0xf7c2); + ASSERT_CRITICAL (gst_rtp_buffer_set_csrc (buf, 3, 0xf123)); + gst_buffer_unref (buf); } GST_END_TEST;