Asterisk - The Open Source Telephony Project GIT-master-f36a736
Macros | Functions | Variables
test_abstract_jb.c File Reference

Abstract Jitterbuffer Tests. More...

#include "asterisk.h"
#include "asterisk/utils.h"
#include "asterisk/module.h"
#include "asterisk/test.h"
#include "asterisk/abstract_jb.h"
#include "asterisk/frame.h"
#include "asterisk/format_cache.h"
Include dependency graph for test_abstract_jb.c:

Go to the source code of this file.

Macros

#define DEFAULT_CONFIG_FLAGS   0
 
#define DEFAULT_CONFIG_RESYNC_THRESHOLD   (DEFAULT_FRAME_MS) * 2
 
#define DEFAULT_CONFIG_SIZE   (DEFAULT_FRAME_MS) * 10
 
#define DEFAULT_CONFIG_TARGET_EXTRA   -1
 
#define DEFAULT_FRAME_MS   160
 
#define INT_TEST(actual, expected)
 
#define LONG_INT_TEST(actual, expected)
 
#define MAKE_DEFAULT_CONFIG(conf, impl)
 
#define OBTAIN_JITTERBUFFER_IMPL(impl, ast_jb_type, literal_name)
 
#define STRING_TEST(actual, expected)
 
#define STRINGIFY_TESTNAME(test_name)   TEST_NAME2(test_name)
 
#define test_create_nominal(type_name, literal_type_name)
 
#define TEST_NAME(type_name, specifier)   type_name ## _ ## specifier
 
#define TEST_NAME2(test_name)   #test_name
 
#define test_put(type_name, literal_type_name)
 
#define test_put_first(type_name, literal_type_name)
 
#define test_put_out_of_order(type_name, literal_type_name, synch_limit)
 
#define test_put_overflow(type_name, literal_type_name, overflow_limit)
 
#define UINT_TEST(actual, expected)
 
#define VERIFY_FRAME(actual, expected)
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static struct ast_framecreate_test_frame (long timestamp, int seqno)
 
static void dispose_jitterbuffer (struct ast_jb *jb)
 
static int load_module (void)
 
 test_create_nominal (test_put_first(AST_JB_ADAPTIVE, test_put_first("adaptive")
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Abstract JitterBuffer API Tests" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_jb default_jb
 

Detailed Description

Abstract Jitterbuffer Tests.

Author
Matt Jordan <mjordan@digium.com> 

Tests the abstract jitter buffer API. This tests both adaptive and fixed jitter buffers. Functions defined in abstract_jb that are not part of the abstract jitter buffer API are not tested by this unit test.

Definition in file test_abstract_jb.c.

Macro Definition Documentation

◆ DEFAULT_CONFIG_FLAGS

#define DEFAULT_CONFIG_FLAGS   0

Definition at line 47 of file test_abstract_jb.c.

◆ DEFAULT_CONFIG_RESYNC_THRESHOLD

#define DEFAULT_CONFIG_RESYNC_THRESHOLD   (DEFAULT_FRAME_MS) * 2

Definition at line 49 of file test_abstract_jb.c.

◆ DEFAULT_CONFIG_SIZE

#define DEFAULT_CONFIG_SIZE   (DEFAULT_FRAME_MS) * 10

Definition at line 48 of file test_abstract_jb.c.

◆ DEFAULT_CONFIG_TARGET_EXTRA

#define DEFAULT_CONFIG_TARGET_EXTRA   -1

Definition at line 50 of file test_abstract_jb.c.

◆ DEFAULT_FRAME_MS

#define DEFAULT_FRAME_MS   160

Definition at line 46 of file test_abstract_jb.c.

◆ INT_TEST

#define INT_TEST (   actual,
  expected 
)
Value:
do { \
if ((actual) != (expected)) { \
ast_test_status_update(test, #actual ": expected [%d]; actual [%d]\n", (expected), (actual)); \
return AST_TEST_FAIL; \
} } while (0)
@ AST_TEST_FAIL
Definition: test.h:196

Definition at line 109 of file test_abstract_jb.c.

◆ LONG_INT_TEST

#define LONG_INT_TEST (   actual,
  expected 
)
Value:
do { \
if ((actual) != (expected)) { \
ast_test_status_update(test, #actual ": expected [%ld]; actual [%ld]\n", (long int)(expected), (long int)(actual)); \
return AST_TEST_FAIL; \
} } while (0)

Definition at line 100 of file test_abstract_jb.c.

◆ MAKE_DEFAULT_CONFIG

#define MAKE_DEFAULT_CONFIG (   conf,
  impl 
)

Definition at line 161 of file test_abstract_jb.c.

◆ OBTAIN_JITTERBUFFER_IMPL

#define OBTAIN_JITTERBUFFER_IMPL (   impl,
  ast_jb_type,
  literal_name 
)

Definition at line 147 of file test_abstract_jb.c.

◆ STRING_TEST

#define STRING_TEST (   actual,
  expected 
)
Value:
do { \
if (strcmp((actual), (expected))) { \
ast_test_status_update(test, #actual ": expected [%s]; actual [%s]\n", (expected), (actual)); \
return AST_TEST_FAIL; \
} } while (0)

Definition at line 127 of file test_abstract_jb.c.

◆ STRINGIFY_TESTNAME

#define STRINGIFY_TESTNAME (   test_name)    TEST_NAME2(test_name)

Definition at line 185 of file test_abstract_jb.c.

◆ test_create_nominal

#define test_create_nominal (   type_name,
  literal_type_name 
)

Definition at line 194 of file test_abstract_jb.c.

◆ TEST_NAME

#define TEST_NAME (   type_name,
  specifier 
)    type_name ## _ ## specifier

Definition at line 182 of file test_abstract_jb.c.

◆ TEST_NAME2

#define TEST_NAME2 (   test_name)    #test_name

Definition at line 184 of file test_abstract_jb.c.

◆ test_put

#define test_put (   type_name,
  literal_type_name 
)

Definition at line 292 of file test_abstract_jb.c.

◆ test_put_first

#define test_put_first (   type_name,
  literal_type_name 
)

Definition at line 233 of file test_abstract_jb.c.

◆ test_put_out_of_order

#define test_put_out_of_order (   type_name,
  literal_type_name,
  synch_limit 
)

Definition at line 436 of file test_abstract_jb.c.

◆ test_put_overflow

#define test_put_overflow (   type_name,
  literal_type_name,
  overflow_limit 
)

Definition at line 368 of file test_abstract_jb.c.

◆ UINT_TEST

#define UINT_TEST (   actual,
  expected 
)
Value:
do { \
if ((actual) != (expected)) { \
ast_test_status_update(test, #actual ": expected [%u]; actual [%u]\n", (expected), (actual)); \
return AST_TEST_FAIL; \
} } while (0)

Definition at line 118 of file test_abstract_jb.c.

◆ VERIFY_FRAME

#define VERIFY_FRAME (   actual,
  expected 
)

Definition at line 136 of file test_abstract_jb.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 567 of file test_abstract_jb.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 567 of file test_abstract_jb.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 567 of file test_abstract_jb.c.

◆ create_test_frame()

static struct ast_frame * create_test_frame ( long  timestamp,
int  seqno 
)
static

Definition at line 82 of file test_abstract_jb.c.

84{
85 struct ast_frame f = {0};
86
89 f.src = "TEST";
90 f.ts = timestamp;
92 f.seqno = seqno;
93
94 return ast_frisolate(&f);
95}
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
#define ast_frisolate(fr)
Makes a frame independent of any static storage.
@ AST_FRAME_VOICE
struct ast_format * format
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
enum ast_frame_type frametype
const char * src
#define DEFAULT_FRAME_MS

References ast_format_slin, AST_FRAME_VOICE, ast_frisolate, DEFAULT_FRAME_MS, ast_frame_subclass::format, ast_frame::frametype, ast_frame::len, ast_frame::seqno, ast_frame::src, ast_frame::subclass, and ast_frame::ts.

◆ dispose_jitterbuffer()

static void dispose_jitterbuffer ( struct ast_jb jb)
static

Definition at line 60 of file test_abstract_jb.c.

61{
62 if (!jb || !jb->impl || !jb->jbobj) {
63 return;
64 }
65
66 jb->impl->empty_and_reset(jb->jbobj);
67
68 jb->impl->destroy(jb->jbobj);
69 jb->impl = NULL;
70 jb->jbobj = NULL;
71}
#define NULL
Definition: resample.c:96
jb_destroy_impl destroy
Definition: abstract_jb.h:126
jb_empty_and_reset_impl empty_and_reset
Definition: abstract_jb.h:133
void * jbobj
Jitterbuffer object, passed to the implementation.
Definition: abstract_jb.h:147
const struct ast_jb_impl * impl
Jitterbuffer implementation to be used.
Definition: abstract_jb.h:145

References ast_jb_impl::destroy, ast_jb_impl::empty_and_reset, ast_jb::impl, ast_jb::jbobj, and NULL.

◆ load_module()

static int load_module ( void  )
static

Definition at line 550 of file test_abstract_jb.c.

551{
556 AST_TEST_REGISTER(TEST_NAME(AST_JB_ADAPTIVE, put_out_of_order));
557
562 AST_TEST_REGISTER(TEST_NAME(AST_JB_FIXED, put_out_of_order));
563
565}
@ AST_JB_ADAPTIVE
Definition: abstract_jb.h:53
@ AST_JB_FIXED
Definition: abstract_jb.h:52
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
#define AST_TEST_REGISTER(cb)
Definition: test.h:127
#define TEST_NAME(type_name, specifier)

References AST_JB_ADAPTIVE, AST_JB_FIXED, AST_MODULE_LOAD_SUCCESS, AST_TEST_REGISTER, and TEST_NAME.

◆ test_create_nominal()

test_create_nominal ( test_put_first AST_JB_ADAPTIVE,
test_put_first "adaptive" 
)

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Abstract JitterBuffer API Tests" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static

Definition at line 567 of file test_abstract_jb.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 567 of file test_abstract_jb.c.

◆ default_jb

struct ast_jb default_jb
static
Initial value:
= {
.impl = NULL,
.jbobj = NULL
}

Definition at line 173 of file test_abstract_jb.c.