Class MediaContainerDetection


  • public class MediaContainerDetection
    extends java.lang.Object
    Detects the container used by a file and whether the specific file is supported for playback.
    • Constructor Detail

      • MediaContainerDetection

        public MediaContainerDetection​(MediaContainerRegistry containerRegistry,
                                       AudioReference reference,
                                       SeekableInputStream inputStream,
                                       MediaContainerHints hints)
        Parameters:
        reference - Reference to the track with an identifier, used in the AudioTrackInfo in result
        inputStream - Input stream of the file
        hints - Hints about the format (mime type, extension)
    • Method Detail

      • checkNextBytes

        public static boolean checkNextBytes​(SeekableInputStream stream,
                                             int[] match)
                                      throws java.io.IOException
        Checks the next bytes in the stream if they match the specified bytes. The input may contain -1 as byte value as a wildcard, which means the value of this byte does not matter. The position of the stream is restored on return.
        Parameters:
        stream - Input stream to read the bytes from
        match - Bytes that the next bytes from input stream should match (-1 as wildcard
        Returns:
        True if the bytes matched
        Throws:
        java.io.IOException - On IO error
      • checkNextBytes

        public static boolean checkNextBytes​(SeekableInputStream stream,
                                             int[] match,
                                             boolean rewind)
                                      throws java.io.IOException
        Checks the next bytes in the stream if they match the specified bytes. The input may contain -1 as byte value as a wildcard, which means the value of this byte does not matter.
        Parameters:
        stream - Input stream to read the bytes from
        match - Bytes that the next bytes from input stream should match (-1 as wildcard
        rewind - If set to true, restores the original position of the stream after checking
        Returns:
        True if the bytes matched
        Throws:
        java.io.IOException - On IO error
      • matchNextBytesAsRegex

        public static boolean matchNextBytesAsRegex​(SeekableInputStream stream,
                                                    int distance,
                                                    java.util.regex.Pattern pattern,
                                                    java.nio.charset.Charset charset)
                                             throws java.io.IOException
        Check if the next bytes in the stream match the specified regex pattern.
        Parameters:
        stream - Input stream to read the bytes from
        distance - Maximum number of bytes to read for matching
        pattern - Pattern to match against
        charset - Charset to use to decode the bytes
        Returns:
        True if the next bytes in the stream are a match
        Throws:
        java.io.IOException - On read error