From 1c704e8cb8fdd9dc9d02c61d37bb0f6b6d1b944e Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Mon, 1 Sep 2008 13:58:19 +0000 Subject: [PATCH] Ignore sdp process on inviteOK if we have already received it in early media. --- .../communicator/impl/media/MediaControl.java | 4 +- .../OperationSetBasicTelephonySipImpl.java | 121 +++++++++--------- 2 files changed, 66 insertions(+), 59 deletions(-) diff --git a/src/net/java/sip/communicator/impl/media/MediaControl.java b/src/net/java/sip/communicator/impl/media/MediaControl.java index 1c22680ae..6ffd9855a 100644 --- a/src/net/java/sip/communicator/impl/media/MediaControl.java +++ b/src/net/java/sip/communicator/impl/media/MediaControl.java @@ -236,13 +236,13 @@ private void initializeFormatPreferences() setEncodingPreference(SdpConstants.H261, 800); //audio + setEncodingPreference(SdpConstants.PCMU, 650); + setEncodingPreference(SdpConstants.PCMA, 600); setEncodingPreference(97, 500); setEncodingPreference(SdpConstants.GSM, 450); - setEncodingPreference(SdpConstants.PCMU, 400); setEncodingPreference(110, 350); setEncodingPreference(SdpConstants.DVI4_8000, 300); setEncodingPreference(SdpConstants.DVI4_16000, 250); - setEncodingPreference(SdpConstants.PCMA, 200); setEncodingPreference(SdpConstants.G723, 150); setEncodingPreference(SdpConstants.G728, 100); diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicTelephonySipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicTelephonySipImpl.java index 918b9fbfa..a04f23b51 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicTelephonySipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicTelephonySipImpl.java @@ -81,7 +81,7 @@ public OperationSetBasicTelephonySipImpl( /** * Create a new call and invite the specified CallParticipant to it. - * + * * @param callee the sip address of the callee that we should invite to a * new call. * @return CallParticipant the CallParticipant that will represented by the @@ -106,7 +106,7 @@ public Call createCall(String callee) /** * Create a new call and invite the specified CallParticipant to it. - * + * * @param callee the address of the callee that we should invite to a new * call. * @return CallParticipant the CallParticipant that will represented by the @@ -138,17 +138,17 @@ public Call createCall(Contact callee) throws OperationFailedException /** * Init and establish the specified call. - * + * * @param calleeAddress the address of the callee that we'd like to connect * with. - * + * * @return CallParticipant the CallParticipant that will represented by the * specified uri. All following state change events will be * delivered through that call participant. The Call that this * participant is a member of could be retrieved from the * CallParticipatn instance with the use of the corresponding * method. - * + * * @throws OperationFailedException with the corresponding code if we fail * to create the call. */ @@ -282,7 +282,7 @@ private synchronized CallSipImpl createOutgoingCall(Address calleeAddress) /** * Returns an iterator over all currently active calls. - * + * * @return an iterator over all currently active calls. */ public Iterator getActiveCalls() @@ -292,7 +292,7 @@ public Iterator getActiveCalls() /** * Resumes communication with a call participant previously put on hold. - * + * * @param participant the call participant to put on hold. * @throws OperationFailedException */ @@ -304,7 +304,7 @@ public synchronized void putOffHold(CallParticipant participant) /** * Puts the specified CallParticipant "on hold". - * + * * @param participant the participant that we'd like to put on hold. * @throws OperationFailedException */ @@ -316,7 +316,7 @@ public synchronized void putOnHold(CallParticipant participant) /** * Puts the specified CallParticipant on or off hold. - * + * * @param participant the CallParticipant to be put on or off hold * @param on true to have the specified CallParticipant * put on hold; false, otherwise @@ -375,7 +375,7 @@ else if (on) /** * Sends an invite request with a specific SDP offer (description) within * the current Dialog with a specific call participant. - * + * * @param sipParticipant the SIP-specific call participant to send the * invite to within the current Dialog * @param sdpOffer the description of the SDP offer to be made to the @@ -407,7 +407,7 @@ private void sendInviteRequest(CallParticipantSipImpl sipParticipant, * Sends a specific Request through a given * SipProvider as part of the conversation associated with a * specific Dialog. - * + * * @param sipProvider the SipProvider to send the specified * request through * @param request the Request to send through @@ -450,7 +450,7 @@ private void sendRequest(SipProvider sipProvider, Request request, * error using the current Logger and then throws a new * OperationFailedException with the message, a specific error code * and the cause. - * + * * @param message the message to be logged and then wrapped in a new * OperationFailedException * @param errorCode the error code to be assigned to the new @@ -471,7 +471,7 @@ private void throwOperationFailedException(String message, int errorCode, * Processes a Request received on a SipProvider upon which this SipListener * is registered. *

- * + * * @param requestEvent requestEvent fired from the SipProvider to the * SipListener representing a Request received from the * network. @@ -571,7 +571,7 @@ else if (requestMethod.equals(Request.NOTIFY)) /** * Process an asynchronously reported TransactionTerminatedEvent. - * + * * @param transactionTerminatedEvent -- an event that indicates that the * transaction has transitioned into the terminated state. * @return true if the specified event has been handled by this @@ -588,7 +588,7 @@ public boolean processTransactionTerminated( /** * Analyzes the incoming responseEvent and then forwards it to the * proper event handler. - * + * * @param responseEvent the responseEvent that we received * ProtocolProviderService. * @return true if the specified event has been handled by this @@ -698,7 +698,7 @@ else if (method.equals(Request.BYE)) /** * Processes a specific Response.ACCEPTED response of an * earlier Request.REFER request. - * + * * @param clientTransaction the ClientTransaction which brought * the response * @param accepted the Response.ACCEPTED response to an earlier @@ -721,7 +721,7 @@ private void processReferAccepted(ClientTransaction clientTransaction, /** * Updates the call state of the corresponding call participant. - * + * * @param clientTransaction the transaction in which the response was * received. * @param response the trying response. @@ -751,7 +751,7 @@ private void processTrying(ClientTransaction clientTransaction, * Updates the call state of the corresponding call participant. We'll also * try to extract any details here that might be of use for call participant * presentation and that we didn't have when establishing the call. - * + * * @param clientTransaction the transaction in which the response was * received. * @param response the Trying response. @@ -794,7 +794,7 @@ private void processRinging(ClientTransaction clientTransaction, * Handles early media in 183 Session Progress responses. Retrieves the SDP * and makes sure that we start transmitting and playing early media that we * receive. Puts the call into a CONNECTING_WITH_EARLY_MEDIA state. - * + * * @param clientTransaction the ClientTransaction that the response * arrived in. * @param sessionProgress the 183 Response to process @@ -894,7 +894,7 @@ private void processSessionProgress(ClientTransaction clientTransaction, /** * Sets to CONNECTED that state of the corresponding call participant and * sends an ACK. - * + * * @param clientTransaction the ClientTransaction that the response * arrived in. * @param ok the OK Response to process @@ -1001,7 +1001,10 @@ private void processInviteOK(ClientTransaction clientTransaction, // !!! set sdp content before setting call state as that is where // listeners get alerted and they need the sdp - callParticipant.setSdpDescription(new String(ok.getRawContent())); + // ignore sdp if we have already received one in early media + if(!CallParticipantState.CONNECTING_WITH_EARLY_MEDIA. + equals(callParticipant.getState())) + callParticipant.setSdpDescription(new String(ok.getRawContent())); // notify the media manager of the sdp content CallSession callSession = @@ -1050,10 +1053,14 @@ private void processInviteOK(ClientTransaction clientTransaction, return; } } + + // ignore sdp process if we have already received one in early media CallParticipantState callParticipantState = callParticipant.getState(); if ((callParticipantState != CallParticipantState.CONNECTED) - && !CallParticipantState.isOnHold(callParticipantState)) + && !CallParticipantState.isOnHold(callParticipantState) + && !CallParticipantState.CONNECTING_WITH_EARLY_MEDIA. + equals(callParticipantState)) { callSession.processSdpAnswer(callParticipant, callParticipant .getSdpDescription()); @@ -1095,7 +1102,7 @@ private void processInviteOK(ClientTransaction clientTransaction, /** * Sets corresponding state to the call participant associated with this * transaction. - * + * * @param clientTransaction the transaction in which * @param busyHere the busy here Response */ @@ -1120,7 +1127,7 @@ private void processBusyHere(ClientTransaction clientTransaction, /** * Attempts to re-generate the corresponding request with the proper * credentials and terminates the call if it fails. - * + * * @param clientTransaction the corresponding transaction * @param response the challenge * @param jainSipProvider the provider that received the challenge @@ -1186,7 +1193,7 @@ private void processAuthenticationChallenge( * server upon which the timeout occurred. The type of Timeout can by * determined by: * timeoutType = timeoutEvent.getTimeout().getValue(); - * + * * @param timeoutEvent the timeoutEvent received indicating either the * message retransmit or transaction timed out. * @return true if the specified event has been handled by this @@ -1229,7 +1236,7 @@ public boolean processTimeout(TimeoutEvent timeoutEvent) * to the application immediately (according to RFC 3261). This method * enables an implementation to propagate the asynchronous handling of IO * Exceptions to the application. - * + * * @param exceptionEvent The Exception event that is reported to the * application. * @return true if the specified event has been handled by this @@ -1245,7 +1252,7 @@ public boolean processIOException(IOExceptionEvent exceptionEvent) /** * Process an asynchronously reported DialogTerminatedEvent. - * + * * @param dialogTerminatedEvent -- an event that indicates that the dialog * has transitioned into the terminated state. * @return true if the specified event has been handled by this @@ -1271,7 +1278,7 @@ public boolean processDialogTerminated( /** * Creates an invite request destined for callee. - * + * * @param toAddress the sip address of the callee that the request is meant * for. * @return a newly created sip Request destined for callee @@ -1398,7 +1405,7 @@ private Request createInviteRequest(Address toAddress) /** * Creates a new call and sends a RINGING response. - * + * * @param sourceProvider the provider containing sourceTransaction. * @param serverTransaction the transaction containing the received request. * @param invite the Request that we've just received. @@ -1569,7 +1576,7 @@ private void processInvite(SipProvider sourceProvider, * specific Response before it is sent to a specific * CallParticipant as part of the execution of * {@link #processInvite(SipProvider, ServerTransaction, Request)}. - * + * * @param participant the CallParticipant to receive a specific * Response * @param response the Response to be sent to the @@ -1614,7 +1621,7 @@ private void processInviteSendingResponse(CallParticipant participant, * specific Response has been sent to a specific * CallParticipant as part of the execution of * {@link #processInvite(SipProvider, ServerTransaction, Request)}. - * + * * @param participant the CallParticipant who was sent a specific * Response * @param response the Response that has just been sent to the @@ -1676,7 +1683,7 @@ else if (on) /** * Sets the state of the corresponding call participant to DISCONNECTED and * sends an OK response. - * + * * @param serverTransaction the ServerTransaction the the BYE request * arrived in. * @param byeRequest the BYE request to process @@ -1751,7 +1758,7 @@ private void processBye(ServerTransaction serverTransaction, /** * Updates the session description and sends the state of the corresponding * call participant to CONNECTED. - * + * * @param serverTransaction the transaction that the Ack was received in. * @param ackRequest Request */ @@ -1782,7 +1789,7 @@ void processAck(ServerTransaction serverTransaction, Request ackRequest) /** * Sets the state of the specifies call participant as DISCONNECTED. - * + * * @param serverTransaction the transaction that the cancel was received in. * @param cancelRequest the Request that we've just received. */ @@ -1869,7 +1876,7 @@ void processCancel(ServerTransaction serverTransaction, * Processes a specific REFER request i.e. attempts to transfer the * call/call participant receiving the request to a specific transfer * target. - * + * * @param serverTransaction the ServerTransaction containing * the REFER request * @param referRequest the very REFER request @@ -2041,7 +2048,7 @@ && referToCallStateChanged(referToCallListenerSource, /** * Processes a specific Request.NOTIFY request for the purposes * of telephony. - * + * * @param serverTransaction the ServerTransaction containing * the Request.NOTIFY request * @param notifyRequest the Request.NOTIFY request to be @@ -2147,7 +2154,7 @@ private boolean processNotify(ServerTransaction serverTransaction, * session-terminating NOTIFY request to the Dialog which * referred to the call in question as soon as the outcome of the refer is * determined. - * + * * @param referToCall the Call to track and send a NOTIFY * request for * @param sendNotifyRequest true if a session-terminating NOTIFY @@ -2179,7 +2186,7 @@ private boolean referToCallStateChanged(Call referToCall, /* * NOTIFY OK/Declined - * + * * It doesn't sound like sending NOTIFY Service Unavailable is * appropriate because the REFER request has (presumably) already been * accepted. @@ -2226,7 +2233,7 @@ private boolean referToCallStateChanged(Call referToCall, * a specific Subscription-State header and reason, carries a * specific body content and is sent through a specific * SipProvider. - * + * * @param dialog the Dialog to send the NOTIFY request in * @param subscriptionState the Subscription-State header to be * sent with the NOTIFY request @@ -2302,7 +2309,7 @@ private void sendReferNotifyRequest(Dialog dialog, * Creates a new {@link Request} of a specific method which is to be sent in * a specific Dialog and populates its generally-necessary * headers such as the Authorization header. - * + * * @param dialog the Dialog to create the new * Request in * @param method the method of the newly-created Request @@ -2347,7 +2354,7 @@ private Request createRequest(Dialog dialog, String method) * Indicates a user request to end a call with the specified call * participant. Depending on the state of the call the method would send a * CANCEL, BYE, or BUSY_HERE and set the new state to DISCONNECTED. - * + * * @param participant the participant that we'd like to hang up on. * @throws ClassCastException if participant is not an instance of this * CallParticipantSipImpl. @@ -2414,9 +2421,9 @@ else if (participantState.equals(CallParticipantState.FAILED)) /** * Sends an Internal Error response to callParticipant. - * + * * @param callParticipant the call participant that we need to say bye to. - * + * * @throws OperationFailedException if we failed constructing or sending a * SIP Message. */ @@ -2429,10 +2436,10 @@ public void sayInternalError(CallParticipantSipImpl callParticipant) /** * Send an error response with the errorCode code to * callParticipant. - * + * * @param callParticipant the call participant that we need to say bye to. * @param errorCode the code that the response should have. - * + * * @throws OperationFailedException if we failed constructing or sending a * SIP Message. */ @@ -2497,7 +2504,7 @@ public void sayError(CallParticipantSipImpl callParticipant, int errorCode) /** * Sends a BYE request to callParticipant. - * + * * @param callParticipant the call participant that we need to say bye to. * @return true if the Dialog should be considered * alive after sending the BYE request (e.g. when there're still @@ -2565,9 +2572,9 @@ private boolean sayBye(CallParticipantSipImpl callParticipant) /** * Sends a Cancel request to callParticipant. - * + * * @param callParticipant the call participant that we need to cancel. - * + * * @throws OperationFailedException we failed to construct or send the * CANCEL request. */ @@ -2605,7 +2612,7 @@ private void sayCancel(CallParticipantSipImpl callParticipant) /** * Sends a BUSY_HERE response to callParticipant. - * + * * @param callParticipant the call participant that we need to send busy * tone to. * @throws OperationFailedException if we fail to create or send the @@ -2659,10 +2666,10 @@ private void sayBusyHere(CallParticipantSipImpl callParticipant) /** * * Indicates a user request to answer an incoming call from the specified * CallParticipant. - * + * * Sends an OK response to callParticipant. Make sure that the call * participant contains an sdp description when you call this method. - * + * * @param participant the call participant that we need to send the ok to. * @throws OperationFailedException if we fail to create or send the * response. @@ -2809,7 +2816,7 @@ public synchronized void answerCallParticipant(CallParticipant participant) /** * Creates a new {@link Response#OK} response to a specific {@link Request} * which is to be sent as part of a specific {@link Dialog}. - * + * * @param request the Request to create the OK response for * @param containingDialog the Dialog to send the response in * @return a new @@ -2831,11 +2838,11 @@ private Response createOKResponse(Request request, Dialog containingDialog) /** * Creates a new call and call participant associated with * containingTransaction - * + * * @param containingTransaction the transaction that created the call. * @param sourceProvider the provider that the containingTransaction belongs * to. - * + * * @return a new instance of a CallParticipantSipImpl corresponding * to the containingTransaction. */ @@ -2872,7 +2879,7 @@ private CallParticipantSipImpl createCallParticipantFor( * instance including information that would permit to distinguish it among * other instances when reading a log file. *

- * + * * @return a string representation of this operation set. */ public String toString() @@ -2930,7 +2937,7 @@ public synchronized void shutdown() *

* The implementation sends silence through the audio stream. *

- * + * * @param participant the CallParticipant who receives the audio * stream to have its mute state set * @param mute true to mute the audio stream being sent to @@ -2945,7 +2952,7 @@ public void setMute(CallParticipant participant, boolean mute) /** * Transfers (in the sense of call transfer) a specific * CallParticipant to a specific callee address. - * + * * @param participant the CallParticipant to be transfered to * the specified callee address * @param target the address of the callee to transfer