mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
echo-cancel: Plug in WebRTC drift compensation
This adds the ability for echo cancellers to provide their own drift compensation, and hooks in the appropriate bits to implement this in the WebRTC canceller. We do this by introducing an alternative model for the canceller. So far, the core engine just provided a run() method which was given blocksize-sized chunks of playback and record samples. The new model has the engine provide play() and record() methods that can (in theory) be called by the playback and capture threads. The latter would actually do the processing required. In addition to this a set_drift() method may be provided by the implementation. PA will provide periodic samples of the drift to the engine. These values need to be aggregated and processed over some time, since the point values vary quite a bit (but generally fit a linear regression reasonably accurately). At some point of time, we might move the actual drift calculation into PA and change the semantics of this function. NOTE: This needs further testing before being deemed ready for wider use.
This commit is contained in:
parent
8c0cca7905
commit
23ce9a4f79
3 changed files with 250 additions and 68 deletions
|
|
@ -60,11 +60,16 @@ struct pa_echo_canceller_params {
|
|||
#endif
|
||||
/* each canceller-specific structure goes here */
|
||||
} priv;
|
||||
|
||||
/* Set this if canceller can do drift compensation. Also see set_drift()
|
||||
* below */
|
||||
pa_bool_t drift_compensation;
|
||||
};
|
||||
|
||||
typedef struct pa_echo_canceller pa_echo_canceller;
|
||||
|
||||
struct pa_echo_canceller {
|
||||
/* Initialise canceller engine. */
|
||||
pa_bool_t (*init) (pa_core *c,
|
||||
pa_echo_canceller *ec,
|
||||
pa_sample_spec *source_ss,
|
||||
|
|
@ -73,9 +78,36 @@ struct pa_echo_canceller {
|
|||
pa_channel_map *sink_map,
|
||||
uint32_t *blocksize,
|
||||
const char *args);
|
||||
|
||||
/* You should have only one of play()+record() or run() set. The first
|
||||
* works under the assumption that you'll handle buffering and matching up
|
||||
* samples yourself. If you set run(), module-echo-cancel will handle
|
||||
* synchronising the playback and record streams. */
|
||||
|
||||
/* Feed the engine 'blocksize' playback bytes.. */
|
||||
void (*play) (pa_echo_canceller *ec, const uint8_t *play);
|
||||
/* Feed the engine 'blocksize' record bytes. blocksize processed bytes are
|
||||
* returned in out. */
|
||||
void (*record) (pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out);
|
||||
/* Feed the engine blocksize playback and record streams, with a reasonable
|
||||
* effort at keeping the two in sync. blocksize processed bytes are
|
||||
* returned in out. */
|
||||
void (*run) (pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *play, uint8_t *out);
|
||||
|
||||
/* Optional callback to set the drift, expressed as the ratio of the
|
||||
* difference in number of playback and capture samples to the number of
|
||||
* capture samples, for some instant of time. This is used only if the
|
||||
* canceller signals that it supports drift compensation, and is called
|
||||
* before record(). The actual implementation needs to derive drift based
|
||||
* on point samples -- the individual values are not accurate enough to use
|
||||
* as-is. */
|
||||
/* NOTE: the semantics of this function might change in the future. */
|
||||
void (*set_drift) (pa_echo_canceller *ec, float drift);
|
||||
|
||||
/* Free up resources. */
|
||||
void (*done) (pa_echo_canceller *ec);
|
||||
|
||||
/* Structure with common and engine-specific canceller parameters. */
|
||||
pa_echo_canceller_params params;
|
||||
};
|
||||
|
||||
|
|
@ -102,6 +134,9 @@ 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);
|
||||
void pa_webrtc_ec_play(pa_echo_canceller *ec, const uint8_t *play);
|
||||
void pa_webrtc_ec_record(pa_echo_canceller *ec, const uint8_t *rec, uint8_t *out);
|
||||
void pa_webrtc_ec_set_drift(pa_echo_canceller *ec, float drift);
|
||||
void pa_webrtc_ec_run(pa_echo_canceller *ec, const uint8_t *rec, const uint8_t *play, uint8_t *out);
|
||||
void pa_webrtc_ec_done(pa_echo_canceller *ec);
|
||||
PA_C_DECL_END
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue