Package org.jitsi.impl.neomedia.device
Class AudioSystem
- java.lang.Object
-
- org.jitsi.utils.event.PropertyChangeNotifier
-
- org.jitsi.impl.neomedia.device.DeviceSystem
-
- org.jitsi.impl.neomedia.device.AudioSystem
-
- Direct Known Subclasses:
AudioSilenceSystem,AudioSystem2,NoneAudioSystem,PulseAudioSystem,WASAPISystem
public abstract class AudioSystem extends DeviceSystem
Represents a DeviceSystem which provides support for the devices to capture and play back audio (media). Examples include implementations which integrate the native PortAudio, PulseAudio libraries.- Author:
- Lyubomir Marinov, Vincent Lucas, Timothy Price
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAudioSystem.DataFlowEnumerates the different types of media data flow of CaptureDeviceInfo2s contributed by an AudioSystem.
-
Field Summary
Fields Modifier and Type Field Description static intFEATURE_AGCThe constant/flag (to be) returned byDeviceSystem.getFeatures()in order to indicate that the respective AudioSystem supports toggling its automatic gain control (AGC) functionality between on and off.static intFEATURE_DENOISEThe constant/flag (to be) returned byDeviceSystem.getFeatures()in order to indicate that the respective AudioSystem supports toggling its denoise functionality between on and off.static intFEATURE_ECHO_CANCELLATIONThe constant/flag (to be) returned byDeviceSystem.getFeatures()in order to indicate that the respective AudioSystem supports toggling its echo cancellation functionality between on and off.static intFEATURE_NOTIFY_AND_PLAYBACK_DEVICESThe constant/flag (to be) returned byDeviceSystem.getFeatures()in order to indicate that the respective AudioSystem differentiates between playback and notification audio devices.static StringLOCATOR_PROTOCOL_AUDIORECORDstatic StringLOCATOR_PROTOCOL_AUDIOSILENCEstatic StringLOCATOR_PROTOCOL_JAVASOUNDstatic StringLOCATOR_PROTOCOL_MACCOREAUDIOThe protocol of the MediaLocators identifying CaptureDeviceInfos contributed by MacCoreaudioSystem.static StringLOCATOR_PROTOCOL_OPENSLESstatic StringLOCATOR_PROTOCOL_PORTAUDIOstatic StringLOCATOR_PROTOCOL_PULSEAUDIOstatic StringLOCATOR_PROTOCOL_WASAPIThe protocol of the MediaLocators identifying CaptureDeviceInfos contributed by WASAPISystem.protected static StringPNAME_DENOISEThe (base) name of the ConfigurationService property which indicates whether noise suppression is to be performed for the captured audio.protected static StringPNAME_ECHOCANCELThe (base) name of the ConfigurationService property which indicates whether noise cancellation is to be performed for the captured audio.-
Fields inherited from class org.jitsi.impl.neomedia.device.DeviceSystem
FEATURE_REINITIALIZE, LOCATOR_PROTOCOL_ANDROIDCAMERA, LOCATOR_PROTOCOL_CIVIL, LOCATOR_PROTOCOL_DIRECTSHOW, LOCATOR_PROTOCOL_IMGSTREAMING, LOCATOR_PROTOCOL_MEDIARECORDER, LOCATOR_PROTOCOL_QUICKTIME, LOCATOR_PROTOCOL_VIDEO4LINUX2, PROP_DEVICES
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAudioSystem(String locatorProtocol)protectedAudioSystem(String locatorProtocol, int features)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.media.RenderercreateRenderer()Initializes a new Renderer instance which is to perform playback on a device contributed by this system.javax.media.RenderercreateRenderer(boolean playback)Initializes a new Renderer instance which is to either perform playback on or sound a notification through a device contributed by this system.InputStreamgetAudioInputStream(String uri)Obtains an audio input stream from the URL provided.static AudioSystemgetAudioSystem(String locatorProtocol)static AudioSystem[]getAudioSystems()CaptureDeviceInfo2getDevice(AudioSystem.DataFlow dataFlow, javax.media.MediaLocator locator)Gets a CaptureDeviceInfo2 which has been contributed by this AudioSystem, supports a specific flow of media data (i.e.List<CaptureDeviceInfo2>getDevices(AudioSystem.DataFlow dataFlow)Gets the list of devices with a specific data flow: capture, notify or playback.javax.media.format.AudioFormatgetFormat(InputStream audioInputStream)Returns the FMJ format of a specific InputStream providing audio media.protected StringgetPropertyName(String basePropertyName)Gets the (full) name of the ConfigurationService property which is associated with a (base) AudioSystem-specific property name.CaptureDeviceInfo2getSelectedDevice(AudioSystem.DataFlow dataFlow)Gets the selected device for a specific data flow: capture, notify or playback.booleanisAutomaticGainControl()Gets the indicator which determines whether automatic gain control (AGC) is to be performed for captured audio.booleanisDenoise()Gets the indicator which determines whether noise suppression is to be performed for captured audio.booleanisEchoCancel()Gets the indicator which determines whether echo cancellation is to be performed for captured audio.protected voidpostInitialize()Invoked as part of the execution ofDeviceSystem.initialize()after the execution ofDeviceSystem.doInitialize()regardless of whether the latter completed successfully.protected voidpostInitializeSpecificDevices(AudioSystem.DataFlow dataFlow)Sets the device lists after the different audio systems (PortAudio, PulseAudio, etc) have finished detecting their devices.protected voidpreInitialize()Invoked as part of the execution ofDeviceSystem.initialize()before the execution ofDeviceSystem.doInitialize().voidsetAutomaticGainControl(boolean automaticGainControl)Sets the indicator which determines whether automatic gain control (AGC) is to be performed for captured audio.protected voidsetCaptureDevices(List<CaptureDeviceInfo2> captureDevices)Sets the list of a kind of devices: capture, notify or playback.voidsetDenoise(boolean denoise)Sets the indicator which determines whether noise suppression is to be performed for captured audio.voidsetDevice(AudioSystem.DataFlow dataFlow, CaptureDeviceInfo2 device, boolean save)Selects the active device.voidsetEchoCancel(boolean echoCancel)Sets the indicator which determines whether echo cancellation is to be performed for captured audio.protected voidsetPlaybackDevices(List<CaptureDeviceInfo2> playbackDevices)Sets the list of the active devices.-
Methods inherited from class org.jitsi.impl.neomedia.device.DeviceSystem
doInitialize, filterDeviceListByLocatorProtocol, getDeviceSystems, getFeatures, getFormat, getLocatorProtocol, getMediaType, getRendererClassName, initialize, initializeDeviceSystems, initializeDeviceSystems, toString
-
-
-
-
Field Detail
-
FEATURE_AGC
public static final int FEATURE_AGC
The constant/flag (to be) returned byDeviceSystem.getFeatures()in order to indicate that the respective AudioSystem supports toggling its automatic gain control (AGC) functionality between on and off. The UI will look for the presence of the flag in order to determine whether a check box is to be shown to the user to enable toggling the automatic gain control (AGC) functionality.- See Also:
- Constant Field Values
-
FEATURE_DENOISE
public static final int FEATURE_DENOISE
The constant/flag (to be) returned byDeviceSystem.getFeatures()in order to indicate that the respective AudioSystem supports toggling its denoise functionality between on and off. The UI will look for the presence of the flag in order to determine whether a check box is to be shown to the user to enable toggling the denoise functionality.- See Also:
- Constant Field Values
-
FEATURE_ECHO_CANCELLATION
public static final int FEATURE_ECHO_CANCELLATION
The constant/flag (to be) returned byDeviceSystem.getFeatures()in order to indicate that the respective AudioSystem supports toggling its echo cancellation functionality between on and off. The UI will look for the presence of the flag in order to determine whether a check box is to be shown to the user to enable toggling the echo cancellation functionality.- See Also:
- Constant Field Values
-
FEATURE_NOTIFY_AND_PLAYBACK_DEVICES
public static final int FEATURE_NOTIFY_AND_PLAYBACK_DEVICES
The constant/flag (to be) returned byDeviceSystem.getFeatures()in order to indicate that the respective AudioSystem differentiates between playback and notification audio devices. The UI, for example, will look for the presence of the flag in order to determine whether separate combo boxes are to be shown to the user to allow the configuration of the preferred playback and notification audio devices.- See Also:
- Constant Field Values
-
LOCATOR_PROTOCOL_AUDIORECORD
public static final String LOCATOR_PROTOCOL_AUDIORECORD
- See Also:
- Constant Field Values
-
LOCATOR_PROTOCOL_AUDIOSILENCE
public static final String LOCATOR_PROTOCOL_AUDIOSILENCE
- See Also:
- Constant Field Values
-
LOCATOR_PROTOCOL_JAVASOUND
public static final String LOCATOR_PROTOCOL_JAVASOUND
- See Also:
- Constant Field Values
-
LOCATOR_PROTOCOL_MACCOREAUDIO
public static final String LOCATOR_PROTOCOL_MACCOREAUDIO
The protocol of the MediaLocators identifying CaptureDeviceInfos contributed by MacCoreaudioSystem.- See Also:
- Constant Field Values
-
LOCATOR_PROTOCOL_OPENSLES
public static final String LOCATOR_PROTOCOL_OPENSLES
- See Also:
- Constant Field Values
-
LOCATOR_PROTOCOL_PORTAUDIO
public static final String LOCATOR_PROTOCOL_PORTAUDIO
- See Also:
- Constant Field Values
-
LOCATOR_PROTOCOL_PULSEAUDIO
public static final String LOCATOR_PROTOCOL_PULSEAUDIO
- See Also:
- Constant Field Values
-
LOCATOR_PROTOCOL_WASAPI
public static final String LOCATOR_PROTOCOL_WASAPI
The protocol of the MediaLocators identifying CaptureDeviceInfos contributed by WASAPISystem.- See Also:
- Constant Field Values
-
PNAME_DENOISE
protected static final String PNAME_DENOISE
The (base) name of the ConfigurationService property which indicates whether noise suppression is to be performed for the captured audio.- See Also:
- Constant Field Values
-
PNAME_ECHOCANCEL
protected static final String PNAME_ECHOCANCEL
The (base) name of the ConfigurationService property which indicates whether noise cancellation is to be performed for the captured audio.- See Also:
- Constant Field Values
-
-
Method Detail
-
getAudioSystem
public static AudioSystem getAudioSystem(String locatorProtocol)
-
getAudioSystems
public static AudioSystem[] getAudioSystems()
-
createRenderer
public javax.media.Renderer createRenderer()
Initializes a new Renderer instance which is to perform playback on a device contributed by this system. Delegates tocreateRenderer(boolean)with the value of the playback argument set to true.- Overrides:
createRendererin classDeviceSystem- Returns:
- a new Renderer instance which is to perform playback on a device contributed by this system or null
-
createRenderer
public javax.media.Renderer createRenderer(boolean playback)
Initializes a new Renderer instance which is to either perform playback on or sound a notification through a device contributed by this system. The (default) implementation of AudioSystem ignores the value of the playback argument and delegates toDeviceSystem.createRenderer().- Parameters:
playback- true if the new instance is to perform playback or false if the new instance is to sound a notification- Returns:
- a new Renderer instance which is to either perform playback on or sound a notification through a device contributed by this system
-
getAudioInputStream
public InputStream getAudioInputStream(String uri) throws IOException
Obtains an audio input stream from the URL provided.- Parameters:
uri- a valid uri to a sound resource.- Returns:
- the input stream to audio data.
- Throws:
IOException- if an I/O exception occurs
-
getDevice
public CaptureDeviceInfo2 getDevice(AudioSystem.DataFlow dataFlow, javax.media.MediaLocator locator)
Gets a CaptureDeviceInfo2 which has been contributed by this AudioSystem, supports a specific flow of media data (i.e. capture, notify or playback) and is identified by a specific MediaLocator.- Parameters:
dataFlow- the flow of the media data supported by the CaptureDeviceInfo2 to be returnedlocator- the MediaLocator of the CaptureDeviceInfo2 to be returned- Returns:
- a CaptureDeviceInfo2 which has been contributed by this instance, supports the specified dataFlow and is identified by the specified locator
-
getDevices
public List<CaptureDeviceInfo2> getDevices(AudioSystem.DataFlow dataFlow)
Gets the list of devices with a specific data flow: capture, notify or playback.- Parameters:
dataFlow- the data flow of the devices to retrieve: capture, notify or playback- Returns:
- the list of devices with the specified dataFlow
-
getFormat
public javax.media.format.AudioFormat getFormat(InputStream audioInputStream)
Returns the FMJ format of a specific InputStream providing audio media.- Parameters:
audioInputStream- the InputStream providing audio media to determine the FMJ format of- Returns:
- the FMJ format of the specified audioInputStream or null if such an FMJ format could not be determined
-
getPropertyName
protected String getPropertyName(String basePropertyName)
Gets the (full) name of the ConfigurationService property which is associated with a (base) AudioSystem-specific property name.- Parameters:
basePropertyName- the (base) AudioSystem-specific property name of which the associated (full) ConfigurationService property name is to be returned- Returns:
- the (full) name of the ConfigurationService property which is associated with the (base) AudioSystem-specific property name
-
getSelectedDevice
public CaptureDeviceInfo2 getSelectedDevice(AudioSystem.DataFlow dataFlow)
Gets the selected device for a specific data flow: capture, notify or playback.- Parameters:
dataFlow- the data flow of the selected device to retrieve: capture, notify or playback.- Returns:
- the selected device for the specified dataFlow
-
isAutomaticGainControl
public boolean isAutomaticGainControl()
Gets the indicator which determines whether automatic gain control (AGC) is to be performed for captured audio.- Returns:
- true if automatic gain control (AGC) is to be performed for captured audio; otherwise, false
-
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
-
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
-
postInitialize
protected void postInitialize() throws ExceptionInvoked as part of the execution ofDeviceSystem.initialize()after the execution ofDeviceSystem.doInitialize()regardless of whether the latter completed successfully. The implementation of DeviceSystem fires a new PropertyChangeEvent to notify that the value of the propertyDeviceSystem.PROP_DEVICESof this instance may have changed i.e. that the list of devices detected by this instance may have changed. Because AudioSystem may support playback and notification audio devices apart from capture audio devices, fires more specific PropertyChangeEvents than DeviceSystem- Overrides:
postInitializein classDeviceSystem- Throws:
Exception
-
postInitializeSpecificDevices
protected void postInitializeSpecificDevices(AudioSystem.DataFlow dataFlow)
Sets the device lists after the different audio systems (PortAudio, PulseAudio, etc) have finished detecting their devices.- Parameters:
dataFlow- the data flow of the devices to perform post-initialization on
-
preInitialize
protected void preInitialize() throws ExceptionInvoked as part of the execution ofDeviceSystem.initialize()before the execution ofDeviceSystem.doInitialize(). The implementation of DeviceSystem removes from FMJ's CaptureDeviceManager the CaptureDeviceInfos whose MediaLocator has the same protocol asDeviceSystem.getLocatorProtocol()of this instance. Removes any capture, playback and notification devices previously detected by this AudioSystem and prepares it for the execution of itsDeviceSystem.doInitialize()implementation (which detects all devices to be provided by this instance).- Overrides:
preInitializein classDeviceSystem- Throws:
Exception
-
setAutomaticGainControl
public void setAutomaticGainControl(boolean automaticGainControl)
Sets the indicator which determines whether automatic gain control (AGC) is to be performed for captured audio.- Parameters:
automaticGainControl- true if automatic gain control (AGC) is to be performed for captured audio; otherwise, false
-
setCaptureDevices
protected void setCaptureDevices(List<CaptureDeviceInfo2> captureDevices)
Sets the list of a kind of devices: capture, notify or playback.- Parameters:
captureDevices- The list of a kind of devices: capture, notify or playback.
-
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
-
setDevice
public void setDevice(AudioSystem.DataFlow dataFlow, CaptureDeviceInfo2 device, boolean save)
Selects the active device.- Parameters:
dataFlow- the data flow of the device to set: capture, notify or playbackdevice- The selected active device.save- Flag set to true in order to save this choice in the configuration. False otherwise.
-
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
-
setPlaybackDevices
protected void setPlaybackDevices(List<CaptureDeviceInfo2> playbackDevices)
Sets the list of the active devices.- Parameters:
playbackDevices- The list of the active devices.
-
-