tests: Distribute IPv6 tests to other tests
Also slightly shorten the duration of some tests.
This commit is contained in:
parent
f6ef56f3c7
commit
0fd38ffca6
|
@ -16,7 +16,6 @@ if (Git_FOUND)
|
|||
test_4_formats.cpp
|
||||
test_5_srtp_zrtp.cpp
|
||||
test_6_scl_unit_test.cpp
|
||||
test_7_ipv6.cpp
|
||||
test_common.hh
|
||||
)
|
||||
|
||||
|
|
|
@ -8,7 +8,10 @@
|
|||
constexpr uint16_t SEND_PORT = 9300;
|
||||
|
||||
constexpr char REMOTE_ADDRESS[] = "127.0.0.1";
|
||||
constexpr char REMOTE_ADDRESS_IP6[] = "::1";
|
||||
constexpr char MULTICAST_ADDRESS[] = "224.0.0.122";
|
||||
constexpr char MULTICAST_ADDRESS_IP6[] = "FF02:0:0:0:0:0:0:0";
|
||||
|
||||
constexpr uint16_t RECEIVE_PORT = 9302;
|
||||
|
||||
void rtp_receive_hook(void* arg, uvgrtp::frame::rtp_frame* frame);
|
||||
|
@ -77,6 +80,36 @@ TEST(RTPTests, rtp_hook)
|
|||
cleanup_sess(ctx, sess);
|
||||
}
|
||||
|
||||
TEST(RTPTests, rtp_hook_ip6)
|
||||
{
|
||||
// Tests installing a hook to uvgRTP
|
||||
std::cout << "Starting IPv6 RTP hook test" << std::endl;
|
||||
uvgrtp::context ctx;
|
||||
uvgrtp::session* sess = ctx.create_session(REMOTE_ADDRESS_IP6);
|
||||
|
||||
uvgrtp::media_stream* sender = nullptr;
|
||||
uvgrtp::media_stream* receiver = nullptr;
|
||||
|
||||
int flags = RCE_FRAGMENT_GENERIC;
|
||||
if (sess)
|
||||
{
|
||||
sender = sess->create_stream(RECEIVE_PORT, SEND_PORT, RTP_FORMAT_GENERIC, flags);
|
||||
receiver = sess->create_stream(SEND_PORT, RECEIVE_PORT, RTP_FORMAT_GENERIC, flags);
|
||||
}
|
||||
|
||||
int test_packets = 10;
|
||||
std::vector<size_t> sizes = { 1000, 2000 };
|
||||
for (size_t& size : sizes)
|
||||
{
|
||||
std::unique_ptr<uint8_t[]> test_frame = create_test_packet(RTP_FORMAT_GENERIC, 0, false, size, RTP_NO_FLAGS);
|
||||
test_packet_size(std::move(test_frame), test_packets, size, sess, sender, receiver, RTP_NO_FLAGS, RTP_FORMAT_GENERIC);
|
||||
}
|
||||
|
||||
cleanup_ms(sess, sender);
|
||||
cleanup_ms(sess, receiver);
|
||||
cleanup_sess(ctx, sess);
|
||||
}
|
||||
|
||||
TEST(RTPTests, rtp_copy)
|
||||
{
|
||||
// Tests installing a hook to uvgRTP
|
||||
|
@ -430,7 +463,7 @@ TEST(RTPTests, rtp_multicast)
|
|||
cleanup_sess(ctx, sess);
|
||||
}
|
||||
|
||||
TEST(RTPTests, rtp_multicast_multiple)
|
||||
TEST(RTPTests, rtp_multicast_multiple_ip4)
|
||||
{
|
||||
// Tests with a multicast address
|
||||
std::cout << "Starting RTP multicast test" << std::endl;
|
||||
|
@ -461,6 +494,37 @@ TEST(RTPTests, rtp_multicast_multiple)
|
|||
cleanup_sess(ctx, sess);
|
||||
}
|
||||
|
||||
TEST(RTPTests, rtp_multicast_multiple_ip6)
|
||||
{
|
||||
// Tests with a multicast address
|
||||
std::cout << "Starting RTP multicast test" << std::endl;
|
||||
uvgrtp::context ctx;
|
||||
uvgrtp::session* sess = ctx.create_session(MULTICAST_ADDRESS_IP6, MULTICAST_ADDRESS_IP6);
|
||||
|
||||
EXPECT_NE(nullptr, sess);
|
||||
if (!sess) return;
|
||||
|
||||
int flags = RCE_FRAGMENT_GENERIC;
|
||||
|
||||
auto sender = sess->create_stream(RECEIVE_PORT, SEND_PORT, RTP_FORMAT_GENERIC, flags);
|
||||
std::vector<uvgrtp::media_stream*> receivers = {
|
||||
sess->create_stream(SEND_PORT, RECEIVE_PORT, RTP_FORMAT_GENERIC, flags),
|
||||
sess->create_stream(SEND_PORT, RECEIVE_PORT, RTP_FORMAT_GENERIC, flags)
|
||||
};
|
||||
|
||||
int test_packets = 10;
|
||||
std::vector<size_t> sizes = { 1000, 2000 };
|
||||
for (size_t& size : sizes)
|
||||
{
|
||||
std::unique_ptr<uint8_t[]> test_frame = create_test_packet(RTP_FORMAT_GENERIC, 0, false, size, RTP_NO_FLAGS);
|
||||
test_packet_size(std::move(test_frame), test_packets, size, sess, sender, receivers, RTP_NO_FLAGS, RTP_FORMAT_GENERIC);
|
||||
}
|
||||
|
||||
cleanup_ms(sess, sender);
|
||||
for (auto receiver : receivers) cleanup_ms(sess, receiver);
|
||||
cleanup_sess(ctx, sess);
|
||||
}
|
||||
|
||||
TEST(RTPTests, rtp_multiplex)
|
||||
{
|
||||
// Test multiplexing two RTP streams into a single socket
|
||||
|
@ -653,6 +717,7 @@ TEST(RTPTests, rtp_multiplex_poll)
|
|||
cleanup_sess(ctx, sender_sess);
|
||||
cleanup_sess(ctx, receiver_sess);
|
||||
}
|
||||
|
||||
/* User packets disabled for now
|
||||
TEST(RTPTests, uvgrtp_user_frames)
|
||||
{
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
#include "test_common.hh"
|
||||
|
||||
constexpr char LOCAL_INTERFACE[] = "127.0.0.1";
|
||||
constexpr char LOCAL_INTERFACE_IP6[] = "::1";
|
||||
constexpr uint16_t LOCAL_PORT = 9200;
|
||||
|
||||
constexpr char REMOTE_ADDRESS[] = "127.0.0.1";
|
||||
constexpr char REMOTE_ADDRESS_IP6[] = "::1";
|
||||
constexpr uint16_t REMOTE_PORT = 9202;
|
||||
|
||||
|
||||
constexpr uint16_t PAYLOAD_LEN = 256;
|
||||
constexpr uint16_t FRAME_RATE = 30;
|
||||
constexpr uint32_t EXAMPLE_RUN_TIME_S = 4;
|
||||
constexpr uint32_t EXAMPLE_RUN_TIME_S = 3;
|
||||
constexpr int SEND_TEST_PACKETS = FRAME_RATE * EXAMPLE_RUN_TIME_S;
|
||||
constexpr int PACKET_INTERVAL_MS = 1000 / FRAME_RATE;
|
||||
|
||||
|
@ -31,7 +34,7 @@ static int received2;
|
|||
static int received3;
|
||||
static int received4;
|
||||
|
||||
TEST(RTCPTests, rtcp) {
|
||||
TEST(RTCPTests, rtcp_ip4) {
|
||||
std::cout << "Starting uvgRTP RTCP tests" << std::endl;
|
||||
|
||||
// Creation of RTP stream. See sending example for more details
|
||||
|
@ -77,6 +80,58 @@ TEST(RTCPTests, rtcp) {
|
|||
|
||||
|
||||
|
||||
cleanup(ctx, local_session, remote_session, local_stream, remote_stream);
|
||||
std::cout << "Received RRs: " << received1 << ", received SRs: " << received2 << std::endl;
|
||||
EXPECT_TRUE(received1 > 0);
|
||||
EXPECT_TRUE(received2 > 0);
|
||||
}
|
||||
|
||||
TEST(RTCPTests, rtcp_ip6) {
|
||||
std::cout << "Starting uvgRTP RTCP tests" << std::endl;
|
||||
|
||||
// Creation of RTP stream. See sending example for more details
|
||||
uvgrtp::context ctx;
|
||||
uvgrtp::session* local_session = ctx.create_session(REMOTE_ADDRESS_IP6);
|
||||
uvgrtp::session* remote_session = ctx.create_session(LOCAL_INTERFACE_IP6);
|
||||
|
||||
int flags = RCE_RTCP;
|
||||
|
||||
// received1 is receiver reports, received2 sender reports
|
||||
received1 = 0;
|
||||
received2 = 0;
|
||||
|
||||
uvgrtp::media_stream* local_stream = nullptr;
|
||||
if (local_session)
|
||||
{
|
||||
local_stream = local_session->create_stream(LOCAL_PORT, REMOTE_PORT, RTP_FORMAT_GENERIC, flags);
|
||||
}
|
||||
|
||||
uvgrtp::media_stream* remote_stream = nullptr;
|
||||
if (remote_session)
|
||||
{
|
||||
remote_stream = remote_session->create_stream(REMOTE_PORT, LOCAL_PORT, RTP_FORMAT_GENERIC, flags);
|
||||
}
|
||||
|
||||
EXPECT_NE(nullptr, remote_stream);
|
||||
|
||||
if (local_stream)
|
||||
{
|
||||
EXPECT_EQ(RTP_OK, local_stream->get_rtcp()->install_receiver_hook(receiver_hook));
|
||||
EXPECT_EQ(RTP_OK, local_stream->get_rtcp()->install_sdes_hook(sdes_hook));
|
||||
}
|
||||
|
||||
if (remote_stream)
|
||||
{
|
||||
EXPECT_EQ(RTP_OK, remote_stream->get_rtcp()->install_sender_hook(sender_hook));
|
||||
EXPECT_EQ(RTP_OK, remote_stream->get_rtcp()->install_sdes_hook(sdes_hook));
|
||||
}
|
||||
|
||||
std::unique_ptr<uint8_t[]> test_frame = std::unique_ptr<uint8_t[]>(new uint8_t[PAYLOAD_LEN]);
|
||||
memset(test_frame.get(), 'b', PAYLOAD_LEN);
|
||||
send_packets(std::move(test_frame), PAYLOAD_LEN, local_session, local_stream, SEND_TEST_PACKETS, PACKET_INTERVAL_MS, true, RTP_NO_FLAGS);
|
||||
|
||||
|
||||
|
||||
cleanup(ctx, local_session, remote_session, local_stream, remote_stream);
|
||||
std::cout << "Received RRs: " << received1 << ", received SRs: " << received2 << std::endl;
|
||||
EXPECT_TRUE(received1 > 0);
|
||||
|
@ -134,7 +189,7 @@ TEST(RTCPTests, rtcp_app) {
|
|||
EXPECT_TRUE(received1 > 0);
|
||||
}
|
||||
|
||||
TEST(RTCP_reopen_receiver, rtcp) {
|
||||
TEST(RTCPTests, rtcp_reopen) {
|
||||
std::cout << "Starting uvgRTP RTCP reopen receiver test" << std::endl;
|
||||
|
||||
// Creation of RTP stream. See sending example for more details
|
||||
|
@ -367,6 +422,7 @@ TEST(RTCPTests, rtcp_multiplex2)
|
|||
|
||||
}
|
||||
|
||||
|
||||
void m_r_hook1(uvgrtp::frame::rtcp_receiver_report* frame)
|
||||
{
|
||||
//Hook for stream Sender1 ssrc 11
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
constexpr uint16_t SEND_PORT = 9100;
|
||||
constexpr char LOCAL_ADDRESS[] = "127.0.0.1";
|
||||
constexpr char LOCAL_ADDRESS_IP6[] = "::1";
|
||||
constexpr uint16_t RECEIVE_PORT = 9102;
|
||||
|
||||
constexpr int AMOUNT_OF_TEST_PACKETS = 100;
|
||||
|
@ -71,7 +72,7 @@ TEST(FormatTests, h264_single_nal_unit)
|
|||
|
||||
int rtp_flags = RTP_NO_FLAGS;
|
||||
rtp_format_t format = RTP_FORMAT_H264;
|
||||
int test_runs = 5;
|
||||
int test_runs = 2;
|
||||
int size = 8;
|
||||
|
||||
std::cout << "Testing small NAL unit" << std::endl;
|
||||
|
@ -116,6 +117,47 @@ TEST(FormatTests, h264_fragmentation)
|
|||
|
||||
// the default packet limit for RTP is 1458 where 12 bytes are dedicated to RTP header
|
||||
|
||||
std::vector<size_t> test_sizes = std::vector<size_t>(13);
|
||||
std::iota(test_sizes.begin(), test_sizes.end(), 1443);
|
||||
test_sizes.insert(test_sizes.end(), { 1501,
|
||||
1446 * 2 - 1,
|
||||
1446 * 2,
|
||||
1446 * 2 + 1,
|
||||
5000, 7500, 10000, 50000 });
|
||||
|
||||
int rtp_flags = RTP_NO_FLAGS;
|
||||
int nal_type = 5;
|
||||
rtp_format_t format = RTP_FORMAT_H264;
|
||||
int test_runs = 10;
|
||||
|
||||
for (auto& size : test_sizes)
|
||||
{
|
||||
std::unique_ptr<uint8_t[]> intra_frame = create_test_packet(format, nal_type, true, size, rtp_flags);
|
||||
test_packet_size(std::move(intra_frame), test_runs, size, sess, sender, receiver, rtp_flags, RTP_FORMAT_H264);
|
||||
}
|
||||
|
||||
cleanup_ms(sess, sender);
|
||||
cleanup_ms(sess, receiver);
|
||||
cleanup_sess(ctx, sess);
|
||||
}
|
||||
|
||||
TEST(FormatTests, h264_fragmentation_ip6)
|
||||
{
|
||||
std::cout << "Starting IPv6 h264 fragmentation test" << std::endl;
|
||||
uvgrtp::context ctx;
|
||||
uvgrtp::session* sess = ctx.create_session(LOCAL_ADDRESS_IP6);
|
||||
|
||||
uvgrtp::media_stream* sender = nullptr;
|
||||
uvgrtp::media_stream* receiver = nullptr;
|
||||
|
||||
if (sess)
|
||||
{
|
||||
sender = sess->create_stream(SEND_PORT, RECEIVE_PORT, RTP_FORMAT_H264, RCE_NO_FLAGS);
|
||||
receiver = sess->create_stream(RECEIVE_PORT, SEND_PORT, RTP_FORMAT_H264, RCE_NO_FLAGS);
|
||||
}
|
||||
|
||||
// the default packet limit for RTP is 1458 where 12 bytes are dedicated to RTP header
|
||||
|
||||
std::vector<size_t> test_sizes = std::vector<size_t>(13);
|
||||
std::iota(test_sizes.begin(), test_sizes.end(), 1443);
|
||||
test_sizes.insert(test_sizes.end(), { 1501,
|
||||
|
@ -157,7 +199,7 @@ TEST(FormatTests, h265_single_nal_unit)
|
|||
|
||||
int rtp_flags = RTP_NO_FLAGS;
|
||||
rtp_format_t format = RTP_FORMAT_H265;
|
||||
int test_runs = 5;
|
||||
int test_runs = 2;
|
||||
int size = 8;
|
||||
|
||||
std::cout << "Testing small NAL unit" << std::endl;
|
||||
|
@ -206,7 +248,7 @@ TEST(FormatTests, h265_fragmentation)
|
|||
1446 * 2 - 1,
|
||||
1446 * 2,
|
||||
1446 * 2 + 1,
|
||||
5000, 7500, 10000, 25000, 50000 });
|
||||
5000, 7500, 10000, 50000 });
|
||||
|
||||
// the default packet limit for RTP is 1458 where 12 bytes are dedicated to RTP header
|
||||
int rtp_flags = RTP_NO_FLAGS;
|
||||
|
@ -255,6 +297,7 @@ TEST(FormatTests, h265_fps)
|
|||
int nal_type = 5;
|
||||
rtp_format_t format = RTP_FORMAT_H265;
|
||||
int test_runs = 10;
|
||||
test_runs = 2;
|
||||
|
||||
for (auto& size : test_sizes)
|
||||
{
|
||||
|
@ -329,7 +372,7 @@ TEST(FormatTests, h266_single_nal_unit)
|
|||
|
||||
int rtp_flags = RTP_NO_FLAGS;
|
||||
rtp_format_t format = RTP_FORMAT_H266;
|
||||
int test_runs = 5;
|
||||
int test_runs = 2;
|
||||
int size = 8;
|
||||
|
||||
std::cout << "Testing small NAL unit" << std::endl;
|
||||
|
@ -478,13 +521,8 @@ TEST(FormatTests, h264_multiplex)
|
|||
}
|
||||
|
||||
// the default packet limit for RTP is 1458 where 12 bytes are dedicated to RTP header
|
||||
std::vector<size_t> test_sizes = std::vector<size_t>(13);
|
||||
std::iota(test_sizes.begin(), test_sizes.end(), 1443);
|
||||
test_sizes.insert(test_sizes.end(), { 1501,
|
||||
1446 * 2 - 1,
|
||||
1446 * 2,
|
||||
1446 * 2 + 1,
|
||||
5000, 7500, 10000, 25000, 50000 });
|
||||
std::vector<size_t> test_sizes = std::vector<size_t>();
|
||||
test_sizes.insert(test_sizes.end(), { 1400, 50000 });
|
||||
|
||||
int rtp_flags = RTP_NO_FLAGS;
|
||||
int nal_type = 5;
|
||||
|
@ -524,7 +562,7 @@ TEST(FormatTests, v3c_single_nal_unit)
|
|||
|
||||
int rtp_flags = RTP_NO_FLAGS;
|
||||
rtp_format_t format = RTP_FORMAT_ATLAS;
|
||||
int test_runs = 5;
|
||||
int test_runs = 2;
|
||||
int size = 8;
|
||||
|
||||
std::cout << "Testing small NAL unit" << std::endl;
|
||||
|
@ -562,6 +600,7 @@ TEST(FormatTests, v3c_single_nal_unit)
|
|||
cleanup_ms(sess, receiver);
|
||||
cleanup_sess(ctx, sess);
|
||||
}
|
||||
|
||||
TEST(FormatTests, v3c_fragmentation)
|
||||
{
|
||||
std::cout << "Starting V3C fragmentation test" << std::endl;
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
|
||||
// network parameters of example
|
||||
constexpr char SENDER_ADDRESS[] = "127.0.0.1";
|
||||
constexpr char SENDER_ADDRESS_IP6[] = "::1";
|
||||
constexpr uint16_t SENDER_PORT = 9000;
|
||||
|
||||
constexpr char RECEIVER_ADDRESS[] = "127.0.0.1";
|
||||
constexpr char RECEIVER_ADDRESS_IP6[] = "::1";
|
||||
constexpr uint16_t RECEIVER_PORT = 9042;
|
||||
|
||||
constexpr auto EXAMPLE_DURATION_S = std::chrono::seconds(2);
|
||||
|
@ -270,7 +272,7 @@ TEST(EncryptionTests, zrtp_multistream)
|
|||
return;
|
||||
}
|
||||
|
||||
/* Enable SRTP and ZRTP */
|
||||
// Enable SRTP and ZRTP
|
||||
unsigned zrtp_dh_flags = RCE_SRTP | RCE_SRTP_KMNGMNT_ZRTP | RCE_ZRTP_DIFFIE_HELLMAN_MODE;
|
||||
|
||||
// only one of the streams should perform DH
|
||||
|
@ -334,6 +336,82 @@ TEST(EncryptionTests, zrtp_multistream)
|
|||
cleanup_sess(ctx, receiver_session);
|
||||
}
|
||||
|
||||
TEST(EncryptionTests, zrtp_multistream_ip6)
|
||||
{
|
||||
uvgrtp::context ctx;
|
||||
received_packets = 0;
|
||||
|
||||
if (!ctx.crypto_enabled())
|
||||
{
|
||||
std::cout << "Please link crypto to uvgRTP library in order to tests its ZRTP feature!" << std::endl;
|
||||
FAIL();
|
||||
return;
|
||||
}
|
||||
|
||||
// Enable SRTP and ZRTP
|
||||
unsigned zrtp_dh_flags = RCE_SRTP | RCE_SRTP_KMNGMNT_ZRTP | RCE_ZRTP_DIFFIE_HELLMAN_MODE;
|
||||
|
||||
// only one of the streams should perform DH
|
||||
unsigned int zrtp_multistream_flags = RCE_SRTP | RCE_SRTP_KMNGMNT_ZRTP | RCE_ZRTP_MULTISTREAM_MODE;
|
||||
|
||||
uvgrtp::session* sender_session = ctx.create_session(RECEIVER_ADDRESS_IP6, SENDER_ADDRESS_IP6);
|
||||
uvgrtp::session* receiver_session = ctx.create_session(SENDER_ADDRESS_IP6, RECEIVER_ADDRESS_IP6);
|
||||
|
||||
std::unique_ptr<std::thread> sender_thread1 =
|
||||
std::unique_ptr<std::thread>(new std::thread(zrtp_sender_func, sender_session, SENDER_PORT + 2, RECEIVER_PORT + 2, zrtp_dh_flags, false));
|
||||
|
||||
std::unique_ptr<std::thread> receiver_thread1 =
|
||||
std::unique_ptr<std::thread>(new std::thread(zrtp_receive_func, receiver_session, SENDER_PORT + 2, RECEIVER_PORT + 2, zrtp_dh_flags, false));
|
||||
|
||||
std::unique_ptr<std::thread> sender_thread2 =
|
||||
std::unique_ptr<std::thread>(new std::thread(zrtp_sender_func, sender_session, SENDER_PORT + 4, RECEIVER_PORT + 4, zrtp_multistream_flags, false));
|
||||
|
||||
std::unique_ptr<std::thread> receiver_thread2 =
|
||||
std::unique_ptr<std::thread>(new std::thread(zrtp_receive_func, receiver_session, SENDER_PORT + 4, RECEIVER_PORT + 4, zrtp_multistream_flags, false));
|
||||
|
||||
std::unique_ptr<std::thread> sender_thread3 =
|
||||
std::unique_ptr<std::thread>(new std::thread(zrtp_sender_func, sender_session, SENDER_PORT + 6, RECEIVER_PORT + 6, zrtp_multistream_flags, false));
|
||||
|
||||
std::unique_ptr<std::thread> receiver_thread3 =
|
||||
std::unique_ptr<std::thread>(new std::thread(zrtp_receive_func, receiver_session, SENDER_PORT + 6, RECEIVER_PORT + 6, zrtp_multistream_flags, false));
|
||||
|
||||
if (receiver_thread1 && receiver_thread1->joinable())
|
||||
{
|
||||
receiver_thread1->join();
|
||||
}
|
||||
|
||||
if (sender_thread1 && sender_thread1->joinable())
|
||||
{
|
||||
sender_thread1->join();
|
||||
}
|
||||
|
||||
if (sender_thread2 && sender_thread2->joinable())
|
||||
{
|
||||
sender_thread2->join();
|
||||
}
|
||||
|
||||
if (receiver_thread2 && receiver_thread2->joinable())
|
||||
{
|
||||
receiver_thread2->join();
|
||||
}
|
||||
|
||||
if (sender_thread3 && sender_thread3->joinable())
|
||||
{
|
||||
sender_thread3->join();
|
||||
}
|
||||
|
||||
if (receiver_thread3 && receiver_thread3->joinable())
|
||||
{
|
||||
receiver_thread3->join();
|
||||
}
|
||||
|
||||
std::cout << received_packets << " / 30 packets received" << std::endl;
|
||||
EXPECT_TRUE(received_packets > 25);
|
||||
|
||||
cleanup_sess(ctx, sender_session);
|
||||
cleanup_sess(ctx, receiver_session);
|
||||
}
|
||||
|
||||
TEST(EncryptionTests, zrtp_multistream_mux)
|
||||
{
|
||||
std::cout << "Testing ZRTP multiple streams in a single socket" << std::endl;
|
||||
|
|
|
@ -1,564 +0,0 @@
|
|||
#include "test_common.hh"
|
||||
|
||||
#include <numeric>
|
||||
|
||||
|
||||
constexpr char LOCAL_INTERFACE[] = "::1";
|
||||
constexpr uint16_t SEND_PORT = 9300;
|
||||
|
||||
constexpr char REMOTE_ADDRESS[] = "::1";
|
||||
constexpr uint16_t RECEIVE_PORT = 9400;
|
||||
|
||||
constexpr char MULTICAST_ADDRESS[] = "FF02:0:0:0:0:0:0:0";
|
||||
|
||||
// RTCP TEST PARAMETERS
|
||||
constexpr uint16_t PAYLOAD_LEN = 256;
|
||||
constexpr uint16_t FRAME_RATE = 30;
|
||||
constexpr uint32_t EXAMPLE_RUN_TIME_S = 4;
|
||||
constexpr int SEND_TEST_PACKETS = FRAME_RATE * EXAMPLE_RUN_TIME_S;
|
||||
constexpr int PACKET_INTERVAL_MS = 1000 / FRAME_RATE;
|
||||
|
||||
// FORMATS TEST PARAMETERS
|
||||
constexpr int AMOUNT_OF_TEST_PACKETS = 100;
|
||||
|
||||
// ZRTP TEST PARAMETERS
|
||||
constexpr auto EXAMPLE_DURATION_S = std::chrono::seconds(2);
|
||||
// encryption parameters of example
|
||||
enum Key_length { SRTP_128 = 128, SRTP_196 = 196, SRTP_256 = 256 };
|
||||
constexpr int SALT_SIZE = 112;
|
||||
constexpr int SALT_SIZE_BYTES = SALT_SIZE / 8;
|
||||
|
||||
void rtp_receive_hook(void* arg, uvgrtp::frame::rtp_frame* frame);
|
||||
void process_rtp_frame(uvgrtp::frame::rtp_frame* frame);
|
||||
void test_wait(int time_ms, uvgrtp::media_stream* receiver);
|
||||
|
||||
void receiver_hook(uvgrtp::frame::rtcp_receiver_report* frame);
|
||||
void sender_hook(uvgrtp::frame::rtcp_sender_report* frame);
|
||||
void sdes_hook(uvgrtp::frame::rtcp_sdes_packet* frame);
|
||||
void app_hook(uvgrtp::frame::rtcp_app_packet* frame);
|
||||
void cleanup(uvgrtp::context& ctx, uvgrtp::session* local_session, uvgrtp::session* remote_session,
|
||||
uvgrtp::media_stream* send, uvgrtp::media_stream* receive);
|
||||
|
||||
void zrtp_sender_func6(uvgrtp::session* sender_session, int sender_port, int receiver_port, unsigned int flags);
|
||||
void zrtp_receive_func6(uvgrtp::session* receiver_session, int sender_port, int receiver_port, unsigned int flags);
|
||||
|
||||
TEST(RTPTests_ip6, rtp_hook_ip6)
|
||||
{
|
||||
// Tests installing a hook to uvgRTP
|
||||
std::cout << "Starting IPv6 RTP hook test" << std::endl;
|
||||
uvgrtp::context ctx;
|
||||
uvgrtp::session* sess = ctx.create_session(REMOTE_ADDRESS);
|
||||
|
||||
uvgrtp::media_stream* sender = nullptr;
|
||||
uvgrtp::media_stream* receiver = nullptr;
|
||||
|
||||
int flags = RCE_FRAGMENT_GENERIC;
|
||||
if (sess)
|
||||
{
|
||||
sender = sess->create_stream(RECEIVE_PORT, SEND_PORT, RTP_FORMAT_GENERIC, flags);
|
||||
receiver = sess->create_stream(SEND_PORT, RECEIVE_PORT, RTP_FORMAT_GENERIC, flags);
|
||||
}
|
||||
|
||||
int test_packets = 10;
|
||||
std::vector<size_t> sizes = { 1000, 2000 };
|
||||
for (size_t& size : sizes)
|
||||
{
|
||||
std::unique_ptr<uint8_t[]> test_frame = create_test_packet(RTP_FORMAT_GENERIC, 0, false, size, RTP_NO_FLAGS);
|
||||
test_packet_size(std::move(test_frame), test_packets, size, sess, sender, receiver, RTP_NO_FLAGS, RTP_FORMAT_GENERIC);
|
||||
}
|
||||
|
||||
cleanup_ms(sess, sender);
|
||||
cleanup_ms(sess, receiver);
|
||||
cleanup_sess(ctx, sess);
|
||||
}
|
||||
|
||||
TEST(RTPTests_ip6, rtp_copy_ip6)
|
||||
{
|
||||
// Tests installing a hook to uvgRTP
|
||||
std::cout << "Starting IPv6 RTP hook test" << std::endl;
|
||||
uvgrtp::context ctx;
|
||||
uvgrtp::session* sess = ctx.create_session(REMOTE_ADDRESS);
|
||||
|
||||
uvgrtp::media_stream* sender = nullptr;
|
||||
uvgrtp::media_stream* receiver = nullptr;
|
||||
|
||||
int flags = RCE_FRAGMENT_GENERIC;
|
||||
if (sess)
|
||||
{
|
||||
sender = sess->create_stream(RECEIVE_PORT, SEND_PORT, RTP_FORMAT_GENERIC, flags);
|
||||
receiver = sess->create_stream(SEND_PORT, RECEIVE_PORT, RTP_FORMAT_GENERIC, flags);
|
||||
}
|
||||
|
||||
int test_packets = 10;
|
||||
std::vector<size_t> sizes = { 1000, 2000 };
|
||||
for (size_t& size : sizes)
|
||||
{
|
||||
int rtp_flags = RTP_COPY;
|
||||
std::unique_ptr<uint8_t[]> test_frame = create_test_packet(RTP_FORMAT_GENERIC, 0, false, size, rtp_flags);
|
||||
test_packet_size(std::move(test_frame), test_packets, size, sess, sender, receiver, rtp_flags, RTP_FORMAT_GENERIC);
|
||||
}
|
||||
|
||||
cleanup_ms(sess, sender);
|
||||
cleanup_ms(sess, receiver);
|
||||
cleanup_sess(ctx, sess);
|
||||
}
|
||||
|
||||
TEST(RTPTests_ip6, rtp_holepuncher_ip6)
|
||||
{
|
||||
// Tests installing a hook to uvgRTP
|
||||
std::cout << "Starting IPv6 RTP holepuncher test" << std::endl;
|
||||
uvgrtp::context ctx;
|
||||
uvgrtp::session* sess = ctx.create_session(REMOTE_ADDRESS);
|
||||
|
||||
uvgrtp::media_stream* sender = nullptr;
|
||||
uvgrtp::media_stream* receiver = nullptr;
|
||||
|
||||
int flags = RCE_FRAGMENT_GENERIC | RCE_HOLEPUNCH_KEEPALIVE;
|
||||
if (sess)
|
||||
{
|
||||
sender = sess->create_stream(RECEIVE_PORT, SEND_PORT, RTP_FORMAT_GENERIC, flags);
|
||||
receiver = sess->create_stream(SEND_PORT, RECEIVE_PORT, RTP_FORMAT_GENERIC, flags);
|
||||
}
|
||||
|
||||
int test_packets = 10;
|
||||
std::vector<size_t> sizes = { 1000, 2000 };
|
||||
for (size_t& size : sizes)
|
||||
{
|
||||
std::unique_ptr<uint8_t[]> test_frame = create_test_packet(RTP_FORMAT_GENERIC, 0, false, size, RTP_NO_FLAGS);
|
||||
test_packet_size(std::move(test_frame), test_packets, size, sess, sender, receiver, RTP_NO_FLAGS, RTP_FORMAT_GENERIC);
|
||||
}
|
||||
|
||||
cleanup_ms(sess, sender);
|
||||
cleanup_ms(sess, receiver);
|
||||
cleanup_sess(ctx, sess);
|
||||
}
|
||||
|
||||
TEST(RTPTests_ip6, rtp_configuration_ip6)
|
||||
{
|
||||
// Tests installing a hook to uvgRTP
|
||||
std::cout << "Starting IPv6 RTP configuration test" << std::endl;
|
||||
uvgrtp::context ctx;
|
||||
uvgrtp::session* sess = ctx.create_session(REMOTE_ADDRESS);
|
||||
|
||||
uvgrtp::media_stream* sender = nullptr;
|
||||
uvgrtp::media_stream* receiver = nullptr;
|
||||
|
||||
int flags = RCE_FRAGMENT_GENERIC;
|
||||
if (sess)
|
||||
{
|
||||
sender = sess->create_stream(RECEIVE_PORT, SEND_PORT, RTP_FORMAT_GENERIC, flags);
|
||||
receiver = sess->create_stream(SEND_PORT, RECEIVE_PORT, RTP_FORMAT_GENERIC, flags);
|
||||
}
|
||||
|
||||
// here we try to break uvgRTP by calling various configure values
|
||||
if (sender)
|
||||
{
|
||||
sender->configure_ctx(RCC_UDP_SND_BUF_SIZE, 40 * 1000 * 1000);
|
||||
sender->configure_ctx(RCC_UDP_SND_BUF_SIZE, 2 * 1000 * 1000);
|
||||
|
||||
sender->configure_ctx(RCC_DYN_PAYLOAD_TYPE, 8);
|
||||
|
||||
sender->configure_ctx(RCC_MTU_SIZE, 800);
|
||||
|
||||
sender->configure_ctx(RCC_FPS_NUMERATOR, 100);
|
||||
sender->configure_ctx(RCC_FPS_DENOMINATOR, 1);
|
||||
}
|
||||
|
||||
if (receiver)
|
||||
{
|
||||
receiver->configure_ctx(RCC_UDP_RCV_BUF_SIZE, 20 * 1000 * 1000);
|
||||
receiver->configure_ctx(RCC_UDP_RCV_BUF_SIZE, 2 * 1000 * 1000);
|
||||
|
||||
receiver->configure_ctx(RCC_RING_BUFFER_SIZE, 20 * 1000 * 1000);
|
||||
receiver->configure_ctx(RCC_RING_BUFFER_SIZE, 2 * 1000 * 1000);
|
||||
|
||||
receiver->configure_ctx(RCC_PKT_MAX_DELAY, 200);
|
||||
|
||||
receiver->configure_ctx(RCC_DYN_PAYLOAD_TYPE, 8);
|
||||
}
|
||||
|
||||
int test_packets = 10;
|
||||
std::vector<size_t> sizes = { 1000, 2000 };
|
||||
for (size_t& size : sizes)
|
||||
{
|
||||
std::unique_ptr<uint8_t[]> test_frame = create_test_packet(RTP_FORMAT_GENERIC, 0, false, size, RTP_NO_FLAGS);
|
||||
test_packet_size(std::move(test_frame), test_packets, size, sess, sender, receiver, RTP_NO_FLAGS, RTP_FORMAT_GENERIC);
|
||||
}
|
||||
|
||||
cleanup_ms(sess, sender);
|
||||
cleanup_ms(sess, receiver);
|
||||
cleanup_sess(ctx, sess);
|
||||
}
|
||||
|
||||
TEST(RTPTests_ip6, rtp_send_receive_only_flags_ip6)
|
||||
{
|
||||
// Tests installing a hook to uvgRTP
|
||||
std::cout << "Starting IPv6 RTP send_receive_only test" << std::endl;
|
||||
uvgrtp::context ctx;
|
||||
uvgrtp::session* send_sess = ctx.create_session(REMOTE_ADDRESS);
|
||||
uvgrtp::session* receive_sess = ctx.create_session(REMOTE_ADDRESS);
|
||||
|
||||
uvgrtp::media_stream* sender = nullptr;
|
||||
uvgrtp::media_stream* receiver = nullptr;
|
||||
|
||||
int send_flags = RCE_FRAGMENT_GENERIC | RCE_SEND_ONLY;
|
||||
int receive_flags = RCE_FRAGMENT_GENERIC | RCE_RECEIVE_ONLY;
|
||||
if (send_sess)
|
||||
{
|
||||
sender = send_sess->create_stream(RECEIVE_PORT, SEND_PORT, RTP_FORMAT_GENERIC, send_flags);
|
||||
}
|
||||
|
||||
if (receive_sess)
|
||||
{
|
||||
receiver = receive_sess->create_stream(SEND_PORT, RECEIVE_PORT, RTP_FORMAT_GENERIC, receive_flags);
|
||||
}
|
||||
|
||||
int test_packets = 10;
|
||||
std::vector<size_t> sizes = { 1000, 2000 };
|
||||
for (size_t& size : sizes)
|
||||
{
|
||||
std::unique_ptr<uint8_t[]> test_frame = create_test_packet(RTP_FORMAT_GENERIC, 0, false, size, RTP_NO_FLAGS);
|
||||
test_packet_size(std::move(test_frame), test_packets, size, send_sess, sender, receiver, RTP_NO_FLAGS, RTP_FORMAT_GENERIC);
|
||||
}
|
||||
|
||||
cleanup_ms(send_sess, sender);
|
||||
cleanup_ms(receive_sess, receiver);
|
||||
cleanup_sess(ctx, send_sess);
|
||||
cleanup_sess(ctx, receive_sess);
|
||||
}
|
||||
|
||||
TEST(RTCPTests_ip6, rtcp_ip6) {
|
||||
std::cout << "Starting uvgRTP IPv6 RTCP tests" << std::endl;
|
||||
|
||||
// Creation of RTP stream. See sending example for more details
|
||||
uvgrtp::context ctx;
|
||||
uvgrtp::session* local_session = ctx.create_session(REMOTE_ADDRESS, LOCAL_INTERFACE);
|
||||
uvgrtp::session* remote_session = ctx.create_session(LOCAL_INTERFACE, REMOTE_ADDRESS);
|
||||
|
||||
int flags = RCE_RTCP;
|
||||
|
||||
uvgrtp::media_stream* local_stream = nullptr;
|
||||
if (local_session)
|
||||
{
|
||||
local_stream = local_session->create_stream(SEND_PORT, RECEIVE_PORT, RTP_FORMAT_GENERIC, flags);
|
||||
local_stream->configure_ctx(RCC_SESSION_BANDWIDTH, 3000);
|
||||
}
|
||||
|
||||
uvgrtp::media_stream* remote_stream = nullptr;
|
||||
if (remote_session)
|
||||
{
|
||||
remote_stream = remote_session->create_stream(RECEIVE_PORT, SEND_PORT, RTP_FORMAT_GENERIC, flags);
|
||||
remote_stream->configure_ctx(RCC_SESSION_BANDWIDTH, 3000);
|
||||
|
||||
}
|
||||
|
||||
EXPECT_NE(nullptr, remote_stream);
|
||||
|
||||
if (local_stream)
|
||||
{
|
||||
EXPECT_EQ(RTP_OK, local_stream->get_rtcp()->install_receiver_hook(receiver_hook));
|
||||
EXPECT_EQ(RTP_OK, local_stream->get_rtcp()->install_sdes_hook(sdes_hook));
|
||||
}
|
||||
|
||||
if (remote_stream)
|
||||
{
|
||||
EXPECT_EQ(RTP_OK, remote_stream->get_rtcp()->install_sender_hook(sender_hook));
|
||||
EXPECT_EQ(RTP_OK, remote_stream->get_rtcp()->install_sdes_hook(sdes_hook));
|
||||
}
|
||||
|
||||
std::unique_ptr<uint8_t[]> test_frame = std::unique_ptr<uint8_t[]>(new uint8_t[PAYLOAD_LEN]);
|
||||
memset(test_frame.get(), 'b', PAYLOAD_LEN);
|
||||
send_packets(std::move(test_frame), PAYLOAD_LEN, local_session, local_stream, SEND_TEST_PACKETS, PACKET_INTERVAL_MS, true, RTP_NO_FLAGS);
|
||||
|
||||
cleanup(ctx, local_session, remote_session, local_stream, remote_stream);
|
||||
}
|
||||
|
||||
TEST(FormatTests_ip6, h264_fragmentation_ip6)
|
||||
{
|
||||
std::cout << "Starting IPv6 h264 fragmentation test" << std::endl;
|
||||
uvgrtp::context ctx;
|
||||
uvgrtp::session* sess = ctx.create_session(LOCAL_INTERFACE);
|
||||
|
||||
uvgrtp::media_stream* sender = nullptr;
|
||||
uvgrtp::media_stream* receiver = nullptr;
|
||||
|
||||
if (sess)
|
||||
{
|
||||
sender = sess->create_stream(SEND_PORT, RECEIVE_PORT, RTP_FORMAT_H264, RCE_NO_FLAGS);
|
||||
receiver = sess->create_stream(RECEIVE_PORT, SEND_PORT, RTP_FORMAT_H264, RCE_NO_FLAGS);
|
||||
}
|
||||
|
||||
// the default packet limit for RTP is 1458 where 12 bytes are dedicated to RTP header
|
||||
|
||||
std::vector<size_t> test_sizes = std::vector<size_t>(13);
|
||||
std::iota(test_sizes.begin(), test_sizes.end(), 1443);
|
||||
test_sizes.insert(test_sizes.end(), { 1501,
|
||||
1446 * 2 - 1,
|
||||
1446 * 2,
|
||||
1446 * 2 + 1,
|
||||
5000, 7500, 10000, 25000, 50000 });
|
||||
|
||||
int rtp_flags = RTP_NO_FLAGS;
|
||||
int nal_type = 5;
|
||||
rtp_format_t format = RTP_FORMAT_H264;
|
||||
int test_runs = 10;
|
||||
|
||||
for (auto& size : test_sizes)
|
||||
{
|
||||
std::unique_ptr<uint8_t[]> intra_frame = create_test_packet(format, nal_type, true, size, rtp_flags);
|
||||
test_packet_size(std::move(intra_frame), test_runs, size, sess, sender, receiver, rtp_flags, RTP_FORMAT_H264);
|
||||
}
|
||||
|
||||
cleanup_ms(sess, sender);
|
||||
cleanup_ms(sess, receiver);
|
||||
cleanup_sess(ctx, sess);
|
||||
}
|
||||
|
||||
TEST(EncryptionTests_ip6, zrtp_ip6)
|
||||
{
|
||||
uvgrtp::context ctx;
|
||||
|
||||
if (!ctx.crypto_enabled())
|
||||
{
|
||||
std::cout << "Please link crypto to uvgRTP library in order to tests its ZRTP feature!" << std::endl;
|
||||
FAIL();
|
||||
return;
|
||||
}
|
||||
|
||||
uvgrtp::session* sender_session = ctx.create_session(REMOTE_ADDRESS, LOCAL_INTERFACE);
|
||||
uvgrtp::session* receiver_session = ctx.create_session(LOCAL_INTERFACE, REMOTE_ADDRESS);
|
||||
|
||||
unsigned zrtp_flags = RCE_SRTP | RCE_SRTP_KMNGMNT_ZRTP;
|
||||
|
||||
std::unique_ptr<std::thread> sender_thread =
|
||||
std::unique_ptr<std::thread>(new std::thread(zrtp_sender_func6, sender_session, SEND_PORT, RECEIVE_PORT, zrtp_flags));
|
||||
|
||||
std::unique_ptr<std::thread> receiver_thread =
|
||||
std::unique_ptr<std::thread>(new std::thread(zrtp_receive_func6, receiver_session, SEND_PORT, RECEIVE_PORT, zrtp_flags));
|
||||
|
||||
if (sender_thread && sender_thread->joinable())
|
||||
{
|
||||
sender_thread->join();
|
||||
}
|
||||
|
||||
if (receiver_thread && receiver_thread->joinable())
|
||||
{
|
||||
receiver_thread->join();
|
||||
}
|
||||
|
||||
cleanup_sess(ctx, sender_session);
|
||||
cleanup_sess(ctx, receiver_session);
|
||||
}
|
||||
|
||||
TEST(EncryptionTests_ip6, zrtp_authenticate_ip6)
|
||||
{
|
||||
uvgrtp::context ctx;
|
||||
|
||||
if (!ctx.crypto_enabled())
|
||||
{
|
||||
std::cout << "Please link crypto to uvgRTP library in order to tests its ZRTP feature!" << std::endl;
|
||||
FAIL();
|
||||
return;
|
||||
}
|
||||
|
||||
uvgrtp::session* sender_session = ctx.create_session(REMOTE_ADDRESS, LOCAL_INTERFACE);
|
||||
uvgrtp::session* receiver_session = ctx.create_session(LOCAL_INTERFACE, REMOTE_ADDRESS);
|
||||
|
||||
unsigned zrtp_flags = RCE_SRTP | RCE_SRTP_KMNGMNT_ZRTP | RCE_SRTP_AUTHENTICATE_RTP;
|
||||
|
||||
std::unique_ptr<std::thread> sender_thread =
|
||||
std::unique_ptr<std::thread>(new std::thread(zrtp_sender_func6, sender_session, SEND_PORT, RECEIVE_PORT, zrtp_flags));
|
||||
|
||||
std::unique_ptr<std::thread> receiver_thread =
|
||||
std::unique_ptr<std::thread>(new std::thread(zrtp_receive_func6, receiver_session, SEND_PORT, RECEIVE_PORT, zrtp_flags));
|
||||
|
||||
if (sender_thread && sender_thread->joinable())
|
||||
{
|
||||
sender_thread->join();
|
||||
}
|
||||
|
||||
if (receiver_thread && receiver_thread->joinable())
|
||||
{
|
||||
receiver_thread->join();
|
||||
}
|
||||
|
||||
cleanup_sess(ctx, sender_session);
|
||||
cleanup_sess(ctx, receiver_session);
|
||||
}
|
||||
|
||||
TEST(EncryptionTests_ip6, zrtp_multistream_ip6)
|
||||
{
|
||||
uvgrtp::context ctx;
|
||||
|
||||
if (!ctx.crypto_enabled())
|
||||
{
|
||||
std::cout << "Please link crypto to uvgRTP library in order to tests its ZRTP feature!" << std::endl;
|
||||
FAIL();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Enable SRTP and ZRTP */
|
||||
unsigned zrtp_dh_flags = RCE_SRTP | RCE_SRTP_KMNGMNT_ZRTP | RCE_ZRTP_DIFFIE_HELLMAN_MODE;
|
||||
|
||||
// only one of the streams should perform DH
|
||||
unsigned int zrtp_multistream_flags = RCE_SRTP | RCE_SRTP_KMNGMNT_ZRTP | RCE_ZRTP_MULTISTREAM_MODE;
|
||||
|
||||
uvgrtp::session* sender_session = ctx.create_session(REMOTE_ADDRESS, LOCAL_INTERFACE);
|
||||
uvgrtp::session* receiver_session = ctx.create_session(LOCAL_INTERFACE, REMOTE_ADDRESS);
|
||||
|
||||
std::unique_ptr<std::thread> sender_thread1 =
|
||||
std::unique_ptr<std::thread>(new std::thread(zrtp_sender_func6, sender_session, SEND_PORT + 2, RECEIVE_PORT + 2, zrtp_dh_flags));
|
||||
|
||||
std::unique_ptr<std::thread> receiver_thread1 =
|
||||
std::unique_ptr<std::thread>(new std::thread(zrtp_receive_func6, receiver_session, SEND_PORT + 2, RECEIVE_PORT + 2, zrtp_dh_flags));
|
||||
|
||||
std::unique_ptr<std::thread> sender_thread2 =
|
||||
std::unique_ptr<std::thread>(new std::thread(zrtp_sender_func6, sender_session, SEND_PORT + 4, RECEIVE_PORT + 4, zrtp_multistream_flags));
|
||||
|
||||
std::unique_ptr<std::thread> receiver_thread2 =
|
||||
std::unique_ptr<std::thread>(new std::thread(zrtp_receive_func6, receiver_session, SEND_PORT + 4, RECEIVE_PORT + 4, zrtp_multistream_flags));
|
||||
|
||||
if (receiver_thread1 && receiver_thread1->joinable())
|
||||
{
|
||||
receiver_thread1->join();
|
||||
}
|
||||
|
||||
if (sender_thread1 && sender_thread1->joinable())
|
||||
{
|
||||
sender_thread1->join();
|
||||
}
|
||||
|
||||
if (sender_thread2 && sender_thread2->joinable())
|
||||
{
|
||||
sender_thread2->join();
|
||||
}
|
||||
|
||||
if (receiver_thread2 && receiver_thread2->joinable())
|
||||
{
|
||||
receiver_thread2->join();
|
||||
}
|
||||
|
||||
cleanup_sess(ctx, sender_session);
|
||||
cleanup_sess(ctx, receiver_session);
|
||||
}
|
||||
|
||||
void zrtp_sender_func6(uvgrtp::session* sender_session, int sender_port, int receiver_port, unsigned int flags)
|
||||
{
|
||||
std::cout << "Starting ZRTP sender thread" << std::endl;
|
||||
|
||||
/* See sending.cc for more details about create_stream() */
|
||||
uvgrtp::media_stream* send = nullptr;
|
||||
|
||||
if (sender_session)
|
||||
{
|
||||
send = sender_session->create_stream(sender_port, receiver_port, RTP_FORMAT_GENERIC, flags);
|
||||
}
|
||||
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
|
||||
uvgrtp::frame::rtp_frame* frame = nullptr;
|
||||
|
||||
if (send)
|
||||
{
|
||||
int test_packets = 10;
|
||||
size_t packet_size = 1000;
|
||||
int packet_interval_ms = EXAMPLE_DURATION_S.count() * 1000 / test_packets;
|
||||
|
||||
std::unique_ptr<uint8_t[]> test_frame = create_test_packet(RTP_FORMAT_GENERIC, 0, false, packet_size, RTP_NO_FLAGS);
|
||||
send_packets(std::move(test_frame), packet_size, sender_session, send, test_packets, packet_interval_ms, false, RTP_NO_FLAGS);
|
||||
}
|
||||
|
||||
cleanup_ms(sender_session, send);
|
||||
}
|
||||
|
||||
void zrtp_receive_func6(uvgrtp::session* receiver_session, int sender_port, int receiver_port, unsigned int flags)
|
||||
{
|
||||
std::cout << "Starting ZRTP receiver thread" << std::endl;
|
||||
|
||||
/* See sending.cc for more details about create_stream() */
|
||||
uvgrtp::media_stream* recv = nullptr;
|
||||
|
||||
if (receiver_session)
|
||||
{
|
||||
recv = receiver_session->create_stream(receiver_port, sender_port, RTP_FORMAT_GENERIC, flags);
|
||||
}
|
||||
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
|
||||
uvgrtp::frame::rtp_frame* frame = nullptr;
|
||||
|
||||
if (recv)
|
||||
{
|
||||
while (std::chrono::steady_clock::now() - start < EXAMPLE_DURATION_S)
|
||||
{
|
||||
frame = recv->pull_frame(10);
|
||||
if (frame)
|
||||
{
|
||||
process_rtp_frame(frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cleanup_ms(receiver_session, recv);
|
||||
}
|
||||
|
||||
TEST(RTPTests_ip6, rtp_multicast_ip6)
|
||||
{
|
||||
// Tests installing a hook to uvgRTP
|
||||
std::cout << "Starting IPv6 RTP hook test" << std::endl;
|
||||
uvgrtp::context ctx;
|
||||
uvgrtp::session* sess = ctx.create_session(MULTICAST_ADDRESS, MULTICAST_ADDRESS);
|
||||
|
||||
uvgrtp::media_stream* sender = nullptr;
|
||||
uvgrtp::media_stream* receiver = nullptr;
|
||||
|
||||
int flags = RCE_FRAGMENT_GENERIC;
|
||||
if (sess)
|
||||
{
|
||||
sender = sess->create_stream(RECEIVE_PORT, SEND_PORT, RTP_FORMAT_GENERIC, flags);
|
||||
receiver = sess->create_stream(SEND_PORT, RECEIVE_PORT, RTP_FORMAT_GENERIC, flags);
|
||||
}
|
||||
|
||||
int test_packets = 10;
|
||||
std::vector<size_t> sizes = { 1000, 2000 };
|
||||
for (size_t& size : sizes)
|
||||
{
|
||||
std::unique_ptr<uint8_t[]> test_frame = create_test_packet(RTP_FORMAT_GENERIC, 0, false, size, RTP_NO_FLAGS);
|
||||
test_packet_size(std::move(test_frame), test_packets, size, sess, sender, receiver, RTP_NO_FLAGS, RTP_FORMAT_H264);
|
||||
}
|
||||
|
||||
cleanup_ms(sess, sender);
|
||||
cleanup_ms(sess, receiver);
|
||||
cleanup_sess(ctx, sess);
|
||||
}
|
||||
|
||||
TEST(RTPTests_ip6, rtp_multicast_multiple_ip6)
|
||||
{
|
||||
// Tests with a multicast address
|
||||
std::cout << "Starting RTP multicast test" << std::endl;
|
||||
uvgrtp::context ctx;
|
||||
uvgrtp::session* sess = ctx.create_session(MULTICAST_ADDRESS, MULTICAST_ADDRESS);
|
||||
|
||||
EXPECT_NE(nullptr, sess);
|
||||
if (!sess) return;
|
||||
|
||||
int flags = RCE_FRAGMENT_GENERIC;
|
||||
|
||||
auto sender = sess->create_stream(RECEIVE_PORT, SEND_PORT, RTP_FORMAT_GENERIC, flags);
|
||||
std::vector<uvgrtp::media_stream*> receivers = {
|
||||
sess->create_stream(SEND_PORT, RECEIVE_PORT, RTP_FORMAT_GENERIC, flags),
|
||||
sess->create_stream(SEND_PORT, RECEIVE_PORT, RTP_FORMAT_GENERIC, flags)
|
||||
};
|
||||
|
||||
int test_packets = 10;
|
||||
std::vector<size_t> sizes = { 1000, 2000 };
|
||||
for (size_t& size : sizes)
|
||||
{
|
||||
std::unique_ptr<uint8_t[]> test_frame = create_test_packet(RTP_FORMAT_GENERIC, 0, false, size, RTP_NO_FLAGS);
|
||||
test_packet_size(std::move(test_frame), test_packets, size, sess, sender, receivers, RTP_NO_FLAGS, RTP_FORMAT_GENERIC);
|
||||
}
|
||||
|
||||
cleanup_ms(sess, sender);
|
||||
for (auto receiver : receivers) cleanup_ms(sess, receiver);
|
||||
cleanup_sess(ctx, sess);
|
||||
}
|
Loading…
Reference in New Issue