summaryrefslogtreecommitdiff
path: root/test/test_rtp.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_rtp.cc')
-rw-r--r--test/test_rtp.cc121
1 files changed, 63 insertions, 58 deletions
diff --git a/test/test_rtp.cc b/test/test_rtp.cc
index b3ef80d..489cd42 100644
--- a/test/test_rtp.cc
+++ b/test/test_rtp.cc
@@ -25,88 +25,93 @@
* License along with lrtp; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "../src/rtp.h"
+#include <cppunit/extensions/HelperMacros.h>
-#include <stdio.h>
+#include "../src/rtp.h"
-void dump(RTP &rtp, const char *title)
+class test_rtp_class : public CppUnit::TestFixture
{
- char buf[16 * 1024];
+ CPPUNIT_TEST_SUITE(test_rtp_class);
+ CPPUNIT_TEST(test_rtp);
+ CPPUNIT_TEST_SUITE_END();
- unsigned char *p = (unsigned char *)buf;
- size_t s = rtp.packet(buf, sizeof(buf));
+public:
+ void setUp() {}
+ void tearDown() {}
- printf("%12s: ", title);
- for(int i = 0; i < s; i++) {
- if(i % 8 == 0) printf(" ");
- printf("%02x ", *p++);
- }
- printf("\n");
-}
+ void test_rtp() {
+ RTP rtp;
+ //dump(rtp, "Clean");
-int main()
-{
- RTP rtp;
- dump(rtp, "Clean");
+ rtp.setMarker(true);
+ //dump(rtp, "mark");
+
+ char payload[] = { 0x01, 0x02, 0x03 };
+ rtp.setPayload(payload, sizeof(payload));
+ //dump(rtp, "Payload[6*f]");
- rtp.setMarker(true);
- dump(rtp, "mark");
+ rtp.setPadding(5);
+ //dump(rtp, "Padding(5)");
- char payload[] = { 0xff, 0xff, 0xff };
- rtp.setPayload(payload, sizeof(payload));
- dump(rtp, "Payload[6*f]");
+ rtp.setPadding(0);
+ //dump(rtp, "Padding(0)");
- rtp.setPadding(5);
- dump(rtp, "Padding(5)");
+ rtp.setPadding(3);
+ //dump(rtp, "Padding(3)");
- rtp.setPadding(0);
- dump(rtp, "Padding(0)");
+ rtp.setMarker(true);
+ //dump(rtp, "mark");
- rtp.setPadding(3);
- dump(rtp, "Padding(3)");
+ rtp.setPayloadType(1);
+ //dump(rtp, "pt(1)");
- rtp.setMarker(true);
- dump(rtp, "mark");
+ rtp.setPayloadType(0x7f);
+ //dump(rtp, "pt(7f)");
- rtp.setPayloadType(1);
- dump(rtp, "pt(1)");
+ rtp.setPayloadType(2);
+ //dump(rtp, "pt(2)");
- rtp.setPayloadType(0x7f);
- dump(rtp, "pt(7f)");
+ rtp.addCSrc(1);
+ //dump(rtp, "CSrc[1]");
- rtp.setPayloadType(2);
- dump(rtp, "pt(2)");
+ rtp.removeCSrc(1);
+ //dump(rtp, "CSrc[-]");
- rtp.addCSrc(1);
- dump(rtp, "CSrc[1]");
+ rtp.addCSrc(2);
+ rtp.addCSrc(4);
+ //dump(rtp, "CSrc[2,4]");
- rtp.removeCSrc(1);
- dump(rtp, "CSrc[-]");
+ rtp.removeCSrc(2);
+ //dump(rtp, "CSrc[2]");
- rtp.addCSrc(2);
- rtp.addCSrc(4);
- dump(rtp, "CSrc[2,4]");
+ rtp.setSeq(0x0102);
+ //dump(rtp, "seq");
- rtp.removeCSrc(2);
- dump(rtp, "CSrc[2]");
+ rtp.setTimestamp(0x03040506);
+ //dump(rtp, "ts");
- rtp.setSeq(0x0102);
- dump(rtp, "seq");
+ rtp.setSSrc(0x0708090a);
+ //dump(rtp, "ssrc");
- rtp.setTimestamp(0x03040506);
- dump(rtp, "ts");
+ char buf[MAX_RTP_PACKET_SIZE];
+ size_t sz = rtp.packet(buf, sizeof(buf));
- rtp.setSSrc(0x0708090a);
- dump(rtp, "ssrc");
+ RTP rtp2;
+ rtp2.fromPacket(buf, sz);
- char buf[MAX_RTP_PACKET_SIZE];
- size_t sz = rtp.packet(buf, sizeof(buf));
+ char buf2[MAX_RTP_PACKET_SIZE];
+ size_t sz2 = rtp2.packet(buf2, sizeof(buf2));
- RTP rtp2;
- rtp2.fromPacket(buf, sz);
+ CPPUNIT_ASSERT_EQUAL(sz, sz2);
- dump(rtp2, "fromPacket");
+ int err = 0;
+ for(int i = 0; i < sz; i++) {
+ err += abs(buf[i] - buf2[i]);
+ }
+ CPPUNIT_ASSERT_EQUAL(0, err);
- return 0;
-}
+ }
+};
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION(test_rtp_class);