core_local.h File Reference

Local proxy channel special access. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

struct stasis_message_typeast_local_bridge_type (void)
 Message type for when two local channel halves are bridged together.
struct ast_channelast_local_get_peer (struct ast_channel *ast)
 Get the other local channel in the pair.
struct stasis_message_typeast_local_optimization_begin_type (void)
 Message type for when a local channel optimization begins.
struct stasis_message_typeast_local_optimization_end_type (void)
 Message type for when a local channel optimization completes.
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().
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().


Detailed Description

Local proxy channel special access.

Author:
Richard Mudgett <rmudgett@digium.com>
See Also:

Definition in file core_local.h.


Function Documentation

struct stasis_message_type* ast_local_bridge_type ( void   )  [read]

Message type for when two local channel halves are bridged together.

Since:
12.0.0
Note:
Payloads for the ast_local_bridge_type are a ast_multi_channel_blob. Roles for the channels in the ast_multi_channel_blob are "1" and "2", reflecting the two halves. Unlike most other bridges, the 'bridge' between two local channels is not part of the bridge framework; as such, the message simply references the two local channel halves that are now bridged.
Return values:
A Stasis Message Bus API message type

Referenced by ast_local_init(), local_message_to_ami(), local_shutdown(), and publish_local_bridge_message().

struct ast_channel* ast_local_get_peer ( struct ast_channel ast  )  [read]

Get the other local channel in the pair.

Since:
12.0.0
Parameters:
ast Local channel to get peer.
Note:
On entry, ast must be locked.
Return values:
peer reffed on success.
NULL if no peer or error.

Definition at line 238 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, NULL, and ast_unreal_pvt::owner.

Referenced by ari_channels_handle_originate_with_id(), attended_transfer_bridge(), and park_local_transfer().

00239 {
00240    struct local_pvt *p = ast_channel_tech_pvt(ast);
00241    struct local_pvt *found;
00242    struct ast_channel *peer;
00243 
00244    if (!p) {
00245       return NULL;
00246    }
00247 
00248    found = p ? ao2_find(locals, p, 0) : NULL;
00249    if (!found) {
00250       /* ast is either not a local channel or it has alredy been hungup */
00251       return NULL;
00252    }
00253    ao2_lock(found);
00254    if (ast == p->base.owner) {
00255       peer = p->base.chan;
00256    } else if (ast == p->base.chan) {
00257       peer = p->base.owner;
00258    } else {
00259       peer = NULL;
00260    }
00261    if (peer) {
00262       ast_channel_ref(peer);
00263    }
00264    ao2_unlock(found);
00265    ao2_ref(found, -1);
00266    return peer;
00267 }

struct stasis_message_type* ast_local_optimization_begin_type ( void   )  [read]

Message type for when a local channel optimization begins.

Since:
12.0.0
Note:
Payloads for the ast_local_optimization_begin_type are a ast_multi_channel_blob. Roles for the channels in the ast_multi_channel_blob are "1" and "2", reflecting the two halves.
Return values:
A Stasis Message Bus API message type

Referenced by ast_local_init(), AST_TEST_DEFINE(), local_message_to_ami(), local_optimization_started_cb(), local_shutdown(), and setup_stasis_subs().

struct stasis_message_type* ast_local_optimization_end_type ( void   )  [read]

Message type for when a local channel optimization completes.

Since:
12.0.0
Note:
Payloads for the ast_local_optimization_end_type are a ast_multi_channel_blob. Roles for the channels in the ast_multi_channel_blob are "1" and "2", reflecting the two halves.
Return values:
A Stasis Message Bus API message type

Referenced by ast_local_init(), AST_TEST_DEFINE(), create_routes(), local_message_to_ami(), local_optimization_finished_cb(), local_shutdown(), and setup_stasis_subs().

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().

Since:
12.0.0
Parameters:
ast Either channel of a local channel pair.
bridge Bridge to join.
swap Channel to swap with when joining.
features Bridge features structure.
Note:
The features parameter must be NULL or obtained by ast_bridge_features_new(). You must not dereference features after calling even if the call fails.

Intended to be called after ast_request() and before ast_call() on a local channel.

Return values:
0 on success.
-1 on error.

Definition at line 561 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, NULL, ast_unreal_pvt::owner, local_bridge::swap, and local_pvt::type.

Referenced by attended_transfer_bridge().

00562 {
00563    struct local_pvt *p;
00564    struct local_pvt *found;
00565    int res = -1;
00566 
00567    /* Sanity checks. */
00568    if (!ast || !bridge) {
00569       ast_bridge_features_destroy(features);
00570       return -1;
00571    }
00572 
00573    ast_channel_lock(ast);
00574    p = ast_channel_tech_pvt(ast);
00575    ast_channel_unlock(ast);
00576 
00577    found = p ? ao2_find(locals, p, 0) : NULL;
00578    if (found) {
00579       ao2_lock(found);
00580       if (found->type == LOCAL_CALL_ACTION_DIALPLAN
00581          && found->base.owner
00582          && found->base.chan
00583          && !ast_test_flag(&found->base, AST_UNREAL_CARETAKER_THREAD)) {
00584          ao2_ref(bridge, +1);
00585          if (swap) {
00586             ast_channel_ref(swap);
00587          }
00588          found->type = LOCAL_CALL_ACTION_BRIDGE;
00589          found->action.bridge.join = bridge;
00590          found->action.bridge.swap = swap;
00591          found->action.bridge.features = features;
00592          res = 0;
00593       } else {
00594          ast_bridge_features_destroy(features);
00595       }
00596       ao2_unlock(found);
00597       ao2_ref(found, -1);
00598    }
00599 
00600    return res;
00601 }

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().

Since:
12.0.0
Parameters:
ast Either channel of a local channel pair.
masq Channel to masquerade into.
Note:
Intended to be called after ast_request() and before ast_call() on a local channel.
Return values:
0 on success.
-1 on error.

Definition at line 603 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, local_pvt::masq, NULL, ast_unreal_pvt::owner, and local_pvt::type.

Referenced by attended_transfer_bridge().

00604 {
00605    struct local_pvt *p;
00606    struct local_pvt *found;
00607    int res = -1;
00608 
00609    /* Sanity checks. */
00610    if (!ast || !masq) {
00611       return -1;
00612    }
00613 
00614    ast_channel_lock(ast);
00615    p = ast_channel_tech_pvt(ast);
00616    ast_channel_unlock(ast);
00617 
00618    found = p ? ao2_find(locals, p, 0) : NULL;
00619    if (found) {
00620       ao2_lock(found);
00621       if (found->type == LOCAL_CALL_ACTION_DIALPLAN
00622          && found->base.owner
00623          && found->base.chan
00624          && !ast_test_flag(&found->base, AST_UNREAL_CARETAKER_THREAD)) {
00625          ast_channel_ref(masq);
00626          found->type = LOCAL_CALL_ACTION_MASQUERADE;
00627          found->action.masq = masq;
00628          res = 0;
00629       }
00630       ao2_unlock(found);
00631       ao2_ref(found, -1);
00632    }
00633 
00634    return res;
00635 }


Generated on Thu Apr 16 06:30:31 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6