Loading voip/java/com/android/server/sip/SipHelper.java +22 −8 Original line number Diff line number Diff line Loading @@ -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()); Loading @@ -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); Loading Loading @@ -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")); Loading voip/java/com/android/server/sip/SipSessionGroup.java +35 −2 Original line number Diff line number Diff line Loading @@ -119,6 +119,10 @@ class SipSessionGroup implements SipListener { private Map<String, SipSessionImpl> mSessionMap = new HashMap<String, SipSessionImpl>(); // external address observed from any response private String mExternalIp; private int mExternalPort; /** * @param myself the local profile with password crossed out * @param password the password of the profile Loading Loading @@ -175,6 +179,8 @@ class SipSessionGroup implements SipListener { mCallReceiverSession = null; mSessionMap.clear(); resetExternalAddress(); } synchronized void onConnectivityChanged() { Loading @@ -190,6 +196,12 @@ class SipSessionGroup implements SipListener { } } synchronized void resetExternalAddress() { Log.d(TAG, " reset external addr on " + mSipStack); mExternalIp = null; mExternalPort = 0; } public SipProfile getLocalProfile() { return mLocalProfile; } Loading Loading @@ -363,6 +375,21 @@ class SipSessionGroup implements SipListener { return null; } private void extractExternalAddress(ResponseEvent evt) { Response response = evt.getResponse(); ViaHeader viaHeader = (ViaHeader)(response.getHeader( SIPHeaderNames.VIA)); if (viaHeader == null) return; int rport = viaHeader.getRPort(); String externalIp = viaHeader.getReceived(); if ((rport > 0) && (externalIp != null)) { mExternalIp = externalIp; mExternalPort = rport; Log.d(TAG, " got external addr " + externalIp + ":" + rport + " on " + mSipStack); } } private class SipSessionCallReceiverImpl extends SipSessionImpl { public SipSessionCallReceiverImpl(ISipSessionListener listener) { super(listener); Loading Loading @@ -682,6 +709,7 @@ class SipSessionGroup implements SipListener { dialog = ((RequestEvent) evt).getDialog(); } else if (evt instanceof ResponseEvent) { dialog = ((ResponseEvent) evt).getDialog(); extractExternalAddress((ResponseEvent) evt); } if (dialog != null) mDialog = dialog; Loading Loading @@ -984,7 +1012,8 @@ class SipSessionGroup implements SipListener { mServerTransaction = mSipHelper.sendInviteOk(mInviteReceived, mLocalProfile, ((MakeCallCommand) evt).getSessionDescription(), mServerTransaction); mServerTransaction, mExternalIp, mExternalPort); startSessionTimer(((MakeCallCommand) evt).getTimeout()); return true; } else if (END_CALL == evt) { Loading Loading @@ -1376,6 +1405,7 @@ class SipSessionGroup implements SipListener { if (evt instanceof ResponseEvent) { if (parseOptionsResult(evt)) { if (mPortChanged) { resetExternalAddress(); stop(); } else { cancelSessionTimer(); Loading Loading @@ -1405,8 +1435,11 @@ class SipSessionGroup implements SipListener { if (!mRunning) return; if (DEBUG_PING) { String peerUri = (mPeerProfile == null) ? "null" : mPeerProfile.getUriString(); Log.d(TAG, "keepalive: " + mLocalProfile.getUriString() + " --> " + mPeerProfile + ", interval=" + mInterval); + " --> " + peerUri + ", interval=" + mInterval); } try { sendKeepAlive(); Loading Loading
voip/java/com/android/server/sip/SipHelper.java +22 −8 Original line number Diff line number Diff line Loading @@ -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()); Loading @@ -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); Loading Loading @@ -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")); Loading
voip/java/com/android/server/sip/SipSessionGroup.java +35 −2 Original line number Diff line number Diff line Loading @@ -119,6 +119,10 @@ class SipSessionGroup implements SipListener { private Map<String, SipSessionImpl> mSessionMap = new HashMap<String, SipSessionImpl>(); // external address observed from any response private String mExternalIp; private int mExternalPort; /** * @param myself the local profile with password crossed out * @param password the password of the profile Loading Loading @@ -175,6 +179,8 @@ class SipSessionGroup implements SipListener { mCallReceiverSession = null; mSessionMap.clear(); resetExternalAddress(); } synchronized void onConnectivityChanged() { Loading @@ -190,6 +196,12 @@ class SipSessionGroup implements SipListener { } } synchronized void resetExternalAddress() { Log.d(TAG, " reset external addr on " + mSipStack); mExternalIp = null; mExternalPort = 0; } public SipProfile getLocalProfile() { return mLocalProfile; } Loading Loading @@ -363,6 +375,21 @@ class SipSessionGroup implements SipListener { return null; } private void extractExternalAddress(ResponseEvent evt) { Response response = evt.getResponse(); ViaHeader viaHeader = (ViaHeader)(response.getHeader( SIPHeaderNames.VIA)); if (viaHeader == null) return; int rport = viaHeader.getRPort(); String externalIp = viaHeader.getReceived(); if ((rport > 0) && (externalIp != null)) { mExternalIp = externalIp; mExternalPort = rport; Log.d(TAG, " got external addr " + externalIp + ":" + rport + " on " + mSipStack); } } private class SipSessionCallReceiverImpl extends SipSessionImpl { public SipSessionCallReceiverImpl(ISipSessionListener listener) { super(listener); Loading Loading @@ -682,6 +709,7 @@ class SipSessionGroup implements SipListener { dialog = ((RequestEvent) evt).getDialog(); } else if (evt instanceof ResponseEvent) { dialog = ((ResponseEvent) evt).getDialog(); extractExternalAddress((ResponseEvent) evt); } if (dialog != null) mDialog = dialog; Loading Loading @@ -984,7 +1012,8 @@ class SipSessionGroup implements SipListener { mServerTransaction = mSipHelper.sendInviteOk(mInviteReceived, mLocalProfile, ((MakeCallCommand) evt).getSessionDescription(), mServerTransaction); mServerTransaction, mExternalIp, mExternalPort); startSessionTimer(((MakeCallCommand) evt).getTimeout()); return true; } else if (END_CALL == evt) { Loading Loading @@ -1376,6 +1405,7 @@ class SipSessionGroup implements SipListener { if (evt instanceof ResponseEvent) { if (parseOptionsResult(evt)) { if (mPortChanged) { resetExternalAddress(); stop(); } else { cancelSessionTimer(); Loading Loading @@ -1405,8 +1435,11 @@ class SipSessionGroup implements SipListener { if (!mRunning) return; if (DEBUG_PING) { String peerUri = (mPeerProfile == null) ? "null" : mPeerProfile.getUriString(); Log.d(TAG, "keepalive: " + mLocalProfile.getUriString() + " --> " + mPeerProfile + ", interval=" + mInterval); + " --> " + peerUri + ", interval=" + mInterval); } try { sendKeepAlive(); Loading