Class AudioMediaStreamImpl

    • Constructor Detail

      • AudioMediaStreamImpl

        public AudioMediaStreamImpl​(StreamConnector connector,
                                    MediaDevice device,
                                    SrtpControl srtpControl)
        Initializes a new AudioMediaStreamImpl instance which will use the specified MediaDevice for both capture and playback of audio exchanged via the specified StreamConnector.
        Parameters:
        connector - the StreamConnector the new instance is to use for sending and receiving audio
        device - the MediaDevice the new instance is to use for both capture and playback of audio exchanged via the specified StreamConnector
        srtpControl - a control which is already created, used to control the srtp operations.
    • Method Detail

      • setRTPTranslator

        public void setRTPTranslator​(RTPTranslator rtpTranslator)
        Sets the RTPTranslator which is to forward RTP and RTCP traffic between this and other MediaStreams.
        Specified by:
        setRTPTranslator in interface MediaStream
        Overrides:
        setRTPTranslator in class MediaStreamImpl
        Parameters:
        rtpTranslator - the RTPTranslator which is to forward RTP and RTCP traffic between this and other MediaStreams
      • getLastInputActivityTime

        public long getLastInputActivityTime()
                                      throws IOException
        Gets the time in milliseconds of the last input activity related to this AudioMediaStream. We detect either RTP or RTCP activity.
        Returns:
        the time in milliseconds of the last input activity related to this AudioMediaStream
        Throws:
        IOException - only in case we create input stream and it fails, as we always pass false to skip creating, should never be thrown.
      • addDTMFListener

        public void addDTMFListener​(DTMFListener listener)
        Adds a DTMFListener to this AudioMediaStream which is to receive notifications when the remote party starts sending DTMF tones to us.
        Specified by:
        addDTMFListener in interface AudioMediaStream
        Parameters:
        listener - the DTMFListener to register for notifications about the remote party starting sending of DTM tones to this AudioMediaStream
        See Also:
        AudioMediaStream.addDTMFListener(DTMFListener)
      • addRTPExtension

        public void addRTPExtension​(byte extensionID,
                                    RTPExtension rtpExtension)
        In addition to calling MediaStreamImpl.addRTPExtension(byte, RTPExtension) this method enables sending of CSRC audio levels. The reason we are doing this here rather than in the super class is that CSRC levels only make sense for audio streams so we don't want them enabled in any other type.
        Specified by:
        addRTPExtension in interface MediaStream
        Overrides:
        addRTPExtension in class MediaStreamImpl
        Parameters:
        extensionID - the ID assigned to rtpExtension for the lifetime of this stream.
        rtpExtension - the RTPExtension that is being added to this stream.
      • audioLevelsReceived

        public void audioLevelsReceived​(long[] audioLevels)
        Delivers the audioLevels map to whoever is interested. This method is meant for use primarily by the transform engine handling incoming RTP packets (currently CsrcTransformEngine).
        Parameters:
        audioLevels - an array mapping CSRC IDs to audio levels in consecutive elements.
      • configureRTPManagerBufferControl

        protected void configureRTPManagerBufferControl​(StreamRTPManager rtpManager,
                                                        javax.media.control.BufferControl bufferControl)
        Performs any optional configuration on the BufferControl of the specified RTPManager which is to be used as the RTPManager of this MediaStreamImpl.
        Overrides:
        configureRTPManagerBufferControl in class MediaStreamImpl
        Parameters:
        rtpManager - the RTPManager which is to be used by this MediaStreamImpl
        bufferControl - the BufferControl of rtpManager on which any optional configuration is to be performed
      • createDtmfTransformEngine

        protected DtmfTransformEngine createDtmfTransformEngine()
        A stub that allows audio oriented streams to create and keep a reference to a DtmfTransformEngine.
        Overrides:
        createDtmfTransformEngine in class MediaStreamImpl
        Returns:
        a DtmfTransformEngine if this is an audio oriented stream and null otherwise.
      • deviceSessionChanged

        protected void deviceSessionChanged​(MediaDeviceSession oldValue,
                                            MediaDeviceSession newValue)
        Notifies this MediaStream that the MediaDevice (and respectively the MediaDeviceSession with it) which this instance uses for capture and playback of media has been changed. Allows extenders to override and provide additional processing of oldValue and newValue. Makes sure that localUserAudioLevelListener and streamAudioLevelListener which have been set on this AudioMediaStream will be automatically updated when a new MediaDevice is set on this instance.
        Overrides:
        deviceSessionChanged in class MediaStreamImpl
        Parameters:
        oldValue - the MediaDeviceSession with the MediaDevice this instance used work with
        newValue - the MediaDeviceSession with the MediaDevice this instance is to work with
      • fireDTMFEvent

        public void fireDTMFEvent​(DTMFRtpTone tone,
                                  boolean end)
        Delivers the DTMF tones. The method is meant for use primarily by the transform engine handling incoming RTP packets (currently DtmfTransformEngine).
        Parameters:
        tone - the new tone
        end - true if the tone is to be ended or false to be started
      • getDeviceSession

        public AudioMediaDeviceSession getDeviceSession()
        Returns the MediaDeviceSession associated with this stream after first casting it to AudioMediaDeviceSession since this is, after all, an AudioMediaStreamImpl.
        Overrides:
        getDeviceSession in class MediaStreamImpl
        Returns:
        the AudioMediaDeviceSession associated with this stream.
      • getLastMeasuredAudioLevel

        public int getLastMeasuredAudioLevel​(long ssrc)
        Returns the last audio level that was measured by the underlying device session for the specified ssrc (where ssrc could also correspond to our local sync source identifier).
        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.
      • getPriority

        protected int getPriority()
        The priority of the audio is 3, which is meant to be higher than other threads and higher than the video one.
        Overrides:
        getPriority in class MediaStreamImpl
        Returns:
        audio priority.
      • propertyChange

        public void propertyChange​(PropertyChangeEvent ev)
        Receives and reacts to property change events: if the selected device (for capture, playback or notifications) has changed, then create or recreate the streams in order to use it. We want to listen to these events, especially for those generated after the audio system has changed.
        Specified by:
        propertyChange in interface PropertyChangeListener
        Parameters:
        ev - The event which may contain a audio system change event.
      • setCsrcAudioLevelListener

        public void setCsrcAudioLevelListener​(CsrcAudioLevelListener listener)
        Registers listener as the CsrcAudioLevelListener that will receive notifications for changes in the levels of conference participants that the remote party could be mixing.
        Specified by:
        setCsrcAudioLevelListener in interface AudioMediaStream
        Parameters:
        listener - the CsrcAudioLevelListener that we'd like to register or null if we'd like to stop receiving notifications.
      • setLocalUserAudioLevelListener

        public void setLocalUserAudioLevelListener​(SimpleAudioLevelListener listener)
        Sets listener as the SimpleAudioLevelListener registered to receive notifications from our device session for changes in the levels of the audio that this stream is sending out.
        Specified by:
        setLocalUserAudioLevelListener in interface AudioMediaStream
        Parameters:
        listener - the SimpleAudioLevelListener that we'd like to register or null if we want to stop local audio level measurements.
      • setOutputVolumeControl

        public void setOutputVolumeControl​(VolumeControl outputVolumeControl)
        Sets the VolumeControl which is to control the volume (level) of the audio received in/by this AudioMediaStream and played back.
        Specified by:
        setOutputVolumeControl in interface AudioMediaStream
        Parameters:
        outputVolumeControl - the VolumeControl which is to control the volume (level) of the audio received in this AudioMediaStream and played back
      • setStreamAudioLevelListener

        public void setStreamAudioLevelListener​(SimpleAudioLevelListener listener)
        Sets listener as the SimpleAudioLevelListener registered to receive notifications from our device session for changes in the levels of the party that's at the other end of this stream.
        Specified by:
        setStreamAudioLevelListener in interface AudioMediaStream
        Parameters:
        listener - the SimpleAudioLevelListener that we'd like to register or null if we want to stop stream audio level measurements.
      • startSendingDTMF

        public void startSendingDTMF​(DTMFTone tone,
                                     DTMFMethod dtmfMethod,
                                     int minimalToneDuration,
                                     int maximalToneDuration,
                                     int volume)
        Starts sending the specified DTMFTone until the stopSendingDTMF() method is called (Excepts for INBAND DTMF, which stops by itself this is why where there is no need to call the stopSendingDTMF). Callers should keep in mind the fact that calling this method would most likely interrupt all audio transmission until the corresponding stop method is called. Also, calling this method successively without invoking the corresponding stop method between the calls will simply replace the DTMFTone from the first call with that from the second.
        Specified by:
        startSendingDTMF in interface AudioMediaStream
        Parameters:
        tone - the DTMFTone to start sending.
        dtmfMethod - The kind of DTMF used (RTP, SIP-INOF or INBAND).
        minimalToneDuration - The minimal DTMF tone duration.
        maximalToneDuration - The maximal DTMF tone duration.
        volume - The DTMF tone volume.
        Throws:
        IllegalArgumentException - if dtmfMethod is not one of DTMFMethod.INBAND_DTMF, DTMFMethod.RTP_DTMF, and DTMFMethod.SIP_INFO_DTMF
        See Also:
        AudioMediaStream.startSendingDTMF( DTMFTone, DTMFMethod, int, int, int)