summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorLuigi Rizzo <rizzo@icir.org>2007-07-29 10:13:14 +0000
committerLuigi Rizzo <rizzo@icir.org>2007-07-29 10:13:14 +0000
commitc19549820ec491d866f1dc4fbfc9a91439a3b402 (patch)
tree14c55217e298eb8b60a9d8666766737c75c93f5c /channels
parente5f3a6ccdbb3ddb33e83dc20dd476d961aaf4dfd (diff)
build the version of sip_tech with no send_digit_begin
at load time instead of duplicating the initializer. This should remove the risk of forgetting fields in the initializer. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@77684 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index a679f65e9..894d74f64 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1780,31 +1780,12 @@ static const struct ast_channel_tech sip_tech = {
};
/*! \brief This version of the sip channel tech has no send_digit_begin
- * callback. This is for use with channels using SIP INFO DTMF so that
- * the core knows that the channel doesn't want DTMF BEGIN frames. */
-static const struct ast_channel_tech sip_tech_info = {
- .type = "SIP",
- .description = "Session Initiation Protocol (SIP)",
- .capabilities = AST_FORMAT_AUDIO_MASK, /* all audio formats */
- .properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER,
- .requester = sip_request_call,
- .devicestate = sip_devicestate,
- .call = sip_call,
- .hangup = sip_hangup,
- .answer = sip_answer,
- .read = sip_read,
- .write = sip_write,
- .write_video = sip_write,
- .write_text = sip_write,
- .indicate = sip_indicate,
- .transfer = sip_transfer,
- .fixup = sip_fixup,
- .send_digit_end = sip_senddigit_end,
- .bridge = ast_rtp_bridge,
- .early_bridge = ast_rtp_early_bridge,
- .send_text = sip_sendtext,
- .func_channel_read = acf_channel_read,
-};
+ * callback so that the core knows that the channel does not want
+ * DTMF BEGIN frames.
+ * The struct is initialized just before registering the channel driver,
+ * and is for use with channels using SIP INFO DTMF.
+ */
+static struct ast_channel_tech sip_tech_info;
/* wrapper macro to tell whether t points to one of the sip_tech descriptors */
#define IS_SIP_TECH(t) ((t) == &sip_tech || (t) == &sip_tech_info)
@@ -18651,6 +18632,13 @@ static int load_module(void)
if(reload_config(sip_reloadreason)) /* Load the configuration from sip.conf */
return AST_MODULE_LOAD_DECLINE;
+ /* Prepare the version that does not require DTMF BEGIN frames.
+ * We need to use tricks such as memcopy and casts because the variable
+ * has const fields.
+ */
+ memcpy(&sip_tech_info, &sip_tech, sizeof(sip_tech));
+ *((void **)&sip_tech_info.send_digit_begin) = NULL;
+
/* Make sure we can register our sip channel type */
if (ast_channel_register(&sip_tech)) {
ast_log(LOG_ERROR, "Unable to register channel type 'SIP'\n");