webrtc-delay-estimation
webrtc-delay-estimation copied to clipboard
Delay estimation logic extracted from WebRTC
webrtc-delay-estimation
Delay estimation logic extracted from WebRTC.
How to build
This repository uses CMake to automate cross-platform builds. If it fails to build, please create an issue with the following informations:
- CMake version
- Platform (operating system with CPU architecture)
- Compiler name and version
- Error message produced by CMake
On Windows
- Install Visual Studio and CMake. For Visual Studio 2017 and newer, instead of installing CMake by yourself, you can install a Visual Studio component called
Visual C++ Tools for CMake, which greatly simplifies the process. If you are using an older version of Visual Studio, install standalone CMake.

- Clone this repository with submodules.
git clone --recurse-submodules https://github.com/RangHo/webrtc-delay-estimation
VS2017 or newer
- You can open the project by clicking File > Open > Folder in Visual Studio, and selecting the
webrtc-delay-estimationfolder you just cloned. Visual Studio should recognizeCMakeLists.txtautomatically. You can build the project as if it is a regular Visual Studio project.
VS2015 or older
- For older versions of Visual Studio, you need to use CMake command line to generate project files. Generate
.vcxprojfiles using the following command. Replace<generator>with the name of Visual Studio generator matching the version of Visual Studio you are using.
mkdir build
cd build
cmake -G "<generator>" ..
- Open the
.slnfile CMake created, and build the solution.
On macOS and Linux (and any other POSIX systems)
- Install CMake. For most distributions, there should be a package for your default package manager.
# Ubuntu
sudo apt-get install cmake
# Arch Linux
sudo pacman -S cmake
# Homebrew
brew install cmake
- Clone the repository and
cdinto it.
git clone --recurse-submodules https://github.com/RangHo/webrtc-delay-estimation
cd webrtc-delay-estimation
- Create a build directory and build.
mkdir build && cd build
cmake ..
cmake --build . --target webrtc-delay-estimation
How to use
This repository provides 3 CMake targets as follows:
webrtc-delay-estimation: A static library exposing delay estimation function as declared ininclude/webrtc-delay-estimation.hdelay-estimator: An executable that uses the library above to estimate delay in between two WAV fileswebrtc-delay-estimation-tests: A testing executable that generates random samples and tries to estimate delay using them
webrtc-delay-estimation library
This library exposes the extracted WebRTC components and an additional helper function. By default, linking this library using CMake's target_link_libraries directive includes definition for the helper function only. To access raw WebRTC components, copy the relevant .h files from src/ directory.
Example CMakeLists.txt file would look like:
add_executable (my-executable
"main.cc"
# ...
)
target_link_libraries (my-executable PRIVATE
webrtc-delay-estimation
)
delay-estimator binary
This command line utility uses webrtc-delay-estimation library above to find delay from two different WAV files. Unless given a -v switch, the program will write the estimated delay in samples to stdout. It takes two positional arguments: render and capture. The former is the WAV file of the far end, and the latter is the WAV file captured by the local microphone.
Usage
delay-estimator [-hv] [-f integer] [-d {2,4,8}] /path/to/render /path/to/capture
Argument information
- (required, positional)
/path/to/render: path to the render WAV file. - (required, positional)
/path/to/capture: path to the capture WAV file. - (optional)
-hor--help: displays help message. - (optional)
-vor--verbose: show additional information when executing the program. - (optional)
-f integeror--filter integer: Useintegernumber of filters when estimating delay. (default: 10) - (optional)
-d {2,4,8}or--downsampling-factor {2,4,8}: sets the down sampling factor. The factor can be either 2, 4, or 8. (default: 8)
webrtc-delay-estimation-tests binary
This target builds a testing binary using Catch2 testing framework. Build and run the binary to test the functionality of the library.
# You can run the binary directly
cd build/tests
./webrtc-delay-estimation-tests
# ... or you can just use ctest to automate things
ctest