Package org.jitsi.service.neomedia
Interface MediaService
-
- All Known Implementing Classes:
MediaServiceImpl
public interface MediaServiceThe 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
Fields Modifier and Type Field Description static StringDEFAULT_DEVICEThe name of the property of MediaService the value of which corresponds to the value returned bygetDefaultDevice(MediaType, MediaUseCase).static StringENABLE_FFMPEG_CODECS_PNAMEThe name of the property which controls whether the libjitsi codecs which depend on ffmpeg (currently mp3, h264 and amrwb) will be enabled.static StringENABLE_H264_FORMAT_PNAMEThe name of the property which controls whether the h264 formats will be registered in libjitsi even if the ffmpeg codec is missing.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddPropertyChangeListener(PropertyChangeListener listener)Adds a PropertyChangeListener to be notified about changes in the values of the properties of this instance.voidaddRecorderListener(Recorder.Listener listener)Those interested in Recorder events add listener through MediaService.EncodingConfigurationcreateEmptyEncodingConfiguration()Returns a new EncodingConfiguration instance.MediaStreamcreateMediaStream(MediaDevice device)Create a MediaStream which will use a specific MediaDevice for capture and playback of media.MediaStreamcreateMediaStream(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.MediaStreamcreateMediaStream(StreamConnector connector, MediaDevice device, SrtpControl srtpControl)Creates a MediaStream that will be using the specified MediaDevice for both capture and playback of media exchanged via the specified StreamConnector.MediaStreamcreateMediaStream(StreamConnector connector, org.jitsi.utils.MediaType mediaType)Initializes a new MediaStream instance which is to exchange media of a specific MediaType via a specific StreamConnector.MediaStreamcreateMediaStream(StreamConnector connector, org.jitsi.utils.MediaType mediaType, SrtpControl srtpControl)Initializes a new MediaStream instance which is to exchange media of a specific MediaType via a specific StreamConnector.MediaStreamcreateMediaStream(org.jitsi.utils.MediaType mediaType)Initializes a new MediaStream of a specific MediaType.MediaDevicecreateMixer(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.RecordercreateRecorder(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.RecordercreateRecorder(RTPTranslator translator)Creates a new Recorder instance that can be used to record media from a specific RTPTranslator.RecorderEventHandlercreateRecorderEventHandlerJson(String filename)Creates a RecorderEventHandler instance that saves received events in JSON format.RTPTranslatorcreateRTPTranslator()Initializes a new RTPTranslator which is to forward RTP and RTCP traffic between multiple MediaStreams.SrtpControlcreateSrtpControl(SrtpControlType srtpControlType)Initializes a new SrtpControl instance with a specific SrtpControlType.List<ScreenDevice>getAvailableScreenDevices()Get available ScreenDevices.EncodingConfigurationgetCurrentEncodingConfiguration()Returns the current EncodingConfiguration instance.MediaDevicegetDefaultDevice(org.jitsi.utils.MediaType mediaType, MediaUseCase useCase)Returns the default MediaDevice for the specified media type.ScreenDevicegetDefaultScreenDevice()Get default ScreenDevice device.List<MediaDevice>getDevices(org.jitsi.utils.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 aMapthat binds indicates whatever preferences the media service implementation may have for the RTP payload type numbers that get dynamically assigned toMediaFormats with no static payload type.MediaFormatFactorygetFormatFactory()Gets the MediaFormatFactory through which MediaFormat instances may be created for the purposes of working with the MediaStreams created by this MediaService.VolumeControlgetInputVolumeControl()Gets the VolumeControl which controls the volume level of audio input/capture.MediaDevicegetMediaDeviceForPartialDesktopStreaming(int width, int height, int x, int y)Get a MediaDevice for a part of desktop streaming/sharing.PointgetOriginForDesktopStreamingDevice(MediaDevice mediaDevice)Get origin for desktop streaming device.VolumeControlgetOutputVolumeControl()Gets the VolumeControl which controls the volume level of audio output/playback.Iterator<Recorder.Listener>getRecorderListeners()Gives access to currently registered Recorder.Listeners.StringgetRtpCname()Returns the value which will be used for the canonical end-point identifier (CNAME) in RTCP packets sent by this running instance of libjitsi.ObjectgetVideoPreviewComponent(MediaDevice device, int preferredWidth, int preferredHeight)Creates a preview component for the specified device(video device) used to show video preview from it.booleanisPartialStreaming(MediaDevice mediaDevice)If the MediaDevice corresponds to partial desktop streaming device.voidremovePropertyChangeListener(PropertyChangeListener listener)Removes a PropertyChangeListener to no longer be notified about changes in the values of the properties of this instance.voidremoveRecorderListener(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 bygetDefaultDevice(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
-
ENABLE_FFMPEG_CODECS_PNAME
static final String ENABLE_FFMPEG_CODECS_PNAME
The name of the property which controls whether the libjitsi codecs which depend on ffmpeg (currently mp3, h264 and amrwb) will be enabled.
-
ENABLE_H264_FORMAT_PNAME
static final String ENABLE_H264_FORMAT_PNAME
The name of the property which controls whether the h264 formats will be registered in libjitsi even if the ffmpeg codec is missing.
-
-
Method Detail
-
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
-
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.
-
createEmptyEncodingConfiguration
EncodingConfiguration createEmptyEncodingConfiguration()
Returns a new EncodingConfiguration instance.- Returns:
- a new EncodingConfiguration instance.
-
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(org.jitsi.utils.MediaType mediaType)
Initializes a new MediaStream of a specific MediaType. The new instance will not have a MediaDevice at the time of its initialization and a MediaDevice may be specified later on with the constraint thatMediaDevice.getMediaType()equals mediaType.- Parameters:
mediaType- the MediaType of the new instance to be initialized- Returns:
- a new MediaStream instance of the specified mediaType
-
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 ondevice- 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, org.jitsi.utils.MediaType mediaType)
Initializes a new MediaStream instance which is to exchange media of a specific MediaType via a specific 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 onmediaType- the MediaType of the media to be exchanged by the new instance via the specified connector- Returns:
- a new MediaStream instance which is to exchange media of the specified mediaType via the specified connector
-
createMediaStream
MediaStream createMediaStream(StreamConnector connector, MediaDevice device, SrtpControl srtpControl)
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 ondevice- the device to be used for both capture and playback of media exchanged via the specified StreamConnectorsrtpControl- a control which is already created, used to control the ZRTP operations.- Returns:
- the newly created MediaStream.
-
createMediaStream
MediaStream createMediaStream(StreamConnector connector, org.jitsi.utils.MediaType mediaType, SrtpControl srtpControl)
Initializes a new MediaStream instance which is to exchange media of a specific MediaType via a specific StreamConnector. The security of the media exchange is to be controlled by a specific SrtpControl.- 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 onmediaType- the MediaType of the media to be exchanged by the new instance via the specified connectorsrtpControl- the SrtpControl to control the security of the media exchange- Returns:
- a new MediaStream instance which is to exchange media of the specified mediaType via the specified connector
-
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
-
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
-
createRecorder
Recorder createRecorder(RTPTranslator translator)
Creates a new Recorder instance that can be used to record media from a specific RTPTranslator.- Parameters:
translator- the RTPTranslator for which to create a Recorder- Returns:
- a new Recorder instance that can be used to record media from a specific RTPTranslator.
-
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
-
createSrtpControl
SrtpControl createSrtpControl(SrtpControlType srtpControlType)
Initializes a new SrtpControl instance with a specific SrtpControlType.- Parameters:
srtpControlType- the SrtpControlType of the new instance- Returns:
- a new SrtpControl instance with the specified srtpControlType
-
getAvailableScreenDevices
List<ScreenDevice> getAvailableScreenDevices()
Get available ScreenDevices.- Returns:
- screens
-
getCurrentEncodingConfiguration
EncodingConfiguration getCurrentEncodingConfiguration()
Returns the current EncodingConfiguration instance.- Returns:
- the current EncodingConfiguration instance.
-
getDefaultDevice
MediaDevice getDefaultDevice(org.jitsi.utils.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.
-
getDefaultScreenDevice
ScreenDevice getDefaultScreenDevice()
Get default ScreenDevice device.- Returns:
- default screen device
-
getDevices
List<MediaDevice> getDevices(org.jitsi.utils.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.
-
getDynamicPayloadTypePreferences
Map<MediaFormat,Byte> getDynamicPayloadTypePreferences()
Returns aMapthat binds indicates whatever preferences the media service implementation may have for the RTP payload type numbers that get dynamically assigned toMediaFormats 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 thisMap.- Returns:
- a
Mapbinding some formats to a preferred dynamic RTP payload type number.
-
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
-
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
-
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 partheight- height of the partx- 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
-
getOriginForDesktopStreamingDevice
Point getOriginForDesktopStreamingDevice(MediaDevice mediaDevice)
Get origin for desktop streaming device.- Parameters:
mediaDevice- media device- Returns:
- origin
-
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
-
getRecorderListeners
Iterator<Recorder.Listener> getRecorderListeners()
Gives access to currently registered Recorder.Listeners.- Returns:
- currently registered Recorder.Listeners.
-
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 devicepreferredWidth- the width we prefer for the componentpreferredHeight- the height we prefer for the component- Returns:
- the preview component.
-
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
-
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
-
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
-
getRtpCname
String getRtpCname()
Returns the value which will be used for the canonical end-point identifier (CNAME) in RTCP packets sent by this running instance of libjitsi.- Returns:
- the value which will be used for the canonical end-point identifier (CNAME) in RTCP packets sent by this running instance of libjitsi.
-
createRecorderEventHandlerJson
RecorderEventHandler createRecorderEventHandlerJson(String filename) throws IOException
Creates a RecorderEventHandler instance that saves received events in JSON format.- Parameters:
filename- the filename into which the created RecorderEventHandler will save received events.- Returns:
- a RecorderEventHandler instance that saves received events in JSON format.
- Throws:
IOException- if a RecorderEventHandler could not be created for filename.
-
-