Class MultiFileDataSourceImpl

  • All Implemented Interfaces:
    Closeable, AutoCloseable, DataSource

    public class MultiFileDataSourceImpl
    extends Object
    implements DataSource
    A rather naive DataSource implementation allowing multiple files as source. Not as performant and memory efficient as a normal FileDataSourceImpl but helpful if video packets are dumped packet by packet to disk.
    • Method Detail

      • read

        public int read​(ByteBuffer byteBuffer)
                 throws IOException
        Description copied from interface: DataSource
        Reads a sequence of bytes from this channel into the given buffer. Bytes are read starting at this channel's current position, and then the file position is updated with the number of bytes actually read.
        Specified by:
        read in interface DataSource
        Parameters:
        byteBuffer - sink for this read operation
        Returns:
        number of bytes actually read
        Throws:
        IOException - If some I/O error occurs
      • size

        public long size()
                  throws IOException
        Description copied from interface: DataSource
        Returns the current size of this DataSource.
        Specified by:
        size in interface DataSource
        Returns:
        The current size of this DataSource, measured in bytes
        Throws:
        IOException - If some I/O error occurs
      • position

        public long position()
                      throws IOException
        Description copied from interface: DataSource
        Returns the DataSource's current position.
        Specified by:
        position in interface DataSource
        Returns:
        This DataSource's file position, a non-negative integer counting the number of bytes from the beginning of the data to the current position
        Throws:
        IOException - If some I/O error occurs
      • position

        public void position​(long nuPos)
                      throws IOException
        Description copied from interface: DataSource
        Sets the DataSource's position.
        Specified by:
        position in interface DataSource
        Parameters:
        nuPos - The new position, a non-negative integer counting the number of bytes from the beginning of the data
        Throws:
        IOException - If some I/O error occurs
      • transferTo

        public long transferTo​(long startPosition,
                               long count,
                               WritableByteChannel sink)
                        throws IOException
        Description copied from interface: DataSource
        Transfers bytes from this DataSource to the given writable byte channel.
        An attempt should be made to read up to count bytes starting at the given position in this DataSource and write them to the target channel. An invocation of this method may or may not transfer all of the requested bytes;
        Specified by:
        transferTo in interface DataSource
        Parameters:
        startPosition - The position within the DataSource at which the transfer is to begin; must be non-negative
        count - The maximum number of bytes to be transferred; must be non-negative
        sink - The target channel
        Returns:
        the actual number of bytes written
        Throws:
        IOException - If some I/O error occurs
      • map

        public ByteBuffer map​(long startPosition,
                              long size)
                       throws IOException
        Description copied from interface: DataSource
        Maps a part of this DataSource into a ByteBuffer. It might utilize an operating system supported memory mapped file or potentially just reads the requested portion of the file into the memory.
        Specified by:
        map in interface DataSource
        Parameters:
        startPosition - where the requested block start
        size - size of the requested block
        Returns:
        the requested portion of the DataSource
        Throws:
        IOException - If some I/O error occurs