diff options
author | Boris Grozev <boris@jitsi.org> | 2013-07-16 10:58:53 +0300 |
---|---|---|
committer | Boris Grozev <boris@jitsi.org> | 2013-07-16 15:34:59 +0300 |
commit | d7930b34a6fa55708a41d8568464ee5dec8301b2 (patch) | |
tree | 949b14be86c0c5bfe0f96b83c1e9818f16a22c63 /src | |
parent | dd08179d07e12e40454a655f63909de181e7abe9 (diff) | |
download | jitsi-d7930b34a6fa55708a41d8568464ee5dec8301b2.zip jitsi-d7930b34a6fa55708a41d8568464ee5dec8301b2.tar.gz jitsi-d7930b34a6fa55708a41d8568464ee5dec8301b2.tar.bz2 |
Updates getting the direction of a CallPeer for use in conference-info documents
Diffstat (limited to 'src')
5 files changed, 105 insertions, 36 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerGTalkImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerGTalkImpl.java index d7cbc1f..a8278a0 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerGTalkImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerGTalkImpl.java @@ -14,6 +14,7 @@ import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.*; import org.jivesoftware.smack.packet.*; /** @@ -666,4 +667,25 @@ public class CallPeerGTalkImpl { return getAddress(); } + + /** + * {@inheritDoc} + * + * Uses the direction of the media stream as a fallback. + * TODO: return the direction of the GTalk session? + */ + @Override + public MediaDirection getDirection(MediaType mediaType) + { + MediaStream stream = getMediaHandler().getStream(mediaType); + if (stream != null) + { + MediaDirection direction = stream.getDirection(); + return direction == null + ? MediaDirection.INACTIVE + : direction; + } + + return MediaDirection.INACTIVE; + } } 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 978dcd3..3c97e21 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerJabberImpl.java @@ -1067,7 +1067,7 @@ public class CallPeerJabberImpl } /** - * Returns the <tt>MediaDirection</tt> that should be used for the content + * Returns the <tt>MediaDirection</tt> that should be set for the content * of type <tt>mediaType</tt> in the Jingle session for this * <tt>CallPeer</tt>. * If we are the focus of a conference and are doing RTP translation, @@ -1079,7 +1079,7 @@ public class CallPeerJabberImpl * of type <tt>mediaType</tt> in the Jingle session for this * <tt>CallPeer</tt>. */ - private MediaDirection getJingleDirection(MediaType mediaType) + private MediaDirection getDirectionForJingle(MediaType mediaType) { MediaDirection direction = MediaDirection.INACTIVE; CallPeerMediaHandlerJabberImpl mediaHandler = getMediaHandler(); @@ -1135,7 +1135,7 @@ public class CallPeerJabberImpl public void sendModifyVideoContent() { CallPeerMediaHandlerJabberImpl mediaHandler = getMediaHandler(); - MediaDirection direction = getJingleDirection(MediaType.VIDEO); + MediaDirection direction = getDirectionForJingle(MediaType.VIDEO); ContentPacketExtension remoteContent = mediaHandler.getLocalContent(MediaType.VIDEO.toString()); @@ -1471,4 +1471,28 @@ public class CallPeerJabberImpl { return getAddress(); } + + /** + * {@inheritDoc} + * + * In Jingle there isn't an actual "direction" parameter. We use the + * <tt>senders</tt> field to calculate the direction. + */ + @Override + public MediaDirection getDirection(MediaType mediaType) + { + SendersEnum senders = getMediaHandler().getSenders(mediaType); + if (senders == SendersEnum.none) + return MediaDirection.INACTIVE; + else if (senders == null || senders == SendersEnum.both) + return MediaDirection.SENDRECV; + else if (senders == SendersEnum.initiator) + return isInitiator() + ? MediaDirection.RECVONLY + : MediaDirection.SENDONLY; + else //senders == SendersEnum.responder + return isInitiator() + ? MediaDirection.SENDONLY + : MediaDirection.RECVONLY; + } } diff --git a/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java index 874225f..57a37be 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/CallPeerSipImpl.java @@ -26,6 +26,8 @@ import net.java.sip.communicator.service.protocol.event.*; import net.java.sip.communicator.service.protocol.media.*; import net.java.sip.communicator.util.*; +import org.jitsi.service.neomedia.*; +import org.jitsi.service.neomedia.MediaType; // disambiguate import org.jitsi.service.neomedia.control.*; /** @@ -1691,4 +1693,24 @@ public class CallPeerSipImpl .stripParametersFromAddress(getURI()); } + /** + * {@inheritDoc} + * + * Uses the direction of the media stream as a fallback. + * TODO: return the direction negotiated via SIP + */ + @Override + public MediaDirection getDirection(MediaType mediaType) + { + MediaStream stream = getMediaHandler().getStream(mediaType); + if (stream != null) + { + MediaDirection direction = stream.getDirection(); + return direction == null + ? MediaDirection.INACTIVE + : direction; + } + + return MediaDirection.INACTIVE; + } } diff --git a/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetTelephonyConferencing.java b/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetTelephonyConferencing.java index 6229bcb..21d91c1 100644 --- a/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetTelephonyConferencing.java +++ b/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetTelephonyConferencing.java @@ -487,35 +487,6 @@ public abstract class AbstractOperationSetTelephonyConferencing< } /** - * Gets the <tt>MediaDirection</tt> of the media RTP stream of a specific - * <tt>CallPeer</tt> with a specific <tt>MediaType</tt> from the point of - * view of the remote peer. - * - * @param callPeer - * @param mediaType - * @return the <tt>MediaDirection</tt> of the media RTP stream of a specific - * <tt>CallPeer</tt> with a specific <tt>MediaType</tt> from the point of - * view of the remote peer - */ - protected MediaDirection getRemoteDirection( - MediaAwareCallPeer<?,?,?> callPeer, - MediaType mediaType) - { - MediaStream stream = callPeer.getMediaHandler().getStream(mediaType); - MediaDirection remoteDirection; - - if (stream != null) - { - remoteDirection = stream.getDirection(); - if (remoteDirection != null) - remoteDirection = remoteDirection.getReverseDirection(); - } - else - remoteDirection = null; - return remoteDirection; - } - - /** * Gets the remote SSRC to be reported in the conference-info XML for a * specific <tt>CallPeer</tt>'s media of a specific <tt>MediaType</tt>. * @@ -1119,10 +1090,23 @@ public abstract class AbstractOperationSetTelephonyConferencing< media.setType(mediaType.toString()); - MediaDirection direction - = remote - ? getRemoteDirection(callPeer, mediaType) - : stream.getDirection(); + MediaDirection direction = MediaDirection.INACTIVE; + if (remote) + direction + = callPeer.getDirection(mediaType).getReverseDirection(); + else + { + if (mediaType == MediaType.AUDIO && + callPeer.getMediaHandler() + .isLocalAudioTransmissionEnabled()) + direction = direction.or(MediaDirection.SENDONLY); + else if (mediaType == MediaType.VIDEO && + callPeer.isLocalVideoStreaming()) + direction = direction.or(MediaDirection.SENDONLY); + + if (callPeer.getDirection(mediaType).allowsReceiving()) + direction = direction.or(MediaDirection.RECVONLY); + } if (direction == null) direction = MediaDirection.INACTIVE; diff --git a/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallPeer.java b/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallPeer.java index b6a5cf0..bdc84a6 100644 --- a/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallPeer.java +++ b/src/net/java/sip/communicator/service/protocol/media/MediaAwareCallPeer.java @@ -1165,4 +1165,21 @@ public abstract class MediaAwareCallPeer this.confInfoScheduled = confInfoScheduled; } } + + /** + * Returns the direction of the session for media of type <tt>mediaType</tt> + * that we have with this <tt>CallPeer</tt>. This is the direction of the + * session negotiated in the signaling protocol, and it may or may not + * coincide with the direction of the media stream. + * For example, if we are the focus of a videobridge conference and another + * peer is sending video to us, we have a <tt>RECVONLY</tt> video stream, + * but <tt>SENDONLY</tt> or <tt>SENDRECV</tt> (Jingle) sessions with the + * rest of the conference members. + * Should always return non-null. + * + * @param mediaType the <tt>MediaType</tt> to use + * @return Returns the direction of the session for media of type + * <tt>mediaType</tt> that we have with this <tt>CallPeer</tt>. + */ + public abstract MediaDirection getDirection(MediaType mediaType); } |