Skip to content

Commit 74a1aef

Browse files
saxrainliu
authored andcommitted
Fixup to move responsibility closer into ICETransportStats
1 parent 6bf76ec commit 74a1aef

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/ice_transport/mod.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::sync::Arc;
66
use ice::candidate::Candidate;
77
use ice::state::ConnectionState;
88
use tokio::sync::{mpsc, Mutex};
9-
use tokio::time::Instant;
109
use util::Conn;
1110

1211
use ice_candidate::RTCIceCandidate;
@@ -335,13 +334,10 @@ impl RTCIceTransport {
335334
let mut internal = self.internal.lock().await;
336335
if let Some(_conn) = internal.conn.take() {
337336
let collector = collector.clone();
338-
let stats = ICETransportStats {
339-
timestamp: Instant::now(),
340-
id: "ice_transport".to_owned(),
341-
// TODO: get bytes out of Conn.
342-
// bytes_received: conn.bytes_received,
343-
// bytes_sent: conn.bytes_sent,
344-
};
337+
let stats = ICETransportStats::new();
338+
// TODO: get bytes out of Conn.
339+
// bytes_received: conn.bytes_received,
340+
// bytes_sent: conn.bytes_sent,
345341

346342
let mut lock = collector.try_lock().unwrap();
347343
lock.push(Transport(stats));

src/stats/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,17 @@ impl From<CandidateStats> for ICECandidateStats {
135135
}
136136

137137
pub struct ICETransportStats {
138-
pub timestamp: Instant,
139-
pub id: String,
138+
timestamp: Instant,
139+
id: String,
140140
// bytes_received: u64,
141141
// bytes_sent: u64,
142142
}
143+
144+
impl ICETransportStats {
145+
pub(crate) fn new() -> Self {
146+
ICETransportStats {
147+
timestamp: Instant::now(),
148+
id: "ice_transport".to_owned(),
149+
}
150+
}
151+
}

0 commit comments

Comments
 (0)