static struct ast_channel *media_request_helper(struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, struct ast_channel_tech *tech, const char *role) { struct ast_channel *chan; ast_callid callid; RAII_VAR(struct ast_unreal_pvt *, pvt, NULL, ao2_cleanup); if (!(pvt = ast_unreal_alloc(sizeof(*pvt), ast_unreal_destructor, cap))) { return NULL; } ast_copy_string(pvt->name, data, sizeof(pvt->name)); ast_set_flag(pvt, AST_UNREAL_NO_OPTIMIZATION); callid = ast_read_threadstorage_callid(); chan = ast_unreal_new_channels(pvt, tech, AST_STATE_UP, AST_STATE_UP, NULL, NULL, assignedids, requestor, callid); if (!chan) { return NULL; } ast_answer(pvt->owner); ast_answer(pvt->chan); if (ast_channel_add_bridge_role(pvt->chan, role)) { ast_hangup(chan); return NULL; } return chan; }
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) { struct ast_channel *chan; const char *conf_name = data; /* Allocate a new private structure and then Asterisk channels */ struct announce_pvt *pvt = (struct announce_pvt *) ast_unreal_alloc(sizeof(*pvt), announce_pvt_destructor, cap); if (!pvt) { return NULL; } ast_set_flag(&pvt->base, AST_UNREAL_NO_OPTIMIZATION); ast_copy_string(pvt->base.name, conf_name, sizeof(pvt->base.name)); #if !defined(CS_AST_CHANNEL_CALLID_TYPEDEF) chan = ast_unreal_new_channels(&pvt->base, sccpconf_announce_get_tech(), AST_STATE_UP, AST_STATE_UP, NULL, NULL, assignedids, requestor, NULL); #else chan = ast_unreal_new_channels(&pvt->base, sccpconf_announce_get_tech(), AST_STATE_UP, AST_STATE_UP, NULL, NULL, assignedids, requestor, 0); #endif if (chan) { ast_answer(pvt->base.owner); ast_answer(pvt->base.chan); if (ast_channel_add_bridge_role(pvt->base.chan, "announcer")) { ast_hangup(chan); chan = NULL; } } ao2_cleanup(pvt); return chan; }
/*! \brief Create a call structure */ static struct local_pvt *local_alloc(const char *data, struct ast_format_cap *cap) { struct local_pvt *pvt; char *parse; char *context; char *opts; pvt = (struct local_pvt *) ast_unreal_alloc(sizeof(*pvt), local_pvt_destructor, cap); if (!pvt) { return NULL; } pvt->base.callbacks = &local_unreal_callbacks; parse = ast_strdupa(data); /* * Local channels intercept MOH by default. * * This is a silly default because it represents state held by * the local channels. Unless local channel optimization is * disabled, the state will dissapear when the local channels * optimize out. */ ast_set_flag(&pvt->base, AST_UNREAL_MOH_INTERCEPT); /* Look for options */ if ((opts = strchr(parse, '/'))) { *opts++ = '\0'; if (strchr(opts, 'n')) { ast_set_flag(&pvt->base, AST_UNREAL_NO_OPTIMIZATION); } if (strchr(opts, 'j')) { if (ast_test_flag(&pvt->base, AST_UNREAL_NO_OPTIMIZATION)) { ast_set_flag(&pvt->base.jb_conf, AST_JB_ENABLED); } else { ast_log(LOG_ERROR, "You must use the 'n' option with the 'j' option to enable the jitter buffer\n"); } } if (strchr(opts, 'm')) { ast_clear_flag(&pvt->base, AST_UNREAL_MOH_INTERCEPT); } } /* Look for a context */ if ((context = strchr(parse, '@'))) { *context++ = '\0'; } ast_copy_string(pvt->context, S_OR(context, "default"), sizeof(pvt->context)); ast_copy_string(pvt->exten, parse, sizeof(pvt->exten)); snprintf(pvt->base.name, sizeof(pvt->base.name), "%s@%s", pvt->exten, pvt->context); return pvt; /* this is returned with a ref */ }
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) { struct ast_channel *chan; const char *conf_name = data; RAII_VAR(struct confbridge_conference *, conference, NULL, ao2_cleanup); RAII_VAR(struct announce_pvt *, pvt, NULL, ao2_cleanup); conference = ao2_find(conference_bridges, conf_name, OBJ_KEY); if (!conference) { return NULL; } ast_assert(conference->bridge != NULL); /* Allocate a new private structure and then Asterisk channels */ pvt = (struct announce_pvt *) ast_unreal_alloc(sizeof(*pvt), announce_pvt_destructor, cap); if (!pvt) { return NULL; } ast_set_flag(&pvt->base, AST_UNREAL_NO_OPTIMIZATION); ast_copy_string(pvt->base.name, conf_name, sizeof(pvt->base.name)); pvt->bridge = conference->bridge; ao2_ref(pvt->bridge, +1); chan = ast_unreal_new_channels(&pvt->base, conf_announce_get_tech(), AST_STATE_UP, AST_STATE_UP, NULL, NULL, assignedids, requestor, 0); if (chan) { ast_answer(pvt->base.owner); ast_answer(pvt->base.chan); if (ast_channel_add_bridge_role(pvt->base.chan, "announcer")) { ast_hangup(chan); chan = NULL; } } return chan; }