[翻译]RM文件格式——之一

[原文]

RealMedia File Format (RMFF)   1

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

RealMedia File Format is a standard tagged file format that uses four-character codes to identify file elements. These codes are 32-bit, represented by a sequence of one to four ASCII alphanumeric characters, padded on the right with space characters. The data 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 can contain subobjects. This document describes the tagged chunks contained in RMFF, as well as the format of the data stored in each type of tagged chunk.

Tagged File Formats

Header Section

Because RMFF is a tagged file format, the order of the chunks is not explicit, except that the RealMedia File Header must be the first chunk in the file. However, most applications write the standard headers into the file's header section. The following chunks 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 other headers may appear in any order. All headers are required except the Index Header. The following sections describe the individual header objects .

RealMedia File Header

Each RealMedia file begins with the RealMedia File Header, which identifies the file as RMFF. There is only one RealMedia File Header in a RealMedia file. Because the contents of the RealMedia File Header may change with different versions of RMFF, the header structure supports an object version field for determining what additional fields exists. The following pseudo-structure describes the RealMedia 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 Version format. All files created according to this specification have a major version 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 general media properties of the RealMedia File. Components of the RealMedia system use this object to configure themselves for handling the data in the RealMedia file or stream. There is only one Properties Header in a RealMedia file. The following pseudo-structure describes the Properties header:

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 to the start of the index header object. This member is present on all Properties objects with an object_version of 0 (zero).

data_offset: 32 bits

The offset in bytes from the start of the file to the start of the Data Section. This member is present on all Properties objects 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.

 

 

 

 

[译文]

RM文件格式(RMFF   之一

RealSystem系统结构描述RM文件结构,有了RM文件,RealSystem可在各种不同网络带宽的网络中传送高质量的多媒体内容。第三方可将他们的多媒体格式转换成RM文件格式,RM文件可使用RealPlayer或其它使用RealSystem SDK开发的软件播放。借助RealSystem体系,第三方能够使用自己的应用软件在互联网上传播多媒体内容。

RM文件格式是一种标准的标识化文件格式,文件中的每个组成部分都使用一个标记符来标识,该标记符占32个位,四个字节,由一至四个ASCII码字符组成,标记符不足四字符则以空格字符右边填齐,其数据类型为FOURCC,使用PN_FOURCC宏可将四个字符转换为标识符。

RM文件的基本组成部分称为块,是一个逻辑地数据单元,类似于流头或数据包。每个块都包含以下几个部分:

块标识符,四字符编码

用于描述块中数据成员的长度

可视块数据

依据块的类型,最高层块包含子对象,本文描述了标识块在RM文件格式中的包含信息,也即数据在每种类型的标识块中的存储格式。

标识文件格式

头部

因为RM文件格式是标识文件格式,所以块的顺序没有明确规定,除了RM文件头必须是文件的第一个块以外。然而,很多应用软件会按某种标准写文件头部。常有的RM文件头部组成块具体如下:RM文件头(必须在文件第一个块)

属性头

媒体属性头

内容描述头

RM文件头后,其它头可任意顺序存在,除索引头外所有头都是必须的。下面分别对各种头进行详细叙述:

RM文件头

RM文件的第一部分是RM文件头,它标识文件为RM格式。一个RM文件只有一个RM文件头。因为RM文件头记录了RM文件格式的版本,所以RM文件头结构提供一个对象版本项以确定附加项。RM文件头抽象结构如下:

RealMedia_File_Header{

 UINT32 object_id;

 UINT32 size;

 UINT16 object_version;

 if (object_version == 0) {

UINT32 file_version;

UINT32 num_headers;

}

}

RM文件头所含的项如下:

object_id:32

RM文件(.RMF)的ID(标识符),所有的RM文件的第一项内容是本项标识符。

size:32

用于存放RM头部长度的字节。

object_version: 16

RM文件头对象的版本,所有依照规定的新建的文件都有0对象版本号。

file_version:32

RM文件的版本存放在PN版本格式中,所有依据规定新建的文件都有1版本号。所有0RM文件头对象都包含有文件版本信息。

num_headers: 32

头部中RM文件头后的头的个数。所有0RM文件头对象都包含有该信息。

属性头

属性头描述了RM文件的一般媒体属性,RM系统部件使用属性头来配置,使之能处理RM文件或流中的数据。一个RM文件中只有一个属性头,以下是属性头结构:

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;

}

}

属性头包含项如下:

object_id:32

属性头的对象ID,具有唯一性(“PROP”)

size32

属性头的长度,单位为是字节。

object_version16

属性头的版本号,所有新建文件的版本号为0

max_bit_rate32

最大比特率指得是文件在网络上传送的需求,当版本号为0是该属性存在。

avg_bit_rate32

平均比特率指得是文件在网络上传送的需求,当版本号为0是该属性存在。

max_packet_size: 32

媒体数据中的包最大长度(字节),当版本号为0是该属性存在。

avg_packet_size: 32

媒体数据中的包平均长度(字节),当版本号为0是该属性存在。

num_packets: 32

媒体数据中的包的数量,当版本号为0是该属性存在。

duration32

文件的持续时间,单位为毫秒,当版本号为0是该属性存在。

preroll: 32

播放前的预缓冲时间,单位为毫秒,当版本号为0是该属性存在。

index_offset: 32

索引头所指的起始地址在文件中的位移字节数,当版本号为0是该属性存在。

data_offset: 32

数据部分所指的起始地址在文件中的位移字节数,当版本号为0是该属性存在。

num_streams: 16

文件包含媒体流的数量,当版本号为0是该属性存在。

flags: 16

flags标记指明RM文件的特征,标记具体定义发下:

#define PN_SAVE_ENABLED 0x0001  允许客户端在本地盘备份RM文件。

#define PN_PERFECT_PLAY_ENABLED 0x0002 允许客户端使用额外的缓存确保文件播放。

#define PN_LIVE_BROADCAST 0x0004 实时广播产生RM文件。

 

 

[后面部分请待续]

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值