| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/media/webrtc_browsertest_perf.h" | 5 #include "chrome/browser/media/webrtc_browsertest_perf.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 if (stats_iterator.key().find("ssrc_") != std::string::npos) | 202 if (stats_iterator.key().find("ssrc_") != std::string::npos) |
| 203 result.insert(ExtractSsrcIdentifier(stats_iterator.key())); | 203 result.insert(ExtractSsrcIdentifier(stats_iterator.key())); |
| 204 stats_iterator.Advance(); | 204 stats_iterator.Advance(); |
| 205 } | 205 } |
| 206 return result; | 206 return result; |
| 207 } | 207 } |
| 208 | 208 |
| 209 namespace test { | 209 namespace test { |
| 210 | 210 |
| 211 void PrintBweForVideoMetrics(const base::DictionaryValue& pc_dict, | 211 void PrintBweForVideoMetrics(const base::DictionaryValue& pc_dict, |
| 212 const std::string& modifier) { | 212 const std::string& modifier, |
| 213 const std::string& video_codec) { |
| 214 std::string video_modifier = |
| 215 video_codec.empty() ? modifier : modifier + "_" + video_codec; |
| 213 const std::string kBweStatsKey = "bweforvideo"; | 216 const std::string kBweStatsKey = "bweforvideo"; |
| 214 std::string value; | 217 std::string value; |
| 215 ASSERT_TRUE(pc_dict.GetString( | 218 ASSERT_TRUE(pc_dict.GetString( |
| 216 Statistic("googAvailableSendBandwidth", kBweStatsKey), &value)); | 219 Statistic("googAvailableSendBandwidth", kBweStatsKey), &value)); |
| 217 perf_test::PrintResult( | 220 perf_test::PrintResult("bwe_stats", video_modifier, "available_send_bw", |
| 218 "bwe_stats", modifier, "available_send_bw", value, "bit/s", false); | 221 value, "bit/s", false); |
| 219 ASSERT_TRUE(pc_dict.GetString( | 222 ASSERT_TRUE(pc_dict.GetString( |
| 220 Statistic("googAvailableReceiveBandwidth", kBweStatsKey), &value)); | 223 Statistic("googAvailableReceiveBandwidth", kBweStatsKey), &value)); |
| 221 perf_test::PrintResult( | 224 perf_test::PrintResult("bwe_stats", video_modifier, "available_recv_bw", |
| 222 "bwe_stats", modifier, "available_recv_bw", value, "bit/s", false); | 225 value, "bit/s", false); |
| 223 ASSERT_TRUE(pc_dict.GetString( | 226 ASSERT_TRUE(pc_dict.GetString( |
| 224 Statistic("googTargetEncBitrate", kBweStatsKey), &value)); | 227 Statistic("googTargetEncBitrate", kBweStatsKey), &value)); |
| 225 perf_test::PrintResult( | 228 perf_test::PrintResult("bwe_stats", video_modifier, "target_enc_bitrate", |
| 226 "bwe_stats", modifier, "target_enc_bitrate", value, "bit/s", false); | 229 value, "bit/s", false); |
| 227 ASSERT_TRUE(pc_dict.GetString( | 230 ASSERT_TRUE(pc_dict.GetString( |
| 228 Statistic("googActualEncBitrate", kBweStatsKey), &value)); | 231 Statistic("googActualEncBitrate", kBweStatsKey), &value)); |
| 229 perf_test::PrintResult( | 232 perf_test::PrintResult("bwe_stats", video_modifier, "actual_enc_bitrate", |
| 230 "bwe_stats", modifier, "actual_enc_bitrate", value, "bit/s", false); | 233 value, "bit/s", false); |
| 231 ASSERT_TRUE(pc_dict.GetString( | 234 ASSERT_TRUE(pc_dict.GetString( |
| 232 Statistic("googTransmitBitrate", kBweStatsKey), &value)); | 235 Statistic("googTransmitBitrate", kBweStatsKey), &value)); |
| 233 perf_test::PrintResult( | 236 perf_test::PrintResult("bwe_stats", video_modifier, "transmit_bitrate", value, |
| 234 "bwe_stats", modifier, "transmit_bitrate", value, "bit/s",false); | 237 "bit/s", false); |
| 235 } | 238 } |
| 236 | 239 |
| 237 void PrintMetricsForAllStreams(const base::DictionaryValue& pc_dict, | 240 void PrintMetricsForAllStreams(const base::DictionaryValue& pc_dict, |
| 238 const std::string& modifier) { | 241 const std::string& modifier, |
| 242 const std::string& video_codec) { |
| 243 std::string video_modifier = |
| 244 video_codec.empty() ? modifier : modifier + "_" + video_codec; |
| 239 const base::DictionaryValue* stats_dict; | 245 const base::DictionaryValue* stats_dict; |
| 240 ASSERT_TRUE(pc_dict.GetDictionary("stats", &stats_dict)); | 246 ASSERT_TRUE(pc_dict.GetDictionary("stats", &stats_dict)); |
| 241 std::set<std::string> ssrc_identifiers = FindAllSsrcIdentifiers(*stats_dict); | 247 std::set<std::string> ssrc_identifiers = FindAllSsrcIdentifiers(*stats_dict); |
| 242 | 248 |
| 243 std::set<std::string>::const_iterator ssrc_iterator = | 249 std::set<std::string>::const_iterator ssrc_iterator = |
| 244 ssrc_identifiers.begin(); | 250 ssrc_identifiers.begin(); |
| 245 for (; ssrc_iterator != ssrc_identifiers.end(); ++ssrc_iterator) { | 251 for (; ssrc_iterator != ssrc_identifiers.end(); ++ssrc_iterator) { |
| 246 // Figure out which stream type this ssrc represents and print all the | 252 // Figure out which stream type this ssrc represents and print all the |
| 247 // interesting metrics for it. | 253 // interesting metrics for it. |
| 248 const std::string& ssrc = *ssrc_iterator; | 254 const std::string& ssrc = *ssrc_iterator; |
| 249 bool did_recognize_stream_type = | 255 bool did_recognize_stream_type = |
| 250 MaybePrintResultsForAudioReceive(ssrc, pc_dict, modifier) || | 256 MaybePrintResultsForAudioReceive(ssrc, pc_dict, modifier) || |
| 251 MaybePrintResultsForAudioSend(ssrc, pc_dict, modifier) || | 257 MaybePrintResultsForAudioSend(ssrc, pc_dict, modifier) || |
| 252 MaybePrintResultsForVideoReceive(ssrc, pc_dict, modifier) || | 258 MaybePrintResultsForVideoReceive(ssrc, pc_dict, video_modifier) || |
| 253 MaybePrintResultsForVideoSend(ssrc, pc_dict, modifier); | 259 MaybePrintResultsForVideoSend(ssrc, pc_dict, video_modifier); |
| 254 ASSERT_TRUE(did_recognize_stream_type) << "Failed to figure out which " | 260 ASSERT_TRUE(did_recognize_stream_type) << "Failed to figure out which " |
| 255 "kind of stream SSRC " << ssrc | 261 "kind of stream SSRC " << ssrc |
| 256 << " is. "; | 262 << " is. "; |
| 257 } | 263 } |
| 258 } | 264 } |
| 259 | 265 |
| 260 } // namespace test | 266 } // namespace test |
| OLD | NEW |