Class AesMediaDataSource

java.lang.Object
MediaDataSource
com.mku.android.salmonfs.media.AesMediaDataSource

public class AesMediaDataSource extends MediaDataSource
Seekable source for encrypted media content.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct a seekable source for the android media player from an encrypted stream.
    Construct a seekable source for the android media player from an encrypted file.
    AesMediaDataSource(AesFile aesFile, int buffers, int bufferSize, int threads, int backOffset)
    Construct a seekable source for the android media player from an encrypted file using cached buffers and parallel processing.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close the source and all associated resources.
    long
    Get the content size.
    int
    readAt(long position, byte[] buffer, int offset, int size)
    Decrypts and reads the contents of an encrypted file
    void
    Notify when error occurs

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AesMediaDataSource

      public AesMediaDataSource(AesFile aesFile) throws Exception
      Construct a seekable source for the android media player from an encrypted file.
      Parameters:
      aesFile - AesFile that will be used as a source
      Throws:
      Exception - Thrown if error occurred
    • AesMediaDataSource

      public AesMediaDataSource(AesFile aesFile, int buffers, int bufferSize, int threads, int backOffset) throws Exception
      Construct a seekable source for the android media player from an encrypted file using cached buffers and parallel processing.
      Parameters:
      aesFile - AesFile that will be used as a source
      buffers - The buffers
      bufferSize - Buffer size
      threads - Threads for parallel processing
      backOffset - The backwards offset to use when reading buffers
      Throws:
      Exception - Thrown if error occurred
    • AesMediaDataSource

      public AesMediaDataSource(AesStream aesStream) throws Exception
      Construct a seekable source for the android media player from an encrypted stream.
      Parameters:
      aesStream - AesStream that will be used as a source
      Throws:
      Exception - Thrown if error occurred
  • Method Details

    • setOnError

      public void setOnError(Consumer<String> onError)
      Notify when error occurs
      Parameters:
      onError - The callback
    • readAt

      public int readAt(long position, byte[] buffer, int offset, int size) throws IOException
      Decrypts and reads the contents of an encrypted file
      Parameters:
      position - The source file position the read will start from
      buffer - The buffer that will store the decrypted contents
      offset - The position on the buffer that the decrypted data will start
      size - The length of the data requested
      Throws:
      IOException
    • getSize

      public long getSize()
      Get the content size.
      Returns:
      The size
    • close

      public void close() throws IOException
      Close the source and all associated resources.
      Throws:
      IOException - Thrown if error during IO