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);
#define ast_channel_lock(chan)
Main Channel structure associated with a channel.
void ast_bridge_features_cleanup(struct ast_bridge_features *features)
Clean up the contents of a bridge features structure.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
static void safe_channel_release(struct ast_channel *chan)
static int feature_callback(struct ast_bridge_channel *bridge_channel, void *obj)
Structure that contains features information.
Time-related functions and macros.
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
int ast_bridge_features_init(struct ast_bridge_features *features)
Initialize bridge features structure.
static void wait_for_bridged(struct ast_channel *channel)
Wait until a channel is bridged.
#define AST_TEST_REGISTER(cb)
int ast_bridge_destroy(struct ast_bridge *bridge, int cause)
Destroy a bridge.
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 ...
struct ast_frame_subclass subclass
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)
static void test_nanosleep(int secs, long nanosecs)
General Asterisk PBX channel definitions.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
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.
Structure to describe a channel "technology", ie a channel driver See for examples: ...
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
static int unload_module(void)
Structure that contains information about a bridge.
#define AST_TEST_UNREGISTER(cb)
int ast_bridge_depart(struct ast_channel *chan)
Depart a channel from a bridge.
struct ast_format_cap * capabilities
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
static void safe_bridge_destroy(struct ast_bridge *bridge)
#define ast_channel_unlock(chan)
static void wait_for_unbridged(struct ast_channel *channel)
Wait until a channel is not bridged.
Module has failed to load, may be in an inconsistent state.
Basic bridge subclass API.
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.
struct ast_frame ast_null_frame
struct ast_bridge * ast_bridge_basic_new(void)
Create a new basic class bridge.
Structure that contains information regarding a channel in a bridge.
#define START_BOB(channel)
Create a test_features_chan_tech for Bob.
#define CHANNEL_TECH_NAME
static struct ast_channel_tech test_features_chan_tech
A channel technology used for the unit tests.
Data structure associated with a single frame of data.
AST_TEST_DEFINE(test_features_channel_dtmf)
Call Parking and Pickup API Includes code and algorithms from the Zapata library. ...
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.
#define START_ALICE(channel)
Create a test_features_chan_tech for Alice.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define HANGUP_CHANNEL(channel)
Hang up a test channel safely.
#define TEST_CHANNEL_FORMAT
static int load_module(void)
static void stream_periodic_frames(struct ast_channel *chan, int ms, int interval_ms)