Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.neomedia.audiolevel
Class AudioLevelMap

java.lang.Object
  extended by net.java.sip.communicator.impl.neomedia.audiolevel.AudioLevelMap

public class AudioLevelMap
extends Object

The class implements a basic mapping utility that allows binding long CSRC ID-s to int audio levels. The class does not implement any synchronization for neither read nor write operations but it is still intended to handle concurrent access in a manner that can be considered graceful for the audio level use case. The class uses a bi-dimensional long[][] matrix that is recreated every time a new CSRC is added or an existing one is removed. Iterating through the matrix is only possible after obtaining a direct reference to it. It is possible for this reference to become invalid shortly after someone has obtained it (e.g. because someone added a new CSRC) but this should not cause problems for the CSRC audio level delivery case.

Author:
Emil Ivov

Constructor Summary
AudioLevelMap()
           
 
Method Summary
 int getLevel(long csrc)
          Returns the audio level of the specified csrc id or -1 if csrc is not currently registered in this map.
 void putLevel(long csrc, int level)
          If this map already contains csrc this method updates its level, otherwise we add a new entry mapping csrc to level.
 boolean removeLevel(long csrc)
          Removes csrc and its mapped level from this map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AudioLevelMap

public AudioLevelMap()
Method Detail

putLevel

public void putLevel(long csrc,
                     int level)
If this map already contains csrc this method updates its level, otherwise we add a new entry mapping csrc to level.

Parameters:
csrc - the CSRC key that we'd like to add/update.
level - the new audio level for the specified csrc.

removeLevel

public boolean removeLevel(long csrc)
Removes csrc and its mapped level from this map.

Parameters:
csrc - the CSRC ID that we'd like to remove from this map.
Returns:
true if csrc was present in the Map and false otherwise.

getLevel

public int getLevel(long csrc)
Returns the audio level of the specified csrc id or -1 if csrc is not currently registered in this map.

Parameters:
csrc - the CSRC ID whose level we'd like to obtain.
Returns:
the audio level of the specified csrc id or -1 if csrc is not currently registered in this map.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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