136 static const char tdesc[] =
"Local Proxy Channel Driver";
175 .description =
tdesc,
319 opts = strchr(exten,
'/');
324 context = strchr(exten,
'@');
327 "Someone used Local/%s somewhere without a @context. This is bad.\n", data);
335 if (!strcmp(exten, lp->
exten)
336 && !strcmp(context, lp->
context)) {
353 ast_debug(3,
"Checking if extension %s@%s exists (devicestate)\n", exten, context);
370 if (!local_one_snapshot) {
375 if (!local_two_snapshot) {
417 if (!source_snapshot) {
476 if (!local_snapshot_one || !local_snapshot_two) {
483 if (!event_buffer || !local_channel_one || !local_channel_two) {
490 const char *dest_uniqueid;
493 if (source_snapshot) {
503 event =
"LocalOptimizationBegin";
507 ast_str_append(&event_buffer, 0,
"DestUniqueId: %s\r\n", dest_uniqueid);
510 event =
"LocalOptimizationEnd";
514 event =
"LocalBridge";
606 if (!ast || !bridge) {
687 const char *chan_cid;
706 if (!owner || !chan) {
718 if ((slash = strrchr(reduced_dest,
'/'))) {
739 ast_log(
LOG_NOTICE,
"No such extension/context %s@%s while calling Local channel\n",
850 switch (doomed->
type) {
892 if ((opts = strchr(parse,
'/'))) {
894 if (strchr(opts,
'n')) {
897 if (strchr(opts,
'j')) {
901 ast_log(
LOG_ERROR,
"You must use the 'n' option with the 'j' option to enable the jitter buffer\n");
904 if (strchr(opts,
'm')) {
910 if ((context = strchr(parse,
'@'))) {
952 if (!audio_filtered_topology) {
980 ao2_ref(audio_filtered_topology, -1);
988 &tmp_fmt, &best_audio_fmt);
993 ast_log(
LOG_WARNING,
"No translator path exists for channel type %s (native %s) to %s\n", type,
999 ao2_ref(audio_filtered_topology, -1);
1013 ao2_ref(audio_filtered_topology, -1);
1037 e->
command =
"local show channels";
1039 "Usage: local show channels\n" 1040 " Provides summary information on active local proxy channels.\n";
1051 ast_cli(a->
fd,
"No local channels in use\n");
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
Struct containing info for an AMI event to send out.
#define ast_channel_lock(chan)
static char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
Local proxy channel special access.
#define AST_CLI_DEFINE(fn, txt,...)
struct ast_channel_snapshot_base * base
static int manager_optimize_away(struct mansession *s, const struct message *m)
Asterisk main include file. File version handling, generic pbx functions.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
static void local_optimization_finished_cb(struct ast_unreal_pvt *base, int success, unsigned int id)
Callback for ast_unreal_pvt_callbacks optimization_finished_cb.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
static int locals_cmp_cb(void *obj, void *arg, int flags)
char context[AST_MAX_CONTEXT]
Structure that contains features information.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
void * ast_channel_tech_pvt(const struct ast_channel *chan)
#define ast_channel_unref(c)
Decrease channel reference count.
#define ast_test_flag(p, flag)
Support for translation of data formats. translate.c.
struct ast_channel * ast_local_get_peer(struct ast_channel *ast)
Get the other local channel in the pair.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
struct ast_unreal_pvt_callbacks * callbacks
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
enum ast_media_type ast_stream_get_type(const struct ast_stream *stream)
Get the media type of a stream.
#define ast_set_flag(p, flag)
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
descriptor for a cli entry.
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
AST_JSON_INT_T ast_json_int_t
Primarily used to cast when packing to an "I" type.
static const char tdesc[]
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
struct ast_channel * owner
int ast_unreal_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen)
int ast_json_is_true(const struct ast_json *value)
Check if value is JSON true.
Structure representing a snapshot of channel state.
static struct ast_multi_channel_blob * local_channel_optimization_blob(struct local_pvt *p, struct ast_json *json_object)
#define AST_UNREAL_NO_OPTIMIZATION
Set when the stream has been removed/declined.
struct ast_str * ast_manager_build_channel_state_string_prefix(const struct ast_channel_snapshot *snapshot, const char *prefix)
Generate the AMI message body from a channel snapshot.
struct ast_jb_conf jb_conf
#define STASIS_MESSAGE_TYPE_CLEANUP(name)
Boiler-plate messaging macro for cleaning up message types.
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
Structure to pass both assignedid values to channel drivers.
struct ast_channel * swap
const ast_string_field uniqueid
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
#define AST_UNREAL_CARETAKER_THREAD
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
struct ast_stream_topology * ast_stream_topology_create_from_format_cap(struct ast_format_cap *cap)
A helper function that, given a format capabilities structure, creates a topology and separates the m...
void astman_send_ack(struct mansession *s, const struct message *m, char *msg)
Send ack in manager transaction.
#define AST_OPTION_SECURE_MEDIA
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_str_alloca(init_len)
static int local_hangup(struct ast_channel *ast)
Hangup a call through the local proxy channel.
struct ast_channel * ast_unreal_new_channels(struct ast_unreal_pvt *p, const struct ast_channel_tech *tech, int semi1_state, int semi2_state, const char *exten, const char *context, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, ast_callid callid)
Create the semi1 and semi2 unreal channels.
struct ast_stream * ast_stream_topology_get_stream(const struct ast_stream_topology *topology, unsigned int position)
Get a specific stream from the topology.
int ast_unreal_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
int ast_channel_move(struct ast_channel *dest, struct ast_channel *source)
Move a channel from its current location to a new location.
#define ast_manager_register_xml_core(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
void ast_cli(int fd, const char *fmt,...)
void ast_stream_set_formats(struct ast_stream *stream, struct ast_format_cap *caps)
Set the current negotiated formats of a stream.
void ast_bridge_features_destroy(struct ast_bridge_features *features)
Destroy an allocated bridge features struct.
struct ast_manager_event_blob * ast_manager_event_blob_create(int event_flags, const char *manager_event, const char *extra_fields_fmt,...)
Construct a ast_manager_event_blob.
struct ast_json * ast_multi_channel_blob_get_json(struct ast_multi_channel_blob *obj)
Retrieve the JSON blob from a ast_multi_channel_blob. Returned ast_json is still owned by obj...
int ast_translator_best_choice(struct ast_format_cap *dst_cap, struct ast_format_cap *src_cap, struct ast_format **dst_fmt_out, struct ast_format **src_fmt_out)
Chooses the best translation path.
ast_callid ast_read_threadstorage_callid(void)
extracts the callerid from the thread
static void local_optimization_started_cb(struct ast_unreal_pvt *base, struct ast_channel *source, enum ast_unreal_channel_indicator dest, unsigned int id)
Callback for ast_unreal_pvt_callbacks optimization_started_cb.
const char * astman_get_header(const struct message *m, char *var)
Get header from mananger transaction.
#define ast_strlen_zero(foo)
static struct ast_channel * local_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
Part of PBX interface.
int ast_unreal_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
static struct ast_cli_entry cli_local[]
#define AST_UNREAL_MOH_INTERCEPT
struct ast_json * ast_json_null(void)
Get the JSON null value.
int ast_local_init(void)
Initialize the local proxy channel.
int ast_local_setup_bridge(struct ast_channel *ast, struct ast_bridge *bridge, struct ast_channel *swap, struct ast_bridge_features *features)
Setup the outgoing local channel to join a bridge on ast_call().
#define EVENT_FLAG_SYSTEM
#define ast_debug(level,...)
Log a DEBUG message.
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.
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
struct ast_unreal_pvt base
void(*const optimization_started)(struct ast_unreal_pvt *p, struct ast_channel *source, enum ast_unreal_channel_indicator dest, unsigned int id)
Called when an optimization attempt has started.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
void ast_unreal_destructor(void *vdoomed)
struct ast_unreal_pvt destructor.
static char * locals_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command "local show channels".
void ast_multi_channel_blob_add_channel(struct ast_multi_channel_blob *obj, const char *role, struct ast_channel_snapshot *snapshot)
Add a ast_channel_snapshot to a ast_multi_channel_blob object.
struct ast_bridge_features * features
#define AST_MAX_EXTENSION
#define ao2_ref(o, delta)
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
In case you didn't read that giant block of text above the mansession_session struct, the struct mansession is named this solely to keep the API the same in Asterisk. This structure really represents data that is different from Manager action to Manager action. The mansession_session pointer contained within points to session-specific data.
#define ast_strdupa(s)
duplicate a string in memory from the stack
int ast_unreal_setoption(struct ast_channel *chan, int option, void *data, int datalen)
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
static struct ast_channel * local_request_with_stream_topology(const char *type, struct ast_stream_topology *topology, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
Part of PBX interface.
const struct ast_format_cap * ast_stream_get_formats(const struct ast_stream *stream)
Get the current negotiated formats of a stream.
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Core PBX routines and definitions.
struct ast_channel * chan
const char * ast_channel_uniqueid(const struct ast_channel *chan)
struct stasis_topic * ast_channel_topic(struct ast_channel *chan)
A topic which publishes the events for a particular channel.
void ast_unreal_call_setup(struct ast_channel *semi1, struct ast_channel *semi2)
Setup unreal owner and chan channels before initiating call.
struct ast_unreal_pvt_callbacks local_unreal_callbacks
Callbacks from the unreal core when channel optimization occurs.
struct stasis_message_type * ast_local_optimization_end_type(void)
Message type for when a local channel optimization completes.
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
enum local_call_action type
static void publish_local_bridge_message(struct local_pvt *p)
Structure that contains information about a bridge.
int ast_unreal_write(struct ast_channel *ast, struct ast_frame *f)
void ast_local_unlock_all(void *tech_pvt, struct ast_channel *base_chan, struct ast_channel *base_owner)
Remove a reference to the given local channel's private tech, unlock the given local channel's privat...
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
int ast_unreal_digit_begin(struct ast_channel *ast, char digit)
static struct ast_channel_tech local_tech
#define ao2_unlink(container, obj)
union local_pvt::@376 action
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
char name[AST_MAX_EXTENSION+AST_MAX_CONTEXT+2]
The base pvt structure for local channel derivatives.
STASIS_MESSAGE_TYPE_DEFN(ast_local_bridge_type,.to_ami=local_message_to_ami,)
Define local channel message types.
#define ao2_iterator_next(iter)
int ast_unreal_write_stream(struct ast_channel *ast, int stream_num, struct ast_frame *f)
struct ast_format_cap * capabilities
int ast_unreal_digit_end(struct ast_channel *ast, char digit, unsigned int duration)
#define ast_channel_unlock(chan)
static void parse(struct mgcp_request *req)
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
#define AST_OPTION_SECURE_SIGNALING
static int local_devicestate(const char *data)
Adds devicestate to local channels.
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
static struct local_pvt * local_alloc(const char *data, struct ast_stream_topology *topology)
Create a call structure.
static void to_ami(struct ast_sip_subscription *sub, struct ast_str **buf)
struct ast_frame * ast_unreal_read(struct ast_channel *ast)
int ast_local_setup_masquerade(struct ast_channel *ast, struct ast_channel *masq)
Setup the outgoing local channel to masquerade into a channel on ast_call().
Prototypes for public functions only of internal interest,.
ast_unreal_channel_indicator
#define ao2_find(container, arg, flags)
int ast_stream_topology_get_count(const struct ast_stream_topology *topology)
Get the number of streams in a topology.
struct stasis_message_type * ast_local_bridge_type(void)
Message type for when two local channel halves are bridged together.
#define ast_clear_flag(p, flag)
static struct ast_manager_event_blob * local_message_to_ami(struct stasis_message *msg)
struct ast_stream_topology * ast_stream_topology_clone(const struct ast_stream_topology *topology)
Create a deep clone of an existing stream topology.
static int local_call(struct ast_channel *ast, const char *dest, int timeout)
Initiate new call, part of PBX interface dest is the dial string.
struct stasis_message_type * ast_local_optimization_begin_type(void)
Message type for when a local channel optimization begins.
void ast_local_lock_all(struct ast_channel *chan, void **tech_pvt, struct ast_channel **base_chan, struct ast_channel **base_owner)
Add a reference to the local channel's private tech, lock the local channel's private base...
int ast_unreal_queryoption(struct ast_channel *ast, int option, void *data, int *datalen)
#define ast_channel_ref(c)
Increase channel reference count.
struct ast_channel_snapshot * ast_channel_snapshot_get_latest(const char *uniqueid)
Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object...
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
the local pvt structure for all channels
Standard Command Line Interface.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
int ast_unreal_answer(struct ast_channel *ast)
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_channel_snapshot * ast_multi_channel_blob_get_channel(struct ast_multi_channel_blob *obj, const char *role)
Retrieve a channel snapshot associated with a specific role from a ast_multi_channel_blob.
struct ast_unreal_pvt * ast_unreal_alloc_stream_topology(size_t size, ao2_destructor_fn destructor, struct ast_stream_topology *topology)
Allocate the base unreal struct for a derivative.
A multi channel blob data structure for multi_channel_blob stasis messages.
static void local_pvt_destructor(void *vdoomed)
int ast_answer(struct ast_channel *chan)
Answer a channel.
char exten[AST_MAX_EXTENSION]
Abstract JSON element (object, array, string, int, ...).
struct ast_channel * masq
static char context[AST_MAX_CONTEXT]
static struct ao2_container * locals
void ast_stream_topology_free(struct ast_stream_topology *topology)
Unreference and destroy a stream topology.
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
void astman_send_error(struct mansession *s, const struct message *m, char *error)
Send error in manager transaction.
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
Callbacks that can be provided by concrete implementations of the unreal channel driver that will be ...
static int local_setoption(struct ast_channel *chan, int option, void *data, int datalen)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
struct local_bridge bridge
int ast_unreal_hangup(struct ast_unreal_pvt *p, struct ast_channel *ast)
Hangup one end (maybe both ends) of an unreal channel derivative.
enum ast_stream_state ast_stream_get_state(const struct ast_stream *stream)
Get the current state of a stream.
struct ast_multi_channel_blob * ast_multi_channel_blob_create(struct ast_json *blob)
Create a ast_multi_channel_blob suitable for a stasis_message.
void ast_unreal_lock_all(struct ast_unreal_pvt *p, struct ast_channel **outchan, struct ast_channel **outowner)
Send an unreal pvt in with no locks held and get all locks.
int ast_set_cc_interfaces_chanvar(struct ast_channel *chan, const char *const extension)
Set the CC_INTERFACES channel variable for a channel using an.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
static void local_shutdown(void)
int ast_unreal_sendtext(struct ast_channel *ast, const char *text)
#define ao2_link(container, obj)
Unreal channel derivative framework.