}
pa_bool_t pa_webrtc_ec_init(pa_core *c, pa_echo_canceller *ec,
- pa_sample_spec *source_ss, pa_channel_map *source_map,
- pa_sample_spec *sink_ss, pa_channel_map *sink_map,
- uint32_t *blocksize, const char *args)
-{
+ pa_sample_spec *rec_ss, pa_channel_map *rec_map,
+ pa_sample_spec *play_ss, pa_channel_map *play_map,
+ pa_sample_spec *out_ss, pa_channel_map *out_map,
+ uint32_t *nframes, const char *args) {
webrtc::AudioProcessing *apm = NULL;
pa_bool_t hpf, ns, agc, dgc, mobile, cn;
int rm = -1;
goto fail;
}
-
hpf = DEFAULT_HIGH_PASS_FILTER;
if (pa_modargs_get_value_boolean(ma, "high_pass_filter", &hpf) < 0) {
pa_log("Failed to parse high_pass_filter value");
apm = webrtc::AudioProcessing::Create(0);
- source_ss->format = PA_SAMPLE_S16NE;
- *sink_ss = *source_ss;
+ out_ss->format = PA_SAMPLE_S16NE;
+ *play_ss = *out_ss;
/* FIXME: the implementation actually allows a different number of
* source/sink channels. Do we want to support that? */
- *sink_map = *source_map;
+ *play_map = *out_map;
+ *rec_ss = *out_ss;
+ *rec_map = *out_map;
- apm->set_sample_rate_hz(source_ss->rate);
+ apm->set_sample_rate_hz(out_ss->rate);
- apm->set_num_channels(source_ss->channels, source_ss->channels);
- apm->set_num_reverse_channels(sink_ss->channels);
+ apm->set_num_channels(out_ss->channels, out_ss->channels);
+ apm->set_num_reverse_channels(play_ss->channels);
if (hpf)
apm->high_pass_filter()->Enable(true);
if (!mobile) {
if (ec->params.drift_compensation) {
- apm->echo_cancellation()->set_device_sample_rate_hz(source_ss->rate);
+ apm->echo_cancellation()->set_device_sample_rate_hz(out_ss->rate);
apm->echo_cancellation()->enable_drift_compensation(true);
} else {
apm->echo_cancellation()->enable_drift_compensation(false);
apm->voice_detection()->Enable(true);
ec->params.priv.webrtc.apm = apm;
- ec->params.priv.webrtc.sample_spec = *source_ss;
- ec->params.priv.webrtc.blocksize = *blocksize = (uint64_t)pa_bytes_per_second(source_ss) * BLOCK_SIZE_US / PA_USEC_PER_SEC;
+ ec->params.priv.webrtc.sample_spec = *out_ss;
+ ec->params.priv.webrtc.blocksize = (uint64_t)pa_bytes_per_second(out_ss) * BLOCK_SIZE_US / PA_USEC_PER_SEC;
+ *nframes = ec->params.priv.webrtc.blocksize / pa_frame_size(out_ss);
pa_modargs_free(ma);
return TRUE;