Fixes a problem when we cancel a Jingle call, it is not really cancelled. In fact the session-terminate was sent _before_ session-initiate.

cusax-fix
Sebastien Vincent 14 years ago
parent 0da9e559d9
commit 3eede72c8e

@ -69,6 +69,16 @@ public class CallPeerJabberImpl
*/
private boolean contentAddWithNoCands = false;
/**
* Synchronization object for SID.
*/
private final Object sidSyncRoot = new Object();
/**
* If the call is cancelled before session-initiate is sent.
*/
private boolean cancelled = false;
/**
* Creates a new call peer with address <tt>peerAddress</tt>.
*
@ -261,12 +271,24 @@ protected synchronized void initiateSession(
ProtocolProviderServiceJabberImpl protocolProvider
= getProtocolProvider();
sessionInitIQ
= JinglePacketFactory.createSessionInitiate(
synchronized(sidSyncRoot)
{
sessionInitIQ
= JinglePacketFactory.createSessionInitiate(
protocolProvider.getOurJID(),
this.peerJID,
JingleIQ.generateSID(),
offer);
if(cancelled)
{
// we cancelled the call too early so no need to send the
// session-initiate to peer
getMediaHandler().getTransportManager().close();
return;
}
}
if (sessionInitiateExtensions != null)
{
for (PacketExtension sessionInitiateExtension
@ -399,6 +421,20 @@ else if (CallPeerState.CONNECTING.equals(prevPeerState)
|| CallPeerState.CONNECTING_WITH_EARLY_MEDIA.equals(prevPeerState)
|| CallPeerState.ALERTING_REMOTE_SIDE.equals(prevPeerState))
{
String jingleSID = getJingleSID();
if(jingleSID == null)
{
synchronized(sidSyncRoot)
{
// we cancelled the call too early because the jingleSID
// is null (i.e. the session-initiate has not been created)
// and no need to send the session-terminate
cancelled = true;
return;
}
}
responseIQ = JinglePacketFactory.createCancel(
getProtocolProvider().getOurJID(), peerJID, getJingleSID());
}
@ -1165,6 +1201,11 @@ public void processTransportInfo(JingleIQ jingleIQ)
*/
protected void sendTransportInfo(Iterable<ContentPacketExtension> contents)
{
// if the call is cancelled, do not start sending candidates in
// transport-info
if(cancelled)
return;
JingleIQ transportInfo = new JingleIQ();
for (ContentPacketExtension content : contents)

Loading…
Cancel
Save