diff options
author | Hung-ying Tyan <tyanh@google.com> | 2010-08-18 14:37:59 +0800 |
---|---|---|
committer | Hung-ying Tyan <tyanh@google.com> | 2010-08-24 17:54:47 +0800 |
commit | 3294d44b96f63f647fba3a03604eb028e28a42bc (patch) | |
tree | f6e4ed0b30c0edb0e681f39eef43292da250148a /voip | |
parent | a83987d2ccc6b235dd3dd5cc6206c257dfe9e0a8 (diff) | |
download | frameworks_base-3294d44b96f63f647fba3a03604eb028e28a42bc.zip frameworks_base-3294d44b96f63f647fba3a03604eb028e28a42bc.tar.gz frameworks_base-3294d44b96f63f647fba3a03604eb028e28a42bc.tar.bz2 |
Add confcall management to SIP calls
and fix the bug of re-assigning connectTime's in SipConnection,
and adding synchronization for SipPhone to be thread-safe,
and set normal audio mode when call not on hold instead of on hold in SipAudioCallImpl,
and fix re-entrance problem in CallManager.setAudioMode() for in-call mode.
Change-Id: I54f39dab052062de1ce141e5358d892d30453a3a
Diffstat (limited to 'voip')
-rw-r--r-- | voip/java/android/net/sip/SipAudioCall.java | 12 | ||||
-rw-r--r-- | voip/java/android/net/sip/SipAudioCallImpl.java | 51 |
2 files changed, 45 insertions, 18 deletions
diff --git a/voip/java/android/net/sip/SipAudioCall.java b/voip/java/android/net/sip/SipAudioCall.java index f4be839..3cdd114 100644 --- a/voip/java/android/net/sip/SipAudioCall.java +++ b/voip/java/android/net/sip/SipAudioCall.java @@ -244,7 +244,8 @@ public interface SipAudioCall { * 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. + * {@link #close} method is called. If a group object is set by + * {@link #setAudioGroup(AudioGroup)}, then this method returns that object. * * @return the {@link AudioGroup} object or null if the RTP stream has not * yet been set up @@ -253,6 +254,15 @@ public interface SipAudioCall { AudioGroup getAudioGroup(); /** + * Sets the {@link AudioGroup} object which the {@link AudioStream} object + * joins. If {@code audioGroup} is null, then the {@code AudioGroup} object + * will be dynamically created when needed. + * + * @see #getAudioStream + */ + void setAudioGroup(AudioGroup audioGroup); + + /** * Checks if the call is established. * * @return true if the call is established diff --git a/voip/java/android/net/sip/SipAudioCallImpl.java b/voip/java/android/net/sip/SipAudioCallImpl.java index 7161309..b8ac6d7 100644 --- a/voip/java/android/net/sip/SipAudioCallImpl.java +++ b/voip/java/android/net/sip/SipAudioCallImpl.java @@ -70,7 +70,8 @@ public class SipAudioCallImpl extends SipSessionAdapter private ISipSession mSipSession; private SdpSessionDescription mPeerSd; - private AudioStream mRtpSession; + private AudioStream mAudioStream; + private AudioGroup mAudioGroup; private SdpSessionDescription.AudioCodec mCodec; private long mSessionId = -1L; // SDP session ID private boolean mInCall = false; @@ -505,11 +506,19 @@ public class SipAudioCallImpl extends SipSessionAdapter } public synchronized AudioStream getAudioStream() { - return mRtpSession; + return mAudioStream; } public synchronized AudioGroup getAudioGroup() { - return ((mRtpSession == null) ? null : mRtpSession.getAudioGroup()); + if (mAudioGroup != null) return mAudioGroup; + return ((mAudioStream == null) ? null : mAudioStream.getAudioGroup()); + } + + public synchronized void setAudioGroup(AudioGroup group) { + if ((mAudioStream != null) && (mAudioStream.getAudioGroup() != null)) { + mAudioStream.join(group); + } + mAudioGroup = group; } private SdpSessionDescription.AudioCodec getCodec(SdpSessionDescription sd) { @@ -561,7 +570,7 @@ public class SipAudioCallImpl extends SipSessionAdapter // TODO: get sample rate from sdp mCodec = getCodec(peerSd); - AudioStream audioStream = mRtpSession; + AudioStream audioStream = mAudioStream; audioStream.associate(InetAddress.getByName(peerMediaAddress), peerMediaPort); audioStream.setCodec(convert(mCodec), mCodec.payloadType); @@ -580,7 +589,7 @@ public class SipAudioCallImpl extends SipSessionAdapter Log.d(TAG, " not sending"); audioStream.setMode(RtpStream.MODE_RECEIVE_ONLY); } - } else { + /* The recorder volume will be very low if the device is in * IN_CALL mode. Therefore, we have to set the mode to NORMAL * in order to have the normal microphone level. @@ -590,14 +599,22 @@ public class SipAudioCallImpl extends SipSessionAdapter .setMode(AudioManager.MODE_NORMAL); } - AudioGroup audioGroup = new AudioGroup(); - audioStream.join(audioGroup); + // AudioGroup logic: + AudioGroup audioGroup = getAudioGroup(); if (mHold) { - audioGroup.setMode(AudioGroup.MODE_ON_HOLD); - } else if (mMuted) { - audioGroup.setMode(AudioGroup.MODE_MUTED); + if (audioGroup != null) { + audioGroup.setMode(AudioGroup.MODE_ON_HOLD); + } + // don't create an AudioGroup here; doing so will fail if + // there's another AudioGroup out there that's active } else { - audioGroup.setMode(AudioGroup.MODE_NORMAL); + if (audioGroup == null) audioGroup = new AudioGroup(); + audioStream.join(audioGroup); + if (mMuted) { + audioGroup.setMode(AudioGroup.MODE_MUTED); + } else { + audioGroup.setMode(AudioGroup.MODE_NORMAL); + } } } catch (Exception e) { Log.e(TAG, "call()", e); @@ -606,20 +623,20 @@ public class SipAudioCallImpl extends SipSessionAdapter private void stopCall(boolean releaseSocket) { Log.d(TAG, "stop audiocall"); - if (mRtpSession != null) { - mRtpSession.join(null); + if (mAudioStream != null) { + mAudioStream.join(null); if (releaseSocket) { - mRtpSession.release(); - mRtpSession = null; + mAudioStream.release(); + mAudioStream = null; } } } private int getLocalMediaPort() { - if (mRtpSession != null) return mRtpSession.getLocalPort(); + if (mAudioStream != null) return mAudioStream.getLocalPort(); try { - AudioStream s = mRtpSession = + AudioStream s = mAudioStream = new AudioStream(InetAddress.getByName(getLocalIp())); return s.getLocalPort(); } catch (IOException e) { |