Rate This Document
Findability
Accuracy
Completeness
Readability

Data Injection

Different from data output, the InjectData API needs to be invoked for data input. You can specify data using the MIC_SEND_MIC_DATA command word in the VmiCmd enumeration and inject data to the server through the InjectData API. The following is an example:

VmiDataType module = DATA_MIC;
VmiCmd cmd = MIC_SEND_MIC_DATA;
uint8_t micData[240];
AudioData audioData;
audioData.size = sizeof(micData);
uint8_t *data = new uint8_t[sizeof(AudioData) + sizeof(micData)];
memcpy(data, &audioData, sizeof(AudioData));
memcpy(data + sizeof(AudioData), micData, sizeof(micData))
InjectData(module, cmd, data, sizeof(AudioData) + sizeof(micData));

Restrictions

Microphone frames need to be injected stably. Otherwise, the sound may be intermittent. The specific restrictions subject to the value of vmi.mic.cachefactor in the default.prop configuration file. This configuration item indicates the buffer size of the microphone frame queue. The options are as follows:

  • 0: One frame needs to be injected every 10 ms, causing no extra delay.
  • 1: 16 frames need to be injected every 160 ms, causing a 160 ms delay.
  • 2: 32 frames need to be injected every 320 ms, causing a 320 ms delay.
  • 3: 48 frames need to be injected every 480 ms, causing a 480 ms delay.
  • If microphone data is transmitted in PCM mode, it is recommended that the upstream bandwidth from the client to the server be greater than or equal to 2 Mbit/s.
  • Injected microphone frames cannot contain blank frames. Otherwise, the sound may be intermittent.