Asterisk - The Open Source Telephony Project  18.5.0
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 <[email protected]> 

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.

Referenced by create_test_frame().

◆ 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)

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.

Referenced by load_module(), and test_create_nominal().

◆ 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 426 of file test_abstract_jb.c.

◆ test_put_overflow

#define test_put_overflow (   type_name,
  literal_type_name,
  overflow_limit 
)

Definition at line 358 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 548 of file test_abstract_jb.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 548 of file test_abstract_jb.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 548 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.

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.

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_frame_subclass subclass
const char * src
#define DEFAULT_FRAME_MS
#define ast_frisolate(fr)
Makes a frame independent of any static storage.
Data structure associated with a single frame of data.
enum ast_frame_type frametype
struct ast_format * format
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41

◆ dispose_jitterbuffer()

static void dispose_jitterbuffer ( struct ast_jb jb)
static

Definition at line 60 of file test_abstract_jb.c.

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

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 }
const struct ast_jb_impl * impl
Jitterbuffer implementation to be used.
Definition: abstract_jb.h:145
jb_destroy_impl destroy
Definition: abstract_jb.h:126
#define NULL
Definition: resample.c:96
void * jbobj
Jitterbuffer object, passed to the implementation.
Definition: abstract_jb.h:147
jb_empty_and_reset_impl empty_and_reset
Definition: abstract_jb.h:133

◆ load_module()

static int load_module ( void  )
static

Definition at line 531 of file test_abstract_jb.c.

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

532 {
537  AST_TEST_REGISTER(TEST_NAME(AST_JB_ADAPTIVE, put_out_of_order));
538 
542  AST_TEST_REGISTER(TEST_NAME(AST_JB_FIXED, put_overflow));
543  AST_TEST_REGISTER(TEST_NAME(AST_JB_FIXED, put_out_of_order));
544 
546 }
#define AST_TEST_REGISTER(cb)
Definition: test.h:127
#define TEST_NAME(type_name, specifier)

◆ test_create_nominal()

test_create_nominal ( test_put_first AST_JB_ADAPTIVE,
test_put_first "adaptive" 
)

Definition at line 494 of file test_abstract_jb.c.

References AST_TEST_UNREGISTER, and TEST_NAME.

515 {
520  AST_TEST_UNREGISTER(TEST_NAME(AST_JB_ADAPTIVE, put_out_of_order));
521 
526  AST_TEST_UNREGISTER(TEST_NAME(AST_JB_FIXED, put_out_of_order));
527 
528  return 0;
529 }
#define TEST_NAME(type_name, specifier)
#define AST_TEST_UNREGISTER(cb)
Definition: test.h:128

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 548 of file test_abstract_jb.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 548 of file test_abstract_jb.c.

◆ default_jb

struct ast_jb default_jb
static
Initial value:
= {
.impl = NULL,
.jbobj = NULL
}
#define NULL
Definition: resample.c:96

Definition at line 173 of file test_abstract_jb.c.