RealMedia File Format (RMFF)

来源:互联网 发布:淘宝论文查重靠谱吗 编辑:程序博客网 时间:2024/05/14 13:49

RealMedia File Format (RMFF)

RealSystem Architecture introduces RealMedia FileFormat (RMFF), which lets RealSystem deliver high-quality multimediacontent over a variety of network bandwidths. Third-party developerscan convert their media formats into RMFF, enabling RealServer todeliver the files to RealPlayer or other applications built with theRealSystem SDK. Third-party developers can thereby use RealSystem totransport content over the Internet to their own applications.

RealMedia File Format is a standard tagged fileformat that uses four-character codes to identify file elements. Thesecodes are 32-bit, represented by a sequence of one to four ASCIIalphanumeric characters, padded on the right with space characters. Thedata type for four-character codes is FOURCC. Use the PN_FOURCC macro to convert four characters into a four-character code.

The basic building block of a RealMedia File is a chunk, which is a logical unit of data, such as a stream header or a packet of data. Each chunk contains the following fields:

  • four-character code specifying the chunk identifier
  • 32-bit value specifying the size of the data member in the chunk
  • blob of opaque chunk data

Depending on its type, a top-level chunk cancontain subobjects. This document describes the tagged chunks containedin RMFF, as well as the format of the data stored in each type oftagged chunk.

Tagged File Formats

Header Section

Because RMFF is a tagged file format, the orderof the chunks is not explicit, except that the RealMedia File Headermust be the first chunk in the file. However, most applications writethe standard headers into the file's header section. The followingchunks are typically found in the header section of RMFF:

  • RealMedia File Header (This must be the first chunk of the file)
  • Properties Header
  • Media Properties Header
  • Content Description Header

After the RealMedia File Header object, the otherheaders may appear in any order. All headers are required except theIndex Header. The following sections describe the individual headerobjects .

RealMedia File Header

Each RealMedia file begins with the RealMediaFile Header, which identifies the file as RMFF. There is only oneRealMedia File Header in a RealMedia file. Because the contents of theRealMedia File Header may change with different versions of RMFF, theheader structure supports an object version field for determining whatadditional fields exists. The following pseudo-structure describes theRealMedia File Header:


RealMedia_File_Header
{
UINT32 object_id;
UINT32 size;
UINT16 object_version;

if (object_version == 0)
{
UINT32 file_version;
UINT32 num_headers;
}
}

The RealMedia File Header contains the following fields:

object_id: 32 bits

The unique object ID for a RealMedia File (.RMF). All RealMedia files begin with this identifier.

size: 32 bits

The size of the RealMedia header section in bytes.

object_version: 16 bits

The version of the RealMedia File Header object. All files created according to this specification have an object_version number of 0 (zero).

file_version: 32 bits

The version of the RealMedia file in PN Versionformat. All files created according to this specification have a majorversion number of 1. This member is present on all RealMedia_File_Header objects with an object_version of 0 (zero).

num_headers: 32 bits

The number of headers in the header section that follow the RealMedia File Header. This member is present on all RealMedia_File_Header objects with an object_version of 0 (zero).

Properties Header

The Properties Header describes the generalmedia properties of the RealMedia File. Components of the RealMediasystem use this object to configure themselves for handling the data inthe RealMedia file or stream. There is only one Properties Header in aRealMedia file. The following pseudo-structure describes the Propertiesheader:


Properties
{
UINT32 object_id;
UINT32 size;
UINT16 object_version;

if (object_version == 0)
{
UINT32 max_bit_rate;
UINT32 avg_bit_rate;
UINT32 max_packet_size;
UINT32 avg_packet_size;
UINT32 num_packets;
UINT32 duration;
UINT32 preroll;
UINT32 index_offset;
UINT32 data_offset;
UINT16 num_streams;
UINT16 flags;
}
}

The Properties Header contains the following fields:

object_id: 32 bits

The unique object ID for a Properties Header ('PROP').

size: 32 bits

The size of the Properties Header in bytes.

object_version: 16 bits

The version of the RealMedia File Header object. All files created according to this specification have an object_version number of 0 (zero).

max_bit_rate: 32 bits

The maximum bit rate required to deliver this file over a network. This member is present on all Properties objects with an object_version of 0 (zero).

avg_bit_rate: 32 bits

The average bit rate required to deliver this file over a network. This member is present on all Properties objects with an object_version of 0 (zero).

max_packet_size: 32 bits

The largest packet size (in bytes) in the media data. This member is present on all Properties objects with an object_version of 0 (zero).

avg_packet_size: 32 bits

The average packet size (in bytes) in the media data. This member is present on all Properties objects with an object_version of 0 (zero).

num_packets: 32 bits

The number of packets in the media data. This member is present on all Properties objects with an object_version of 0 (zero).

duration: 32 bits

The duration of the file in milliseconds. This member is present on all Properties objects with an object_version of 0 (zero).

preroll: 32 bits

The number of milliseconds to pre-buffer before starting playback. This member is present on all Properties objects with an object_version of 0 (zero).

index_offset: 32 bits

The offset in bytes from the start of the file tothe start of the index header object. This member is present on allProperties objects with an object_version of 0 (zero).

data_offset: 32 bits

The offset in bytes from the start of the file tothe start of the Data Section. This member is present on all Propertiesobjects with an object_version of 0 (zero).

num_streams: 16 bits

The number of media streams contained in the file. This member is present on all Properties objects with an object_version of 0 (zero).

flags: 16 bits

Flags indicating characteristics of the RealMedia file. The following flags are defined:

  • #define PN_SAVE_ENABLED 0x0001

    Allows clients to save a copy of the RealMedia file to disk.

  • #define PN_PERFECT_PLAY_ENABLED 0x0002

    Allows clients to use extra buffering to ensure Perfect Play.

  • #define PN_LIVE_BROADCAST 0x0004

    The RealMedia file is being generated by a live broadcast.

Media Properties Header

The Media Properties Header describes thespecific media properties of each stream in a RealMedia File.Components of the RealMedia system use this object to configurethemselves for handling the media data in each stream. There is oneMedia Properties Header for each media stream in a RealMedia file. Thefollowing pseudo-structure describes the Media Properties header:


Media_Properties
{
UINT32 object_id;
UINT32 size;
UINT16 object_version;

if (object_version == 0)
{
UINT16 stream_number;
UINT32 max_bit_rate;
UINT32 avg_bit_rate;
UINT32 max_packet_size;
UINT32 avg_packet_size;
UINT32 start_time;
UINT32 preroll;
UINT32 duration;
UINT8 stream_name_size;
UINT8[stream_name_size] stream_name;
UINT8 mime_type_size;
UINT8[mime_type_size] mime_type;
UINT32 type_specific_len;
UINT8[type_specific_len] type_specific_data;
}
}

The Media Properties Header contains the following fields:

object_id: 32 bits

The unique object ID for a Media Properties Header ("MDPR").

size: 32 bits

The size of the Media Properties Header in bytes.

object_version: 16 bits

The version of the Media Properties Header object.

stream_number: 32 bits

The stream_number (synchronizationsource identifier) is a unique value that identifies a media stream.Every data packet that belongs to a media stream contains the same STREAM_NUMBER. The STREAM_NUMBERenables a receiver of multiple media streams to distinguish whichpackets belong to each media stream. This member is present on allMediaProperties objects with an object_version of 0 (zero).

max_bit_rate: 32 bits

The maximum bit rate required to deliver thisstream over a network. This member is present on all MediaPropertiesobjects with an object_version of 0 (zero).

avg_bit_rate: 32 bits

The average bit rate required to deliver thisstream over a network. This member is present on all MediaPropertiesobjects with an object_version of 0 (zero).

max_packet_size: 32 bits

The largest packet size (in bytes) in the stream of media data. This member is present on all MediaProperties objects with an object_version of 0 (zero).

avg_packet_size: 32 bits

The average packet size (in bytes) in the stream of media data. This member is present on all MediaProperties objects with an object_version of 0 (zero).

start_time: 32 bits

The time offset in milliseconds to add to thetimestamp of each packet in a media stream. This member is present onall MediaProperties objects with an object_version of 0 (zero).

preroll: 32 bits

The time offset in milliseconds to subtract tothe timestamp of each packet in a media stream. This member is presenton all MediaProperties objects with an object_version of 0 (zero).

duration: 32 bits

The duration of the stream in milliseconds. This member is present on all MediaProperties objects with an object_version of 0 (zero).

stream_name_size: 8 bits

The length of the following stream_name field in bytes. This member is present on all MediaProperties objects with an object_version of 0 (zero).

stream_name: variable length

A non-unique alias or name for the stream. This member is present on all MediaProperties objects with an object_version of 0 (zero).

mime_type_size: 8 bits

The length of the following mime_type field in bytes. This member is present on all MediaProperties objects with an object_version of 0 (zero).

mime_type: variable length

A non-unique MIME style type/subtype string fordata associated with the stream. This member is present on allMediaProperties objects with an object_version of 0 (zero).

type_specific_len: 32 bits

The length of the following type_specific_data in bytes. The type_specific_datais typically used by the datatype renderer to initialize itself inorder to process the media stream. This member is present on allMediaProperties objects with an object_version of 0 (zero).

type_specific_data: variable length

The type_specific_data is typicallyused by the data-type renderer to initialize itself in order to processthe media stream. This member is present on all MediaProperties objectswith an object_version of 0 (zero).

Content Description Header

The Content Description Header contains thetitle, author, copyright, and comments information for the RealMediaFile. All text data is in ASCII format. The following pseudo-structuredescribes the Content Description Header:


Content_Description
{
UINT32 object_id;
UINT32 size;
UINT16 object_version;

if (object_version == 0)
{
UINT16 title_len;
UINT8[title_len] title;
UINT16 author_len;
UINT8[author_len] author;
UINT16 copyright_len;
UINT8[copyright_len] copyright;
UINT16 comment_len;
UINT8[comment_len] comment;
}
}

The Content Description Header contains the following fields:

object_id: 32 bits

The unique object ID for the Content Description Header ('CONT').

size: 32 bits

The size of the Content Description Header in bytes.

object_version: 16 bits

The version of the Content Description Header object.

title_len: 16 bits

The length of the title data in bytes. Note thatthe title data is not null terminated. This member is present on allContent Description Header objects with an object_version of 0 (zero).

title: variable length

An array of ASCII characters that represents thetitle information for the RealMedia file. This member is present on allContent Description Header objects with an object_version of 0 (zero).

author_len: 16 bits

The length of the author data in bytes. Note thatthe author data is not null terminated. This member is present on allContent Description Header objects with an object_version of 0 (zero).

author: variable length

An array of ASCII characters that represents theauthor information for the RealMedia file. This member is present onall Content Description Header objects with an object_version of 0 (zero).

copyright_len: 16 bits

The length of the copyright data in bytes. Notethat the copyright data is not null terminated. This member is presenton all Content Description Header objects with an object_version of 0 (zero).

copyright: variable length

An array of ASCII characters that represents thecopyright information for the RealMedia file. This member is present onall Content Description Header objects with an object_version of 0 (zero).

comment_len: 16 bits

The length of the comment data in bytes. Notethat the comment data is not null terminated. This member is present onall Content Description Header objects with an object_version of 0 (zero).

comment: variable length

An array of ASCII characters that represents thecomment information for the RealMedia file. This member is present onall Content Description Header objects with an object_version of 0 (zero).

Data Section

The data section of the RealMedia file consistsof a Data Section Header that describes the contents of the datasection, followed by a series of interleaved media data packets. Notethat the size field of the Data Chunk Header is the size of the entiredata chunk, including the media data packets.

Data Chunk Header

The Data Chunk Header marks the start of the datachunk. There is usually only one data chunk in a RealMedia file,however for extremely large files there may be multiple data chunks.The following pseudo-structure describes the Data chunk header:


Data_Chunk_Header
{
UINT32 object_id;
UINT32 size;
UINT16 object_version;

if (object_version == 0)
{
UINT32 num_packets;
UINT32 next_data_header;
}
}

The Data Chunk Header contains the following fields:

object_id: 32 bits

The unique object ID for the Data Chunk Header ('DATA').

size: 32 bits

The size of the Data Chunk in bytes.

object_version: 16 bits

The version of the Data Chunk Header object.

num_packets: 32 bits

Number of packets in the data chunk. This member is present on all Data Chunk Header objects with an object_version of 0 (zero).

next_data_header: 32 bits

Offset from start of file to the next data chunk.This field is not typically used. This member is present on all DataChunk Header objects with an object_version of 0 (zero).

Data Packet Header

The data section of a RealMedia file consists ofa series of interleaved data objects. Each data object contains apacket of data for a media stream. Because a RealMedia file can containnumerous media streams, data objects for each stream are interleaved.The following pseudo-structure describes the details of eachinterleaved packet:


Media_Packet_Header
{
UINT16 object_version;

if (object_version == 0)
{
UINT16 length;
UINT16 stream_number;
UINT32 timestamp;
UINT8 reserved;
UINT8 flags;
UINT8[length] data;
}
}

The Media Packet Header contains the following fields:

object_version: 16 bits

The version of the Media Packet Header object.

length: 16 bits

The length of the packet in bytes. This member is present on all Media Packet Header objects with an object_version of 0 (zero).

stream_number: 16 bits

The 16-bit alias used to associate data packetswith their associated Media Properties Header. This member is presenton all Media Packet Header objects with an object_version of 0 (zero).

timeStamp: 32 bits

The timestamp of the packet in milliseconds This member is present on all Media Packet Header objects with an object_version of 0 (zero).

reserved: 8 bits

This is not used. This member is present on all Media Packet Header objects with an object_version of 0 (zero).

flags: 16 bits

Flags describing the properties of the packet. The following flags are defined:

#define PN_RELIABLE_FLAG 0x0001

If this flag is set, the packet is delivered reliably.

#define PN_KEYFRAME_FLAG 0x0002

If this flag is set, the packet is part of a key frame or in some way marks a boundary in your data stream.

This member is present on all Media Packet Header objects with an object_version of 0 (zero).

data: variable length

The application-specific media data. This member is present on all Media Packet Header objects with an object_version of 0 (zero).

Index Section

The index section of the RealMedia file consistsof a Index Chunk Header that describes the contents of the indexsection, followed by a series of index records. Note that the sizefield of the Index Chunk Header is the size of the entire index chunk,including the index records.

Index Section Header

The Index Chunk Header marks the start of theindex chunk. There is usually one index chunk per stream in a RealMediafile. The following pseudo-structure describes the Index chunk header.


Index_Chunk_Header
{
u_int32 object_id;
u_int32 size;
u_int16 object_version;

if (object_version == 0)
{
u_int32 num_indices;
u_int16 stream_number;
u_int32 next_index_header;
}
}

The Index Chunk Header contains the following fields:

object_id: 32 bits

The unique object ID for the Index Chunk Header ('INDX').

size: 32 bits

The size of the Index Chunk in bytes.

object_version: 16 bits

The version of the Index Chunk Header object.

num_indices: 32 bits

Number of index records in the index chunk. This member is present on all Index Chunk Header objects with an object_version of 0 (zero).

stream_number: 16 bits

The stream number for which the index records inthis index chunk are associated. This member is present on all IndexChunk Header objects with an object_version of 0 (zero).

next_index_header: 32 bits

Offset from start of file to the next indexchunk. This field lets RealMedia file format readers find all the indexchunks quickly. This member is present on all Index Chunk Headerobjects with an object_version of 0 (zero).

Index Record

The index section of a RealMedia file consists ofa series of index record objects. Each index record containsinformation for quickly finding a packet of a particular time stamp fora media stream. The following pseudo-structure describes the details ofeach index record:


IndexRecord
{
UINT16 object_version;

if (object_version == 0)
{
u_int32 timestamp;
u_int32 offset;
u_int32 packet_count_for_this_packet;
}
}

An Index Record contains the following fields:

object_version: 16 bits

The version of the Index Record object.

timestamp: 32 bits

The timestamp in milliseconds associated with this record. This member is present on all Index Record objects with an object_version of 0 (zero).

offset: 32 bits

The offset from the start of the file at whichthis packet can be found. This member is present on all Index Recordobjects with an object_version of 0 (zero).

packet_count_for_this_packet: 32 bits

The packet number of the packet for this record.This is the same number of packets that would have been seen had thefile been played from the beginning to this point. This member ispresent on all Index Record objects with an object_version of 0 (zero).



From: http://www.multimedia.cx/rmff.htm
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 坐式马桶堵了怎么办 电动修眉刀钝了怎么办 眉毛自己修坏了怎么办 旋耕机旋的太深怎么办 摩拜单车忘了锁怎么办 胶棒没有胶枪怎么办 催泪喷雾被喷了怎么办 中了防狼喷雾怎么办 防狼喷雾喷脸上怎么办 高帮足球鞋难穿怎么办 水氟含量太高怎么办 买的自慰器太大怎么办 电棍充电器丢了怎么办 电动车连电了怎么办啊 鼻子两侧红是怎么办啊 自控力差的孩子怎么办 衣服肩膀破了洞怎么办 衣服烧了个洞怎么办 出满月黄疸没退怎么办 满月后黄疸还高怎么办 月子里的宝宝吐奶怎么办 刚满月的宝宝有点咳嗽怎么办 刚满月的咳嗽了怎么办 实木家具烫白了怎么办 木桌子烫白了怎么办 毛孔粗皮肤暗黄怎么办 脖子往右转就疼怎么办 夏天晚上热的睡不着怎么办 膝盖凉着了疼怎么办 打篮球手肿了怎么办呢 手被篮球戳肿了怎么办 手指被篮球砸了怎么办 走路久了膝盖疼怎么办 路走太多膝盖痛怎么办 走一天路膝盖疼怎么办 走多了膝盖胀痛怎么办 跑步多了膝盖疼怎么办 跑步跑得膝盖疼怎么办 脚打球崴脚淤血怎么办 打球歪了脚肿了怎么办 打球脚踝扭伤肿了怎么办