Package org.jitsi.impl.neomedia.device
Class DeviceSystem
- java.lang.Object
-
- org.jitsi.utils.event.PropertyChangeNotifier
-
- org.jitsi.impl.neomedia.device.DeviceSystem
-
- Direct Known Subclasses:
AudioSystem,DirectShowSystem,ImgStreamingSystem,QuickTimeSystem,Video4Linux2System
public abstract class DeviceSystem extends org.jitsi.utils.event.PropertyChangeNotifierRepresents 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 itscreateRenderer()method.- Author:
- Lyubomir Marinov
-
-
Field Summary
Fields Modifier and Type Field Description static intFEATURE_REINITIALIZEThe constant/flag (to be) returned bygetFeatures()in order to indicate that the respective DeviceSystem supports invoking itsinitialize()more than once.static StringLOCATOR_PROTOCOL_ANDROIDCAMERAstatic StringLOCATOR_PROTOCOL_CIVILstatic StringLOCATOR_PROTOCOL_DIRECTSHOWstatic StringLOCATOR_PROTOCOL_IMGSTREAMINGstatic StringLOCATOR_PROTOCOL_MEDIARECORDERstatic StringLOCATOR_PROTOCOL_QUICKTIMEstatic StringLOCATOR_PROTOCOL_VIDEO4LINUX2static StringPROP_DEVICES
-
Constructor Summary
Constructors Modifier Constructor Description protectedDeviceSystem(org.jitsi.utils.MediaType mediaType, String locatorProtocol)protectedDeviceSystem(org.jitsi.utils.MediaType mediaType, String locatorProtocol, int features)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description javax.media.RenderercreateRenderer()Initializes a new Renderer instance which is to perform playback on a device contributed by this system.protected abstract voiddoInitialize()Invoked byinitialize()to perform the very logic of the initialization of this DeviceSystem.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.static DeviceSystem[]getDeviceSystems(org.jitsi.utils.MediaType mediaType)intgetFeatures()Gets the flags indicating the optional features supported by this DeviceSystem.javax.media.FormatgetFormat()Returns the format depending on the media type: AudioFormat for AUDIO, VideoFormat for VIDEO.StringgetLocatorProtocol()Gets the protocol of the MediaLocators of the CaptureDeviceInfos (to be) registered (with FMJ) by this DeviceSystem.org.jitsi.utils.MediaTypegetMediaType()protected StringgetRendererClassName()Gets the name of the class which implements the Renderer interface to render media on a playback or notification device associated with this DeviceSystem.protected voidinitialize()Initializes this DeviceSystem i.e.static voidinitializeDeviceSystems()Initializes the DeviceSystem instances which are to represent the supported device systems/backends such as DirectShow, PortAudio, PulseAudio, QuickTime, video4linux2.static voidinitializeDeviceSystems(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.protected voidpostInitialize()Invoked as part of the execution ofinitialize()after the execution ofdoInitialize()regardless of whether the latter completed successfully.protected voidpreInitialize()Invoked as part of the execution ofinitialize()before the execution ofdoInitialize().StringtoString()Returns a human-readable representation of this DeviceSystem.
-
-
-
Field Detail
-
FEATURE_REINITIALIZE
public static final int FEATURE_REINITIALIZE
The constant/flag (to be) returned bygetFeatures()in order to indicate that the respective DeviceSystem supports invoking itsinitialize()more than once.- See Also:
- Constant Field Values
-
LOCATOR_PROTOCOL_ANDROIDCAMERA
public static final String LOCATOR_PROTOCOL_ANDROIDCAMERA
- See Also:
- Constant Field Values
-
LOCATOR_PROTOCOL_CIVIL
public static final String LOCATOR_PROTOCOL_CIVIL
- See Also:
- Constant Field Values
-
LOCATOR_PROTOCOL_DIRECTSHOW
public static final String LOCATOR_PROTOCOL_DIRECTSHOW
- See Also:
- Constant Field Values
-
LOCATOR_PROTOCOL_IMGSTREAMING
public static final String LOCATOR_PROTOCOL_IMGSTREAMING
- See Also:
- Constant Field Values
-
LOCATOR_PROTOCOL_MEDIARECORDER
public static final String LOCATOR_PROTOCOL_MEDIARECORDER
- See Also:
- Constant Field Values
-
LOCATOR_PROTOCOL_QUICKTIME
public static final String LOCATOR_PROTOCOL_QUICKTIME
- See Also:
- Constant Field Values
-
LOCATOR_PROTOCOL_VIDEO4LINUX2
public static final String LOCATOR_PROTOCOL_VIDEO4LINUX2
- See Also:
- Constant Field Values
-
PROP_DEVICES
public static final String PROP_DEVICES
- See Also:
- Constant Field Values
-
-
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 protocollocatorProtocol- 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, itsinitialize()method will be called again as part of the subsequent invocation only if the DeviceSystem in question returns a set of flags from itsgetFeatures()method which contains the constant/flagFEATURE_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 ExceptionInvoked byinitialize()to perform the very logic of the initialization of this DeviceSystem. This instance has been prepared for initialization by an earlier call topreInitialize()and the initialization will be completed with a subsequent call topostInitialize().- 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 ExceptionInitializes 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 ExceptionInvoked as part of the execution ofinitialize()after the execution ofdoInitialize()regardless of whether the latter completed successfully. The implementation of DeviceSystem fires a new PropertyChangeEvent to notify that the value of the propertyPROP_DEVICESof 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 ExceptionInvoked as part of the execution ofinitialize()before the execution ofdoInitialize(). The implementation of DeviceSystem removes from FMJ's CaptureDeviceManager the CaptureDeviceInfos whose MediaLocator has the same protocol asgetLocatorProtocol()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.
-
-