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);
272 info->name =
"rtp_port_exhaustion";
273 info->category =
"/res/res_rtp/";
274 info->summary =
"RTP port exhaustion without a scheduler";
276 "Exhaust a per-instance RTP port range with no scheduler, as used by "
277 "UnicastRTP. Verify allocation fails safely and succeeds after the "
278 "occupied port is released.";
327 info->name =
"nack_no_packet_loss";
328 info->category =
"/res/res_rtp/";
329 info->summary =
"nack no packet loss unit test";
331 "Tests sending packets with no packet loss and "
332 "validates that the send buffer stores sent packets "
333 "and the receive buffer is empty";
348 ast_test_validate(
test, ast_rtp_instance_get_send_buffer_count(instance1) == 10,
349 "Send buffer did not have the expected count of 10");
351 ast_test_validate(
test, ast_rtp_instance_get_recv_buffer_count(instance2) == 0,
352 "Receive buffer did not have the expected count of 0");
365 info->name =
"nack_nominal";
366 info->category =
"/res/res_rtp/";
367 info->summary =
"nack nominal unit test";
369 "Tests sending packets with some packet loss and "
370 "validates that a NACK request is sent on reaching "
371 "the triggering amount of lost packets";
388 ast_rtp_instance_drop_packets(instance2, 10);
400 ast_test_validate(
test, ast_rtp_instance_get_recv_buffer_count(instance2) == 0,
401 "Receive buffer did not have the expected count of 0");
415 info->name =
"nack_overflow";
416 info->category =
"/res/res_rtp/";
417 info->summary =
"nack overflow unit test";
419 "Tests that when the buffer hits its capacity, we "
420 "queue all the packets we currently have stored";
437 max_packets = ast_rtp_instance_get_recv_buffer_max(instance2);
440 ast_test_validate(
test, ast_rtp_instance_get_recv_buffer_count(instance2) == max_packets,
441 "Receive buffer did not have the expected count of max buffer size");
446 ast_test_validate(
test, ast_rtp_instance_get_recv_buffer_count(instance2) == 0,
447 "Receive buffer did not have the expected count of 0");
462 info->name =
"lost_packet_stats_nominal";
463 info->category =
"/res/res_rtp/";
464 info->summary =
"lost packet stats nominal unit test";
466 "Tests that when some packets are lost, we calculate that "
467 "loss correctly when doing lost packet statistics";
487 ast_rtp_instance_queue_report(instance1);
498 ast_rtp_instance_queue_report(instance1);
509 ast_rtp_instance_queue_report(instance1);
521 ast_rtp_instance_queue_report(instance1);
542 .remb.br_mantissa = 1000,
547 .data.ptr = &feedback,
548 .datalen =
sizeof(feedback),
554 info->name =
"remb_nominal";
555 info->category =
"/res/res_rtp/";
556 info->summary =
"remb nominal unit test";
558 "Tests sending and receiving a REMB packet";
572 ast_rtp_instance_set_schedid(instance1, 0);
578 ast_test_validate(
test, frame_in !=
NULL,
"Did not receive a REMB frame");
580 "REMB frame did not have the expected frametype");
582 "REMB frame did not have the expected subclass integer");
585 received_feedback = frame_in->data.ptr;
587 "REMB frame did not have the expected feedback format");
589 "REMB received exponent did not match sent exponent");
591 "REMB received mantissa did not match sent mantissa");
605 info->name =
"sr_rr_nominal";
606 info->category =
"/res/res_rtp/";
607 info->summary =
"SR/RR nominal unit test";
609 "Tests sending SR/RR and receiving it; includes SDES";
628 ast_rtp_instance_queue_report(instance1);
633 "Sender report frame did not have the expected frametype");
635 "Sender report frame did not have the expected subclass integer");
636 ast_test_validate(
test, ast_rtp_instance_get_sdes_received(instance2) == 1,
637 "SDES was never processed for sender report");
642 ast_rtp_instance_queue_report(instance1);
647 "Receiver report frame did not have the expected frametype");
649 "Receiver report frame did not have the expected subclass integer");
667 info->name =
"fir_nominal";
668 info->category =
"/res/res_rtp/";
669 info->summary =
"fir nominal unit test";
671 "Tests sending and receiving a FIR packet";
688 ast_rtp_instance_set_schedid(instance1, 0);
703 ast_test_validate(
test, frame_in !=
NULL,
"Did not receive a FIR frame");
705 "FIR frame did not have the expected frametype");
707 "FIR frame did not have the expected subclass integer");
725 info->category =
"/res/res_rtp/";
726 info->summary =
"Media Experience Score";
728 "Tests calculation of Media Experience Score (only run by explicit request)";
729 info->explicit_only = 1;
745 instance1, instance2, 1000, 5000);
756 int offered_initialized = 0;
757 int active_initialized = 0;
761 info->name =
"payload_merge_abandoned_offer";
762 info->category =
"/res/res_rtp/";
763 info->summary =
"Verify mappings retained after an uncommitted payload merge";
765 "Characterizes the state left behind when an SDP offer's payloads "
766 "are merged into an active RTP mapping but no later copy commits "
767 "or rolls back that offer.";
778 offered_initialized = 1;
784 active_initialized = 1;
788 &active,
NULL, 96,
"audio",
"PCMU", 0)
790 &offered,
NULL, 97,
"audio",
"PCMA", 0)) {
817 if (active_initialized) {
820 if (offered_initialized) {
832 int offered_initialized = 0;
833 int active_initialized = 0;
837 info->name =
"payload_merge_preserves_preferences";
838 info->category =
"/res/res_rtp/";
839 info->summary =
"Verify a payload merge preserves active preferences";
841 "Verifies that merging an SDP offer's provisional payload mappings "
842 "updates framing needed to generate the SDP answer without changing "
843 "the active preferred format or preferred DTMF metadata before the "
844 "offer is committed.";
855 offered_initialized = 1;
861 active_initialized = 1;
881 "Payload merge changed the active preferred DTMF metadata\n");
890 if (active_initialized) {
893 if (offered_initialized) {
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
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
static void cleanup(void)
Clean up any old apps that we don't need any more.
Pluggable RTP Architecture.
#define AST_RTP_RTCP_PSFB
void ast_rtp_codecs_payloads_destroy(struct ast_rtp_codecs *codecs)
Destroy the contents of an RTP codecs structure (but not the structure itself)
int ast_rtp_instance_destroy(struct ast_rtp_instance *instance)
Destroy an RTP instance.
struct ast_format * ast_rtp_codecs_get_preferred_format(struct ast_rtp_codecs *codecs)
Retrieve rx preferred format.
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.
struct ast_rtp_payload_type * ast_rtp_codecs_get_payload(struct ast_rtp_codecs *codecs, int payload)
Retrieve rx payload mapped information by payload type.
@ 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_codecs_set_framing(struct ast_rtp_codecs *codecs, unsigned int framing)
Set the framing used for a set of codecs.
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.
int ast_rtp_codecs_get_preferred_dtmf_format_rate(struct ast_rtp_codecs *codecs)
Retrieve rx preferred dtmf format sample rate.
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.
struct ast_rtp_instance * ast_rtp_instance_new_with_options(const char *engine_name, struct ast_sched_context *sched, const struct ast_sockaddr *sa, void *data, const struct ast_rtp_instance_options *options)
Create a new RTP instance with additional options.
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
void ast_rtp_codecs_payloads_merge(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance)
Merge payload information from one RTP instance into another.
int ast_rtp_codecs_payloads_initialize(struct ast_rtp_codecs *codecs)
Initialize an RTP codecs structure.
@ 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.
int ast_rtp_codecs_payloads_set_rtpmap_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload, char *mimetype, char *mimesubtype, enum ast_rtp_options options)
Record tx payload type information that was seen in an a=rtpmap: SDP line.
void ast_rtp_instance_set_channel_id(struct ast_rtp_instance *instance, const char *uniqueid)
Set the channel that owns this RTP instance.
int ast_rtp_codecs_set_preferred_dtmf_format(struct ast_rtp_codecs *codecs, int pt, int rate)
Set the preferred dtmf format pt and sample rate.
#define AST_RTP_CODECS_NULL_INIT
int ast_rtp_codecs_get_preferred_dtmf_format_pt(struct ast_rtp_codecs *codecs)
Retrieve rx preferred dtmf format payload type.
unsigned int ast_rtp_codecs_get_framing(struct ast_rtp_codecs *codecs)
Get the framing used for a set of codecs.
void ast_rtp_codecs_payloads_xover(struct ast_rtp_codecs *src, struct ast_rtp_codecs *dest, struct ast_rtp_instance *instance)
Crossover copy the tx payload mapping of src to the rx payload mapping of dest.
int ast_rtp_codecs_set_preferred_format(struct ast_rtp_codecs *codecs, struct ast_format *format)
Set the preferred format.
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.
enum ast_frame_type frametype
union ast_frame::@237 data
Options for creating a new RTP instance.
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_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
#define AST_TEST_DEFINE(hdr)
static void SLEEP_SPINNER(int ms)
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)