43 #define TEST_CATEGORY "/main/bridging/" 45 #define CHANNEL_TECH_NAME "BridgingTestChannel" 47 #define TEST_CHANNEL_FORMAT ast_format_slin 83 .description =
"Mock channel technology for bridge tests",
91 struct timespec sleep_time = {secs, nanosecs};
93 while ((nanosleep(&sleep_time, &sleep_time) == -1) && (
errno == EINTR)) {
134 #define START_ALICE(channel, pvt) START_CHANNEL(channel, pvt, "Alice", "100") 137 #define START_BOB(channel, pvt) START_CHANNEL(channel, pvt, "Bob", "200") 139 #define START_CHANNEL(channel, pvt, name, number) do { \ 140 channel = ast_channel_alloc(0, AST_STATE_UP, number, name, number, number, \ 141 "default", NULL, NULL, 0, CHANNEL_TECH_NAME "/" name); \ 142 pvt = ast_calloc(1, sizeof(*pvt)); \ 143 ast_channel_tech_pvt_set(channel, pvt); \ 144 ast_channel_nativeformats_set(channel, test_bridging_chan_tech.capabilities); \ 145 ast_channel_set_rawwriteformat(channel, TEST_CHANNEL_FORMAT); \ 146 ast_channel_set_rawreadformat(channel, TEST_CHANNEL_FORMAT); \ 147 ast_channel_set_writeformat(channel, TEST_CHANNEL_FORMAT); \ 148 ast_channel_set_readformat(channel, TEST_CHANNEL_FORMAT); \ 149 ast_channel_unlock(channel); \ 153 #define HANGUP_CHANNEL(channel) do { \ 154 ao2_ref(channel, +1); \ 155 ast_hangup((channel)); \ 156 ao2_cleanup(channel); \ 184 nanosecs = interval_ms * 1000000L;
188 if (interval_ms < ms) {
191 nanosecs = ms * 1000000L;
208 .data.ptr = &t38_parameters,
209 .datalen =
sizeof(t38_parameters),
217 info->name = __func__;
219 info->summary =
"Test that deferred frames from a channel in a bridge get written";
221 "This test creates two channels, queues a deferrable frame on one, places it into\n" 222 "a bridge, confirms the frame was read by the bridge, adds the second channel to the\n" 223 "bridge, and makes sure the deferred frame is written to it.";
231 ast_test_validate(
test, bridge1 !=
NULL);
#define ast_channel_lock(chan)
Main Channel structure associated with a channel.
static int load_module(void)
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk main include file. File version handling, generic pbx functions.
static void stream_periodic_frames(struct ast_channel *chan, int ms, int interval_ms)
void * ast_channel_tech_pvt(const struct ast_channel *chan)
Time-related functions and macros.
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
#define START_ALICE(channel, pvt)
Create a test_bridging_chan_tech for Alice.
A private structure for the test channel.
struct ast_channel * ast_channel_release(struct ast_channel *chan)
Unlink and release reference to a channel.
static void wait_for_unbridged(struct ast_channel *channel)
Wait until a channel is not bridged.
enum ast_control_t38 request_response
#define AST_TEST_REGISTER(cb)
int ast_bridge_destroy(struct ast_bridge *bridge, int cause)
Destroy a bridge.
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
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 ...
static void safe_bridge_destroy(struct ast_bridge *bridge)
unsigned int indicated
The number of indicated things.
static void wait_for_bridged(struct ast_channel *channel)
Wait until a channel is bridged.
struct ast_readq_list * ast_channel_readq(struct ast_channel *chan)
#define CHANNEL_TECH_NAME
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)
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.
Channels with this particular technology are an implementation detail of Asterisk and should generall...
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.
AST_TEST_DEFINE(test_bridging_deferred_queue)
#define HANGUP_CHANNEL(channel)
Hang up a test channel safely.
Structure that contains information about a bridge.
#define TEST_CHANNEL_FORMAT
static int unload_module(void)
#define AST_TEST_UNREGISTER(cb)
static void wait_for_empty_queue(struct ast_channel *channel)
Wait until a channel has no frames on its read queue.
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.
#define ast_channel_unlock(chan)
static void safe_channel_release(struct ast_channel *chan)
Module has failed to load, may be in an inconsistent state.
Basic bridge subclass API.
static int test_bridging_chan_indicate(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Callback function for when a frame is written to a channel.
struct ast_frame ast_null_frame
static void test_nanosleep(int secs, long nanosecs)
struct ast_bridge * ast_bridge_basic_new(void)
Create a new basic class bridge.
static struct ast_channel_tech test_bridging_chan_tech
A channel technology used for the unit tests.
Data structure associated with a single frame of data.
enum ast_frame_type frametype
Call Parking and Pickup API Includes code and algorithms from the Zapata library. ...
#define START_BOB(channel, pvt)
Create a test_bridging_chan_tech for Bob.
#define ASTERISK_GPL_KEY
The text the key() function should return.
static int test_bridging_chan_hangup(struct ast_channel *chan)
Callback function for when a channel is hung up.
Asterisk module definitions.
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)