Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Commit

Permalink
update deps + loosen some requirements (#26)
Browse files Browse the repository at this point in the history
* update deps + loosen some requirements

rules:
- for crates that are below v1.0 -> specify the precise version
- If the code uses a feature that was added for example in X 0.3.17,
  then you should specify 0.3.17, which actually means "0.3.y where y >=
  17"
- for crates the are above or equal v1.0 -> specify only major version
  if the crate's API is minimal and won't change between minor versions
    OR specify major&minor versions otherwise

tested with https://github.com/taiki-e/cargo-minimal-versions

* fix warnings

* update util version

* format code

* disable 'windows-latest' until criterion#atty version is upgraded

"0.2" min version (0.2.0) depends on winapi-0.2.4 which does not
compile on nightly.
bheisler/criterion.rs#587
  • Loading branch information
melekes authored Jun 27, 2022
1 parent ce68374 commit 2591e4f
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 56 deletions.
61 changes: 50 additions & 11 deletions .github/workflows/cargo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,80 @@ env:
CARGO_TERM_COLOR: always

jobs:
build:
name: Build and test
check_and_test:
name: Check and test
strategy:
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
toolchain:
- 1.56.1 # min supported version (https://github.com/webrtc-rs/webrtc/#toolchain)
- stable
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- uses: actions/checkout@v3
- name: Cache cargo registry
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
profile: minimal
override: true
- uses: actions-rs/cargo@v1
with:
command: check
- uses: actions-rs/cargo@v1
with:
command: test

rustfmt_and_clippy:
name: Check rustfmt style && run clippy
name: Check rustfmt style and run clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.55.0
toolchain: stable
profile: minimal
components: clippy, rustfmt
override: true
- name: Cache cargo registry
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Run clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
- name: Check formating
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

minimal_versions:
name: Compile and test with minimal versions
strategy:
matrix:
# TODO: add 'windows-latest' once criterion#atty version is upgraded
# "0.2" min version (0.2.0) depends on winapi-0.2.4 which does not
# compile on nightly.
# https://github.com/bheisler/criterion.rs/pull/587
os: ['ubuntu-latest', 'macos-latest']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- uses: taiki-e/install-action@cargo-hack
- uses: taiki-e/install-action@cargo-minimal-versions
- run: cargo minimal-versions check --workspace --all-features --ignore-private -v
- run: cargo minimal-versions build --workspace --all-features --ignore-private -v
- run: cargo minimal-versions test --workspace --all-features -v
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ homepage = "https://webrtc.rs"
repository = "https://github.com/webrtc-rs/rtp"

[dependencies]
util = { package = "webrtc-util", version = "0.5.3", default-features = false, features = ["marshal"] }
bytes = "1.1.0"
rand = "0.8.4"
thiserror = "1.0.30"
async-trait = "0.1.52"
util = { package = "webrtc-util", version = "0.5.4", default-features = false, features = ["marshal"] }
bytes = "1"
rand = "0.8.5"
thiserror = "1.0"
async-trait = "0.1.56"

[dev-dependencies]
chrono = "0.4.19"
criterion = "0.3.5"
tokio = { version = "1.15.0", features = ["full"] }
tokio-test = "0.4.2"
tokio = { version = "1.19", features = ["full"] }
tokio-test = "0.4.0" # must match the min version of the `tokio` crate above

[[bench]]
name = "packet_bench"
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/h264/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl Payloader for H264Payloader {
}

/// H264Packet represents the H264 header that is stored in the payload of an RTP Packet
#[derive(PartialEq, Debug, Default, Clone)]
#[derive(PartialEq, Eq, Debug, Default, Clone)]
pub struct H264Packet {
pub is_avc: bool,
fua_buffer: Option<BytesMut>,
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/h265/h265_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ fn test_h265_paci_packet() -> Result<()> {
raw: Bytes::from_static(&[0x64, 0x01, 0x64, 0x00, 0xab, 0xcd, 0xef]),
expected_fu: Some(H265PACIPacket {
payload_header: H265NALUHeader::new(0x64, 0x01),
paci_header_fields: ((0x64) << 8) | (0x00),
paci_header_fields: ((0x64) << 8),
phes: Bytes::from_static(&[]),
payload: Bytes::from_static(&[0xab, 0xcd, 0xef]),
}),
Expand Down
22 changes: 11 additions & 11 deletions src/codecs/h265/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const H265NALU_PACI_PACKET_TYPE: u8 = 50;
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// |F| Type | layer_id | tid |
/// +-------------+-----------------+
#[derive(Default, Debug, Copy, Clone, PartialEq)]
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
pub struct H265NALUHeader(pub u16);

impl H265NALUHeader {
Expand Down Expand Up @@ -97,7 +97,7 @@ impl H265NALUHeader {
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
///
/// Reference: https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.1
#[derive(Default, Debug, Clone, PartialEq)]
#[derive(Default, Debug, Clone, PartialEq, Eq)]
pub struct H265SingleNALUnitPacket {
/// payload_header is the header of the H265 packet.
payload_header: H265NALUHeader,
Expand Down Expand Up @@ -186,7 +186,7 @@ impl H265SingleNALUnitPacket {
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
///
/// Reference: https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.2
#[derive(Default, Debug, Clone, PartialEq)]
#[derive(Default, Debug, Clone, PartialEq, Eq)]
pub struct H265AggregationUnitFirst {
donl: Option<u16>,
nal_unit_size: u16,
Expand Down Expand Up @@ -226,7 +226,7 @@ impl H265AggregationUnitFirst {
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
///
/// Reference: https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.2
#[derive(Default, Debug, Clone, PartialEq)]
#[derive(Default, Debug, Clone, PartialEq, Eq)]
pub struct H265AggregationUnit {
dond: Option<u8>,
nal_unit_size: u16,
Expand Down Expand Up @@ -266,7 +266,7 @@ impl H265AggregationUnit {
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
///
/// Reference: https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.2
#[derive(Default, Debug, Clone, PartialEq)]
#[derive(Default, Debug, Clone, PartialEq, Eq)]
pub struct H265AggregationPacket {
first_unit: Option<H265AggregationUnitFirst>,
other_units: Vec<H265AggregationUnit>,
Expand Down Expand Up @@ -388,7 +388,7 @@ const H265FRAGMENTATION_UNIT_HEADER_SIZE: usize = 1;
/// +-+-+-+-+-+-+-+-+
/// |S|E| fu_type |
/// +---------------+
#[derive(Default, Debug, Copy, Clone, PartialEq)]
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
pub struct H265FragmentationUnitHeader(pub u8);

impl H265FragmentationUnitHeader {
Expand Down Expand Up @@ -427,7 +427,7 @@ impl H265FragmentationUnitHeader {
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
///
/// Reference: https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.3
#[derive(Default, Debug, Clone, PartialEq)]
#[derive(Default, Debug, Clone, PartialEq, Eq)]
pub struct H265FragmentationUnitPacket {
/// payload_header is the header of the H265 packet.
payload_header: H265NALUHeader,
Expand Down Expand Up @@ -526,7 +526,7 @@ impl H265FragmentationUnitPacket {
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
///
/// Reference: https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.4
#[derive(Default, Debug, Clone, PartialEq)]
#[derive(Default, Debug, Clone, PartialEq, Eq)]
pub struct H265PACIPacket {
/// payload_header is the header of the H265 packet.
payload_header: H265NALUHeader,
Expand Down Expand Up @@ -655,7 +655,7 @@ impl H265PACIPacket {

/// H265TSCI is a Temporal Scalability Control Information header extension.
/// Reference: https://datatracker.ietf.org/doc/html/rfc7798#section-4.5
#[derive(Default, Debug, Copy, Clone, PartialEq)]
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
pub struct H265TSCI(pub u32);

impl H265TSCI {
Expand Down Expand Up @@ -698,7 +698,7 @@ impl H265TSCI {
///
/// H265 Payload Enum
///
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum H265Payload {
H265SingleNALUnitPacket(H265SingleNALUnitPacket),
H265FragmentationUnitPacket(H265FragmentationUnitPacket),
Expand All @@ -717,7 +717,7 @@ impl Default for H265Payload {
///

/// H265Packet represents a H265 packet, stored in the payload of an RTP packet.
#[derive(Default, Debug, Clone, PartialEq)]
#[derive(Default, Debug, Clone, PartialEq, Eq)]
pub struct H265Packet {
payload: H265Payload,
might_need_donl: bool,
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/opus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl Payloader for OpusPayloader {
}

/// OpusPacket represents the Opus header that is stored in the payload of an RTP Packet
#[derive(PartialEq, Debug, Default, Clone)]
#[derive(PartialEq, Eq, Debug, Default, Clone)]
pub struct OpusPacket;

impl Depacketizer for OpusPacket {
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/vp8/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Payloader for Vp8Payloader {
}

/// Vp8Packet represents the VP8 header that is stored in the payload of an RTP Packet
#[derive(PartialEq, Debug, Default, Clone)]
#[derive(PartialEq, Eq, Debug, Default, Clone)]
pub struct Vp8Packet {
/// Required Header
/// extended controlbits present
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/vp9/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl Payloader for Vp9Payloader {
}

/// Vp9Packet represents the VP9 header that is stored in the payload of an RTP Packet
#[derive(PartialEq, Debug, Default, Clone)]
#[derive(PartialEq, Eq, Debug, Default, Clone)]
pub struct Vp9Packet {
/// picture ID is present
pub i: bool,
Expand Down
6 changes: 3 additions & 3 deletions src/codecs/vp9/vp9_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ fn test_vp9_packet_unmarshal() -> Result<()> {
"ScalabilityStructureNoPayload",
Bytes::from_static(&[
0x0A,
(1 << 5) | (0 << 4) | (1 << 3), // NS:1 Y:0 G:1
(1 << 5) | (1 << 3), // NS:1 Y:0 G:1
2,
(0 << 5) | (1 << 4) | (0 << 2), // T:0 U:1 R:0 -
(2 << 5) | (0 << 4) | (1 << 2), // T:2 U:0 R:1 -
(1 << 4), // T:0 U:1 R:0 -
(2 << 5) | (1 << 2), // T:2 U:0 R:1 -
33,
]),
Vp9Packet {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ fn test_ntp_conversion() -> Result<()> {
let tests = vec![
(
loc.ymd(1985, 6, 23).and_hms_nano(4, 0, 0, 0),
0xa0c65b1000000000 as u64,
0xa0c65b1000000000_u64,
),
(
loc.ymd(1999, 12, 31).and_hms_nano(23, 59, 59, 500000),
0xbc18084f0020c49b as u64,
0xbc18084f0020c49b_u64,
),
(
loc.ymd(2019, 3, 27).and_hms_nano(13, 39, 30, 8675309),
0xe04641e202388b88 as u64,
0xe04641e202388b88_u64,
),
];

Expand All @@ -35,7 +35,7 @@ fn test_ntp_conversion() -> Result<()> {
let actual = ntp as i128;
let expected = *n as i128;
let diff = actual - expected;
if diff < -ABS_SEND_TIME_RESOLUTION || ABS_SEND_TIME_RESOLUTION < diff {
if !(-ABS_SEND_TIME_RESOLUTION..=ABS_SEND_TIME_RESOLUTION).contains(&diff) {
assert!(false, "unix2ntp error, expected: {:?}, got: {:?}", ntp, *n,);
}
} else {
Expand All @@ -49,7 +49,7 @@ fn test_ntp_conversion() -> Result<()> {
.checked_add(Duration::from_nanos(t.timestamp_nanos() as u64))
.unwrap_or(UNIX_EPOCH);
let diff = input.duration_since(output).unwrap().as_nanos() as i128;
if diff < -ABS_SEND_TIME_RESOLUTION || ABS_SEND_TIME_RESOLUTION < diff {
if !(-ABS_SEND_TIME_RESOLUTION..=ABS_SEND_TIME_RESOLUTION).contains(&diff) {
assert!(
false,
"Converted time.Time from NTP time differs, expected: {:?}, got: {:?}",
Expand Down Expand Up @@ -103,7 +103,7 @@ fn test_abs_send_time_extension_estimate() -> Result<()> {

let estimated = receive.estimate(ntp2unix(receive_ntp));
let diff = estimated.duration_since(in_time).unwrap().as_nanos() as i128;
if diff < -ABS_SEND_TIME_RESOLUTION || ABS_SEND_TIME_RESOLUTION < diff {
if !(-ABS_SEND_TIME_RESOLUTION..=ABS_SEND_TIME_RESOLUTION).contains(&diff) {
assert!(
false,
"Converted time.Time from NTP time differs, expected: {:?}, got: {:?}",
Expand Down
2 changes: 1 addition & 1 deletion src/extension/abs_send_time_extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub const ABS_SEND_TIME_EXTENSION_SIZE: usize = 3;

/// AbsSendTimeExtension is a extension payload format in
/// http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
#[derive(PartialEq, Debug, Default, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone)]
pub struct AbsSendTimeExtension {
pub timestamp: u64,
}
Expand Down
2 changes: 1 addition & 1 deletion src/extension/audio_level_extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub const AUDIO_LEVEL_EXTENSION_SIZE: usize = 1;
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// | ID | len=1 |V| level | 0 (pad) |
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#[derive(PartialEq, Debug, Default, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone)]
pub struct AudioLevelExtension {
pub level: u8,
pub voice: bool,
Expand Down
2 changes: 1 addition & 1 deletion src/extension/transport_cc_extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub const TRANSPORT_CC_EXTENSION_SIZE: usize = 2;
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/// | ID | L=1 |transport-wide sequence number | zero padding |
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#[derive(PartialEq, Debug, Default, Copy, Clone)]
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone)]
pub struct TransportCcExtension {
pub transport_sequence: u16,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ fn test_transport_cc_extension() -> Result<()> {

#[test]
fn test_transport_cc_extension_extra_bytes() -> Result<()> {
let raw = Bytes::from_static(&[0x00, 0x02, 0x00, 0xff, 0xff]);
let buf = &mut raw.clone();
let mut raw = Bytes::from_static(&[0x00, 0x02, 0x00, 0xff, 0xff]);
let buf = &mut raw;
let t1 = TransportCcExtension::unmarshal(buf)?;
let t2 = TransportCcExtension {
transport_sequence: 2,
Expand Down
Loading

0 comments on commit 2591e4f

Please sign in to comment.