Class MediaContainerDetection
- java.lang.Object
-
- com.sedmelluq.discord.lavaplayer.container.MediaContainerDetection
-
public class MediaContainerDetection extends java.lang.ObjectDetects the container used by a file and whether the specific file is supported for playback.
-
-
Field Summary
Fields Modifier and Type Field Description static intSTREAM_SCAN_DISTANCEstatic java.lang.StringUNKNOWN_ARTISTstatic java.lang.StringUNKNOWN_TITLE
-
Constructor Summary
Constructors Constructor Description MediaContainerDetection(MediaContainerRegistry containerRegistry, AudioReference reference, SeekableInputStream inputStream, MediaContainerHints hints)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleancheckNextBytes(SeekableInputStream stream, int[] match)Checks the next bytes in the stream if they match the specified bytes.static booleancheckNextBytes(SeekableInputStream stream, int[] match, boolean rewind)Checks the next bytes in the stream if they match the specified bytes.MediaContainerDetectionResultdetectContainer()static booleanmatchNextBytesAsRegex(SeekableInputStream stream, int distance, java.util.regex.Pattern pattern, java.nio.charset.Charset charset)Check if the next bytes in the stream match the specified regex pattern.
-
-
-
Field Detail
-
UNKNOWN_TITLE
public static final java.lang.String UNKNOWN_TITLE
- See Also:
- Constant Field Values
-
UNKNOWN_ARTIST
public static final java.lang.String UNKNOWN_ARTIST
- See Also:
- Constant Field Values
-
STREAM_SCAN_DISTANCE
public static final int STREAM_SCAN_DISTANCE
- See Also:
- Constant Field Values
-
-
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 resultinputStream- Input stream of the filehints- Hints about the format (mime type, extension)
-
-
Method Detail
-
detectContainer
public MediaContainerDetectionResult detectContainer()
- Returns:
- Result of detection.
-
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 frommatch- 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 frommatch- Bytes that the next bytes from input stream should match (-1 as wildcardrewind- 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 fromdistance- Maximum number of bytes to read for matchingpattern- Pattern to match againstcharset- 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
-
-