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);
699 int offered_initialized = 0;
700 int active_initialized = 0;
704 info->name =
"payload_merge_abandoned_offer";
705 info->category =
"/res/res_rtp/";
706 info->summary =
"Verify mappings retained after an uncommitted payload merge";
708 "Characterizes the state left behind when an SDP offer's payloads "
709 "are merged into an active RTP mapping but no later copy commits "
710 "or rolls back that offer.";
721 offered_initialized = 1;
727 active_initialized = 1;
731 &active,
NULL, 96,
"audio",
"PCMU", 0)
733 &offered,
NULL, 97,
"audio",
"PCMA", 0)) {
760 if (active_initialized) {
763 if (offered_initialized) {
775 int offered_initialized = 0;
776 int active_initialized = 0;
780 info->name =
"payload_merge_preserves_preferences";
781 info->category =
"/res/res_rtp/";
782 info->summary =
"Verify a payload merge preserves active preferences";
784 "Verifies that merging an SDP offer's provisional payload mappings "
785 "updates framing needed to generate the SDP answer without changing "
786 "the active preferred format or preferred DTMF metadata before the "
787 "offer is committed.";
798 offered_initialized = 1;
804 active_initialized = 1;
824 "Payload merge changed the active preferred DTMF metadata\n");
833 if (active_initialized) {
836 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
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.
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
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)