ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
client_pipeline.h
Go to the documentation of this file.
1
46
47#pragma once
48
50#include <stdbool.h>
51#include <stdint.h>
52
53// C11 stdatomic.h conflicts with MSVC's C++ <atomic> header on Windows.
54// When compiling C++ with MSVC runtime headers (even with Clang), we must not
55// include stdatomic.h as the MSVC <atomic> header already provides the same
56// functionality and the declarations conflict.
57#if defined(__cplusplus) && defined(_WIN32)
58// C++ mode on Windows: use <atomic> from MSVC runtime
59#include <atomic>
60#else
61#include <libplatform/atomic.h>
62#endif
63
64#include "../audio/mixer.h"
65#include "../audio/processor.h"
66#include <libplatform/mutex.h>
67
68// Forward declarations for SpeexDSP types
69typedef struct SpeexPreprocessState_ SpeexPreprocessState;
70typedef struct JitterBuffer_ JitterBuffer;
71
72// Forward declarations for WebRTC types (opaque pointers for C compatibility)
74
75// Forward declarations for Opus types
76typedef struct OpusEncoder OpusEncoder;
77typedef struct OpusDecoder OpusDecoder;
78
79#ifdef __cplusplus
80extern "C" {
81#endif
82
109
114#define CLIENT_AUDIO_PIPELINE_FLAGS_ALL \
115 ((client_audio_pipeline_flags_t){ \
116 .echo_cancel = true, \
117 .noise_suppress = true, \
118 .agc = true, \
119 .vad = true, \
120 .jitter_buffer = true, \
121 .compressor = true, \
122 .noise_gate = true, \
123 .highpass = true, \
124 .lowpass = true, \
125 })
126
130#define CLIENT_AUDIO_PIPELINE_FLAGS_MINIMAL \
131 ((client_audio_pipeline_flags_t){ \
132 .echo_cancel = false, \
133 .noise_suppress = false, \
134 .agc = false, \
135 .vad = false, \
136 .jitter_buffer = false, \
137 .compressor = false, \
138 .noise_gate = false, \
139 .highpass = false, \
140 .lowpass = false, \
141 })
142
172
179
182
189typedef struct {
192
198
205
210
213
216
218 int16_t *work_i16;
220 int16_t *echo_i16;
223
224 // No mutex needed - full-duplex means single callback thread handles all AEC3
225
228
231
233 void *debug_wav_aec3_in; // Microphone input before AEC3
234 void *debug_wav_aec3_out; // Microphone output after AEC3
235
240 void *aec3_render_buffer; // Persistent render AudioBuffer
241 void *aec3_capture_buffer; // Persistent capture AudioBuffer
243
249
259
268
270
275
284
291
293
298
319int client_audio_pipeline_capture(client_audio_pipeline_t *pipeline, const float *input, int num_samples,
320 uint8_t *opus_out, int opus_out_size);
321
323
328
347int client_audio_pipeline_playback(client_audio_pipeline_t *pipeline, const uint8_t *opus_in, int opus_len,
348 float *output, int max_samples);
349
360int client_audio_pipeline_get_playback_frame(client_audio_pipeline_t *pipeline, float *output, int num_samples);
361
363
368
388void client_audio_pipeline_process_duplex(client_audio_pipeline_t *pipeline, const float *render_samples,
389 int render_count, const float *capture_samples, int capture_count,
390 float *processed_output);
391
393
398
405
412
421
423
424#ifdef __cplusplus
425}
426#endif
struct SpeexPreprocessState_ SpeexPreprocessState
client_audio_pipeline_t * client_audio_pipeline_create(const client_audio_pipeline_config_t *config)
Create a new client audio pipeline.
void client_audio_pipeline_process_duplex(client_audio_pipeline_t *pipeline, const float *render_samples, int render_count, const float *capture_samples, int capture_count, float *processed_output)
Process AEC3 inline in full-duplex callback.
client_audio_pipeline_config_t client_audio_pipeline_config_for_source(bool has_media_audio)
client_audio_pipeline_flags_t client_audio_pipeline_get_flags(client_audio_pipeline_t *pipeline)
Get current component enable flags.
bool client_audio_pipeline_voice_detected(client_audio_pipeline_t *pipeline)
Check if VAD detected voice activity in last capture.
int client_audio_pipeline_jitter_margin(client_audio_pipeline_t *pipeline)
Get jitter buffer margin (buffered time in ms).
int client_audio_pipeline_get_playback_frame(client_audio_pipeline_t *pipeline, float *output, int num_samples)
Get audio frame from jitter buffer for playback callback.
client_audio_pipeline_config_t client_audio_pipeline_default_config(void)
Audio-pipeline setup for channel conversion, Opus encoding, echo handling, and preprocessing....
int client_audio_pipeline_playback(client_audio_pipeline_t *pipeline, const uint8_t *opus_in, int opus_len, float *output, int max_samples)
Decode Opus packet and process for playback.
struct webrtc_EchoCanceller3 webrtc_EchoCanceller3
void client_audio_pipeline_set_flags(client_audio_pipeline_t *pipeline, client_audio_pipeline_flags_t flags)
Set component enable flags.
void client_audio_pipeline_destroy(client_audio_pipeline_t *pipeline)
Destroy a client audio pipeline.
int client_audio_pipeline_capture(client_audio_pipeline_t *pipeline, const float *input, int num_samples, uint8_t *opus_out, int opus_out_size)
Process captured audio and encode to Opus.
struct JitterBuffer_ JitterBuffer
void client_audio_pipeline_reset(client_audio_pipeline_t *pipeline)
Reset pipeline state.
struct OpusDecoder OpusDecoder
struct OpusEncoder OpusEncoder
unsigned int uint32_t
Definition common.h:62
unsigned long long uint64_t
Definition common.h:63
unsigned char uint8_t
Definition common.h:60
Multi-Source Audio Mixing and Processing System.
struct audio_processor audio_processor_t
Definition processor.h:13
Pipeline configuration parameters.
int encoder_channels
Transmitted channels, independent of playback.
audio_processor_config_t processor
client_audio_pipeline_flags_t flags
int channels
PCM channels (1 or 2).
Component enable/disable flags.
Client audio pipeline state.
client_audio_pipeline_config_t config
audio_processor_t * processor
client_audio_pipeline_flags_t flags
SpeexPreprocessState * preprocess