Class AbstractPullBufferCaptureDevice
- java.lang.Object
-
- javax.media.protocol.DataSource
-
- javax.media.protocol.PullBufferDataSource
-
- org.jitsi.impl.neomedia.jmfext.media.protocol.AbstractPullBufferCaptureDevice
-
- All Implemented Interfaces:
javax.media.Controls,javax.media.Duration,javax.media.protocol.CaptureDevice,javax.media.protocol.Controls
- Direct Known Subclasses:
AbstractVideoPullBufferCaptureDevice,DataSource,DataSource,DataSource
public abstract class AbstractPullBufferCaptureDevice extends javax.media.protocol.PullBufferDataSource implements javax.media.protocol.CaptureDeviceProvides a base implementation of PullBufferDataSource 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 protectedAbstractPullBufferCaptureDevice()Initializes a new AbstractPullBufferCaptureDevice instance.protectedAbstractPullBufferCaptureDevice(javax.media.MediaLocator locator)Initializes a new AbstractPullBufferCaptureDevice 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 AbstractPullBufferCaptureDevice.protected abstract AbstractPullBufferStream<?>createStream(int streamIndex, javax.media.control.FormatControl formatControl)Creates a new PullBufferStream which is to be at a specific zero-based index in the list of streams of this PullBufferDataSource.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 PullBufferStream at a specific zero-based index in the list of streams of this PullBufferDataSource.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.PullBufferStream[]getStreams()Gets the PullBufferStreams through which this PullBufferDataSource 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 PullBufferStream at a specific zero-based index in the list of streams of this PullBufferDataSource.voidsetCaptureDeviceInfo(javax.media.CaptureDeviceInfo deviceInfo)Sets a specific CaptureDeviceInfo on this CaptureDevice.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 PullBufferStream at a specific zero-based index in the list of streams of this PullBufferDataSource.voidstart()Starts the transfer of media data from this DataSourcevoidstop()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
-
AbstractPullBufferCaptureDevice
protected AbstractPullBufferCaptureDevice()
Initializes a new AbstractPullBufferCaptureDevice instance.
-
AbstractPullBufferCaptureDevice
protected AbstractPullBufferCaptureDevice(javax.media.MediaLocator locator)
Initializes a new AbstractPullBufferCaptureDevice 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 AbstractPullBufferCaptureDevice.- Returns:
- a new FrameRateControl instance which is to allow the getting and setting of the frame rate of this AbstractPullBufferCaptureDevice
-
createStream
protected abstract AbstractPullBufferStream<?> createStream(int streamIndex, javax.media.control.FormatControl formatControl)
Creates a new PullBufferStream which is to be at a specific zero-based index in the list of streams of this PullBufferDataSource. The Format-related information of the new instance is to be abstracted by a specific FormatControl.- Parameters:
streamIndex- the zero-based index of the PullBufferStream in the list of streams of this PullBufferDataSourceformatControl- the FormatControl which is to abstract the Format-related information of the new instance- Returns:
- a new PullBufferStream which is to be at the specified streamIndex in the list of streams of this PullBufferDataSource 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 AbstractPullBufferCaptureDevice 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 AbstractPullBufferCaptureDevice 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 PullBufferStream at a specific zero-based index in the list of streams of this PullBufferDataSource. The PullBufferStream 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 PullBufferStream the Format of which is to be retrievedoldValue- the last-known Format for the PullBufferStream at the specified streamIndex- Returns:
- the Format to be reported by the FormatControl of the PullBufferStream at the specified streamIndex in the list of streams of this PullBufferDataSource.
-
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.PullBufferStream[] getStreams()
Gets the PullBufferStreams through which this PullBufferDataSource gives access to its media data.- Specified by:
getStreamsin classjavax.media.protocol.PullBufferDataSource- Returns:
- an array of the PullBufferStreams through which this PullBufferDataSource 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 PullBufferStream at a specific zero-based index in the list of streams of this PullBufferDataSource.- Parameters:
streamIndex- the zero-based index of the PullBufferStream 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 PullBufferStream at the specified streamIndex in the list of streams of this PullBufferDataSource
-
setCaptureDeviceInfo
public void setCaptureDeviceInfo(javax.media.CaptureDeviceInfo deviceInfo)
Sets a specific CaptureDeviceInfo on this CaptureDevice.- Parameters:
deviceInfo- the CaptureDeviceInfo on this CaptureDevice
-
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 PullBufferStream at a specific zero-based index in the list of streams of this PullBufferDataSource. The PullBufferStream 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 PullBufferStream. If setting the Format of an existing PullBufferStream is desired, AbstractPullBufferStream#doSetFormat(Format) should be overridden instead.- Parameters:
streamIndex- the zero-based index of the PullBufferStream the Format of which is to be setoldValue- the last-known Format for the PullBufferStream at the specified streamIndexnewValue- the Format which is to be set- Returns:
- the Format to be reported by the FormatControl of the PullBufferStream at the specified streamIndex in the list of streams of this PullBufferStream 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
-
-