Interface IURLProtocolHandler

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int close()
      A request to close() from FFMPEG
      boolean isStreamed​(java.lang.String url, int flags)
      Special callback made by AVPKit in order to determine if your stream supports streaming.
      int open​(java.lang.String url, int flags)
      This method gets called by FFMPEG when it opens a file.
      int read​(byte[] buf, int size)
      This method gets called by FFMPEG when it tries to read data.
      long seek​(long offset, int whence)
      A request from FFMPEG to seek to a position in the stream.
      int write​(byte[] buf, int size)
      This method gets called by FFMPEG when it tries to write data.
    • Method Detail

      • open

        int open​(java.lang.String url,
                 int flags)
        This method gets called by FFMPEG when it opens a file.
        Parameters:
        url - The URL to open
        flags - The flags (e.g. URL_RDONLY_MODE)
        Returns:
        >= 0 for success; -1 for error.
      • read

        int read​(byte[] buf,
                 int size)
        This method gets called by FFMPEG when it tries to read data.

        For non-blocking IO, return: IError.typeToErrorNumber(com.avpkit.core.IError.Type) pass in IError.Type.ERROR_AGAIN for the error type. This returns the platform specific number for EAGAIN on your platform signaling that callers should try again later.

        Alternately implementors may block until data is returning, but they should then respect the Thread.isInterrupted() setting.

        Parameters:
        buf - The buffer to write your data to.
        size - The number of bytes in buf data available for you to write the data that FFMPEG will read.
        Returns:
        0 for end of file, else number of bytes you wrote to the buffer, or -1 if error.
      • write

        int write​(byte[] buf,
                  int size)
        This method gets called by FFMPEG when it tries to write data.

        For non-blocking IO, return: IError.typeToErrorNumber(com.avpkit.core.IError.Type) pass in IError.Type.ERROR_AGAIN for the error type. This returns the platform specific number for EAGAIN on your platform signaling that callers should try again later.

        Alternately implementators may block until data is returning, but they should then respect the Thread.isInterrupted() setting.

        Parameters:
        buf - The data you should write.
        size - The number of bytes in buf.
        Returns:
        0 for end of file, else number of bytes you read from buf, or -1 if error.
      • seek

        long seek​(long offset,
                  int whence)
        A request from FFMPEG to seek to a position in the stream.
        Parameters:
        offset - The offset in bytes.
        whence - Where that offset is relative to. Follow the C stdlib fseek() conventions EXCEPT SEEK_SIZE should return back the size of the stream in bytes if known without adjusting the seek pointer.
        Returns:
        -1 if not supported, else the position relative to whence
      • close

        int close()
        A request to close() from FFMPEG
        Returns:
        -1 on error; else >= 0
      • isStreamed

        boolean isStreamed​(java.lang.String url,
                           int flags)
        Special callback made by AVPKit in order to determine if your stream supports streaming.

        If this method returns true, AVPKit will assume it cannot seek backwards in this container.

        This has one main practical consequence. When writing it means certain container formats (e.g. the MOV container) will not be usable as it requires seeking back to the start of a file to write MOV required header information once the entire file has been encoded.

        But if your medium is streaming, you'll want to return true for this, and then FFMPEG will not attempt to seek back in time.

        Parameters:
        url - The URL that would be passed to open(String, int)
        flags - The flags that would be passed to open(String, int)
        Returns:
        true if you can stream that URL; false if not.