Package org.jitsi.impl.neomedia.device
Class VideoMediaDeviceSession
- java.lang.Object
-
- org.jitsi.utils.event.PropertyChangeNotifier
-
- org.jitsi.impl.neomedia.device.MediaDeviceSession
-
- org.jitsi.impl.neomedia.device.VideoMediaDeviceSession
-
- All Implemented Interfaces:
RTCPFeedbackMessageCreateListener
public class VideoMediaDeviceSession extends MediaDeviceSession implements RTCPFeedbackMessageCreateListener
Extends MediaDeviceSession to add video-specific functionality.- Author:
- Lyubomir Marinov, Sebastien Vincent, Hristo Terezov, Boris Grozev
-
-
Field Summary
-
Fields inherited from class org.jitsi.impl.neomedia.device.MediaDeviceSession
OUTPUT_DATA_SOURCE, outputSizeChanged, SSRC_LIST, useTranslator
-
-
Constructor Summary
Constructors Constructor Description VideoMediaDeviceSession(AbstractMediaDevice device)Initializes a new VideoMediaDeviceSession instance which is to represent the work of a MediaStream with a specific video MediaDevice.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRTCPFeedbackMessageCreateListner(RTCPFeedbackMessageCreateListener listener)Adds RTCPFeedbackMessageCreateListener.voidaddVideoListener(VideoListener listener)Adds a specific VideoListener to this instance in order to receive notifications when visual/video Components are being added and removed.protected voidcheckDevice(AbstractMediaDevice device)Asserts that a specific MediaDevice is acceptable to be set as the MediaDevice of this instance.protected javax.media.protocol.DataSourcecreateCaptureDevice()Creates the DataSource that this instance is to read captured media from.protected javax.media.PlayercreateLocalPlayer(javax.media.protocol.DataSource captureDevice)Initializes a new Player instance which is to provide the local visual/video Component.protected ComponentcreateLocalVisualComponent()Creates the visual Component depicting the video being streamed from the local peer to the remote peer.protected voiddisposeLocalPlayer(javax.media.Player player)Releases the resources allocated by a specific local Player in the course of its execution and prepares it to be garbage collected.protected voiddisposeLocalVisualComponent(Component component)Disposes of the local visual Component of the local peer.protected voiddisposePlayer(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.protected booleanfireVideoEvent(int type, Component visualComponent, int origin, boolean wait)Notifies the VideoListeners registered with this instance about a specific type of change in the availability of a specific visual Component depicting video.protected voidfireVideoEvent(VideoEvent videoEvent, boolean wait)Notifies the VideoListeners registered with this instance about a specific VideoEvent.protected javax.media.PlayergetLocalPlayer()Return the Player instance which provides the local visual/video Component.ComponentgetLocalVisualComponent()Gets the visual Component, if any, depicting the video streamed from the local peer to the remote peer.javax.media.format.VideoFormatgetReceivedVideoFormat()Returns the FMJ Format of the video we are receiving from the remote peer.javax.media.format.VideoFormatgetSentVideoFormat()Returns the format of the video we are streaming to the remote peer.ComponentgetVisualComponent(long ssrc)Gets the visual Components rendering the ReceiveStream corresponding to the given ssrc.List<Component>getVisualComponents()Gets the visual Components where video from the remote peer is being rendered.voidonRTCPFeedbackMessageCreate(RTCPFeedbackMessageListener rtcpFeedbackMessageListener)Notifies this VideoMediaDeviceSession of a new RTCPFeedbackListenerprotected voidplayerConfigureComplete(javax.media.Processor player)Notifies this instance that a specific Player of remote content has generated a ConfigureCompleteEvent.protected voidplayerControllerUpdate(javax.media.ControllerEvent ev)Gets notified about ControllerEvents generated by a specific Player of remote content.protected voidplayerRealizeComplete(javax.media.Processor player)Notifies this instance that a specific Player of remote content has generated a RealizeCompleteEvent.protected voidplayerSizeChange(javax.media.Controller sourceController, int origin, int width, int height)Notifies this instance that a specific Player of local or remote content/video has generated a SizeChangeEvent.voidremoveRTCPFeedbackMessageCreateListner(RTCPFeedbackMessageCreateListener listener)Removes RTCPFeedbackMessageCreateListener.voidremoveVideoListener(VideoListener listener)Removes a specific VideoListener from this instance in order to have to no longer receive notifications when visual/video Components are being added and removed.voidsetConnector(AbstractRTPConnector rtpConnector)Sets the RTPConnector that will be used to initialize some codec for RTCP feedback.voidsetFormat(MediaFormat format)Sets the MediaFormat in which this MediaDeviceSession outputs the media captured by its MediaDevice.voidsetKeyFrameControl(KeyFrameControl keyFrameControl)Sets the KeyFrameControl to be used by this VideoMediaDeviceSession as a means of control over its key frame-related logic.voidsetLocalSSRC(long localSSRC)Set the local SSRC.voidsetOutputSize(Dimension size)Sets the size of the output video.protected javax.media.FormatsetProcessorFormat(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.protected voidsetProcessorFormat(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.voidsetRemoteSSRC(long remoteSSRC)Set the remote SSRC.voidsetRTCPFeedbackPLI(boolean useRTCPFeedbackPLI)Sets the indicator which determines whether RTCP feedback Picture Loss Indication (PLI) is to be used to request keyframes.protected voidstartedDirectionChanged(MediaDirection oldValue, MediaDirection newValue)Notifies this instance that the value of its startedDirection property has changed from a specific oldValue to a specific newValue.-
Methods inherited from class org.jitsi.impl.neomedia.device.MediaDeviceSession
addDTMF, addPlaybackDataSource, addReceiveStream, addSSRC, close, copyPlayback, createPlayer, createProcessor, createProcessorContentDescriptor, createRenderer, getCaptureDevice, getConnectedCaptureDevice, getDecoderControls, getDevice, getEncoderControls, getFormat, getOutputDataSource, getPlayer, getPlayers, getProcessorFormat, getReceiveStreams, getRemoteSSRCList, getStartedDirection, getSupportedFormats, getTranscodingDataSource, isMute, playbackDataSourceAdded, playbackDataSourceChanged, playbackDataSourceRemoved, playbackDataSourceUpdated, processorControllerUpdate, receiveStreamAdded, receiveStreamRemoved, removePlaybackDataSource, removeReceiveStream, removeSSRC, setCaptureDeviceFormat, setContentDescriptor, setDisposePlayerOnClose, setMute, setUseTranslator, start, startProcessorInAccordWithDirection, stop
-
-
-
-
Constructor Detail
-
VideoMediaDeviceSession
public VideoMediaDeviceSession(AbstractMediaDevice device)
Initializes a new VideoMediaDeviceSession instance which is to represent the work of a MediaStream with a specific video MediaDevice.- Parameters:
device- the video MediaDevice the use of which by a MediaStream is to be represented by the new instance
-
-
Method Detail
-
addRTCPFeedbackMessageCreateListner
public void addRTCPFeedbackMessageCreateListner(RTCPFeedbackMessageCreateListener listener)
Adds RTCPFeedbackMessageCreateListener.- Parameters:
listener- the listener to add
-
addVideoListener
public void addVideoListener(VideoListener listener)
Adds a specific VideoListener to this instance in order to receive notifications when visual/video Components are being added and removed.Adding a listener which has already been added does nothing i.e. it is not added more than once and thus does not receive one and the same VideoEvent multiple times.
- Parameters:
listener- the VideoListener to be notified when visual/video Components are being added or removed in this instance
-
checkDevice
protected void checkDevice(AbstractMediaDevice device)
Asserts that a specific MediaDevice is acceptable to be set as the MediaDevice of this instance. Makes sure that its MediaType isMediaType.VIDEO.- Overrides:
checkDevicein classMediaDeviceSession- Parameters:
device- the MediaDevice to be checked for suitability to become the MediaDevice of this instance- See Also:
MediaDeviceSession.checkDevice(AbstractMediaDevice)
-
createCaptureDevice
protected javax.media.protocol.DataSource createCaptureDevice()
Creates the DataSource that this instance is to read captured media from.- Overrides:
createCaptureDevicein classMediaDeviceSession- Returns:
- the DataSource that this instance is to read captured media from
-
createLocalPlayer
protected javax.media.Player createLocalPlayer(javax.media.protocol.DataSource captureDevice)
Initializes a new Player instance which is to provide the local visual/video Component. The new instance is initialized to render the media of a specific DataSource.- Parameters:
captureDevice- the DataSource which is to have its media rendered by the new instance as the local visual/video Component- Returns:
- a new Player instance which is to provide the local visual/video Component
-
createLocalVisualComponent
protected Component createLocalVisualComponent()
Creates the visual Component depicting the video being streamed from the local peer to the remote peer.- Returns:
- the visual Component depicting the video being streamed
from the local peer to the remote peer if it was immediately created or
null if it was not immediately created and it is to be delivered
to the currently registered VideoListeners in a
VideoEvent with type
VideoEvent.VIDEO_ADDEDand originVideoEvent.LOCAL
-
disposeLocalPlayer
protected void disposeLocalPlayer(javax.media.Player player)
Releases the resources allocated by a specific local Player in the course of its execution and prepares it to be garbage collected. If the specified Player is rendering video, notifies the VideoListeners of this instance that its visual Component is to no longer be used by firing aVideoEvent.VIDEO_REMOVEDVideoEvent.- Parameters:
player- the Player to dispose of- See Also:
MediaDeviceSession.disposePlayer(Player)
-
disposeLocalVisualComponent
protected void disposeLocalVisualComponent(Component component)
Disposes of the local visual Component of the local peer.- Parameters:
component- the local visual Component of the local peer to dispose of
-
disposePlayer
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. If the specified Player is rendering video, notifies the VideoListeners of this instance that its visual Component is to no longer be used by firing aVideoEvent.VIDEO_REMOVEDVideoEvent.- Overrides:
disposePlayerin classMediaDeviceSession- Parameters:
player- the Player to dispose of- See Also:
MediaDeviceSession.disposePlayer(Player)
-
fireVideoEvent
protected boolean fireVideoEvent(int type, Component visualComponent, int origin, boolean wait)Notifies the VideoListeners registered with this instance about a specific type of change in the availability of a specific visual Component depicting video.- Parameters:
type- the type of change as defined by VideoEvent in the availability of the specified visual Component depicting videovisualComponent- the visual Component depicting video which has been added or removed in this instanceorigin-VideoEvent.LOCALif the origin of the video is local (e.g. it is being locally captured);VideoEvent.REMOTEif the origin of the video is remote (e.g. a remote peer is streaming it)wait- true if the call is to wait till the specified VideoEvent has been delivered to the VideoListeners; otherwise, false- Returns:
- true if this event and, more specifically, the visual Component it describes have been consumed and should be considered owned, referenced (which is important because Components belong to a single Container at a time); otherwise, false
-
fireVideoEvent
protected void fireVideoEvent(VideoEvent videoEvent, boolean wait)
Notifies the VideoListeners registered with this instance about a specific VideoEvent.- Parameters:
videoEvent- the VideoEvent to be fired to the VideoListeners registered with this instancewait- true if the call is to wait till the specified VideoEvent has been delivered to the VideoListeners; otherwise, false
-
getLocalVisualComponent
public Component getLocalVisualComponent()
Gets the visual Component, if any, depicting the video streamed from the local peer to the remote peer.- Returns:
- the visual Component depicting the local video if local video is actually being streamed from the local peer to the remote peer; otherwise, null
-
getReceivedVideoFormat
public javax.media.format.VideoFormat getReceivedVideoFormat()
Returns the FMJ Format of the video we are receiving from the remote peer.- Returns:
- the FMJ Format of the video we are receiving from the remote peer or null if we are not receiving any video or the FMJ Format of the video we are receiving from the remote peer cannot be determined
-
getSentVideoFormat
public javax.media.format.VideoFormat getSentVideoFormat()
Returns the format of the video we are streaming to the remote peer.- Returns:
- The video format of the sent video. Null, if no video is sent.
-
getVisualComponent
public Component getVisualComponent(long ssrc)
Gets the visual Components rendering the ReceiveStream corresponding to the given ssrc.- Parameters:
ssrc- the src-id of the receive stream, which visual Component we're looking for- Returns:
- the visual Component rendering the ReceiveStream corresponding to the given ssrc
-
getVisualComponents
public List<Component> getVisualComponents()
Gets the visual Components where video from the remote peer is being rendered.- Returns:
- the visual Components where video from the remote peer is being rendered
-
onRTCPFeedbackMessageCreate
public void onRTCPFeedbackMessageCreate(RTCPFeedbackMessageListener rtcpFeedbackMessageListener)
Notifies this VideoMediaDeviceSession of a new RTCPFeedbackListener- Specified by:
onRTCPFeedbackMessageCreatein interfaceRTCPFeedbackMessageCreateListener- Parameters:
rtcpFeedbackMessageListener- the listener to be added.
-
playerConfigureComplete
protected void playerConfigureComplete(javax.media.Processor player)
Notifies this instance that a specific Player of remote content has generated a ConfigureCompleteEvent.- Overrides:
playerConfigureCompletein classMediaDeviceSession- Parameters:
player- the Player which is the source of a ConfigureCompleteEvent- See Also:
MediaDeviceSession.playerConfigureComplete(Processor)
-
playerControllerUpdate
protected void playerControllerUpdate(javax.media.ControllerEvent ev)
Gets notified about ControllerEvents generated by a specific Player of remote content.- Overrides:
playerControllerUpdatein classMediaDeviceSession- Parameters:
ev- the ControllerEvent specifying the Controller which is the source of the event and the very type of the event- See Also:
MediaDeviceSession.playerControllerUpdate(ControllerEvent)
-
playerRealizeComplete
protected void playerRealizeComplete(javax.media.Processor player)
Notifies this instance that a specific Player of remote content has generated a RealizeCompleteEvent.- Overrides:
playerRealizeCompletein classMediaDeviceSession- Parameters:
player- the Player which is the source of a RealizeCompleteEvent.- See Also:
MediaDeviceSession.playerRealizeComplete(Processor)
-
playerSizeChange
protected void playerSizeChange(javax.media.Controller sourceController, int origin, int width, int height)Notifies this instance that a specific Player of local or remote content/video has generated a SizeChangeEvent.- Parameters:
sourceController- the Player which is the source of the eventorigin-VideoEvent.LOCALorVideoEvent.REMOTEwhich specifies the origin of the visual Component displaying video which is concernedwidth- the width reported in the eventheight- the height reported in the event- See Also:
SizeChangeEvent
-
removeRTCPFeedbackMessageCreateListner
public void removeRTCPFeedbackMessageCreateListner(RTCPFeedbackMessageCreateListener listener)
Removes RTCPFeedbackMessageCreateListener.- Parameters:
listener- the listener to remove
-
removeVideoListener
public void removeVideoListener(VideoListener listener)
Removes a specific VideoListener from this instance in order to have to no longer receive notifications when visual/video Components are being added and removed.- Parameters:
listener- the VideoListener to no longer be notified when visual/video Components are being added or removed in this instance
-
setConnector
public void setConnector(AbstractRTPConnector rtpConnector)
Sets the RTPConnector that will be used to initialize some codec for RTCP feedback.- Parameters:
rtpConnector- the RTP connector
-
setFormat
public void setFormat(MediaFormat format)
Sets the MediaFormat in which this MediaDeviceSession outputs the media captured by its MediaDevice.- Overrides:
setFormatin classMediaDeviceSession- Parameters:
format- the MediaFormat in which this MediaDeviceSession is to output the media captured by its MediaDevice
-
setKeyFrameControl
public void setKeyFrameControl(KeyFrameControl keyFrameControl)
Sets the KeyFrameControl to be used by this VideoMediaDeviceSession as a means of control over its key frame-related logic.- Parameters:
keyFrameControl- the KeyFrameControl to be used by this VideoMediaDeviceSession as a means of control over its key frame-related logic
-
setLocalSSRC
public void setLocalSSRC(long localSSRC)
Set the local SSRC.- Parameters:
localSSRC- local SSRC
-
setOutputSize
public void setOutputSize(Dimension size)
Sets the size of the output video.- Parameters:
size- the size of the output video
-
setProcessorFormat
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.- Overrides:
setProcessorFormatin classMediaDeviceSession- Parameters:
processor- the Processor to set the output MediaFormatImpl ofmediaFormat- the MediaFormatImpl to set on processor- See Also:
MediaDeviceSession.setProcessorFormat(Processor, MediaFormatImpl)
-
setProcessorFormat
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. Allows extenders to override the set procedure and to detect when the JMF Format of the specified TrackControl changes.- Overrides:
setProcessorFormatin classMediaDeviceSession- Parameters:
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 mediaFormat- Returns:
- the JMF Format set on TrackControl after the attempt to set the specified mediaFormat or null if the specified format was found to be incompatible with trackControl
- See Also:
MediaDeviceSession.setProcessorFormat(TrackControl, MediaFormatImpl, Format)
-
setRemoteSSRC
public void setRemoteSSRC(long remoteSSRC)
Set the remote SSRC.- Parameters:
remoteSSRC- remote SSRC
-
setRTCPFeedbackPLI
public void setRTCPFeedbackPLI(boolean useRTCPFeedbackPLI)
Sets the indicator which determines whether RTCP feedback Picture Loss Indication (PLI) is to be used to request keyframes.- Parameters:
useRTCPFeedbackPLI- true to use PLI; otherwise, false
-
startedDirectionChanged
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.- Overrides:
startedDirectionChangedin classMediaDeviceSession- Parameters:
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 instance
-
getLocalPlayer
protected javax.media.Player getLocalPlayer()
Return the Player instance which provides the local visual/video Component.- Returns:
- the Player instance which provides the local visual/video Component.
-
-