Skip to content

Commit a4a6413

Browse files
committed
Add attended transfer via remote Contact URI (xferReplacesContact) - closes #237
Regenerate native libs + pjsua2 SWIG bindings from pjsip-android-builder 3.1.0, which adds Call::xferReplacesContact() (Call.java / Call_xferReplacesContact JNI). The variant builds the REFER/Replaces target from the destination dialog's remote Contact URI instead of its AOR, falling back to the AOR when no Contact is present. This keeps attended transfers reachable when the registration binding changes mid-call (network switch / NAT rebind) or behind stricter proxies. Surface it through the SipService API: - New PARAM_USE_CONTACT_URI intent extra. - attendedTransferCall(..., useContactUri) overload; the existing 4-arg overload is unchanged and keeps using the AOR (xferReplaces). - SipService dispatches to xferReplacesContact() when the flag is set.
1 parent 4a52586 commit a4a6413

9 files changed

Lines changed: 37 additions & 1 deletion

File tree

sipservice/src/main/java/net/gotev/sipservice/SipService.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,15 @@ private void handleAttendedTransferCall(Intent intent) {
446446
SipCall sipCallOrig = getCall(accountID, callIdOrig);
447447
if (sipCallOrig != null) {
448448
int callIdDest = intent.getIntExtra(PARAM_CALL_ID_DEST, 0);
449+
boolean useContactUri = intent.getBooleanExtra(PARAM_USE_CONTACT_URI, false);
449450
SipCall sipCallDest = getCall(accountID, callIdDest);
450-
sipCallOrig.xferReplaces(sipCallDest, new CallOpParam());
451+
Logger.debug(TAG, "Completing attended transfer (useContactUri=" + useContactUri + ")");
452+
// Target the remote Contact URI when requested; otherwise the AOR.
453+
if (useContactUri) {
454+
sipCallOrig.xferReplacesContact(sipCallDest, new CallOpParam());
455+
} else {
456+
sipCallOrig.xferReplaces(sipCallDest, new CallOpParam());
457+
}
451458
}
452459
} catch (Exception exc) {
453460
Logger.error(TAG, "Error while finalizing attended transfer", exc);

sipservice/src/main/java/net/gotev/sipservice/SipServiceCommand.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,13 +399,24 @@ public static void transferCall(Context context, String accountID, int callID, S
399399
* @param callIdDest call ID of the destination call
400400
*/
401401
public static void attendedTransferCall(Context context, String accountID, int callIdOrig, int callIdDest) {
402+
attendedTransferCall(context, accountID, callIdOrig, callIdDest, false);
403+
}
404+
405+
/**
406+
* Attended call transfer, selecting how the destination dialog is targeted.
407+
* @param useContactUri when true, completes via the remote Contact URI (xferReplacesContact)
408+
* instead of the AOR (xferReplaces), falling back to the AOR if the
409+
* Contact URI is unavailable.
410+
*/
411+
public static void attendedTransferCall(Context context, String accountID, int callIdOrig, int callIdDest, boolean useContactUri) {
402412
checkAccount(accountID);
403413

404414
Intent intent = new Intent(context, SipService.class);
405415
intent.setAction(ACTION_ATTENDED_TRANSFER_CALL);
406416
intent.putExtra(PARAM_ACCOUNT_ID, accountID);
407417
intent.putExtra(PARAM_CALL_ID, callIdOrig);
408418
intent.putExtra(PARAM_CALL_ID_DEST, callIdDest);
419+
intent.putExtra(PARAM_USE_CONTACT_URI, useContactUri);
409420
context.startService(intent);
410421
}
411422

0 commit comments

Comments
 (0)