Voice Intercom And Forwarding¶
Flow of implementing voice intercom/forwarding
Interface Overview¶
| interface Name | Functional Description |
|---|---|
NET_SDK_StartVoiceCom | Start voice intercom. |
NET_SDK_StartVoiceCom_MR | Turn on voice forwarding. |
NET_SDK_VoiceComSendData | Voice forwarding for real-time data delivery. |
NET_SDK_InitAudioEncoder | Initializing the audio encoder. |
NET_SDK_EncodeAudioFrame | Audio Encoding. |
NET_SDK_ReleaseAudioEncoder | Free up audio encoding resources. |
NET_SDK_StopVoiceCom | End voice intercom or voice forwarding. |
Note
Detailed parameters of the interface can be found in the interface definition section
Process Description¶
---
title: Voice Intercom And Forwarding
---
flowchart TD
A(Device SDK Initialization<br><strong>NET_SDK_Init</strong>)
B(User Registers Device<br><strong>NET_SDK_Login</strong> or<br><strong>NET_SDK_LoginEx</strong>)
C("Start Voice Intercom<br><strong>NET_SDK_StartVoiceCom</strong>")
D("Start Voice Forwarding<br><strong>NET_SDK_StartVoiceCom_MR</strong>")
subgraph S1 [Audio Data Encoding]
C1(Initialize Audio Encoder<br><strong>NET_SDK_InitAudioEncoder</strong>)
C2(Audio Encoding<br><strong>NET_SDK_EncodeAudioFrame</strong>)
C3(Release Audio Encoding Resources<br><strong>NET_SDK_ReleaseAudioEncoder</strong>)
C1 --> C2 --> C3
end
E("Send Audio Data<br><strong>NET_SDK_VoiceComSendData</strong>")
style S1 fill:#e7b13387,stroke:#f66,stroke-width:2px,stroke-dasharray: 5
X("Stop voice intercom or voice forwarding <br><strong>NET_SDK_StopVoiceCom</strong>")
Y(Log out of device <br><strong>NET_SDK_Logout</strong>)
Z(Release SDK resources <br><strong>NET_SDK_Cleanup</strong>)
A --> B --> C ----> X --> Y --> Z
B ---> D --> S1 --> E ---> X -
The voice intercom function enables the sending and receiving of audio between the PC and the device. After successfully registering the device call
NET_SDK_StartVoiceCominterface is completed, while in the interface the user can set the callback function to get the data sent by the current device or collected by the PC (after the callback encoding or PCM data as needed). -
First call
NET_SDK_StartVoiceCom_MRinterface initiates voice forwarding with the device (at this point the connection to the device is established and waiting for data to be sent). -
Prepare the data to be sent (which needs to be encoded), the encoding process is shown in the purple box in the figure above. The data source can be captured from the PC sound card or read from a file, but it needs to be compressed by the compression algorithm provided by our company.
-
After the encoding operation, we can get a fixed size and encoded data each time by calling
NET_SDK_VoiceComSendDatainterface sends this data to the device. -
When all forwarding operations are complete, call
NET_SDK_StopVoiceCominterface ends the voice forwarding connection to the device.
Note
The audio data format received by the device is: 8000HZ sample rate, 16bit, mono.
Sample Code¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
Related notes¶
-
Before calling
NET_SDK_StartVoiceCom,to confirm whether the device has voice intercom function first -
The interfaces to end voice intercom and end voice forwarding are both
NET_SDK_StopVoiceCom -
The sample code does not contain the
NET_SDK_InitAudioEncoder,NET_SDK_EncodeAudioFrame,NET_SDK_ReleaseAudioEncoder