[asterisk-commits] rmudgett: branch rmudgett/bridge_phase r397503 - in /team/rmudgett/bridge_pha...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Aug 22 18:28:02 CDT 2013
Author: rmudgett
Date: Thu Aug 22 18:28:00 2013
New Revision: 397503
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=397503
Log:
* Add complete any active hold when a channel leaves the bridging system or masquerades.
* Restore MOH with the same music class after playing a file.
Modified:
team/rmudgett/bridge_phase/bridges/bridge_builtin_interval_features.c
team/rmudgett/bridge_phase/include/asterisk/channel.h
team/rmudgett/bridge_phase/main/bridge_channel.c
team/rmudgett/bridge_phase/main/channel.c
team/rmudgett/bridge_phase/main/channel_internal_api.c
team/rmudgett/bridge_phase/res/res_musiconhold.c
Modified: team/rmudgett/bridge_phase/bridges/bridge_builtin_interval_features.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/bridges/bridge_builtin_interval_features.c?view=diff&rev=397503&r1=397502&r2=397503
==============================================================================
--- team/rmudgett/bridge_phase/bridges/bridge_builtin_interval_features.c (original)
+++ team/rmudgett/bridge_phase/bridges/bridge_builtin_interval_features.c Thu Aug 22 18:28:00 2013
@@ -103,12 +103,14 @@
/*
* It may be necessary to resume music on hold after we finish
* playing the announcment.
- *
- * XXX We have no idea what MOH class was in use before playing
- * the file.
*/
if (ast_test_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_MOH)) {
- ast_moh_start(bridge_channel->chan, NULL, NULL);
+ const char *latest_musicclass;
+
+ ast_channel_lock(bridge_channel->chan);
+ latest_musicclass = ast_strdupa(ast_channel_latest_musicclass(bridge_channel->chan));
+ ast_channel_unlock(bridge_channel->chan);
+ ast_moh_start(bridge_channel->chan, latest_musicclass, NULL);
}
}
Modified: team/rmudgett/bridge_phase/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/include/asterisk/channel.h?view=diff&rev=397503&r1=397502&r2=397503
==============================================================================
--- team/rmudgett/bridge_phase/include/asterisk/channel.h (original)
+++ team/rmudgett/bridge_phase/include/asterisk/channel.h Thu Aug 22 18:28:00 2013
@@ -3792,6 +3792,7 @@
DECLARE_STRINGFIELD_SETTERS_FOR(name);
DECLARE_STRINGFIELD_SETTERS_FOR(language);
DECLARE_STRINGFIELD_SETTERS_FOR(musicclass);
+DECLARE_STRINGFIELD_SETTERS_FOR(latest_musicclass);
DECLARE_STRINGFIELD_SETTERS_FOR(accountcode);
DECLARE_STRINGFIELD_SETTERS_FOR(peeraccount);
DECLARE_STRINGFIELD_SETTERS_FOR(userfield);
@@ -3805,6 +3806,7 @@
const char *ast_channel_name(const struct ast_channel *chan);
const char *ast_channel_language(const struct ast_channel *chan);
const char *ast_channel_musicclass(const struct ast_channel *chan);
+const char *ast_channel_latest_musicclass(const struct ast_channel *chan);
const char *ast_channel_accountcode(const struct ast_channel *chan);
const char *ast_channel_peeraccount(const struct ast_channel *chan);
const char *ast_channel_userfield(const struct ast_channel *chan);
@@ -3857,6 +3859,8 @@
void ast_channel_timingfd_set(struct ast_channel *chan, int value);
int ast_channel_visible_indication(const struct ast_channel *chan);
void ast_channel_visible_indication_set(struct ast_channel *chan, int value);
+int ast_channel_hold_state(const struct ast_channel *chan);
+void ast_channel_hold_state_set(struct ast_channel *chan, int value);
int ast_channel_vstreamid(const struct ast_channel *chan);
void ast_channel_vstreamid_set(struct ast_channel *chan, int value);
unsigned short ast_channel_transfercapability(const struct ast_channel *chan);
Modified: team/rmudgett/bridge_phase/main/bridge_channel.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/bridge_channel.c?view=diff&rev=397503&r1=397502&r2=397503
==============================================================================
--- team/rmudgett/bridge_phase/main/bridge_channel.c (original)
+++ team/rmudgett/bridge_phase/main/bridge_channel.c Thu Aug 22 18:28:00 2013
@@ -758,14 +758,14 @@
/*
* It may be necessary to resume music on hold after we finish
* playing the announcment.
- *
- * XXX We have no idea what MOH class was in use before playing
- * the file. This method also fails to restore ringing indications.
- * the proposed solution is to create a resume_entertainment callback
- * for the bridge technology and execute it here.
*/
if (ast_test_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_MOH)) {
- ast_moh_start(bridge_channel->chan, NULL, NULL);
+ const char *latest_musicclass;
+
+ ast_channel_lock(bridge_channel->chan);
+ latest_musicclass = ast_strdupa(ast_channel_latest_musicclass(bridge_channel->chan));
+ ast_channel_unlock(bridge_channel->chan);
+ ast_moh_start(bridge_channel->chan, latest_musicclass, NULL);
}
}
@@ -1595,17 +1595,6 @@
ast_channel_connected_line_macro(NULL, chan, fr, is_caller, 1)) {
ast_indicate_data(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
}
- break;
- case AST_CONTROL_HOLD:
- case AST_CONTROL_UNHOLD:
-/*
- * BUGBUG bridge_channels should remember sending/receiving an outstanding HOLD to/from the bridge
- *
- * When the sending channel is pulled from the bridge it needs to write into the bridge an UNHOLD before being pulled.
- * When the receiving channel is pulled from the bridge it needs to generate its own UNHOLD.
- * Something similar needs to be done for DTMF begin/end.
- */
- ast_indicate_data(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
break;
case AST_CONTROL_OPTION:
/*
@@ -1993,17 +1982,22 @@
ast_bridge_unlock(bridge_channel->bridge);
- /* Indicate a source change since this channel is leaving the bridge system. */
- ast_indicate(bridge_channel->chan, AST_CONTROL_SRCCHANGE);
-
-/* BUGBUG Revisit in regards to moving channels between bridges and local channel optimization. */
-/* BUGBUG This is where outgoing HOLD/UNHOLD memory should write UNHOLD to channel. */
+ /* Complete any active hold before exiting the bridge. */
+ if (ast_channel_hold_state(bridge_channel->chan) == AST_CONTROL_HOLD) {
+ ast_debug(1, "Channel %s simulating UNHOLD for bridge end.\n",
+ ast_channel_name(bridge_channel->chan));
+ ast_indicate(bridge_channel->chan, AST_CONTROL_UNHOLD);
+ }
+
/* Complete any partial DTMF digit before exiting the bridge. */
if (ast_channel_sending_dtmf_digit(bridge_channel->chan)) {
ast_channel_end_dtmf(bridge_channel->chan,
ast_channel_sending_dtmf_digit(bridge_channel->chan),
ast_channel_sending_dtmf_tv(bridge_channel->chan), "bridge end");
}
+
+ /* Indicate a source change since this channel is leaving the bridge system. */
+ ast_indicate(bridge_channel->chan, AST_CONTROL_SRCCHANGE);
/*
* Wait for any dual redirect to complete.
Modified: team/rmudgett/bridge_phase/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/channel.c?view=diff&rev=397503&r1=397502&r2=397503
==============================================================================
--- team/rmudgett/bridge_phase/main/channel.c (original)
+++ team/rmudgett/bridge_phase/main/channel.c Thu Aug 22 18:28:00 2013
@@ -939,6 +939,7 @@
/* Initial state */
ast_channel_state_set(tmp, state);
+ ast_channel_hold_state_set(tmp, AST_CONTROL_UNHOLD);
ast_channel_streamid_set(tmp, -1);
@@ -1069,6 +1070,8 @@
#ifdef HAVE_EPOLL
ast_channel_epfd_set(tmp, -1);
#endif
+
+ ast_channel_hold_state_set(tmp, AST_CONTROL_UNHOLD);
ast_channel_internal_setup_topics(tmp);
@@ -4451,7 +4454,6 @@
ast_channel_connected(chan));
}
break;
-
case AST_CONTROL_REDIRECTING:
{
struct ast_party_redirecting redirecting;
@@ -4464,7 +4466,10 @@
ast_party_redirecting_free(&redirecting);
}
break;
-
+ case AST_CONTROL_HOLD:
+ case AST_CONTROL_UNHOLD:
+ ast_channel_hold_state_set(chan, condition);
+ break;
default:
break;
}
@@ -6374,6 +6379,7 @@
int origstate;
int visible_indication;
int clone_was_zombie = 0;/*!< TRUE if the clonechan was a zombie before the masquerade. */
+ int clone_hold_state;
struct ast_frame *current;
const struct ast_channel_tech *t;
void *t_pvt;
@@ -6476,6 +6482,8 @@
free_translation(clonechan);
free_translation(original);
+ clone_hold_state = ast_channel_hold_state(clonechan);
+
/* Save the current DTMF digit being sent if any. */
clone_sending_dtmf_digit = ast_channel_sending_dtmf_digit(clonechan);
clone_sending_dtmf_tv = ast_channel_sending_dtmf_tv(clonechan);
@@ -6710,6 +6718,11 @@
ast_bridge_notify_masquerade(original);
+ if (clone_hold_state == AST_CONTROL_HOLD) {
+ ast_debug(1, "Channel %s simulating UNHOLD for masquerade.\n",
+ ast_channel_name(original));
+ ast_indicate(original, AST_CONTROL_UNHOLD);
+ }
if (clone_sending_dtmf_digit) {
/*
* The clonechan was sending a DTMF digit that was not completed
@@ -6729,7 +6742,23 @@
* (RINGING, CONGESTION, etc.)
*/
if (visible_indication) {
- ast_indicate(original, visible_indication);
+ if (visible_indication == AST_CONTROL_HOLD) {
+ const char *latest_musicclass;
+ int len;
+
+ ast_channel_lock(original);
+ latest_musicclass = ast_strdupa(ast_channel_latest_musicclass(original));
+ ast_channel_unlock(original);
+ if (ast_strlen_zero(latest_musicclass)) {
+ latest_musicclass = NULL;
+ len = 0;
+ } else {
+ len = strlen(latest_musicclass) + 1;
+ }
+ ast_indicate_data(original, visible_indication, latest_musicclass, len);
+ } else {
+ ast_indicate(original, visible_indication);
+ }
}
ast_channel_lock(original);
Modified: team/rmudgett/bridge_phase/main/channel_internal_api.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/main/channel_internal_api.c?view=diff&rev=397503&r1=397502&r2=397503
==============================================================================
--- team/rmudgett/bridge_phase/main/channel_internal_api.c (original)
+++ team/rmudgett/bridge_phase/main/channel_internal_api.c Thu Aug 22 18:28:00 2013
@@ -96,6 +96,7 @@
AST_STRING_FIELD(name); /*!< ASCII unique channel name */
AST_STRING_FIELD(language); /*!< Language requested for voice prompts */
AST_STRING_FIELD(musicclass); /*!< Default music class */
+ AST_STRING_FIELD(latest_musicclass); /*!< Latest active music class */
AST_STRING_FIELD(accountcode); /*!< Account code for billing */
AST_STRING_FIELD(peeraccount); /*!< Peer account code for billing */
AST_STRING_FIELD(userfield); /*!< Userfield for CEL billing */
@@ -190,6 +191,7 @@
int epfd;
#endif
int visible_indication; /*!< Indication currently playing on the channel */
+ int hold_state; /*!< Current Hold/Unhold state */
unsigned short transfercapability; /*!< ISDN Transfer Capability - AST_FLAG_DIGITAL is not enough */
@@ -444,6 +446,7 @@
DEFINE_STRINGFIELD_SETTERS_FOR(name, 0, 1);
DEFINE_STRINGFIELD_SETTERS_FOR(language, 1, 0);
DEFINE_STRINGFIELD_SETTERS_FOR(musicclass, 0, 0);
+DEFINE_STRINGFIELD_SETTERS_FOR(latest_musicclass, 0, 0);
DEFINE_STRINGFIELD_SETTERS_FOR(accountcode, 1, 0);
DEFINE_STRINGFIELD_SETTERS_FOR(peeraccount, 1, 0);
DEFINE_STRINGFIELD_SETTERS_FOR(userfield, 0, 0);
@@ -462,6 +465,7 @@
DEFINE_STRINGFIELD_GETTER_FOR(name);
DEFINE_STRINGFIELD_GETTER_FOR(language);
DEFINE_STRINGFIELD_GETTER_FOR(musicclass);
+DEFINE_STRINGFIELD_GETTER_FOR(latest_musicclass);
DEFINE_STRINGFIELD_GETTER_FOR(accountcode);
DEFINE_STRINGFIELD_GETTER_FOR(peeraccount);
DEFINE_STRINGFIELD_GETTER_FOR(userfield);
@@ -644,6 +648,14 @@
void ast_channel_visible_indication_set(struct ast_channel *chan, int value)
{
chan->visible_indication = value;
+}
+int ast_channel_hold_state(const struct ast_channel *chan)
+{
+ return chan->hold_state;
+}
+void ast_channel_hold_state_set(struct ast_channel *chan, int value)
+{
+ chan->hold_state = value;
}
int ast_channel_vstreamid(const struct ast_channel *chan)
{
Modified: team/rmudgett/bridge_phase/res/res_musiconhold.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/bridge_phase/res/res_musiconhold.c?view=diff&rev=397503&r1=397502&r2=397503
==============================================================================
--- team/rmudgett/bridge_phase/res/res_musiconhold.c (original)
+++ team/rmudgett/bridge_phase/res/res_musiconhold.c Thu Aug 22 18:28:00 2013
@@ -1570,6 +1570,7 @@
}
}
+ ast_channel_latest_musicclass_set(chan, mohclass->name);
ast_set_flag(ast_channel_flags(chan), AST_FLAG_MOH);
if (mohclass->total_files) {
More information about the asterisk-commits
mailing list