summaryrefslogtreecommitdiff
path: root/voip/java/com/android/server/sip/SipHelper.java
diff options
context:
space:
mode:
authorHung-ying Tyan <tyanh@google.com>2011-06-28 19:56:19 +0800
committerHung-ying Tyan <tyanh@google.com>2011-06-28 20:05:53 +0800
commit99705b52ec952012bedc4aa8e1f62caff80a6a2f (patch)
treee0548343dd676125932839bd8acfbf1ae8e8995a /voip/java/com/android/server/sip/SipHelper.java
parentd9f10ab6fe10a4eb42bd0ed59d2abbe5816164dc (diff)
Record external IP and port from SIP responses
and use them to create the contact header when sending OK response for INVITE. Bug: 3461707 Change-Id: I5b254618f4920cf10a1460631bcd336778f344ec
Diffstat (limited to 'voip/java/com/android/server/sip/SipHelper.java')
-rw-r--r--voip/java/com/android/server/sip/SipHelper.java30
1 files changed, 22 insertions, 8 deletions
diff --git a/voip/java/com/android/server/sip/SipHelper.java b/voip/java/com/android/server/sip/SipHelper.java
index 47950e30afa8..c031bc147edd 100644
--- a/voip/java/com/android/server/sip/SipHelper.java
+++ b/voip/java/com/android/server/sip/SipHelper.java
@@ -150,9 +150,17 @@ class SipHelper {
private ContactHeader createContactHeader(SipProfile profile)
throws ParseException, SipException {
- ListeningPoint lp = getListeningPoint();
- SipURI contactURI =
- createSipUri(profile.getUserName(), profile.getProtocol(), lp);
+ return createContactHeader(profile, null, 0);
+ }
+
+ private ContactHeader createContactHeader(SipProfile profile,
+ String ip, int port) throws ParseException,
+ SipException {
+ SipURI contactURI = (ip == null)
+ ? createSipUri(profile.getUserName(), profile.getProtocol(),
+ getListeningPoint())
+ : createSipUri(profile.getUserName(), profile.getProtocol(),
+ ip, port);
Address contactAddress = mAddressFactory.createAddress(contactURI);
contactAddress.setDisplayName(profile.getDisplayName());
@@ -168,9 +176,14 @@ class SipHelper {
private SipURI createSipUri(String username, String transport,
ListeningPoint lp) throws ParseException {
- SipURI uri = mAddressFactory.createSipURI(username, lp.getIPAddress());
+ return createSipUri(username, transport, lp.getIPAddress(), lp.getPort());
+ }
+
+ private SipURI createSipUri(String username, String transport,
+ String ip, int port) throws ParseException {
+ SipURI uri = mAddressFactory.createSipURI(username, ip);
try {
- uri.setPort(lp.getPort());
+ uri.setPort(port);
uri.setTransportParam(transport);
} catch (InvalidArgumentException e) {
throw new RuntimeException(e);
@@ -353,13 +366,14 @@ class SipHelper {
*/
public ServerTransaction sendInviteOk(RequestEvent event,
SipProfile localProfile, String sessionDescription,
- ServerTransaction inviteTransaction)
- throws SipException {
+ ServerTransaction inviteTransaction, String externalIp,
+ int externalPort) throws SipException {
try {
Request request = event.getRequest();
Response response = mMessageFactory.createResponse(Response.OK,
request);
- response.addHeader(createContactHeader(localProfile));
+ response.addHeader(createContactHeader(localProfile, externalIp,
+ externalPort));
response.setContent(sessionDescription,
mHeaderFactory.createContentTypeHeader(
"application", "sdp"));