summaryrefslogtreecommitdiff
path: root/apps/app_parkandannounce.c
diff options
context:
space:
mode:
authorDavid Vossel <dvossel@digium.com>2011-02-03 16:22:10 +0000
committerDavid Vossel <dvossel@digium.com>2011-02-03 16:22:10 +0000
commitc26c190711a1bbe3b5fff1a93facae333757c56e (patch)
tree00da0caa5a07b7b25729f089dbcafb08129fa9be /apps/app_parkandannounce.c
parent652fb64a01c7a8656697d07e606620ee0ced6929 (diff)
Asterisk media architecture conversion - no more format bitfields
This patch is the foundation of an entire new way of looking at media in Asterisk. The code present in this patch is everything required to complete phase1 of my Media Architecture proposal. For more information about this project visit the link below. https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal The primary function of this patch is to convert all the usages of format bitfields in Asterisk to use the new format and format_cap APIs. Functionally no change in behavior should be present in this patch. Thanks to twilson and russell for all the time they spent reviewing these changes. Review: https://reviewboard.asterisk.org/r/1083/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@306010 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_parkandannounce.c')
-rw-r--r--apps/app_parkandannounce.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/apps/app_parkandannounce.c b/apps/app_parkandannounce.c
index 5bb8b6594..fb3e713e1 100644
--- a/apps/app_parkandannounce.c
+++ b/apps/app_parkandannounce.c
@@ -96,6 +96,9 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
struct ast_channel *dchan;
struct outgoing_helper oh = { 0, };
int outstate;
+ struct ast_format tmpfmt;
+ struct ast_format_cap *cap_slin = ast_format_cap_alloc_nolock();
+
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(template);
AST_APP_ARG(timeout);
@@ -104,9 +107,15 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "ParkAndAnnounce requires arguments: (announce:template|timeout|dial|[return_context])\n");
- return -1;
+ res = -1;
+ goto parkcleanup;
+ }
+ if (!cap_slin) {
+ res = -1;
+ goto parkcleanup;
}
-
+ ast_format_cap_add(cap_slin, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
+
s = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, s);
@@ -115,7 +124,8 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
if (ast_strlen_zero(args.dial)) {
ast_log(LOG_WARNING, "PARK: A dial resource must be specified i.e: Console/dsp or DAHDI/g1/5551212\n");
- return -1;
+ res = -1;
+ goto parkcleanup;
}
dialtech = strsep(&args.dial, "/");
@@ -138,8 +148,9 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
before we are done announcing and the channel is messed with, Kablooeee. So we use Masq to prevent this. */
res = ast_masq_park_call(chan, NULL, timeout, &lot);
- if (res == -1)
- return res;
+ if (res == -1) {
+ goto parkcleanup;
+ }
ast_verb(3, "Call Parking Called, lot: %d, timeout: %d, context: %s\n", lot, timeout, args.return_context);
@@ -148,7 +159,7 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
snprintf(buf, sizeof(buf), "%d", lot);
oh.parent_channel = chan;
oh.vars = ast_variable_new("_PARKEDAT", buf, "");
- dchan = __ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, chan, args.dial, 30000,
+ dchan = __ast_request_and_dial(dialtech, cap_slin, chan, args.dial, 30000,
&outstate,
S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL),
S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL),
@@ -160,11 +171,13 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
ast_verb(4, "Channel %s was never answered.\n", dchan->name);
ast_log(LOG_WARNING, "PARK: Channel %s was never answered for the announce.\n", dchan->name);
ast_hangup(dchan);
- return -1;
+ res = -1;
+ goto parkcleanup;
}
} else {
ast_log(LOG_WARNING, "PARK: Unable to allocate announce channel.\n");
- return -1;
+ res = -1;
+ goto parkcleanup;
}
ast_stopstream(dchan);
@@ -197,7 +210,10 @@ static int parkandannounce_exec(struct ast_channel *chan, const char *data)
ast_stopstream(dchan);
ast_hangup(dchan);
-
+
+parkcleanup:
+ cap_slin = ast_format_cap_destroy(cap_slin);
+
return res;
}