Skip to content

Commit

Permalink
Broaden compatibility for embedded platforms
Browse files Browse the repository at this point in the history
* Remove dependence on unneeded Tokio 'process' and 'signal' features
* Comprehensive migration to portable_atomic
  • Loading branch information
coder0xff authored Mar 13, 2024
1 parent cc7e2ba commit cd0bd25
Show file tree
Hide file tree
Showing 73 changed files with 253 additions and 73 deletions.
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion data/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,22 @@ repository = "https://github.com/webrtc-rs/data"
util = { version = "0.8.1", path = "../util", package = "webrtc-util", default-features = false, features = ["conn", "marshal"] }
sctp = { version = "0.9.1", path = "../sctp", package = "webrtc-sctp" }

tokio = { version = "1.32.0", features = ["full"] }
tokio = { version = "1.32.0", features = [
"fs",
"io-util",
"io-std",
"macros",
"net",
"parking_lot",
"rt",
"rt-multi-thread",
"sync",
"time",
] }
bytes = "1"
log = "0.4"
thiserror = "1"
portable-atomic = "1.6"

[dev-dependencies]
tokio-test = "0.4" # must match the min version of the `tokio` crate above
Expand Down
3 changes: 2 additions & 1 deletion data/src/data_channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ use std::borrow::Borrow;
use std::future::Future;
use std::net::Shutdown;
use std::pin::Pin;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::task::{Context, Poll};
use std::{fmt, io};

use bytes::{Buf, Bytes};
use portable_atomic::AtomicUsize;
use sctp::association::Association;
use sctp::chunk::chunk_payload_data::PayloadProtocolIdentifier;
use sctp::stream::*;
Expand Down
14 changes: 13 additions & 1 deletion dtls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,18 @@ aes = "0.8"
cbc = { version = "0.1", features = [ "block-padding", "alloc"] }
aes-gcm = "0.10"
ccm = "0.5"
tokio = { version = "1.32.0", features = ["full"] }
tokio = { version = "1.32.0", features = [
"fs",
"io-util",
"io-std",
"macros",
"net",
"parking_lot",
"rt",
"rt-multi-thread",
"sync",
"time",
] }
async-trait = "0.1"
x25519-dalek = { version = "2", features = ["static_secrets"] }
x509-parser = "0.15"
Expand All @@ -40,6 +51,7 @@ subtle = "2"
log = "0.4"
thiserror = "1"
pem = { version = "3", optional = true }
portable-atomic = "1.6"

[dev-dependencies]
tokio-test = "0.4"
Expand Down
3 changes: 2 additions & 1 deletion dtls/src/conn/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ mod conn_test;
use std::io::{BufReader, BufWriter};
use std::marker::{Send, Sync};
use std::net::SocketAddr;
use std::sync::atomic::{AtomicBool, AtomicU16, Ordering};
use std::sync::atomic::Ordering;
use std::sync::Arc;

use async_trait::async_trait;
use log::*;
use portable_atomic::{AtomicBool, AtomicU16};
use tokio::sync::{mpsc, Mutex};
use tokio::time::Duration;
use util::replay_detector::*;
Expand Down
3 changes: 2 additions & 1 deletion dtls/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use std::io::{BufWriter, Cursor};
use std::marker::{Send, Sync};
use std::sync::atomic::{AtomicU16, Ordering};
use std::sync::atomic::Ordering;
use std::sync::Arc;

use async_trait::async_trait;
use portable_atomic::AtomicU16;
use serde::{Deserialize, Serialize};
use tokio::sync::Mutex;
use util::{KeyingMaterialExporter, KeyingMaterialExporterError};
Expand Down
14 changes: 13 additions & 1 deletion ice/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,22 @@ rand = "0.8"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "1"
tokio = { version = "1.32.0", features = ["full"] }
tokio = { version = "1.32.0", features = [
"fs",
"io-util",
"io-std",
"macros",
"net",
"parking_lot",
"rt",
"rt-multi-thread",
"sync",
"time",
] }
url = "2"
uuid = { version = "1", features = ["v4"] }
waitgroup = "0.1"
portable-atomic = "1.6"

[dev-dependencies]
tokio-test = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion ice/src/agent/agent_internal.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::atomic::{AtomicBool, AtomicU64};
use portable_atomic::{AtomicBool, AtomicU64};

use arc_swap::ArcSwapOption;
use util::sync::Mutex as SyncMutex;
Expand Down
3 changes: 2 additions & 1 deletion ice/src/agent/agent_transport.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::io;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::atomic::Ordering;

use arc_swap::ArcSwapOption;
use async_trait::async_trait;
use portable_atomic::AtomicBool;
use util::Conn;

use super::*;
Expand Down
2 changes: 1 addition & 1 deletion ice/src/agent/agent_vnet_test.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::net::{IpAddr, Ipv4Addr};
use std::result::Result;
use std::str::FromStr;
use std::sync::atomic::AtomicU64;

use async_trait::async_trait;
use portable_atomic::AtomicU64;
use util::vnet::chunk::Chunk;
use util::vnet::router::Nic;
use util::vnet::*;
Expand Down
3 changes: 2 additions & 1 deletion ice/src/agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ use std::collections::HashMap;
use std::future::Future;
use std::net::{Ipv4Addr, SocketAddr};
use std::pin::Pin;
use std::sync::atomic::{AtomicU8, AtomicUsize, Ordering};
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::time::SystemTime;

use agent_config::*;
use agent_internal::*;
use agent_stats::*;
use mdns::conn::*;
use portable_atomic::{AtomicU8, AtomicUsize};
use stun::agent::*;
use stun::attributes::*;
use stun::fingerprint::*;
Expand Down
3 changes: 2 additions & 1 deletion ice/src/candidate/candidate_base.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use std::fmt;
use std::ops::Add;
use std::sync::atomic::{AtomicU16, AtomicU64, AtomicU8, Ordering};
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::time::{Duration, SystemTime, UNIX_EPOCH};

use async_trait::async_trait;
use crc::{Crc, CRC_32_ISCSI};
use portable_atomic::{AtomicU16, AtomicU64, AtomicU8};
use tokio::sync::{broadcast, Mutex};
use util::sync::Mutex as SyncMutex;

Expand Down
2 changes: 1 addition & 1 deletion ice/src/candidate/candidate_host.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::atomic::{AtomicU16, AtomicU8};
use portable_atomic::{AtomicU16, AtomicU8};

use super::candidate_base::*;
use super::*;
Expand Down
2 changes: 1 addition & 1 deletion ice/src/candidate/candidate_peer_reflexive.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::atomic::{AtomicU16, AtomicU8};
use portable_atomic::{AtomicU16, AtomicU8};

use util::sync::Mutex as SyncMutex;

Expand Down
2 changes: 1 addition & 1 deletion ice/src/candidate/candidate_relay.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::atomic::{AtomicU16, AtomicU8};
use portable_atomic::{AtomicU16, AtomicU8};
use std::sync::Arc;

use util::sync::Mutex as SyncMutex;
Expand Down
2 changes: 1 addition & 1 deletion ice/src/candidate/candidate_server_reflexive.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::atomic::{AtomicU16, AtomicU8};
use portable_atomic::{AtomicU16, AtomicU8};

use util::sync::Mutex as SyncMutex;

Expand Down
3 changes: 2 additions & 1 deletion ice/src/candidate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ pub mod candidate_server_reflexive;

use std::fmt;
use std::net::{IpAddr, SocketAddr};
use std::sync::atomic::{AtomicBool, AtomicU16, AtomicU8, Ordering};
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::time::SystemTime;

use async_trait::async_trait;
use candidate_base::*;
use portable_atomic::{AtomicBool, AtomicU16, AtomicU8};
use serde::Serialize;
use tokio::sync::{broadcast, Mutex};

Expand Down
1 change: 1 addition & 0 deletions interceptor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ thiserror = "1"
rand = "0.8"
waitgroup = "0.1"
log = "0.4"
portable-atomic = "1.6"

[dev-dependencies]
tokio-test = "0.4"
Expand Down
3 changes: 2 additions & 1 deletion interceptor/src/twcc/sender/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ mod sender_stream;
#[cfg(test)]
mod sender_test;

use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::atomic::Ordering;
use std::sync::Arc;

use portable_atomic::AtomicU32;
use rtp::extension::transport_cc_extension::TransportCcExtension;
use sender_stream::SenderStream;
use tokio::sync::Mutex;
Expand Down
13 changes: 12 additions & 1 deletion mdns/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@ reuse_port = []
[dependencies]
util = { version = "0.8.1", path = "../util", package = "webrtc-util", default-features = false, features = ["ifaces"] }

tokio = { version = "1.32.0", features = ["full"] }
tokio = { version = "1.32.0", features = [
"fs",
"io-util",
"io-std",
"macros",
"net",
"parking_lot",
"rt",
"rt-multi-thread",
"sync",
"time",
] }
socket2 = { version = "0.5", features = ["all"] }
log = "0.4"
thiserror = "1"
Expand Down
1 change: 1 addition & 0 deletions rtp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ bytes = "1"
rand = "0.8"
thiserror = "1"
serde = { version = "1", features = ["derive"] }
portable-atomic = "1.6"

[dev-dependencies]
chrono = "0.4.28"
Expand Down
4 changes: 3 additions & 1 deletion rtp/src/sequence.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use std::fmt;
use std::sync::atomic::{AtomicU16, AtomicU64, Ordering};
use std::sync::atomic::Ordering;
use std::sync::Arc;

use portable_atomic::{AtomicU16, AtomicU64};

/// Sequencer generates sequential sequence numbers for building RTP packets
pub trait Sequencer: fmt::Debug {
fn next_sequence_number(&self) -> u16;
Expand Down
14 changes: 13 additions & 1 deletion sctp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,25 @@ repository = "https://github.com/webrtc-rs/sctp"
util = { version = "0.8.1", path = "../util", package = "webrtc-util", default-features = false, features = ["conn"] }

arc-swap = "1"
tokio = { version = "1.32.0", features = ["full"] }
tokio = { version = "1.32.0", features = [
"fs",
"io-util",
"io-std",
"macros",
"net",
"parking_lot",
"rt",
"rt-multi-thread",
"sync",
"time",
] }
bytes = "1"
rand = "0.8"
crc = "3"
async-trait = "0.1"
log = "0.4"
thiserror = "1"
portable-atomic = "1.6"

[dev-dependencies]
tokio-test = "0.4"
Expand Down
3 changes: 1 addition & 2 deletions sctp/src/association/association_internal.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#[cfg(test)]
mod association_internal_test;

use std::sync::atomic::AtomicBool;

use async_trait::async_trait;
use portable_atomic::AtomicBool;

use super::*;
use crate::param::param_forward_tsn_supported::ParamForwardTsnSupported;
Expand Down
Loading

0 comments on commit cd0bd25

Please sign in to comment.