OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "media/cast/logging/stats_converter.h" | |
6 | |
7 #include "base/json/json_writer.h" | |
8 #include "base/values.h" | |
9 | |
10 namespace media { | |
11 namespace cast { | |
12 | |
13 scoped_ptr<base::DictionaryValue> ConvertStats( | |
Alpha Left Google
2014/03/04 21:13:35
Move this to logging_stats.cc?
imcheng
2014/03/05 00:20:26
Done.
| |
14 const FrameStatsMap& frame_stats_map, | |
15 const PacketStatsMap& packet_stats_map) { | |
16 scoped_ptr<base::DictionaryValue> overall_stats(new base::DictionaryValue); | |
17 | |
18 scoped_ptr<base::DictionaryValue> overall_frame_stats( | |
19 new base::DictionaryValue); | |
20 for (FrameStatsMap::const_iterator it = frame_stats_map.begin(); | |
21 it != frame_stats_map.end(); | |
22 ++it) { | |
23 scoped_ptr<base::DictionaryValue> frame_stats(new base::DictionaryValue); | |
24 | |
25 frame_stats->SetDouble("firstEventTime", | |
26 it->second.first_event_time.ToInternalValue()); | |
27 frame_stats->SetDouble("lastEventTime", | |
28 it->second.last_event_time.ToInternalValue()); | |
29 frame_stats->SetInteger("count", it->second.event_counter); | |
30 frame_stats->SetInteger("sizeTotal", it->second.sum_size); | |
31 frame_stats->SetInteger("minDelayMs", | |
32 it->second.min_delay.InMilliseconds()); | |
33 frame_stats->SetInteger("maxDelayMs", | |
34 it->second.max_delay.InMilliseconds()); | |
35 frame_stats->SetInteger("sumDelayMs", | |
36 it->second.sum_delay.InMilliseconds()); | |
37 | |
38 overall_frame_stats->Set(CastLoggingToString(it->first), | |
39 frame_stats.release()); | |
40 } | |
41 | |
42 overall_stats->Set("frameStats", overall_frame_stats.release()); | |
43 | |
44 scoped_ptr<base::DictionaryValue> overall_packet_stats( | |
45 new base::DictionaryValue); | |
46 for (PacketStatsMap::const_iterator it = packet_stats_map.begin(); | |
47 it != packet_stats_map.end(); | |
48 ++it) { | |
49 scoped_ptr<base::DictionaryValue> packet_stats(new base::DictionaryValue); | |
50 | |
51 packet_stats->SetDouble("firstEventTime", | |
52 it->second.first_event_time.ToInternalValue()); | |
53 packet_stats->SetDouble("lastEventTime", | |
54 it->second.last_event_time.ToInternalValue()); | |
55 packet_stats->SetDouble("lastEventTime", | |
56 it->second.last_event_time.ToInternalValue()); | |
57 packet_stats->SetInteger("count", it->second.event_counter); | |
58 packet_stats->SetInteger("sizeTotal", it->second.sum_size); | |
59 | |
60 overall_packet_stats->Set(CastLoggingToString(it->first), | |
61 packet_stats.release()); | |
62 } | |
63 | |
64 overall_stats->Set("packetStats", overall_packet_stats.release()); | |
65 | |
66 return overall_stats.Pass(); | |
67 } | |
68 | |
69 } // namespace cast | |
70 } // namespace media | |
OLD | NEW |