Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.neomedia.device
Class DeviceConfiguration

java.lang.Object
  extended by net.java.sip.communicator.util.PropertyChangeNotifier
      extended by net.java.sip.communicator.impl.neomedia.device.DeviceConfiguration
All Implemented Interfaces:
PropertyChangeListener, EventListener, PortAudioDeviceChangedCallback

public class DeviceConfiguration
extends PropertyChangeNotifier
implements PropertyChangeListener, PortAudioDeviceChangedCallback

This class aims to provide a simple configuration interface for JMF. It retrieves stored configuration when started or listens to ConfigurationEvent for property changes and configures the JMF accordingly.

Author:
Martin Andre, Emil Ivov, Lyubomir Marinov

Field Summary
static String AUDIO_CAPTURE_DEVICE
          The name of the DeviceConfiguration property which represents the device used by DeviceConfiguration for audio capture.
static String AUDIO_NONE
          When audio is disabled the selected audio system is with name None.
static String AUDIO_NOTIFY_DEVICE
          The name of the DeviceConfiguration property which represents the device used by DeviceConfiguration for audio notify.
static String AUDIO_PLAYBACK_DEVICE
          The name of the DeviceConfiguration property which represents the device used by DeviceConfiguration for audio playback.
static String AUDIO_SYSTEM_JAVASOUND
          JavaSound sound system.
static String AUDIO_SYSTEM_PORTAUDIO
          PortAudio sound system.
static int DEFAULT_FRAME_RATE
          The default frame rate, -1 unlimited.
static int DEFAULT_VIDEO_HEIGHT
          The default video height.
static int DEFAULT_VIDEO_MAX_BANDWIDTH
          The default value for video maximum bandwidth.
static int DEFAULT_VIDEO_WIDTH
          The default video width.
(package private) static String PROP_AUDIO_DENOISE
          The name of the boolean property which determines whether noise suppression is to be performed for captured audio.
(package private) static String PROP_AUDIO_ECHOCANCEL
          The name of the boolean property which determines whether echo cancellation is to be performed for captured audio.
(package private) static String PROP_AUDIO_ECHOCANCEL_FILTER_LENGTH_IN_MILLIS
          The name of the long property which determines the filter length in milliseconds to be used by the echo cancellation implementation.
static Dimension[] SUPPORTED_RESOLUTIONS
          The currently supported resolutions we will show as option and user can select.
static String VIDEO_CAPTURE_DEVICE
          The name of the DeviceConfiguration property which represents the device used by DeviceConfiguration for video capture.
 
Constructor Summary
DeviceConfiguration()
           
 
Method Summary
static void addAudioSystem(String audioSystemName)
          Adds audio system.
 void deviceChanged()
          Callback when PortAudio device changed.
 javax.media.CaptureDeviceInfo getAudioCaptureDevice()
          Returns a device that we could use for audio capture.
 javax.media.CaptureDeviceInfo getAudioNotifyDevice()
           
 javax.media.CaptureDeviceInfo getAudioPlaybackDevice()
           
 String getAudioSystem()
          The current selected audio system.
 javax.media.CaptureDeviceInfo[] getAvailableAudioCaptureDevices()
          Gets the list of audio capture devices which are available through this DeviceConfiguration, amongst which is getAudioCaptureDevice() and represent acceptable values for setAudioCaptureDevice(CaptureDeviceInfo, boolean)
 javax.media.CaptureDeviceInfo[] getAvailableAudioCaptureDevices(String soundSystem)
          Gets the list of audio capture devices which are available through this DeviceConfiguration, amongst which is getAudioCaptureDevice() and represent acceptable values for setAudioCaptureDevice(CaptureDeviceInfo, boolean)
 javax.media.CaptureDeviceInfo[] getAvailableAudioPlaybackDevices()
          Lists all the playback devices.
 String[] getAvailableAudioSystems()
          Return the installed Audio Systems.
 javax.media.CaptureDeviceInfo[] getAvailableVideoCaptureDevices(MediaUseCase useCase)
          Gets the list of video capture devices which are available through this DeviceConfiguration, amongst which is getVideoCaptureDevice(MediaUseCase) and represent acceptable values for setVideoCaptureDevice(CaptureDeviceInfo, boolean)
 long getEchoCancelFilterLengthInMillis()
          Get the echo cancellation filter length (in milliseconds).
 int getFrameRate()
          Gets the frame rate set on this DeviceConfiguration.
 javax.media.CaptureDeviceInfo getVideoCaptureDevice(MediaUseCase useCase)
          Returns a device that we could use for video capture.
 int getVideoMaxBandwidth()
          Gets the maximum allowed video bandwidth.
 Dimension getVideoSize()
          Gets the video size set on this DeviceConfiguration.
 void initialize()
          Initializes capture devices.
 boolean isAudioCaptureSupported()
          Enable or disable Audio stream transmission.
 boolean isDenoise()
          Gets the indicator which determines whether noise suppression is to be performed for captured audio
 boolean isEchoCancel()
          Gets the indicator which determines whether echo cancellation is to be performed for captured audio.
 boolean isVideoCaptureSupported()
          Enable or disable Video stream transmission.
 void propertyChange(PropertyChangeEvent evt)
          Listens for changes in the configuration and if such happen we reset local values so next time we will update from the configuration.
 void reinitializeVideo()
          Reinitialize video capture devices.
 void setAudioCaptureDevice(javax.media.CaptureDeviceInfo device, boolean save)
          Sets the device which is to be used by this DeviceConfiguration for audio capture.
 void setAudioNotifyDevice(javax.media.CaptureDeviceInfo audioNotifyDevice, boolean save)
          Sets the notify device.
 void setAudioPlaybackDevice(javax.media.CaptureDeviceInfo audioPlaybackDevice, boolean save)
          Set audio playback device.
 void setAudioSystem(String name, javax.media.CaptureDeviceInfo captureDevice, boolean save)
          Changes the current audio system.
 void setDenoise(boolean denoise)
          Sets the indicator which determines whether noise suppression is to be performed for captured audio.
 void setEchoCancel(boolean echoCancel)
          Sets the indicator which determines whether echo cancellation is to be performed for captured audio.
 void setFrameRate(int frameRate)
          Sets and stores the frame rate.
 void setVideoCaptureDevice(javax.media.CaptureDeviceInfo device, boolean save)
          Sets the device which is to be used by this DeviceConfiguration for video capture.
 void setVideoMaxBandwidth(int videoMaxBandwidth)
          Sets and stores the maximum allowed video bandwidth.
 void setVideoSize(Dimension videoSize)
          Sets and stores the video size.
 
Methods inherited from class net.java.sip.communicator.util.PropertyChangeNotifier
addPropertyChangeListener, firePropertyChange, getPropertyChangeSource, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AUDIO_CAPTURE_DEVICE

public static final String AUDIO_CAPTURE_DEVICE
The name of the DeviceConfiguration property which represents the device used by DeviceConfiguration for audio capture.

See Also:
Constant Field Values

AUDIO_PLAYBACK_DEVICE

public static final String AUDIO_PLAYBACK_DEVICE
The name of the DeviceConfiguration property which represents the device used by DeviceConfiguration for audio playback.

See Also:
Constant Field Values

AUDIO_NOTIFY_DEVICE

public static final String AUDIO_NOTIFY_DEVICE
The name of the DeviceConfiguration property which represents the device used by DeviceConfiguration for audio notify.

See Also:
Constant Field Values

VIDEO_CAPTURE_DEVICE

public static final String VIDEO_CAPTURE_DEVICE
The name of the DeviceConfiguration property which represents the device used by DeviceConfiguration for video capture.

See Also:
Constant Field Values

AUDIO_NONE

public static final String AUDIO_NONE
When audio is disabled the selected audio system is with name None. Used and for audio devices, when disabled are set in configuration to None.

See Also:
Constant Field Values

AUDIO_SYSTEM_JAVASOUND

public static final String AUDIO_SYSTEM_JAVASOUND
JavaSound sound system.

See Also:
Constant Field Values

AUDIO_SYSTEM_PORTAUDIO

public static final String AUDIO_SYSTEM_PORTAUDIO
PortAudio sound system.

See Also:
Constant Field Values

PROP_AUDIO_ECHOCANCEL

static final String PROP_AUDIO_ECHOCANCEL
The name of the boolean property which determines whether echo cancellation is to be performed for captured audio.

See Also:
Constant Field Values

PROP_AUDIO_ECHOCANCEL_FILTER_LENGTH_IN_MILLIS

static final String PROP_AUDIO_ECHOCANCEL_FILTER_LENGTH_IN_MILLIS
The name of the long property which determines the filter length in milliseconds to be used by the echo cancellation implementation. The recommended filter length is approximately the third of the room reverberation time. For example, in a small room, reverberation time is in the order of 300 ms, so a filter length of 100 ms is a good choice (800 samples at 8000 Hz sampling rate).

See Also:
Constant Field Values

PROP_AUDIO_DENOISE

static final String PROP_AUDIO_DENOISE
The name of the boolean property which determines whether noise suppression is to be performed for captured audio.

See Also:
Constant Field Values

DEFAULT_FRAME_RATE

public static final int DEFAULT_FRAME_RATE
The default frame rate, -1 unlimited.

See Also:
Constant Field Values

DEFAULT_VIDEO_MAX_BANDWIDTH

public static final int DEFAULT_VIDEO_MAX_BANDWIDTH
The default value for video maximum bandwidth.

See Also:
Constant Field Values

DEFAULT_VIDEO_WIDTH

public static final int DEFAULT_VIDEO_WIDTH
The default video width.

See Also:
Constant Field Values

DEFAULT_VIDEO_HEIGHT

public static final int DEFAULT_VIDEO_HEIGHT
The default video height.

See Also:
Constant Field Values

SUPPORTED_RESOLUTIONS

public static final Dimension[] SUPPORTED_RESOLUTIONS
The currently supported resolutions we will show as option and user can select.

Constructor Detail

DeviceConfiguration

public DeviceConfiguration()
Method Detail

initialize

public void initialize()
Initializes capture devices.


reinitializeVideo

public void reinitializeVideo()
Reinitialize video capture devices.


getAudioCaptureDevice

public javax.media.CaptureDeviceInfo getAudioCaptureDevice()
Returns a device that we could use for audio capture.

Returns:
the CaptureDeviceInfo of a device that we could use for audio capture.

getAvailableAudioCaptureDevices

public javax.media.CaptureDeviceInfo[] getAvailableAudioCaptureDevices()
Gets the list of audio capture devices which are available through this DeviceConfiguration, amongst which is getAudioCaptureDevice() and represent acceptable values for setAudioCaptureDevice(CaptureDeviceInfo, boolean)

Returns:
an array of CaptureDeviceInfo describing the audio capture devices available through this DeviceConfiguration

getAvailableAudioCaptureDevices

public javax.media.CaptureDeviceInfo[] getAvailableAudioCaptureDevices(String soundSystem)
Gets the list of audio capture devices which are available through this DeviceConfiguration, amongst which is getAudioCaptureDevice() and represent acceptable values for setAudioCaptureDevice(CaptureDeviceInfo, boolean)

Parameters:
soundSystem - filter capture devices only from the supplied audio system.
Returns:
an array of CaptureDeviceInfo describing the audio capture devices available through this DeviceConfiguration

getAvailableAudioPlaybackDevices

public javax.media.CaptureDeviceInfo[] getAvailableAudioPlaybackDevices()
Lists all the playback devices. These are only portaudio devices as we can only set particular device for playback when using portaudio.

Returns:
the devices that can be used for playback.

getAvailableVideoCaptureDevices

public javax.media.CaptureDeviceInfo[] getAvailableVideoCaptureDevices(MediaUseCase useCase)
Gets the list of video capture devices which are available through this DeviceConfiguration, amongst which is getVideoCaptureDevice(MediaUseCase) and represent acceptable values for setVideoCaptureDevice(CaptureDeviceInfo, boolean)

Parameters:
useCase - extract video capture devices that correspond to this MediaUseCase
Returns:
an array of CaptureDeviceInfo describing the video capture devices available through this DeviceConfiguration

getVideoCaptureDevice

public javax.media.CaptureDeviceInfo getVideoCaptureDevice(MediaUseCase useCase)
Returns a device that we could use for video capture.

Parameters:
useCase - MediaUseCase that will determined device we will use
Returns:
the CaptureDeviceInfo of a device that we could use for video capture.

setVideoCaptureDevice

public void setVideoCaptureDevice(javax.media.CaptureDeviceInfo device,
                                  boolean save)
Sets the device which is to be used by this DeviceConfiguration for video capture.

Parameters:
device - a CaptureDeviceInfo describing device to be used by this DeviceConfiguration for video capture.
save - whether we will save this option or not.

setAudioCaptureDevice

public void setAudioCaptureDevice(javax.media.CaptureDeviceInfo device,
                                  boolean save)
Sets the device which is to be used by this DeviceConfiguration for audio capture.

Parameters:
device - a CaptureDeviceInfo describing the device to be used by this DeviceConfiguration for audio capture
save - whether we will save this option or not.

isAudioCaptureSupported

public boolean isAudioCaptureSupported()
Enable or disable Audio stream transmission.

Returns:
true if audio capture is supported and false otherwise.

isVideoCaptureSupported

public boolean isVideoCaptureSupported()
Enable or disable Video stream transmission.

Returns:
true if audio capture is supported and false otherwise.

getAvailableAudioSystems

public String[] getAvailableAudioSystems()
Return the installed Audio Systems.

Returns:
the audio systems names.

addAudioSystem

public static void addAudioSystem(String audioSystemName)
Adds audio system.

Parameters:
audioSystemName - the name of the audio system.

getAudioSystem

public String getAudioSystem()
The current selected audio system.

Returns:
the name of the current audio system.

setAudioSystem

public void setAudioSystem(String name,
                           javax.media.CaptureDeviceInfo captureDevice,
                           boolean save)
Changes the current audio system. When javasound is selected we also change the capture device.

Parameters:
name - the name of the audio system.
captureDevice - the selected capture device, if is null we will choose a default one. Param used when first time initing and extracting config.
save - whether we will save this new option or not.

getAudioPlaybackDevice

public javax.media.CaptureDeviceInfo getAudioPlaybackDevice()
Returns:
the audioPlaybackDevice

getAudioNotifyDevice

public javax.media.CaptureDeviceInfo getAudioNotifyDevice()
Returns:
the audioNotifyDevice

setAudioPlaybackDevice

public void setAudioPlaybackDevice(javax.media.CaptureDeviceInfo audioPlaybackDevice,
                                   boolean save)
Set audio playback device.

Parameters:
audioPlaybackDevice - the audioPlaybackDevice to set.
save - whether we will save this option or not.

setAudioNotifyDevice

public void setAudioNotifyDevice(javax.media.CaptureDeviceInfo audioNotifyDevice,
                                 boolean save)
Sets the notify device.

Parameters:
audioNotifyDevice - the audioNotifyDevice to set
save - whether we will save this option or not.

setEchoCancel

public void setEchoCancel(boolean echoCancel)
Sets the indicator which determines whether echo cancellation is to be performed for captured audio.

Parameters:
echoCancel - true if echo cancellation is to be performed for captured audio; otherwise, false

setDenoise

public void setDenoise(boolean denoise)
Sets the indicator which determines whether noise suppression is to be performed for captured audio.

Parameters:
denoise - true if noise suppression is to be performed for captured audio; otherwise, false

isEchoCancel

public boolean isEchoCancel()
Gets the indicator which determines whether echo cancellation is to be performed for captured audio.

Returns:
true if echo cancellation is to be performed for captured audio; otherwise, false

getEchoCancelFilterLengthInMillis

public long getEchoCancelFilterLengthInMillis()
Get the echo cancellation filter length (in milliseconds).

Returns:
echo cancel filter length in milliseconds

isDenoise

public boolean isDenoise()
Gets the indicator which determines whether noise suppression is to be performed for captured audio

Returns:
true if noise suppression is to be performed for captured audio; otherwise, false

getVideoMaxBandwidth

public int getVideoMaxBandwidth()
Gets the maximum allowed video bandwidth.

Returns:
the maximum allowed video bandwidth. The default value is DEFAULT_VIDEO_MAX_BANDWIDTH.

setVideoMaxBandwidth

public void setVideoMaxBandwidth(int videoMaxBandwidth)
Sets and stores the maximum allowed video bandwidth.

Parameters:
videoMaxBandwidth - the maximum allowed video bandwidth

getFrameRate

public int getFrameRate()
Gets the frame rate set on this DeviceConfiguration.

Returns:
the frame rate set on this DeviceConfiguration. The default value is DEFAULT_FRAME_RATE

setFrameRate

public void setFrameRate(int frameRate)
Sets and stores the frame rate.

Parameters:
frameRate - the frame rate to be set on this DeviceConfiguration

getVideoSize

public Dimension getVideoSize()
Gets the video size set on this DeviceConfiguration.

Returns:
the video size set on this DeviceConfiguration

setVideoSize

public void setVideoSize(Dimension videoSize)
Sets and stores the video size.

Parameters:
videoSize - the video size to be set on this DeviceConfiguration

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Listens for changes in the configuration and if such happen we reset local values so next time we will update from the configuration.

Specified by:
propertyChange in interface PropertyChangeListener
Parameters:
evt - the property change event

deviceChanged

public void deviceChanged()
Callback when PortAudio device changed.

Specified by:
deviceChanged in interface PortAudioDeviceChangedCallback

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.