Package org.jitsi.impl.neomedia
Class AudioMediaStreamImpl
- java.lang.Object
-
- org.jitsi.service.neomedia.AbstractMediaStream
-
- org.jitsi.impl.neomedia.MediaStreamImpl
-
- org.jitsi.impl.neomedia.AudioMediaStreamImpl
-
- All Implemented Interfaces:
PropertyChangeListener,EventListener,javax.media.rtp.ReceiveStreamListener,javax.media.rtp.RemoteListener,javax.media.rtp.SendStreamListener,javax.media.rtp.SessionListener,AudioMediaStream,MediaStream
public class AudioMediaStreamImpl extends MediaStreamImpl implements AudioMediaStream, PropertyChangeListener
Extends MediaStreamImpl in order to provide an implementation of AudioMediaStream.- Author:
- Lyubomir Marinov, Emil Ivov
-
-
Field Summary
-
Fields inherited from class org.jitsi.impl.neomedia.MediaStreamImpl
PROPERTY_NAME_RECEIVE_BUFFER_LENGTH, sendStreamsAreCreated
-
Fields inherited from class org.jitsi.service.neomedia.AbstractMediaStream
rtpTranslator
-
Fields inherited from interface org.jitsi.service.neomedia.AudioMediaStream
DISABLE_DTMF_HANDLING_PNAME
-
Fields inherited from interface org.jitsi.service.neomedia.MediaStream
PNAME_LOCAL_SSRC, PNAME_REMOTE_SSRC
-
-
Constructor Summary
Constructors Constructor Description 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDTMFListener(DTMFListener listener)Adds a DTMFListener to this AudioMediaStream which is to receive notifications when the remote party starts sending DTMF tones to us.voidaddRTPExtension(byte extensionID, RTPExtension rtpExtension)In addition to callingMediaStreamImpl.addRTPExtension(byte, RTPExtension)this method enables sending of CSRC audio levels.voidaudioLevelsReceived(long[] audioLevels)Delivers the audioLevels map to whoever is interested.voidclose()Releases the resources allocated by this instance in the course of its execution and prepares it to be garbage collected.protected voidconfigureRTPManagerBufferControl(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.protected DiscardTransformEnginecreateDiscardEngine()Creates theDiscardTransformEnginefor this stream.protected DtmfTransformEnginecreateDtmfTransformEngine()A stub that allows audio oriented streams to create and keep a reference to a DtmfTransformEngine.protected SsrcTransformEnginecreateSsrcTransformEngine()protected voiddeviceSessionChanged(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.voidfireDTMFEvent(DTMFRtpTone tone, boolean end)Delivers the DTMF tones.AudioMediaDeviceSessiongetDeviceSession()Returns the MediaDeviceSession associated with this stream after first casting it to AudioMediaDeviceSession since this is, after all, an AudioMediaStreamImpl.longgetLastInputActivityTime()Gets the time in milliseconds of the last input activity related to this AudioMediaStream.intgetLastMeasuredAudioLevel(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).MediaStreamTrackReceivergetMediaStreamTrackReceiver()Gets theMediaStreamTrackReceiverof thisMediaStream.protected intgetPriority()The priority of the audio is 3, which is meant to be higher than other threads and higher than the video one.protected TransformEnginegetRTCPTermination()Gets the RTCP termination for thisMediaStreamImpl.voidpropertyChange(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.protected voidregisterCustomCodecFormats(StreamRTPManager rtpManager)RegistersCUSTOM_CODEC_FORMATSwith a specific RTPManager.voidremoveDTMFListener(DTMFListener listener)Removes listener from the list of DTMFListeners registered with this AudioMediaStream to receive notifications about incoming DTMF tones.voidsetCsrcAudioLevelListener(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.voidsetLocalUserAudioLevelListener(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.voidsetOutputVolumeControl(VolumeControl outputVolumeControl)Sets the VolumeControl which is to control the volume (level) of the audio received in/by this AudioMediaStream and played back.voidsetRTPTranslator(RTPTranslator rtpTranslator)Sets the RTPTranslator which is to forward RTP and RTCP traffic between this and other MediaStreams.voidsetStreamAudioLevelListener(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.voidstartSendingDTMF(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).voidstopSendingDTMF(DTMFMethod dtmfMethod)Interrupts transmission of a DTMFTone started with the startSendingDTMF() method.-
Methods inherited from class org.jitsi.impl.neomedia.MediaStreamImpl
addDynamicRTPPayloadType, addDynamicRTPPayloadTypeOverride, addRemoteSourceID, clearDynamicRTPPayloadTypes, clearRTPExtensions, configureDataInputStream, configureDataOutputStream, createAbsSendTimeEngine, createCachingTransformer, createRetransmissionRequester, createSendStreams, getActiveRTPExtensionID, getActiveRTPExtensions, getCachingTransformer, getCsrcEngine, getDevice, getDiagnosticContext, getDirection, getDynamicRTPPayloadType, getDynamicRTPPayloadTypes, getFecTransformEngine, getFormat, getFormat, getLocalContributingSourceIDs, getLocalControlAddress, getLocalDataAddress, getLocalSourceID, getMediaStreamStats, getMediaType, getPaddingTermination, getPrimaryREDBlock, getPrimaryREDBlock, getReceiveStream, getReceiveStreams, getRedTransformEngine, getRemoteBitrateEstimator, getRemoteContributingSourceIDs, getRemoteControlAddress, getRemoteDataAddress, getRemoteSourceID, getRemoteSourceIDs, getRetransmissionRequester, getRTPConnector, getRTPManager, getRtxTransformer, getSpatialID, getSrtpControl, getStreamRTPManager, getTarget, getTemporalID, getTransformEngineChain, getTransportCCEngine, getTransportProtocol, injectPacket, injectPacket, isEndOfFrame, isKeyFrame, isKeyFrame, isMute, isStarted, isStartOfFrame, packetToString, queryRTPManager, recreateSendStreams, removeReceiveStreamForSsrc, rtpConnectorChanged, setConnector, setDevice, setDirection, setExternalTransformer, setFecTransformEngine, setFormat, setLocalSourceID, setMute, setSSRCFactory, setTarget, setTransportCCEngine, start, stop, supportsFrameBoundaries, toString, update, update, update, update
-
Methods inherited from class org.jitsi.service.neomedia.AbstractMediaStream
addPropertyChangeListener, assertDirection, firePropertyChange, getName, getProperty, getRTPTranslator, handleAttributes, injectPacket, removePropertyChangeListener, setName, setProperty
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jitsi.service.neomedia.MediaStream
addDynamicRTPPayloadType, addDynamicRTPPayloadTypeOverride, addPropertyChangeListener, clearDynamicRTPPayloadTypes, clearRTPExtensions, getActiveRTPExtensions, getDevice, getDirection, getDynamicRTPPayloadType, getDynamicRTPPayloadTypes, getFormat, getFormat, getLocalSourceID, getMediaStreamStats, getName, getPrimaryREDBlock, getPrimaryREDBlock, getProperty, getRemoteControlAddress, getRemoteDataAddress, getRemoteSourceID, getRemoteSourceIDs, getRetransmissionRequester, getRTPTranslator, getSrtpControl, getStreamRTPManager, getTarget, getTransformEngineChain, getTransportProtocol, injectPacket, isKeyFrame, isKeyFrame, isMute, isStarted, removePropertyChangeListener, removeReceiveStreamForSsrc, setConnector, setDevice, setDirection, setExternalTransformer, setFormat, setMute, setName, setProperty, setSSRCFactory, setTarget, setTransportCCEngine, start, stop
-
-
-
-
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 audiodevice- the MediaDevice the new instance is to use for both capture and playback of audio exchanged via the specified StreamConnectorsrtpControl- 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:
setRTPTranslatorin interfaceMediaStream- Overrides:
setRTPTranslatorin classMediaStreamImpl- Parameters:
rtpTranslator- the RTPTranslator which is to forward RTP and RTCP traffic between this and other MediaStreams
-
getLastInputActivityTime
public long getLastInputActivityTime() throws IOExceptionGets 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:
addDTMFListenerin interfaceAudioMediaStream- 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 callingMediaStreamImpl.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:
addRTPExtensionin interfaceMediaStream- Overrides:
addRTPExtensionin classMediaStreamImpl- 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.
-
close
public void close()
Releases the resources allocated by this instance in the course of its execution and prepares it to be garbage collected.- Specified by:
closein interfaceMediaStream- Overrides:
closein classMediaStreamImpl- See Also:
MediaStream.close()
-
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:
configureRTPManagerBufferControlin classMediaStreamImpl- Parameters:
rtpManager- the RTPManager which is to be used by this MediaStreamImplbufferControl- 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:
createDtmfTransformEnginein classMediaStreamImpl- Returns:
- a DtmfTransformEngine if this is an audio oriented stream and null otherwise.
-
createSsrcTransformEngine
protected SsrcTransformEngine createSsrcTransformEngine()
- Overrides:
createSsrcTransformEnginein classMediaStreamImpl
-
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 thatlocalUserAudioLevelListenerandstreamAudioLevelListenerwhich have been set on this AudioMediaStream will be automatically updated when a new MediaDevice is set on this instance.- Overrides:
deviceSessionChangedin classMediaStreamImpl- Parameters:
oldValue- the MediaDeviceSession with the MediaDevice this instance used work withnewValue- 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 toneend- 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:
getDeviceSessionin classMediaStreamImpl- 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:
getPriorityin classMediaStreamImpl- 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:
propertyChangein interfacePropertyChangeListener- Parameters:
ev- The event which may contain a audio system change event.
-
registerCustomCodecFormats
protected void registerCustomCodecFormats(StreamRTPManager rtpManager)
RegistersCUSTOM_CODEC_FORMATSwith a specific RTPManager.- Overrides:
registerCustomCodecFormatsin classMediaStreamImpl- Parameters:
rtpManager- the RTPManager to registerCUSTOM_CODEC_FORMATSwith- See Also:
MediaStreamImpl.registerCustomCodecFormats(StreamRTPManager)
-
removeDTMFListener
public void removeDTMFListener(DTMFListener listener)
Removes listener from the list of DTMFListeners registered with this AudioMediaStream to receive notifications about incoming DTMF tones.- Specified by:
removeDTMFListenerin interfaceAudioMediaStream- Parameters:
listener- the DTMFListener to no longer be notified by this AudioMediaStream about incoming DTMF tones- See Also:
AudioMediaStream.removeDTMFListener(DTMFListener)
-
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:
setCsrcAudioLevelListenerin interfaceAudioMediaStream- 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:
setLocalUserAudioLevelListenerin interfaceAudioMediaStream- 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:
setOutputVolumeControlin interfaceAudioMediaStream- 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:
setStreamAudioLevelListenerin interfaceAudioMediaStream- 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:
startSendingDTMFin interfaceAudioMediaStream- 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 ofDTMFMethod.INBAND_DTMF,DTMFMethod.RTP_DTMF, andDTMFMethod.SIP_INFO_DTMF- See Also:
AudioMediaStream.startSendingDTMF( DTMFTone, DTMFMethod, int, int, int)
-
stopSendingDTMF
public void stopSendingDTMF(DTMFMethod dtmfMethod)
Interrupts transmission of a DTMFTone started with the startSendingDTMF() method. Has no effect if no tone is currently being sent.- Specified by:
stopSendingDTMFin interfaceAudioMediaStream- Parameters:
dtmfMethod- The kind of DTMF used (RTP, SIP-INOF or INBAND).- Throws:
IllegalArgumentException- if dtmfMethod is not one ofDTMFMethod.INBAND_DTMF,DTMFMethod.RTP_DTMF, andDTMFMethod.SIP_INFO_DTMF- See Also:
AudioMediaStream.stopSendingDTMF(DTMFMethod)
-
createDiscardEngine
protected DiscardTransformEngine createDiscardEngine()
Creates theDiscardTransformEnginefor this stream. Allows extenders to override.- Overrides:
createDiscardEnginein classMediaStreamImpl
-
getRTCPTermination
protected TransformEngine getRTCPTermination()
Gets the RTCP termination for thisMediaStreamImpl.- Overrides:
getRTCPTerminationin classMediaStreamImpl
-
getMediaStreamTrackReceiver
public MediaStreamTrackReceiver getMediaStreamTrackReceiver()
Gets theMediaStreamTrackReceiverof thisMediaStream.- Specified by:
getMediaStreamTrackReceiverin interfaceMediaStream- Overrides:
getMediaStreamTrackReceiverin classAbstractMediaStream- Returns:
- the
MediaStreamTrackReceiverof thisMediaStream, or null.
-
-