Skip to content

Commit

Permalink
Fix over-NACK due to NackPair lost_packets not resetting (#372)
Browse files Browse the repository at this point in the history
Co-authored-by: Olof Kraigher <[email protected]>
  • Loading branch information
kraigher and Olof Kraigher authored Dec 19, 2022
1 parent 630c46f commit e32feda
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 14 deletions.
3 changes: 2 additions & 1 deletion interceptor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# interceptor changelog

## Unreleased
- [#372 Fix over-NACK due not resetting lost_packets bitmask](https://github.com/webrtc-rs/webrtc/pull/372/)

## v0.8.1

Expand All @@ -9,7 +10,7 @@
* Don't generate empty TWCC packets that libWebRTC will ignore. [#324](https://github.com/webrtc-rs/webrtc/pull/324) by [@k0nserv](https://github.com/k0nserv).
* Increased minimum support rust version to `1.60.0`.
* Increased required `webrtc-util` version to `0.7.0`.


## v0.8.0

Expand Down
4 changes: 2 additions & 2 deletions interceptor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "interceptor"
version = "0.8.1"
version = "0.8.2"
authors = ["Rain Liu <[email protected]>"]
edition = "2018"
description = "A pure Rust implementation of Pluggable RTP/RTCP processors"
Expand All @@ -13,7 +13,7 @@ rust-version = "1.60.0"
[dependencies]
util = { version = "0.7.0", path = "../util", package = "webrtc-util", default-features = false, features = ["marshal", "sync"] }
rtp = { version = "0.6.7", path = "../rtp" }
rtcp = { version = "0.7.0", path = "../rtcp" }
rtcp = { version = "0.7.2", path = "../rtcp" }
srtp = { version = "0.9.0", path = "../srtp", package = "webrtc-srtp" }

tokio = { version = "1.19", features = ["sync", "time"] }
Expand Down
1 change: 1 addition & 0 deletions rtcp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# rtcp changelog

## Unreleased
- [#372 Fix over-NACK due not resetting lost_packets bitmask](https://github.com/webrtc-rs/webrtc/pull/372/)

## v0.7.1

Expand Down
2 changes: 1 addition & 1 deletion rtcp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rtcp"
version = "0.7.1"
version = "0.7.2"
authors = ["Rain Liu <[email protected]>", "Michael Uti <[email protected]>"]
edition = "2018"
description = "A pure Rust implementation of RTCP"
Expand Down
17 changes: 10 additions & 7 deletions rtcp/src/transport_feedbacks/transport_layer_nack/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ impl Iterator for NackIterator {
}

impl NackPair {
pub fn new(seq: u16) -> Self {
Self {
packet_id: seq,
lost_packets: Default::default(),
}
}

/// PacketList returns a list of Nack'd packets that's referenced by a NackPair
pub fn packet_list(&self) -> Vec<u16> {
self.into_iter().collect()
Expand Down Expand Up @@ -243,11 +250,7 @@ pub fn nack_pairs_from_sequence_numbers(seq_nos: &[u16]) -> Vec<NackPair> {
return vec![];
}

let mut nack_pair = NackPair {
packet_id: seq_nos[0],
..Default::default()
};

let mut nack_pair = NackPair::new(seq_nos[0]);
let mut pairs = vec![];

for &seq in seq_nos.iter().skip(1) {
Expand All @@ -256,7 +259,7 @@ pub fn nack_pairs_from_sequence_numbers(seq_nos: &[u16]) -> Vec<NackPair> {
}
if seq <= nack_pair.packet_id || seq > nack_pair.packet_id.saturating_add(16) {
pairs.push(nack_pair);
nack_pair.packet_id = seq;
nack_pair = NackPair::new(seq);
continue;
}

Expand All @@ -267,4 +270,4 @@ pub fn nack_pairs_from_sequence_numbers(seq_nos: &[u16]) -> Vec<NackPair> {
pairs.push(nack_pair);

pairs
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ fn test_transport_layer_nack_pair_generation() {
},
NackPair {
packet_id: 99,
lost_packets: 1,
lost_packets: 0,
},
],
),
Expand All @@ -359,3 +359,23 @@ fn test_transport_layer_nack_pair_generation() {
)
}
}

/// This test case reproduced a bug in the implementation
#[test]
fn test_lost_packets_is_reset_when_crossing_16_bit_boundary() {
let seq: Vec<_> = (0u16..=17u16).collect();
assert_eq!(
nack_pairs_from_sequence_numbers(&seq),
vec![
NackPair {
packet_id: 0,
lost_packets: 0b1111_1111_1111_1111,
},
NackPair {
packet_id: 17,
// Was 0xffff before fixing the bug
lost_packets: 0b0000_0000_0000_0000,
}
],
)
}
4 changes: 2 additions & 2 deletions webrtc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "webrtc"
version = "0.6.0"
version = "0.6.1"
authors = ["Rain Liu <[email protected]>"]
edition = "2018"
description = "A pure Rust implementation of WebRTC API"
Expand All @@ -17,7 +17,7 @@ rust-version = "1.60.0"
data = { version = "0.6.0", path = "../data", package = "webrtc-data" }
dtls = { version = "0.7.0", path = "../dtls", package = "webrtc-dtls" }
ice = { version = "0.9.0", path = "../ice", package = "webrtc-ice" }
interceptor = { version = "0.8.0", path = "../interceptor" }
interceptor = { version = "0.8.2", path = "../interceptor" }
mdns = { version = "0.5.0", path = "../mdns", package = "webrtc-mdns" }
media = { version = "0.5.0", path = "../media", package = "webrtc-media" }
rtcp = { version = "0.7.0", path = "../rtcp" }
Expand Down

0 comments on commit e32feda

Please sign in to comment.