.underline { text-decoration: none; font-weight: bold; color: #4040f0;}
.domain { margin-left: 6em; }
.key-name { font-family: monospace; color: blue; }
.typename { color: green; font-weight: bold;}
.info { color: #425ad5; }
#packets { margin-top: 2em; }
body { font-size: 10pt; }
p { margin-left: 3em; margin-right: 2em;}
ul { margin-left: 3em; }
li { margin-top: 1.5em; margin-right: 2em; }
tt { color: red; }
BMPx Media Cache Format Documentation
The media library used by BMPx is a binary metadata cache, binary here means it's not a human readable format like XML or CSV or plain text; this choice was made mostly because of speed concerns.
File Format
- The beginning of the file must contain the string 'MC' (in uppercase ASCII, non-null terminated) followed by the uint16_t value '666'; in other words the first 4 bytes of a BMPx media cache file are 0x4D 0x43 0x9A 0x02. This is the 'file magic' for BMPx media cache files, and only those containing this file magic at the start of the file are recognized as BMP media cache files by BMP.
Following can be any of the following packets. Each packet type is identified by a uint8_t value, following the individual packet data as described below.
Packet Types
- 0x01
Library Name
This packet holds the individual libary's name. This packet is optional.
The next value is a uint8_t size of the following, non-null terminated string which is the library name.
It should be obvious but just to make it totally clear, using a uint8_t size for the string length limits the name to a
maximal length of 255 characters.
- 0x02
Media File
This packet type holds the information about a particular file. It is divided into sub-packets which are identified by a uint8_t value. They are described in the following list:
- 0x01
Database File ID
Following is a uint16_t value with the database's unique file id (UFID) for this file. It must not change for every individual file between reads and (re)-writes of the cache file.
- 0x02
File URI
Following is a uint16_t value with the length of the file's URI string, and directly after that the string itself. Currently only 'file://' URIs are supported.
- 0x03
Metadata Value
Following is a uint8_t identifier which specifies which particular metadatum is following. The enumeration is this (it is identical to the enumeration in src/bmp_metadata.h):
0x00 TITLE
0x01 TIME
0x02 TRACK
0x03 RATING
0x04 ARTIST
0x05 ALBUM
0x06 DATE
0x07 GENRE
0x08 COMMENT
0x09 BITRATE
Currently all values are being saved as strings. Hence the next following field is a uint16_t value holding the length of the actual contents of the individual metadatum, after that the (non-null terminated) string holding the data itself.
Even though the point of the media cache is to cache metadata, holding metadata is optional for a file record in the BMPx media cache file; it is possible for a file record to not hold any Metadata Value packet at all. Possible reasons are for example that the file simply doesn't hold any metadata; it is up to the application to make something out of that, e.g. use the filename for display instead of metadata.
- 0x04
End of Media File
No data follows, it signalises the end of the Media File packet.
0x03
EMC (End of Media Cache)
This packet signalizes the end of the cache file. No other data follows, it is a signal to the application to stop reading the metadata cache.