Adds to Jingle support for placing calls off and on hold (still: only for Raw UDP)

cusax-fix
Emil Ivov 16 years ago
parent 920a76b789
commit ccf956befe

@ -403,18 +403,19 @@ public void putOnHold(boolean onHold)
CallPeerMediaHandlerJabberImpl mediaHandler = getMediaHandler();
mediaHandler.setLocallyOnHold(onHold);
/*
try
{
JinglePacketFactory.createSessionInfo(from, to, sid, type)
}
catch (Exception ex)
{
ProtocolProviderServiceJabberImpl.throwOperationFailedException(
"Failed to create SDP offer to hold.",
OperationFailedException.INTERNAL_ERROR, ex, logger);
}
*/
SessionInfoType type;
if(onHold)
type = SessionInfoType.hold;
else
type = SessionInfoType.unhold;
JinglePacketFactory.createSessionInfo(
getProtocolProvider().getOurJID(),
peerJID,
getJingleSID(),
type);
reevalLocalHoldStatus();
}
@ -452,4 +453,25 @@ public boolean isInitiator()
{
return isInitiator;
}
/**
* Handles the specified session <tt>info</tt> packet according to its
* content.
*
* @param info the {@link SessionInfoPacketExtension} that we just received.
*/
public void processSessionInfo(SessionInfoPacketExtension info)
{
if( info.getType() == SessionInfoType.ringing)
setState(CallPeerState.ALERTING_REMOTE_SIDE);
if (info.getType() == SessionInfoType.hold)
{
getMediaHandler().setRemotelyOnHold(true);
}
else if (info.getType() == SessionInfoType.unhold
|| info.getType() == SessionInfoType.active)
{
getMediaHandler().setRemotelyOnHold(true);
}
}
}

@ -56,6 +56,11 @@ public class CallPeerMediaHandlerJabberImpl
private Map<String, ContentPacketExtension> remoteContentMap
= new LinkedHashMap<String, ContentPacketExtension>();
/**
* Indicates whether the remote party has placed us on hold.
*/
private boolean remotelyOnHold = false;
/**
* Creates a new handler that will be managing media streams for
* <tt>peer</tt>.
@ -466,6 +471,53 @@ public void processAnswer(List<ContentPacketExtension> answer)
}
}
/**
* Acts upon a notification received from the remote party indicating that
* they've put us on/off hold.
*
* @param onHold <tt>true</tt> if the remote party has put us on hold
* and <tt>false</tt> if they've just put us off hold.
*/
public void setRemotelyOnHold(boolean onHold)
{
this.remotelyOnHold = onHold;
MediaStream audioStream = getStream(MediaType.AUDIO);
MediaStream videoStream = getStream(MediaType.VIDEO);
if(remotelyOnHold)
{
if(audioStream != null)
{
audioStream.setDirection(audioStream.getDirection()
.and(MediaDirection.RECVONLY));
audioStream.setMute(remotelyOnHold);
}
if(videoStream != null)
{
videoStream.setDirection(videoStream.getDirection()
.and(MediaDirection.RECVONLY));
videoStream.setMute(remotelyOnHold);
}
}
else
{
//off hold - make sure that we re-enable sending
if(audioStream != null)
{
audioStream.setDirection(audioStream.getDirection()
.or(MediaDirection.RECVONLY));
audioStream.setMute(remotelyOnHold);
}
if(videoStream != null
&& videoStream.getDirection() != MediaDirection.INACTIVE)
{
videoStream.setDirection(videoStream.getDirection()
.or(MediaDirection.RECVONLY));
videoStream.setMute(remotelyOnHold);
}
}
}
/**
* Returns the transport manager that is handling our address management.
*

@ -291,7 +291,9 @@ private void putOnHold(CallPeer peer, boolean on)
@Override
public void setMute(Call call, boolean mute)
{
/** @todo implement putOnHold() */
CallJabberImpl jabberCall = (CallJabberImpl)call;
jabberCall.setMute(mute);
}
/**
@ -510,8 +512,7 @@ else if (action == JingleAction.SESSION_INFO)
return;
// change status.
if( info.getType() == SessionInfoType.ringing)
callPeer.setState(CallPeerState.ALERTING_REMOTE_SIDE);
callPeer.processSessionInfo(info);
}
}

@ -1528,7 +1528,7 @@ public synchronized void shutdown()
* and one of the possible approaches to it is sending silence.
* </p>
*
* @param call the <tt>Call</tt> whos mute state is set
* @param call the <tt>Call</tt> whose mute state is set
* @param mute <tt>true</tt> to mute the call streams being sent to
* <tt>peers</tt>; otherwise, <tt>false</tt>
*/

@ -9,6 +9,7 @@
import java.net.*;
import java.util.*;
import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.*;

Loading…
Cancel
Save