File tree Expand file tree Collapse file tree 3 files changed +7
-9
lines changed Expand file tree Collapse file tree 3 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -550,10 +550,8 @@ impl RTCDataChannel {
550
550
}
551
551
552
552
pub ( crate ) async fn collect_stats ( & self , collector : & StatsCollector ) {
553
- collector. insert (
554
- self . stats_id . clone ( ) ,
555
- StatsReportType :: DataChannel ( DataChannelStats :: from ( self ) ) ,
556
- ) ;
553
+ let stats = DataChannelStats :: from ( self ) . await ;
554
+ collector. insert ( self . stats_id . clone ( ) , StatsReportType :: DataChannel ( stats) ) ;
557
555
}
558
556
559
557
pub ( crate ) fn set_ready_state ( & self , r : RTCDataChannelState ) {
Original file line number Diff line number Diff line change @@ -374,7 +374,7 @@ impl RTCSctpTransport {
374
374
375
375
// data channels
376
376
let mut data_channels_closed = 0 ;
377
- let data_channels = self . data_channels . try_lock ( ) . unwrap ( ) ;
377
+ let data_channels = self . data_channels . lock ( ) . await ;
378
378
for data_channel in & * data_channels {
379
379
match data_channel. ready_state ( ) {
380
380
RTCDataChannelState :: Connecting => ( ) ,
Original file line number Diff line number Diff line change @@ -367,16 +367,16 @@ pub struct DataChannelStats {
367
367
pub state : RTCDataChannelState ,
368
368
}
369
369
370
- impl From < & RTCDataChannel > for DataChannelStats {
371
- fn from ( data_channel : & RTCDataChannel ) -> Self {
370
+ impl DataChannelStats {
371
+ pub ( crate ) async fn from ( data_channel : & RTCDataChannel ) -> Self {
372
372
let state = data_channel. ready_state ( ) ;
373
373
374
374
let mut bytes_received = 0 ;
375
375
let mut bytes_sent = 0 ;
376
376
let mut messages_received = 0 ;
377
377
let mut messages_sent = 0 ;
378
378
379
- let lock = data_channel. data_channel . try_lock ( ) . unwrap ( ) ;
379
+ let lock = data_channel. data_channel . lock ( ) . await ;
380
380
381
381
if let Some ( internal) = & * lock {
382
382
bytes_received = internal. bytes_received ( ) ;
@@ -385,7 +385,7 @@ impl From<&RTCDataChannel> for DataChannelStats {
385
385
messages_sent = internal. messages_sent ( ) ;
386
386
}
387
387
388
- DataChannelStats {
388
+ Self {
389
389
bytes_received,
390
390
bytes_sent,
391
391
data_channel_identifier : data_channel. id ( ) , // TODO: "The value is initially null"
You can’t perform that action at this time.
0 commit comments