Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Local proxy channel driver. More...
#include "asterisk.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/cli.h"
#include "asterisk/manager.h"
#include "asterisk/devicestate.h"
#include "asterisk/astobj2.h"
#include "asterisk/bridge.h"
#include "asterisk/core_unreal.h"
#include "asterisk/core_local.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/_private.h"
#include "asterisk/stream.h"
#include "asterisk/translate.h"
Go to the source code of this file.
Data Structures | |
struct | local_bridge |
struct | local_pvt |
the local pvt structure for all channels More... | |
Enumerations | |
enum | local_call_action { LOCAL_CALL_ACTION_DIALPLAN , LOCAL_CALL_ACTION_BRIDGE , LOCAL_CALL_ACTION_MASQUERADE } |
Functions | |
struct ast_channel * | ast_local_get_peer (struct ast_channel *ast) |
Get the other local channel in the pair. More... | |
int | ast_local_init (void) |
Initialize the local proxy channel. More... | |
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, and add references and lock both sides of the local channel. More... | |
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(). More... | |
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(). More... | |
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 private base, and remove references and unlock both sides of given the local channel. More... | |
static struct local_pvt * | local_alloc (const char *data, struct ast_stream_topology *topology) |
Create a call structure. More... | |
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. More... | |
static struct ast_multi_channel_blob * | local_channel_optimization_blob (struct local_pvt *p, struct ast_json *json_object) |
static int | local_devicestate (const char *data) |
Adds devicestate to local channels. More... | |
static int | local_hangup (struct ast_channel *ast) |
Hangup a call through the local proxy channel. More... | |
static struct ast_manager_event_blob * | local_message_to_ami (struct stasis_message *msg) |
static void | local_optimization_finished_cb (struct ast_unreal_pvt *base, int success, unsigned int id) |
Callback for ast_unreal_pvt_callbacks optimization_finished . More... | |
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 . More... | |
static void | local_pvt_destructor (void *vdoomed) |
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. More... | |
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. More... | |
static int | local_setoption (struct ast_channel *chan, int option, void *data, int datalen) |
static void | local_shutdown (void) |
static int | locals_cmp_cb (void *obj, void *arg, int flags) |
static char * | locals_show (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
CLI command "local show channels". More... | |
static int | manager_optimize_away (struct mansession *s, const struct message *m) |
static void | publish_local_bridge_message (struct local_pvt *p) |
STASIS_MESSAGE_TYPE_DEFN (ast_local_bridge_type,.to_ami=local_message_to_ami,) | |
Define local channel message types. More... | |
STASIS_MESSAGE_TYPE_DEFN (ast_local_optimization_begin_type,.to_ami=local_message_to_ami,) | |
STASIS_MESSAGE_TYPE_DEFN (ast_local_optimization_end_type,.to_ami=local_message_to_ami,) | |
Variables | |
static struct ast_cli_entry | cli_local [] |
static struct ast_channel_tech | local_tech |
struct ast_unreal_pvt_callbacks | local_unreal_callbacks |
Callbacks from the unreal core when channel optimization occurs. More... | |
static struct ao2_container * | locals |
static const char | tdesc [] = "Local Proxy Channel Driver" |
enum local_call_action |
What to do with the ;2 channel when ast_call() happens.
Enumerator | |
---|---|
LOCAL_CALL_ACTION_DIALPLAN | |
LOCAL_CALL_ACTION_BRIDGE | |
LOCAL_CALL_ACTION_MASQUERADE |
Definition at line 197 of file core_local.c.
struct ast_channel * ast_local_get_peer | ( | struct ast_channel * | ast | ) |
Get the other local channel in the pair.
ast | Local channel to get peer. |
peer | reffed on success. |
NULL | if no peer or error. |
Definition at line 276 of file core_local.c.
References ao2_find, ao2_lock, ao2_ref, ao2_unlock, ast_channel_ref, ast_channel_tech_pvt(), local_pvt::base, ast_unreal_pvt::chan, locals, NULL, and ast_unreal_pvt::owner.
Referenced by ari_channels_handle_originate_with_id(), bridge_channel_internal_join(), and park_local_transfer().
int ast_local_init | ( | void | ) |
Initialize the local proxy channel.
0 | on success. |
-1 | on error. |
Definition at line 1139 of file core_local.c.
References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_list, ARRAY_LEN, ast_channel_register(), ast_cli_register_multiple, ast_format_cap_alloc, ast_format_cap_append_by_type(), AST_FORMAT_CAP_FLAG_DEFAULT, ast_local_bridge_type(), ast_local_optimization_begin_type(), ast_local_optimization_end_type(), ast_log, ast_manager_register_xml_core, AST_MEDIA_TYPE_UNKNOWN, ast_register_cleanup(), ast_channel_tech::capabilities, cli_local, EVENT_FLAG_CALL, EVENT_FLAG_SYSTEM, local_shutdown(), local_tech, locals, locals_cmp_cb(), LOG_ERROR, manager_optimize_away(), NULL, and STASIS_MESSAGE_TYPE_INIT.
Referenced by asterisk_daemon().
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, and add references and lock both sides of the local channel.
chan | Must be a local channel | |
[out] | tech_pvt | channel's private tech (ref and lock added) |
[out] | base_chan | One side of the local channel (ref and lock added) |
[out] | base_owner | Other side of the local channel (ref and lock added) |
Definition at line 241 of file core_local.c.
References ao2_bump, ast_channel_tech_pvt(), ast_unreal_lock_all(), local_pvt::base, and NULL.
Referenced by attended_transfer_bridge().
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().
ast | Either channel of a local channel pair. |
bridge | Bridge to join. |
swap | Channel to swap with when joining. |
features | Bridge features structure. |
0 | on success. |
-1 | on error. |
Definition at line 601 of file core_local.c.
References local_pvt::action, ao2_find, ao2_lock, ao2_ref, ao2_unlock, ast_bridge_features_destroy(), ast_channel_lock, ast_channel_ref, ast_channel_tech_pvt(), ast_channel_unlock, ast_test_flag, AST_UNREAL_CARETAKER_THREAD, local_pvt::base, local_pvt::bridge, ast_unreal_pvt::chan, local_bridge::features, local_bridge::join, LOCAL_CALL_ACTION_BRIDGE, LOCAL_CALL_ACTION_DIALPLAN, locals, NULL, ast_unreal_pvt::owner, local_bridge::swap, and local_pvt::type.
Referenced by attended_transfer_bridge().
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().
ast | Either channel of a local channel pair. |
masq | Channel to masquerade into. |
0 | on success. |
-1 | on error. |
Definition at line 643 of file core_local.c.
References local_pvt::action, ao2_find, ao2_lock, ao2_ref, ao2_unlock, ast_channel_lock, ast_channel_ref, ast_channel_tech_pvt(), ast_channel_unlock, ast_test_flag, AST_UNREAL_CARETAKER_THREAD, local_pvt::base, ast_unreal_pvt::chan, LOCAL_CALL_ACTION_DIALPLAN, LOCAL_CALL_ACTION_MASQUERADE, locals, local_pvt::masq, NULL, ast_unreal_pvt::owner, and local_pvt::type.
Referenced by attended_transfer_bridge().
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 private base, and remove references and unlock both sides of given the local channel.
tech_pvt | channel's private tech (ref and lock removed) |
base_chan | One side of the local channel (ref and lock removed) |
base_owner | Other side of the local channel (ref and lock removed) |
Definition at line 256 of file core_local.c.
References ao2_ref, ao2_unlock, ast_channel_unlock, ast_channel_unref, and local_pvt::base.
Referenced by attended_transfer_bridge().
|
static |
Create a call structure.
Definition at line 866 of file core_local.c.
References ast_clear_flag, ast_copy_string(), AST_JB_ENABLED, ast_log, ast_set_flag, ast_strdupa, ast_test_flag, ast_unreal_alloc_stream_topology(), AST_UNREAL_MOH_INTERCEPT, AST_UNREAL_NO_OPTIMIZATION, local_pvt::base, ast_unreal_pvt::callbacks, voicemailpwcheck::context, local_pvt::context, local_pvt::exten, ast_unreal_pvt::jb_conf, local_pvt_destructor(), local_unreal_callbacks, LOG_ERROR, ast_unreal_pvt::name, NULL, and S_OR.
Referenced by local_request_with_stream_topology().
|
static |
Initiate new call, part of PBX interface dest is the dial string.
Definition at line 679 of file core_local.c.
References local_pvt::action, ao2_cleanup, ao2_lock, ao2_ref, ao2_unlock, ast_answer(), ast_bridge_impart(), AST_BRIDGE_IMPART_CHAN_INDEPENDENT, ast_channel_caller(), ast_channel_lock, ast_channel_move(), ast_channel_tech_pvt(), ast_channel_unlock, ast_channel_unref, ast_exists_extension(), ast_hangup(), ast_log, ast_pbx_start(), ast_set_cc_interfaces_chanvar(), ast_set_flag, ast_strdupa, ast_unreal_call_setup(), AST_UNREAL_CARETAKER_THREAD, ast_unreal_lock_all(), local_pvt::base, local_pvt::bridge, local_pvt::context, local_pvt::exten, local_bridge::features, local_bridge::join, LOCAL_CALL_ACTION_BRIDGE, LOCAL_CALL_ACTION_DIALPLAN, LOCAL_CALL_ACTION_MASQUERADE, LOG_NOTICE, local_pvt::masq, NULL, publish_local_bridge_message(), S_COR, local_bridge::swap, and local_pvt::type.
|
static |
Definition at line 366 of file core_local.c.
References ao2_cleanup, ast_channel_snapshot_get_latest(), ast_channel_uniqueid(), ast_multi_channel_blob_add_channel(), ast_multi_channel_blob_create(), local_pvt::base, ast_unreal_pvt::chan, NULL, ast_unreal_pvt::owner, and RAII_VAR.
Referenced by local_optimization_finished_cb(), and local_optimization_started_cb().
|
static |
Adds devicestate to local channels.
Definition at line 308 of file core_local.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock, ao2_ref, ao2_unlock, ast_debug, AST_DEVICE_INUSE, AST_DEVICE_INVALID, AST_DEVICE_NOT_INUSE, ast_exists_extension(), ast_log, ast_strdupa, ast_test_flag, AST_UNREAL_CARETAKER_THREAD, local_pvt::base, voicemailpwcheck::context, local_pvt::context, ast_channel::data, ast_channel::exten, local_pvt::exten, locals, LOG_WARNING, NULL, and ast_unreal_pvt::owner.
|
static |
Hangup a call through the local proxy channel.
Definition at line 813 of file core_local.c.
References ao2_lock, ao2_ref, ao2_unlink, ao2_unlock, ast_channel_tech_pvt(), ast_unreal_hangup(), local_pvt::base, ast_unreal_pvt::chan, locals, and ast_unreal_pvt::owner.
|
static |
Definition at line 467 of file core_local.c.
References ast_free, ast_json_integer_get(), ast_json_is_true(), ast_json_object_get(), ast_json_string_get(), ast_local_bridge_type(), ast_local_optimization_begin_type(), ast_local_optimization_end_type(), ast_manager_build_channel_state_string_prefix(), ast_manager_event_blob_create(), ast_multi_channel_blob_get_channel(), ast_multi_channel_blob_get_json(), ast_str_append(), ast_str_buffer(), ast_str_create, AST_UNREAL_OWNER, ast_channel_snapshot::base, EVENT_FLAG_CALL, NULL, RAII_VAR, stasis_message_data(), stasis_message_type(), and ast_channel_snapshot_base::uniqueid.
|
static |
Callback for ast_unreal_pvt_callbacks optimization_finished
.
Definition at line 437 of file core_local.c.
References ao2_cleanup, ast_channel_topic(), ast_json_null(), ast_json_pack(), ast_json_unref(), ast_local_optimization_end_type(), local_pvt::base, local_channel_optimization_blob(), NULL, ast_unreal_pvt::owner, RAII_VAR, stasis_message_create(), and stasis_publish().
|
static |
Callback for ast_unreal_pvt_callbacks optimization_started
.
Definition at line 394 of file core_local.c.
References ao2_cleanup, ast_channel_snapshot_get_latest(), ast_channel_topic(), ast_channel_uniqueid(), ast_json_null(), ast_json_pack(), ast_json_unref(), ast_local_optimization_begin_type(), ast_multi_channel_blob_add_channel(), local_pvt::base, local_channel_optimization_blob(), NULL, ast_unreal_pvt::owner, RAII_VAR, stasis_message_create(), and stasis_publish().
|
static |
Definition at line 846 of file core_local.c.
References local_pvt::action, ao2_cleanup, ast_bridge_features_destroy(), ast_unreal_destructor(), local_pvt::base, local_pvt::bridge, local_bridge::features, local_bridge::join, LOCAL_CALL_ACTION_BRIDGE, LOCAL_CALL_ACTION_DIALPLAN, LOCAL_CALL_ACTION_MASQUERADE, local_pvt::masq, local_bridge::swap, and local_pvt::type.
Referenced by local_alloc().
|
static |
Part of PBX interface.
Definition at line 923 of file core_local.c.
References ast_stream_topology_create_from_format_cap(), ast_stream_topology_free(), ast_channel::data, local_request_with_stream_topology(), NULL, and type.
|
static |
Part of PBX interface.
Definition at line 941 of file core_local.c.
References ao2_link, ao2_ref, ast_format_cap_alloc, ast_format_cap_append, AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_cap_get_names(), AST_FORMAT_CAP_NAMES_LEN, ast_log, AST_MEDIA_TYPE_AUDIO, ast_read_threadstorage_callid(), AST_STATE_DOWN, AST_STATE_RING, ast_str_alloca, ast_stream_get_formats(), ast_stream_get_state(), ast_stream_get_type(), ast_stream_set_formats(), AST_STREAM_STATE_REMOVED, ast_stream_topology_clone(), ast_stream_topology_get_count(), ast_stream_topology_get_stream(), ast_translator_best_choice(), ast_unreal_new_channels(), local_pvt::base, ast_channel::callid, ast_channel_tech::capabilities, local_pvt::context, local_pvt::exten, local_alloc(), local_tech, locals, LOG_WARNING, NULL, and type.
Referenced by local_request().
|
static |
Definition at line 1176 of file core_local.c.
References AST_OPTION_SECURE_MEDIA, AST_OPTION_SECURE_SIGNALING, ast_unreal_setoption(), and ast_channel::data.
|
static |
Definition at line 1121 of file core_local.c.
References ao2_cleanup, ao2_ref, ARRAY_LEN, ast_channel_unregister(), ast_cli_unregister_multiple(), ast_local_bridge_type(), ast_local_optimization_begin_type(), ast_local_optimization_end_type(), ast_manager_unregister(), ast_channel_tech::capabilities, cli_local, local_tech, locals, NULL, and STASIS_MESSAGE_TYPE_CLEANUP.
Referenced by ast_local_init().
|
static |
Definition at line 1111 of file core_local.c.
References CMP_MATCH.
Referenced by ast_local_init().
|
static |
CLI command "local show channels".
Definition at line 1031 of file core_local.c.
References a, ao2_container_count(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock, ao2_ref, ao2_unlock, ast_channel_name(), ast_cli(), local_pvt::base, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, locals, ast_unreal_pvt::name, NULL, ast_unreal_pvt::owner, RESULT_SUCCESS, and ast_cli_entry::usage.
|
static |
Definition at line 1074 of file core_local.c.
References ao2_find, ao2_lock, ao2_ref, ao2_unlock, ast_channel_get_by_name(), ast_channel_tech_pvt(), ast_channel_unref, ast_clear_flag, ast_strlen_zero(), AST_UNREAL_NO_OPTIMIZATION, astman_get_header(), astman_send_ack(), astman_send_error(), local_pvt::base, locals, and NULL.
Referenced by ast_local_init().
|
static |
Definition at line 542 of file core_local.c.
References ao2_cleanup, ao2_unlock, ast_channel_snapshot_get_latest(), ast_channel_topic(), ast_channel_uniqueid(), ast_channel_unlock, ast_channel_unref, ast_json_pack(), ast_json_unref(), ast_local_bridge_type(), ast_multi_channel_blob_add_channel(), ast_multi_channel_blob_create(), ast_test_flag, ast_unreal_lock_all(), AST_UNREAL_NO_OPTIMIZATION, local_pvt::base, local_pvt::context, end, local_pvt::exten, NULL, RAII_VAR, stasis_message_create(), and stasis_publish().
Referenced by local_call().
STASIS_MESSAGE_TYPE_DEFN | ( | ast_local_bridge_type | , |
. | to_ami = local_message_to_ami |
||
) |
Define local channel message types.
STASIS_MESSAGE_TYPE_DEFN | ( | ast_local_optimization_begin_type | , |
. | to_ami = local_message_to_ami |
||
) |
STASIS_MESSAGE_TYPE_DEFN | ( | ast_local_optimization_end_type | , |
. | to_ami = local_message_to_ami |
||
) |
|
static |
Definition at line 1070 of file core_local.c.
Referenced by ast_local_init(), and local_shutdown().
|
static |
Definition at line 173 of file core_local.c.
Referenced by ast_local_init(), local_request_with_stream_topology(), and local_shutdown().
struct ast_unreal_pvt_callbacks local_unreal_callbacks |
Callbacks from the unreal core when channel optimization occurs.
Definition at line 167 of file core_local.c.
Referenced by local_alloc().
|
static |
Definition at line 138 of file core_local.c.
Referenced by ast_attended_transfer_message_add_link(), ast_local_get_peer(), ast_local_init(), ast_local_setup_bridge(), ast_local_setup_masquerade(), attended_transfer_bridge(), local_devicestate(), local_hangup(), local_request_with_stream_topology(), local_shutdown(), locals_show(), and manager_optimize_away().
|
static |
Definition at line 136 of file core_local.c.