hi_mpi_adec_send_stream
The
The
Description
Sends streams to an ADEC channel.
Restrictions
- When creating an ADEC channel (hi_mpi_adec_create_chn), you can set the decoding mode to pack or stream by setting the hi_adec_mode variable. The pack mode is recommended.
- pack mode: This mode is applicable when you can make sure that the stream packet contains only one-frame data. In this case, the decoder decodes the stream packet directly. If the packet contains more than one frame or less than one frame, an error code is returned.
For example, for a G.711a file, the frame header contains data length information. Assume that the data length is 240 (unit: s16), that is, 240 x 2 = 480 bytes. Because the frame header length is 4 bytes, therefore, the length of a complete frame is 480 + 4 = 484 bytes. That is, 484 bytes should be read each time.
- stream mode: This mode is used when you are not sure whether the stream packet contains one frame, but this mode has low efficiency and may cause delay or full buffer. Application scenario: The program runs for a long time and does not exit. There is no matching requirement between the sender and receiver. The efficiency is low.
- pack mode: This mode is applicable when you can make sure that the stream packet contains only one-frame data. In this case, the decoder decodes the stream packet directly. If the packet contains more than one frame or less than one frame, an error code is returned.
- Before sending data, ensure that an ADEC channel is created. Otherwise, an error code is returned.
- Streams can be sent in blocking or non-blocking mode. When streams are sent in blocking mode, if the buffer for decoded audio frames is full, this API call will be blocked until the decoded audio frames are fetched.
- This API supports only the decoding of G.711a and G.711u audio sources which have a mono audio channel and a voice frame header that meets the requirements.
Prototype
hi_s32 hi_mpi_adec_send_stream(hi_adec_chn adec_chn, const hi_audio_stream *stream, hi_bool block);
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
adec_chn |
Input |
Channel ID. The value range is [0, 6). |
stream |
Input |
Audio stream. |
block |
Input |
Blocking flag.
|
Returns
- 0: success
- Other values: failure. For details, see Audio Return Codes.
Parent topic: AENC/ADEC