summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2008-11-27 12:42:07 +0000
committerBenny Prijono <bennylp@teluu.com>2008-11-27 12:42:07 +0000
commitaa39a64bb0d43467eeceecf9759473135be09751 (patch)
tree7184fa543358b6c843ebfde889ee83a5cb6800fa
parentc40accaad90c1ec16cf734e478d13247812c0e0c (diff)
More ticket #10: changed to signature of the redirection callbacks to make it more natural to use
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2371 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip-apps/src/pjsua/pjsua_app.c11
-rw-r--r--pjsip/include/pjsip-ua/sip_inv.h24
-rw-r--r--pjsip/include/pjsua-lib/pjsua.h20
-rw-r--r--pjsip/src/pjsip-ua/sip_inv.c4
-rw-r--r--pjsip/src/pjsua-lib/pjsua_call.c22
5 files changed, 44 insertions, 37 deletions
diff --git a/pjsip-apps/src/pjsua/pjsua_app.c b/pjsip-apps/src/pjsua/pjsua_app.c
index 870d0129..b3b5a98d 100644
--- a/pjsip-apps/src/pjsua/pjsua_app.c
+++ b/pjsip-apps/src/pjsua/pjsua_app.c
@@ -2393,14 +2393,13 @@ static void call_on_dtmf_callback(pjsua_call_id call_id, int dtmf)
/*
* Redirection handler.
*/
-static void call_on_redirected(pjsua_call_id call_id, const pjsip_uri *target,
- pjsip_redirect_op *cmd, const pjsip_event *e)
+static pjsip_redirect_op call_on_redirected(pjsua_call_id call_id,
+ const pjsip_uri *target,
+ const pjsip_event *e)
{
- *cmd = app_config.redir_op;
-
PJ_UNUSED_ARG(e);
- if (*cmd == PJSIP_REDIRECT_PENDING) {
+ if (app_config.redir_op == PJSIP_REDIRECT_PENDING) {
char uristr[PJSIP_MAX_URL_SIZE];
int len;
@@ -2415,6 +2414,8 @@ static void call_on_redirected(pjsua_call_id call_id, const pjsip_uri *target,
"disconnect.",
call_id, len, uristr));
}
+
+ return app_config.redir_op;
}
/*
diff --git a/pjsip/include/pjsip-ua/sip_inv.h b/pjsip/include/pjsip-ua/sip_inv.h
index 0d878573..d3d6614c 100644
--- a/pjsip/include/pjsip-ua/sip_inv.h
+++ b/pjsip/include/pjsip-ua/sip_inv.h
@@ -230,12 +230,19 @@ typedef struct pjsip_inv_callback
*
* @param inv The invite session.
* @param target The current target to be tried.
- * @param cmd Action to be performed for the target. Set this
+ * @param e The event that caused this callback to be called.
+ * This could be the receipt of 3xx response, or
+ * 4xx/5xx response received for the INVITE sent to
+ * subsequent targets, or NULL if this callback is
+ * called from within #pjsip_inv_process_redirect()
+ * context.
+ *
+ * @return Action to be performed for the target. Set this
* parameter to one of the value below:
* - PJSIP_REDIRECT_ACCEPT: immediately accept the
- * redirection (default value). When set, the
+ * redirection to this target. When set, the
* session will immediately resend INVITE request
- * to the target.
+ * to the target after this callback returns.
* - PJSIP_REDIRECT_REJECT: immediately reject this
* target. The session will continue retrying with
* next target if present, or disconnect the call
@@ -251,15 +258,10 @@ typedef struct pjsip_inv_callback
* then MUST call #pjsip_inv_process_redirect()
* to either accept or reject the redirection upon
* getting user decision.
- * @param e The event that caused this callback to be called.
- * This could be the receipt of 3xx response, or
- * 4xx/5xx response received for the INVITE sent to
- * subsequent targets, or NULL if this callback is
- * called from within #pjsip_inv_process_redirect()
- * context.
*/
- void (*on_redirected)(pjsip_inv_session *inv, const pjsip_uri *target,
- pjsip_redirect_op *cmd, const pjsip_event *e);
+ pjsip_redirect_op (*on_redirected)(pjsip_inv_session *inv,
+ const pjsip_uri *target,
+ const pjsip_event *e);
} pjsip_inv_callback;
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index efc1c188..74cbffec 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -1079,7 +1079,14 @@ typedef struct pjsua_callback
*
* @param call_id The call ID.
* @param target The current target to be tried.
- * @param cmd Action to be performed for the target. Set this
+ * @param e The event that caused this callback to be called.
+ * This could be the receipt of 3xx response, or
+ * 4xx/5xx response received for the INVITE sent to
+ * subsequent targets, or NULL if this callback is
+ * called from within #pjsua_call_process_redirect()
+ * context.
+ *
+ * @return Action to be performed for the target. Set this
* parameter to one of the value below:
* - PJSIP_REDIRECT_ACCEPT: immediately accept the
* redirection (default value). When set, the
@@ -1100,15 +1107,10 @@ typedef struct pjsua_callback
* then MUST call #pjsua_call_process_redirect()
* to either accept or reject the redirection upon
* getting user decision.
- * @param e The event that caused this callback to be called.
- * This could be the receipt of 3xx response, or
- * 4xx/5xx response received for the INVITE sent to
- * subsequent targets, or NULL if this callback is
- * called from within #pjsua_call_process_redirect()
- * context.
*/
- void (*on_call_redirected)(pjsua_call_id call_id, const pjsip_uri *target,
- pjsip_redirect_op *cmd, const pjsip_event *e);
+ pjsip_redirect_op (*on_call_redirected)(pjsua_call_id call_id,
+ const pjsip_uri *target,
+ const pjsip_event *e);
} pjsua_callback;
diff --git a/pjsip/src/pjsip-ua/sip_inv.c b/pjsip/src/pjsip-ua/sip_inv.c
index 46872f06..e1bcd0df 100644
--- a/pjsip/src/pjsip-ua/sip_inv.c
+++ b/pjsip/src/pjsip-ua/sip_inv.c
@@ -1937,7 +1937,7 @@ PJ_DEF(pj_status_t) pjsip_inv_end_session( pjsip_inv_session *inv,
static pj_bool_t inv_uac_recurse(pjsip_inv_session *inv, int code,
const pj_str_t *reason, pjsip_event *e)
{
- pjsip_redirect_op op = PJSIP_REDIRECT_ACCEPT;
+ pjsip_redirect_op op;
pjsip_target *target;
/* Won't redirect if the callback is not implemented. */
@@ -1980,7 +1980,7 @@ static pj_bool_t inv_uac_recurse(pjsip_inv_session *inv, int code,
*/
pjsip_target_set_set_current(&inv->dlg->target_set, target);
- (*mod_inv.cb.on_redirected)(inv, target->uri, &op, e);
+ op = (*mod_inv.cb.on_redirected)(inv, target->uri, e);
/* Check what the application wants to do now */
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c
index 6831487d..5b6b8e66 100644
--- a/pjsip/src/pjsua-lib/pjsua_call.c
+++ b/pjsip/src/pjsua-lib/pjsua_call.c
@@ -68,10 +68,9 @@ static void pjsua_call_on_tsx_state_changed(pjsip_inv_session *inv,
/*
* Redirection handler.
*/
-static void pjsua_call_on_redirected(pjsip_inv_session *inv,
- const pjsip_uri *target,
- pjsip_redirect_op *cmd,
- const pjsip_event *e);
+static pjsip_redirect_op pjsua_call_on_redirected(pjsip_inv_session *inv,
+ const pjsip_uri *target,
+ const pjsip_event *e);
/* Create SDP for call hold. */
@@ -3814,25 +3813,28 @@ static void pjsua_call_on_tsx_state_changed(pjsip_inv_session *inv,
/* Redirection handler */
-static void pjsua_call_on_redirected(pjsip_inv_session *inv,
- const pjsip_uri *target,
- pjsip_redirect_op *cmd,
- const pjsip_event *e)
+static pjsip_redirect_op pjsua_call_on_redirected(pjsip_inv_session *inv,
+ const pjsip_uri *target,
+ const pjsip_event *e)
{
pjsua_call *call = (pjsua_call*) inv->dlg->mod_data[pjsua_var.mod.id];
+ pjsip_redirect_op op;
PJSUA_LOCK();
if (pjsua_var.ua_cfg.cb.on_call_redirected) {
- (*pjsua_var.ua_cfg.cb.on_call_redirected)(call->index, target, cmd, e);
+ op = (*pjsua_var.ua_cfg.cb.on_call_redirected)(call->index,
+ target, e);
} else {
PJ_LOG(4,(THIS_FILE, "Unhandled redirection for call %d "
"(callback not implemented by application). Disconnecting "
"call.",
call->index));
- *cmd = PJSIP_REDIRECT_STOP;
+ op = PJSIP_REDIRECT_STOP;
}
PJSUA_UNLOCK();
+
+ return op;
}