[asterisk-commits] oej: branch group/rana-moh-sip-transfer-1.8 r393701 - in /team/group/rana-moh...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jul 4 10:23:23 CDT 2013
Author: oej
Date: Thu Jul 4 10:23:21 2013
New Revision: 393701
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=393701
Log:
Mergine the code from rana-moh-queue-transfer-1.8 into this branch, as they both handle MOH issues and affects
the same part of chan_sip.
Now for combined testing
Modified:
team/group/rana-moh-sip-transfer-1.8/channels/chan_sip.c
team/group/rana-moh-sip-transfer-1.8/channels/sip/include/sip.h
team/group/rana-moh-sip-transfer-1.8/include/asterisk/musiconhold.h
team/group/rana-moh-sip-transfer-1.8/main/channel.c
team/group/rana-moh-sip-transfer-1.8/res/res_musiconhold.c
Modified: team/group/rana-moh-sip-transfer-1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/rana-moh-sip-transfer-1.8/channels/chan_sip.c?view=diff&rev=393701&r1=393700&r2=393701
==============================================================================
--- team/group/rana-moh-sip-transfer-1.8/channels/chan_sip.c (original)
+++ team/group/rana-moh-sip-transfer-1.8/channels/chan_sip.c Thu Jul 4 10:23:21 2013
@@ -23858,7 +23858,6 @@
struct ast_party_connected_line connected_to_target;
char transferer_linkedid[32];
struct ast_channel *chans[2];
- int target_chan1_mohstate = FALSE;
/* Check if the call ID of the replaces header does exist locally */
if (!(targetcall_pvt = get_sip_pvt_byid_locked(transferer->refer->replaces_callid, transferer->refer->replaces_callid_totag,
@@ -23902,8 +23901,13 @@
/* Target chan1 is running a one-legged call, maybe queue or IVR */
/* If this channel is serviced by music, we need to make sure that it
continues */
- target_chan1_mohstate = ast_test_flag(target.chan1, AST_FLAG_MOH);
- }
+ if (target.chan1) {
+ char *musicclass = ast_moh_query(target.chan1);
+ if (musicclass != NULL) {
+ ast_copy_string(target.chan1_musicclass, musicclass, sizeof (target.chan1_musicclass));
+ }
+ }
+ }
if (!target.chan2 || !(target.chan2->_state == AST_STATE_UP || target.chan2->_state == AST_STATE_RINGING) ) {
/* Wrong state of new channel */
@@ -24010,9 +24014,8 @@
if (current->chan2 && current->chan2->_state == AST_STATE_RING) {
ast_indicate(target.chan1, AST_CONTROL_RINGING);
}
- if (target_chan1_mohstate) {
- ast_debug(4, "====> Turning on music on hold again. Trying to at least \n");
- ast_moh_start(target.chan1, NULL, NULL);
+ if (!ast_strlen_zero(target.chan1_musicclass)) {
+ ast_moh_start(target.chan1, target.chan1_musicclass, target.chan1_musicclass);
}
if (target.chan2) {
Modified: team/group/rana-moh-sip-transfer-1.8/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/team/group/rana-moh-sip-transfer-1.8/channels/sip/include/sip.h?view=diff&rev=393701&r1=393700&r2=393701
==============================================================================
--- team/group/rana-moh-sip-transfer-1.8/channels/sip/include/sip.h (original)
+++ team/group/rana-moh-sip-transfer-1.8/channels/sip/include/sip.h Thu Jul 4 10:23:21 2013
@@ -790,6 +790,8 @@
uint32_t seqno; /*!< Sequence number */
char *park_exten;
char *park_context;
+ char chan1_musicclass[MAX_MUSICCLASS]; /* Music class if chan2 is one-legged and getting
+ serviced by MOH */
};
/*! \brief Parameters to the transmit_invite function */
Modified: team/group/rana-moh-sip-transfer-1.8/include/asterisk/musiconhold.h
URL: http://svnview.digium.com/svn/asterisk/team/group/rana-moh-sip-transfer-1.8/include/asterisk/musiconhold.h?view=diff&rev=393701&r1=393700&r2=393701
==============================================================================
--- team/group/rana-moh-sip-transfer-1.8/include/asterisk/musiconhold.h (original)
+++ team/group/rana-moh-sip-transfer-1.8/include/asterisk/musiconhold.h Thu Jul 4 10:23:21 2013
@@ -44,8 +44,12 @@
/*! Turn off music on hold on a given channel */
void ast_moh_stop(struct ast_channel *chan);
+/*! Query for the musicclass if MOH is active on a given channel */
+char * ast_moh_query(struct ast_channel *chan);
+
void ast_install_music_functions(int (*start_ptr)(struct ast_channel *, const char *, const char *),
void (*stop_ptr)(struct ast_channel *),
+ char * (*query_ptr)(struct ast_channel *),
void (*cleanup_ptr)(struct ast_channel *));
void ast_uninstall_music_functions(void);
Modified: team/group/rana-moh-sip-transfer-1.8/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/group/rana-moh-sip-transfer-1.8/main/channel.c?view=diff&rev=393701&r1=393700&r2=393701
==============================================================================
--- team/group/rana-moh-sip-transfer-1.8/main/channel.c (original)
+++ team/group/rana-moh-sip-transfer-1.8/main/channel.c Thu Jul 4 10:23:21 2013
@@ -7949,14 +7949,17 @@
static int (*ast_moh_start_ptr)(struct ast_channel *, const char *, const char *) = NULL;
static void (*ast_moh_stop_ptr)(struct ast_channel *) = NULL;
+static char * (*ast_moh_query_ptr)(struct ast_channel *) = NULL;
static void (*ast_moh_cleanup_ptr)(struct ast_channel *) = NULL;
void ast_install_music_functions(int (*start_ptr)(struct ast_channel *, const char *, const char *),
void (*stop_ptr)(struct ast_channel *),
+ char * (*query_ptr)(struct ast_channel *),
void (*cleanup_ptr)(struct ast_channel *))
{
ast_moh_start_ptr = start_ptr;
ast_moh_stop_ptr = stop_ptr;
+ ast_moh_query_ptr = query_ptr;
ast_moh_cleanup_ptr = cleanup_ptr;
}
@@ -7964,6 +7967,7 @@
{
ast_moh_start_ptr = NULL;
ast_moh_stop_ptr = NULL;
+ ast_moh_query_ptr = NULL;
ast_moh_cleanup_ptr = NULL;
}
@@ -7983,6 +7987,15 @@
{
if (ast_moh_stop_ptr)
ast_moh_stop_ptr(chan);
+}
+
+/*! \brief Ask for the musicclass if there's moh active on this channel */
+char *ast_moh_query(struct ast_channel *chan)
+{
+ if (ast_moh_query_ptr) {
+ return ast_moh_query_ptr(chan);
+ }
+ return NULL;
}
void ast_moh_cleanup(struct ast_channel *chan)
Modified: team/group/rana-moh-sip-transfer-1.8/res/res_musiconhold.c
URL: http://svnview.digium.com/svn/asterisk/team/group/rana-moh-sip-transfer-1.8/res/res_musiconhold.c?view=diff&rev=393701&r1=393700&r2=393701
==============================================================================
--- team/group/rana-moh-sip-transfer-1.8/res/res_musiconhold.c (original)
+++ team/group/rana-moh-sip-transfer-1.8/res/res_musiconhold.c Thu Jul 4 10:23:21 2013
@@ -1540,6 +1540,29 @@
return res;
}
+static char *local_ast_moh_query(struct ast_channel *chan)
+{
+ struct moh_files_state *state;
+
+ if (!chan) {
+ return NULL;
+ }
+ if (!ast_test_flag(chan, AST_FLAG_MOH)) {
+ ast_debug(2, "===> Not currently playing music \n");
+ return NULL;
+ }
+ ast_channel_lock(chan);
+ ast_channel_unlock(chan);
+ if (chan->music_state) {
+ state = chan->music_state;
+ if (state->class) {
+ ast_debug(2, "===> Playing music - class %s \n", state->class->name);
+ return state->class->name;
+ }
+ }
+ return NULL;
+}
+
static void local_ast_moh_stop(struct ast_channel *chan)
{
ast_clear_flag(chan, AST_FLAG_MOH);
@@ -1917,6 +1940,7 @@
"disabling music on hold.\n");
} else {
ast_install_music_functions(local_ast_moh_start, local_ast_moh_stop,
+ local_ast_moh_query,
local_ast_moh_cleanup);
}
@@ -1938,7 +1962,8 @@
static int reload(void)
{
if (load_moh_classes(1)) {
- ast_install_music_functions(local_ast_moh_start, local_ast_moh_stop,
+ ast_install_music_functions(local_ast_moh_start, local_ast_moh_stop,
+ local_ast_moh_query,
local_ast_moh_cleanup);
}
More information about the asterisk-commits
mailing list