aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/service/protocol/media
diff options
context:
space:
mode:
authorLyubomir Marinov <lyubomir.marinov@jitsi.org>2010-08-11 18:45:17 +0000
committerLyubomir Marinov <lyubomir.marinov@jitsi.org>2010-08-11 18:45:17 +0000
commit347408cc5b84a6d8537f2a8b5fe76eb62056fcc8 (patch)
tree729b8e7d232462995cb35273654110b3e52f6c84 /src/net/java/sip/communicator/service/protocol/media
parent13dbadac72e35d87a7f0990389864acd40e72177 (diff)
downloadjitsi-347408cc5b84a6d8537f2a8b5fe76eb62056fcc8.zip
jitsi-347408cc5b84a6d8537f2a8b5fe76eb62056fcc8.tar.gz
jitsi-347408cc5b84a6d8537f2a8b5fe76eb62056fcc8.tar.bz2
Commits callRecording.patch and recordButton.png provided by Dmitri Melnikov on the dev mailing list in the thread "Call Recording".
Diffstat (limited to 'src/net/java/sip/communicator/service/protocol/media')
-rw-r--r--src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetBasicTelephony.java152
-rw-r--r--src/net/java/sip/communicator/service/protocol/media/MediaAwareCall.java38
2 files changed, 189 insertions, 1 deletions
diff --git a/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetBasicTelephony.java b/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetBasicTelephony.java
new file mode 100644
index 0000000..feaaf06
--- /dev/null
+++ b/src/net/java/sip/communicator/service/protocol/media/AbstractOperationSetBasicTelephony.java
@@ -0,0 +1,152 @@
+/*
+ * SIP Communicator, 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.media;
+
+import java.util.*;
+
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.service.protocol.event.*;
+import net.java.sip.communicator.util.*;
+
+/**
+ * Represents a default implementation of <tt>OperationSetBasicTelephony</tt> in
+ * order to make it easier for implementers to provide complete solutions while
+ * focusing on implementation-specific details.
+ *
+ * @param <T> the implementation specific provider class like for example
+ * <tt>ProtocolProviderServiceSipImpl</tt>.
+ *
+ * @author Lubomir Marinov
+ * @author Emil Ivov
+ * @author Dmitri Melnikov
+ */
+public abstract class AbstractOperationSetBasicTelephony
+ <T extends ProtocolProviderService>
+ implements OperationSetBasicTelephony<T>
+{
+ /**
+ * The <tt>Logger</tt> used by the
+ * <tt>AbstractOperationSetBasicTelephony</tt> class and its instances for
+ * logging output.
+ */
+ private static final Logger logger
+ = Logger.getLogger(AbstractOperationSetBasicTelephony.class);
+
+ /**
+ * A list of listeners registered for call events.
+ */
+ private final List<CallListener> callListeners = new Vector<CallListener>();
+
+ /**
+ * Registers <tt>listener</tt> with this provider so that it
+ * could be notified when incoming calls are received.
+ *
+ * @param listener the listener to register with this provider.
+ */
+ public void addCallListener(CallListener listener)
+ {
+ synchronized(callListeners)
+ {
+ if (!callListeners.contains(listener))
+ callListeners.add(listener);
+ }
+ }
+
+ /**
+ * Creates and dispatches a <tt>CallEvent</tt> notifying registered
+ * listeners that an event with id <tt>eventID</tt> has occurred on
+ * <tt>sourceCall</tt>.
+ *
+ * @param eventID the ID of the event to dispatch
+ * @param sourceCall the call on which the event has occurred.
+ */
+ public void fireCallEvent(int eventID, Call sourceCall)
+ {
+ CallEvent cEvent = new CallEvent(sourceCall, eventID);
+ List<CallListener> listeners;
+
+ synchronized (callListeners)
+ {
+ listeners = new ArrayList<CallListener>(callListeners);
+ }
+
+ if (logger.isDebugEnabled())
+ logger.debug("Dispatching a CallEvent to " + listeners.size()
+ + " listeners. event is: " + cEvent);
+
+ for (CallListener listener : listeners)
+ {
+ switch (eventID)
+ {
+ case CallEvent.CALL_INITIATED:
+ listener.outgoingCallCreated(cEvent);
+ break;
+ case CallEvent.CALL_RECEIVED:
+ listener.incomingCallReceived(cEvent);
+ break;
+ case CallEvent.CALL_ENDED:
+ listener.callEnded(cEvent);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Removes the <tt>listener</tt> from the list of call listeners.
+ *
+ * @param listener the listener to unregister.
+ */
+ public void removeCallListener(CallListener listener)
+ {
+ synchronized(callListeners)
+ {
+ callListeners.remove(listener);
+ }
+ }
+
+ /**
+ * Sets the mute state of the <tt>Call</tt>.
+ * <p>
+ * Muting audio streams sent from the call is implementation specific
+ * and one of the possible approaches to it is sending silence.
+ * </p>
+ *
+ * @param call the <tt>Call</tt> whose mute state is to be set
+ * @param mute <tt>true</tt> to mute the call streams being sent to
+ * <tt>peers</tt>; otherwise, <tt>false</tt>
+ */
+ public void setMute(Call call, boolean mute)
+ {
+ /*
+ * While throwing UnsupportedOperationException may be a possible
+ * approach, putOnHold/putOffHold just do nothing when not supported so
+ * this implementation takes inspiration from them.
+ */
+ }
+
+ /**
+ * Starts the recording of the <tt>Call</tt>.
+ *
+ * @param call the <tt>Call</tt> to start recording
+ * @param callFilename call filename, when <tt>null</tt> a default filename
+ * is used
+ */
+ public void startRecording(Call call, String callFilename)
+ {
+ ((MediaAwareCall<?, ?, ?>) call).startRecording(callFilename);
+ }
+
+ /**
+ * Stops the recording of the <tt>Call</tt>.
+ *
+ * @param call the <tt>Call</tt> to stop recording
+ */
+ public void stopRecording(Call call)
+ {
+ ((MediaAwareCall<?, ?, ?>) call).stopRecording();
+ }
+}
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 5dbb3b6..e16f631 100644
--- a/src/net/java/sip/communicator/service/protocol/media/MediaAwareCall.java
+++ b/src/net/java/sip/communicator/service/protocol/media/MediaAwareCall.java
@@ -79,6 +79,11 @@ public abstract class MediaAwareCall<
private boolean mute = false;
/**
+ * The <tt>Recorder</tt> used to record this call.
+ */
+ private Recorder recorder;
+
+ /**
* Device used in call will be chosen according to <tt>MediaUseCase</tt>.
*/
protected MediaUseCase mediaUseCase = MediaUseCase.ANY;
@@ -330,7 +335,7 @@ public abstract class MediaAwareCall<
MediaDevice device = mediaService.getDefaultDevice(mediaType,
mediaUseCase);
- if (MediaType.AUDIO.equals(mediaType) && isConferenceFocus())
+ if (MediaType.AUDIO.equals(mediaType))
{
if (conferenceAudioMixer == null)
{
@@ -565,4 +570,35 @@ public abstract class MediaAwareCall<
peer.removeVideoPropertyChangeListener(listener);
}
}
+
+ /**
+ * Stops the recording of this call.
+ */
+ public void stopRecording()
+ {
+ recorder.stopRecording();
+ }
+
+ /**
+ * Starts the recording of this call.
+ * @param callFilename call filename
+ */
+ public void startRecording(String callFilename)
+ {
+ MediaService mediaService = ProtocolMediaActivator.getMediaService();
+ recorder =
+ mediaService.createRecorder(getDefaultDevice(MediaType.AUDIO));
+
+ recorder.startRecording(callFilename);
+ }
+
+ /**
+ * Returns the recorder used by this instance to record the call.
+ *
+ * @return call recorder
+ */
+ public Recorder getRecorder()
+ {
+ return recorder;
+ }
}