mirror of
https://github.com/mollyim/ringrtc.git
synced 2025-05-12 21:30:36 +01:00
Implement ADM using cubeb
This commit is contained in:
parent
cc66bb1040
commit
292ea7ad30
11 changed files with 1226 additions and 118 deletions
14
.github/workflows/ringrtc.yml
vendored
14
.github/workflows/ringrtc.yml
vendored
|
@ -26,6 +26,8 @@ jobs:
|
|||
steps:
|
||||
- name: Install protoc
|
||||
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
|
||||
- name: Install cmake
|
||||
run: sudo apt-get update && sudo apt-get install -y cmake
|
||||
- name: Install Python tools
|
||||
run: pip3 install flake8 mypy
|
||||
- uses: actions/checkout@v4
|
||||
|
@ -92,6 +94,8 @@ jobs:
|
|||
steps:
|
||||
- name: Install protoc
|
||||
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
|
||||
- name: Install cmake
|
||||
run: sudo apt-get update && sudo apt-get install -y cmake
|
||||
- uses: actions/checkout@v4
|
||||
- run: rustup toolchain install $(cat rust-toolchain) --profile minimal
|
||||
- name: Run rust tests
|
||||
|
@ -105,12 +109,12 @@ jobs:
|
|||
os: [ubuntu-latest, windows-latest, macos-13]
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
install-deps: sudo apt-get update && sudo apt-get install -y protobuf-compiler
|
||||
install-deps: sudo apt-get update && sudo apt-get install -y protobuf-compiler cmake
|
||||
test-runner: xvfb-run --auto-servernum
|
||||
- os: windows-latest
|
||||
install-deps: choco install protoc
|
||||
install-deps: choco install protoc cmake
|
||||
- os: macos-13
|
||||
install-deps: brew install protobuf coreutils
|
||||
install-deps: brew install protobuf coreutils cmake
|
||||
runs-on: ${{ matrix.os }}
|
||||
defaults:
|
||||
run:
|
||||
|
@ -140,9 +144,9 @@ jobs:
|
|||
os: [ubuntu-latest, macos-13]
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
install-deps: sudo apt-get update && sudo apt-get install -y protobuf-compiler
|
||||
install-deps: sudo apt-get update && sudo apt-get install -y protobuf-compiler cmake
|
||||
- os: macos-13
|
||||
install-deps: brew install protobuf coreutils
|
||||
install-deps: brew install protobuf coreutils cmake
|
||||
runs-on: ${{ matrix.os }}
|
||||
defaults:
|
||||
run:
|
||||
|
|
11
BUILDING.md
11
BUILDING.md
|
@ -26,6 +26,17 @@ Install rustup, the Rust management system:
|
|||
|
||||
We use a pinned nightly toolchain for official builds, specified by our [rust-toolchain file](https://github.com/signalapp/ringrtc/blob/master/rust-toolchain) ([more information](https://rust-lang.github.io/rustup/overrides.html)).
|
||||
|
||||
|
||||
### cmake
|
||||
|
||||
For Desktop builds, one of ringrtc's dependencies relies on `cmake` being
|
||||
available. This can be installed via some package managers, such as:
|
||||
|
||||
brew install cmake # MacOS dev machine
|
||||
|
||||
If it is not available in your system's package manger, see
|
||||
https://cmake.org/download/.
|
||||
|
||||
#### Android
|
||||
|
||||
Install Rust target support for Android via `rustup`:
|
||||
|
|
116
Cargo.lock
generated
116
Cargo.lock
generated
|
@ -352,7 +352,7 @@ version = "0.69.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 2.6.0",
|
||||
"cexpr",
|
||||
"clang-sys",
|
||||
"itertools",
|
||||
|
@ -369,6 +369,12 @@ dependencies = [
|
|||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.6.0"
|
||||
|
@ -749,6 +755,35 @@ dependencies = [
|
|||
"cipher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cubeb"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46141374032595c0fa92563b6ff21c2fef695c4e932ab1a35d8726d78b35255d"
|
||||
dependencies = [
|
||||
"cubeb-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cubeb-core"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e9d9d5a70e005de5a7ca350d973822702244af08c0e0720112641a799d8be4c"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"cubeb-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cubeb-sys"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "192cd49cc8485ceb2b9d82ba7ca583af01b9b0a9251f4128550d154b06702c6e"
|
||||
dependencies = [
|
||||
"cmake",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "curve25519-dalek"
|
||||
version = "4.1.3"
|
||||
|
@ -1563,7 +1598,7 @@ version = "0.1.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 2.6.0",
|
||||
"libc",
|
||||
]
|
||||
|
||||
|
@ -2236,6 +2271,8 @@ dependencies = [
|
|||
"chrono",
|
||||
"clap",
|
||||
"ctr",
|
||||
"cubeb",
|
||||
"cubeb-core",
|
||||
"env_logger",
|
||||
"fern",
|
||||
"futures",
|
||||
|
@ -2271,6 +2308,7 @@ dependencies = [
|
|||
"tower",
|
||||
"ureq",
|
||||
"uuid",
|
||||
"windows 0.58.0",
|
||||
"x25519-dalek",
|
||||
"zkgroup",
|
||||
]
|
||||
|
@ -2302,7 +2340,7 @@ version = "0.38.34"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 2.6.0",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
|
@ -2624,7 +2662,7 @@ dependencies = [
|
|||
"libc",
|
||||
"memchr",
|
||||
"ntapi",
|
||||
"windows",
|
||||
"windows 0.57.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3153,6 +3191,16 @@ dependencies = [
|
|||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows"
|
||||
version = "0.58.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6"
|
||||
dependencies = [
|
||||
"windows-core 0.58.0",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.52.0"
|
||||
|
@ -3168,9 +3216,22 @@ version = "0.57.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2ed2439a290666cd67ecce2b0ffaad89c2a56b976b736e6ece670297897832d"
|
||||
dependencies = [
|
||||
"windows-implement",
|
||||
"windows-interface",
|
||||
"windows-result",
|
||||
"windows-implement 0.57.0",
|
||||
"windows-interface 0.57.0",
|
||||
"windows-result 0.1.2",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.58.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
|
||||
dependencies = [
|
||||
"windows-implement 0.58.0",
|
||||
"windows-interface 0.58.0",
|
||||
"windows-result 0.2.0",
|
||||
"windows-strings",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
|
@ -3185,6 +3246,17 @@ dependencies = [
|
|||
"syn 2.0.71",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-implement"
|
||||
version = "0.58.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.71",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-interface"
|
||||
version = "0.57.0"
|
||||
|
@ -3196,6 +3268,17 @@ dependencies = [
|
|||
"syn 2.0.71",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-interface"
|
||||
version = "0.58.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.71",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-result"
|
||||
version = "0.1.2"
|
||||
|
@ -3205,6 +3288,25 @@ dependencies = [
|
|||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-result"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e"
|
||||
dependencies = [
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-strings"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
|
||||
dependencies = [
|
||||
"windows-result 0.2.0",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.45.0"
|
||||
|
|
|
@ -45,11 +45,11 @@
|
|||
|
||||
<h2>Overview of licenses:</h2>
|
||||
<ul class="licenses-overview">
|
||||
<li><a href="#MIT">MIT License</a> (147)</li>
|
||||
<li><a href="#MIT">MIT License</a> (157)</li>
|
||||
<li><a href="#AGPL-3.0">GNU Affero General Public License v3.0</a> (11)</li>
|
||||
<li><a href="#Apache-2.0">Apache License 2.0</a> (5)</li>
|
||||
<li><a href="#BSD-3-Clause">BSD 3-Clause "New" or "Revised" License</a> (4)</li>
|
||||
<li><a href="#ISC">ISC License</a> (1)</li>
|
||||
<li><a href="#ISC">ISC License</a> (4)</li>
|
||||
<li><a href="#Unicode-DFS-2016">Unicode License Agreement - Data Files and Software (2016)</a> (1)</li>
|
||||
</ul>
|
||||
|
||||
|
@ -1534,6 +1534,29 @@ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR
|
|||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
THIS SOFTWARE.
|
||||
</pre>
|
||||
</li>
|
||||
<li class="license">
|
||||
<h3 id="ISC">ISC License</h3>
|
||||
<h4>Used by:</h4>
|
||||
<ul class="license-used-by">
|
||||
<li><a href="https://github.com/mozilla/cubeb-rs">cubeb-core 0.14.0</a></li>
|
||||
<li><a href="https://github.com/mozilla/cubeb-rs">cubeb-sys 0.14.0</a></li>
|
||||
<li><a href="https://github.com/mozilla/cubeb-rs">cubeb 0.14.0</a></li>
|
||||
</ul>
|
||||
<pre class="license-text">Copyright © 2017 Mozilla Foundation
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
</pre>
|
||||
</li>
|
||||
<li class="license">
|
||||
|
@ -1709,7 +1732,10 @@ SOFTWARE.
|
|||
<h3 id="MIT">MIT License</h3>
|
||||
<h4>Used by:</h4>
|
||||
<ul class="license-used-by">
|
||||
<li><a href="https://github.com/rust-lang/cc-rs">cc 1.1.5</a></li>
|
||||
<li><a href="https://github.com/alexcrichton/cfg-if">cfg-if 1.0.0</a></li>
|
||||
<li><a href="https://github.com/rust-lang/cmake-rs">cmake 0.1.50</a></li>
|
||||
<li><a href="https://github.com/rust-lang/pkg-config-rs">pkg-config 0.3.30</a></li>
|
||||
</ul>
|
||||
<pre class="license-text">Copyright (c) 2014 Alex Crichton
|
||||
|
||||
|
@ -1775,6 +1801,7 @@ DEALINGS IN THE SOFTWARE.
|
|||
<h3 id="MIT">MIT License</h3>
|
||||
<h4>Used by:</h4>
|
||||
<ul class="license-used-by">
|
||||
<li><a href="https://github.com/bitflags/bitflags">bitflags 1.3.2</a></li>
|
||||
<li><a href="https://github.com/bitflags/bitflags">bitflags 2.6.0</a></li>
|
||||
<li><a href="https://github.com/rust-lang/log">log 0.4.22</a></li>
|
||||
<li><a href="https://github.com/rust-lang/regex/tree/master/regex-automata">regex-automata 0.4.7</a></li>
|
||||
|
@ -3346,10 +3373,16 @@ SOFTWARE.
|
|||
<li><a href="https://github.com/emk/cesu8-rs">cesu8 1.1.0</a></li>
|
||||
<li><a href="https://github.com/neon-bindings/neon">neon 1.0.0</a></li>
|
||||
<li><a href="https://github.com/microsoft/windows-rs">windows-core 0.57.0</a></li>
|
||||
<li><a href="https://github.com/microsoft/windows-rs">windows-core 0.58.0</a></li>
|
||||
<li><a href="https://github.com/microsoft/windows-rs">windows-implement 0.57.0</a></li>
|
||||
<li><a href="https://github.com/microsoft/windows-rs">windows-implement 0.58.0</a></li>
|
||||
<li><a href="https://github.com/microsoft/windows-rs">windows-interface 0.57.0</a></li>
|
||||
<li><a href="https://github.com/microsoft/windows-rs">windows-interface 0.58.0</a></li>
|
||||
<li><a href="https://github.com/microsoft/windows-rs">windows-result 0.1.2</a></li>
|
||||
<li><a href="https://github.com/microsoft/windows-rs">windows-result 0.2.0</a></li>
|
||||
<li><a href="https://github.com/microsoft/windows-rs">windows-strings 0.1.0</a></li>
|
||||
<li><a href="https://github.com/microsoft/windows-rs">windows 0.57.0</a></li>
|
||||
<li><a href="https://github.com/microsoft/windows-rs">windows 0.58.0</a></li>
|
||||
</ul>
|
||||
<pre class="license-text">MIT License
|
||||
|
||||
|
|
|
@ -1453,6 +1453,25 @@ THIS SOFTWARE.
|
|||
|
||||
```
|
||||
|
||||
## cubeb-core 0.14.0, cubeb-sys 0.14.0, cubeb 0.14.0
|
||||
|
||||
```
|
||||
Copyright © 2017 Mozilla Foundation
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
```
|
||||
|
||||
## windows-sys 0.45.0, windows-sys 0.52.0, windows-targets 0.42.2, windows-targets 0.52.6, windows_aarch64_msvc 0.42.2, windows_aarch64_msvc 0.52.6, windows_x86_64_gnu 0.52.6, windows_x86_64_msvc 0.42.2, windows_x86_64_msvc 0.52.6
|
||||
|
||||
```
|
||||
|
@ -1601,7 +1620,7 @@ SOFTWARE.
|
|||
|
||||
```
|
||||
|
||||
## cfg-if 1.0.0
|
||||
## cc 1.1.5, cfg-if 1.0.0, cmake 0.1.50, pkg-config 0.3.30
|
||||
|
||||
```
|
||||
Copyright (c) 2014 Alex Crichton
|
||||
|
@ -1663,7 +1682,7 @@ DEALINGS IN THE SOFTWARE.
|
|||
|
||||
```
|
||||
|
||||
## bitflags 2.6.0, log 0.4.22, regex-automata 0.4.7, regex-syntax 0.8.4, regex 1.10.5
|
||||
## bitflags 1.3.2, bitflags 2.6.0, log 0.4.22, regex-automata 0.4.7, regex-syntax 0.8.4, regex 1.10.5
|
||||
|
||||
```
|
||||
Copyright (c) 2014 The Rust Project Developers
|
||||
|
@ -3110,7 +3129,7 @@ SOFTWARE.
|
|||
|
||||
```
|
||||
|
||||
## cesu8 1.1.0, neon 1.0.0, windows-core 0.57.0, windows-implement 0.57.0, windows-interface 0.57.0, windows-result 0.1.2, windows 0.57.0
|
||||
## cesu8 1.1.0, neon 1.0.0, windows-core 0.57.0, windows-core 0.58.0, windows-implement 0.57.0, windows-implement 0.58.0, windows-interface 0.57.0, windows-interface 0.58.0, windows-result 0.1.2, windows-result 0.2.0, windows-strings 0.1.0, windows 0.57.0, windows 0.58.0
|
||||
|
||||
```
|
||||
MIT License
|
||||
|
|
|
@ -1499,6 +1499,29 @@ THIS SOFTWARE.
|
|||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>FooterText</key>
|
||||
<string>Copyright © 2017 Mozilla Foundation
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
</string>
|
||||
<key>License</key>
|
||||
<string>ISC License</string>
|
||||
<key>Title</key>
|
||||
<string>cubeb-core 0.14.0, cubeb-sys 0.14.0, cubeb 0.14.0</string>
|
||||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>FooterText</key>
|
||||
<string> MIT License
|
||||
|
@ -1698,7 +1721,7 @@ DEALINGS IN THE SOFTWARE.
|
|||
<key>License</key>
|
||||
<string>MIT License</string>
|
||||
<key>Title</key>
|
||||
<string>cfg-if 1.0.0</string>
|
||||
<string>cc 1.1.5, cfg-if 1.0.0, cmake 0.1.50, pkg-config 0.3.30</string>
|
||||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
|
@ -1768,7 +1791,7 @@ DEALINGS IN THE SOFTWARE.
|
|||
<key>License</key>
|
||||
<string>MIT License</string>
|
||||
<key>Title</key>
|
||||
<string>bitflags 2.6.0, log 0.4.22, regex-automata 0.4.7, regex-syntax 0.8.4, regex 1.10.5</string>
|
||||
<string>bitflags 1.3.2, bitflags 2.6.0, log 0.4.22, regex-automata 0.4.7, regex-syntax 0.8.4, regex 1.10.5</string>
|
||||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
|
@ -3391,7 +3414,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRES
|
|||
<key>License</key>
|
||||
<string>MIT License</string>
|
||||
<key>Title</key>
|
||||
<string>cesu8 1.1.0, neon 1.0.0, windows-core 0.57.0, windows-implement 0.57.0, windows-interface 0.57.0, windows-result 0.1.2, windows 0.57.0</string>
|
||||
<string>cesu8 1.1.0, neon 1.0.0, windows-core 0.57.0, windows-core 0.58.0, windows-implement 0.57.0, windows-implement 0.58.0, windows-interface 0.57.0, windows-interface 0.58.0, windows-result 0.1.2, windows-result 0.2.0, windows-strings 0.1.0, windows 0.57.0, windows 0.58.0</string>
|
||||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
|
|
|
@ -94,6 +94,12 @@ chrono = {version = "0.4.38", optional = true }
|
|||
call_protobuf = { path = "../../protobuf", package = "protobuf"}
|
||||
mrp = { path = "../../mrp" }
|
||||
|
||||
# Optional, needed by "native" feature
|
||||
cubeb = { version = "0.14.0", optional = true }
|
||||
cubeb-core = { version = "0.14.0", optional = true }
|
||||
# Only needed by native feature on windows
|
||||
windows = { version = "0.58.0", optional = true, features = ["Win32_System_Com"] }
|
||||
|
||||
[target.'cfg(not(target_os="android"))'.dependencies]
|
||||
# sysinfo depends on getgrgid_r, which was added in Android API level 24
|
||||
sysinfo = { version = "0.31.2", default-features = false, features = ["system"] }
|
||||
|
@ -102,7 +108,7 @@ sysinfo = { version = "0.31.2", default-features = false, features = ["system"]
|
|||
default = []
|
||||
sim = []
|
||||
electron = ["neon", "native"]
|
||||
native = []
|
||||
native = ["cubeb", "cubeb-core", "windows"]
|
||||
prebuilt_webrtc = ["native"]
|
||||
simnet = ["injectable_network"]
|
||||
injectable_network = []
|
||||
|
|
|
@ -91,6 +91,8 @@ pub mod webrtc {
|
|||
pub use arc::Arc;
|
||||
#[cfg(all(not(feature = "sim"), feature = "native"))]
|
||||
pub mod audio_device_module;
|
||||
#[cfg(all(not(feature = "sim"), feature = "native"))]
|
||||
pub mod audio_device_module_utils;
|
||||
pub mod field_trial;
|
||||
pub mod ice_gatherer;
|
||||
#[cfg(feature = "injectable_network")]
|
||||
|
|
File diff suppressed because it is too large
Load diff
201
src/rust/src/webrtc/audio_device_module_utils.rs
Normal file
201
src/rust/src/webrtc/audio_device_module_utils.rs
Normal file
|
@ -0,0 +1,201 @@
|
|||
//
|
||||
// Copyright 2024 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
//! Utility functions for audio_device_module.rs
|
||||
//! Nothing in here should depend on webrtc directly.
|
||||
|
||||
use crate::webrtc;
|
||||
use anyhow::anyhow;
|
||||
use cubeb::{DeviceCollection, DeviceInfo, DeviceState};
|
||||
use cubeb_core::DevicePref;
|
||||
use std::ffi::{c_uchar, CString};
|
||||
|
||||
/// Wrapper struct for DeviceCollection that handles default devices.
|
||||
pub struct DeviceCollectionWrapper<'a> {
|
||||
device_collection: DeviceCollection<'a>,
|
||||
}
|
||||
|
||||
impl DeviceCollectionWrapper<'_> {
|
||||
pub fn new(device_collection: DeviceCollection<'_>) -> DeviceCollectionWrapper<'_> {
|
||||
DeviceCollectionWrapper { device_collection }
|
||||
}
|
||||
|
||||
/// Iterate over all Enabled devices (those that are plugged in and not disabled by the OS)
|
||||
pub fn iter(
|
||||
&self,
|
||||
) -> std::iter::Filter<std::slice::Iter<'_, DeviceInfo>, fn(&&DeviceInfo) -> bool> {
|
||||
self.device_collection
|
||||
.iter()
|
||||
.filter(|d| d.state() == DeviceState::Enabled)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
/// Get a specified device index, accounting for the two default devices.
|
||||
pub fn get(&self, idx: usize) -> Option<&DeviceInfo> {
|
||||
// 0 should be "default device" and 1 should be "default communications device".
|
||||
// Note: On windows, CUBEB_DEVICE_PREF_VOICE will be set for default communications device,
|
||||
// and CUBEB_DEVICE_PREF_MULTIMEDIA | CUBEB_DEVICE_PREF_NOTIFICATION for default device.
|
||||
// https://github.com/mozilla/cubeb/blob/bbbe5bb0b29ed64cc7dd191d7a72fe24bba0d284/src/cubeb_wasapi.cpp#L3322
|
||||
if self.count() == 0 {
|
||||
None
|
||||
} else if idx > 1 {
|
||||
self.iter().nth(idx - 2)
|
||||
} else if idx == 1 {
|
||||
// Find a device that's preferred for VOICE -- device 1 is the "default communications"
|
||||
self.iter()
|
||||
.find(|&device| device.preferred().contains(DevicePref::VOICE))
|
||||
} else {
|
||||
// Find a device that's preferred for MULTIMEDIA -- device 0 is the "default"
|
||||
self.iter()
|
||||
.find(|&device| device.preferred().contains(DevicePref::MULTIMEDIA))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
/// Get a specified device index, accounting for the default device.
|
||||
pub fn get(&self, idx: usize) -> Option<&DeviceInfo> {
|
||||
if self.count() == 0 {
|
||||
None
|
||||
} else if idx > 0 {
|
||||
self.iter().nth(idx - 1)
|
||||
} else {
|
||||
// Find a device that's preferred for VOICE -- device 0 is the "default"
|
||||
self.iter()
|
||||
.find(|&device| device.preferred().contains(DevicePref::VOICE))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
/// Returns the number of devices.
|
||||
/// Note: On Windows, this is 2 smaller than the number of addressable
|
||||
/// devices, because the default device and default communications device
|
||||
/// are not counted.
|
||||
pub fn count(&self) -> usize {
|
||||
self.iter().count()
|
||||
}
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
/// Returns the number of devices, counting the default device.
|
||||
pub fn count(&self) -> usize {
|
||||
let count = self.iter().count();
|
||||
if count == 0 {
|
||||
0
|
||||
} else {
|
||||
count + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Copy from |src| into |dest| at most |dest_size| - 1 bytes and write a nul terminator either after |src| or at the end of |dest_size|
|
||||
pub fn copy_and_truncate_string(
|
||||
src: &str,
|
||||
dest: webrtc::ptr::Borrowed<c_uchar>,
|
||||
dest_size: usize,
|
||||
) -> anyhow::Result<()> {
|
||||
// Leave room for the nul terminator.
|
||||
let size = std::cmp::min(src.len(), dest_size - 1);
|
||||
let c_str = CString::new(src.get(0..size).ok_or(anyhow!("couldn't get substring"))?)?;
|
||||
let c_str_bytes = c_str.as_bytes_with_nul();
|
||||
// Safety: dest has at least |dest_size| bytes allocated, and we won't
|
||||
// write any more than that. In addition, we are copying from a slice that
|
||||
// includes the nul-terminator, and we are not copying beyond the end of that
|
||||
// slice.
|
||||
unsafe {
|
||||
std::ptr::copy(
|
||||
c_str_bytes.as_ptr(),
|
||||
std::ptr::from_mut(
|
||||
dest.as_mut()
|
||||
.ok_or(anyhow!("couldn't get mutable pointer"))?,
|
||||
),
|
||||
c_str_bytes.len(),
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod audio_device_module_tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
// Verify that extremely long strings are properly truncated and
|
||||
// nul-terminated
|
||||
fn copy_and_truncate_long_string() {
|
||||
let data = vec![0xaau8; 10];
|
||||
let src = String::from_iter(['A'; 20]); // longer than data
|
||||
let out = webrtc::ptr::Borrowed::from_ptr(data.as_ptr());
|
||||
copy_and_truncate_string(&src, out, data.len()).unwrap();
|
||||
let mut expected = vec![0x41u8; 9]; // 'A'
|
||||
expected.push(0);
|
||||
assert_eq!(data, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
// Ensure that we do not read past the end of `src`
|
||||
fn copy_and_truncate_short_string() {
|
||||
let data = vec![0xaau8; 10];
|
||||
let src = String::from_iter(['A'; 4]); // shorter than data
|
||||
let out = webrtc::ptr::Borrowed::from_ptr(data.as_ptr());
|
||||
copy_and_truncate_string(&src, out, data.len()).unwrap();
|
||||
let expected = vec![0x41u8, 0x41, 0x41, 0x41, 0x0, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa];
|
||||
assert_eq!(data, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
// Check for off-by-one errors
|
||||
fn copy_and_truncate_max_len_string() {
|
||||
let data = vec![0xaau8; 10];
|
||||
let src = String::from_iter(['A'; 10]); // equal length to data
|
||||
let out = webrtc::ptr::Borrowed::from_ptr(data.as_ptr());
|
||||
copy_and_truncate_string(&src, out, data.len()).unwrap();
|
||||
let mut expected = vec![0x41u8; 9]; // 'A'
|
||||
expected.push(0);
|
||||
assert_eq!(data, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
// Check for off-by-one errors
|
||||
fn copy_and_truncate_barely_short_string() {
|
||||
let data = vec![0xaau8; 10];
|
||||
let src = String::from_iter(['A'; 9]); // one shorter than data
|
||||
let out = webrtc::ptr::Borrowed::from_ptr(data.as_ptr());
|
||||
copy_and_truncate_string(&src, out, data.len()).unwrap();
|
||||
let mut expected = vec![0x41u8; 9]; // 'A'
|
||||
expected.push(0);
|
||||
assert_eq!(data, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
// Check for overwrite errors
|
||||
fn copy_no_overwrite() {
|
||||
let data = vec![0xaau8; 10];
|
||||
let src = String::from_iter(['A'; 20]); // longer than data
|
||||
let out = webrtc::ptr::Borrowed::from_ptr(data.as_ptr());
|
||||
// State that data has one fewer byte than it actually does to make sure
|
||||
// the function doesn't write past the end.
|
||||
copy_and_truncate_string(&src, out, data.len() - 1).unwrap();
|
||||
let mut expected = vec![0x41u8; 8]; // 'A'
|
||||
expected.push(0);
|
||||
expected.push(0xaa);
|
||||
assert_eq!(data, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
// Verify that a string with internal nul characters is handled gracefully.
|
||||
fn string_with_nuls() {
|
||||
let data = vec![0xaau8; 10];
|
||||
let src = "a\0b";
|
||||
let out = webrtc::ptr::Borrowed::from_ptr(data.as_ptr());
|
||||
assert!(copy_and_truncate_string(src, out, data.len() - 1).is_err());
|
||||
// data should be untouched
|
||||
assert_eq!(data, vec![0xaau8; 10]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
// Verify that a null dest pointer is handled gracefully
|
||||
fn null_ptr() {
|
||||
let src = "AA";
|
||||
let out = webrtc::ptr::Borrowed::null();
|
||||
assert!(copy_and_truncate_string(src, out, 5).is_err());
|
||||
}
|
||||
}
|
|
@ -8,15 +8,17 @@
|
|||
use crate::webrtc;
|
||||
use crate::webrtc::audio_device_module::{AudioDeviceModule, AudioLayer, WindowsDeviceType};
|
||||
use libc::size_t;
|
||||
use std::ffi::c_void;
|
||||
use std::os::raw::c_char;
|
||||
use std::ffi::{c_uchar, c_void};
|
||||
|
||||
/// Incomplete type for C++ AudioTransport.
|
||||
#[repr(C)]
|
||||
/// Wrapper type for C++ AudioTransport.
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct RffiAudioTransport {
|
||||
_private: [u8; 0],
|
||||
pub callback: *const c_void,
|
||||
}
|
||||
|
||||
// Safety: managed by not allowing changes to the transport while playout or recording are in progress.
|
||||
unsafe impl Send for RffiAudioTransport {}
|
||||
|
||||
/// all_adm_functions is a higher-level macro that enables "tt muncher" macros
|
||||
/// The list of functions MUST be kept in sync with AudioDeviceCallbacks in webrtc C++, and
|
||||
/// in particular the order must match.
|
||||
|
@ -25,7 +27,7 @@ macro_rules! all_adm_functions {
|
|||
$macro!(
|
||||
active_audio_layer(audio_layer: webrtc::ptr::Borrowed<AudioLayer>) -> i32;
|
||||
|
||||
register_audio_callback(audio_callback: webrtc::ptr::Borrowed<RffiAudioTransport>) -> i32;
|
||||
register_audio_callback(audio_callback: *const c_void) -> i32;
|
||||
|
||||
// Main initialization and termination
|
||||
init() -> i32;
|
||||
|
@ -35,8 +37,8 @@ macro_rules! all_adm_functions {
|
|||
// Device enumeration
|
||||
playout_devices() -> i16;
|
||||
recording_devices() -> i16;
|
||||
playout_device_name(index: u16, name: webrtc::ptr::Borrowed<c_char>, guid: webrtc::ptr::Borrowed<c_char>) -> i32;
|
||||
recording_device_name(index: u16, name: webrtc::ptr::Borrowed<c_char>, guid: webrtc::ptr::Borrowed<c_char>) -> i32;
|
||||
playout_device_name(index: u16, name: webrtc::ptr::Borrowed<c_uchar>, guid: webrtc::ptr::Borrowed<c_uchar>) -> i32;
|
||||
recording_device_name(index: u16, name: webrtc::ptr::Borrowed<c_uchar>, guid: webrtc::ptr::Borrowed<c_uchar>) -> i32;
|
||||
|
||||
// Device selection
|
||||
set_playout_device(index: u16) -> i32;
|
||||
|
@ -136,7 +138,16 @@ macro_rules! adm_wrapper {
|
|||
() => {};
|
||||
($f:ident($($param:ident: $arg_ty:ty),*) -> $ret:ty ; $($t:tt)*) => {
|
||||
extern "C" fn $f(ptr: webrtc::ptr::Borrowed<AudioDeviceModule>, $($param: $arg_ty),*) -> $ret {
|
||||
debug!("{} wrapper", stringify!($f));
|
||||
// Safety: Safe as long as this function is only called from a single thread, which will
|
||||
// be the case.
|
||||
static mut LOG_COUNT: i32 = 0;
|
||||
unsafe {
|
||||
if LOG_COUNT % 100 == 0 {
|
||||
info!("{} wrapper", stringify!($f));
|
||||
LOG_COUNT = 0;
|
||||
}
|
||||
LOG_COUNT += 1;
|
||||
}
|
||||
if let Some(adm) = unsafe { ptr.as_mut() } {
|
||||
adm.$f($($param),*)
|
||||
} else {
|
||||
|
@ -208,7 +219,7 @@ pub const AUDIO_DEVICE_CBS_PTR: *const AudioDeviceCallbacks = &AUDIO_DEVICE_CBS;
|
|||
|
||||
extern "C" {
|
||||
pub fn Rust_recordedDataIsAvailable(
|
||||
audio_transport: webrtc::ptr::Borrowed<RffiAudioTransport>,
|
||||
audio_transport: *const c_void,
|
||||
audio_samples: *const c_void,
|
||||
n_samples: size_t,
|
||||
n_bytes_per_sample: size_t,
|
||||
|
@ -223,7 +234,7 @@ extern "C" {
|
|||
) -> i32;
|
||||
|
||||
pub fn Rust_needMorePlayData(
|
||||
audio_transport: webrtc::ptr::Borrowed<RffiAudioTransport>,
|
||||
audio_transport: *const c_void,
|
||||
n_samples: size_t,
|
||||
n_bytes_per_sample: size_t,
|
||||
n_channels: size_t,
|
||||
|
|
Loading…
Reference in a new issue