previously submitted packet. The total duration of audio in the repacketizer state also must not exceed 120 ms, the maximum duration of a single packet, after adding this packet.
用opus_repacketizer_out() 或 opus_repacketizer_out_range(),当前repacketizer状态的内容可以被提取到新的包。
The contents of the current repacketizer state can be extracted into new packets using opus_repacketizer_out() or opus_repacketizer_out_range().
如果想添加不同配置的包,或加更多的超过120毫秒的音频数据,就必须调用opus_repacketizer_init()来清除repacketizer状态。如果一个包太大不能整体添加到当前repacketizer状态,它的任何一部分也不能添加,即使这个包包含多个帧,其中部分也许适合添加。如果你想添加这样的包的部分内容,你应当首先使用另一个repacketizer来将这些包分离成适合添加的小片,再一个个地将这些小片加入目标repacketizer状态。
In order to add a packet with a different configuration or to add more audio beyond 120 ms, you must clear the repacketizer state by calling opus_repacketizer_init(). If a packet is too large to add to the current repacketizer state, no part of it is added, even if it contains multiple frames, some of which might fit. If you wish to be able to add parts of such packets, you should first use another repacketizer to split the packet into pieces and add them individually.
参见:
opus_repacketizer_out_range opus_repacketizer_out opus_repacketizer_init 参数:
rp OpusRepacketizer*:将要添加包的repacketizer状态。 The
repacketizer state to which to add the packet.
[in] data
const unsigned char*: 包数据。应用程序必须确保这个指
针合法有效直到对opus_repacketizer_init() 或 opus_repacketizer_destroy()的
26
下一次调用。The packet data. The application must ensure this pointer remains valid
until
the
next
call
to
opus_repacketizer_init()
or
opus_repacketizer_destroy().
packet data.
返回:
表示操作成功与否的错误代码。
An error code indicating whether or not the operation succeeded. 返回值:
OPUS_OK 包的内容已被添加到repacketizer状态。The packet's contents have been added to the repacketizer状态.
OPUS_INVALID_PACKET 包的TOC系列无效,该系列不能与以前提交的包相匹配(编码模式、音频带宽、帧大小或通道数不吻合),或添加这个包将导致存储在repacketizer状态的声音时长超过120毫秒。The packet did not have a valid TOC sequence, the packet's TOC sequence was not compatible with previously submitted packets (because the coding mode, audio bandwidth, frame size, or channel count did not match), or adding this packet would increase the total amount of audio stored in the repacketizer状态 to more than 120 ms.
OpusRepacketizer* opus_repacketizer_create ( void
)
len opus_int32: 包数据中的字节数。The number of bytes in the
为用opus_repacketizer_init()产生的新repacketizer 分配内存和初始化。 Allocates
memory
and
initializes
the
new
repacketizer
with
opus_repacketizer_init().
void opus_repacketizer_destroy ( OpusRepacketizer *
rp )
释放通过opus_repacketizer_create()分配过的OpusRepacketizer。 Frees an OpusRepacketizer allocated by opus_repacketizer_create(). 参数:
27
[in] rp OpusRepacketizer*:将被释放的repacketizer状态。 State to be freed.
int opus_repacketizer_get_nb_frames
)
返回最后一次调用opus_repacketizer_init() 或 opus_repacketizer_create()后,到当前为止通过opus_repacketizer_cat()提交的包数据所包含的帧的总数。
Return the total number of frames contained in packet data submitted to the repacketizer状态 so far via opus_repacketizer_cat() since the last call to opus_repacketizer_init() or opus_repacketizer_create().
这
里
定
义
了
能
被
opus_repacketizer_out_range()
或
( OpusRepacketizer *
rp
opus_repacketizer_out()提取的有效包的范围。
This defines the valid range of packets that can be extracted with opus_repacketizer_out_range() or opus_repacketizer_out().
参数:
rp OpusRepacketizer*: 包含各帧的repacketizer状态。The repacketizer状态 containing the frames.
返回:
提交给repacketizer状态的包所包含的帧的总数。
The total number of frames contained in the packet data submitted to the repacketizer状态.
int opus_repacketizer_get_size ( void 获得 OpusRepacketizer结构的大小
Gets the size of an OpusRepacketizer structure. 返回:
结构体字节的大小 The size in bytes.
28
)
OpusRepacketizer* opus_repacketizer_init
rp )
( OpusRepacketizer *
(重新)初始化以前分配过的repacketizer 状态 (Re)initializes a previously allocated repacketizer状态.
Repacketizer状态必须至少有opus_repacketizer_get_size()返回的大小。这适用于不使用malloc(),而是用自己的分配器的应用程序。它也要被调用来重设正在等待重构的那些包的队列,如果最大包时长达到120ms或你希望用不同的Opus配置(编码模式、音频带宽、帧大小或通道数)来提交包的时候,这么做就有必要了。这么做如果失败了,系统将阻止用opus_repacketizer_cat()添加新的包。
The state must be at least the size returned by opus_repacketizer_get_size(). This can be used for applications which use their own allocator instead of malloc(). It must also be called to reset the queue of packets waiting to be repacketized, which is necessary if the maximum packet duration of 120 ms is reached or if you wish to submit packets with a different Opus configuration (coding mode, audio bandwidth, frame size, or channel count). Failure to do so will prevent a new packet from being added with opus_repacketizer_cat().
参见:
opus_repacketizer_create opus_repacketizer_get_size opus_repacketizer_cat 参数:
rp OpusRepacketizer*:需要 (重新)初始化的repacketizer状态 返回:
输入的同一个repacketizer状态的指针。
A pointer to the same repacketizer状态 that was passed in.
opus_int32 opus_repacketizer_out ( OpusRepacketizer *
rp,
unsigned char * opus_int32
data,
29
maxlen
)
通过opus_repacketizer_cat()从以前提交给repacketizer状态的数据构建一个新的包。
Construct a new packet from data previously submitted to the repacketizer状态 via opus_repacketizer_cat().
返回迄今提交进单一个包的所有数据可以提供便利,这么做等同于调用opus_repacketizer_out_range(rp, 0, opus_repacketizer_get_nb_frames(rp),data, maxlen)
This is a convenience routine that returns all the data submitted so far in a single packet. It is equivalent to calling
opus_repacketizer_out_range(rp, 0, opus_repacketizer_get_nb_frames(rp), data, maxlen) 参数:
rp OpusRepacketizer*: 准备构建新包的repacketizer状态。The
repacketizer状态 from which to construct the new packet.
[out]
data
const unsigned char*: 将要存储输出包的缓冲区。
The buffer in which to store the output packet.
maxlen opus_int32: 将要存入输出缓冲区的字节最大数。为保证
成功,这个值应该至少为1277*opus_repacketizer_get_nb_frames(rp)。然而,1*opus_repacketizer_get_nb_frames(rp)
加
上
自
从
上
次
调
用
opus_repacketizer_init() 或opus_repacketizer_create()以来所有提交包数据的大小,也是足够的,也可能小得多(此话似有矛盾)。 The maximum number of bytes to store in the output buffer. In order to guarantee success, this should be
at
least
1277*opus_repacketizer_get_nb_frames(rp).
However,
1*opus_repacketizer_get_nb_frames(rp) plus the size of all packet data submitted to the repacketizer since the last call to opus_repacketizer_init() or opus_repacketizer_create() is also sufficient, and possibly much smaller.
返回:
成功,输出包总的大小,失败,错误代码。
The total size of the output packet on success, or an error code on
30