123 #include "include/dialplan_functions.h" 152 memset(buf, 0, buflen);
158 if (!strcasecmp(
args.param,
"peerip")) {
160 }
else if (!strcasecmp(
args.param,
"recvip")) {
162 }
else if (!strcasecmp(
args.param,
"recvport")) {
164 }
else if (!strcasecmp(
args.param,
"from")) {
166 }
else if (!strcasecmp(
args.param,
"uri")) {
168 }
else if (!strcasecmp(
args.param,
"ruri")) {
171 }
else if (!strcasecmp(
args.param,
"useragent")) {
173 }
else if (!strcasecmp(
args.param,
"peername")) {
175 }
else if (!strcasecmp(
args.param,
"t38passthrough")) {
177 }
else if (!strcasecmp(
args.param,
"rtpdest")) {
184 if (!strcasecmp(
args.type,
"audio"))
186 else if (!strcasecmp(
args.type,
"video"))
188 else if (!strcasecmp(
args.type,
"text"))
200 }
else if (!strcasecmp(
args.param,
"rtpsource")) {
207 if (!strcasecmp(
args.type,
"audio"))
209 else if (!strcasecmp(
args.type,
"video"))
211 else if (!strcasecmp(
args.type,
"text"))
230 }
else if (!strcasecmp(
args.param,
"rtpqos")) {
237 if (!strcasecmp(
args.type,
"audio")) {
239 }
else if (!strcasecmp(
args.type,
"video")) {
241 }
else if (!strcasecmp(
args.type,
"text")) {
261 enum { INT, DBL }
type;
267 {
"txcount", INT, { .i4 = &stats.
txcount, }, },
268 {
"rxcount", INT, { .i4 = &stats.
rxcount, }, },
269 {
"txjitter", DBL, { .d8 = &stats.
txjitter, }, },
270 {
"rxjitter", DBL, { .d8 = &stats.
rxjitter, }, },
279 {
"txploss", INT, { .i4 = &stats.
txploss, }, },
280 {
"rxploss", INT, { .i4 = &stats.
rxploss, }, },
289 {
"rtt", DBL, { .d8 = &stats.
rtt, }, },
290 {
"maxrtt", DBL, { .d8 = &stats.
maxrtt, }, },
291 {
"minrtt", DBL, { .d8 = &stats.
minrtt, }, },
292 {
"normdevrtt", DBL, { .d8 = &stats.
normdevrtt, }, },
293 {
"stdevrtt", DBL, { .d8 = &stats.
stdevrtt, }, },
294 {
"local_ssrc", INT, { .i4 = &stats.
local_ssrc, }, },
295 {
"remote_ssrc", INT, { .i4 = &stats.
remote_ssrc, }, },
304 if (!strcasecmp(
args.field, lookup[i].name)) {
305 if (lookup[i].
type == INT) {
306 snprintf(buf, buflen,
"%u", *lookup[i].i4);
308 snprintf(buf, buflen,
"%f", *lookup[i].d8);
316 }
else if (!strcasecmp(
args.param,
"secure_signaling")) {
318 }
else if (!strcasecmp(
args.param,
"secure_media")) {
319 snprintf(buf, buflen,
"%s", p->
srtp ?
"1" :
"");
326 #ifdef TEST_FRAMEWORK 355 memcpy(stats, s,
sizeof(*stats));
377 enum { INT, DBL }
type;
383 {
"txcount", INT, { .i4 = &mine.
txcount, }, },
384 {
"rxcount", INT, { .i4 = &mine.
rxcount, }, },
385 {
"txjitter", DBL, { .d8 = &mine.
txjitter, }, },
386 {
"rxjitter", DBL, { .d8 = &mine.
rxjitter, }, },
395 {
"txploss", INT, { .i4 = &mine.
txploss, }, },
396 {
"rxploss", INT, { .i4 = &mine.
rxploss, }, },
405 {
"rtt", DBL, { .d8 = &mine.
rtt, }, },
406 {
"maxrtt", DBL, { .d8 = &mine.
maxrtt, }, },
407 {
"minrtt", DBL, { .d8 = &mine.
minrtt, }, },
408 {
"normdevrtt", DBL, { .d8 = &mine.
normdevrtt, }, },
409 {
"stdevrtt", DBL, { .d8 = &mine.
stdevrtt, }, },
410 {
"local_ssrc", INT, { .i4 = &mine.
local_ssrc, }, },
411 {
"remote_ssrc", INT, { .i4 = &mine.
remote_ssrc, }, },
417 info->name =
"test_sip_rtpqos";
418 info->category =
"/channels/chan_sip/";
419 info->summary =
"Test retrieval of SIP RTP QOS stats";
421 "Verify values in the RTP instance structure can be accessed through the dialplan.";
449 if (!varstr || !buffer) {
456 ast_str_set(&varstr, 0,
"${CHANNEL(rtpqos,audio,%s)}", lookup[i].name);
457 if (lookup[i].
type == INT) {
460 for (j = 1; j < 25; j++) {
463 snprintf(cmpstr,
sizeof(cmpstr),
"%d", j);
471 double j, cmpdbl = 0.0;
472 for (j = 1.0; j < 10.0; j += 0.3) {
475 if (sscanf(
ast_str_buffer(buffer),
"%lf", &cmpdbl) != 1 || fabs(j - cmpdbl) > .05) {
static char * ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
void sip_dialplan_function_register_tests(void)
SIP test registration.
double local_normdevrxploss
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
#define ast_rtp_engine_register(engine)
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.
double remote_normdevjitter
void * ast_channel_tech_pvt(const struct ast_channel *chan)
#define ast_channel_unref(c)
Decrease channel reference count.
struct ast_rtp_instance * trtp
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
double remote_stdevjitter
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
#define AST_TEST_REGISTER(cb)
const ast_string_field from
void sip_dialplan_function_unregister_tests(void)
SIP test registration.
Socket address structure.
sip global declaration header file
#define ast_strlen_zero(foo)
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
static struct ast_frame * test_sip_rtpqos_1_read(struct ast_rtp_instance *instance, int rtcp)
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized, or having a 0 length.
void dialog_unlink_all(struct sip_pvt *dialog)
Unlink a dialog from the dialogs container, as well as any other places that it may be currently stor...
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
static char * ast_sockaddr_stringify_port(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return a port only.
AST_TEST_DEFINE(test_sip_rtpqos_1)
int ast_ouraddrfor(const struct ast_sockaddr *them, struct ast_sockaddr *us)
Get our local IP address when contacting a remote host.
General Asterisk PBX channel definitions.
int ast_rtp_engine_unregister(struct ast_rtp_engine *engine)
Unregister an RTP engine.
void ast_rtp_instance_set_data(struct ast_rtp_instance *instance, void *data)
Set the data portion of an RTP instance.
#define ast_test_status_update(a, b, c...)
static int test_sip_rtpqos_1_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
#define ast_dummy_channel_alloc()
Create a fake channel structure.
struct sip_request initreq
Access Control of various sorts.
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define sip_alloc(callid, addr, useglobal_nat, intended_method, req, logger_callid)
double local_stdevrxploss
char * ast_rtp_instance_get_quality(struct ast_rtp_instance *instance, enum ast_rtp_instance_stat_field field, char *buf, size_t size)
Retrieve quality statistics about an RTP instance.
Core PBX routines and definitions.
double remote_normdevrxploss
const ast_string_field useragent
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
#define AST_TEST_UNREGISTER(cb)
#define dialog_unref(dialog, tag)
#define ast_rtp_instance_set_remote_address(instance, address)
Set the address of the remote endpoint that we are sending RTP to.
int sip_acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen)
Channel read dialplan function for SIP.
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
struct ast_rtp_instance * vrtp
Structure used for each SIP dialog, ie. a call, a registration, a subscribe. Created and initialized ...
static void parse(struct mgcp_request *req)
void * ast_rtp_instance_get_data(struct ast_rtp_instance *instance)
Get the data portion of an RTP instance.
struct ast_channel * owner
#define dialog_ref(dialog, tag)
when we create or delete references, make sure to use these functions so we keep track of the refcoun...
#define REQ_OFFSET_TO_STR(req, offset)
sip dialog management header file
struct ast_rtp_instance * rtp
const ast_string_field peername
static int test_sip_rtpqos_1_destroy(struct ast_rtp_instance *instance)
static int test_sip_rtpqos_1_new(struct ast_rtp_instance *instance, struct ast_sched_context *sched, struct ast_sockaddr *addr, void *data)
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_frame ast_null_frame
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static int test_sip_rtpqos_1_get_stat(struct ast_rtp_instance *instance, struct ast_rtp_instance_stats *stats, enum ast_rtp_instance_stat stat)
Data structure associated with a single frame of data.
double remote_stdevrxploss
struct ast_channel_tech sip_tech
Definition of this channel for PBX channel registration.
double local_normdevjitter
struct ast_sdp_srtp * srtp
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.
Pluggable RTP Architecture.
#define ast_rtp_instance_get_remote_address(instance, address)
Get the address of the remote endpoint that we are sending RTP to.
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
const ast_string_field uri
struct ast_sockaddr bindaddr
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_MAX_USER_FIELD