Class MediaInfoAccessor

java.lang.Object
com.amilesend.mediainfo.lib.MediaInfoAccessor
All Implemented Interfaces:
AutoCloseable

public class MediaInfoAccessor extends Object implements AutoCloseable
The object used by java applications to interact with the libMediaInfo library.
  • Constructor Summary

    Constructors
    Constructor
    Description
    MediaInfoAccessor(@NonNull MediaInfoLibrary mediaInfoLibrary)
    Creates a new MediaInfo object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the library instance.
    void
    Closes a file handle that was previously opened.
    void
    Disposes of the library instance reference.
    get(@NonNull StreamType streamType, int streamNumber, int parameterIndex, @NonNull InfoType infoType)
    Get a piece of information about a file (parameter is an integer that represents the parameter index).
    get(@NonNull StreamType streamType, int streamNumber, String parameter, @NonNull InfoType infoType, @NonNull InfoType searchType)
    Get a piece of information about a file (parameter is a string).
    get(StreamType streamType, int streamNumber, int parameterIndex)
    Get a piece of information about a file (parameter is an integer that represents the parameter index).
    get(StreamType streamType, int streamNumber, String parameter)
    Get a piece of information about a file (parameter is a string).
    get(StreamType streamType, int streamNumber, String parameter, InfoType infoType)
    Get a piece of information about a file (parameter is a string).
    getOption(String option)
    Gets information about MediaInfo.
    int
    getStreamCount(@NonNull StreamType streamType)
    Gets the number of streams for the given stream type.
    int
    getStreamOrParameterCount(@NonNull StreamType streamType, int streamNumber)
    Gets the number of streams for the given stream type or the total count of information parameters for a stream.
    Get all details about a file.
    boolean
    open(String fileName)
    Opens a file to parse.
    int
    openBufferContinue(@NonNull byte[] buffer, int size)
    Reads from a memory buffer to parse media information and tags.
    long
    Tests if there is request to seek to another position in the stream.
    int
    Closes the buffer upon read completion.
    boolean
    openBufferInit(long length, long offset)
    Prepares a memory buffer for reading and parsing media information from a stream.
    setOption(String option, @NonNull String value)
    Configures information about MediaInfo.

    Methods inherited from class java.lang.Object

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

    • MediaInfoAccessor

      public MediaInfoAccessor(@NonNull MediaInfoLibrary mediaInfoLibrary)
      Creates a new MediaInfo object.
      Parameters:
      mediaInfoLibrary - the library instance
      See Also:
  • Method Details

    • close

      public void close()
      Closes the library instance.
      Specified by:
      close in interface AutoCloseable
    • dispose

      public void dispose()
      Disposes of the library instance reference.
    • open

      public boolean open(String fileName)
      Opens a file to parse.
      Parameters:
      fileName - the full path and filename to open
      Returns:
      true if file was opened; else, false
    • openBufferInit

      public boolean openBufferInit(long length, long offset)
      Prepares a memory buffer for reading and parsing media information from a stream.
      Parameters:
      length - the length of the buffer
      offset - the byte offset to start reading from
      Returns:
      true if the buffer was successfully initialized; else, false
    • openBufferContinue

      public int openBufferContinue(@NonNull byte[] buffer, int size)
      Reads from a memory buffer to parse media information and tags.
      Parameters:
      buffer - the buffer reference
      size - the amount of data to read
      Returns:
      a bitfield with the following bits:
      • 0 - Accepted (format is known)
      • 1 - Filled (data collected)
      • 2 - Buffer updated (further data required)
      • 3 - Buffer finalized (no further data required)
      • 4-15 - Reserved
      • 16-31 - User defined
    • openBufferContinueGotoGet

      public long openBufferContinueGotoGet()
      Tests if there is request to seek to another position in the stream.
      Returns:
      -1 if there is no more data to seek to; else, the seek position
    • openBufferFinalize

      public int openBufferFinalize()
      Closes the buffer upon read completion.
      Returns:
      0 if the buffer has been read or null; else non-0 value if an error occurred.
    • closeHandle

      public void closeHandle()
      Closes a file handle that was previously opened.
    • inform

      public String inform()
      Get all details about a file.
      Returns:
      All details about a file in one string
    • get

      public String get(StreamType streamType, int streamNumber, String parameter)
      Get a piece of information about a file (parameter is a string).
      Parameters:
      streamType - the stream type
      streamNumber - the stream number
      parameter - the parameter you are looking for in the stream (e.g., resolution, codec, bitrate, etc.)
      Returns:
      the query result, or empty if there is a problem or not found
      See Also:
    • get

      public String get(StreamType streamType, int streamNumber, String parameter, InfoType infoType)
      Get a piece of information about a file (parameter is a string).
      Parameters:
      streamType - the stream type
      streamNumber - the stream number
      parameter - the parameter you are looking for in the stream (e.g., resolution, codec, bitrate, etc.)
      infoType - the type of information about the parameter
      See Also:
    • get

      public String get(@NonNull StreamType streamType, int streamNumber, String parameter, @NonNull InfoType infoType, @NonNull InfoType searchType)
      Get a piece of information about a file (parameter is a string). For a list of available parameters, please refer to General.csv.
      Parameters:
      streamType - the stream type
      streamNumber - the stream number
      parameter - the parameter you are looking for in the stream (e.g., resolution, codec, bitrate, etc.)
      infoType - the type of information about the parameter
      searchType - describes where to look for the parameter
      Returns:
      the queries information; or an empty string if there was a problem
    • get

      public String get(StreamType streamType, int streamNumber, int parameterIndex)
      Get a piece of information about a file (parameter is an integer that represents the parameter index).
      Parameters:
      streamType - the stream type
      streamNumber - the stream number
      parameterIndex - the parameter index that you are looking for in the stream
      Returns:
      a string about information you search, an empty string if there is a problem
    • get

      public String get(@NonNull StreamType streamType, int streamNumber, int parameterIndex, @NonNull InfoType infoType)
      Get a piece of information about a file (parameter is an integer that represents the parameter index).
      Parameters:
      streamType - the stream type
      streamNumber - the stream number
      parameterIndex - the parameter index that you are looking for in the stream
      infoType - the type of information you want about the parameter (the text, the measure, the help...)
      Returns:
      the information or an empty string if there is a problem
    • getStreamCount

      public int getStreamCount(@NonNull StreamType streamType)
      Gets the number of streams for the given stream type.
      Parameters:
      streamType - the stream type
      Returns:
      number of streams of the given stream type
    • getStreamOrParameterCount

      public int getStreamOrParameterCount(@NonNull StreamType streamType, int streamNumber)
      Gets the number of streams for the given stream type or the total count of information parameters for a stream.
      Parameters:
      streamType - the stream type
      streamNumber - the stream number
      Returns:
      number of streams of the given stream type
    • getOption

      public String getOption(String option)
      Gets information about MediaInfo.
      Parameters:
      option - The name of option
      Returns:
      the option value
    • setOption

      public String setOption(String option, @NonNull String value)
      Configures information about MediaInfo.
      Parameters:
      option - The name of option
      value - The value of option
      Returns:
      "" means no; else, any other value means yes