1
1
use ice:: agent:: agent_stats:: { CandidatePairStats , CandidateStats } ;
2
+ use ice:: candidate:: { CandidatePairState , CandidateType } ;
3
+ use ice:: network_type:: NetworkType ;
2
4
use stats_collector:: StatsCollector ;
3
5
4
6
use std:: sync:: Arc ;
5
7
use tokio:: sync:: Mutex ;
8
+ use tokio:: time:: Instant ;
6
9
7
10
pub mod stats_collector;
8
11
9
- pub enum StatsType {
10
- CSRC ,
11
- CandidatePair ,
12
- Certificate ,
13
- Codec ,
14
- DataChannel ,
15
- InboundRTP ,
16
- LocalCandidate ,
17
- OutboundRTP ,
18
- PeerConnection ,
19
- Receiver ,
20
- RemoteCandidate ,
21
- RemoteInboundRTP ,
22
- RemoteOutboundRTP ,
23
- Sender ,
24
- Stream ,
25
- Track ,
26
- Transport ,
12
+ pub enum SourceStatsType {
13
+ CandidatePair ( CandidatePairStats ) ,
14
+ LocalCandidate ( CandidateStats ) ,
15
+ RemoteCandidate ( CandidateStats ) ,
27
16
}
28
17
29
18
pub enum StatsReportType {
30
- StatsType ( ICECandidatePairStats ) ,
19
+ CandidatePair ( ICECandidatePairStats ) ,
20
+ LocalCandidate ( ICECandidateStats ) ,
21
+ RemoteCandidate ( ICECandidateStats ) ,
31
22
}
32
23
33
- impl From < CandidatePairStats > for StatsReportType {
34
- fn from ( stats : CandidatePairStats ) -> Self {
35
- StatsReportType :: StatsType ( stats. into ( ) )
36
- }
37
- }
38
-
39
- impl From < CandidateStats > for StatsReportType {
40
- fn from ( stats : CandidateStats ) -> Self {
41
- StatsReportType :: StatsType ( stats . into ( ) )
24
+ impl From < SourceStatsType > for StatsReportType {
25
+ fn from ( stats : SourceStatsType ) -> Self {
26
+ match stats {
27
+ SourceStatsType :: CandidatePair ( stats ) => StatsReportType :: CandidatePair ( stats . into ( ) ) ,
28
+ SourceStatsType :: LocalCandidate ( stats ) => StatsReportType :: LocalCandidate ( stats . into ( ) ) ,
29
+ SourceStatsType :: RemoteCandidate ( stats ) => {
30
+ StatsReportType :: RemoteCandidate ( stats . into ( ) )
31
+ }
32
+ }
42
33
}
43
34
}
44
35
@@ -50,16 +41,93 @@ impl From<Arc<Mutex<StatsCollector>>> for StatsReport {
50
41
}
51
42
}
52
43
53
- pub struct ICECandidatePairStats { }
44
+ pub struct ICECandidatePairStats {
45
+ timestamp : Instant ,
46
+ // id: String,
47
+ local_candidate_id : String ,
48
+ remote_candidate_id : String ,
49
+ state : CandidatePairState ,
50
+ nominated : bool ,
51
+ packets_sent : u32 ,
52
+ packets_received : u32 ,
53
+ bytes_sent : u64 ,
54
+ bytes_received : u64 ,
55
+ last_packet_sent_timestamp : Instant ,
56
+ last_packet_received_timstamp : Instant ,
57
+ first_request_timestamp : Instant ,
58
+ last_request_timestamp : Instant ,
59
+ total_round_trip_time : f64 ,
60
+ current_round_trip_time : f64 ,
61
+ available_outgoing_bitrate : f64 ,
62
+ available_incoming_bitrate : f64 ,
63
+ circuit_breaker_trigger_count : u32 ,
64
+ requests_received : u64 ,
65
+ requests_sent : u64 ,
66
+ responses_received : u64 ,
67
+ responses_sent : u64 ,
68
+ retransmissions_sent : u64 ,
69
+ consent_requests_sent : u64 ,
70
+ consent_expired_timestamp : Instant ,
71
+ }
54
72
55
73
impl From < CandidatePairStats > for ICECandidatePairStats {
56
- fn from ( _stats : CandidatePairStats ) -> Self {
57
- ICECandidatePairStats { }
74
+ fn from ( stats : CandidatePairStats ) -> Self {
75
+ ICECandidatePairStats {
76
+ timestamp : stats. timestamp ,
77
+ local_candidate_id : stats. local_candidate_id ,
78
+ remote_candidate_id : stats. remote_candidate_id ,
79
+ state : stats. state ,
80
+ nominated : stats. nominated ,
81
+ packets_sent : stats. packets_sent ,
82
+ packets_received : stats. packets_received ,
83
+ bytes_sent : stats. bytes_sent ,
84
+ bytes_received : stats. bytes_received ,
85
+ last_packet_sent_timestamp : stats. last_packet_sent_timestamp ,
86
+ last_packet_received_timstamp : stats. last_packet_received_timestamp ,
87
+ first_request_timestamp : stats. first_request_timestamp ,
88
+ last_request_timestamp : stats. last_request_timestamp ,
89
+ total_round_trip_time : stats. total_round_trip_time ,
90
+ current_round_trip_time : stats. current_round_trip_time ,
91
+ available_outgoing_bitrate : stats. available_outgoing_bitrate ,
92
+ available_incoming_bitrate : stats. available_incoming_bitrate ,
93
+ circuit_breaker_trigger_count : stats. circuit_breaker_trigger_count ,
94
+ requests_received : stats. requests_received ,
95
+ requests_sent : stats. requests_sent ,
96
+ responses_received : stats. responses_received ,
97
+ responses_sent : stats. responses_sent ,
98
+ retransmissions_sent : stats. retransmissions_sent ,
99
+ consent_requests_sent : stats. consent_requests_sent ,
100
+ consent_expired_timestamp : stats. consent_expired_timestamp ,
101
+ }
58
102
}
59
103
}
60
104
61
- impl From < CandidateStats > for ICECandidatePairStats {
62
- fn from ( _stats : CandidateStats ) -> Self {
63
- ICECandidatePairStats { }
105
+ pub struct ICECandidateStats {
106
+ timestamp : Instant ,
107
+ // id: String,
108
+ candidate_type : CandidateType ,
109
+ deleted : bool ,
110
+ ip : String ,
111
+ network_type : NetworkType ,
112
+ port : u16 ,
113
+ priority : u32 ,
114
+ relay_protocol : String ,
115
+ url : String ,
116
+ }
117
+
118
+ impl From < CandidateStats > for ICECandidateStats {
119
+ fn from ( stats : CandidateStats ) -> Self {
120
+ ICECandidateStats {
121
+ timestamp : stats. timestamp ,
122
+ // id: String,
123
+ network_type : stats. network_type ,
124
+ ip : stats. ip ,
125
+ port : stats. port ,
126
+ candidate_type : stats. candidate_type ,
127
+ priority : stats. priority ,
128
+ url : stats. url ,
129
+ relay_protocol : stats. relay_protocol ,
130
+ deleted : stats. deleted ,
131
+ }
64
132
}
65
133
}
0 commit comments