Voice Intercom (NVR Scenario)

This section describes the typical process, key APIs, and precautions for audio processing in the NVR scenario.

NVR refers to the storage and forwarding of the network video system. The NVR works with the network camera to record, store, and forward videos and audios. In addition, the NVR provides the local human-machine interface, video decoding, video display, and voice intercom functions.

NVR Audio Scenario

This section describes the API call sequence of the NVR audio service (voice intercom). Voice intercom includes functions such as initialization and deinitialization of the media data processing system, receiving IP camera voice and playing the voice, and recording audios and sending audios to the IP camera. The following modules are required: the common module, AI, AENC, AO, and ADEC.

Receiving Audios from the IP Camera and Play the Audios

Figure 1 Receiving audios from the IP camera and playing the audios

The API call sequence is as follows:

  1. Call hi_mpi_adec_create_chn to create an ADEC channel.
  2. Enable an AO device and a channel:
    1. Call hi_mpi_ao_set_pub_attr to set the AO device attributes.
    2. Call hi_mpi_ao_enable to start the AO device.
    3. Call hi_mpi_ao_enable_chn to start the AO channel.
    4. Call hi_mpi_ao_enable_resample to enable AO resampling.

      The AO sampling rate is fixed at 48 kHz. The G.711a and G.711u protocols only support the sampling rate of 8 kHz, and when either protocol is used, resampling needs to be enabled. However, the AAC protocol supports the sampling rate of 48 kHz, and when it is used, AO resampling is not required.

  3. Call hi_mpi_sys_bind to bind ADEC to AO.

    ADEC Device ID

    ADEC Channel ID

    AO Device ID

    AO Channel ID

    0

    0

    2

    0

    0

    1

    3

    0

  4. Call hi_mpi_adec_send_stream repeatedly to send each frame of the audio to the decoder.

    Based on the mapping in 3, the decoded audio data is automatically sent to the corresponding AO device for audio playing.

  5. After audio playback is complete, unbind the ADEC channel from the AO by calling hi_mpi_sys_unbind, disable AO resampling by calling hi_mpi_ao_disable_resample, disable the AO channel by calling hi_mpi_ao_disable_chn, disable the AO device by calling hi_mpi_ao_disable, and destroy the ADEC channel by calling hi_mpi_adec_destroy_chn in sequence.

Recording Audios and Sending Audios to the IP Camera

Figure 2 Recording audios and sending audios to the IP camera

The API call sequence is as follows:

  1. Enable an AI device and a channel:
    1. Call hi_mpi_ai_set_pub_attr to set the AI device attributes.
    2. Call hi_mpi_ai_enable to start the AI device.
    3. Call hi_mpi_ai_set_chn_attr to set the AI channel attributes.
    4. Call hi_mpi_ai_enable_chn to start the AI channel.
    5. Call hi_mpi_ai_enable_resample to enable AI resampling.

      The AI sampling rate is fixed at 48 kHz. The G.711a and G.711u protocols only support the sampling rate of 8 kHz, and when either protocol is used, resampling needs to be enabled. However, the AAC protocol supports the sampling rate of 48 kHz, and when it is used, AI resampling is not required.

  2. Call hi_mpi_aenc_create_chn to create an AENC channel.
  3. Call hi_mpi_sys_bind to bind AI to AENC.

    AI Device ID

    AI Channel ID

    AENC Device ID

    AENC Channel ID

    2

    0

    0

    0

  4. Call hi_mpi_aenc_get_stream repeatedly to obtain the encoded data. After the encoded data is no longer used, call hi_mpi_aenc_release_stream in a timely manner to release the encoded data.

    Based on the mapping in 3, the audio data obtained by the AI device is automatically sent to the corresponding AENC channel for encoding, and then the voice data is sent to the IP camera.

  5. After voice data is sent, unbind AI from AENC by calling hi_mpi_sys_unbind, destroy the AENC channel by calling hi_mpi_aenc_destroy_chn, disable AI resampling by calling hi_mpi_ai_disable_resample, disable the AI channel by calling hi_mpi_ai_disable_chn, and disable the AI device by calling hi_mpi_ai_disable in sequence.