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

Commit 2591e4f

Browse files
authored
update deps + loosen some requirements (#26)
* 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
1 parent ce68374 commit 2591e4f

File tree

15 files changed

+95
-56
lines changed

15 files changed

+95
-56
lines changed

.github/workflows/cargo.yml

+50-11
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,80 @@ env:
1010
CARGO_TERM_COLOR: always
1111

1212
jobs:
13-
build:
14-
name: Build and test
13+
check_and_test:
14+
name: Check and test
1515
strategy:
1616
matrix:
1717
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
18+
toolchain:
19+
- 1.56.1 # min supported version (https://github.com/webrtc-rs/webrtc/#toolchain)
20+
- stable
1821
runs-on: ${{ matrix.os }}
1922
steps:
20-
- uses: actions/checkout@v2
21-
- name: Build
22-
run: cargo build --verbose
23-
- name: Run tests
24-
run: cargo test --verbose
23+
- uses: actions/checkout@v3
24+
- name: Cache cargo registry
25+
uses: actions/cache@v3
26+
with:
27+
path: ~/.cargo/registry
28+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
29+
- uses: actions-rs/toolchain@v1
30+
with:
31+
toolchain: ${{ matrix.toolchain }}
32+
profile: minimal
33+
override: true
34+
- uses: actions-rs/cargo@v1
35+
with:
36+
command: check
37+
- uses: actions-rs/cargo@v1
38+
with:
39+
command: test
2540

2641
rustfmt_and_clippy:
27-
name: Check rustfmt style && run clippy
42+
name: Check rustfmt style and run clippy
2843
runs-on: ubuntu-latest
2944
steps:
30-
- uses: actions/checkout@v2
45+
- uses: actions/checkout@v3
3146
- uses: actions-rs/toolchain@v1
3247
with:
33-
toolchain: 1.55.0
48+
toolchain: stable
3449
profile: minimal
3550
components: clippy, rustfmt
3651
override: true
3752
- name: Cache cargo registry
38-
uses: actions/cache@v1
53+
uses: actions/cache@v3
3954
with:
4055
path: ~/.cargo/registry
4156
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
4257
- name: Run clippy
4358
uses: actions-rs/cargo@v1
4459
with:
4560
command: clippy
61+
args: -- -D warnings
4662
- name: Check formating
4763
uses: actions-rs/cargo@v1
4864
with:
4965
command: fmt
5066
args: --all -- --check
67+
68+
minimal_versions:
69+
name: Compile and test with minimal versions
70+
strategy:
71+
matrix:
72+
# TODO: add 'windows-latest' once criterion#atty version is upgraded
73+
# "0.2" min version (0.2.0) depends on winapi-0.2.4 which does not
74+
# compile on nightly.
75+
# https://github.com/bheisler/criterion.rs/pull/587
76+
os: ['ubuntu-latest', 'macos-latest']
77+
runs-on: ${{ matrix.os }}
78+
steps:
79+
- uses: actions/checkout@v3
80+
- name: Install latest nightly
81+
uses: actions-rs/toolchain@v1
82+
with:
83+
toolchain: nightly
84+
override: true
85+
- uses: taiki-e/install-action@cargo-hack
86+
- uses: taiki-e/install-action@cargo-minimal-versions
87+
- run: cargo minimal-versions check --workspace --all-features --ignore-private -v
88+
- run: cargo minimal-versions build --workspace --all-features --ignore-private -v
89+
- run: cargo minimal-versions test --workspace --all-features -v

Cargo.toml

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ homepage = "https://webrtc.rs"
1010
repository = "https://github.com/webrtc-rs/rtp"
1111

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

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

2525
[[bench]]
2626
name = "packet_bench"

src/codecs/h264/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl Payloader for H264Payloader {
199199
}
200200

201201
/// H264Packet represents the H264 header that is stored in the payload of an RTP Packet
202-
#[derive(PartialEq, Debug, Default, Clone)]
202+
#[derive(PartialEq, Eq, Debug, Default, Clone)]
203203
pub struct H264Packet {
204204
pub is_avc: bool,
205205
fua_buffer: Option<BytesMut>,

src/codecs/h265/h265_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ fn test_h265_paci_packet() -> Result<()> {
669669
raw: Bytes::from_static(&[0x64, 0x01, 0x64, 0x00, 0xab, 0xcd, 0xef]),
670670
expected_fu: Some(H265PACIPacket {
671671
payload_header: H265NALUHeader::new(0x64, 0x01),
672-
paci_header_fields: ((0x64) << 8) | (0x00),
672+
paci_header_fields: ((0x64) << 8),
673673
phes: Bytes::from_static(&[]),
674674
payload: Bytes::from_static(&[0xab, 0xcd, 0xef]),
675675
}),

src/codecs/h265/mod.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const H265NALU_PACI_PACKET_TYPE: u8 = 50;
2424
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2525
/// |F| Type | layer_id | tid |
2626
/// +-------------+-----------------+
27-
#[derive(Default, Debug, Copy, Clone, PartialEq)]
27+
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
2828
pub struct H265NALUHeader(pub u16);
2929

3030
impl H265NALUHeader {
@@ -97,7 +97,7 @@ impl H265NALUHeader {
9797
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
9898
///
9999
/// Reference: https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.1
100-
#[derive(Default, Debug, Clone, PartialEq)]
100+
#[derive(Default, Debug, Clone, PartialEq, Eq)]
101101
pub struct H265SingleNALUnitPacket {
102102
/// payload_header is the header of the H265 packet.
103103
payload_header: H265NALUHeader,
@@ -186,7 +186,7 @@ impl H265SingleNALUnitPacket {
186186
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
187187
///
188188
/// Reference: https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.2
189-
#[derive(Default, Debug, Clone, PartialEq)]
189+
#[derive(Default, Debug, Clone, PartialEq, Eq)]
190190
pub struct H265AggregationUnitFirst {
191191
donl: Option<u16>,
192192
nal_unit_size: u16,
@@ -226,7 +226,7 @@ impl H265AggregationUnitFirst {
226226
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
227227
///
228228
/// Reference: https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.2
229-
#[derive(Default, Debug, Clone, PartialEq)]
229+
#[derive(Default, Debug, Clone, PartialEq, Eq)]
230230
pub struct H265AggregationUnit {
231231
dond: Option<u8>,
232232
nal_unit_size: u16,
@@ -266,7 +266,7 @@ impl H265AggregationUnit {
266266
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
267267
///
268268
/// Reference: https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.2
269-
#[derive(Default, Debug, Clone, PartialEq)]
269+
#[derive(Default, Debug, Clone, PartialEq, Eq)]
270270
pub struct H265AggregationPacket {
271271
first_unit: Option<H265AggregationUnitFirst>,
272272
other_units: Vec<H265AggregationUnit>,
@@ -388,7 +388,7 @@ const H265FRAGMENTATION_UNIT_HEADER_SIZE: usize = 1;
388388
/// +-+-+-+-+-+-+-+-+
389389
/// |S|E| fu_type |
390390
/// +---------------+
391-
#[derive(Default, Debug, Copy, Clone, PartialEq)]
391+
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
392392
pub struct H265FragmentationUnitHeader(pub u8);
393393

394394
impl H265FragmentationUnitHeader {
@@ -427,7 +427,7 @@ impl H265FragmentationUnitHeader {
427427
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
428428
///
429429
/// Reference: https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.3
430-
#[derive(Default, Debug, Clone, PartialEq)]
430+
#[derive(Default, Debug, Clone, PartialEq, Eq)]
431431
pub struct H265FragmentationUnitPacket {
432432
/// payload_header is the header of the H265 packet.
433433
payload_header: H265NALUHeader,
@@ -526,7 +526,7 @@ impl H265FragmentationUnitPacket {
526526
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
527527
///
528528
/// Reference: https://datatracker.ietf.org/doc/html/rfc7798#section-4.4.4
529-
#[derive(Default, Debug, Clone, PartialEq)]
529+
#[derive(Default, Debug, Clone, PartialEq, Eq)]
530530
pub struct H265PACIPacket {
531531
/// payload_header is the header of the H265 packet.
532532
payload_header: H265NALUHeader,
@@ -655,7 +655,7 @@ impl H265PACIPacket {
655655
656656
/// H265TSCI is a Temporal Scalability Control Information header extension.
657657
/// Reference: https://datatracker.ietf.org/doc/html/rfc7798#section-4.5
658-
#[derive(Default, Debug, Copy, Clone, PartialEq)]
658+
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
659659
pub struct H265TSCI(pub u32);
660660

661661
impl H265TSCI {
@@ -698,7 +698,7 @@ impl H265TSCI {
698698
///
699699
/// H265 Payload Enum
700700
///
701-
#[derive(Debug, Clone, PartialEq)]
701+
#[derive(Debug, Clone, PartialEq, Eq)]
702702
pub enum H265Payload {
703703
H265SingleNALUnitPacket(H265SingleNALUnitPacket),
704704
H265FragmentationUnitPacket(H265FragmentationUnitPacket),
@@ -717,7 +717,7 @@ impl Default for H265Payload {
717717
///
718718
719719
/// H265Packet represents a H265 packet, stored in the payload of an RTP packet.
720-
#[derive(Default, Debug, Clone, PartialEq)]
720+
#[derive(Default, Debug, Clone, PartialEq, Eq)]
721721
pub struct H265Packet {
722722
payload: H265Payload,
723723
might_need_donl: bool,

src/codecs/opus/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl Payloader for OpusPayloader {
2626
}
2727

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

3232
impl Depacketizer for OpusPacket {

src/codecs/vp8/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl Payloader for Vp8Payloader {
111111
}
112112

113113
/// Vp8Packet represents the VP8 header that is stored in the payload of an RTP Packet
114-
#[derive(PartialEq, Debug, Default, Clone)]
114+
#[derive(PartialEq, Eq, Debug, Default, Clone)]
115115
pub struct Vp8Packet {
116116
/// Required Header
117117
/// extended controlbits present

src/codecs/vp9/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl Payloader for Vp9Payloader {
142142
}
143143

144144
/// Vp9Packet represents the VP9 header that is stored in the payload of an RTP Packet
145-
#[derive(PartialEq, Debug, Default, Clone)]
145+
#[derive(PartialEq, Eq, Debug, Default, Clone)]
146146
pub struct Vp9Packet {
147147
/// picture ID is present
148148
pub i: bool,

src/codecs/vp9/vp9_test.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ fn test_vp9_packet_unmarshal() -> Result<()> {
187187
"ScalabilityStructureNoPayload",
188188
Bytes::from_static(&[
189189
0x0A,
190-
(1 << 5) | (0 << 4) | (1 << 3), // NS:1 Y:0 G:1
190+
(1 << 5) | (1 << 3), // NS:1 Y:0 G:1
191191
2,
192-
(0 << 5) | (1 << 4) | (0 << 2), // T:0 U:1 R:0 -
193-
(2 << 5) | (0 << 4) | (1 << 2), // T:2 U:0 R:1 -
192+
(1 << 4), // T:0 U:1 R:0 -
193+
(2 << 5) | (1 << 2), // T:2 U:0 R:1 -
194194
33,
195195
]),
196196
Vp9Packet {

src/extension/abs_send_time_extension/abs_send_time_extension_test.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ fn test_ntp_conversion() -> Result<()> {
1313
let tests = vec![
1414
(
1515
loc.ymd(1985, 6, 23).and_hms_nano(4, 0, 0, 0),
16-
0xa0c65b1000000000 as u64,
16+
0xa0c65b1000000000_u64,
1717
),
1818
(
1919
loc.ymd(1999, 12, 31).and_hms_nano(23, 59, 59, 500000),
20-
0xbc18084f0020c49b as u64,
20+
0xbc18084f0020c49b_u64,
2121
),
2222
(
2323
loc.ymd(2019, 3, 27).and_hms_nano(13, 39, 30, 8675309),
24-
0xe04641e202388b88 as u64,
24+
0xe04641e202388b88_u64,
2525
),
2626
];
2727

@@ -35,7 +35,7 @@ fn test_ntp_conversion() -> Result<()> {
3535
let actual = ntp as i128;
3636
let expected = *n as i128;
3737
let diff = actual - expected;
38-
if diff < -ABS_SEND_TIME_RESOLUTION || ABS_SEND_TIME_RESOLUTION < diff {
38+
if !(-ABS_SEND_TIME_RESOLUTION..=ABS_SEND_TIME_RESOLUTION).contains(&diff) {
3939
assert!(false, "unix2ntp error, expected: {:?}, got: {:?}", ntp, *n,);
4040
}
4141
} else {
@@ -49,7 +49,7 @@ fn test_ntp_conversion() -> Result<()> {
4949
.checked_add(Duration::from_nanos(t.timestamp_nanos() as u64))
5050
.unwrap_or(UNIX_EPOCH);
5151
let diff = input.duration_since(output).unwrap().as_nanos() as i128;
52-
if diff < -ABS_SEND_TIME_RESOLUTION || ABS_SEND_TIME_RESOLUTION < diff {
52+
if !(-ABS_SEND_TIME_RESOLUTION..=ABS_SEND_TIME_RESOLUTION).contains(&diff) {
5353
assert!(
5454
false,
5555
"Converted time.Time from NTP time differs, expected: {:?}, got: {:?}",
@@ -103,7 +103,7 @@ fn test_abs_send_time_extension_estimate() -> Result<()> {
103103

104104
let estimated = receive.estimate(ntp2unix(receive_ntp));
105105
let diff = estimated.duration_since(in_time).unwrap().as_nanos() as i128;
106-
if diff < -ABS_SEND_TIME_RESOLUTION || ABS_SEND_TIME_RESOLUTION < diff {
106+
if !(-ABS_SEND_TIME_RESOLUTION..=ABS_SEND_TIME_RESOLUTION).contains(&diff) {
107107
assert!(
108108
false,
109109
"Converted time.Time from NTP time differs, expected: {:?}, got: {:?}",

src/extension/abs_send_time_extension/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub const ABS_SEND_TIME_EXTENSION_SIZE: usize = 3;
1111

1212
/// AbsSendTimeExtension is a extension payload format in
1313
/// http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
14-
#[derive(PartialEq, Debug, Default, Copy, Clone)]
14+
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone)]
1515
pub struct AbsSendTimeExtension {
1616
pub timestamp: u64,
1717
}

src/extension/audio_level_extension/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub const AUDIO_LEVEL_EXTENSION_SIZE: usize = 1;
2828
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2929
/// | ID | len=1 |V| level | 0 (pad) |
3030
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
31-
#[derive(PartialEq, Debug, Default, Copy, Clone)]
31+
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone)]
3232
pub struct AudioLevelExtension {
3333
pub level: u8,
3434
pub voice: bool,

src/extension/transport_cc_extension/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub const TRANSPORT_CC_EXTENSION_SIZE: usize = 2;
1818
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1919
/// | ID | L=1 |transport-wide sequence number | zero padding |
2020
/// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
21-
#[derive(PartialEq, Debug, Default, Copy, Clone)]
21+
#[derive(PartialEq, Eq, Debug, Default, Copy, Clone)]
2222
pub struct TransportCcExtension {
2323
pub transport_sequence: u16,
2424
}

src/extension/transport_cc_extension/transport_cc_extension_test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ fn test_transport_cc_extension() -> Result<()> {
3131

3232
#[test]
3333
fn test_transport_cc_extension_extra_bytes() -> Result<()> {
34-
let raw = Bytes::from_static(&[0x00, 0x02, 0x00, 0xff, 0xff]);
35-
let buf = &mut raw.clone();
34+
let mut raw = Bytes::from_static(&[0x00, 0x02, 0x00, 0xff, 0xff]);
35+
let buf = &mut raw;
3636
let t1 = TransportCcExtension::unmarshal(buf)?;
3737
let t2 = TransportCcExtension {
3838
transport_sequence: 2,

0 commit comments

Comments
 (0)