diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerJabberImpl.java index 488473802..e40622dbb 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerJabberImpl.java @@ -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 info 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); + } + } } diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerJabberImpl.java index a27e0978b..a686f929c 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerJabberImpl.java @@ -56,6 +56,11 @@ public class CallPeerMediaHandlerJabberImpl private Map remoteContentMap = new LinkedHashMap(); + /** + * 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 * peer. @@ -466,6 +471,53 @@ public void processAnswer(List answer) } } + /** + * Acts upon a notification received from the remote party indicating that + * they've put us on/off hold. + * + * @param onHold true if the remote party has put us on hold + * and false 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. * diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java index 0d0755056..37a89f000 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetBasicTelephonyJabberImpl.java @@ -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); } } 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 bde859912..2a4a7f145 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicTelephonySipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicTelephonySipImpl.java @@ -1528,7 +1528,7 @@ public synchronized void shutdown() * and one of the possible approaches to it is sending silence. *

* - * @param call the Call whos mute state is set + * @param call the Call whose mute state is set * @param mute true to mute the call streams being sent to * peers; otherwise, false */ diff --git a/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java b/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java index 115df8a6a..1bbf11c6c 100644 --- a/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java +++ b/src/net/java/sip/communicator/service/protocol/AbstractCallPeer.java @@ -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.*;