Class AudioMediaDeviceSession


  • public class AudioMediaDeviceSession
    extends MediaDeviceSession
    Extends MediaDeviceSession to add audio-specific functionality.
    Author:
    Emil Ivov, Damian Minkov, Lyubomir Marinov, Boris Grozev
    • Constructor Detail

      • AudioMediaDeviceSession

        public AudioMediaDeviceSession​(AbstractMediaDevice device)
        Initializes a new MediaDeviceSession instance which is to represent the use of a specific MediaDevice by a MediaStream.
        Parameters:
        device - the MediaDevice the use of which by a MediaStream is to be represented by the new instance
    • Method Detail

      • copyPlayback

        public void copyPlayback​(MediaDeviceSession deviceSession)
        Copies the playback part of a specific MediaDeviceSession into this instance.
        Overrides:
        copyPlayback in class MediaDeviceSession
        Parameters:
        deviceSession - the MediaDeviceSession to copy the playback part of into this instance
      • createRenderer

        protected javax.media.Renderer createRenderer​(javax.media.Player player,
                                                      javax.media.control.TrackControl trackControl)
        Initializes a Renderer instance which is to be utilized by a specific Player in order to play back the media represented by a specific TrackControl. Allows extenders to override and, optionally, perform additional configuration of the returned Renderer. Overrides the super implementation in order to configure the VolumeControl of the returned Renderer for the purposes of having call/telephony conference-specific volume (levels).
        Overrides:
        createRenderer in class MediaDeviceSession
        Parameters:
        player - the Player which is to utilize the initialized/returned Renderer
        trackControl - the TrackControl which represents the media to be played back (and, technically, on which the initialized/returned Renderer is to be set)
        Returns:
        the Renderer which is to be set on the specified trackControl. If null, TrackControl.setRenderer(Renderer) is not invoked on the specified trackControl.
      • getLastMeasuredAudioLevel

        public int getLastMeasuredAudioLevel​(long ssrc)
        Returns the last audio level that was measured by this device session for the specified ssrc.
        Parameters:
        ssrc - the SSRC ID whose last measured audio level we'd like to retrieve.
        Returns:
        the audio level that was last measured for the specified ssrc or -1 if no level has been cached for that ID.
      • getLastMeasuredLocalUserAudioLevel

        public int getLastMeasuredLocalUserAudioLevel()
        Returns the last audio level that was measured by the underlying mixer for local user.
        Returns:
        the audio level that was last measured for the local user.
      • processorControllerUpdate

        protected void processorControllerUpdate​(javax.media.ControllerEvent event)
        Gets notified about ControllerEvents generated by the processor reading our capture data source, calls the corresponding method from the parent class so that it would initialize the processor and then adds the level effect for the local user audio levels.
        Overrides:
        processorControllerUpdate in class MediaDeviceSession
        Parameters:
        event - the ControllerEvent specifying the Controller which is the source of the event and the very type of the event
      • registerLocalUserAudioLevelEffect

        protected void registerLocalUserAudioLevelEffect​(javax.media.Processor processor)
        Creates an audio level effect and add its to the codec chain of the TrackControl assuming that it only contains a single track.
        Parameters:
        processor - the processor on which track control we need to register a level effect with.
      • setLocalUserAudioLevelListener

        public void setLocalUserAudioLevelListener​(SimpleAudioLevelListener listener)
        Sets the SimpleAudioLevelListener that this session should be notifying about changes in local audio level related information. This class only supports a single listener for audio changes per source (i.e. stream or data source). Audio changes are generally quite time intensive (~ 50 per second) so we are doing this in order to reduce the number of objects associated with the process (such as event instances listener list iterators and sync copies).
        Parameters:
        listener - the SimpleAudioLevelListener to add
      • setOutputVolumeControl

        public void setOutputVolumeControl​(VolumeControl outputVolumeControl)
        Sets the VolumeControl which is to control the volume (level) of the audio (to be) played back by this instance.
        Parameters:
        outputVolumeControl - the VolumeControl which is to be control the volume (level) of the audio (to be) played back by this instance
      • setStreamAudioLevelListener

        public void setStreamAudioLevelListener​(SimpleAudioLevelListener listener)
        Sets listener as the SimpleAudioLevelListener that we are going to notify every time a change occurs in the audio level of the media that this device session is receiving from the remote party. This class only supports a single listener for audio changes per source (i.e. stream or data source). Audio changes are generally quite time intensive (~ 50 per second) so we are doing this in order to reduce the number of objects associated with the process (such as event instances listener list iterators and sync copies).
        Parameters:
        listener - the SimpleAudioLevelListener that we want notified for audio level changes in the remote participant's media.
      • setVolumeControl

        public static void setVolumeControl​(javax.media.Renderer renderer,
                                            VolumeControl volumeControl)
        Implements a utility which facilitates setting a specific VolumeControl on a specific Renderer for the purposes of control over the volume (level) of the audio (to be) played back by the specified Renderer.
        Parameters:
        renderer - the Renderer on which the specified volumeControl is to be set
        volumeControl - the VolumeControl to be set on the specified renderer
      • createProcessor

        protected javax.media.Processor createProcessor()
        Performs additional configuration on the Processor, after it is configured, but before it is realized. Adds the AudioLevelEffect2 instance to the codec chain, if necessary, in order to enabled audio level measurements. Initializes a new FMJ Processor which is to transcode MediaDeviceSession.captureDevice into the format of this instance.
        Overrides:
        createProcessor in class MediaDeviceSession
        Returns:
        a new FMJ Processor which is to transcode captureDevice into the format of this instance
      • enableOutputSSRCAudioLevels

        public void enableOutputSSRCAudioLevels​(boolean enabled,
                                                byte extensionID)
        Enables or disables measuring audio levels for the output DataSource of this AudioMediaDeviceSession. Note that if audio levels are to be enabled, this method needs to be called (with enabled set to true) before the output DataSource, or the Processor are accessed (via MediaDeviceSession.getOutputDataSource() and MediaDeviceSession.getProcessor()). This limitation allows to not insert an Effect in the codec chain when measuring audio levels is not required (since we can only do this before the Processor is realized).
        Parameters:
        enabled - whether to enable or disable output audio levels.