summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChung-yih Wang <cywang@google.com>2010-07-22 01:40:01 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-07-22 01:40:01 -0700
commite5545a697c39fa611fb4cc93fba447a91828436c (patch)
tree9c22e169e04f39933976864d567f24290a127e97
parent9e0897705e979998e4d446136dd066c97580bb0c (diff)
parent5854d60d69498dd4004c1627a7556661e3cc639c (diff)
downloadnist-sip-e5545a697c39fa611fb4cc93fba447a91828436c.tar.gz
Merge changes I9adc67d2,I32dd22af
* changes: SIP: fix a recursion bug when local IP becomes invalid (network disconnected). SIP telephony: integrate with new RTP stack and other fixes.
-rw-r--r--phone/src2/com/android/internal/telephony/sip/SipCallBase.java2
-rwxr-xr-xphone/src2/com/android/internal/telephony/sip/SipPhone.java168
-rw-r--r--src/android/net/sip/SipAudioCall.java38
-rw-r--r--src/com/android/sip/FLog.java2
-rw-r--r--src/com/android/sip/SipAudioCallImpl.java120
-rw-r--r--src/com/android/sip/SipServiceImpl.java2
-rw-r--r--src/com/android/sip/SipSessionListenerProxy.java22
7 files changed, 229 insertions, 125 deletions
diff --git a/phone/src2/com/android/internal/telephony/sip/SipCallBase.java b/phone/src2/com/android/internal/telephony/sip/SipCallBase.java
index 67f72d3..e7eda4f 100644
--- a/phone/src2/com/android/internal/telephony/sip/SipCallBase.java
+++ b/phone/src2/com/android/internal/telephony/sip/SipCallBase.java
@@ -92,7 +92,7 @@ abstract class SipCallBase extends Call {
return connections.size() == MAX_CONNECTIONS_PER_CALL;
}
- protected void clearDisconnected() {
+ void clearDisconnected() {
for (Iterator<Connection> it = connections.iterator(); it.hasNext(); ) {
Connection c = it.next();
if (c.getState() == State.DISCONNECTED) it.remove();
diff --git a/phone/src2/com/android/internal/telephony/sip/SipPhone.java b/phone/src2/com/android/internal/telephony/sip/SipPhone.java
index 49fe7db..1af5200 100755
--- a/phone/src2/com/android/internal/telephony/sip/SipPhone.java
+++ b/phone/src2/com/android/internal/telephony/sip/SipPhone.java
@@ -20,6 +20,7 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
+import android.net.rtp.AudioGroup;
import android.net.sip.SipAudioCall;
import android.net.sip.SipManager;
import android.net.sip.SipProfile;
@@ -211,10 +212,6 @@ public class SipPhone extends SipPhoneBase {
}
}
- private void switchWaitingOrHoldingAndActive() {
- // TODO
- }
-
public boolean canConference() {
//TODO
//return mCT.canConference();
@@ -321,8 +318,6 @@ public class SipPhone extends SipPhoneBase {
}
private class SipCall extends SipCallBase {
- SipAudioCall mSipAudioCall;
-
void switchWith(SipCall that) {
synchronized (SipPhone.class) {
SipCall tmp = new SipCall();
@@ -335,16 +330,17 @@ public class SipPhone extends SipPhoneBase {
private void takeOver(SipCall that) {
connections = that.connections;
state = that.state;
- mSipAudioCall = that.mSipAudioCall;
for (Connection c : connections) {
((SipConnection) c).changeOwner(this);
}
}
+ @Override
public Phone getPhone() {
return SipPhone.this;
}
+ @Override
public List<Connection> getConnections() {
synchronized (SipPhone.class) {
// FIXME should return Collections.unmodifiableList();
@@ -352,14 +348,13 @@ public class SipPhone extends SipPhoneBase {
}
}
- public Connection dial(String calleeSipUri) throws SipException {
+ Connection dial(String calleeSipUri) throws SipException {
try {
SipProfile callee =
new SipProfile.Builder(calleeSipUri).build();
SipConnection c = new SipConnection(this, callee);
connections.add(c);
c.dial();
- mSipAudioCall = c.mSipAudioCall;
setState(Call.State.DIALING);
return c;
} catch (ParseException e) {
@@ -370,6 +365,7 @@ public class SipPhone extends SipPhoneBase {
// TODO: if this is the foreground call and a background call exists,
// resume the background call
+ @Override
public void hangup() throws CallStateException {
Log.v(LOG_TAG, "hang up call: " + getState() + ": " + this
+ " on phone " + getPhone());
@@ -385,8 +381,7 @@ public class SipPhone extends SipPhoneBase {
setState(State.DISCONNECTING);
}
- public void take(SipAudioCall sipAudioCall, boolean makeCallWait) {
- mSipAudioCall = sipAudioCall;
+ void take(SipAudioCall sipAudioCall, boolean makeCallWait) {
SipProfile callee = sipAudioCall.getPeerProfile();
SipConnection c = new SipConnection(this, callee);
connections.add(c);
@@ -398,61 +393,74 @@ public class SipPhone extends SipPhoneBase {
notifyNewRingingConnectionP(c);
}
- public void rejectCall() throws CallStateException {
+ void rejectCall() throws CallStateException {
hangup();
}
- public void acceptCall() throws CallStateException {
- try {
- mSipAudioCall.answerCall();
- } catch (SipException e) {
- throw new CallStateException("acceptCall(): " + e);
+ void acceptCall() throws CallStateException {
+ if (this != foregroundCall) {
+ throw new CallStateException("acceptCall() in a non-fg call");
+ }
+ if (connections.size() != 1) {
+ throw new CallStateException("acceptCall() in a conf call");
}
+ ((SipConnection) connections.get(0)).acceptCall();
}
- public void hold() {
- if (mSipAudioCall == null) return;
- try {
- mSipAudioCall.holdCall();
- setState(State.HOLDING);
- } catch (SipException e) {
- // FIXME: ignore?
- }
+ void hold() throws CallStateException {
+ AudioGroup audioGroup = getAudioGroup();
+ if (audioGroup == null) return;
+ audioGroup.setMode(AudioGroup.MODE_ON_HOLD);
+ setState(State.HOLDING);
+ for (Connection c : connections) ((SipConnection) c).hold();
}
- public void unhold() {
- if (mSipAudioCall == null) return;
- try {
- mSipAudioCall.continueCall();
- setState(State.ACTIVE);
- } catch (SipException e) {
- // FIXME: ignore?
- }
+ void unhold() throws CallStateException {
+ AudioGroup audioGroup = getAudioGroup();
+ if (audioGroup == null) return;
+ audioGroup.setMode(AudioGroup.MODE_NORMAL);
+ setState(State.ACTIVE);
+ for (Connection c : connections) ((SipConnection) c).unhold();
}
- public void setMute(boolean muted) {
- if (mSipAudioCall == null) return;
- if (mSipAudioCall.isMuted() != muted) {
- mSipAudioCall.toggleMute();
- }
+ void setMute(boolean muted) {
+ AudioGroup audioGroup = getAudioGroup();
+ if (audioGroup == null) return;
+ audioGroup.setMode(
+ muted ? AudioGroup.MODE_MUTED : AudioGroup.MODE_NORMAL);
}
- public boolean getMute() {
- if (mSipAudioCall == null) return false;
- return mSipAudioCall.isMuted();
+ boolean getMute() {
+ AudioGroup audioGroup = getAudioGroup();
+ if (audioGroup == null) return false;
+ return (audioGroup.getMode() == AudioGroup.MODE_MUTED);
}
- public void sendDtmf(char c) {
- if (mSipAudioCall != null) {
- mSipAudioCall.sendDtmf((int) (c - '0'));
- }
+ void sendDtmf(char c) {
+ AudioGroup audioGroup = getAudioGroup();
+ if (audioGroup == null) return;
+ audioGroup.sendDtmf(convertDtmf(c));
}
- protected void clearDisconnected() {
- super.clearDisconnected();
- if (state == State.IDLE) mSipAudioCall = null;
+ private int convertDtmf(char c) {
+ int code = c - '0';
+ if ((code < 0) || (code > 9)) {
+ switch (c) {
+ case '*': return 10;
+ case '#': return 11;
+ case 'A': return 12;
+ case 'B': return 13;
+ case 'C': return 14;
+ case 'D': return 15;
+ default:
+ throw new IllegalArgumentException(
+ "invalid DTMF char: " + (int) c);
+ }
+ }
+ return code;
}
+ @Override
protected void setState(State newState) {
if (state != newState) {
Log.v(LOG_TAG, "++******++ call state changed: " + state
@@ -471,14 +479,14 @@ public class SipPhone extends SipPhoneBase {
}
}
- private void onConnectionStateChanged(SipConnection conn) {
+ void onConnectionStateChanged(SipConnection conn) {
// this can be called back when a conf call is formed
if (state != State.ACTIVE) {
setState(conn.getState());
}
}
- private void onConnectionEnded(SipConnection conn) {
+ void onConnectionEnded(SipConnection conn) {
// set state to DISCONNECTED only when all conns are disconnected
if (state != State.DISCONNECTED) {
boolean allConnectionsDisconnected = true;
@@ -492,6 +500,11 @@ public class SipPhone extends SipPhoneBase {
}
notifyDisconnectP(conn);
}
+
+ private AudioGroup getAudioGroup() {
+ if (connections.isEmpty()) return null;
+ return ((SipConnection) connections.get(0)).getAudioGroup();
+ }
}
private class SipConnection extends SipConnectionBase {
@@ -502,6 +515,7 @@ public class SipPhone extends SipPhoneBase {
private boolean mIncoming = false;
private SipAudioCallAdapter mAdapter = new SipAudioCallAdapter() {
+ @Override
protected void onCallEnded(DisconnectCause cause) {
if (getDisconnectCause() != DisconnectCause.LOCAL) {
setDisconnectCause(cause);
@@ -517,6 +531,7 @@ public class SipPhone extends SipPhoneBase {
}
}
+ @Override
public void onChanged(SipAudioCall call) {
synchronized (SipPhone.class) {
Call.State newState = getCallStateFrom(call);
@@ -540,17 +555,54 @@ public class SipPhone extends SipPhoneBase {
mPeer = callee;
}
- public void take(SipAudioCall sipAudioCall, Call.State newState) {
+ void take(SipAudioCall sipAudioCall, Call.State newState) {
mState = newState;
mSipAudioCall = sipAudioCall;
sipAudioCall.setListener(mAdapter); // call back to set state
mIncoming = true;
}
- public void changeOwner(SipCall owner) {
+ void acceptCall() throws CallStateException {
+ try {
+ mSipAudioCall.answerCall();
+ } catch (SipException e) {
+ throw new CallStateException("acceptCall(): " + e);
+ }
+ }
+
+ void changeOwner(SipCall owner) {
mOwner = owner;
}
+ AudioGroup getAudioGroup() {
+ if (mSipAudioCall == null) return null;
+ return mSipAudioCall.getAudioGroup();
+ }
+
+ void dial() throws SipException {
+ mState = Call.State.DIALING;
+ mSipAudioCall = mSipManager.makeAudioCall(mContext, mProfile,
+ mPeer, null);
+ mSipAudioCall.setRingbackToneEnabled(false);
+ mSipAudioCall.setListener(mAdapter);
+ }
+
+ void hold() throws CallStateException {
+ try {
+ mSipAudioCall.holdCall();
+ } catch (SipException e) {
+ throw new CallStateException("hold(): " + e);
+ }
+ }
+
+ void unhold() throws CallStateException {
+ try {
+ mSipAudioCall.continueCall();
+ } catch (SipException e) {
+ throw new CallStateException("unhold(): " + e);
+ }
+ }
+
@Override
public Call.State getState() {
return mState;
@@ -566,14 +618,6 @@ public class SipPhone extends SipPhoneBase {
return mPeer.getUriString();
}
- public void dial() throws SipException {
- mState = Call.State.DIALING;
- mSipAudioCall = mSipManager.makeAudioCall(mContext, mProfile,
- mPeer, null);
- mSipAudioCall.setRingbackToneEnabled(false);
- mSipAudioCall.setListener(mAdapter);
- }
-
@Override
public SipCall getCall() {
return mOwner;
@@ -632,6 +676,7 @@ public class SipPhone extends SipPhoneBase {
}
private static Call.State getCallStateFrom(SipAudioCall sipAudioCall) {
+ if (sipAudioCall.isOnHold()) return Call.State.HOLDING;
SipSessionState sessionState = sipAudioCall.getState();
switch (sessionState) {
case READY_TO_CALL: return Call.State.IDLE;
@@ -652,14 +697,17 @@ public class SipPhone extends SipPhoneBase {
protected abstract void onCallEnded(Connection.DisconnectCause cause);
+ @Override
public void onCallEnded(SipAudioCall call) {
onCallEnded(Connection.DisconnectCause.NORMAL);
}
+ @Override
public void onCallBusy(SipAudioCall call) {
onCallEnded(Connection.DisconnectCause.BUSY);
}
+ @Override
public void onError(SipAudioCall call, String errorMessage) {
mError = new SipException(errorMessage);
// FIXME: specify error
diff --git a/src/android/net/sip/SipAudioCall.java b/src/android/net/sip/SipAudioCall.java
index 79f4481..abdc9d7 100644
--- a/src/android/net/sip/SipAudioCall.java
+++ b/src/android/net/sip/SipAudioCall.java
@@ -16,6 +16,8 @@
package android.net.sip;
+import android.net.rtp.AudioGroup;
+import android.net.rtp.AudioStream;
import android.os.Message;
import javax.sip.SipException;
@@ -174,13 +176,19 @@ public interface SipAudioCall {
/** Ends a call. */
void endCall() throws SipException;
- /** Puts a call on hold. */
+ /**
+ * Puts a call on hold. When succeeds,
+ * {@link #Listener#onCallHeld(SipAudioCall)} is called.
+ */
void holdCall() throws SipException;
/** Answers a call. */
void answerCall() throws SipException;
- /** Continues a call that's on hold. */
+ /**
+ * Continues a call that's on hold. When succeeds,
+ * {@link #Listener#onCallEstablished(SipAudioCall)} is called.
+ */
void continueCall() throws SipException;
/** Puts the device to in-call mode. */
@@ -222,6 +230,32 @@ public interface SipAudioCall {
void sendDtmf(int code, Message result);
/**
+ * Gets the {@link AudioStream} object used in this call. The object
+ * represents the RTP stream that carries the audio data to and from the
+ * peer. The object may not be created before the call is established. And
+ * it is undefined after the call ends or the {@link #close} method is
+ * called.
+ *
+ * @return the {@link AudioStream} object or null if the RTP stream has not
+ * yet been set up
+ */
+ AudioStream getAudioStream();
+
+ /**
+ * Gets the {@link AudioGroup} object which the {@link AudioStream} object
+ * joins. The group object may not exist before the call is established.
+ * Also, the {@code AudioStream} may change its group during a call (e.g.,
+ * after the call is held/un-held). Finally, the {@code AudioGroup} object
+ * returned by this method is undefined after the call ends or the
+ * {@link #close} method is called.
+ *
+ * @return the {@link AudioGroup} object or null if the RTP stream has not
+ * yet been set up
+ * @see #getAudioStream
+ */
+ AudioGroup getAudioGroup();
+
+ /**
* Checks if the call is established.
*
* @return true if the call is established
diff --git a/src/com/android/sip/FLog.java b/src/com/android/sip/FLog.java
index 2cc1827..460d759 100644
--- a/src/com/android/sip/FLog.java
+++ b/src/com/android/sip/FLog.java
@@ -58,6 +58,7 @@ class FLog {
}
static synchronized void write(String type, String tag, String msg) {
+ if (writer == null) return;
try {
writer.println(String.format("%s %s %s| %s| %s", type,
getDate(), getTime(), tag, msg));
@@ -69,6 +70,7 @@ class FLog {
static synchronized void write(String type, String tag, String msg,
Throwable t) {
+ if (writer == null) return;
try {
writer.println(String.format("%s %s| %s| %s", type,
getDate(), getTime(), tag, msg));
diff --git a/src/com/android/sip/SipAudioCallImpl.java b/src/com/android/sip/SipAudioCallImpl.java
index 15fc726..ffecb16 100644
--- a/src/com/android/sip/SipAudioCallImpl.java
+++ b/src/com/android/sip/SipAudioCallImpl.java
@@ -18,16 +18,16 @@ package com.android.sip;
import gov.nist.javax.sdp.fields.SDPKeywords;
-import com.android.sip.rtp.AudioCodec;
-import com.android.sip.rtp.AudioStream;
-import com.android.sip.rtp.RtpSocket;
-
import android.content.Context;
import android.media.AudioManager;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.media.ToneGenerator;
import android.net.Uri;
+import android.net.rtp.AudioCodec;
+import android.net.rtp.AudioGroup;
+import android.net.rtp.AudioStream;
+import android.net.rtp.RtpStream;
import android.net.sip.ISipSession;
import android.net.sip.SdpSessionDescription;
import android.net.sip.SessionDescription;
@@ -71,9 +71,7 @@ public class SipAudioCallImpl extends SipSessionAdapter
private AudioStream mRtpSession;
private SdpSessionDescription.AudioCodec mCodec;
- private RtpSocket mMediaSocket;
private long mSessionId = -1L; // SDP session ID
- private boolean mChangingSession = false;
private boolean mInCall = false;
private boolean mMuted = false;
private boolean mHold = false;
@@ -138,7 +136,6 @@ public class SipAudioCallImpl extends SipSessionAdapter
mSipSession = null;
mInCall = false;
mHold = false;
- mChangingSession = false;
mSessionId = -1L;
}
@@ -222,7 +219,6 @@ public class SipAudioCallImpl extends SipSessionAdapter
private synchronized void establishCall(byte[] sessionDescription) {
stopRingbackTone();
stopRinging();
- mChangingSession = false;
try {
SdpSessionDescription sd =
new SdpSessionDescription(sessionDescription);
@@ -241,7 +237,11 @@ public class SipAudioCallImpl extends SipSessionAdapter
Listener listener = mListener;
if (listener != null) {
try {
- listener.onCallEstablished(SipAudioCallImpl.this);
+ if (mHold) {
+ listener.onCallHeld(SipAudioCallImpl.this);
+ } else {
+ listener.onCallEstablished(SipAudioCallImpl.this);
+ }
} catch (Throwable t) {
Log.e(TAG, "onCallEstablished()", t);
}
@@ -280,16 +280,13 @@ public class SipAudioCallImpl extends SipSessionAdapter
public void onCallChangeFailed(ISipSession session,
String className, String message) {
// TODO:
- mChangingSession = false;
}
@Override
public void onError(ISipSession session, String className,
String message) {
Log.d(TAG, "sip session error: " + className + ": " + message);
- // don't stop RTP session on SIP error
- // TODO: what to do if call is on hold
- close(false);
+ close(true);
Listener listener = mListener;
if (listener != null) {
try {
@@ -335,20 +332,23 @@ public class SipAudioCallImpl extends SipSessionAdapter
try {
stopRinging();
if (mSipSession != null) mSipSession.endCall();
+ stopCall(true);
} catch (Throwable e) {
throwSipException(e);
}
}
public synchronized void holdCall() throws SipException {
+ if (mHold) return;
try {
- if (mChangingSession) return;
- mChangingSession = true;
- mHold = true;
mSipSession.changeCall(createHoldSessionDescription());
+ mHold = true;
} catch (Throwable e) {
throwSipException(e);
}
+
+ AudioGroup audioGroup = getAudioGroup();
+ if (audioGroup != null) audioGroup.setMode(AudioGroup.MODE_ON_HOLD);
}
public synchronized void answerCall() throws SipException {
@@ -362,14 +362,16 @@ public class SipAudioCallImpl extends SipSessionAdapter
}
public synchronized void continueCall() throws SipException {
+ if (!mHold) return;
try {
- if (mChangingSession) return;
- mChangingSession = true;
mHold = false;
mSipSession.changeCall(createContinueSessionDescription());
} catch (Throwable e) {
throwSipException(e);
}
+
+ AudioGroup audioGroup = getAudioGroup();
+ if (audioGroup != null) audioGroup.setMode(AudioGroup.MODE_NORMAL);
}
private SessionDescription createOfferSessionDescription() {
@@ -456,12 +458,10 @@ public class SipAudioCallImpl extends SipSessionAdapter
}
public synchronized void toggleMute() {
- if (mRtpSession != null) {
- if (mMuted) {
- mRtpSession.startSending();
- } else {
- mRtpSession.stopSending();
- }
+ AudioGroup audioGroup = getAudioGroup();
+ if (audioGroup != null) {
+ audioGroup.setMode(
+ mMuted ? AudioGroup.MODE_NORMAL : AudioGroup.MODE_MUTED);
mMuted = !mMuted;
}
}
@@ -485,13 +485,23 @@ public class SipAudioCallImpl extends SipSessionAdapter
}
public synchronized void sendDtmf(int code, Message result) {
- if ((mSipSession != null) && (SipSessionState.IN_CALL == getState())) {
+ AudioGroup audioGroup = getAudioGroup();
+ if ((audioGroup != null) && (mSipSession != null)
+ && (SipSessionState.IN_CALL == getState())) {
Log.v(TAG, "send DTMF: " + code);
- mRtpSession.sendDtmf(code);
+ audioGroup.sendDtmf(code);
}
if (result != null) result.sendToTarget();
}
+ public synchronized AudioStream getAudioStream() {
+ return mRtpSession;
+ }
+
+ public synchronized AudioGroup getAudioGroup() {
+ return ((mRtpSession == null) ? null : mRtpSession.getAudioGroup());
+ }
+
private SdpSessionDescription.AudioCodec getCodec(SdpSessionDescription sd) {
HashMap<String, AudioCodec> acceptableCodecs =
new HashMap<String, AudioCodec>();
@@ -539,30 +549,39 @@ public class SipAudioCallImpl extends SipSessionAdapter
int frameSize = sampleRate / 50; // 160
try {
// TODO: get sample rate from sdp
- mMediaSocket.associate(InetAddress.getByName(peerMediaAddress),
- peerMediaPort);
mCodec = getCodec(peerSd);
- mRtpSession = new AudioStream(mMediaSocket);
- mRtpSession.setCodec(convert(mCodec), mCodec.payloadType);
- mRtpSession.setDtmf(DTMF);
- mRtpSession.prepare();
+
+ AudioStream audioStream = mRtpSession;
+ audioStream.associate(InetAddress.getByName(peerMediaAddress),
+ peerMediaPort);
+ audioStream.setCodec(convert(mCodec), mCodec.payloadType);
+ audioStream.setDtmfType(DTMF);
Log.d(TAG, "start media: localPort=" + localPort + ", peer="
+ peerMediaAddress + ":" + peerMediaPort);
- if (mHold) {
- Log.d(TAG, " on hold");
- mRtpSession.stopSending();
- mRtpSession.stopReceiving();
- } else {
- if (peerSd.isSending(AUDIO)) {
- Log.d(TAG, " start receiving");
- mRtpSession.startReceiving();
+
+ audioStream.setMode(RtpStream.MODE_NORMAL);
+ if (!mHold) {
+ // FIXME: won't work if peer is not sending nor receiving
+ if (!peerSd.isSending(AUDIO)) {
+ Log.d(TAG, " not receiving");
+ audioStream.setMode(RtpStream.MODE_SEND_ONLY);
}
- if (peerSd.isReceiving(AUDIO)) {
- Log.d(TAG, " start sending");
- mRtpSession.startSending();
+ if (!peerSd.isReceiving(AUDIO)) {
+ Log.d(TAG, " not sending");
+ audioStream.setMode(RtpStream.MODE_RECEIVE_ONLY);
}
}
setInCallMode();
+
+ AudioGroup audioGroup = new AudioGroup();
+ audioStream.join(audioGroup);
+ if (mHold) {
+ audioGroup.setMode(AudioGroup.MODE_ON_HOLD);
+ } else if (mMuted) {
+ audioGroup.setMode(AudioGroup.MODE_MUTED);
+ } else {
+ audioGroup.setMode(AudioGroup.MODE_NORMAL);
+ }
} catch (Exception e) {
Log.e(TAG, "call()", e);
}
@@ -571,21 +590,22 @@ public class SipAudioCallImpl extends SipSessionAdapter
private void stopCall(boolean releaseSocket) {
Log.d(TAG, "stop audiocall");
if (mRtpSession != null) {
- mRtpSession.close();
+ mRtpSession.join(null);
+
if (releaseSocket) {
- mMediaSocket = null;
+ mRtpSession.release();
+ mRtpSession = null;
}
}
setInCallMode();
}
private int getLocalMediaPort() {
- if (mMediaSocket != null) return mMediaSocket.getLocalPort();
+ if (mRtpSession != null) return mRtpSession.getLocalPort();
try {
- RtpSocket s = mMediaSocket =
- new RtpSocket(InetAddress.getByName(getLocalIp()));
- int localPort = s.getLocalPort();
- return localPort;
+ AudioStream s = mRtpSession =
+ new AudioStream(InetAddress.getByName(getLocalIp()));
+ return s.getLocalPort();
} catch (IOException e) {
Log.w(TAG, "getLocalMediaPort(): " + e);
throw new RuntimeException(e);
diff --git a/src/com/android/sip/SipServiceImpl.java b/src/com/android/sip/SipServiceImpl.java
index baf7e4c..f926905 100644
--- a/src/com/android/sip/SipServiceImpl.java
+++ b/src/com/android/sip/SipServiceImpl.java
@@ -411,7 +411,7 @@ class SipServiceImpl extends ISipService.Stub {
// network disconnected
FLog.w(TAG, "resetGroup(): network disconnected?");
if (localIp != null) {
- resetGroup(localIp);
+ resetGroup(null); // reset w/o local IP
} else {
// recursive
Log.wtf(TAG, "impossible!");
diff --git a/src/com/android/sip/SipSessionListenerProxy.java b/src/com/android/sip/SipSessionListenerProxy.java
index c640df4..531e394 100644
--- a/src/com/android/sip/SipSessionListenerProxy.java
+++ b/src/com/android/sip/SipSessionListenerProxy.java
@@ -49,7 +49,7 @@ class SipSessionListenerProxy extends ISipSessionListener.Stub {
try {
mListener.onCalling(session);
} catch (Throwable t) {
- Log.w(TAG, "onCalling(): " + t);
+ Log.w(TAG, "onCalling()", t);
}
}
});
@@ -63,7 +63,7 @@ class SipSessionListenerProxy extends ISipSessionListener.Stub {
try {
mListener.onRinging(session, caller, sessionDescription);
} catch (Throwable t) {
- Log.w(TAG, "onRinging(): " + t);
+ Log.w(TAG, "onRinging()", t);
}
}
});
@@ -76,7 +76,7 @@ class SipSessionListenerProxy extends ISipSessionListener.Stub {
try {
mListener.onRingingBack(session);
} catch (Throwable t) {
- Log.w(TAG, "onRingingBack(): " + t);
+ Log.w(TAG, "onRingingBack()", t);
}
}
});
@@ -90,7 +90,7 @@ class SipSessionListenerProxy extends ISipSessionListener.Stub {
try {
mListener.onCallEstablished(session, sessionDescription);
} catch (Throwable t) {
- Log.w(TAG, "onCallEstablished(): " + t);
+ Log.w(TAG, "onCallEstablished()", t);
}
}
});
@@ -103,7 +103,7 @@ class SipSessionListenerProxy extends ISipSessionListener.Stub {
try {
mListener.onCallEnded(session);
} catch (Throwable t) {
- Log.w(TAG, "onCallEnded(): " + t);
+ Log.w(TAG, "onCallEnded()", t);
}
}
});
@@ -116,7 +116,7 @@ class SipSessionListenerProxy extends ISipSessionListener.Stub {
try {
mListener.onCallBusy(session);
} catch (Throwable t) {
- Log.w(TAG, "onCallBusy(): " + t);
+ Log.w(TAG, "onCallBusy()", t);
}
}
});
@@ -130,7 +130,7 @@ class SipSessionListenerProxy extends ISipSessionListener.Stub {
try {
mListener.onCallChangeFailed(session, className, message);
} catch (Throwable t) {
- Log.w(TAG, "onCallChangeFailed(): " + t);
+ Log.w(TAG, "onCallChangeFailed()", t);
}
}
});
@@ -144,7 +144,7 @@ class SipSessionListenerProxy extends ISipSessionListener.Stub {
try {
mListener.onError(session, className, message);
} catch (Throwable t) {
- Log.w(TAG, "onError(): " + t);
+ Log.w(TAG, "onError()", t);
}
}
});
@@ -157,7 +157,7 @@ class SipSessionListenerProxy extends ISipSessionListener.Stub {
try {
mListener.onRegistering(session);
} catch (Throwable t) {
- Log.w(TAG, "onRegistering(): " + t);
+ Log.w(TAG, "onRegistering()", t);
}
}
});
@@ -185,7 +185,7 @@ class SipSessionListenerProxy extends ISipSessionListener.Stub {
try {
mListener.onRegistrationFailed(session, className, message);
} catch (Throwable t) {
- Log.w(TAG, "onRegistrationFailed(): " + t);
+ Log.w(TAG, "onRegistrationFailed()", t);
}
}
});
@@ -198,7 +198,7 @@ class SipSessionListenerProxy extends ISipSessionListener.Stub {
try {
mListener.onRegistrationTimeout(session);
} catch (Throwable t) {
- Log.w(TAG, "onRegistrationTimeout(): " + t);
+ Log.w(TAG, "onRegistrationTimeout()", t);
}
}
});