Class AudioLevelEventDispatcher


  • public class AudioLevelEventDispatcher
    extends Object
    The class implements an audio level measurement thread. The thread will measure new data every time it is added through the addData() method and would then deliver it to a registered listener if any. (No measurement would be performed until we have a levelListener). We use a separate thread so that we could compute and deliver audio levels in a way that won't delay the media processing thread.

    Note that, for performance reasons this class is not 100% thread safe and you should not modify add or remove audio listeners in this dispatcher in the notification thread (i.e. in the thread where you were notified of an audio level change).

    Author:
    Damian Minkov, Emil Ivov, Lyubomir Marinov
    • Constructor Detail

      • AudioLevelEventDispatcher

        public AudioLevelEventDispatcher​(String threadName)
        Initializes a new AudioLevelEventDispatcher instance which is to use a specific name for its Thread which is to run the actual audio level calculations and to dispatch to its SimpleAudioLevelListener
        Parameters:
        threadName -
    • Method Detail

      • addData

        public void addData​(javax.media.Buffer buffer)
        Adds data to be processed.
        Parameters:
        buffer - the data that we'd like to queue for processing.
      • setAudioLevelListener

        public void setAudioLevelListener​(SimpleAudioLevelListener listener)
        Sets the new listener that will be gathering all events from this dispatcher.
        Parameters:
        listener - the listener that we will be notifying or null if we are to remove it.
      • setAudioLevelCache

        public void setAudioLevelCache​(AudioLevelMap cache,
                                       long ssrc)
        Sets an AudioLevelMap that this dispatcher could use to cache levels it's measuring in addition to simply delivering them to a listener.
        Parameters:
        cache - the AudioLevelMap where this dispatcher should cache measured results.
        ssrc - the SSRC key where entries should be logged