43#define TEST_CATEGORY "/channels/features/" 
   45#define CHANNEL_TECH_NAME "FeaturesTestChannel" 
   47#define TEST_BACKEND_NAME "Features Test Logging" 
   49#define TEST_CHANNEL_FORMAT     ast_format_slin 
   54    .description = 
"Mock channel technology for Features tests",
 
 
   59    struct timespec sleep_time = {secs, nanosecs};
 
   61    while ((nanosleep(&sleep_time, &sleep_time) == -1) && (
errno == EINTR)) {
 
 
   90#define START_ALICE(channel) START_CHANNEL(channel, "Alice", "100") 
   93#define START_BOB(channel) START_CHANNEL(channel, "Bob", "200") 
   95#define START_CHANNEL(channel, name, number) do { \ 
   96    channel = ast_channel_alloc(0, AST_STATE_UP, number, name, number, number, \ 
   97        "default", NULL, NULL, 0, CHANNEL_TECH_NAME "/" name); \ 
   98    ast_channel_nativeformats_set(channel, test_features_chan_tech.capabilities); \ 
   99    ast_channel_set_rawwriteformat(channel, TEST_CHANNEL_FORMAT); \ 
  100    ast_channel_set_rawreadformat(channel, TEST_CHANNEL_FORMAT); \ 
  101    ast_channel_set_writeformat(channel, TEST_CHANNEL_FORMAT); \ 
  102    ast_channel_set_readformat(channel, TEST_CHANNEL_FORMAT); \ 
  103    ast_channel_unlock(channel); \ 
 
  107#define HANGUP_CHANNEL(channel) do { \ 
  108    ao2_ref(channel, +1); \ 
  109    ast_hangup((channel)); \ 
  110    ao2_cleanup(channel); \ 
 
  132    int *callback_executed = obj;
 
  133    (*callback_executed)++;
 
 
  146    nanosecs = interval_ms * 1000000L;
 
  150        if (interval_ms < ms) {
 
  153            nanosecs = ms * 1000000L;
 
 
  167    int callback_executed = 0;
 
  172        info->name = __func__;
 
  174        info->summary = 
"Test running DTMF hooks on a channel via the feature hooks mechanism";
 
  176            "This test creates two channels, adds a DTMF hook to one, places them into\n" 
  177            "a bridge, and verifies that the DTMF hook added to the channel feature\n" 
  178            "hooks can be triggered once the channel is bridged.";
 
  186    ast_test_validate(
test, bridge1 != 
NULL);
 
  188    ast_test_validate(
test, bridge2 != 
NULL);
 
  248    ast_test_validate(
test, callback_executed == 2);
 
 
  260    int callback_executed = 0;
 
  264        info->name = __func__;
 
  266        info->summary = 
"Test running interval hooks on a channel via the feature hooks mechanism";
 
  268            "This test creates two channels, adds an interval hook to one, places them\n" 
  269            "into a bridge, and verifies that the interval hook added to the channel\n" 
  270            "feature hooks is triggered once the channel is bridged.";
 
  278    ast_test_validate(
test, bridge1 != 
NULL);
 
  280    ast_test_validate(
test, bridge2 != 
NULL);
 
  307    ast_test_validate(
test, callback_executed >= 1);
 
  308    callback_executed = 0;
 
  327    ast_test_validate(
test, callback_executed >= 1);
 
 
Asterisk main include file. File version handling, generic pbx functions.
int ast_bridge_depart(struct ast_channel *chan)
Depart a channel from a bridge.
int ast_bridge_destroy(struct ast_bridge *bridge, int cause)
Destroy a bridge.
int ast_bridge_impart(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, enum ast_bridge_impart_flags flags) attribute_warn_unused_result
Impart a channel to a bridge (non-blocking)
@ AST_BRIDGE_IMPART_CHAN_DEPARTABLE
Basic bridge subclass API.
struct ast_bridge * ast_bridge_basic_new(void)
Create a new basic class bridge.
int ast_bridge_features_init(struct ast_bridge_features *features)
Initialize bridge features structure.
int ast_bridge_interval_hook(struct ast_bridge_features *features, enum ast_bridge_hook_timer_option flags, unsigned int interval, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
Attach an interval hook to a bridge features structure.
int ast_bridge_dtmf_hook(struct ast_bridge_features *features, const char *dtmf, ast_bridge_hook_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
Attach a DTMF hook to a bridge features structure.
void ast_bridge_features_cleanup(struct ast_bridge_features *features)
Clean up the contents of a bridge features structure.
General Asterisk PBX channel definitions.
#define ast_channel_lock(chan)
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
int ast_channel_feature_hooks_append(struct ast_channel *chan, struct ast_bridge_features *features)
Appends to the channel-attached features a channel has access to upon being bridged.
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
#define ast_channel_unlock(chan)
Call Parking and Pickup API Includes code and algorithms from the Zapata library.
struct ast_frame ast_null_frame
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
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Structure that contains information regarding a channel in a bridge.
Structure that contains features information.
Structure that contains information about a bridge.
Structure to describe a channel "technology", ie a channel driver See for examples:
struct ast_format_cap * capabilities
Main Channel structure associated with a channel.
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
#define AST_TEST_REGISTER(cb)
#define AST_TEST_UNREGISTER(cb)
#define AST_TEST_DEFINE(hdr)
#define START_ALICE(channel)
Create a test_features_chan_tech for Alice.
#define TEST_CHANNEL_FORMAT
#define START_BOB(channel)
Create a test_features_chan_tech for Bob.
static struct ast_channel_tech test_features_chan_tech
A channel technology used for the unit tests.
static void safe_bridge_destroy(struct ast_bridge *bridge)
#define CHANNEL_TECH_NAME
static int feature_callback(struct ast_bridge_channel *bridge_channel, void *obj)
static void safe_channel_release(struct ast_channel *chan)
static void wait_for_unbridged(struct ast_channel *channel)
Wait until a channel is not bridged.
static void test_nanosleep(int secs, long nanosecs)
static int load_module(void)
static int unload_module(void)
static void wait_for_bridged(struct ast_channel *channel)
Wait until a channel is bridged.
#define HANGUP_CHANNEL(channel)
Hang up a test channel safely.
static void stream_periodic_frames(struct ast_channel *chan, int ms, int interval_ms)
Time-related functions and macros.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.