public class MediaDeviceSession extends PropertyChangeNotifier
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
OUTPUT_DATA_SOURCE
The name of the MediaDeviceSession instance property the value
of which represents the output DataSource of the
MediaDeviceSession instance which provides the captured (RTP)
data to be sent by MediaStream to MediaStreamTarget.
|
protected boolean |
outputSizeChanged
Whether output size has changed after latest processor config.
|
static java.lang.String |
SSRC_LIST
The name of the property that corresponds to the array of SSRC
identifiers that we store in this MediaDeviceSession instance
and that we update upon adding and removing ReceiveStream
|
Modifier | Constructor and Description |
---|---|
protected |
MediaDeviceSession(AbstractMediaDevice device)
Initializes a new MediaDeviceSession instance which is to
represent the use of a specific MediaDevice by a
MediaStream.
|
Modifier and Type | Method and Description |
---|---|
void |
addDTMF(DTMFInbandTone tone)
Adds a new inband DTMF tone to send.
|
void |
addPlaybackDataSource(javax.media.protocol.DataSource playbackDataSource)
Adds a specific DataSource to the list of playbacks of
ReceiveStreams and/or DataSources performed by
respective Players on the MediaDevice represented by
this instance.
|
void |
addReceiveStream(javax.media.rtp.ReceiveStream receiveStream)
Adds a specific ReceiveStream to the list of playbacks of
ReceiveStreams and/or DataSources performed by
respective Players on the MediaDevice represented by
this instance.
|
protected void |
addSSRC(long ssrc)
Adds ssrc to the array of SSRC identifiers representing parties
that this MediaDeviceSession is currently receiving streams
from.
|
protected void |
checkDevice(AbstractMediaDevice device)
Asserts that a specific MediaDevice is acceptable to be set as
the MediaDevice of this instance.
|
void |
close()
Releases the resources allocated by this instance in the course of its
execution and prepares it to be garbage collected.
|
void |
copyPlayback(MediaDeviceSession deviceSession)
Copies the playback part of a specific MediaDeviceSession into
this instance.
|
protected javax.media.protocol.DataSource |
createCaptureDevice()
Creates the DataSource that this instance is to read captured
media from.
|
protected javax.media.Player |
createPlayer(javax.media.protocol.DataSource dataSource)
Creates a new Player for a specific DataSource so that
it is played back on the MediaDevice represented by this
instance.
|
protected javax.media.Processor |
createProcessor()
Initializes a new FMJ Processor which is to transcode
captureDevice into the format of this instance. |
protected javax.media.protocol.ContentDescriptor |
createProcessorContentDescriptor(javax.media.Processor processor)
Creates a ContentDescriptor to be set on a specific
Processor of captured media to be sent to the remote peer.
|
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.
|
protected void |
disposePlayer(javax.media.Player player)
Releases the resources allocated by a specific Player in the
course of its execution and prepares it to be garbage collected.
|
javax.media.protocol.DataSource |
getCaptureDevice()
Gets the DataSource that this instance uses to read captured
media from.
|
protected javax.media.protocol.DataSource |
getConnectedCaptureDevice()
Gets
captureDevice in a connected state. |
<T> java.util.Set<T> |
getDecoderControls(javax.media.rtp.ReceiveStream receiveStream,
java.lang.Class<T> controlType)
Searches for controls of type controlType in the
TrackControls of the Processor used to decode
receiveStream.
|
AbstractMediaDevice |
getDevice()
Gets the MediaDevice associated with this instance and the work
of a MediaStream with which is represented by it.
|
<T> java.util.Set<T> |
getEncoderControls(java.lang.Class<T> controlType)
Searches for controls of type controlType in the
TrackControls of the Processor used to transcode the
MediaDevice of this instance into the format of this instance.
|
MediaFormatImpl<? extends javax.media.Format> |
getFormat()
Gets the MediaFormat in which this instance captures media from
its associated MediaDevice.
|
javax.media.protocol.DataSource |
getOutputDataSource()
Gets the output DataSource of this instance which provides the
captured (RTP) data to be sent by MediaStream to
MediaStreamTarget.
|
protected javax.media.Player |
getPlayer(long ssrc)
Gets the Player rendering the ReceiveStream with a
specific SSRC.
|
protected java.util.List<javax.media.Player> |
getPlayers()
Gets the Players rendering the ReceiveStreams of this
instance on its associated MediaDevice.
|
javax.media.Format |
getProcessorFormat()
Gets the JMF Format in which this instance captures media.
|
java.util.List<javax.media.rtp.ReceiveStream> |
getReceiveStreams()
Gets a list of the ReceiveStreams being played back on the
MediaDevice represented by this instance.
|
long[] |
getRemoteSSRCList()
Returns the list of SSRC identifiers that this device session is handling
streams from.
|
MediaDirection |
getStartedDirection()
Gets the MediaDirection in which this instance has been started.
|
java.util.List<MediaFormat> |
getSupportedFormats()
Gets a list of the MediaFormats in which this instance is
capable of capturing media from its associated MediaDevice.
|
TranscodingDataSource |
getTranscodingDataSource(javax.media.rtp.ReceiveStream receiveStream)
Returns the TranscodingDataSource associated with
receiveStream.
|
boolean |
isMute()
Determines whether this MediaDeviceSession is set to output
"silence" instead of the actual media fed from its
CaptureDevice.
|
protected void |
playbackDataSourceAdded(javax.media.protocol.DataSource playbackDataSource)
Notifies this MediaDeviceSession that a DataSource has
been added for playback on the represented MediaDevice.
|
void |
playbackDataSourceChanged(javax.media.protocol.DataSource playbackDataSource)
Notifies this MediaDeviceSession that a DataSource has
been changed on the represented MediaDevice.
|
protected void |
playbackDataSourceRemoved(javax.media.protocol.DataSource playbackDataSource)
Notifies this MediaDeviceSession that a DataSource has
been removed from playback on the represented MediaDevice.
|
protected void |
playbackDataSourceUpdated(javax.media.protocol.DataSource playbackDataSource)
Notifies this MediaDeviceSession that a DataSource has
been changed on the represented MediaDevice.
|
protected void |
playerConfigureComplete(javax.media.Processor player)
Notifies this instance that a specific Player of remote content
has generated a ConfigureCompleteEvent.
|
protected void |
playerControllerUpdate(javax.media.ControllerEvent ev)
Gets notified about ControllerEvents generated by a specific
Player of remote content.
|
protected void |
playerRealizeComplete(javax.media.Processor player)
Notifies this instance that a specific Player of remote content
has generated a RealizeCompleteEvent.
|
protected void |
processorControllerUpdate(javax.media.ControllerEvent ev)
Gets notified about ControllerEvents generated by
processor . |
protected void |
receiveStreamAdded(javax.media.rtp.ReceiveStream receiveStream)
Notifies this instance that a specific ReceiveStream has been
added to the list of playbacks of ReceiveStreams and/or
DataSources performed by respective Players on the
MediaDevice represented by this instance.
|
protected void |
receiveStreamRemoved(javax.media.rtp.ReceiveStream receiveStream)
Notifies this instance that a specific ReceiveStream has been
removed from the list of playbacks of ReceiveStreams and/or
DataSources performed by respective Players on the
MediaDevice represented by this instance.
|
void |
removePlaybackDataSource(javax.media.protocol.DataSource playbackDataSource)
Removes a specific DataSource from the list of playbacks of
ReceiveStreams and/or DataSources performed by
respective Players on the MediaDevice represented by
this instance.
|
void |
removeReceiveStream(javax.media.rtp.ReceiveStream receiveStream)
Removes a specific ReceiveStream from the list of playbacks of
ReceiveStreams and/or DataSources performed by
respective Players on the MediaDevice represented by
this instance.
|
protected void |
removeSSRC(long ssrc)
Removes ssrc from the array of SSRC identifiers representing
parties that this MediaDeviceSession is currently receiving
streams from.
|
protected void |
setCaptureDeviceFormat(javax.media.protocol.DataSource captureDevice,
MediaFormatImpl<? extends javax.media.Format> mediaFormat) |
void |
setContentDescriptor(javax.media.protocol.ContentDescriptor contentDescriptor)
Sets the ContentDescriptor which specifies the content type in
which this MediaDeviceSession is to output the media captured by
its MediaDevice.
|
void |
setDisposePlayerOnClose(boolean disposePlayerOnClose)
Sets the indicator which determines whether this instance is to dispose
of its associated player upon closing.
|
void |
setFormat(MediaFormat format)
Sets the MediaFormat in which this MediaDeviceSession
outputs the media captured by its MediaDevice.
|
void |
setMute(boolean mute)
Sets the indicator which determines whether this
MediaDeviceSession is set to output "silence" instead of the
actual media fed from its CaptureDevice.
|
protected void |
setProcessorFormat(javax.media.Processor processor,
MediaFormatImpl<? extends javax.media.Format> mediaFormat)
Sets the MediaFormatImpl in which a specific Processor
producing media to be streamed to the remote peer is to output.
|
protected javax.media.Format |
setProcessorFormat(javax.media.control.TrackControl trackControl,
MediaFormatImpl<? extends javax.media.Format> mediaFormat,
javax.media.Format format)
Sets the MediaFormatImpl of a specific TrackControl of
the Processor which produces the media to be streamed by this
MediaDeviceSession to the remote peer.
|
void |
start(MediaDirection direction)
Starts the processing of media in this instance in a specific direction.
|
protected void |
startedDirectionChanged(MediaDirection oldValue,
MediaDirection newValue)
Notifies this instance that the value of its startedDirection
property has changed from a specific oldValue to a specific
newValue.
|
protected void |
startProcessorInAccordWithDirection(javax.media.Processor processor)
Starts a specific Processor if this MediaDeviceSession
has been started and the specified Processor is not started.
|
void |
stop(MediaDirection direction)
Stops the processing of media in this instance in a specific direction.
|
addPropertyChangeListener, firePropertyChange, getPropertyChangeSource, removePropertyChangeListener
public static final java.lang.String OUTPUT_DATA_SOURCE
public static final java.lang.String SSRC_LIST
protected boolean outputSizeChanged
protected MediaDeviceSession(AbstractMediaDevice device)
device
- the MediaDevice the use of which by a
MediaStream is to be represented by the new instancepublic void setDisposePlayerOnClose(boolean disposePlayerOnClose)
disposePlayerOnClose
- true to have this instance dispose
of its associated player upon closing; otherwise, falseprotected void addSSRC(long ssrc)
ssrc
- the new SSRC identifier that we'd like to add to the array of
ssrc identifiers stored by this session.protected void checkDevice(AbstractMediaDevice device)
device
- the MediaDevice to be checked for suitability to
become the MediaDevice of this instancepublic void close()
protected javax.media.protocol.DataSource createCaptureDevice()
protected javax.media.Player createPlayer(javax.media.protocol.DataSource dataSource)
dataSource
- the DataSource to create a new Player
forprotected javax.media.Processor createProcessor()
captureDevice
into the format of this instance.protected javax.media.protocol.ContentDescriptor createProcessorContentDescriptor(javax.media.Processor processor)
ContentDescriptor.RAW_RTP
.processor
- the Processor of captured media to be sent to
the remote peer which is to have its contentDescriptor set to
the returned ContentDescriptorprotected javax.media.Renderer createRenderer(javax.media.Player player, javax.media.control.TrackControl trackControl)
player
- the Player which is to utilize the
initialized/returned RenderertrackControl
- the TrackControl which represents the media
to be played back (and, technically, on which the initialized/returned
Renderer is to be set)TrackControl.setRenderer(Renderer)
is not invoked on the
specified trackControl.protected void disposePlayer(javax.media.Player player)
player
- the Player to dispose ofpublic javax.media.protocol.DataSource getCaptureDevice()
protected javax.media.protocol.DataSource getConnectedCaptureDevice()
captureDevice
in a connected state. If this instance is not
connected to captureDevice yet, first tries to connect to it.
Returns null if this instance fails to create
captureDevice or to connect to it.captureDevice
in a connected state; null if
this instance fails to create captureDevice or to connect to itpublic AbstractMediaDevice getDevice()
public javax.media.Format getProcessorFormat()
public MediaFormatImpl<? extends javax.media.Format> getFormat()
public javax.media.protocol.DataSource getOutputDataSource()
protected javax.media.Player getPlayer(long ssrc)
ssrc
- the SSRC of the ReceiveStream to get the rendering
the Player ofprotected java.util.List<javax.media.Player> getPlayers()
public java.util.List<javax.media.rtp.ReceiveStream> getReceiveStreams()
public long[] getRemoteSSRCList()
public MediaDirection getStartedDirection()
public java.util.List<MediaFormat> getSupportedFormats()
public boolean isMute()
protected void playbackDataSourceAdded(javax.media.protocol.DataSource playbackDataSource)
playbackDataSource
- the DataSource which has been added
for playback on the represented MediaDeviceprotected void playbackDataSourceRemoved(javax.media.protocol.DataSource playbackDataSource)
playbackDataSource
- the DataSource which has been removed
from playback on the represented MediaDeviceprotected void playbackDataSourceUpdated(javax.media.protocol.DataSource playbackDataSource)
playbackDataSource
- the DataSource which has been added
for playback on the represented MediaDevicepublic void playbackDataSourceChanged(javax.media.protocol.DataSource playbackDataSource)
playbackDataSource
- the DataSource which has been added
for playback on the represented MediaDeviceprotected void playerConfigureComplete(javax.media.Processor player)
player
- the Player which is the source of a
ConfigureCompleteEventprotected void playerControllerUpdate(javax.media.ControllerEvent ev)
Extenders who choose to override are advised to override more specialized
methods such as playerConfigureComplete(Processor)
and
playerRealizeComplete(Processor)
. In any case, extenders
overriding this method should call the super implementation.
ev
- the ControllerEvent specifying the
Controller which is the source of the event and the very type of
the eventprotected void playerRealizeComplete(javax.media.Processor player)
player
- the Player which is the source of a
RealizeCompleteEventprotected void processorControllerUpdate(javax.media.ControllerEvent ev)
processor
.ev
- the ControllerEvent specifying the
Controller which is the source of the event and the very type of
the eventprotected void removeSSRC(long ssrc)
ssrc
- the SSRC identifier that we'd like to remove from the array
of ssrc identifiers stored by this session.protected void receiveStreamAdded(javax.media.rtp.ReceiveStream receiveStream)
receiveStream
- the ReceiveStream which has been added to
the list of playbacks of ReceiveStreams and/or
DataSources performed by respective Players on the
MediaDevice represented by this instanceprotected void receiveStreamRemoved(javax.media.rtp.ReceiveStream receiveStream)
receiveStream
- the ReceiveStream which has been removed
from the list of playbacks of ReceiveStreams and/or
DataSources performed by respective Players on the
MediaDevice represented by this instanceprotected void setCaptureDeviceFormat(javax.media.protocol.DataSource captureDevice, MediaFormatImpl<? extends javax.media.Format> mediaFormat)
public void setContentDescriptor(javax.media.protocol.ContentDescriptor contentDescriptor)
ContentDescriptor.RAW_RTP
.contentDescriptor
- the ContentDescriptor which specifies
the content type in which this MediaDeviceSession is to output
the media captured by its MediaDevicepublic void setFormat(MediaFormat format)
format
- the MediaFormat in which this
MediaDeviceSession is to output the media captured by its
MediaDeviceprotected void setProcessorFormat(javax.media.Processor processor, MediaFormatImpl<? extends javax.media.Format> mediaFormat)
processor
- the Processor to set the output
MediaFormatImpl ofmediaFormat
- the MediaFormatImpl to set on
processorprotected javax.media.Format setProcessorFormat(javax.media.control.TrackControl trackControl, MediaFormatImpl<? extends javax.media.Format> mediaFormat, javax.media.Format format)
trackControl
- the TrackControl to set the JMF
Format ofmediaFormat
- the MediaFormatImpl to be set on the
specified TrackControl. Though mediaFormat encapsulates
a JMF Format, format is to be set on the specified
trackControl because it may be more specific. In any case, the
two JMF Formats match. The MediaFormatImpl is provided
anyway because it carries additional information such as format
parameters.format
- the JMF Format to be set on the specified
TrackControl. Though mediaFormat encapsulates a JMF
Format, the specified format is to be set on the
specified trackControl because it may be more specific than the
JMF Format of the mediaFormatpublic void setMute(boolean mute)
mute
- true to set this MediaDeviceSession to
output "silence" instead of the actual media fed from its
CaptureDevice; otherwise, falsepublic void addDTMF(DTMFInbandTone tone)
tone
- the DTMF tone to send.public void addPlaybackDataSource(javax.media.protocol.DataSource playbackDataSource)
playbackDataSource
- the DataSource which to be added to
the list of playbacks of ReceiveStreams and/or
DataSources performed by respective Players on the
MediaDevice represented by this instancepublic void removePlaybackDataSource(javax.media.protocol.DataSource playbackDataSource)
playbackDataSource
- the DataSource which to be removed
from the list of playbacks of ReceiveStreams and/or
DataSources performed by respective Players on the
MediaDevice represented by this instancepublic void addReceiveStream(javax.media.rtp.ReceiveStream receiveStream)
receiveStream
- the ReceiveStream which to be added to the
list of playbacks of ReceiveStreams and/or DataSources
performed by respective Players on the MediaDevice
represented by this instancepublic void removeReceiveStream(javax.media.rtp.ReceiveStream receiveStream)
receiveStream
- the ReceiveStream which to be removed from
the list of playbacks of ReceiveStreams and/or
DataSources performed by respective Players on the
MediaDevice represented by this instancepublic void start(MediaDirection direction)
direction
- a MediaDirection value which represents the
direction of the processing of media to be started. For example,
MediaDirection.SENDRECV
to start both capture and playback of
media in this instance or MediaDirection.SENDONLY
to only start
the capture of media in this instanceprotected void startedDirectionChanged(MediaDirection oldValue, MediaDirection newValue)
oldValue
- the MediaDirection which used to be the value of
the startedDirection property of this instancenewValue
- the MediaDirection which is the value of the
startedDirection property of this instanceprotected void startProcessorInAccordWithDirection(javax.media.Processor processor)
processor
- the Processor to startpublic void stop(MediaDirection direction)
direction
- a MediaDirection value which represents the
direction of the processing of media to be stopped. For example,
MediaDirection.SENDRECV
to stop both capture and playback of
media in this instance or MediaDirection.SENDONLY
to only stop
the capture of media in this instancepublic void copyPlayback(MediaDeviceSession deviceSession)
deviceSession
- the MediaDeviceSession to copy the playback
part of into this instancepublic TranscodingDataSource getTranscodingDataSource(javax.media.rtp.ReceiveStream receiveStream)
receiveStream
- the ReceiveStream to usepublic <T> java.util.Set<T> getEncoderControls(java.lang.Class<T> controlType)
controlType
- the name of the class to search for.public <T> java.util.Set<T> getDecoderControls(javax.media.rtp.ReceiveStream receiveStream, java.lang.Class<T> controlType)
receiveStream
- the ReceiveStream whose Processor's
TrackControls are to be searched.controlType
- the name of the class to search for.
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.