[vlc-commits] [Git][videolan/vlc][master] 2 commits: rtp: move test code to dedicated subdirectory
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Tue Nov 23 10:12:35 UTC 2021
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC
Commits:
471350e8 by Rémi Denis-Courmont at 2021-11-23T08:57:09+00:00
rtp: move test code to dedicated subdirectory
- - - - -
aaff6519 by Rémi Denis-Courmont at 2021-11-23T08:57:09+00:00
rtp: add test cases for rtpmap parsing
- - - - -
7 changed files:
- modules/Makefile.am
- modules/access/rtp/Makefile.am
- + modules/access/rtp/test/Makefile.am
- + modules/access/rtp/test/rtpfmt.c
- modules/access/rtp/sdp_test.c → modules/access/rtp/test/sdp.c
- modules/access/rtp/srtp-test-aes.c → modules/access/rtp/test/srtp-aes.c
- modules/access/rtp/srtp-test-recv.c → modules/access/rtp/test/srtp-recv.c
Changes:
=====================================
modules/Makefile.am
=====================================
@@ -17,6 +17,7 @@ include common.am
include access/Makefile.am
include access/http/Makefile.am
include access/rtp/Makefile.am
+include access/rtp/test/Makefile.am
include arm_neon/Makefile.am
include audio_filter/Makefile.am
include audio_mixer/Makefile.am
=====================================
modules/access/rtp/Makefile.am
=====================================
@@ -11,28 +11,17 @@ librtp_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/access/rtp
librtp_plugin_la_CFLAGS = $(AM_CFLAGS)
librtp_plugin_la_LIBADD = $(SOCKET_LIBS)
-sdp_parse_test_SOURCES = access/rtp/sdp_test.c access/rtp/sdp.c
-check_PROGRAMS += sdp_parse_test
-TESTS += sdp_parse_test
-
# Secure RTP library
libvlc_srtp_la_SOURCES = access/rtp/srtp.c access/rtp/srtp.h
libvlc_srtp_la_CPPFLAGS = -I$(srcdir)/access/rtp
libvlc_srtp_la_CFLAGS = $(GCRYPT_CFLAGS)
libvlc_srtp_la_LDFLAGS = -static
libvlc_srtp_la_LIBADD = $(GCRYPT_LIBS)
-srtp_test_recv_SOURCES = access/rtp/srtp-test-recv.c
-srtp_test_recv_LDADD = libvlc_srtp.la
-srtp_test_aes_SOURCES = access/rtp/srtp-test-aes.c
-srtp_test_aes_LDADD = $(GCRYPT_LIBS)
librtp_plugin_la_DEPENDENCIES =
if HAVE_GCRYPT
noinst_LTLIBRARIES += libvlc_srtp.la
-check_PROGRAMS += srtp-test-aes srtp-test-recv
-TESTS += srtp-test-aes srtp-test-recv
-
librtp_plugin_la_CPPFLAGS += -DHAVE_SRTP
librtp_plugin_la_CFLAGS += $(GCRYPT_CFLAGS)
librtp_plugin_la_LIBADD += libvlc_srtp.la $(GCRYPT_LIBS)
=====================================
modules/access/rtp/test/Makefile.am
=====================================
@@ -0,0 +1,19 @@
+rtpfmt_test_SOURCES = \
+ access/rtp/rtpfmt.c \
+ access/rtp/sdp.c \
+ access/rtp/test/rtpfmt.c
+sdp_test_SOURCES = \
+ access/rtp/sdp.c \
+ access/rtp/test/sdp.c
+check_PROGRAMS += rtpfmt_test sdp_test
+TESTS += rtpfmt_test sdp_test
+
+srtp_aes_test_SOURCES = access/rtp/test/srtp-aes.c
+srtp_aes_test_LDADD = $(GCRYPT_LIBS)
+srtp_recv_test_SOURCES = access/rtp/test/srtp-recv.c
+srtp_recv_test_LDADD = libvlc_srtp.la
+
+if HAVE_GCRYPT
+check_PROGRAMS += srtp_aes_test srtp_recv_test
+TESTS += srtp_aes_test srtp_recv_test
+endif
=====================================
modules/access/rtp/test/rtpfmt.c
=====================================
@@ -0,0 +1,138 @@
+/**
+ * @file rtpfmt_test.c
+ */
+/*****************************************************************************
+ * Copyright © 2021 Rémi Denis-Courmont
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ ****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#undef NDEBUG
+#include <assert.h>
+#include <stdbool.h>
+#include <string.h>
+#include "../sdp.h"
+#include <vlc_common.h>
+#include <vlc_block.h>
+#include "../rtp.h"
+
+const char vlc_module_name[] = "rtpfmt_test";
+
+static const struct vlc_rtp_pt_operations ops = {
+ NULL, NULL, NULL, NULL,
+};
+
+int vlc_rtp_pt_instantiate(vlc_object_t *obj, struct vlc_rtp_pt *restrict pt,
+ const struct vlc_sdp_pt *restrict desc)
+{
+ assert(obj == NULL);
+ assert(pt != NULL);
+ assert(desc != NULL);
+ pt->ops = &ops;
+ return 0;
+}
+
+uint8_t ptmask[16];
+
+int rtp_add_type(rtp_session_t *s, struct vlc_rtp_pt *pt)
+{
+ unsigned int num = pt->number;
+
+ assert(s == NULL);
+ assert(num < 128);
+ assert((ptmask[num / 8] >> (num % 8)) & 1);
+ ptmask[num / 8] &= ~(1 << (num % 8));
+ vlc_rtp_pt_release(pt);
+ return 0;
+}
+
+static const struct vlc_rtp_pt_owner owner = {
+ NULL, NULL,
+};
+
+#define EXPECT_PTS(...) \
+{ \
+ static const unsigned char nums[] = { __VA_ARGS__ }; \
+ for (size_t i = 0; i < sizeof (ptmask); i++) \
+ assert(ptmask[i] == 0); \
+ for (int i = 0; i < (int)ARRAY_SIZE(nums); i++) \
+ ptmask[nums[i] / 8] |= 1 << (nums[i] % 8); \
+}
+
+int main(void)
+{
+ static const char sdptext[] =
+ "v=0\r\n"
+ "o=- 1 1 IN IP4 192.0.2.1\r\n"
+ "s=Title here\r\n"
+ "t=0 0\r\n"
+ "m=audio 5004 RTP/AVP 0 3 8 12 14 33 96 97\r\n"
+ "a=rtpmap:96 L16/44100/6\r\n"
+ "a=rtpmap:97 L16/44100\r\n"
+ "m=video 5006 RTP/AVP 32 33 98\r\n"
+ "a=rtpmap:98 H264/90000\r\n"
+ "a=fmtp:98 profile-level-id=42A01E; packetization-mode=1\r\n"
+ "m=text 5008 RTP/AVP 127\r\n"
+ "a=rtpmap:127 t140/1000\r\n"
+ "m=naughty 5010 RTP/AVP 64 64 foobar 128 255\r\n"
+ "a=rtpmap:64 invalid/0/0\r\n"
+ "m=evil 5010 RTP/AVP 42 128 255\r\n"
+ "a=rtpmap:128 overflow/90000\r\n";
+
+ int val;
+
+ struct vlc_sdp *sdp = vlc_sdp_parse(sdptext, strlen(sdptext));
+ assert(sdp != NULL);
+
+ /* audio */
+ struct vlc_sdp_media *media = sdp->media;
+ assert(media != NULL);
+ EXPECT_PTS(0, 3, 8, 12, 14, 33, 96, 97);
+ val = vlc_rtp_add_media_types(NULL, NULL, media, &owner);
+ assert(val == 0);
+
+ /* video */
+ media = media->next;
+ assert(media != NULL);
+ EXPECT_PTS(32, 33, 98);
+ val = vlc_rtp_add_media_types(NULL, NULL, media, &owner);
+ assert(val == 0);
+ /* text */
+ media = media->next;
+ assert(media != NULL);
+ EXPECT_PTS(127);
+ val = vlc_rtp_add_media_types(NULL, NULL, media, &owner);
+ assert(val == 0);
+ /* naughty */
+ media = media->next;
+ assert(media != NULL);
+ EXPECT_PTS();
+ vlc_rtp_add_media_types(NULL, NULL, media, &owner);
+ /* evil */
+ media = media->next;
+ assert(media != NULL);
+ EXPECT_PTS();
+ vlc_rtp_add_media_types(NULL, NULL, media, &owner);
+
+ media = media->next;
+ EXPECT_PTS();
+ assert(media == NULL);
+ vlc_sdp_free(sdp);
+ return 0;
+}
=====================================
modules/access/rtp/sdp_test.c → modules/access/rtp/test/sdp.c
=====================================
@@ -27,7 +27,7 @@
#include <assert.h>
#include <stdbool.h>
#include <string.h>
-#include "sdp.h"
+#include "../sdp.h"
#include <vlc_common.h>
static void test_sdp_valid(const char *str)
=====================================
modules/access/rtp/srtp-test-aes.c → modules/access/rtp/test/srtp-aes.c
=====================================
@@ -18,7 +18,7 @@
*/
#include <stdio.h>
-#include "srtp.c"
+#include "../srtp.c"
static void printhex (const void *buf, size_t len)
{
=====================================
modules/access/rtp/srtp-test-recv.c → modules/access/rtp/test/srtp-recv.c
=====================================
@@ -23,7 +23,7 @@
#include <stdint.h>
#include <stddef.h>
-#include "srtp.h"
+#include "../srtp.h"
#include <stdio.h>
#include <string.h>
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/17f3a9f6bc22e2879ca3faf82eab86f0bc0be869...aaff6519b2d24675b9a3ef8a066ebb735ed29ee4
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/17f3a9f6bc22e2879ca3faf82eab86f0bc0be869...aaff6519b2d24675b9a3ef8a066ebb735ed29ee4
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list