wtay gst-plugins-base: gst-plugins-base/ gst-plugins-base/gst-libs/gst/rtp/ gst-plugins-base/tests/check/libs/
[email protected] Mon, 8 Dec 2008 04:08:47 -0800 (PST)
| Newsgroups | gmane.comp.video.gstreamer.cvs |
|---|---|
| Message-ID | <[email protected]> |
CVS Root: /cvs/gstreamer
Module: gst-plugins-base
Changes by: wtay
Date: Mon Dec 08 2008 12:08:47 UTC
Log message:
Patch by: Olivier Crete <tester at tester ca>
* gst-libs/gst/rtp/gstrtcpbuffer.c: (gst_rtcp_packet_remove):
* gst-libs/gst/rtp/gstrtcpbuffer.h:
Implement gst_rtcp_packet_remove(). Fixes #563174.
* tests/check/libs/rtp.c: (GST_START_TEST), (rtp_suite):
Add unit test for some RTCP functions.
Modified files:
. : ChangeLog
gst-libs/gst/rtp: gstrtcpbuffer.c gstrtcpbuffer.h
tests/check/libs: rtp.c
Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/ChangeLog.diff?r1=1.4231&r2=1.4232
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst-libs/gst/rtp/gstrtcpbuffer.c.diff?r1=1.11&r2=1.12
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst-libs/gst/rtp/gstrtcpbuffer.h.diff?r1=1.5&r2=1.6
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/tests/check/libs/rtp.c.diff?r1=1.7&r2=1.8
====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/ChangeLog,v
retrieving revision 1.4231
retrieving revision 1.4232
diff -u -d -r1.4231 -r1.4232
--- ChangeLog 4 Dec 2008 20:09:18 -0000 1.4231
+++ ChangeLog 8 Dec 2008 12:08:29 -0000 1.4232
@@ -1,3 +1,14 @@
+2008-12-08 Wim Taymans <[email protected]>
+
+ Patch by: Olivier Crete <tester at tester ca>
+ * gst-libs/gst/rtp/gstrtcpbuffer.c: (gst_rtcp_packet_remove):
+ * gst-libs/gst/rtp/gstrtcpbuffer.h:
+ Implement gst_rtcp_packet_remove(). Fixes #563174.
+ * tests/check/libs/rtp.c: (GST_START_TEST), (rtp_suite):
+ Add unit test for some RTCP functions.
2008-12-04 Sebastian Dröge <[email protected]>
* configure.ac:
Index: gstrtcpbuffer.c
RCS file: /cvs/gstreamer/gst-plugins-base/gst-libs/gst/rtp/gstrtcpbuffer.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- gstrtcpbuffer.c 25 Nov 2008 15:33:30 -0000 1.11
+++ gstrtcpbuffer.c 8 Dec 2008 12:08:31 -0000 1.12
@@ -486,17 +486,34 @@
* gst_rtcp_packet_remove:
* @packet: a #GstRTCPPacket
*
- * Removes the packet pointed to by @packet.
+ * Removes the packet pointed to by @packet and moves pointer to the next one
- * Note: Not implemented.
+ * Returns: TRUE if @packet is pointing to a valid packet after calling this
+ * function.
*/
-void
+gboolean
gst_rtcp_packet_remove (GstRTCPPacket * packet)
{
- g_return_if_fail (packet != NULL);
- g_return_if_fail (packet->type != GST_RTCP_TYPE_INVALID);
+ gboolean ret = FALSE;
+ guint offset = 0;
- g_warning ("not implemented");
+ g_return_val_if_fail (packet != NULL, FALSE);
+ g_return_val_if_fail (packet->type != GST_RTCP_TYPE_INVALID, FALSE);
+ /* The next packet starts at offset + length + 4 (the header) */
+ offset = packet->offset + (packet->length << 2) + 4;
+ /* Overwrite this packet with the rest of the data */
+ memmove (GST_BUFFER_DATA (packet->buffer) + packet->offset,
+ GST_BUFFER_DATA (packet->buffer) + offset,
+ GST_BUFFER_SIZE (packet->buffer) - offset);
+ /* try to read next header */
+ ret = read_packet_header (packet);
+ if (!ret)
+ packet->type = GST_RTCP_TYPE_INVALID;
+ return ret;
}
/**
Index: gstrtcpbuffer.h
RCS file: /cvs/gstreamer/gst-plugins-base/gst-libs/gst/rtp/gstrtcpbuffer.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- gstrtcpbuffer.h 3 Sep 2007 19:31:11 -0000 1.5
+++ gstrtcpbuffer.h 8 Dec 2008 12:08:31 -0000 1.6
@@ -169,7 +169,7 @@
gboolean gst_rtcp_buffer_add_packet (GstBuffer *buffer, GstRTCPType type,
GstRTCPPacket *packet);
-void gst_rtcp_packet_remove (GstRTCPPacket *packet);
+gboolean gst_rtcp_packet_remove (GstRTCPPacket *packet);
/* working with packets */
gboolean gst_rtcp_packet_get_padding (GstRTCPPacket *packet);
Index: rtp.c
RCS file: /cvs/gstreamer/gst-plugins-base/tests/check/libs/rtp.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- rtp.c 14 May 2008 20:28:02 -0000 1.7
+++ rtp.c 8 Dec 2008 12:08:32 -0000 1.8
@@ -25,6 +25,7 @@
#include <gst/check/gstcheck.h>
#include <gst/rtp/gstrtpbuffer.h>
+#include <gst/rtp/gstrtcpbuffer.h>
#include <string.h>
#define RTP_HEADER_LEN 12
@@ -261,6 +262,103 @@
GST_END_TEST;
+GST_START_TEST (test_rtcp_buffer)
+{
+ GstBuffer *buf;
+ GstRTCPPacket packet;
+ guint8 *data;
+ buf = gst_rtcp_buffer_new (1400);
+ fail_unless (buf != NULL);
+ fail_unless_equals_int (GST_BUFFER_SIZE (buf), 1400);
+ data = GST_BUFFER_DATA (buf);
+ fail_unless (gst_rtcp_buffer_get_first_packet (buf, &packet) == FALSE);
+ fail_unless (gst_rtcp_buffer_get_packet_count (buf) == 0);
+ fail_unless (gst_rtcp_buffer_validate (buf) == FALSE);
+ /* add an SR packet */
+ fail_unless (gst_rtcp_buffer_add_packet (buf, GST_RTCP_TYPE_SR,
+ &packet) == TRUE);
+ fail_unless (gst_rtcp_packet_get_padding (&packet) == 0);
+ fail_unless (gst_rtcp_packet_get_count (&packet) == 0);
+ fail_unless (gst_rtcp_packet_get_type (&packet) == GST_RTCP_TYPE_SR);
+ fail_unless (gst_rtcp_packet_get_length (&packet) == 6);
+ gst_rtcp_packet_sr_set_sender_info (&packet, 0x44556677,
+ G_GUINT64_CONSTANT (1), 0x11111111, 101, 123456);
+ {
+ guint32 ssrc;
+ guint64 ntptime;
+ guint32 rtptime;
+ guint32 packet_count;
+ guint32 octet_count;
+ gst_rtcp_packet_sr_get_sender_info (&packet, &ssrc, &ntptime, &rtptime,
+ &packet_count, &octet_count);
+ fail_unless (ssrc == 0x44556677);
+ fail_unless (ntptime == G_GUINT64_CONSTANT (1));
+ fail_unless (rtptime == 0x11111111);
+ fail_unless (packet_count == 101);
+ fail_unless (octet_count == 123456);
+ }
+ /* go to first packet, this should be the packet we just added */
+ fail_unless (gst_rtcp_buffer_get_first_packet (buf, &packet) == TRUE);
+ fail_unless (gst_rtcp_packet_move_to_next (&packet) == FALSE);
+ /* add some SDES */
+ fail_unless (gst_rtcp_buffer_add_packet (buf, GST_RTCP_TYPE_SDES,
+ fail_unless (gst_rtcp_packet_sdes_add_item (&packet, 0xff658743) == TRUE);
+ fail_unless (gst_rtcp_packet_sdes_add_entry (&packet, GST_RTCP_SDES_CNAME,
+ sizeof ("[email protected]"), (guint8 *) "[email protected]") == TRUE);
+ /* add some BYE */
+ fail_unless (gst_rtcp_buffer_add_packet (buf, GST_RTCP_TYPE_BYE,
+ fail_unless (gst_rtcp_packet_bye_add_ssrc (&packet, 0x5613212f) == TRUE);
+ fail_unless (gst_rtcp_packet_bye_add_ssrc (&packet, 0x00112233) == TRUE);
+ fail_unless (gst_rtcp_packet_bye_get_ssrc_count (&packet) == 2);
+ fail_unless (gst_rtcp_packet_get_count (&packet) == 2);
+ fail_unless (gst_rtcp_packet_get_type (&packet) == GST_RTCP_TYPE_BYE);
+ fail_unless (gst_rtcp_packet_get_length (&packet) == 2);
+ /* move to SDES */
+ fail_unless (gst_rtcp_packet_move_to_next (&packet) == TRUE);
+ fail_unless (gst_rtcp_packet_get_count (&packet) == 1);
+ fail_unless (gst_rtcp_packet_get_type (&packet) == GST_RTCP_TYPE_SDES);
+ fail_unless (gst_rtcp_packet_get_length (&packet) == 5);
+ /* remove the SDES */
+ fail_unless (gst_rtcp_packet_remove (&packet) == TRUE);
+ /* we are now at the BYE packet */
+ /* close and validate */
+ gst_rtcp_buffer_end (buf);
+ fail_unless (gst_rtcp_buffer_validate (buf) == TRUE);
+}
+GST_END_TEST;
static Suite *
rtp_suite (void)
@@ -271,6 +369,9 @@
tcase_add_test (tc_chain, test_rtp_buffer);
tcase_add_test (tc_chain, test_rtp_buffer_set_extension_data);
tcase_add_test (tc_chain, test_rtp_seqnum_compare);
+ tcase_add_test (tc_chain, test_rtcp_buffer);
return s;
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
gstreamer-cvs-verbose mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gstreamer-cvs-verbose