Package org.jitsi.impl.neomedia
Class MediaServiceImpl
- java.lang.Object
-
- org.jitsi.utils.event.PropertyChangeNotifier
-
- org.jitsi.impl.neomedia.MediaServiceImpl
-
- All Implemented Interfaces:
MediaService
public class MediaServiceImpl extends org.jitsi.utils.event.PropertyChangeNotifier implements MediaService
Implements MediaService for JMF.- Author:
- Lyubomir Marinov, Dmitri Melnikov
-
-
Field Summary
Fields Modifier and Type Field Description static StringDISABLE_AUDIO_SUPPORT_PNAMEThe name of the boolean ConfigurationService property which indicates whether the detection of audio CaptureDevices is to be disabled.static StringDISABLE_SET_AUDIO_SYSTEM_PNAMEThe name of the boolean ConfigurationService property which indicates whether the methodDeviceConfiguration.setAudioSystem(AudioSystem, boolean)is to be considered disabled for the user i.e.static StringDISABLE_VIDEO_SUPPORT_PNAMEThe name of the boolean ConfigurationService property which indicates whether the detection of video CaptureDevices is to be disabled.-
Fields inherited from interface org.jitsi.service.neomedia.MediaService
DEFAULT_DEVICE, ENABLE_FFMPEG_CODECS_PNAME, ENABLE_H264_FORMAT_PNAME
-
-
Constructor Summary
Constructors Constructor Description MediaServiceImpl()Initializes a new MediaServiceImpl instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRecorderListener(Recorder.Listener listener)Those interested in Recorder events add listener through MediaService.EncodingConfigurationcreateEmptyEncodingConfiguration()Returns a newEncodingConfigurationinstance that can be used by other bundles.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 new MediaStream instance which will use the specified MediaDevice for both capture and playback of media exchanged via the specified StreamConnector.MediaStreamcreateMediaStream(StreamConnector connector, MediaDevice device, SrtpControl srtpControl)Creates a new MediaStream instance which will use 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 screens.EncodingConfigurationgetCurrentEncodingConfiguration()Returns the current encoding configuration -- the instance that contains the global settings.MediaDevicegetDefaultDevice(org.jitsi.utils.MediaType mediaType, MediaUseCase useCase)Gets the default MediaDevice for the specified MediaType.ScreenDevicegetDefaultScreenDevice()Get default screen device.DeviceConfigurationgetDeviceConfiguration()Gets the CaptureDevice user choices such as the default audio and video capture devices.List<MediaDevice>getDevices(org.jitsi.utils.MediaType mediaType, MediaUseCase useCase)Gets a list of the MediaDevices known to this MediaService and handling the specified MediaType.Map<MediaFormat,Byte>getDynamicPayloadTypePreferences()Returns aMapthat binds indicates whatever preferences this 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)Gets the origin of a specific 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.ScreenDevicegetScreenForPoint(Point p)Find the screen device that contains specified point.ObjectgetVideoPreviewComponent(MediaDevice device, int preferredWidth, int preferredHeight)Creates a preview component for the specified device(video device) used to show video preview from that device.static booleanisJmfRegistryDisableLoad()Gets the indicator which determines whether the loading of the JMF/FMJ Registry has been disabled.static booleanisMediaTypeSupportEnabled(org.jitsi.utils.MediaType mediaType)Determines whether the support for a specific MediaType is enabled.booleanisPartialStreaming(MediaDevice mediaDevice)If the MediaDevice corresponds to partial desktop streaming device.voidremoveRecorderListener(Recorder.Listener listener)Removes an existing Recorder.Listener from the list of listeners interested in notifications from Recorders.-
Methods inherited from class org.jitsi.utils.event.PropertyChangeNotifier
addPropertyChangeListener, firePropertyChange, getPropertyChangeSource, removePropertyChangeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jitsi.service.neomedia.MediaService
addPropertyChangeListener, removePropertyChangeListener
-
-
-
-
Field Detail
-
DISABLE_AUDIO_SUPPORT_PNAME
public static final String DISABLE_AUDIO_SUPPORT_PNAME
The name of the boolean ConfigurationService property which indicates whether the detection of audio CaptureDevices is to be disabled. The default value is false i.e. the audio CaptureDevices are detected.- See Also:
- Constant Field Values
-
DISABLE_SET_AUDIO_SYSTEM_PNAME
public static final String DISABLE_SET_AUDIO_SYSTEM_PNAME
The name of the boolean ConfigurationService property which indicates whether the methodDeviceConfiguration.setAudioSystem(AudioSystem, boolean)is to be considered disabled for the user i.e. the user is not presented with user interface which allows selecting a particular AudioSystem.- See Also:
- Constant Field Values
-
DISABLE_VIDEO_SUPPORT_PNAME
public static final String DISABLE_VIDEO_SUPPORT_PNAME
The name of the boolean ConfigurationService property which indicates whether the detection of video CaptureDevices is to be disabled. The default value is false i.e. the video CaptureDevices are detected.- See Also:
- Constant Field Values
-
-
Method Detail
-
createMediaStream
public 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.- Specified by:
createMediaStreamin interfaceMediaService- 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
- See Also:
MediaService.createMediaStream(MediaDevice)
-
createMediaStream
public 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. ImplementsMediaService.createMediaStream(MediaType). Initializes a new AudioMediaStreamImpl or VideoMediaStreamImpl in accord with mediaType- Specified by:
createMediaStreamin interfaceMediaService- Parameters:
mediaType- the MediaType of the new instance to be initialized- Returns:
- a new MediaStream instance of the specified mediaType
-
createMediaStream
public MediaStream createMediaStream(StreamConnector connector, MediaDevice device)
Creates a new MediaStream instance which will use the specified MediaDevice for both capture and playback of media exchanged via the specified StreamConnector.- Specified by:
createMediaStreamin interfaceMediaService- Parameters:
connector- the StreamConnector that the new MediaStream instance is to use for sending and receiving mediadevice- the MediaDevice that the new MediaStream instance is to use for both capture and playback of media exchanged via the specified connector- Returns:
- a new MediaStream instance
- See Also:
MediaService.createMediaStream(StreamConnector, MediaDevice)
-
createMediaStream
public 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.- Specified by:
createMediaStreamin interfaceMediaService- 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
public MediaStream createMediaStream(StreamConnector connector, MediaDevice device, SrtpControl srtpControl)
Creates a new MediaStream instance which will use the specified MediaDevice for both capture and playback of media exchanged via the specified StreamConnector.- Specified by:
createMediaStreamin interfaceMediaService- Parameters:
connector- the StreamConnector that the new MediaStream instance is to use for sending and receiving mediadevice- the MediaDevice that the new MediaStream instance is to use for both capture and playback of media exchanged via the specified connectorsrtpControl- a control which is already created, used to control the SRTP operations.- Returns:
- a new MediaStream instance
- See Also:
MediaService.createMediaStream(StreamConnector, MediaDevice)
-
createMediaStream
public 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.- Specified by:
createMediaStreamin interfaceMediaService- 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
public 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.- Specified by:
createMixerin interfaceMediaService- 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
- See Also:
MediaService.createMixer(MediaDevice)
-
getDefaultDevice
public MediaDevice getDefaultDevice(org.jitsi.utils.MediaType mediaType, MediaUseCase useCase)
Gets the default MediaDevice for the specified MediaType.- Specified by:
getDefaultDevicein interfaceMediaService- Parameters:
mediaType- a MediaType value indicating the type of media to be handled by the MediaDevice to be obtaineduseCase- the MediaUseCase to obtain the MediaDevice list for- Returns:
- the default MediaDevice for the specified mediaType if such a MediaDevice exists; otherwise, null
- See Also:
MediaService.getDefaultDevice(MediaType, MediaUseCase)
-
getDeviceConfiguration
public DeviceConfiguration getDeviceConfiguration()
Gets the CaptureDevice user choices such as the default audio and video capture devices.- Returns:
- the CaptureDevice user choices such as the default audio and video capture devices.
-
getDevices
public List<MediaDevice> getDevices(org.jitsi.utils.MediaType mediaType, MediaUseCase useCase)
Gets a list of the MediaDevices known to this MediaService and handling the specified MediaType.- Specified by:
getDevicesin interfaceMediaService- Parameters:
mediaType- the MediaType to obtain the MediaDevice list foruseCase- the MediaUseCase to obtain the MediaDevice list for- Returns:
- a new List of MediaDevices known to this MediaService and handling the specified MediaType. The returned List is a copy of the internal storage and, consequently, modifications to it do not affect this instance. Despite the fact that a new List instance is returned by each call to this method, the MediaDevice instances are the same if they are still known to this MediaService to be available.
- See Also:
MediaService.getDevices(MediaType, MediaUseCase)
-
getCurrentEncodingConfiguration
public EncodingConfiguration getCurrentEncodingConfiguration()
Returns the current encoding configuration -- the instance that contains the global settings. Note that any changes made to this instance will have immediate effect on the configuration.- Specified by:
getCurrentEncodingConfigurationin interfaceMediaService- Returns:
- the current encoding configuration -- the instance that contains the global settings.
-
getFormatFactory
public MediaFormatFactory getFormatFactory()
Gets the MediaFormatFactory through which MediaFormat instances may be created for the purposes of working with the MediaStreams created by this MediaService.- Specified by:
getFormatFactoryin interfaceMediaService- Returns:
- the MediaFormatFactory through which MediaFormat instances may be created for the purposes of working with the MediaStreams created by this MediaService
- See Also:
MediaService.getFormatFactory()
-
createSrtpControl
public SrtpControl createSrtpControl(SrtpControlType srtpControlType)
Initializes a new SrtpControl instance with a specific SrtpControlType.- Specified by:
createSrtpControlin interfaceMediaService- Parameters:
srtpControlType- the SrtpControlType of the new instance- Returns:
- a new SrtpControl instance with the specified srtpControlType
-
getOutputVolumeControl
public VolumeControl getOutputVolumeControl()
Gets the VolumeControl which controls the volume level of audio output/playback.- Specified by:
getOutputVolumeControlin interfaceMediaService- Returns:
- the VolumeControl which controls the volume level of audio output/playback
- See Also:
MediaService.getOutputVolumeControl()
-
getInputVolumeControl
public VolumeControl getInputVolumeControl()
Gets the VolumeControl which controls the volume level of audio input/capture.- Specified by:
getInputVolumeControlin interfaceMediaService- Returns:
- the VolumeControl which controls the volume level of audio input/capture
- See Also:
MediaService.getInputVolumeControl()
-
getAvailableScreenDevices
public List<ScreenDevice> getAvailableScreenDevices()
Get available screens.- Specified by:
getAvailableScreenDevicesin interfaceMediaService- Returns:
- screens
-
getDefaultScreenDevice
public ScreenDevice getDefaultScreenDevice()
Get default screen device.- Specified by:
getDefaultScreenDevicein interfaceMediaService- Returns:
- default screen device
-
createRecorder
public 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.- Specified by:
createRecorderin interfaceMediaService- 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
- See Also:
MediaService.createRecorder(MediaDevice)
-
createRecorder
public Recorder createRecorder(RTPTranslator translator)
Creates a new Recorder instance that can be used to record media from a specific RTPTranslator.- Specified by:
createRecorderin interfaceMediaService- 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.
-
getDynamicPayloadTypePreferences
public Map<MediaFormat,Byte> getDynamicPayloadTypePreferences()
Returns aMapthat binds indicates whatever preferences this 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. Signaling 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.- Specified by:
getDynamicPayloadTypePreferencesin interfaceMediaService- Returns:
- a
Mapbinding some formats to a preferred dynamic RTP payload type number.
-
getVideoPreviewComponent
public Object getVideoPreviewComponent(MediaDevice device, int preferredWidth, int preferredHeight)
Creates a preview component for the specified device(video device) used to show video preview from that device.- Specified by:
getVideoPreviewComponentin interfaceMediaService- Parameters:
device- the video devicepreferredWidth- the width we prefer for the componentpreferredHeight- the height we prefer for the component- Returns:
- the preview component.
-
getMediaDeviceForPartialDesktopStreaming
public MediaDevice getMediaDeviceForPartialDesktopStreaming(int width, int height, int x, int y)
Get a MediaDevice for a part of desktop streaming/sharing.- Specified by:
getMediaDeviceForPartialDesktopStreamingin interfaceMediaService- 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
-
isPartialStreaming
public boolean isPartialStreaming(MediaDevice mediaDevice)
If the MediaDevice corresponds to partial desktop streaming device.- Specified by:
isPartialStreamingin interfaceMediaService- Parameters:
mediaDevice- MediaDevice- Returns:
- true if MediaDevice is a partial desktop streaming device, false otherwise
-
getScreenForPoint
public ScreenDevice getScreenForPoint(Point p)
Find the screen device that contains specified point.- Parameters:
p- point coordinates- Returns:
- screen device that contains point
-
getOriginForDesktopStreamingDevice
public Point getOriginForDesktopStreamingDevice(MediaDevice mediaDevice)
Gets the origin of a specific desktop streaming device.- Specified by:
getOriginForDesktopStreamingDevicein interfaceMediaService- Parameters:
mediaDevice- the desktop streaming device to get the origin on- Returns:
- the origin of the specified desktop streaming device
-
addRecorderListener
public 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.- Specified by:
addRecorderListenerin interfaceMediaService- Parameters:
listener- the new Recorder.Listener to be added to the list of listeners interested in notifications from Recorders.
-
removeRecorderListener
public void removeRecorderListener(Recorder.Listener listener)
Removes an existing Recorder.Listener from the list of listeners interested in notifications from Recorders.- Specified by:
removeRecorderListenerin interfaceMediaService- Parameters:
listener- the existing Listener to be removed from the list of listeners interested in notifications from Recorders
-
getRecorderListeners
public Iterator<Recorder.Listener> getRecorderListeners()
Gives access to currently registered Recorder.Listeners.- Specified by:
getRecorderListenersin interfaceMediaService- Returns:
- currently registered Recorder.Listeners.
-
createRTPTranslator
public RTPTranslator createRTPTranslator()
Initializes a new RTPTranslator which is to forward RTP and RTCP traffic between multiple MediaStreams.- Specified by:
createRTPTranslatorin interfaceMediaService- Returns:
- a new RTPTranslator which is to forward RTP and RTCP traffic between multiple MediaStreams
- See Also:
MediaService.createRTPTranslator()
-
isJmfRegistryDisableLoad
public static boolean isJmfRegistryDisableLoad()
Gets the indicator which determines whether the loading of the JMF/FMJ Registry has been disabled.- Returns:
- true if the loading of the JMF/FMJ Registry has been disabled; otherwise, false
-
createEmptyEncodingConfiguration
public EncodingConfiguration createEmptyEncodingConfiguration()
Returns a newEncodingConfigurationinstance that can be used by other bundles.- Specified by:
createEmptyEncodingConfigurationin interfaceMediaService- Returns:
- a new
EncodingConfigurationinstance.
-
isMediaTypeSupportEnabled
public static boolean isMediaTypeSupportEnabled(org.jitsi.utils.MediaType mediaType)
Determines whether the support for a specific MediaType is enabled. The ConfigurationService and System propertiesDISABLE_AUDIO_SUPPORT_PNAMEandDISABLE_VIDEO_SUPPORT_PNAMEallow disabling the support for, respectively,MediaType.AUDIOandMediaType.VIDEO.- Parameters:
mediaType- the MediaType to be determined whether the support for it is enabled- Returns:
- true if the support for the specified mediaType is enabled; otherwise, false
-
getRtpCname
public 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.- Specified by:
getRtpCnamein interfaceMediaService- 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
public RecorderEventHandler createRecorderEventHandlerJson(String filename) throws IOException
Creates a RecorderEventHandler instance that saves received events in JSON format.- Specified by:
createRecorderEventHandlerJsonin interfaceMediaService- 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.
-
-