Class 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 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_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
    • Constructor Detail

      • MediaServiceImpl

        public MediaServiceImpl()
        Initializes a new MediaServiceImpl instance.
    • 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:
        createMediaStream in interface MediaService
        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 that MediaDevice.getMediaType() equals mediaType. Implements MediaService.createMediaStream(MediaType). Initializes a new AudioMediaStreamImpl or VideoMediaStreamImpl in accord with mediaType
        Specified by:
        createMediaStream in interface MediaService
        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:
        createMediaStream in interface MediaService
        Parameters:
        connector - the StreamConnector that the new MediaStream instance is to use for sending and receiving media
        device - 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:
        createMediaStream in interface MediaService
        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
        mediaType - 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:
        createMediaStream in interface MediaService
        Parameters:
        connector - the StreamConnector that the new MediaStream instance is to use for sending and receiving media
        device - the MediaDevice that the new MediaStream instance is to use for both capture and playback of media exchanged via the specified connector
        srtpControl - 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:
        createMediaStream in interface MediaService
        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
        mediaType - the MediaType of the media to be exchanged by the new instance via the specified connector
        srtpControl - 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:
        createMixer in interface MediaService
        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:
        getDefaultDevice in interface MediaService
        Parameters:
        mediaType - a MediaType value indicating the type of media to be handled by the MediaDevice to be obtained
        useCase - 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:
        getDevices in interface MediaService
        Parameters:
        mediaType - the MediaType to obtain the MediaDevice list for
        useCase - 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:
        getCurrentEncodingConfiguration in interface MediaService
        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:
        getFormatFactory in interface MediaService
        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:
        createSrtpControl in interface MediaService
        Parameters:
        srtpControlType - the SrtpControlType of the new instance
        Returns:
        a new SrtpControl instance with the specified srtpControlType
      • 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:
        createRecorder in interface MediaService
        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:
        createRecorder in interface MediaService
        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 a Map that binds indicates whatever preferences this 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. 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 this Map.
        Specified by:
        getDynamicPayloadTypePreferences in interface MediaService
        Returns:
        a Map binding 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:
        getVideoPreviewComponent in interface MediaService
        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

        public MediaDevice getMediaDeviceForPartialDesktopStreaming​(int width,
                                                                    int height,
                                                                    int x,
                                                                    int y)
        Get a MediaDevice for a part of desktop streaming/sharing.
        Specified by:
        getMediaDeviceForPartialDesktopStreaming in interface MediaService
        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

        public boolean isPartialStreaming​(MediaDevice mediaDevice)
        If the MediaDevice corresponds to partial desktop streaming device.
        Specified by:
        isPartialStreaming in interface MediaService
        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:
        getOriginForDesktopStreamingDevice in interface MediaService
        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:
        addRecorderListener in interface MediaService
        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:
        removeRecorderListener in interface MediaService
        Parameters:
        listener - the existing Listener to be removed from the list of listeners interested in notifications from Recorders
      • 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
      • isMediaTypeSupportEnabled

        public static boolean isMediaTypeSupportEnabled​(org.jitsi.utils.MediaType mediaType)
        Determines whether the support for a specific MediaType is enabled. The ConfigurationService and System properties DISABLE_AUDIO_SUPPORT_PNAME and DISABLE_VIDEO_SUPPORT_PNAME allow disabling the support for, respectively, MediaType.AUDIO and MediaType.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:
        getRtpCname in interface MediaService
        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:
        createRecorderEventHandlerJson in interface MediaService
        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.