Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.neomedia.device
Class VideoMediaDeviceSession

java.lang.Object
  extended by net.java.sip.communicator.util.PropertyChangeNotifier
      extended by net.java.sip.communicator.impl.neomedia.device.MediaDeviceSession
          extended by net.java.sip.communicator.impl.neomedia.device.VideoMediaDeviceSession

public class VideoMediaDeviceSession
extends MediaDeviceSession

Extends MediaDeviceSession to add video-specific functionality.

Author:
Lyubomir Marinov, Sebastien Vincent

Field Summary
 
Fields inherited from class net.java.sip.communicator.impl.neomedia.device.MediaDeviceSession
OUTPUT_DATA_SOURCE, outputsizeChanged, SSRC_LIST
 
Constructor Summary
VideoMediaDeviceSession(AbstractMediaDevice device)
          Initializes a new VideoMediaDeviceSession instance which is to represent the work of a MediaStream with a specific video MediaDevice.
 
Method Summary
 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.
protected  void checkDevice(AbstractMediaDevice device)
          Asserts that a specific MediaDevice is acceptable to be set as the MediaDevice of this instance.
protected  javax.media.protocol.DataSource createCaptureDevice()
          Creates the DataSource that this instance is to read captured media from.
protected  javax.media.Player createLocalPlayer(javax.media.protocol.DataSource captureDevice)
          Initializes a new Player instance which is to provide the local visual/video Component.
 Component createLocalVisualComponent()
          Creates the visual Component depicting the video being streamed from the local peer to the remote peer.
 void disposeLocalVisualComponent(Component component)
          Disposes of the local visual Component of the local peer.
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.
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.
protected  void fireVideoEvent(VideoEvent videoEvent, boolean wait)
          Notifies the VideoListeners registered with this instance about a specific VideoEvent.
 List<Component> getVisualComponents()
          Gets the visual Components where video from the remote peer is being rendered.
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 event)
          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 playerSizeChange(javax.media.Controller sourceController, int width, int height)
          Notifies this instance that a specific Player of remote content has generated a SizeChangeEvent.
 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.
 void setConnector(AbstractRTPConnector rtpConnector)
          Sets the RTPConnector that will be used to initialize some codec for RTCP feedback.
 void setFormat(MediaFormat format)
          Sets the MediaFormat in which this MediaDeviceSession outputs the media captured by its MediaDevice.
 void setKeyFrameControl(KeyFrameControl keyFrameControl)
          Sets the KeyFrameControl to be used by this VideoMediaDeviceSession as a means of control over its key frame-related logic.
 void setLocalSSRC(long localSSRC)
          Set the local SSRC.
 void setOutputSize(Dimension size)
          Sets the size of the output video.
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 setRemoteSSRC(long remoteSSRC)
          Set the remote SSRC.
 void setRtcpFeedbackPLI(boolean usePLI)
          Use or not RTCP feedback Picture Loss Indication.
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.
 
Methods inherited from class net.java.sip.communicator.impl.neomedia.device.MediaDeviceSession
addDTMF, addPlaybackDataSource, addReceiveStream, addSSRC, close, copyPlayback, createPlayer, createProcessor, createProcessorContentDescriptor, getCaptureDevice, getConnectedCaptureDevice, getDevice, getFormat, getOutputDataSource, getPlayers, getProcessorFormat, getReceiveStreams, getRemoteSSRCList, getStartedDirection, getSupportedFormats, isMute, playbackDataSourceAdded, playbackDataSourceRemoved, processorControllerUpdate, receiveStreamAdded, receiveStreamRemoved, removePlaybackDataSource, removeReceiveStream, removeSSRC, setContentDescriptor, setDisposePlayerOnClose, setMute, start, startProcessorInAccordWithDirection, stop
 
Methods inherited from class net.java.sip.communicator.util.PropertyChangeNotifier
addPropertyChangeListener, firePropertyChange, getPropertyChangeSource, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

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

createCaptureDevice

protected javax.media.protocol.DataSource createCaptureDevice()
Creates the DataSource that this instance is to read captured media from.

Overrides:
createCaptureDevice in class MediaDeviceSession
Returns:
the DataSource that this instance is to read captured media from

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 is MediaType.VIDEO.

Overrides:
checkDevice in class MediaDeviceSession
Parameters:
device - the MediaDevice to be checked for suitability to become the MediaDevice of this instance
See Also:
MediaDeviceSession.checkDevice(AbstractMediaDevice)

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 a VideoEvent.VIDEO_REMOVED VideoEvent.

Overrides:
disposePlayer in class MediaDeviceSession
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 video
visualComponent - the visual Component depicting video which has been added or removed in this instance
origin - VideoEvent.LOCAL if the origin of the video is local (e.g. it is being locally captured); VideoEvent.REMOTE if 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 instance
wait - true if the call is to wait till the specified VideoEvent has been delivered to the VideoListeners; otherwise, false

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

public 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_ADDED and origin VideoEvent.LOCAL

disposeLocalVisualComponent

public 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

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

playerConfigureComplete

protected void playerConfigureComplete(javax.media.Processor player)
Notifies this instance that a specific Player of remote content has generated a ConfigureCompleteEvent.

Overrides:
playerConfigureComplete in class MediaDeviceSession
Parameters:
player - the Player which is the source of a ConfigureCompleteEvent
See Also:
MediaDeviceSession.playerConfigureComplete(Processor)

playerControllerUpdate

protected void playerControllerUpdate(javax.media.ControllerEvent event)
Gets notified about ControllerEvents generated by a specific Player of remote content.

Overrides:
playerControllerUpdate in class MediaDeviceSession
Parameters:
event - 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:
playerRealizeComplete in class MediaDeviceSession
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 width,
                                int height)
Notifies this instance that a specific Player of remote content has generated a SizeChangeEvent.

Parameters:
sourceController - the Player which is the source of the event
width - the width reported in the event
height - the height reported in the event
See Also:
SizeChangeEvent

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

setRtcpFeedbackPLI

public void setRtcpFeedbackPLI(boolean usePLI)
Use or not RTCP feedback Picture Loss Indication.

Parameters:
usePLI - true to use PLI; otherwise, false

setOutputSize

public void setOutputSize(Dimension size)
Sets the size of the output video.

Parameters:
size - the size of the output video

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

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

setRemoteSSRC

public void setRemoteSSRC(long remoteSSRC)
Set the remote SSRC.

Parameters:
remoteSSRC - remote SSRC

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:
setProcessorFormat in class MediaDeviceSession
Parameters:
processor - the Processor to set the output MediaFormatImpl of
mediaFormat - 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:
setProcessorFormat in class MediaDeviceSession
Parameters:
trackControl - the TrackControl to set the JMF Format of
mediaFormat - 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)

setFormat

public void setFormat(MediaFormat format)
Sets the MediaFormat in which this MediaDeviceSession outputs the media captured by its MediaDevice.

Overrides:
setFormat in class MediaDeviceSession
Parameters:
format - the MediaFormat in which this MediaDeviceSession is to output the media captured by its MediaDevice

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:
startedDirectionChanged in class MediaDeviceSession
Parameters:
oldValue - the MediaDirection which used to be the value of the startedDirection property of this instance
newValue - the MediaDirection which is the value of the startedDirection property of this instance

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.