Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.service.neomedia
Interface MediaService

All Known Implementing Classes:
MediaServiceImpl

public interface MediaService

The MediaService service is meant to be a wrapper of media libraries such as JMF, FMJ, FFMPEG, and/or others. It takes care of all media play and capture as well as media transport (e.g. over RTP).

Author:
Emil Ivov, Lyubomir Marinov

Field Summary
static String DEFAULT_DEVICE
          The name of the property of MediaService the value of which corresponds to the value returned by getDefaultDevice(MediaType, MediaUseCase).
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a PropertyChangeListener to be notified about changes in the values of the properties of this instance.
 void addRecorderListener(Recorder.Listener listener)
          Those interested in Recorder events add listener through MediaService.
 MediaStream createMediaStream(MediaDevice device)
          Create a MediaStream which will use a specific MediaDevice for capture and playback of media.
 MediaStream createMediaStream(StreamConnector connector, MediaDevice device)
          Creates a MediaStream that will be using the specified MediaDevice for both capture and playback of media exchanged via the specified StreamConnector.
 MediaStream createMediaStream(StreamConnector connector, MediaDevice device, SrtpControl zrtpControl)
          Creates a MediaStream that will be using the specified MediaDevice for both capture and playback of media exchanged via the specified StreamConnector.
 MediaDevice createMixer(MediaDevice device)
          Creates a new MediaDevice which uses a specific MediaDevice to capture and play back media and performs mixing of the captured media and the media played back by any other users of the returned MediaDevice.
 Recorder createRecorder(MediaDevice device)
          Creates a new Recorder instance that can be used to record a call which captures and plays back media using a specific MediaDevice.
 RTPTranslator createRTPTranslator()
          Initializes a new RTPTranslator which is to forward RTP and RTCP traffic between multiple MediaStreams.
 SDesControl createSDesControl()
          Initializes a new SDesControl instance which is to control all SDes options.
 ZrtpControl createZrtpControl()
          Initializes a new ZrtpControl instance which is to control all ZRTP options.
 List<ScreenDevice> getAvailableScreenDevices()
          Get available ScreenDevices.
 MediaDevice getDefaultDevice(MediaType mediaType, MediaUseCase useCase)
          Returns the default MediaDevice for the specified media type.
 ScreenDevice getDefaultScreenDevice()
          Get default ScreenDevice device.
 List<MediaDevice> getDevices(MediaType mediaType, MediaUseCase useCase)
          Returns a list containing all devices known to this service implementation and handling the specified MediaType.
 Map<MediaFormat,Byte> getDynamicPayloadTypePreferences()
          Returns a Map that binds indicates whatever preferences the media service implementation may have for the RTP payload type numbers that get dynamically assigned to MediaFormats with no static payload type.
 MediaFormatFactory getFormatFactory()
          Gets the MediaFormatFactory through which MediaFormat instances may be created for the purposes of working with the MediaStreams created by this MediaService.
 VolumeControl getInputVolumeControl()
          Gets the VolumeControl which controls the volume level of audio input/capture.
 MediaDevice getMediaDeviceForPartialDesktopStreaming(int width, int height, int x, int y)
          Get a MediaDevice for a part of desktop streaming/sharing.
 Point getOriginForDesktopStreamingDevice(MediaDevice mediaDevice)
          Get origin for desktop streaming device.
 VolumeControl getOutputVolumeControl()
          Gets the VolumeControl which controls the volume level of audio output/playback.
 Iterator<Recorder.Listener> getRecorderListeners()
          Gives access to currently registered Recorder.Listeners.
 Object getVideoPreviewComponent(MediaDevice device, int preferredWidth, int preferredHeight)
          Creates a preview component for the specified device(video device) used to show video preview from it.
 boolean isPartialStreaming(MediaDevice mediaDevice)
          If the MediaDevice corresponds to partial desktop streaming device.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a PropertyChangeListener to no longer be notified about changes in the values of the properties of this instance.
 void removeRecorderListener(Recorder.Listener listener)
          Removes an existing Recorder.Listener from the list of listeners interested in notifications from Recorders.
 

Field Detail

DEFAULT_DEVICE

static final String DEFAULT_DEVICE
The name of the property of MediaService the value of which corresponds to the value returned by getDefaultDevice(MediaType, MediaUseCase). The oldValue and the newValue of the fired PropertyChangeEvent are not to be relied on and instead a call to getDefaultDevice is to be performed to retrieve the new value.

See Also:
Constant Field Values
Method Detail

getDefaultDevice

MediaDevice getDefaultDevice(MediaType mediaType,
                             MediaUseCase useCase)
Returns the default MediaDevice for the specified media type.

Parameters:
mediaType - a MediaType value indicating the kind of device that we are trying to obtain.
useCase - MediaUseCase value indicating for the use-case of device that we are trying to obtain.
Returns:
the currently default MediaDevice for the specified MediaType, or null if no such device exists.

getDevices

List<MediaDevice> getDevices(MediaType mediaType,
                             MediaUseCase useCase)
Returns a list containing all devices known to this service implementation and handling the specified MediaType.

Parameters:
mediaType - the media type (i.e. AUDIO or VIDEO) that we'd like to obtain the device list for.
useCase - MediaUseCase value indicating for the use-case of device that we are trying to obtain.
Returns:
the list of MediaDevices currently known to handle the specified mediaType.

createMediaStream

MediaStream createMediaStream(MediaDevice device)
Create a MediaStream which will use a specific MediaDevice for capture and playback of media. The new instance will not have a StreamConnector at the time of its construction and a StreamConnector will be specified later on in order to enable the new instance to send and receive media.

Parameters:
device - the MediaDevice to be used by the new instance for capture and playback of media
Returns:
a newly-created MediaStream which will use the specified device for capture and playback of media

createMediaStream

MediaStream createMediaStream(StreamConnector connector,
                              MediaDevice device)
Creates a MediaStream that will be using the specified MediaDevice for both capture and playback of media exchanged via the specified StreamConnector.

Parameters:
connector - the StreamConnector the stream should use for sending and receiving media or null if the stream is to not have a StreamConnector configured at initialization time and a StreamConnector is to be specified later on
device - the device to be used for both capture and playback of media exchanged via the specified StreamConnector
Returns:
the newly created MediaStream.

createMediaStream

MediaStream createMediaStream(StreamConnector connector,
                              MediaDevice device,
                              SrtpControl zrtpControl)
Creates a MediaStream that will be using the specified MediaDevice for both capture and playback of media exchanged via the specified StreamConnector.

Parameters:
connector - the StreamConnector the stream should use for sending and receiving media or null if the stream is to not have a StreamConnector configured at initialization time and a StreamConnector is to be specified later on
device - the device to be used for both capture and playback of media exchanged via the specified StreamConnector
zrtpControl - a control which is already created, used to control the ZRTP operations.
Returns:
the newly created MediaStream.

createMixer

MediaDevice createMixer(MediaDevice device)
Creates a new MediaDevice which uses a specific MediaDevice to capture and play back media and performs mixing of the captured media and the media played back by any other users of the returned MediaDevice. For the AUDIO MediaType, the returned device is commonly referred to as an audio mixer. The MediaType of the returned MediaDevice is the same as the MediaType of the specified device.

Parameters:
device - the MediaDevice which is to be used by the returned MediaDevice to actually capture and play back media
Returns:
a new MediaDevice instance which uses device to capture and play back media and performs mixing of the captured media and the media played back by any other users of the returned MediaDevice instance

getFormatFactory

MediaFormatFactory getFormatFactory()
Gets the MediaFormatFactory through which MediaFormat instances may be created for the purposes of working with the MediaStreams created by this MediaService.

Returns:
the MediaFormatFactory through which MediaFormat instances may be created for the purposes of working with the MediaStreams created by this MediaService

createZrtpControl

ZrtpControl createZrtpControl()
Initializes a new ZrtpControl instance which is to control all ZRTP options.

Returns:
a new ZrtpControl instance which is to control all ZRTP options

createSDesControl

SDesControl createSDesControl()
Initializes a new SDesControl instance which is to control all SDes options.

Returns:
a new SDesControl instance which is to control all SDes options

getOutputVolumeControl

VolumeControl getOutputVolumeControl()
Gets the VolumeControl which controls the volume level of audio output/playback.

Returns:
the VolumeControl which controls the volume level of audio output/playback

getInputVolumeControl

VolumeControl getInputVolumeControl()
Gets the VolumeControl which controls the volume level of audio input/capture.

Returns:
the VolumeControl which controls the volume level of audio input/capture

getAvailableScreenDevices

List<ScreenDevice> getAvailableScreenDevices()
Get available ScreenDevices.

Returns:
screens

getDefaultScreenDevice

ScreenDevice getDefaultScreenDevice()
Get default ScreenDevice device.

Returns:
default screen device

createRecorder

Recorder createRecorder(MediaDevice device)
Creates a new Recorder instance that can be used to record a call which captures and plays back media using a specific MediaDevice.

Parameters:
device - the MediaDevice which is used for media capture and playback by the call to be recorded
Returns:
a new Recorder instance that can be used to record a call which captures and plays back media using the specified MediaDevice

getDynamicPayloadTypePreferences

Map<MediaFormat,Byte> getDynamicPayloadTypePreferences()
Returns a Map that binds indicates whatever preferences the media service implementation may have for the RTP payload type numbers that get dynamically assigned to MediaFormats with no static payload type. The method is useful for formats such as "telephone-event" for example that is statically assigned the 101 payload type by some legacy systems. Signalling protocol implementations such as SIP and XMPP should make sure that, whenever this is possible, they assign to formats the dynamic payload type returned in this Map.

Returns:
a Map binding some formats to a preferred dynamic RTP payload type number.

getVideoPreviewComponent

Object getVideoPreviewComponent(MediaDevice device,
                                int preferredWidth,
                                int preferredHeight)
Creates a preview component for the specified device(video device) used to show video preview from it.

Parameters:
device - the video device
preferredWidth - the width we prefer for the component
preferredHeight - the height we prefer for the component
Returns:
the preview component.

getMediaDeviceForPartialDesktopStreaming

MediaDevice getMediaDeviceForPartialDesktopStreaming(int width,
                                                     int height,
                                                     int x,
                                                     int y)
Get a MediaDevice for a part of desktop streaming/sharing.

Parameters:
width - width of the part
height - height of the part
x - origin of the x coordinate (relative to the full desktop)
y - origin of the y coordinate (relative to the full desktop)
Returns:
MediaDevice representing the part of desktop or null if problem

isPartialStreaming

boolean isPartialStreaming(MediaDevice mediaDevice)
If the MediaDevice corresponds to partial desktop streaming device.

Parameters:
mediaDevice - MediaDevice
Returns:
true if MediaDevice is a partial desktop streaming device, false otherwise

getOriginForDesktopStreamingDevice

Point getOriginForDesktopStreamingDevice(MediaDevice mediaDevice)
Get origin for desktop streaming device.

Parameters:
mediaDevice - media device
Returns:
origin

addRecorderListener

void addRecorderListener(Recorder.Listener listener)
Those interested in Recorder events add listener through MediaService. This way they don't need to have access to the Recorder instance. Adds a new Recorder.Listener to the list of listeners interested in notifications from a Recorder.

Parameters:
listener - the new Recorder.Listener to be added to the list of listeners interested in notifications from Recorders.

removeRecorderListener

void removeRecorderListener(Recorder.Listener listener)
Removes an existing Recorder.Listener from the list of listeners interested in notifications from Recorders.

Parameters:
listener - the existing Listener to be removed from the list of listeners interested in notifications from Recorders

getRecorderListeners

Iterator<Recorder.Listener> getRecorderListeners()
Gives access to currently registered Recorder.Listeners.

Returns:
currently registered Recorder.Listeners.

createRTPTranslator

RTPTranslator createRTPTranslator()
Initializes a new RTPTranslator which is to forward RTP and RTCP traffic between multiple MediaStreams.

Returns:
a new RTPTranslator which is to forward RTP and RTCP traffic between multiple MediaStreams

addPropertyChangeListener

void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to be notified about changes in the values of the properties of this instance.

Parameters:
listener - the PropertyChangeListener to be notified about changes in the values of the properties of this instance

removePropertyChangeListener

void removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener to no longer be notified about changes in the values of the properties of this instance.

Parameters:
listener - the PropertyChangeListener to no longer be notified about changes in the values of the properties 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.