Skip to content

Commit 37c5088

Browse files
authored
Add backup connection candidate stats and ICE check stats
1 parent b744044 commit 37c5088

File tree

3 files changed

+59
-10
lines changed

3 files changed

+59
-10
lines changed

ringrtc/rffi/api/stats_observer_intf.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,38 @@ typedef struct {
6262
double total_audio_energy;
6363
double jitter_buffer_delay;
6464
uint64_t jitter_buffer_emitted_count;
65+
uint64_t jitter_buffer_flushes;
66+
double estimated_playout_timestamp;
6567
} AudioReceiverStatistics;
6668

6769
typedef struct {
6870
uint32_t ssrc;
6971
uint32_t packets_received;
7072
int32_t packets_lost;
7173
uint64_t bytes_received;
74+
uint32_t frames_received;
7275
uint32_t frames_decoded;
7376
uint32_t key_frames_decoded;
7477
double total_decode_time;
7578
uint32_t frame_width;
7679
uint32_t frame_height;
80+
uint32_t freeze_count;
81+
double total_freezes_duration;
82+
double jitter;
83+
double jitter_buffer_delay;
84+
uint64_t jitter_buffer_emitted_count;
85+
uint64_t jitter_buffer_flushes;
86+
double estimated_playout_timestamp;
7787
} VideoReceiverStatistics;
7888

7989
typedef struct {
90+
const char* raw_candidate_pair_id;
8091
double current_round_trip_time;
8192
double available_outgoing_bitrate;
93+
uint64_t requests_sent;
94+
uint64_t responses_received;
95+
uint64_t requests_received;
96+
uint64_t responses_sent;
8297
} ConnectionStatistics;
8398

8499
typedef struct {
@@ -89,9 +104,11 @@ typedef struct {
89104
const VideoSenderStatistics* video_sender_statistics;
90105
uint32_t audio_receiver_statistics_size;
91106
const AudioReceiverStatistics* audio_receiver_statistics;
92-
uint32_t video_receiver_statistics_count;
107+
uint32_t video_receiver_statistics_size;
93108
const VideoReceiverStatistics* video_receiver_statistics;
94-
ConnectionStatistics connection_statistics;
109+
ConnectionStatistics nominated_connection_statistics;
110+
const ConnectionStatistics* connection_statistics;
111+
uint32_t connection_statistics_size;
95112
} MediaStatistics;
96113

97114
/* Stats Observer Callback callback function pointers */

ringrtc/rffi/src/stats_observer.cc

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ void StatsObserverRffi::OnStatsDelivered(
3535
this->video_sender_statistics_.clear();
3636
this->audio_receiver_statistics_.clear();
3737
this->video_receiver_statistics_.clear();
38+
this->connection_statistics_.clear();
3839

3940
auto outbound_stream_stats =
4041
report->GetStatsOfType<RTCOutboundRtpStreamStats>();
@@ -142,6 +143,10 @@ void StatsObserverRffi::OnStatsDelivered(
142143
stat->jitter_buffer_delay.value_or(0.0);
143144
audio_receiver.jitter_buffer_emitted_count =
144145
stat->jitter_buffer_emitted_count.value_or(0);
146+
audio_receiver.jitter_buffer_flushes =
147+
stat->jitter_buffer_flushes.value_or(0);
148+
audio_receiver.estimated_playout_timestamp =
149+
stat->estimated_playout_timestamp.value_or(0.0);
145150

146151
this->audio_receiver_statistics_.push_back(audio_receiver);
147152
} else if (*stat->kind == "video" &&
@@ -153,31 +158,53 @@ void StatsObserverRffi::OnStatsDelivered(
153158
video_receiver.packets_received = stat->packets_received.value_or(0);
154159
video_receiver.packets_lost = stat->packets_lost.value_or(0);
155160
video_receiver.bytes_received = stat->bytes_received.value_or(0);
161+
video_receiver.frames_received = stat->frames_received.value_or(0);
156162
video_receiver.frames_decoded = stat->frames_decoded.value_or(0);
157163
video_receiver.key_frames_decoded = stat->key_frames_decoded.value_or(0);
158164
video_receiver.total_decode_time = stat->total_decode_time.value_or(0.0);
159165
video_receiver.frame_width = stat->frame_width.value_or(0);
160166
video_receiver.frame_height = stat->frame_height.value_or(0);
167+
video_receiver.jitter = stat->jitter.value_or(0.0);
168+
video_receiver.jitter_buffer_delay =
169+
stat->jitter_buffer_delay.value_or(0.0);
170+
video_receiver.jitter_buffer_emitted_count =
171+
stat->jitter_buffer_emitted_count.value_or(0);
172+
video_receiver.jitter_buffer_flushes =
173+
stat->jitter_buffer_flushes.value_or(0);
174+
video_receiver.freeze_count = stat->freeze_count.value_or(0);
175+
video_receiver.total_freezes_duration =
176+
stat->total_freezes_duration.value_or(0.0);
177+
video_receiver.estimated_playout_timestamp =
178+
stat->estimated_playout_timestamp.value_or(0.0);
161179

162180
this->video_receiver_statistics_.push_back(video_receiver);
163181
}
164182
}
165183

166-
ConnectionStatistics connection_statistics = {0};
184+
ConnectionStatistics nominated_connection_statistics = {0};
167185
uint64_t highest_priority = 0;
168-
169186
for (const auto& stat : candidate_pair_stats) {
187+
ConnectionStatistics connection_stats = {0};
188+
connection_stats.raw_candidate_pair_id = stat->id().c_str();
189+
connection_stats.current_round_trip_time =
190+
stat->current_round_trip_time.value_or(0.0);
191+
connection_stats.available_outgoing_bitrate =
192+
stat->available_outgoing_bitrate.value_or(0.0);
193+
connection_stats.requests_sent = stat->requests_sent.value_or(0);
194+
connection_stats.responses_received = stat->responses_received.value_or(0);
195+
connection_stats.requests_received = stat->requests_received.value_or(0);
196+
connection_stats.responses_sent = stat->responses_sent.value_or(0);
197+
170198
// We'll only look at the pair that is nominated with the highest priority,
171199
// usually that has useful values (there does not seem to be a 'in_use' type
172200
// of flag).
173201
uint64_t current_priority = stat->priority.value_or(0);
174202
if (*stat->nominated && stat->priority.value_or(0) > highest_priority) {
175203
highest_priority = current_priority;
176-
connection_statistics.current_round_trip_time =
177-
stat->current_round_trip_time.value_or(0.0);
178-
connection_statistics.available_outgoing_bitrate =
179-
stat->available_outgoing_bitrate.value_or(0.0);
204+
nominated_connection_statistics = connection_stats;
180205
}
206+
207+
this->connection_statistics_.push_back(connection_stats);
181208
}
182209

183210
MediaStatistics media_statistics;
@@ -194,11 +221,15 @@ void StatsObserverRffi::OnStatsDelivered(
194221
this->audio_receiver_statistics_.size();
195222
media_statistics.audio_receiver_statistics =
196223
this->audio_receiver_statistics_.data();
197-
media_statistics.video_receiver_statistics_count =
224+
media_statistics.video_receiver_statistics_size =
198225
this->video_receiver_statistics_.size();
199226
media_statistics.video_receiver_statistics =
200227
this->video_receiver_statistics_.data();
201-
media_statistics.connection_statistics = connection_statistics;
228+
media_statistics.nominated_connection_statistics =
229+
nominated_connection_statistics;
230+
media_statistics.connection_statistics_size =
231+
this->connection_statistics_.size();
232+
media_statistics.connection_statistics = this->connection_statistics_.data();
202233

203234
std::string report_json =
204235
this->collect_raw_stats_report_.load() ? report->ToJson() : "";

ringrtc/rffi/src/stats_observer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class StatsObserverRffi : public RTCStatsCollectorCallback {
4141
std::vector<VideoSenderStatistics> video_sender_statistics_;
4242
std::vector<AudioReceiverStatistics> audio_receiver_statistics_;
4343
std::vector<VideoReceiverStatistics> video_receiver_statistics_;
44+
std::vector<ConnectionStatistics> connection_statistics_;
4445
};
4546

4647
} // namespace rffi

0 commit comments

Comments
 (0)