Voice Intercom (NVR Scenario)

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

The network video recorder (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 audios. In addition, the NVR provides the local man-machine interface, video decoding, video display, and voice intercom functions.

NVR Audio Scenario

This section describes the API call sequence for the NVR audio service (voice intercom function). The voice intercom function includes the initialization and deinitialization of the media data processing system, receiving and playing the voice sent by the IP camera, and recording the voice and sending the voice to the IP camera. The involved modules include the common module, AI module, AENC module, AO module, and ADEC module.

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. Set AO device attributes by calling hi_mpi_ao_set_pub_attr.
    2. Start the AO device by calling hi_mpi_ao_enable.
    3. Enable the AO channel by calling hi_mpi_ao_enable_chn.
    4. Enable AO resampling by calling hi_mpi_ao_enable_resample.

      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 the hi_mpi_sys_bind API to bind the ADEC to the AO.

    ADEC Device ID

    ADEC Channel ID

    AO Device ID

    AO Channel ID

    0

    0

    2

    0

    0

    1

    3

    0

  4. Call the hi_mpi_adec_send_stream API cyclically to send each frame of audio data to be decoded to the decoder for decoding.

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

  5. After the audio playback is complete, call the hi_mpi_sys_unbind API to unbind the ADEC from the AO, call the hi_mpi_ao_disable_resample API to disable the AO resampling function, call the hi_mpi_ao_disable_chn API to disable the AO channel, call the hi_mpi_ao_disable API to disable the AO device, and then call the hi_mpi_adec_destroy_chn API to destroy the ADEC channel.

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. Set AI device attributes by calling hi_mpi_ai_set_pub_attr.
    2. Start the AI device by calling hi_mpi_ai_enable.
    3. Set AI channel attributes by calling hi_mpi_ai_set_chn_attr.
    4. Enable the AI channel by calling hi_mpi_ai_enable_chn.
    5. Enable AI resampling by calling hi_mpi_ai_enable_resample.

      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 the hi_mpi_sys_bind API to bind the AI channel to the AENC channel.

    AI Device ID

    AI Channel ID

    AENC Device ID

    AENC Channel ID

    2

    0

    0

    0

  4. Call the hi_mpi_aenc_get_stream API cyclically to obtain the encoding data. After the encoding data is used, call the hi_mpi_aenc_release_stream API to release the encoding data in a timely manner.

    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 the audio is sent, call the hi_mpi_sys_unbind API to unbind the AI channel from the AENC channel, call the hi_mpi_aenc_destroy_chn API to destroy the AENC channel, call the hi_mpi_ai_disable_resample API to disable AI resampling, call the hi_mpi_ai_disable_chn API to disable the AI channel, and call the hi_mpi_ai_disable API to disable the AI device in sequence.