Class AbstractPushBufferCaptureDevice
- java.lang.Object
-
- javax.media.protocol.DataSource
-
- javax.media.protocol.PushBufferDataSource
-
- org.jitsi.impl.neomedia.jmfext.media.protocol.AbstractPushBufferCaptureDevice
-
- All Implemented Interfaces:
javax.media.Controls,javax.media.Duration,javax.media.protocol.CaptureDevice,javax.media.protocol.Controls
- Direct Known Subclasses:
AbstractVideoPushBufferCaptureDevice,DataSource,DataSource,FakePushBufferDataSource
public abstract class AbstractPushBufferCaptureDevice extends javax.media.protocol.PushBufferDataSource implements javax.media.protocol.CaptureDeviceProvides a base implementation of PushBufferDataSource and CaptureDevice in order to facilitate implementers by taking care of boilerplate in the most common cases.- Author:
- Lyubomir Marinov
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractPushBufferCaptureDevice()Initializes a new AbstractPushBufferCaptureDevice instance.protectedAbstractPushBufferCaptureDevice(javax.media.MediaLocator locator)Initializes a new AbstractPushBufferCaptureDevice instance from a specific MediaLocator.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidconnect()Opens a connection to the media source specified by the MediaLocator of this DataSource.protected javax.media.control.FrameRateControlcreateFrameRateControl()Creates a new FrameRateControl instance which is to allow the getting and setting of the frame rate of this AbstractPushBufferCaptureDevice.protected abstract AbstractPushBufferStream<?>createStream(int streamIndex, javax.media.control.FormatControl formatControl)Create a new PushBufferStream which is to be at a specific zero-based index in the list of streams of this PushBufferDataSource.voiddisconnect()Closes the connection to the media source specified by the MediaLocator of this DataSource.protected voiddoConnect()Opens a connection to the media source specified by the MediaLocator of this DataSource.protected voiddoDisconnect()Closes the connection to the media source specified by the MediaLocator of this DataSource.protected voiddoStart()Starts the transfer of media data from this DataSource.protected voiddoStop()Stops the transfer of media data from this DataSource.javax.media.CaptureDeviceInfogetCaptureDeviceInfo()Gets the CaptureDeviceInfo of this CaptureDevice which describes it.StringgetContentType()Gets the content type of the media represented by this instance.ObjectgetControl(String controlType)Gets the control of the specified type available for this instance.Object[]getControls()ImplementsControls.getControls().javax.media.TimegetDuration()Gets the duration of the media represented by this instance.protected javax.media.FormatgetFormat(int streamIndex, javax.media.Format oldValue)Gets the Format to be reported by the FormatControl of a PushBufferStream at a specific zero-based index in the list of streams of this PushBufferDataSource.javax.media.control.FormatControl[]getFormatControls()Gets an array of FormatControl instances each one of which can be used beforeconnect()to get and set the capture Format of each one of the capture streams.javax.media.protocol.PushBufferStream[]getStreams()Gets the PushBufferStreams through which this PushBufferDataSource gives access to its media data.protected ObjectgetStreamSyncRoot()Gets the Object which is to synchronize the access tostreams()and its return value.protected javax.media.Format[]getSupportedFormats(int streamIndex)Gets the Formats which are to be reported by a FormatControl as supported formats for a PushBufferStream at a specific zero-based index in the list of streams of this PushBufferDataSource.protected javax.media.FormatsetFormat(int streamIndex, javax.media.Format oldValue, javax.media.Format newValue)Attempts to set the Format to be reported by the FormatControl of a PushBufferStream at a specific zero-based index in the list of streams of this PushBufferDataSource.voidstart()Starts the transfer of media data from this DataSource.voidstop()Stops the transfer of media data from this DataSource.protected org.jitsi.impl.neomedia.jmfext.media.protocol.AbstractBufferStream<?>[]streams()Gets the internal array of AbstractPushBufferStreams through which this AbstractPushBufferCaptureDevice gives access to its media data.
-
-
-
Constructor Detail
-
AbstractPushBufferCaptureDevice
protected AbstractPushBufferCaptureDevice()
Initializes a new AbstractPushBufferCaptureDevice instance.
-
AbstractPushBufferCaptureDevice
protected AbstractPushBufferCaptureDevice(javax.media.MediaLocator locator)
Initializes a new AbstractPushBufferCaptureDevice instance from a specific MediaLocator.- Parameters:
locator- the MediaLocator to create the new instance from
-
-
Method Detail
-
connect
public void connect() throws IOExceptionOpens a connection to the media source specified by the MediaLocator of this DataSource.- Specified by:
connectin interfacejavax.media.protocol.CaptureDevice- Specified by:
connectin classjavax.media.protocol.DataSource- Throws:
IOException- if anything goes wrong while opening the connection to the media source specified by the MediaLocator of this DataSource
-
createFrameRateControl
protected javax.media.control.FrameRateControl createFrameRateControl()
Creates a new FrameRateControl instance which is to allow the getting and setting of the frame rate of this AbstractPushBufferCaptureDevice.- Returns:
- a new FrameRateControl instance which is to allow the getting and setting of the frame rate of this AbstractPushBufferCaptureDevice
-
createStream
protected abstract AbstractPushBufferStream<?> createStream(int streamIndex, javax.media.control.FormatControl formatControl)
Create a new PushBufferStream which is to be at a specific zero-based index in the list of streams of this PushBufferDataSource. The Format-related information of the new instance is to be abstracted by a specific FormatControl.- Parameters:
streamIndex- the zero-based index of the PushBufferStream in the list of streams of this PushBufferDataSourceformatControl- the FormatControl which is to abstract the Format-related information of the new instance- Returns:
- a new PushBufferStream which is to be at the specified streamIndex in the list of streams of this PushBufferDataSource and which has its Format-related information abstracted by the specified formatControl
-
disconnect
public void disconnect()
Closes the connection to the media source specified by the MediaLocator of this DataSource. If such a connection has not been opened, the call is ignored.- Specified by:
disconnectin interfacejavax.media.protocol.CaptureDevice- Specified by:
disconnectin classjavax.media.protocol.DataSource
-
doConnect
protected void doConnect() throws IOExceptionOpens a connection to the media source specified by the MediaLocator of this DataSource. Allows extenders to override and be sure that there will be no request to open a connection if the connection has already been opened.- Throws:
IOException- if anything goes wrong while opening the connection to the media source specified by the MediaLocator of this DataSource
-
doDisconnect
protected void doDisconnect()
Closes the connection to the media source specified by the MediaLocator of this DataSource. Allows extenders to override and be sure that there will be no request to close a connection if the connection has not been opened yet.
-
doStart
protected void doStart() throws IOExceptionStarts the transfer of media data from this DataSource. Allows extenders to override and be sure that there will be no request to start the transfer of media data if it has already been started.- Throws:
IOException- if anything goes wrong while starting the transfer of media data from this DataSource
-
doStop
protected void doStop() throws IOExceptionStops the transfer of media data from this DataSource. Allows extenders to override and be sure that there will be no request to stop the transfer of media data if it has not been started yet.- Throws:
IOException- if anything goes wrong while stopping the transfer of media data from this DataSource
-
getCaptureDeviceInfo
public javax.media.CaptureDeviceInfo getCaptureDeviceInfo()
Gets the CaptureDeviceInfo of this CaptureDevice which describes it.- Specified by:
getCaptureDeviceInfoin interfacejavax.media.protocol.CaptureDevice- Returns:
- the CaptureDeviceInfo of this CaptureDevice which describes it
-
getContentType
public String getContentType()
Gets the content type of the media represented by this instance. The AbstractPushBufferCaptureDevice implementation always returnsContentDescriptor.RAW.- Specified by:
getContentTypein classjavax.media.protocol.DataSource- Returns:
- the content type of the media represented by this instance
-
getControl
public Object getControl(String controlType)
Gets the control of the specified type available for this instance.- Specified by:
getControlin interfacejavax.media.Controls- Parameters:
controlType- the type of the control available for this instance to be retrieved- Returns:
- an Object which represents the control of the specified type available for this instance if such a control is indeed available; otherwise, null
-
getControls
public Object[] getControls()
ImplementsControls.getControls(). Gets the controls available for this instance.- Specified by:
getControlsin interfacejavax.media.Controls- Returns:
- an array of Objects which represent the controls available for this instance
-
getDuration
public javax.media.Time getDuration()
Gets the duration of the media represented by this instance. The AbstractPushBufferCaptureDevice always returnsDuration.DURATION_UNBOUNDED.- Specified by:
getDurationin interfacejavax.media.Duration- Returns:
- the duration of the media represented by this instance
-
getFormat
protected javax.media.Format getFormat(int streamIndex, javax.media.Format oldValue)Gets the Format to be reported by the FormatControl of a PushBufferStream at a specific zero-based index in the list of streams of this PushBufferDataSource. The PushBufferStream may not exist at the time of requesting its Format. Allows extenders to override the default behavior which is to report any last-known format or the first Format from the list of supported formats as defined in the JMF registration of this CaptureDevice.- Parameters:
streamIndex- the zero-based index of the PushBufferStream the Format of which is to be retrievedoldValue- the last-known Format for the PushBufferStream at the specified streamIndex- Returns:
- the Format to be reported by the FormatControl of the PushBufferStream at the specified streamIndex in the list of streams of this PushBufferDataSource.
-
getFormatControls
public javax.media.control.FormatControl[] getFormatControls()
Gets an array of FormatControl instances each one of which can be used beforeconnect()to get and set the capture Format of each one of the capture streams.- Specified by:
getFormatControlsin interfacejavax.media.protocol.CaptureDevice- Returns:
- an array of FormatControl instances each one of which
can be used before
connect()to get and set the capture Format of each one of the capture streams
-
getStreamSyncRoot
protected Object getStreamSyncRoot()
Gets the Object which is to synchronize the access tostreams()and its return value.- Returns:
- the Object which is to synchronize the access to
streams()and its return value
-
getStreams
public javax.media.protocol.PushBufferStream[] getStreams()
Gets the PushBufferStreams through which this PushBufferDataSource gives access to its media data.- Specified by:
getStreamsin classjavax.media.protocol.PushBufferDataSource- Returns:
- an array of the PushBufferStreams through which this PushBufferDataSource gives access to its media data
-
getSupportedFormats
protected javax.media.Format[] getSupportedFormats(int streamIndex)
Gets the Formats which are to be reported by a FormatControl as supported formats for a PushBufferStream at a specific zero-based index in the list of streams of this PushBufferDataSource.- Parameters:
streamIndex- the zero-based index of the PushBufferStream for which the specified FormatControl is to report the list of supported Formats- Returns:
- an array of Formats to be reported by a FormatControl as the supported formats for the PushBufferStream at the specified streamIndex in the list of streams of this PushBufferDataSource
-
setFormat
protected javax.media.Format setFormat(int streamIndex, javax.media.Format oldValue, javax.media.Format newValue)Attempts to set the Format to be reported by the FormatControl of a PushBufferStream at a specific zero-based index in the list of streams of this PushBufferDataSource. The PushBufferStream does not exist at the time of the attempt to set its Format. Allows extenders to override the default behavior which is to not attempt to set the specified Format so that they can enable setting the Format prior to creating the PushBufferStream. If setting the Format of an existing PushBufferStream is desired, AbstractPushBufferStream#doSetFormat(Format) should be overridden instead.- Parameters:
streamIndex- the zero-based index of the PushBufferStream the Format of which is to be setoldValue- the last-known Format for the PushBufferStream at the specified streamIndexnewValue- the Format which is to be set- Returns:
- the Format to be reported by the FormatControl of the PushBufferStream at the specified streamIndex in the list of streams of this PushBufferStream or null if the attempt to set the Format did not success and any last-known Format is to be left in effect
-
start
public void start() throws IOExceptionStarts the transfer of media data from this DataSource.- Specified by:
startin interfacejavax.media.protocol.CaptureDevice- Specified by:
startin classjavax.media.protocol.DataSource- Throws:
IOException- if anything goes wrong while starting the transfer of media data from this DataSource
-
stop
public void stop() throws IOExceptionStops the transfer of media data from this DataSource.- Specified by:
stopin interfacejavax.media.protocol.CaptureDevice- Specified by:
stopin classjavax.media.protocol.DataSource- Throws:
IOException- if anything goes wrong while stopping the transfer of media data from this DataSource
-
streams
protected org.jitsi.impl.neomedia.jmfext.media.protocol.AbstractBufferStream<?>[] streams()
Gets the internal array of AbstractPushBufferStreams through which this AbstractPushBufferCaptureDevice gives access to its media data.- Returns:
- the internal array of AbstractPushBufferStreams through which this AbstractPushBufferCaptureDevice gives access to its media data
-
-