OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 MockStatsObserver() : called_(false), stats_() {} | 120 MockStatsObserver() : called_(false), stats_() {} |
121 virtual ~MockStatsObserver() {} | 121 virtual ~MockStatsObserver() {} |
122 | 122 |
123 virtual void OnComplete(const StatsReports& reports) { | 123 virtual void OnComplete(const StatsReports& reports) { |
124 ASSERT(!called_); | 124 ASSERT(!called_); |
125 called_ = true; | 125 called_ = true; |
126 stats_.Clear(); | 126 stats_.Clear(); |
127 stats_.number_of_reports = reports.size(); | 127 stats_.number_of_reports = reports.size(); |
128 for (const auto* r : reports) { | 128 for (const auto* r : reports) { |
129 if (r->type() == StatsReport::kStatsReportTypeSsrc) { | 129 if (r->type() == StatsReport::kStatsReportTypeSsrc) { |
| 130 stats_.timestamp = r->timestamp(); |
130 GetIntValue(r, StatsReport::kStatsValueNameAudioOutputLevel, | 131 GetIntValue(r, StatsReport::kStatsValueNameAudioOutputLevel, |
131 &stats_.audio_output_level); | 132 &stats_.audio_output_level); |
132 GetIntValue(r, StatsReport::kStatsValueNameAudioInputLevel, | 133 GetIntValue(r, StatsReport::kStatsValueNameAudioInputLevel, |
133 &stats_.audio_input_level); | 134 &stats_.audio_input_level); |
134 GetIntValue(r, StatsReport::kStatsValueNameBytesReceived, | 135 GetIntValue(r, StatsReport::kStatsValueNameBytesReceived, |
135 &stats_.bytes_received); | 136 &stats_.bytes_received); |
136 GetIntValue(r, StatsReport::kStatsValueNameBytesSent, | 137 GetIntValue(r, StatsReport::kStatsValueNameBytesSent, |
137 &stats_.bytes_sent); | 138 &stats_.bytes_sent); |
138 } else if (r->type() == StatsReport::kStatsReportTypeBwe) { | 139 } else if (r->type() == StatsReport::kStatsReportTypeBwe) { |
| 140 stats_.timestamp = r->timestamp(); |
139 GetIntValue(r, StatsReport::kStatsValueNameAvailableReceiveBandwidth, | 141 GetIntValue(r, StatsReport::kStatsValueNameAvailableReceiveBandwidth, |
140 &stats_.available_receive_bandwidth); | 142 &stats_.available_receive_bandwidth); |
141 } else if (r->type() == StatsReport::kStatsReportTypeComponent) { | 143 } else if (r->type() == StatsReport::kStatsReportTypeComponent) { |
| 144 stats_.timestamp = r->timestamp(); |
142 GetStringValue(r, StatsReport::kStatsValueNameDtlsCipher, | 145 GetStringValue(r, StatsReport::kStatsValueNameDtlsCipher, |
143 &stats_.dtls_cipher); | 146 &stats_.dtls_cipher); |
144 GetStringValue(r, StatsReport::kStatsValueNameSrtpCipher, | 147 GetStringValue(r, StatsReport::kStatsValueNameSrtpCipher, |
145 &stats_.srtp_cipher); | 148 &stats_.srtp_cipher); |
146 } | 149 } |
147 } | 150 } |
148 } | 151 } |
149 | 152 |
150 bool called() const { return called_; } | 153 bool called() const { return called_; } |
151 size_t number_of_reports() const { return stats_.number_of_reports; } | 154 size_t number_of_reports() const { return stats_.number_of_reports; } |
| 155 double timestamp() const { return stats_.timestamp; } |
152 | 156 |
153 int AudioOutputLevel() const { | 157 int AudioOutputLevel() const { |
154 ASSERT(called_); | 158 ASSERT(called_); |
155 return stats_.audio_output_level; | 159 return stats_.audio_output_level; |
156 } | 160 } |
157 | 161 |
158 int AudioInputLevel() const { | 162 int AudioInputLevel() const { |
159 ASSERT(called_); | 163 ASSERT(called_); |
160 return stats_.audio_input_level; | 164 return stats_.audio_input_level; |
161 } | 165 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 const StatsReport::Value* v = report->FindValue(name); | 207 const StatsReport::Value* v = report->FindValue(name); |
204 if (v) | 208 if (v) |
205 *value = v->ToString(); | 209 *value = v->ToString(); |
206 return v != nullptr; | 210 return v != nullptr; |
207 } | 211 } |
208 | 212 |
209 bool called_; | 213 bool called_; |
210 struct { | 214 struct { |
211 void Clear() { | 215 void Clear() { |
212 number_of_reports = 0; | 216 number_of_reports = 0; |
| 217 timestamp = 0; |
213 audio_output_level = 0; | 218 audio_output_level = 0; |
214 audio_input_level = 0; | 219 audio_input_level = 0; |
215 bytes_received = 0; | 220 bytes_received = 0; |
216 bytes_sent = 0; | 221 bytes_sent = 0; |
217 available_receive_bandwidth = 0; | 222 available_receive_bandwidth = 0; |
218 dtls_cipher.clear(); | 223 dtls_cipher.clear(); |
219 srtp_cipher.clear(); | 224 srtp_cipher.clear(); |
220 } | 225 } |
221 | 226 |
222 size_t number_of_reports; | 227 size_t number_of_reports; |
| 228 double timestamp; |
223 int audio_output_level; | 229 int audio_output_level; |
224 int audio_input_level; | 230 int audio_input_level; |
225 int bytes_received; | 231 int bytes_received; |
226 int bytes_sent; | 232 int bytes_sent; |
227 int available_receive_bandwidth; | 233 int available_receive_bandwidth; |
228 std::string dtls_cipher; | 234 std::string dtls_cipher; |
229 std::string srtp_cipher; | 235 std::string srtp_cipher; |
230 } stats_; | 236 } stats_; |
231 }; | 237 }; |
232 | 238 |
233 } // namespace webrtc | 239 } // namespace webrtc |
234 | 240 |
235 #endif // TALK_APP_WEBRTC_TEST_MOCKPEERCONNECTIONOBSERVERS_H_ | 241 #endif // TALK_APP_WEBRTC_TEST_MOCKPEERCONNECTIONOBSERVERS_H_ |
OLD | NEW |