69 if (!instance1 || !instance2) {
101 ast_rtp_instance_reset_test_engine(*instance1);
122 for (index = 0; index < num; index++) {
133 for (index = 0; index < num; index++) {
175 int pktinterval = 20;
205 num = howlong / pktinterval;
207 rtcpnum = rtcp_interval / pktinterval;
214 for (index = 0; index < num; index++) {
224 frame_out1.
seqno += index;
226 frame_out1.
ts += frame_out1.
len;
229 if (send_rtcp && index && (index % rtcpnum == 0)) {
230 ast_rtp_instance_queue_report(instance1);
239 frame_out2.
seqno += index;
241 frame_out2.
ts += frame_out2.
len;
244 if (send_rtcp && index && (index % rtcpnum == 0)) {
245 ast_rtp_instance_queue_report(instance2);
256 ms += (index % 2 ? 5 : 12);
257 ms += (index % 3 ? 2 : 30);
270 info->name =
"nack_no_packet_loss";
271 info->category =
"/res/res_rtp/";
272 info->summary =
"nack no packet loss unit test";
274 "Tests sending packets with no packet loss and "
275 "validates that the send buffer stores sent packets "
276 "and the receive buffer is empty";
291 ast_test_validate(
test, ast_rtp_instance_get_send_buffer_count(instance1) == 10,
292 "Send buffer did not have the expected count of 10");
294 ast_test_validate(
test, ast_rtp_instance_get_recv_buffer_count(instance2) == 0,
295 "Receive buffer did not have the expected count of 0");
308 info->name =
"nack_nominal";
309 info->category =
"/res/res_rtp/";
310 info->summary =
"nack nominal unit test";
312 "Tests sending packets with some packet loss and "
313 "validates that a NACK request is sent on reaching "
314 "the triggering amount of lost packets";
331 ast_rtp_instance_drop_packets(instance2, 10);
343 ast_test_validate(
test, ast_rtp_instance_get_recv_buffer_count(instance2) == 0,
344 "Receive buffer did not have the expected count of 0");
358 info->name =
"nack_overflow";
359 info->category =
"/res/res_rtp/";
360 info->summary =
"nack overflow unit test";
362 "Tests that when the buffer hits its capacity, we "
363 "queue all the packets we currently have stored";
380 max_packets = ast_rtp_instance_get_recv_buffer_max(instance2);
383 ast_test_validate(
test, ast_rtp_instance_get_recv_buffer_count(instance2) == max_packets,
384 "Receive buffer did not have the expected count of max buffer size");
389 ast_test_validate(
test, ast_rtp_instance_get_recv_buffer_count(instance2) == 0,
390 "Receive buffer did not have the expected count of 0");
405 info->name =
"lost_packet_stats_nominal";
406 info->category =
"/res/res_rtp/";
407 info->summary =
"lost packet stats nominal unit test";
409 "Tests that when some packets are lost, we calculate that "
410 "loss correctly when doing lost packet statistics";
430 ast_rtp_instance_queue_report(instance1);
441 ast_rtp_instance_queue_report(instance1);
452 ast_rtp_instance_queue_report(instance1);
464 ast_rtp_instance_queue_report(instance1);
485 .remb.br_mantissa = 1000,
490 .data.ptr = &feedback,
491 .datalen =
sizeof(feedback),
497 info->name =
"remb_nominal";
498 info->category =
"/res/res_rtp/";
499 info->summary =
"remb nominal unit test";
501 "Tests sending and receiving a REMB packet";
515 ast_rtp_instance_set_schedid(instance1, 0);
521 ast_test_validate(
test, frame_in !=
NULL,
"Did not receive a REMB frame");
523 "REMB frame did not have the expected frametype");
525 "REMB frame did not have the expected subclass integer");
528 received_feedback = frame_in->data.ptr;
530 "REMB frame did not have the expected feedback format");
532 "REMB received exponent did not match sent exponent");
534 "REMB received mantissa did not match sent mantissa");
548 info->name =
"sr_rr_nominal";
549 info->category =
"/res/res_rtp/";
550 info->summary =
"SR/RR nominal unit test";
552 "Tests sending SR/RR and receiving it; includes SDES";
571 ast_rtp_instance_queue_report(instance1);
576 "Sender report frame did not have the expected frametype");
578 "Sender report frame did not have the expected subclass integer");
579 ast_test_validate(
test, ast_rtp_instance_get_sdes_received(instance2) == 1,
580 "SDES was never processed for sender report");
585 ast_rtp_instance_queue_report(instance1);
590 "Receiver report frame did not have the expected frametype");
592 "Receiver report frame did not have the expected subclass integer");
610 info->name =
"fir_nominal";
611 info->category =
"/res/res_rtp/";
612 info->summary =
"fir nominal unit test";
614 "Tests sending and receiving a FIR packet";
631 ast_rtp_instance_set_schedid(instance1, 0);
646 ast_test_validate(
test, frame_in !=
NULL,
"Did not receive a FIR frame");
648 "FIR frame did not have the expected frametype");
650 "FIR frame did not have the expected subclass integer");
668 info->category =
"/res/res_rtp/";
669 info->summary =
"Media Experience Score";
671 "Tests calculation of Media Experience Score (only run by explicit request)";
672 info->explicit_only = 1;
688 instance1, instance2, 1000, 5000);
Asterisk main include file. File version handling, generic pbx functions.
@ AST_FRFLAG_HAS_SEQUENCE_NUMBER
@ AST_FRFLAG_HAS_TIMING_INFO
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
Pluggable RTP Architecture.
#define AST_RTP_RTCP_PSFB
int ast_rtp_instance_destroy(struct ast_rtp_instance *instance)
Destroy an RTP instance.
struct ast_rtp_instance * ast_rtp_instance_new(const char *engine_name, struct ast_sched_context *sched, const struct ast_sockaddr *sa, void *data)
Create a new RTP instance.
@ AST_RTP_INSTANCE_RTCP_MUX
@ AST_RTP_INSTANCE_RTCP_STANDARD
@ AST_RTP_INSTANCE_STAT_ALL
struct ast_frame * ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp)
Receive a frame over RTP.
void ast_rtp_instance_set_prop(struct ast_rtp_instance *instance, enum ast_rtp_property property, int value)
Set the value of an RTP instance property.
void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the local address that we are expecting RTP on.
int ast_rtp_instance_get_stats(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat)
Retrieve statistics about an RTP instance.
int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
Send a frame out over RTP.
#define ast_rtp_instance_set_remote_address(instance, address)
Set the address of the remote endpoint that we are sending RTP to.
#define AST_RTP_RTCP_FMT_REMB
@ AST_RTP_PROPERTY_RETRANS_RECV
@ AST_RTP_PROPERTY_RETRANS_SEND
int ast_rtp_instance_activate(struct ast_rtp_instance *instance)
Indicate to the RTP engine that packets are now expected to be sent/received on the RTP instance.
void ast_rtp_instance_set_channel_id(struct ast_rtp_instance *instance, const char *uniqueid)
Set the channel that owns this RTP instance.
Scheduler Routines (derived from cheops)
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
int ast_sched_start_thread(struct ast_sched_context *con)
Start a thread for processing scheduler entries.
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
Data structure associated with a single frame of data.
union ast_frame::@226 data
enum ast_frame_type frametype
An object that represents data received in a feedback report.
struct ast_rtp_rtcp_feedback_remb remb
Socket address structure.
#define AST_TEST_REGISTER(cb)
#define AST_TEST_UNREGISTER(cb)
static void SLEEP_SPINNER(int ms)
AST_TEST_DEFINE(nack_no_packet_loss)
static void test_write_and_read_interleaved_frames(struct ast_rtp_instance *instance1, struct ast_rtp_instance *instance2, int howlong, int rtcp_interval)
static int test_init_rtp_instances(struct ast_rtp_instance **instance1, struct ast_rtp_instance **instance2, struct ast_sched_context *test_sched, enum test_type type)
static void test_read_frames(struct ast_rtp_instance *instance, int num)
static void ast_sched_context_destroy_wrapper(struct ast_sched_context *sched)
static int load_module(void)
static void test_write_and_read_frames(struct ast_rtp_instance *instance1, struct ast_rtp_instance *instance2, int seqno, int num)
static int unload_module(void)
static void test_write_frames(struct ast_rtp_instance *instance, int seqno, int num)
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_clear_flag(p, flag)
#define ast_set_flag(p, flag)