Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.neomedia
Class AbstractVolumeControl

java.lang.Object
  extended by net.java.sip.communicator.impl.neomedia.AbstractVolumeControl
All Implemented Interfaces:
javax.media.Control, javax.media.GainControl, VolumeControl

public class AbstractVolumeControl
extends Object
implements VolumeControl, javax.media.GainControl

Controls media service volume input or output. If a playback volume level is set we change it on all current players, as we synchronize volume on all players. Implements interface exposed from media service, also implements the interface used in the Renderer part of JMF and merges the two functionalities to work as one.

Author:
Damian Minkov, Lyubomir Marinov

Field Summary
static int MAX_VOLUME_PERCENT
          The maximum volume level expressed in percent accepted by AbstractVolumeControl.
static int MIN_VOLUME_PERCENT
          The minimum volume level expressed in percent accepted by AbstractVolumeControl.
 
Fields inherited from interface net.java.sip.communicator.service.neomedia.VolumeControl
CAPTURE_VOLUME_LEVEL_PROPERTY_NAME, PLAYBACK_VOLUME_LEVEL_PROPERTY_NAME
 
Constructor Summary
AbstractVolumeControl(String volumeLevelConfigurationPropertyName)
          Creates volume control instance and initializes initial level value if stored in the configuration service.
 
Method Summary
 void addGainChangeListener(javax.media.GainChangeListener listener)
          Register for gain change update events.
 void addVolumeChangeListener(VolumeChangeListener listener)
          Adds a VolumeChangeListener to be informed for any change in the volume levels.
static void applyGain(javax.media.GainControl gainControl, byte[] buffer, int offset, int length)
          Applies the gain specified by gainControl to the signal defined by the length number of samples given in buffer starting at offset.
 Component getControlComponent()
          Not used.
 float getDB()
          Get the current gain set for this object in dB.
 float getLevel()
          Get the current gain set for this object as a value between 0.0 and 1.0
 float getMaxValue()
          Returns the maximum allowed volume value.
 float getMinValue()
          Returns the minimum allowed volume value.
 boolean getMute()
          Get mute state of sound.
 float getVolume()
          Current volume value.
 void removeGainChangeListener(javax.media.GainChangeListener listener)
          Remove interest in gain change update events.
 void removeVolumeChangeListener(VolumeChangeListener listener)
          Removes a VolumeChangeListener.
 float setDB(float gain)
          Set the gain in decibels.
 float setLevel(float level)
          Set the gain using a floating point scale with values between 0.0 and 1.0.
 void setMute(boolean mute)
          Mutes current sound.
 float setVolume(float value)
          Changes volume level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_VOLUME_PERCENT

public static final int MIN_VOLUME_PERCENT
The minimum volume level expressed in percent accepted by AbstractVolumeControl.

See Also:
Constant Field Values

MAX_VOLUME_PERCENT

public static final int MAX_VOLUME_PERCENT
The maximum volume level expressed in percent accepted by AbstractVolumeControl.

See Also:
Constant Field Values
Constructor Detail

AbstractVolumeControl

public AbstractVolumeControl(String volumeLevelConfigurationPropertyName)
Creates volume control instance and initializes initial level value if stored in the configuration service.

Parameters:
volumeLevelConfigurationPropertyName - the name of the configuration property which specifies the value of the volume level of the new instance
Method Detail

applyGain

public static void applyGain(javax.media.GainControl gainControl,
                             byte[] buffer,
                             int offset,
                             int length)
Applies the gain specified by gainControl to the signal defined by the length number of samples given in buffer starting at offset.

Parameters:
gainControl - the GainControl which specifies the gain to apply
buffer - the samples of the signal to apply the gain to
offset - the start of the samples of the signal in buffer
length - the number of samples of the signal given in buffer

getVolume

public float getVolume()
Current volume value.

Specified by:
getVolume in interface VolumeControl
Returns:
the current volume level.
See Also:
VolumeControl

getLevel

public float getLevel()
Get the current gain set for this object as a value between 0.0 and 1.0

Specified by:
getLevel in interface javax.media.GainControl
Returns:
The gain in the level scale (0.0-1.0).
See Also:
GainControl

getMinValue

public float getMinValue()
Returns the minimum allowed volume value.

Specified by:
getMinValue in interface VolumeControl
Returns:
the minimum allowed volume value.
See Also:
VolumeControl

getMaxValue

public float getMaxValue()
Returns the maximum allowed volume value.

Specified by:
getMaxValue in interface VolumeControl
Returns:
the maximum allowed volume value.
See Also:
VolumeControl

setVolume

public float setVolume(float value)
Changes volume level.

Specified by:
setVolume in interface VolumeControl
Parameters:
value - the new level to set.
Returns:
the actual level which was set.
See Also:
VolumeControl

setLevel

public float setLevel(float level)
Set the gain using a floating point scale with values between 0.0 and 1.0. 0.0 is silence; 1.0 is the loudest useful level that this GainControl supports.

Specified by:
setLevel in interface javax.media.GainControl
Parameters:
level - The new gain value specified in the level scale.
Returns:
The level that was actually set.
See Also:
GainControl

setMute

public void setMute(boolean mute)
Mutes current sound.

Specified by:
setMute in interface javax.media.GainControl
Specified by:
setMute in interface VolumeControl
Parameters:
mute - mutes/unmutes.

getMute

public boolean getMute()
Get mute state of sound.

Specified by:
getMute in interface javax.media.GainControl
Specified by:
getMute in interface VolumeControl
Returns:
mute state of sound.

setDB

public float setDB(float gain)
Set the gain in decibels. Setting the gain to 0.0 (the default) implies that the audio signal is neither amplified nor attenuated. Positive values amplify the audio signal and negative values attenuate the signal.

Specified by:
setDB in interface javax.media.GainControl
Parameters:
gain - The new gain in dB.
Returns:
The gain that was actually set.
See Also:
GainControl

getDB

public float getDB()
Get the current gain set for this object in dB.

Specified by:
getDB in interface javax.media.GainControl
Returns:
The gain in dB.

addGainChangeListener

public void addGainChangeListener(javax.media.GainChangeListener listener)
Register for gain change update events. A GainChangeEvent is posted when the state of the GainControl changes.

Specified by:
addGainChangeListener in interface javax.media.GainControl
Parameters:
listener - The object to deliver events to.

removeGainChangeListener

public void removeGainChangeListener(javax.media.GainChangeListener listener)
Remove interest in gain change update events.

Specified by:
removeGainChangeListener in interface javax.media.GainControl
Parameters:
listener - The object that has been receiving events.

addVolumeChangeListener

public void addVolumeChangeListener(VolumeChangeListener listener)
Adds a VolumeChangeListener to be informed for any change in the volume levels.

Specified by:
addVolumeChangeListener in interface VolumeControl
Parameters:
listener - volume change listener.

removeVolumeChangeListener

public void removeVolumeChangeListener(VolumeChangeListener listener)
Removes a VolumeChangeListener.

Specified by:
removeVolumeChangeListener in interface VolumeControl
Parameters:
listener - the volume change listener to be removed.

getControlComponent

public Component getControlComponent()
Not used.

Specified by:
getControlComponent in interface javax.media.Control
Returns:
null

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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