summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am14
-rw-r--r--test/test1.jpgbin0 -> 7484 bytes
-rw-r--r--test/test2.jpgbin0 -> 7728 bytes
-rw-r--r--test/test3.jpgbin0 -> 7604 bytes
-rw-r--r--test/test4.jpgbin0 -> 7768 bytes
-rw-r--r--test/test_amrwb.cc18
-rw-r--r--test/test_asc2bin.cc2
-rw-r--r--test/test_init.cc10
-rw-r--r--test/test_jpeg.cc165
-rw-r--r--test/test_l16.cc148
-rw-r--r--test/test_opus.cc27
-rw-r--r--test/test_raw.cc30
-rw-r--r--test/test_rtp.cc2
-rw-r--r--test/test_srtp.cc2
14 files changed, 370 insertions, 48 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index b735c3c..00dc707 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,7 +1,11 @@
-TESTS = amrwb opus init rtp srtp raw asc2bin
+TESTS = jpeg amrwb opus init rtp srtp raw l16 asc2bin framelist
check_PROGRAMS = $(TESTS)
+jpeg_CXXFLAGS = $(CPPUNIT_CFLAGS) -DOUTPUT=\"jpeg\" -I../src
+jpeg_LDFLAGS = $(CPPUNIT_LIBS) -L../src/.libs/ -llrtp
+jpeg_SOURCES = test.cc test_jpeg.cc
+
amrwb_CXXFLAGS = $(CPPUNIT_CFLAGS) -DOUTPUT=\"amrwb\" -I../src
amrwb_LDFLAGS = $(CPPUNIT_LIBS) -L../src/.libs/ -llrtp
amrwb_SOURCES = test.cc test_amrwb.cc
@@ -26,9 +30,17 @@ raw_CXXFLAGS = $(CPPUNIT_CFLAGS) -DOUTPUT=\"raw\" -I../src
raw_LDFLAGS = $(CPPUNIT_LIBS) -L../src/.libs/ -llrtp
raw_SOURCES = test.cc test_raw.cc
+l16_CXXFLAGS = $(CPPUNIT_CFLAGS) -DOUTPUT=\"l16\" -I../src
+l16_LDFLAGS = $(CPPUNIT_LIBS) -L../src/.libs/ -llrtp
+l16_SOURCES = test.cc test_l16.cc
+
asc2bin_CXXFLAGS = $(CPPUNIT_CFLAGS) -DOUTPUT=\"asc2bin\" -I../src
asc2bin_LDFLAGS = $(CPPUNIT_LIBS)
asc2bin_SOURCES = test.cc test_asc2bin.cc
+framelist_CXXFLAGS = $(CPPUNIT_CFLAGS) -DOUTPUT=\"framelist\" -I../src
+framelist_LDFLAGS = $(CPPUNIT_LIBS) -L../src/.libs/ -llrtp
+framelist_SOURCES = test.cc test_framelist.cc
+
clean-local:
-rm -f result_*.xml
diff --git a/test/test1.jpg b/test/test1.jpg
new file mode 100644
index 0000000..96071a2
--- /dev/null
+++ b/test/test1.jpg
Binary files differ
diff --git a/test/test2.jpg b/test/test2.jpg
new file mode 100644
index 0000000..fda292b
--- /dev/null
+++ b/test/test2.jpg
Binary files differ
diff --git a/test/test3.jpg b/test/test3.jpg
new file mode 100644
index 0000000..ad9ad2d
--- /dev/null
+++ b/test/test3.jpg
Binary files differ
diff --git a/test/test4.jpg b/test/test4.jpg
new file mode 100644
index 0000000..cc86495
--- /dev/null
+++ b/test/test4.jpg
Binary files differ
diff --git a/test/test_amrwb.cc b/test/test_amrwb.cc
index adefda1..d6a0731 100644
--- a/test/test_amrwb.cc
+++ b/test/test_amrwb.cc
@@ -68,7 +68,7 @@ public:
std::vector<std::string> packets;
unsigned int csrc = 42;
- int sent = 0;
+ // int sent = 0;
size_t num_frames = NUM_PKGS;
size_t framesize = wb_frame_size[frame_type_index] * num_frames;
@@ -76,24 +76,25 @@ public:
{ // Encode
struct lrtp_t *lrtp = lrtp_init(KEY, SSRC);
- struct lrtp_profile_t *profile =
+ int x =
lrtp_create_profile(lrtp, PROFILE_AMRWB, csrc,
OPTION_AMRWB_FRAME_TYPE_INDEX, frame_type_index,
OPTION_END);
+ CPPUNIT_ASSERT_EQUAL(0, x);
char packet[PKG_SIZE];
- size_t packetsize = sizeof(packet);
+ //size_t packetsize = sizeof(packet);
char cnt = 0;
+ int timestamp = 0;
+
for(int i = 0; i < NUM_PKGS; i++) {
char frame[wb_frame_size[frame_type_index] * num_frames];
- for(int i = 0; i < framesize; i++) frame[i] = cnt++;
-
- int timestamp = 0;
+ for(size_t j = 0; j < framesize; j++) frame[j] = cnt++;
- int ret = lrtp_enqueue_frame(profile, frame, framesize);
+ int ret = lrtp_enqueue_frame(lrtp, csrc, frame, framesize, timestamp++);
while( (ret = lrtp_pack(lrtp, packet, sizeof(packet))) != 0) {
std::string p;
p.append(packet, ret);
@@ -108,10 +109,11 @@ public:
{ // Decode
struct lrtp_t *lrtp = lrtp_init(KEY, SSRC);
- struct lrtp_profile_t *profile =
+ int x =
lrtp_create_profile(lrtp, PROFILE_AMRWB, csrc,
OPTION_AMRWB_FRAME_TYPE_INDEX, frame_type_index,
OPTION_END);
+ CPPUNIT_ASSERT_EQUAL(0, x);
char frame[16*1024];
diff --git a/test/test_asc2bin.cc b/test/test_asc2bin.cc
index 1663c70..f214a5a 100644
--- a/test/test_asc2bin.cc
+++ b/test/test_asc2bin.cc
@@ -30,8 +30,6 @@
#include "../src/asc2bin.h"
#include "../src/asc2bin.cc"
-static int g_i = -1;
-
class test_asc2bin_class : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(test_asc2bin_class);
diff --git a/test/test_init.cc b/test/test_init.cc
index 3281183..13ca874 100644
--- a/test/test_init.cc
+++ b/test/test_init.cc
@@ -50,12 +50,10 @@ public:
CPPUNIT_ASSERT(lrtp);
unsigned int csrc = 42;
- struct lrtp_profile_t *profile =
- lrtp_create_profile(lrtp, PROFILE_RAW, csrc,
- OPTION_RAW_PKG_SIZE, 100,
- OPTION_END);
-
- CPPUNIT_ASSERT(profile);
+ int x = lrtp_create_profile(lrtp, PROFILE_RAW, csrc,
+ OPTION_RAW_PKG_SIZE, 100,
+ OPTION_END);
+ CPPUNIT_ASSERT_EQUAL(0, x);
lrtp_destroy_profile(lrtp, csrc);
diff --git a/test/test_jpeg.cc b/test/test_jpeg.cc
new file mode 100644
index 0000000..894ae3a
--- /dev/null
+++ b/test/test_jpeg.cc
@@ -0,0 +1,165 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * test_jpeg.cc
+ *
+ * Wed Dec 18 08:59:12 CET 2013
+ * Copyright 2013 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of lrtp.
+ *
+ * lrtp 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.
+ *
+ * lrtp 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 lrtp; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <lrtp.h>
+
+#include <stdio.h>
+
+#include <string>
+#include <vector>
+
+#define KEY "123456789012345678901234567890123456789012345678901234567890"
+#define SSRC 1234567890
+
+class test_jpeg_class : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE(test_jpeg_class);
+ CPPUNIT_TEST(test_jpeg);
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+ void setUp() {}
+ void tearDown() {}
+
+ void test_jpeg() {
+
+ std::vector<std::string> packets;
+ unsigned int csrc = 42;
+
+ { // Encode
+ struct lrtp_t *lrtp = lrtp_init(KEY, SSRC);
+
+ int x = lrtp_create_profile(lrtp, PROFILE_JPEG, csrc,
+ OPTION_END);
+ CPPUNIT_ASSERT_EQUAL(0, x);
+ //char num = 0;
+
+ char packet[16*1024];
+
+
+ for(int n = 1; n < 5; n++) {
+ char filename[32];
+ sprintf(filename, "test%d.jpg", n);
+
+ //printf("----------- Image %d -----------\n", n);
+
+ FILE *fp = fopen(filename, "r");
+ CPPUNIT_ASSERT(fp);
+ fseek(fp, 0, SEEK_END);
+ int imagesize = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+ char *image = (char*)malloc(imagesize);
+ fread(image, imagesize, 1, fp);
+ fclose(fp);
+
+ int ret = 0;
+ ret = lrtp_enqueue_frame(lrtp, csrc, image, imagesize, n);
+ CPPUNIT_ASSERT_EQUAL(0, ret);
+
+ while( (ret = lrtp_pack(lrtp, packet, sizeof(packet))) != 0) {
+ std::string p;
+ p.append(packet, ret);
+ packets.push_back(p);
+ //dump("pkg", packet, ret);
+ }
+
+ free(image);
+ }
+
+ lrtp_destroy_profile(lrtp, csrc);
+
+ lrtp_close(lrtp);
+ }
+
+ //printf("\nPackets: %d\n", packets.size());
+
+ { // Decode
+ //FILE *fp = fopen("output.jpg", "w");
+
+ // Write SIO and JFIF from original image:
+ // fwrite(image, 2 + 16, 1, fp);
+
+ struct lrtp_t *lrtp = lrtp_init(KEY, SSRC);
+
+ int x = lrtp_create_profile(lrtp, PROFILE_JPEG, csrc,
+ OPTION_END);
+ CPPUNIT_ASSERT_EQUAL(0, x);
+
+ char frame[16*1024];
+ size_t framesize = sizeof(frame);
+
+ //int cnt = 0;
+
+ // int num = 2 + 16; // Skip SOI and JFIF in comparison
+
+ std::vector<std::string>::iterator i = packets.begin();
+ while(i != packets.end()) {
+ size_t packetsize = i->size();
+ // printf("unpack sz: %d\n", packetsize);
+ const char *packet = i->data();
+ unsigned int ts;
+
+ framesize = sizeof(frame);
+
+ lrtp_unpack(lrtp, packet, packetsize);
+ int ret;
+ while((ret = lrtp_dequeue_frame(lrtp, frame, framesize, &csrc, &ts))
+ != 0) {
+ //printf("Got %d bytes, csrc %d, ts: %d\n", ret, csrc, ts);
+
+ //fwrite(frame, ret, 1, fp);
+ /*
+ int err = 0;
+ for(int i = 0; i < ret; i++) {
+ err += abs(frame[i] - image[num++]);
+ }
+ CPPUNIT_ASSERT_EQUAL(0, err);
+ */
+ //dump("pkg", frame, ret);
+ }
+
+ i++;
+ }
+
+ // CPPUNIT_ASSERT_EQUAL((int)imagesize, num);
+
+ lrtp_destroy_profile(lrtp, csrc);
+ lrtp_close(lrtp);
+
+ //fclose(fp);
+ }
+
+ //free(image);
+ }
+};
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION(test_jpeg_class);
+
+
diff --git a/test/test_l16.cc b/test/test_l16.cc
new file mode 100644
index 0000000..0cdb4b2
--- /dev/null
+++ b/test/test_l16.cc
@@ -0,0 +1,148 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * test_l16.cc
+ *
+ * Mon Sep 2 14:02:16 CEST 2013
+ * Copyright 2013 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of lrtp.
+ *
+ * lrtp 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.
+ *
+ * lrtp 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 lrtp; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <lrtp.h>
+
+#include <stdio.h>
+
+#include <string>
+#include <vector>
+
+#define KEY "123456789012345678901234567890123456789012345678901234567890"
+#define SSRC 1234567890
+
+class test_conn_class : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE(test_conn_class);
+ CPPUNIT_TEST(test_l16);
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+ void setUp() {}
+ void tearDown() {}
+
+ void test_l16() {
+ char frame[5];
+ int pkg_size = 4;
+
+ std::vector<std::string> packets;
+ unsigned int csrc = 42;
+
+ CPPUNIT_ASSERT(false); // We need to actually test the profile options here...
+
+ { // Encode
+ struct lrtp_t *lrtp = lrtp_init(KEY, SSRC);
+
+ /*
+ OPTION_L16_SAMPLES_PER_CHANNEL_PER_PACKET
+ OPTION_L16_CHANNELS
+ OPTION_L16_LITTLE_ENDIAN
+ */
+
+ int x =
+ lrtp_create_profile(lrtp, PROFILE_L16, csrc,
+ OPTION_L16_SAMPLES_PER_CHANNEL_PER_PACKET, pkg_size,
+ OPTION_END);
+ CPPUNIT_ASSERT_EQUAL(0, x);
+
+ char num = 0;
+
+ char packet[16*1024];
+ //size_t size = sizeof(packet);
+
+ for(unsigned int ts = 0; ts < 8; ts++) {
+
+ for(size_t i = 0; i < sizeof(frame); i++) frame[i] = num++;
+
+ int ret = 0;
+ ret = lrtp_enqueue_frame(lrtp, csrc, frame, sizeof(frame), ts);
+ while( (ret = lrtp_pack(lrtp, packet, sizeof(packet))) != 0) {
+ std::string p;
+ p.append(packet, ret);
+ packets.push_back(p);
+ //dump("pkg", packet, ret);
+ }
+ }
+
+ lrtp_destroy_profile(lrtp, csrc);
+
+ lrtp_close(lrtp);
+ }
+
+ { // Decode
+ struct lrtp_t *lrtp = lrtp_init(KEY, SSRC);
+
+ int x =
+ lrtp_create_profile(lrtp, PROFILE_L16, csrc,
+ OPTION_L16_SAMPLES_PER_CHANNEL_PER_PACKET, pkg_size,
+ OPTION_END);
+ CPPUNIT_ASSERT_EQUAL(0, x);
+
+ char frame[16*1024];
+ size_t framesize = sizeof(frame);
+
+ //int cnt = 0;
+
+ char num = 0;
+
+ std::vector<std::string>::iterator i = packets.begin();
+ while(i != packets.end()) {
+ size_t packetsize = i->size();
+ // printf("unpack sz: %d\n", packetsize);
+ const char *packet = i->data();
+ unsigned int ts;
+
+ framesize = sizeof(frame);
+
+ lrtp_unpack(lrtp, packet, packetsize);
+ int ret;
+ while((ret = lrtp_dequeue_frame(lrtp, frame, framesize, &csrc, &ts))
+ != 0) {
+ //printf("Got %d bytes, csrc %d, ts: %d\n", ret, csrc, ts);
+
+ int err = 0;
+ for(int i = 0; i < ret; i++) {
+ err += abs(frame[i] - num++);
+ }
+ CPPUNIT_ASSERT_EQUAL(0, err);
+
+ //dump("pkg", frame, ret);
+ }
+
+ i++;
+ }
+
+ lrtp_destroy_profile(lrtp, csrc);
+ lrtp_close(lrtp);
+ }
+ }
+};
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION(test_conn_class);
diff --git a/test/test_opus.cc b/test/test_opus.cc
index ea6a5b4..380e7b9 100644
--- a/test/test_opus.cc
+++ b/test/test_opus.cc
@@ -81,20 +81,19 @@ public:
int32_t lookahead;
- size_t ts = 0;
+ //size_t ts = 0;
int sent = 0;
{ // Encode
struct lrtp_t *lrtp = lrtp_init(KEY, SSRC);
- struct lrtp_profile_t *profile =
- lrtp_create_profile(lrtp, PROFILE_OPUS, csrc,
- //OPTION_RAW_PKG_SIZE, pkg_size,
- OPTION_END);
+ int x = lrtp_create_profile(lrtp, PROFILE_OPUS, csrc,
+ OPTION_END);
+ CPPUNIT_ASSERT_EQUAL(0, x);
char packet[16*1024];
- size_t packetsize = sizeof(packet);
+ //size_t packetsize = sizeof(packet);
int err;
OpusEncoder *opus = opus_encoder_create(FS, channels,
@@ -108,14 +107,14 @@ public:
long long int sin_x = 0;
- int cnt = 0;
+ //int cnt = 0;
size_t timestamp = 0;
size_t idx = 0;
for(unsigned int ts = 0; ts < FS / 10; ts++) {
size_t pcmsize = ms[idx] / (48000.0 / FS); // Number of samples pr channel
sent += pcmsize;
short *pcm = new short[100000/*pcmsize * channels*/];
- for(int i = 0 ; i < pcmsize; i++) {
+ for(size_t i = 0 ; i < pcmsize; i++) {
sin_x++;
if((int)sin_x % FS == 0) {
@@ -138,7 +137,7 @@ public:
printf("Opus error: %s\n", opus_strerror(framesize));
}
- int ret = lrtp_enqueue_frame(profile, frame, framesize);
+ int ret = lrtp_enqueue_frame(lrtp, csrc, frame, framesize, timestamp);
while( (ret = lrtp_pack(lrtp, packet, sizeof(packet))) != 0) {
std::string p;
p.append(packet, ret);
@@ -156,15 +155,15 @@ public:
{ // Decode
struct lrtp_t *lrtp = lrtp_init(KEY, SSRC);
- struct lrtp_profile_t *profile =
- lrtp_create_profile(lrtp, PROFILE_OPUS, csrc,
- OPTION_END);
+ int x = lrtp_create_profile(lrtp, PROFILE_OPUS, csrc,
+ OPTION_END);
+ CPPUNIT_ASSERT_EQUAL(0, x);
int err;
OpusDecoder *opus = opus_decoder_create(FS, channels, &err);
CPPUNIT_ASSERT_EQUAL(0, err);
- int idx = (sizeof(ms)/sizeof(size_t)) - 1;
+ //int idx = (sizeof(ms)/sizeof(size_t)) - 1;
char frame[16*1024];
@@ -173,7 +172,7 @@ public:
long long int errl = 0;
long long int errr = 0;
- int cnt = 0;
+ //int cnt = 0;
std::vector<std::string>::iterator i = packets.begin();
while(i != packets.end()) {
size_t packetsize = i->size();
diff --git a/test/test_raw.cc b/test/test_raw.cc
index d3910d3..e219ffa 100644
--- a/test/test_raw.cc
+++ b/test/test_raw.cc
@@ -1,7 +1,7 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set et sw=2 ts=2: */
/***************************************************************************
- * test_init.cc
+ * test_raw.cc
*
* Mon Sep 2 14:02:16 CEST 2013
* Copyright 2013 Bent Bisballe Nyeng
@@ -57,22 +57,22 @@ public:
{ // Encode
struct lrtp_t *lrtp = lrtp_init(KEY, SSRC);
- struct lrtp_profile_t *profile =
- lrtp_create_profile(lrtp, PROFILE_RAW, csrc,
- OPTION_RAW_PKG_SIZE, pkg_size,
- OPTION_END);
-
+ int x = lrtp_create_profile(lrtp, PROFILE_RAW, csrc,
+ OPTION_RAW_PKG_SIZE, pkg_size,
+ OPTION_END);
+ CPPUNIT_ASSERT_EQUAL(0, x);
+
char num = 0;
char packet[16*1024];
- size_t size = sizeof(packet);
+ //size_t size = sizeof(packet);
for(unsigned int ts = 0; ts < 8; ts++) {
- for(int i = 0; i < sizeof(frame); i++) frame[i] = num++;
+ for(size_t i = 0; i < sizeof(frame); i++) frame[i] = num++;
int ret = 0;
- ret = lrtp_enqueue_frame(profile, frame, sizeof(frame));
+ ret = lrtp_enqueue_frame(lrtp, csrc, frame, sizeof(frame), ts);
while( (ret = lrtp_pack(lrtp, packet, sizeof(packet))) != 0) {
std::string p;
p.append(packet, ret);
@@ -89,15 +89,15 @@ public:
{ // Decode
struct lrtp_t *lrtp = lrtp_init(KEY, SSRC);
- struct lrtp_profile_t *profile =
- lrtp_create_profile(lrtp, PROFILE_RAW, csrc,
- OPTION_RAW_PKG_SIZE, pkg_size,
- OPTION_END);
-
+ int x = lrtp_create_profile(lrtp, PROFILE_RAW, csrc,
+ OPTION_RAW_PKG_SIZE, pkg_size,
+ OPTION_END);
+ CPPUNIT_ASSERT_EQUAL(0, x);
+
char frame[16*1024];
size_t framesize = sizeof(frame);
- int cnt = 0;
+ //int cnt = 0;
char num = 0;
diff --git a/test/test_rtp.cc b/test/test_rtp.cc
index 489cd42..4703740 100644
--- a/test/test_rtp.cc
+++ b/test/test_rtp.cc
@@ -105,7 +105,7 @@ public:
CPPUNIT_ASSERT_EQUAL(sz, sz2);
int err = 0;
- for(int i = 0; i < sz; i++) {
+ for(size_t i = 0; i < sz; i++) {
err += abs(buf[i] - buf2[i]);
}
CPPUNIT_ASSERT_EQUAL(0, err);
diff --git a/test/test_srtp.cc b/test/test_srtp.cc
index c7b82e5..7c0dc60 100644
--- a/test/test_srtp.cc
+++ b/test/test_srtp.cc
@@ -78,7 +78,7 @@ public:
CPPUNIT_ASSERT_EQUAL(sz, sz0);
int err = 0;
- for(int i = 0; i < sz0; i++) {
+ for(size_t i = 0; i < sz0; i++) {
err += abs(buf0[i] - buf[i]);
}