Class DeviceSystem

  • Direct Known Subclasses:
    AudioSystem, DirectShowSystem, ImgStreamingSystem, QuickTimeSystem, Video4Linux2System

    public abstract class DeviceSystem
    extends org.jitsi.utils.event.PropertyChangeNotifier
    Represents the base of a supported device system/backend such as DirectShow, PortAudio, PulseAudio, QuickTime, video4linux2. A DeviceSystem is initialized at a certain time (usually, during the initialization of the MediaService implementation which is going to use it) and it registers with FMJ the CaptureDevices it will provide. In addition to providing the devices for the purposes of capture, a DeviceSystem also provides the devices on which playback is to be performed i.e. it acts as a Renderer factory via its createRenderer() method.
    Author:
    Lyubomir Marinov
    • Constructor Detail

      • DeviceSystem

        protected DeviceSystem​(org.jitsi.utils.MediaType mediaType,
                               String locatorProtocol)
                        throws Exception
        Throws:
        Exception
      • DeviceSystem

        protected DeviceSystem​(org.jitsi.utils.MediaType mediaType,
                               String locatorProtocol,
                               int features)
                        throws Exception
        Throws:
        Exception
    • Method Detail

      • filterDeviceListByLocatorProtocol

        protected static List<javax.media.CaptureDeviceInfo> filterDeviceListByLocatorProtocol​(List<javax.media.CaptureDeviceInfo> deviceList,
                                                                                               String locatorProtocol)
        Returns a List of CaptureDeviceInfos which are elements of a specific List of CaptureDeviceInfos and have a specific MediaLocator protocol.
        Parameters:
        deviceList - the List of CaptureDeviceInfo which are to be filtered based on the specified MediaLocator protocol
        locatorProtocol - the protocol of the MediaLocators of the CaptureDeviceInfos which are to be returned
        Returns:
        a List of CaptureDeviceInfos which are elements of the specified deviceList and have the specified locatorProtocol
      • getDeviceSystems

        public static DeviceSystem[] getDeviceSystems​(org.jitsi.utils.MediaType mediaType)
      • initializeDeviceSystems

        public static void initializeDeviceSystems()
        Initializes the DeviceSystem instances which are to represent the supported device systems/backends such as DirectShow, PortAudio, PulseAudio, QuickTime, video4linux2. The method may be invoked multiple times. If a DeviceSystem has been initialized by a previous invocation of the method, its initialize() method will be called again as part of the subsequent invocation only if the DeviceSystem in question returns a set of flags from its getFeatures() method which contains the constant/flag FEATURE_REINITIALIZE.
      • initializeDeviceSystems

        public static void initializeDeviceSystems​(org.jitsi.utils.MediaType mediaType)
        Initializes the DeviceSystem instances which are to represent the supported device systems/backends which are to capable of capturing and playing back media of a specific type such as audio or video.
        Parameters:
        mediaType - the MediaType of the DeviceSystems to be initialized
      • createRenderer

        public javax.media.Renderer createRenderer()
        Initializes a new Renderer instance which is to perform playback on a device contributed by this system.
        Returns:
        a new Renderer instance which is to perform playback on a device contributed by this system or null
      • doInitialize

        protected abstract void doInitialize()
                                      throws Exception
        Invoked by initialize() to perform the very logic of the initialization of this DeviceSystem. This instance has been prepared for initialization by an earlier call to preInitialize() and the initialization will be completed with a subsequent call to postInitialize().
        Throws:
        Exception - if an error occurs during the initialization of this instance. The initialization of this instance will be completed with a subsequent call to postInitialize() regardless of any Exception thrown by doInitialize().
      • getFeatures

        public final int getFeatures()
        Gets the flags indicating the optional features supported by this DeviceSystem.
        Returns:
        the flags indicating the optional features supported by this DeviceSystem. The possible flags are among the FEATURE_XXX constants defined by the DeviceSystem class and its extenders.
      • getFormat

        public javax.media.Format getFormat()
        Returns the format depending on the media type: AudioFormat for AUDIO, VideoFormat for VIDEO. Otherwise, returns null.
        Returns:
        The format depending on the media type: AudioFormat for AUDIO, VideoFormat for VIDEO. Otherwise, returns null.
      • getLocatorProtocol

        public final String getLocatorProtocol()
        Gets the protocol of the MediaLocators of the CaptureDeviceInfos (to be) registered (with FMJ) by this DeviceSystem. The protocol is a unique identifier of a DeviceSystem.
        Returns:
        the protocol of the MediaLocators of the CaptureDeviceInfos (to be) registered (with FMJ) by this DeviceSystem
      • getMediaType

        public final org.jitsi.utils.MediaType getMediaType()
      • getRendererClassName

        protected String getRendererClassName()
        Gets the name of the class which implements the Renderer interface to render media on a playback or notification device associated with this DeviceSystem.
        Returns:
        the name of the class which implements the Renderer interface to render media on a playback or notification device associated with this DeviceSystem or null if no Renderer instance is to be created by the DeviceSystem implementation or createRenderer(boolean) is overridden.
      • initialize

        protected final void initialize()
                                 throws Exception
        Initializes this DeviceSystem i.e. represents the native/system devices in the terms of the application so that they may be utilized. For example, the capture devices are represented as CaptureDeviceInfo instances registered with FMJ.

        Note: The method is synchronized on this instance in order to guarantee that the whole initialization procedure (which includes doInitialize()) executes once at any given time.

        Throws:
        Exception - if an error occurs during the initialization of this DeviceSystem
      • postInitialize

        protected void postInitialize()
                               throws Exception
        Invoked as part of the execution of initialize() after the execution of doInitialize() regardless of whether the latter completed successfully. The implementation of DeviceSystem fires a new PropertyChangeEvent to notify that the value of the property PROP_DEVICES of this instance may have changed i.e. that the list of devices detected by this instance may have changed.
        Throws:
        Exception
      • preInitialize

        protected void preInitialize()
                              throws Exception
        Invoked as part of the execution of initialize() before the execution of doInitialize(). The implementation of DeviceSystem removes from FMJ's CaptureDeviceManager the CaptureDeviceInfos whose MediaLocator has the same protocol as getLocatorProtocol() of this instance.
        Throws:
        Exception
      • toString

        public String toString()
        Returns a human-readable representation of this DeviceSystem. The implementation of DeviceSystem returns the protocol of the MediaLocators of the CaptureDeviceInfos (to be) registered by this DeviceSystem.
        Overrides:
        toString in class Object
        Returns:
        a String which represents this DeviceSystem in a human-readable form