diff options
author | paweldomas <pawel.domas@jitsi.org> | 2014-12-08 13:40:45 +0100 |
---|---|---|
committer | paweldomas <pawel.domas@jitsi.org> | 2014-12-08 13:40:45 +0100 |
commit | 4a17fc226794bfaf5768fe6c01bcc7ba31abda1b (patch) | |
tree | b1e3117be5d44d92fb25ac7b30a1645984a73bfb /src/net/java/sip/communicator | |
parent | fbf0877aa1e01148c3048f826cb8dd11671d51cd (diff) | |
parent | 22bc098d4f0162ed8459e33a5ccfbda45e60dc6d (diff) | |
download | jitsi-4a17fc226794bfaf5768fe6c01bcc7ba31abda1b.zip jitsi-4a17fc226794bfaf5768fe6c01bcc7ba31abda1b.tar.gz jitsi-4a17fc226794bfaf5768fe6c01bcc7ba31abda1b.tar.bz2 |
Merge branch 'sipgateway'
Conflicts:
lib/installer-exclude/fmj.jar
lib/installer-exclude/ice4j.jar
lib/installer-exclude/libjitsi.jar
src/net/java/sip/communicator/impl/protocol/irc/IrcStack.java
src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerJabberImpl.java
src/net/java/sip/communicator/impl/protocol/jabber/extensions/colibri/ColibriConferenceIQ.java
src/net/java/sip/communicator/impl/protocol/jabber/extensions/jingle/CandidatePacketExtension.java
src/net/java/sip/communicator/impl/protocol/jabber/jinglesdp/JingleUtils.java
Diffstat (limited to 'src/net/java/sip/communicator')
12 files changed, 412 insertions, 21 deletions
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 698618c..1390b12 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/CallPeerMediaHandlerJabberImpl.java @@ -1665,7 +1665,7 @@ public class CallPeerMediaHandlerJabberImpl RtpDescriptionPacketExtension description = JingleUtils.getRtpDescription(content); MediaType mediaType - = MediaType.parseString( description.getMedia() ); + = JingleUtils.getMediaType(content); List<MediaFormat> remoteFormats = JingleUtils.extractFormats( diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java index fdff716..1c76c96 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java @@ -1790,7 +1790,9 @@ public class ChatRoomJabberImpl = new ConferenceDescriptionPacketExtension(cd); if (lastPresenceSent != null) { - setConferenceDescriptionPacketExtension(lastPresenceSent, ext); + setPacketExtension( + lastPresenceSent, ext, + ConferenceDescriptionPacketExtension.NAMESPACE); provider.getConnection().sendPacket(lastPresenceSent); } else @@ -1820,28 +1822,66 @@ public class ChatRoomJabberImpl } /** - * Sets <tt>ext</tt> as the only - * <tt>ConferenceDescriptionPacketExtension</tt> of <tt>presence</tt>. + * Sets <tt>ext</tt> as the only <tt>PacketExtension</tt> that belongs to + * given <tt>namespace</tt> of the <tt>packet</tt>. * - * @param packet the <tt>Packet<tt> - * @param ext the <tt>ConferenceDescriptionPacketExtension<tt> to set, + * @param packet the <tt>Packet<tt> to be modified. + * @param extension the <tt>ConferenceDescriptionPacketExtension<tt> to set, * or <tt>null</tt> to not set one. + * @param namespace the namespace of <tt>PacketExtension</tt>. */ - private void setConferenceDescriptionPacketExtension( + private static void setPacketExtension( Packet packet, - ConferenceDescriptionPacketExtension ext) + PacketExtension extension, + String namespace) { + if (org.jitsi.util.StringUtils.isNullOrEmpty(namespace)) + { + return; + } + //clear previous announcements PacketExtension pe; - while (null != - (pe = packet.getExtension( - ConferenceDescriptionPacketExtension.NAMESPACE))) + while (null != (pe = packet.getExtension(namespace))) { packet.removeExtension(pe); } - if (ext != null) - packet.addExtension(ext); + if (extension != null) + { + packet.addExtension(extension); + } + } + + /** + * Publishes new status message in chat room presence. + * @param newStatus the new status message to be published in the MUC. + */ + public void publishPresenceStatus(String newStatus) + { + if (lastPresenceSent != null) + { + lastPresenceSent.setStatus(newStatus); + + provider.getConnection().sendPacket(lastPresenceSent); + } + } + + /** + * Adds given <tt>PacketExtension</tt> to the MUC presence and publishes it + * immediately. + * @param extension the <tt>PacketExtension</tt> to be included in MUC + * presence. + */ + public void sendPresenceExtension(PacketExtension extension) + { + if (lastPresenceSent != null) + { + setPacketExtension( + lastPresenceSent, extension, extension.getNamespace()); + + provider.getConnection().sendPacket(lastPresenceSent); + } } /** @@ -2972,9 +3012,10 @@ public class ChatRoomJabberImpl { if (packet instanceof Presence) { - setConferenceDescriptionPacketExtension( - packet, - publishedConferenceExt); + setPacketExtension( + packet, + publishedConferenceExt, + ConferenceDescriptionPacketExtension.NAMESPACE); lastPresenceSent = (Presence) packet; } diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/IceUdpTransportManager.java b/src/net/java/sip/communicator/impl/protocol/jabber/IceUdpTransportManager.java index 73f1b0b..5ed365f 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/IceUdpTransportManager.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/IceUdpTransportManager.java @@ -890,15 +890,23 @@ public class IceUdpTransportManager if (iceAgentStateIsRunning && (candidates.size() == 0)) return false; + String media = e.getKey(); + IceMediaStream stream = iceAgent.getStream(media); + + if (stream == null) + { + logger.warn( + "No ICE media stream for media: " + media + + " - ignored candidates."); + continue; + } + // Sort the remote candidates (host < reflexive < relayed) in order // to create first the host, then the reflexive, the relayed // candidates and thus be able to set the relative-candidate // matching the rel-addr/rel-port attribute. Collections.sort(candidates); - String media = e.getKey(); - IceMediaStream stream = iceAgent.getStream(media); - // Different stream may have different ufrag/password String ufrag = transport.getUfrag(); diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetJitsiMeetToolsJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetJitsiMeetToolsJabberImpl.java new file mode 100644 index 0000000..06f5bfe --- /dev/null +++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetJitsiMeetToolsJabberImpl.java @@ -0,0 +1,72 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.impl.protocol.jabber; + +import net.java.sip.communicator.service.protocol.*; +import org.jivesoftware.smack.packet.*; + +/** + * Jabber protocol provider implementation of {@link OperationSetJitsiMeetTools} + * + * @author Pawel Domas + */ +public class OperationSetJitsiMeetToolsJabberImpl + implements OperationSetJitsiMeetTools +{ + private final ProtocolProviderServiceJabberImpl parentProvider; + + /** + * Creates new instance of <tt>OperationSetJitsiMeetToolsJabberImpl</tt>. + * + * @param parentProvider parent Jabber protocol provider service instance. + */ + public OperationSetJitsiMeetToolsJabberImpl( + ProtocolProviderServiceJabberImpl parentProvider) + { + this.parentProvider = parentProvider; + } + + /** + * {@inheritDoc} + */ + @Override + public void addSupportedFeature(String featureName) + { + parentProvider.getDiscoveryManager().addFeature(featureName); + } + + /** + * {@inheritDoc} + */ + @Override + public void sendPresenceExtension(ChatRoom chatRoom, + PacketExtension extension) + { + ((ChatRoomJabberImpl)chatRoom).sendPresenceExtension(extension); + } + + /** + * {@inheritDoc} + */ + @Override + public void setPresenceStatus(ChatRoom chatRoom, String statusMessage) + { + ((ChatRoomJabberImpl)chatRoom).publishPresenceStatus(statusMessage); + } + + @Override + public void addRequestListener(JitsiMeetRequestListener requestHandler) + { + // Not used + } + + @Override + public void removeRequestListener(JitsiMeetRequestListener requestHandler) + { + // Not used + } +} diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetTelephonyConferencingJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetTelephonyConferencingJabberImpl.java index e70cfbd..0119964 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetTelephonyConferencingJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetTelephonyConferencingJabberImpl.java @@ -29,6 +29,7 @@ import org.jivesoftware.smackx.packet.*; * @author Lyubomir Marinov
* @author Sebastien Vincent
* @author Boris Grozev
+ * @author Pawel Domas
*/
public class OperationSetTelephonyConferencingJabberImpl
extends AbstractOperationSetTelephonyConferencing<
@@ -57,11 +58,22 @@ public class OperationSetTelephonyConferencingJabberImpl private static final int COIN_MIN_INTERVAL = 200;
/**
+ * Property used to disable COIN notifications.
+ */
+ public static final String DISABLE_COIN_PROP_NAME
+ = "net.java.sip.communicator.impl.protocol.jabber.DISABLE_COIN";
+
+ /**
* Synchronization object.
*/
private final Object lock = new Object();
/**
+ * Field indicates whether COIN notification are disabled or not.
+ */
+ private boolean isCoinDisabled = false;
+
+ /**
* Initializes a new <tt>OperationSetTelephonyConferencingJabberImpl</tt>
* instance which is to provide telephony conferencing services for the
* specified Jabber <tt>ProtocolProviderService</tt> implementation.
@@ -74,6 +86,10 @@ public class OperationSetTelephonyConferencingJabberImpl ProtocolProviderServiceJabberImpl parentProvider)
{
super(parentProvider);
+
+ this.isCoinDisabled
+ = JabberActivator.getConfigurationService()
+ .getBoolean(DISABLE_COIN_PROP_NAME, false);
}
/**
@@ -89,7 +105,7 @@ public class OperationSetTelephonyConferencingJabberImpl @Override
protected void notifyCallPeers(Call call)
{
- if (call.isConferenceFocus())
+ if (!isCoinDisabled && call.isConferenceFocus())
{
synchronized (lock)
{
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java index 6230118..095075e 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java @@ -1715,6 +1715,10 @@ public class ProtocolProviderServiceJabberImpl new OperationSetMultiUserChatJabberImpl(this)); addSupportedOperationSet( + OperationSetJitsiMeetTools.class, + new OperationSetJitsiMeetToolsJabberImpl(this)); + + addSupportedOperationSet( OperationSetServerStoredContactInfo.class, new OperationSetServerStoredContactInfoJabberImpl( infoRetreiver)); diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/jinglesdp/JingleUtils.java b/src/net/java/sip/communicator/impl/protocol/jabber/jinglesdp/JingleUtils.java index c065590..cfcbb91 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/jinglesdp/JingleUtils.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/jinglesdp/JingleUtils.java @@ -79,6 +79,12 @@ public class JingleUtils DynamicPayloadTypeRegistry ptRegistry) { List<MediaFormat> mediaFmts = new ArrayList<MediaFormat>(); + + if (description == null) + { + return mediaFmts; + } + List<PayloadTypePacketExtension> payloadTypes = description.getPayloadTypes(); @@ -236,6 +242,11 @@ public class JingleUtils { List<RTPExtension> extensionsList = new ArrayList<RTPExtension>(); + if (desc == null) + { + return extensionsList; + } + List<RTPHdrExtPacketExtension> extmapList = desc.getExtmapList(); for (RTPHdrExtPacketExtension extmap : extmapList) diff --git a/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java index 075a318..55cc5f3 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java @@ -14,6 +14,7 @@ import javax.sip.address.*; import javax.sip.header.*; import javax.sip.message.*; +import gov.nist.javax.sip.header.*; import gov.nist.javax.sip.stack.*; import net.java.sip.communicator.impl.protocol.sip.sdp.*; @@ -45,6 +46,13 @@ public class CallSipImpl private static final Logger logger = Logger.getLogger(CallSipImpl.class); /** + * Name of extra INVITE header which specifies name of MUC room that is + * hosting the Jitsi Meet conference. + */ + public static final String JITSI_MEET_ROOM_HEADER + = "Jitsi-Conference-Room"; + + /** * When starting call we may have quality preferences we must use * for the call. */ @@ -472,6 +480,19 @@ public class CallSipImpl if (alternativeIMPPAddress != null) peer.setAlternativeIMPPAddress(alternativeIMPPAddress); + // Parses Jitsi Meet room name header + SIPHeader joinRoomHeader + = (SIPHeader) invite.getHeader(JITSI_MEET_ROOM_HEADER); + if (joinRoomHeader != null) + { + OperationSetJitsiMeetToolsSipImpl jitsiMeetTools + = (OperationSetJitsiMeetToolsSipImpl) getProtocolProvider() + .getOperationSet(OperationSetJitsiMeetTools.class); + + jitsiMeetTools.notifyJoinJitsiMeetRoom( + this, joinRoomHeader.getValue()); + } + //send a ringing response Response response = null; try diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetJitsiMeetToolsSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetJitsiMeetToolsSipImpl.java new file mode 100644 index 0000000..4af47a6 --- /dev/null +++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetJitsiMeetToolsSipImpl.java @@ -0,0 +1,129 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.impl.protocol.sip; + +import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.util.*; + +import org.jivesoftware.smack.packet.*; + +import java.util.*; +import java.util.concurrent.*; + +/** + * The SIP implementation of {@link OperationSetJitsiMeetTools}. + * + * @author Pawel Domas + */ +public class OperationSetJitsiMeetToolsSipImpl + implements OperationSetJitsiMeetTools +{ + /** + * The logger used by this class. + */ + private final static Logger logger + = Logger.getLogger(OperationSetJitsiMeetToolsSipImpl.class); + + /** + * The list of {@link JitsiMeetRequestListener}. + */ + private final List<JitsiMeetRequestListener> requestHandlers + = new CopyOnWriteArrayList<JitsiMeetRequestListener>(); + + /*private ProtocolProviderServiceSipImpl parentProvider; + + public OperationSetJitsiMeetToolsSipImpl( + ProtocolProviderServiceSipImpl parentProvider) + { + this.parentProvider = parentProvider; + }*/ + + //@Override + //public Call createGatewayCall(String uri, String roomName) + //{ + /*OperationSetBasicTelephonySipImpl sipTelephony + = (OperationSetBasicTelephonySipImpl) + parentProvider.getOperationSet( + OperationSetBasicTelephony.class); + + Map<String, String> parameters = new HashMap<String, String>(); + + parameters.put(CallSipImpl.JITSI_MEET_ROOM_HEADER, roomName); + + return sipTelephony.createCall(uri, parameters);*/ + //} + + /** + * {@inheritDoc} + */ + @Override + public void addRequestListener(JitsiMeetRequestListener requestHandler) + { + this.requestHandlers.add(requestHandler); + } + + /** + * {@inheritDoc} + */ + @Override + public void removeRequestListener(JitsiMeetRequestListener requestHandler) + { + this.requestHandlers.remove(requestHandler); + } + + /** + * Notifies all registered {@link JitsiMeetRequestListener} about incoming + * call that contains name of the MUC room which is hosting Jitsi Meet + * conference. + * @param call the incoming {@link Call} instance. + * @param jitsiMeetRoom the name of the chat room of Jitsi Meet conference + * to be joined. + */ + public void notifyJoinJitsiMeetRoom(Call call, String jitsiMeetRoom) + { + boolean handled = false; + for (JitsiMeetRequestListener l : requestHandlers) + { + l.onJoinJitsiMeetRequest(call, jitsiMeetRoom); + handled = true; + } + if (!handled) + { + logger.warn( + "Unhandled join Jitsi Meet request R:" + jitsiMeetRoom + + " C: " + call); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void addSupportedFeature(String featureName) + { + throw new RuntimeException("Not implemented for SIP"); + } + + /** + * {@inheritDoc} + */ + @Override + public void sendPresenceExtension(ChatRoom chatRoom, + PacketExtension extension) + { + throw new RuntimeException("Not implemented for SIP"); + } + + /** + * {@inheritDoc} + */ + @Override + public void setPresenceStatus(ChatRoom chatRoom, String statusMessage) + { + throw new RuntimeException("Not implemented for SIP"); + } +} diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java index da36c7c..8a6fe52 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java @@ -554,6 +554,11 @@ public class ProtocolProviderServiceSipImpl new OperationSetDesktopSharingClientSipImpl(this)); } } + + // Jitsi Meet Tools + addSupportedOperationSet( + OperationSetJitsiMeetTools.class, + new OperationSetJitsiMeetToolsSipImpl()); } if (enablePresence) diff --git a/src/net/java/sip/communicator/service/protocol/OperationSetJitsiMeetTools.java b/src/net/java/sip/communicator/service/protocol/OperationSetJitsiMeetTools.java new file mode 100644 index 0000000..8cf4af5 --- /dev/null +++ b/src/net/java/sip/communicator/service/protocol/OperationSetJitsiMeetTools.java @@ -0,0 +1,79 @@ +/* + * Jitsi, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package net.java.sip.communicator.service.protocol; + +import org.jivesoftware.smack.packet.*; + +/** + * The operation set provides functionality specific to Jitsi Meet WebRTC + * conference and is currently used in the SIP gateway. + * + * @author Pawel Domas + */ +public interface OperationSetJitsiMeetTools + extends OperationSet +{ + /** + * Adds given feature to communication protocol capabilities list of parent + * {@link ProtocolProviderService}. + * + * @param featureName feature name to be added to the capabilities list. + */ + public void addSupportedFeature(String featureName); + + /** + * Includes given <tt>PacketExtension</tt> in multi user chat presence and + * sends presence update packet to the chat room. + * @param chatRoom the <tt>ChatRoom</tt> for which the presence will be + * updated. + * @param extension the <tt>PacketExtension</tt> to be included in MUC + * presence. + */ + public void sendPresenceExtension(ChatRoom chatRoom, + PacketExtension extension); + + /** + * Sets the status message of our MUC presence and sends presence status + * update packet to the server. + * @param chatRoom the <tt>ChatRoom</tt> for which the presence status + * message will be changed. + * @param statusMessage the text that will be used as our presence status + * message in the MUC. + */ + public void setPresenceStatus(ChatRoom chatRoom, String statusMessage); + + /** + * Adds given <tt>listener</tt> to the list of + * {@link JitsiMeetRequestListener}s. + * @param listener the {@link JitsiMeetRequestListener} to be notified about + * future events. + */ + public void addRequestListener(JitsiMeetRequestListener listener); + + /** + * Removes given <tt>listener</tt> from the list of + * {@link JitsiMeetRequestListener}s. + * @param listener the {@link JitsiMeetRequestListener} that will be no + * longer notified about Jitsi Meet events. + */ + public void removeRequestListener(JitsiMeetRequestListener listener); + + /** + * Interface used to handle Jitsi Meet conference requests. + */ + interface JitsiMeetRequestListener + { + /** + * Events is fired for an incoming call that contains information about + * Jitsi Meet conference room to be joined. + * @param call the incoming {@link Call} instance. + * @param jitsiMeetRoom the name of multi user chat room that is hosting + * Jitsi Meet conference. + */ + void onJoinJitsiMeetRequest(Call call, String jitsiMeetRoom); + } +} diff --git a/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java b/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java index 5caf298..20822b0 100644 --- a/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java +++ b/src/net/java/sip/communicator/service/protocol/media/CallPeerMediaHandler.java @@ -611,6 +611,8 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>> return audioDirectionUserPreference; case VIDEO: return videoDirectionUserPreference; + case DATA: + return MediaDirection.INACTIVE; default: throw new IllegalArgumentException("mediaType"); } @@ -655,7 +657,10 @@ public abstract class CallPeerMediaHandler<T extends MediaAwareCallPeer<?,?,?>> */ protected List<RTPExtension> getExtensionsForType(MediaType type) { - return getDefaultDevice(type).getSupportedExtensions(); + MediaDevice device = getDefaultDevice(type); + return device != null + ? device.getSupportedExtensions() + : new ArrayList<RTPExtension>(); } /** |