# Multimedia file stream block structures

This topic describes the structures in the stream block of a multimedia file. A subset of these structures is returned by mmGetFileInfo.

This topic contains the following information:

- General structure of a stream block

- Level 1: Block header structure

- Level 2: Stream header structure

- Level 3: Media format structures

- Level 4: Codec-specific structures

## General structure of a stream block

The following table shows the general structure of a stream block:

Block | Structure | Quantity | Description
blkHeader | FILE_INFO_BLOCK_HEADER | 1 | Block header, with type and size of the block.
header | FILE_INFO_STREAM_HEADER | 1 | Stream or track global information.
format | FILE_INFO_FORMAT_AUDIO or FILE_INFO_FORMAT_VIDEO | 1 | Audio or video stream format information.
codec | FILE_INFO_CODEC_AMR or union of FILE_INFO_CODEC_H263 or FILE_INFO_CODEC_MPEG4 | 0 or 1 | Codec-specific information.

## Level 1: Block header structure

Level 1 contains block header information that identifies the block as a stream block and contains the total size of the block. This information is contained in the FILE_INFO_BLOCK_HEADER structure.

#### Definition

typedef struct
{
WORD blkSize;
WORD blkType;
#define BLK_TYPE_PRESENTATION 1
#define BLK_TYPE_STREAM 2
} FILE_INFO_BLOCK_HEADER;

#### Fields

Field | Description
blkSize | Total size of the block in which this header is included, in bytes.
blkType | Identifies the block of information. BLK_STREAM identifies the block as a stream block.

## Level 2: Stream header structure

Level 2 contains header information specific to a stream, including the type of codec used by the stream. The information is contained in the FILE_INFO_STREAM_HEADER structure.

#### Definition

typedef struct
{
WORD blkSize;
WORD streamType;
#define STREAM_TYPE_UNKNWN 0
#define STREAM_TYPE_AUDIO 1
#define STREAM_TYPE_VIDEO 2
WORD codec;
#define S_CODEC_UNKNWN 0
#define S_CODEC_AMR 1
#define S_CODEC_AAC 2
#define S_CODEC_H263 3
#define S_CODEC_MPEG4 4
#define S_CODEC_AMR_WB 5
#define S_CODEC_AMR_WB_EXT 6
#define S_CODEC_H264 7
DWORD streamID;
DWORD creationTime;
DWORD duration;
DWORD rate;
WORD altGroupID;
WORD swiGroupID;
WORD selectAttributes;
#define SELECT_ATTR_LANGUAGE 0x0001
#define SELECT_ATTR_BANDWIDTH 0x0002
#define SELECT_ATTR_CODEC 0x0004
#define SELECT_ATTR_SCREENSIZE 0x0008
#define SELECT_ATTR_MAXPKTSIZE 0x0010
#define SELECT_ATTR_STREAMTYPE 0x0020
DWORD duration;
DWORD rate;
char handlerName [8];
DWORD sampleSize;
#define SAMPLE_SIZE_VARIABLE 0
DWORD sampleCount;
DWORD maxSampleSize;
DWORD byteCount;
DWORD flags;
DWORD startDelay;
} FILE_INFO_STREAM_HEADER;

#### Fields

Field | Description
blkSize | Total size of the FILE_INFO_STREAM_HEADER block, in bytes. The default value is 44.
streamType | Type of stream. Determines whether the stream block is an audio or video stream block. Valid values: STREAM_TYPE_UNKNWN - Ignore the rest of the stream block. STREAM_TYPE_AUDIO - Stream block is a video block. STREAM_TYPE_VIDEO - Stream block is an audio stream block.
codec | Type of codec. Determines whether the codec structure is an audio or video structure. Valid values: CODEC_UNKNWN - Ignore the rest of the stream block. CODEC_AMR - Codec is AMR. CODEC_H263 - Codec is H.263. CODEC_MPEG4 - Codec is MPEG-4.
streamID | Identifier of the stream or track.
creationTime | Creation date of the stream or track.
altGroupID | Reserved for future use.
swiGroupID | Reserved for future use.
selectAttributes | Reserved for future use.
duration | Play duration of the stream or track.
rate | Sampling rate for audio stream (in Hz) or frame rate for video stream (in frames per second).
handlerName | Media handler name.
sampleSize | Size of the sample. The value is 0 (zero) if the size is variable.
sampleCount | Number of samples in the stream.
maxSampleSize | Size of the largest sample in the stream. The value is 0 (zero) if the information is not available.
byteCount | Total number of bytes in the stream or track.
flags | Reserved for future use.
startdelay | Reserved for future use.

## Level 3: Media format structures

Level 3 contains the following media format structures:

- FILE_INFO_FORMAT_AUDIO

- FILE_INFO_FORMAT_VIDEO

The structure used depends on the codec specified in the stream header.

Note: When new fields are added, the blkSize field of blkHeader must reflect the new size of the block.

### FILE_INFO_FORMAT_AUDIO

Contains audio-specific stream format information. It is always present in an audio stream block, and is common to all audio codecs.

#### Definition

typedef struct
WORD blkSize;
WORD channelCount;
#define CHANNEL_COUNT_MONO 1
#define CHANNEL_COUNT_STEREO 2
#define CHANNEL_COUNT_51 6
WORD sampleSize;
WORD flags;
FILE_INFO_FORMAT_AUDIO;

#### Fields

Field | Description
blkSize | Total size of the FILE_INFO_FORMAT_AUDIO block, in bytes. The default value is 10.
channelCount | Number of audio channels: 1 = CHANNEL_COUNT_MONO 2 = CHANNEL_COUNT_STEREO 6 = CHANNEL_COUNT_51
sampleSize | Number of bits per audio sample.
flags | Reserved for future use.

### FILE_INFO_FORMAT_VIDEO

Contains video-specific stream format information. It is always present in a video stream block, and is common to all video codecs.

#### Definition

typedef struct
{
WORD blkSize;
WORD width;
WORD height;
INT16 layer;
WORD hResolution;
WORD vResolution;
DWORD flags;
} FILE_INFO_FORMAT_VIDEO;

#### Fields

Field | Description
blkSize | Total size of the FILE_INFO_FORMAT_VIDEO block, in bytes. The default value is 20.
width | Picture width, in pixels. For example, 176 for QCIF.
height | Picture height, in pixels. For example, 144 for QCIF.
layer | Front-to-back ordering. 0 is the normal view. Negative values are in front.
hResolution | Picture horizontal resolution, in pixels per inch. For example, 72.
vResolution | Picture vertical resolution in pixels per inch. For example, 72.
flags | Reserved for future use.

## Level 4: Codec-specific structures

Level 4 contains the following codec information structures:

- FILE_INFO_CODEC_AMR

- FILE_INFO_CODEC_H263

- FILE_INFO_CODEC_MPEG4

The structure used depends on the codec specified in the stream header.

### FILE_INFO_CODEC_AMR

Contains AMR codec information.

#### Definition

typedef struct
{
WORD modeSet; /* bitmap of AMR modes possibly present in stream. b0=mode 0 etc. */
#define S_AMR_MODE_475 0x0001
#define S_AMR_MODE_515 0x0002
#define S_AMR_MODE_590 0x0004
#define S_AMR_MODE_670 0x0008
#define S_AMR_MODE_740 0x0010
#define S_AMR_MODE_795 0x0020
#define S_AMR_MODE_102 0x0040
#define S_AMR_MODE_122 0x0080
#define S_AMR_MODE_SID 0x0100
#define S_AMR_MODE_NODATA 0x8000
#define S_AMR_MODE_ALL 0x81FF
BYTE modeChangePeriod;
BYTE framesPerSample;
char vendor [8];
// new fields may be added here in future release
} FILE_INFO_CODEC_AMR;

#### Fields

Field | Description
modeSet | Bitmap of AMR modes that can be present in the stream. Valid values: AMR_MODE_475 - Mode 0, 4.75 kbit/s. AMR_MODE_515 - Mode 1, 5.15 kbit/s. AMR_MODE_590 - Mode 2 - 5.90 kbit/s. AMR_MODE_670 - Mode 3, 6.70 kbit/s. AMR_MODE_740 - Mode 4, 7.40 kbit/s. AMR_MODE_795 - Mode 5, 7.95 kbit/s. AMR_MODE_102 - Mode 6, 10.2 kbit/s. AMR_MODE_122 - Mode 7, 12.2 kbit/s. AMR_MODE_SID- Mode 8, AMR SID. AMR_MODE_NODATA - No data. AMR_MODE_ALL - All modes may be present.
modeChangePeriod | A value of 0 (zero) specifies no restriction.
framesPerSample | Number of frames per sample.
vendor | Four-character string representing the codec's manufacturer.

### FILE_INFO_CODEC_H263

Contains H.263 codec information.

#### Definition

typedef struct
{
BYTE level;
BYTE profile;
DWORD avgBitrate;
DWORD maxBitrate;
char vendor [8];
// new fields may be added here in future release
} FILE_INFO_CODEC_H263;

#### Fields

Field | Description
level | H.263 standard level. Valid values are 10, 20, and 30.
profile | H.263 profile. The only valid value is 0.
avgBitrate | Reserved for future use.
maxBitrate | Reserved for future use.
vendor | Reserved for future use.

### FILE_INFO_CODEC_H264

Contains H.264 codec information.

#### Definition

typedef struct
{
WORD dcStreamType;
WORD dcSpecInfoSize;
#define MMFI_MAX_H264_DCI_SZ 1024
BYTE pDcSpecInfo[MMFI_MAX_H264_DCI_SZ];
WORD dcSpecInfoSize3gppFormat;
BYTE pDcSpecInfo3gppFormat[MMFI_MAX_H264_DCI_SZ];
BYTE level;
} FILE_INFO_CODEC_H264;

#### Fields

Field | Description
dcStreamType | streamType field of the MPEG-4 DecoderConfig descriptor.
dcSpecInfoSize | Size of decoder specific information, in bytes.
pDcSpecInfo | Points to specific information found in the MPEG-4 DecoderConfig descriptor.
dcSpecInfoSize3gppFormat | Size of decoder specific information, 3gpp format, in bytes. The 3gpp format version contains H.264 start codes.
pDcSpecInfo3gppFormat | Points to specific information found in the MPEG-4 DecoderConfig descriptor, 3gpp format.
level | H.264 level.

### FILE_INFO_CODEC_MPEG4

Contains MPEG-4 codec information.

#### Definition

typedef struct
{
WORD dcStreamType;
WORD dcBufferSize;
DWORD dcAvgBitrate;
DWORD dcMaxBitrate;
WORD dcSpecInfoSize;
#define MMFI_MAX_MPEG4_DCI_SZ 128
BYTE pDcSpecInfo[MMFI_MAX_MPEG4_DCI_SZ];
BYTE level;
} FILE_INFO_CODEC_MPEG4;

#### Fields

Field | Description
dcStreamType | streamType field of the MPEG-4 DecoderConfig descriptor.
dcBufferSize | Maximum size of sample, in bytes, as indicated in the MPEG-4 DecoderConfig descriptor. For example, minimum size of the decoder buffer.
dcAvgBitrate | Average bitrate, as indicated in the MPEG-4 DecoderConfig descriptor.
dcMaxBitrate | Maximum bitrate, as indicated in the MPEG-4 DecoderConfig descriptor.
dcSpecInfoSize | Size of decoder specific information, in bytes.
pDcSpecInfo | Points to specific information found in the MPEG-4 DecoderConfig descriptor. If present, this data is stored at the end of the current stream block.
level | MPEG-4 level.