[asterisk-commits] file: branch file/issue12713 r185955 - in /team/file/issue12713: channels/ in...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Apr 2 08:52:49 CDT 2009
Author: file
Date: Thu Apr 2 08:52:45 2009
New Revision: 185955
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=185955
Log:
Add the capability for a channel driver to give a true or success failure indication when a transfer is requested.
This was done by adding a new control frame type that the channel driver queues up. This code makes no attempt to time out
though if the channel driver does not queue it up, so any channel driver that supports the Transfer() application has to
have this implemented.
Modified:
team/file/issue12713/channels/chan_iax2.c
team/file/issue12713/channels/chan_sip.c
team/file/issue12713/include/asterisk/frame.h
team/file/issue12713/main/channel.c
Modified: team/file/issue12713/channels/chan_iax2.c
URL: http://svn.digium.com/svn-view/asterisk/team/file/issue12713/channels/chan_iax2.c?view=diff&rev=185955&r1=185954&r2=185955
==============================================================================
--- team/file/issue12713/channels/chan_iax2.c (original)
+++ team/file/issue12713/channels/chan_iax2.c Thu Apr 2 08:52:45 2009
@@ -4413,6 +4413,7 @@
unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
struct iax_ie_data ied = { "", };
char tmp[256], *context;
+ enum ast_control_transfer message = AST_TRANSFER_SUCCESS;
ast_copy_string(tmp, dest, sizeof(tmp));
context = strchr(tmp, '@');
if (context) {
@@ -4423,6 +4424,7 @@
if (context)
iax_ie_append_str(&ied, IAX_IE_CALLED_CONTEXT, context);
ast_debug(1, "Transferring '%s' to '%s'\n", c->name, dest);
+ ast_queue_control_data(c, AST_CONTROL_TRANSFER, &message, sizeof(message));
return send_command_locked(callno, AST_FRAME_IAX, IAX_COMMAND_TRANSFER, 0, ied.buf, ied.pos, -1);
}
Modified: team/file/issue12713/channels/chan_sip.c
URL: http://svn.digium.com/svn-view/asterisk/team/file/issue12713/channels/chan_sip.c?view=diff&rev=185955&r1=185954&r2=185955
==============================================================================
--- team/file/issue12713/channels/chan_sip.c (original)
+++ team/file/issue12713/channels/chan_sip.c Thu Apr 2 08:52:45 2009
@@ -18023,7 +18023,11 @@
if (!success) {
ast_log(LOG_NOTICE, "Transfer failed. Sorry. Nothing further to do with this call\n");
}
-
+
+ if (p->owner) {
+ enum ast_control_transfer message = success ? AST_TRANSFER_SUCCESS : AST_TRANSFER_FAILED;
+ ast_queue_control_data(p->owner, AST_CONTROL_TRANSFER, &message, sizeof(message));
+ }
/* Confirm that we received this packet */
transmit_response(p, "200 OK", req);
} else if (p->mwi && !strcmp(event, "message-summary")) {
Modified: team/file/issue12713/include/asterisk/frame.h
URL: http://svn.digium.com/svn-view/asterisk/team/file/issue12713/include/asterisk/frame.h?view=diff&rev=185955&r1=185954&r2=185955
==============================================================================
--- team/file/issue12713/include/asterisk/frame.h (original)
+++ team/file/issue12713/include/asterisk/frame.h Thu Apr 2 08:52:45 2009
@@ -319,6 +319,7 @@
AST_CONTROL_VIDUPDATE = 18, /*!< Indicate video frame update */
AST_CONTROL_T38 = 19, /*!< T38 state change request/notification */
AST_CONTROL_SRCUPDATE = 20, /*!< Indicate source of media has changed */
+ AST_CONTROL_TRANSFER = 21, /*!< Indicate status of a transfer request */
};
enum ast_control_t38 {
@@ -327,6 +328,11 @@
AST_T38_NEGOTIATED, /*!< T38 negotiated (fax mode) */
AST_T38_TERMINATED, /*!< T38 terminated (back to voice) */
AST_T38_REFUSED /*!< T38 refused for some reason (usually rejected by remote end) */
+};
+
+enum ast_control_transfer {
+ AST_TRANSFER_SUCCESS = 0, /*!< Transfer request on the channel worked */
+ AST_TRANSFER_FAILED, /*!< Transfer request on the channel failed */
};
#define AST_SMOOTHER_FLAG_G729 (1 << 0)
Modified: team/file/issue12713/main/channel.c
URL: http://svn.digium.com/svn-view/asterisk/team/file/issue12713/main/channel.c?view=diff&rev=185955&r1=185954&r2=185955
==============================================================================
--- team/file/issue12713/main/channel.c (original)
+++ team/file/issue12713/main/channel.c Thu Apr 2 08:52:45 2009
@@ -2994,6 +2994,7 @@
case AST_CONTROL_ANSWER:
case AST_CONTROL_HANGUP:
case AST_CONTROL_T38:
+ case AST_CONTROL_TRANSFER:
return 0;
case AST_CONTROL_CONGESTION:
@@ -3080,6 +3081,7 @@
case AST_CONTROL_HOLD:
case AST_CONTROL_UNHOLD:
case AST_CONTROL_T38:
+ case AST_CONTROL_TRANSFER:
/* Nothing left to do for these. */
res = 0;
break;
@@ -3759,6 +3761,37 @@
res = 0;
}
ast_channel_unlock(chan);
+
+ if (res < 0) {
+ return res;
+ }
+
+ for (;;) {
+ struct ast_frame *fr;
+
+ res = ast_waitfor(chan, -1);
+
+ if (res < 0 || !(fr = ast_read(chan))) {
+ res = -1;
+ break;
+ }
+
+ if (fr->frametype == AST_FRAME_CONTROL && fr->subclass == AST_CONTROL_TRANSFER) {
+ enum ast_control_transfer *message = fr->data.ptr;
+
+ if (*message == AST_TRANSFER_SUCCESS) {
+ res = 1;
+ } else {
+ res = -1;
+ }
+
+ ast_frfree(fr);
+ break;
+ }
+
+ ast_frfree(fr);
+ }
+
return res;
}
More information about the asterisk-commits
mailing list