aboutsummaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
authorSebastien Vincent <seb@jitsi.org>2010-10-04 06:29:42 +0000
committerSebastien Vincent <seb@jitsi.org>2010-10-04 06:29:42 +0000
commite03fd00b5737905ed3b17918105b2d9255a1bc59 (patch)
treee5717281ad3dc48e2031357c5eb56bd1931ed971 /src/net
parent92a82069beb70e34de0d1cc6f72aac57c4a9a229 (diff)
downloadjitsi-e03fd00b5737905ed3b17918105b2d9255a1bc59.zip
jitsi-e03fd00b5737905ed3b17918105b2d9255a1bc59.tar.gz
jitsi-e03fd00b5737905ed3b17918105b2d9255a1bc59.tar.bz2
Implement new OperationSetDesktopStreaming interface to prepare integration of the desktop streaming/sharing GUI.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDesktopSharingServerJabberImpl.java8
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDesktopStreamingJabberImpl.java99
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java2
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/OperationSetDesktopStreamingSipImpl.java93
-rw-r--r--src/net/java/sip/communicator/service/protocol/OperationSetDesktopStreaming.java60
-rw-r--r--src/net/java/sip/communicator/service/protocol/media/MediaAwareCall.java58
-rw-r--r--src/net/java/sip/communicator/util/SortedProperties.java2
7 files changed, 315 insertions, 7 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDesktopSharingServerJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDesktopSharingServerJabberImpl.java
index 093c195..488c24e 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDesktopSharingServerJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDesktopSharingServerJabberImpl.java
@@ -20,6 +20,7 @@ import org.jivesoftware.smackx.packet.*;
import net.java.sip.communicator.impl.protocol.jabber.extensions.inputevt.*;
import net.java.sip.communicator.service.hid.*;
import net.java.sip.communicator.service.neomedia.*;
+import net.java.sip.communicator.service.neomedia.device.*;
import net.java.sip.communicator.service.neomedia.format.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
@@ -120,6 +121,7 @@ public class OperationSetDesktopSharingServerJabberImpl
*
* @param uri the address of the callee that we should invite to a new
* call.
+ * @param device video device that will be used to stream desktop.
* @return CallPeer the CallPeer that will represented by the
* specified uri. All following state change events will be delivered
* through that call peer. The Call that this peer is a member
@@ -129,7 +131,7 @@ public class OperationSetDesktopSharingServerJabberImpl
* to create the video call.
*/
@Override
- public Call createVideoCall(String uri)
+ public Call createVideoCall(String uri, MediaDevice device)
throws OperationFailedException
{
CallJabberImpl call = (CallJabberImpl)super.createVideoCall(uri);
@@ -146,6 +148,7 @@ public class OperationSetDesktopSharingServerJabberImpl
*
* @param callee the address of the callee that we should invite to a new
* call.
+ * @param device video device that will be used to stream desktop.
* @return CallPeer the CallPeer that will represented by the
* specified uri. All following state change events will be delivered
* through that call peer. The Call that this peer is a member
@@ -155,7 +158,8 @@ public class OperationSetDesktopSharingServerJabberImpl
* to create the video call.
*/
@Override
- public Call createVideoCall(Contact callee) throws OperationFailedException
+ public Call createVideoCall(Contact callee, MediaDevice device)
+ throws OperationFailedException
{
CallJabberImpl call = (CallJabberImpl)super.createVideoCall(callee);
CallPeerJabberImpl callPeer = call.getCallPeers().next();
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDesktopStreamingJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDesktopStreamingJabberImpl.java
index a86fa32..5090768 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDesktopStreamingJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetDesktopStreamingJabberImpl.java
@@ -6,7 +6,10 @@
*/
package net.java.sip.communicator.impl.protocol.jabber;
+import java.text.*;
+
import net.java.sip.communicator.service.neomedia.*;
+import net.java.sip.communicator.service.neomedia.device.*;
import net.java.sip.communicator.service.protocol.*;
/**
@@ -42,4 +45,100 @@ public class OperationSetDesktopStreamingJabberImpl
{
return MediaUseCase.DESKTOP;
}
+
+ /**
+ * Create a new video call and invite the specified CallPeer to it.
+ *
+ * @param uri the address of the callee that we should invite to a new
+ * call.
+ * @param mediaDevice the media device to use for the desktop streaming
+ * @return CallPeer the CallPeer that will represented by the
+ * specified uri. All following state change events will be delivered
+ * through that call peer. The Call that this peer is a member
+ * of could be retrieved from the CallParticipant instance with the use
+ * of the corresponding method.
+ * @throws OperationFailedException with the corresponding code if we fail
+ * to create the video call.
+ * @throws ParseException if <tt>callee</tt> is not a valid Jabber address
+ * string.
+ */
+ public Call createVideoCall(String uri, MediaDevice mediaDevice)
+ throws OperationFailedException, ParseException
+ {
+ return createOutgoingVideoCall(uri, mediaDevice);
+ }
+
+ /**
+ * Create a new video call and invite the specified CallPeer to it.
+ *
+ * @param callee the address of the callee that we should invite to a new
+ * call.
+ * @param mediaDevice the media device to use for the desktop streaming
+ * @return CallPeer the CallPeer that will represented by the
+ * specified uri. All following state change events will be delivered
+ * through that call peer. The Call that this peer is a member
+ * of could be retrieved from the CallParticipatn instance with the use
+ * of the corresponding method.
+ * @throws OperationFailedException with the corresponding code if we fail
+ * to create the video call.
+ */
+ public Call createVideoCall(Contact callee, MediaDevice mediaDevice)
+ throws OperationFailedException
+ {
+ return this.createOutgoingVideoCall(callee.getAddress(), mediaDevice);
+ }
+
+ /**
+ * Sets the indicator which determines whether the streaming of local video
+ * in a specific <tt>Call</tt> is allowed. The setting does not reflect
+ * the availability of actual video capture devices, it just expresses the
+ * desire of the user to have the local video streamed in the case the
+ * system is actually able to do so.
+ *
+ * @param call the <tt>Call</tt> to allow/disallow the streaming of local
+ * video for
+ * @param mediaDevice the media device to use for the desktop streaming
+ * @param allowed <tt>true</tt> to allow the streaming of local video for
+ * the specified <tt>Call</tt>; <tt>false</tt> to disallow it
+ *
+ * @throws OperationFailedException if initializing local video fails.
+ */
+ public void setLocalVideoAllowed(Call call,
+ MediaDevice mediaDevice,
+ boolean allowed)
+ throws OperationFailedException
+ {
+ ((CallJabberImpl)call).setVideoDevice(mediaDevice);
+ super.setLocalVideoAllowed(call, allowed);
+ }
+
+ /**
+ * Check if the remote part supports Jingle video.
+ *
+ * @param calleeAddress Contact address
+ * @param videoDevice <tt>MediaDevice</tt> used
+ * @return true if contact support Jingle video, false otherwise
+ *
+ * @throws OperationFailedException with the corresponding code if we fail
+ * to create the video call.
+ */
+ protected Call createOutgoingVideoCall(String calleeAddress,
+ MediaDevice videoDevice)
+ throws OperationFailedException
+ {
+ if (parentProvider.getConnection() == null)
+ {
+ throw new OperationFailedException(
+ "Failed to create OutgoingJingleSession.\n"
+ + "we don't have a valid XMPPConnection."
+ , OperationFailedException.INTERNAL_ERROR);
+ }
+
+ CallJabberImpl call = new CallJabberImpl(basicTelephony);
+ /* enable video */
+ call.setVideoDevice(videoDevice);
+ call.setLocalVideoAllowed(true, getMediaUseCase());
+
+ return basicTelephony.createOutgoingCall(call, calleeAddress);
+ }
}
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 fc5aed5..57ba049 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/CallSipImpl.java
@@ -96,7 +96,7 @@ public class CallSipImpl
if (cp.getDialog() == dialog)
{
if (logger.isTraceEnabled())
- logger.trace("Returing cp=" + cp);
+ logger.trace("Returning cp=" + cp);
return cp;
}
else
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetDesktopStreamingSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetDesktopStreamingSipImpl.java
index 6f4f90d..2b068d5 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetDesktopStreamingSipImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetDesktopStreamingSipImpl.java
@@ -6,7 +6,12 @@
*/
package net.java.sip.communicator.impl.protocol.sip;
+import java.text.*;
+
+import javax.sip.address.*;
+
import net.java.sip.communicator.service.neomedia.*;
+import net.java.sip.communicator.service.neomedia.device.*;
import net.java.sip.communicator.service.protocol.*;
/**
@@ -42,4 +47,92 @@ public class OperationSetDesktopStreamingSipImpl
{
return MediaUseCase.DESKTOP;
}
+
+ /**
+ * Create a new video call and invite the specified CallPeer to it.
+ *
+ * @param uri the address of the callee that we should invite to a new
+ * call.
+ * @param mediaDevice the media device to use for the desktop streaming
+ * @return CallPeer the CallPeer that will represented by the
+ * specified uri. All following state change events will be delivered
+ * through that call peer. The Call that this peer is a member
+ * of could be retrieved from the CallParticipatn instance with the use
+ * of the corresponding method.
+ * @throws OperationFailedException with the corresponding code if we fail
+ * to create the video call.
+ * @throws ParseException if <tt>callee</tt> is not a valid sip address
+ * string.
+ */
+ public Call createVideoCall(String uri, MediaDevice mediaDevice)
+ throws OperationFailedException, ParseException
+ {
+ Address toAddress = parentProvider.parseAddressString(uri);
+
+ CallSipImpl call = basicTelephony.createOutgoingCall();
+ call.setVideoDevice(mediaDevice);
+ call.setLocalVideoAllowed(true, getMediaUseCase());
+ call.invite(toAddress, null);
+ return call;
+ }
+
+ /**
+ * Create a new video call and invite the specified CallPeer to it.
+ *
+ * @param callee the address of the callee that we should invite to a new
+ * call.
+ * @param mediaDevice the media device to use for the desktop streaming
+ * @return CallPeer the CallPeer that will represented by the
+ * specified uri. All following state change events will be delivered
+ * through that call peer. The Call that this peer is a member
+ * of could be retrieved from the CallParticipant instance with the use
+ * of the corresponding method.
+ * @throws OperationFailedException with the corresponding code if we fail
+ * to create the video call.
+ */
+ public Call createVideoCall(Contact callee, MediaDevice mediaDevice)
+ throws OperationFailedException
+ {
+ Address toAddress;
+
+ try
+ {
+ toAddress = parentProvider.parseAddressString(callee.getAddress());
+ }
+ catch (ParseException ex)
+ {
+ throw new IllegalArgumentException(ex.getMessage());
+ }
+
+ CallSipImpl call = basicTelephony.createOutgoingCall();
+ call.setLocalVideoAllowed(true, getMediaUseCase());
+ call.setVideoDevice(mediaDevice);
+ call.invite(toAddress, null);
+
+ return call;
+ }
+
+ /**
+ * Sets the indicator which determines whether the streaming of local video
+ * in a specific <tt>Call</tt> is allowed. The setting does not reflect
+ * the availability of actual video capture devices, it just expresses the
+ * desire of the user to have the local video streamed in the case the
+ * system is actually able to do so.
+ *
+ * @param call the <tt>Call</tt> to allow/disallow the streaming of local
+ * video for
+ * @param mediaDevice the media device to use for the desktop streaming
+ * @param allowed <tt>true</tt> to allow the streaming of local video for
+ * the specified <tt>Call</tt>; <tt>false</tt> to disallow it
+ *
+ * @throws OperationFailedException if initializing local video fails.
+ */
+ public void setLocalVideoAllowed(Call call,
+ MediaDevice mediaDevice,
+ boolean allowed)
+ throws OperationFailedException
+ {
+ ((CallSipImpl)call).setVideoDevice(mediaDevice);
+ super.setLocalVideoAllowed(call, allowed);
+ }
}
diff --git a/src/net/java/sip/communicator/service/protocol/OperationSetDesktopStreaming.java b/src/net/java/sip/communicator/service/protocol/OperationSetDesktopStreaming.java
index 9177176..2597e22 100644
--- a/src/net/java/sip/communicator/service/protocol/OperationSetDesktopStreaming.java
+++ b/src/net/java/sip/communicator/service/protocol/OperationSetDesktopStreaming.java
@@ -6,13 +6,73 @@
*/
package net.java.sip.communicator.service.protocol;
+import java.text.*;
+
+import net.java.sip.communicator.service.neomedia.device.*;
+
/**
* Represents an <tt>OperationSet</tt> giving access to desktop streaming
* specific functionality.
*
* @author Sebastien Vincent
+ * @author Yana Stamcheva
*/
public interface OperationSetDesktopStreaming
extends OperationSetVideoTelephony
{
+ /**
+ * Create a new video call and invite the specified CallPeer to it.
+ *
+ * @param uri the address of the callee that we should invite to a new
+ * call.
+ * @param mediaDevice the media device to use for the desktop streaming
+ * @return CallPeer the CallPeer that will represented by the
+ * specified uri. All following state change events will be delivered
+ * through that call peer. The Call that this peer is a member
+ * of could be retrieved from the CallParticipatnt instance with the use
+ * of the corresponding method.
+ * @throws OperationFailedException with the corresponding code if we fail
+ * to create the video call.
+ * @throws ParseException if <tt>callee</tt> is not a valid address
+ * string.
+ */
+ public Call createVideoCall(String uri, MediaDevice mediaDevice)
+ throws OperationFailedException, ParseException;
+
+ /**
+ * Create a new video call and invite the specified CallPeer to it.
+ *
+ * @param callee the address of the callee that we should invite to a new
+ * call.
+ * @param mediaDevice the media device to use for the desktop streaming
+ * @return CallPeer the CallPeer that will represented by the
+ * specified uri. All following state change events will be delivered
+ * through that call peer. The Call that this peer is a member
+ * of could be retrieved from the CallParticipant instance with the use
+ * of the corresponding method.
+ * @throws OperationFailedException with the corresponding code if we fail
+ * to create the video call.
+ */
+ public Call createVideoCall(Contact callee, MediaDevice mediaDevice)
+ throws OperationFailedException;
+
+ /**
+ * Sets the indicator which determines whether the streaming of local video
+ * in a specific <tt>Call</tt> is allowed. The setting does not reflect
+ * the availability of actual video capture devices, it just expresses the
+ * desire of the user to have the local video streamed in the case the
+ * system is actually able to do so.
+ *
+ * @param call the <tt>Call</tt> to allow/disallow the streaming of local
+ * video for
+ * @param mediaDevice the media device to use for the desktop streaming
+ * @param allowed <tt>true</tt> to allow the streaming of local video for
+ * the specified <tt>Call</tt>; <tt>false</tt> to disallow it
+ *
+ * @throws OperationFailedException if initializing local video fails.
+ */
+ public void setLocalVideoAllowed( Call call,
+ MediaDevice mediaDevice,
+ boolean allowed)
+ throws OperationFailedException;
}
diff --git a/src/net/java/sip/communicator/service/protocol/media/MediaAwareCall.java b/src/net/java/sip/communicator/service/protocol/media/MediaAwareCall.java
index 49999c6..c495d9a 100644
--- a/src/net/java/sip/communicator/service/protocol/media/MediaAwareCall.java
+++ b/src/net/java/sip/communicator/service/protocol/media/MediaAwareCall.java
@@ -84,6 +84,20 @@ public abstract class MediaAwareCall<
protected MediaUseCase mediaUseCase = MediaUseCase.ANY;
/**
+ * The <tt>MediaDevice</tt> for video we should use in the call.
+ * In case this member is null, a lookup corresponding to MediaType.VIDEO is
+ * performed to the <tt>MediaService</tt>.
+ */
+ private MediaDevice videoDevice = null;
+
+ /**
+ * The <tt>MediaDevice</tt> for audio we should use in the call.
+ * In case this member is null, a lookup corresponding to MediaType.AUDIO is
+ * performed to the <tt>MediaService</tt>.
+ */
+ private MediaDevice audioDevice = null;
+
+ /**
* The listener that would actually subscribe for level events from the
* media handler if there's at least one listener in
* <tt>localUserAudioLevelListeners</tt>.
@@ -234,7 +248,6 @@ public abstract class MediaAwareCall<
* @param evt The <tt>CallPeerChangeEvent</tt> instance containing
* the source event as well as its previous and its new status.
*/
- @SuppressWarnings("unchecked") // should refactor at some point
public void peerStateChanged(CallPeerChangeEvent evt)
{
CallPeerState newState = (CallPeerState) evt.getNewValue();
@@ -331,9 +344,27 @@ public abstract class MediaAwareCall<
*/
public MediaDevice getDefaultDevice(MediaType mediaType)
{
+ MediaDevice device = null;
MediaService mediaService = ProtocolMediaActivator.getMediaService();
- MediaDevice device = mediaService.getDefaultDevice(mediaType,
- mediaUseCase);
+
+ switch(mediaType)
+ {
+ case AUDIO:
+ device = audioDevice;
+ break;
+ case VIDEO:
+ device = videoDevice;
+ break;
+ default:
+ /* no other type supported */
+ return null;
+ }
+
+ if(device == null)
+ {
+ device = mediaService.getDefaultDevice(mediaType,
+ mediaUseCase);
+ }
if (MediaType.AUDIO.equals(mediaType))
{
@@ -611,4 +642,25 @@ public abstract class MediaAwareCall<
}
return recorder;
}
+
+
+ /**
+ * Set the <tt>MediaDevice</tt> used for the video.
+ *
+ * @param dev video <tt>MediaDevice</tt>
+ */
+ public void setVideoDevice(MediaDevice dev)
+ {
+ videoDevice = dev;
+ }
+
+ /**
+ * Set the <tt>MediaDevice</tt> used for the audio.
+ *
+ * @param dev audio <tt>MediaDevice</tt>
+ */
+ public void setAudioDevice(MediaDevice dev)
+ {
+ this.audioDevice = dev;
+ }
}
diff --git a/src/net/java/sip/communicator/util/SortedProperties.java b/src/net/java/sip/communicator/util/SortedProperties.java
index afc3c59..9c1ea18 100644
--- a/src/net/java/sip/communicator/util/SortedProperties.java
+++ b/src/net/java/sip/communicator/util/SortedProperties.java
@@ -23,7 +23,7 @@ public class SortedProperties extends Properties
/**
* Get an enumeration of keys hold by the <tt>Properties</tt> object.
- * Contrary to the original <tt>Properties</tt> implementation, it force
+ * Contrary to the original <tt>Properties</tt> implementation, it forces
* the keys to be sorted alphabetically.
*/
public synchronized Enumeration<Object> keys()