conf_chan_announce.c File Reference

ConfBridge announcer channel driver. More...

#include "asterisk.h"
#include "asterisk/channel.h"
#include "asterisk/bridge.h"
#include "asterisk/core_unreal.h"
#include "include/confbridge.h"

Include dependency graph for conf_chan_announce.c:

Go to the source code of this file.

Data Structures

struct  announce_pvt

Functions

static int announce_call (struct ast_channel *chan, const char *addr, int timeout)
static int announce_hangup (struct ast_channel *ast)
static void announce_pvt_destructor (void *vdoomed)
static struct ast_channelannounce_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)
void conf_announce_channel_depart (struct ast_channel *chan)
 Remove the announcer channel from the conference.
int conf_announce_channel_push (struct ast_channel *ast)
 Push the announcer channel into the conference.
struct ast_channel_techconf_announce_get_tech (void)
 Get ConfBridge announce channel technology struct.

Variables

static struct ast_channel_tech announce_tech


Detailed Description

ConfBridge announcer channel driver.

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

Definition in file conf_chan_announce.c.


Function Documentation

static int announce_call ( struct ast_channel chan,
const char *  addr,
int  timeout 
) [static]

Definition at line 49 of file conf_chan_announce.c.

00050 {
00051    /* Make sure anyone calling ast_call() for this channel driver is going to fail. */
00052    return -1;
00053 }

static int announce_hangup ( struct ast_channel ast  )  [static]

Definition at line 55 of file conf_chan_announce.c.

References ao2_ref, ast_channel_tech_pvt(), ast_unreal_hangup(), and announce_pvt::base.

00056 {
00057    struct announce_pvt *p = ast_channel_tech_pvt(ast);
00058    int res;
00059 
00060    if (!p) {
00061       return -1;
00062    }
00063 
00064    /* give the pvt a ref to fulfill calling requirements. */
00065    ao2_ref(p, +1);
00066    res = ast_unreal_hangup(&p->base, ast);
00067    ao2_ref(p, -1);
00068 
00069    return res;
00070 }

static void announce_pvt_destructor ( void *  vdoomed  )  [static]

Definition at line 72 of file conf_chan_announce.c.

References ao2_cleanup, ast_unreal_destructor(), announce_pvt::base, announce_pvt::bridge, and NULL.

Referenced by announce_request().

00073 {
00074    struct announce_pvt *doomed = vdoomed;
00075 
00076    ao2_cleanup(doomed->bridge);
00077    doomed->bridge = NULL;
00078    ast_unreal_destructor(&doomed->base);
00079 }

static struct ast_channel* announce_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 
) [static, read]

Definition at line 81 of file conf_chan_announce.c.

References announce_pvt_destructor(), ao2_cleanup, ao2_find, ao2_ref, ast_answer(), ast_assert, ast_channel_add_bridge_role(), ast_copy_string(), ast_hangup(), ast_set_flag, AST_STATE_UP, ast_unreal_alloc(), ast_unreal_new_channels(), AST_UNREAL_NO_OPTIMIZATION, conf_announce_get_tech(), conference_bridges, NULL, OBJ_KEY, and RAII_VAR.

00082 {
00083    struct ast_channel *chan;
00084    const char *conf_name = data;
00085    RAII_VAR(struct confbridge_conference *, conference, NULL, ao2_cleanup);
00086    RAII_VAR(struct announce_pvt *, pvt, NULL, ao2_cleanup);
00087 
00088    conference = ao2_find(conference_bridges, conf_name, OBJ_KEY);
00089    if (!conference) {
00090       return NULL;
00091    }
00092    ast_assert(conference->bridge != NULL);
00093 
00094    /* Allocate a new private structure and then Asterisk channels */
00095    pvt = (struct announce_pvt *) ast_unreal_alloc(sizeof(*pvt), announce_pvt_destructor,
00096       cap);
00097    if (!pvt) {
00098       return NULL;
00099    }
00100    ast_set_flag(&pvt->base, AST_UNREAL_NO_OPTIMIZATION);
00101    ast_copy_string(pvt->base.name, conf_name, sizeof(pvt->base.name));
00102    pvt->bridge = conference->bridge;
00103    ao2_ref(pvt->bridge, +1);
00104 
00105    chan = ast_unreal_new_channels(&pvt->base, conf_announce_get_tech(),
00106       AST_STATE_UP, AST_STATE_UP, NULL, NULL, assignedids, requestor, 0);
00107    if (chan) {
00108       ast_answer(pvt->base.owner);
00109       ast_answer(pvt->base.chan);
00110       if (ast_channel_add_bridge_role(pvt->base.chan, "announcer")) {
00111          ast_hangup(chan);
00112          chan = NULL;
00113       }
00114    }
00115 
00116    return chan;
00117 }

void conf_announce_channel_depart ( struct ast_channel chan  ) 

Remove the announcer channel from the conference.

Since:
12.0.0
Parameters:
chan Either channel in the announcer channel pair.
Returns:
Nothing

Definition at line 146 of file conf_chan_announce.c.

References ao2_lock, ao2_ref, ao2_unlock, ast_bridge_depart(), ast_channel_tech_pvt(), ast_channel_unref, ast_clear_flag, ast_test_flag, AST_UNREAL_CARETAKER_THREAD, announce_pvt::base, and ast_unreal_pvt::chan.

Referenced by destroy_conference_bridge(), and play_sound_helper().

00147 {
00148    struct announce_pvt *p = ast_channel_tech_pvt(chan);
00149 
00150    if (!p) {
00151       return;
00152    }
00153 
00154    ao2_ref(p, +1);
00155    ao2_lock(p);
00156    if (!ast_test_flag(&p->base, AST_UNREAL_CARETAKER_THREAD)) {
00157       ao2_unlock(p);
00158       ao2_ref(p, -1);
00159       return;
00160    }
00161    ast_clear_flag(&p->base, AST_UNREAL_CARETAKER_THREAD);
00162    chan = p->base.chan;
00163    ao2_unlock(p);
00164    ao2_ref(p, -1);
00165    if (chan) {
00166       ast_bridge_depart(chan);
00167       ast_channel_unref(chan);
00168    }
00169 }

int conf_announce_channel_push ( struct ast_channel ast  ) 

Push the announcer channel into the conference.

Since:
12.0.0
Parameters:
ast Either channel in the announcer channel pair.
Return values:
0 on success.
-1 on error.

Definition at line 171 of file conf_chan_announce.c.

References ao2_cleanup, ao2_lock, ao2_ref, ao2_unlock, AST_BRIDGE_CHANNEL_FLAG_IMMOVABLE, ast_bridge_features_destroy(), ast_bridge_features_new(), ast_bridge_impart(), AST_BRIDGE_IMPART_CHAN_DEPARTABLE, ast_channel_ref, ast_channel_tech_pvt(), ast_channel_unref, ast_set_flag, AST_UNREAL_CARETAKER_THREAD, ast_bridge_features::feature_flags, lock, NULL, RAII_VAR, and SCOPED_CHANNELLOCK.

Referenced by play_sound_helper().

00172 {
00173    struct ast_bridge_features *features;
00174    struct ast_channel *chan;
00175    RAII_VAR(struct announce_pvt *, p, NULL, ao2_cleanup);
00176 
00177    {
00178       SCOPED_CHANNELLOCK(lock, ast);
00179 
00180       p = ast_channel_tech_pvt(ast);
00181       if (!p) {
00182          return -1;
00183       }
00184       ao2_ref(p, +1);
00185       chan = p->base.chan;
00186       if (!chan) {
00187          return -1;
00188       }
00189       ast_channel_ref(chan);
00190    }
00191 
00192    features = ast_bridge_features_new();
00193    if (!features) {
00194       ast_channel_unref(chan);
00195       return -1;
00196    }
00197    ast_set_flag(&features->feature_flags, AST_BRIDGE_CHANNEL_FLAG_IMMOVABLE);
00198 
00199    /* Impart the output channel into the bridge */
00200    if (ast_bridge_impart(p->bridge, chan, NULL, features,
00201       AST_BRIDGE_IMPART_CHAN_DEPARTABLE)) {
00202       ast_bridge_features_destroy(features);
00203       ast_channel_unref(chan);
00204       return -1;
00205    }
00206    ao2_lock(p);
00207    ast_set_flag(&p->base, AST_UNREAL_CARETAKER_THREAD);
00208    ao2_unlock(p);
00209    return 0;
00210 }

struct ast_channel_tech* conf_announce_get_tech ( void   )  [read]

Get ConfBridge announce channel technology struct.

Since:
12.0.0
Returns:
ConfBridge announce channel technology.

Definition at line 141 of file conf_chan_announce.c.

Referenced by announce_request(), load_module(), and unload_module().

00142 {
00143    return &announce_tech;
00144 }


Variable Documentation

Definition at line 119 of file conf_chan_announce.c.


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