Class 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.CaptureDevice
    Provides 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
    • Field Summary

      • Fields inherited from interface javax.media.Duration

        DURATION_UNBOUNDED, DURATION_UNKNOWN
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractPullBufferCaptureDevice()
      Initializes a new AbstractPullBufferCaptureDevice instance.
      protected AbstractPullBufferCaptureDevice​(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
      void connect()
      Opens a connection to the media source specified by the MediaLocator of this DataSource.
      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.
      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.
      void disconnect()
      Closes the connection to the media source specified by the MediaLocator of this DataSource.
      protected void doConnect()
      Opens a connection to the media source specified by the MediaLocator of this DataSource.
      protected void doDisconnect()
      Closes the connection to the media source specified by the MediaLocator of this DataSource.
      protected void doStart()
      Starts the transfer of media data from this DataSource.
      protected void doStop()
      Stops the transfer of media data from this DataSource.
      javax.media.CaptureDeviceInfo getCaptureDeviceInfo()
      Gets the CaptureDeviceInfo of this CaptureDevice which describes it.
      String getContentType()
      Gets the content type of the media represented by this instance.
      Object getControl​(String controlType)
      Gets the control of the specified type available for this instance.
      Object[] getControls()
      Implements Controls.getControls().
      javax.media.Time getDuration()
      Gets the duration of the media represented by this instance.
      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.
      javax.media.control.FormatControl[] getFormatControls()
      Gets 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.
      javax.media.protocol.PullBufferStream[] getStreams()
      Gets the PullBufferStreams through which this PullBufferDataSource gives access to its media data.
      protected Object getStreamSyncRoot()
      Gets the Object which is to synchronize the access to streams() 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.
      void setCaptureDeviceInfo​(javax.media.CaptureDeviceInfo deviceInfo)
      Sets a specific CaptureDeviceInfo on this CaptureDevice.
      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.
      void start()
      Starts the transfer of media data from this DataSource
      void stop()
      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.
      • Methods inherited from class javax.media.protocol.DataSource

        getLocator, initCheck, setLocator
    • 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 IOException
        Opens a connection to the media source specified by the MediaLocator of this DataSource.
        Specified by:
        connect in interface javax.media.protocol.CaptureDevice
        Specified by:
        connect in class javax.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 PullBufferDataSource
        formatControl - 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:
        disconnect in interface javax.media.protocol.CaptureDevice
        Specified by:
        disconnect in class javax.media.protocol.DataSource
      • doConnect

        protected void doConnect()
                          throws IOException
        Opens 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 IOException
        Starts 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 IOException
        Stops 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:
        getCaptureDeviceInfo in interface javax.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 returns ContentDescriptor.RAW.
        Specified by:
        getContentType in class javax.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:
        getControl in interface javax.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()
        Implements Controls.getControls(). Gets the controls available for this instance.
        Specified by:
        getControls in interface javax.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 returns Duration.DURATION_UNBOUNDED.
        Specified by:
        getDuration in interface javax.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 retrieved
        oldValue - 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 before connect() to get and set the capture Format of each one of the capture streams.
        Specified by:
        getFormatControls in interface javax.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 to streams() 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:
        getStreams in class javax.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 set
        oldValue - the last-known Format for the PullBufferStream at the specified streamIndex
        newValue - 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 IOException
        Starts the transfer of media data from this DataSource
        Specified by:
        start in interface javax.media.protocol.CaptureDevice
        Specified by:
        start in class javax.media.protocol.DataSource
        Throws:
        IOException - if anything goes wrong while starting the transfer of media data from this DataSource
      • stop

        public void stop()
                  throws IOException
        Stops the transfer of media data from this DataSource.
        Specified by:
        stop in interface javax.media.protocol.CaptureDevice
        Specified by:
        stop in class javax.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