|
|
|
|
@ -25,6 +25,8 @@ struct voice_recorder {
|
|
|
|
|
int active; |
|
|
|
|
|
|
|
|
|
char channel_id[64]; |
|
|
|
|
uint8_t reply_to[32]; |
|
|
|
|
uint64_t request_id; |
|
|
|
|
int sample_rate; |
|
|
|
|
int channels; |
|
|
|
|
int frame_samples; |
|
|
|
|
@ -106,7 +108,7 @@ void voice_recorder_deinit(void) {
|
|
|
|
|
pthread_mutex_unlock(&g_init_mtx); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int voice_recorder_start(const char* channel_id, int sample_rate, int channels) { |
|
|
|
|
int voice_recorder_start(const char* channel_id, int sample_rate, int channels, const uint8_t reply_to[32], uint64_t request_id) { |
|
|
|
|
if (!channel_id || !channel_id[0] || strlen(channel_id) >= 64 || sample_rate != 48000 || channels != 1) { |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_MEDIA, "voice start: invalid target or capture format rate=%d channels=%d", sample_rate, channels); |
|
|
|
|
return -1; |
|
|
|
|
@ -129,6 +131,8 @@ int voice_recorder_start(const char* channel_id, int sample_rate, int channels)
|
|
|
|
|
g_rec->channels = channels; |
|
|
|
|
g_rec->frame_samples = sample_rate * FRAME_MS / 1000; |
|
|
|
|
snprintf(g_rec->channel_id, sizeof(g_rec->channel_id), "%s", channel_id ? channel_id : ""); |
|
|
|
|
memcpy(g_rec->reply_to, reply_to, sizeof(g_rec->reply_to)); |
|
|
|
|
g_rec->request_id = request_id; |
|
|
|
|
|
|
|
|
|
g_rec->pcm_count = 0; |
|
|
|
|
g_rec->active = 1; |
|
|
|
|
@ -213,6 +217,7 @@ int voice_recorder_stop(int* out_duration_ms) {
|
|
|
|
|
} |
|
|
|
|
req->inst = instance_lite_get_instance(); req->info.kind = ATTACHMENT_VOICE; req->preset = g_rec->preset; |
|
|
|
|
req->is_dm = !strncmp(g_rec->channel_id, "dm:", 3); |
|
|
|
|
if (!req->is_dm) { memcpy(req->reply_to, g_rec->reply_to, sizeof(req->reply_to)); req->request_id = g_rec->request_id; } |
|
|
|
|
snprintf(req->target, sizeof(req->target), "%s", g_rec->channel_id + (req->is_dm ? 3 : 0)); |
|
|
|
|
if (g_rec->compressor && g_rec->compressor_enabled) { |
|
|
|
|
struct audio_compressor* replacement = audio_compressor_clone_config(g_rec->compressor); |
|
|
|
|
|