| 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 "base/memory/linked_ptr.h" | 5 #include "base/memory/linked_ptr.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "media/cast/logging/logging_stats.h" | 7 #include "media/cast/logging/logging_stats.h" |
| 8 | 8 |
| 9 namespace media { | 9 namespace media { |
| 10 namespace cast { | 10 namespace cast { |
| 11 | 11 |
| 12 LoggingStats::LoggingStats(base::TickClock* clock) | 12 LoggingStats::LoggingStats(base::TickClock* clock) |
| 13 : frame_stats_(), | 13 : frame_stats_(), |
| 14 packet_stats_(), | 14 packet_stats_(), |
| 15 generic_stats_(), | 15 generic_stats_(), |
| 16 start_time_(), | 16 start_time_(), |
| 17 clock_(clock) { | 17 clock_(clock) { |
| 18 memset(counts_, 0, sizeof(counts_)); | 18 memset(counts_, 0, sizeof(counts_)); |
| 19 memset(start_time_, 0, sizeof(start_time_)); |
| 19 } | 20 } |
| 20 | 21 |
| 21 LoggingStats::~LoggingStats() {} | 22 LoggingStats::~LoggingStats() {} |
| 22 | 23 |
| 23 void LoggingStats::Reset() { | 24 void LoggingStats::Reset() { |
| 24 frame_stats_.clear(); | 25 frame_stats_.clear(); |
| 25 packet_stats_.clear(); | 26 packet_stats_.clear(); |
| 26 generic_stats_.clear(); | 27 generic_stats_.clear(); |
| 27 memset(counts_, 0, sizeof(counts_)); | 28 memset(counts_, 0, sizeof(counts_)); |
| 28 } | 29 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 76 } |
| 76 | 77 |
| 77 ++counts_[event]; | 78 ++counts_[event]; |
| 78 } | 79 } |
| 79 | 80 |
| 80 void LoggingStats::InsertPacketEvent(CastLoggingEvent event, | 81 void LoggingStats::InsertPacketEvent(CastLoggingEvent event, |
| 81 uint32 rtp_timestamp, | 82 uint32 rtp_timestamp, |
| 82 uint8 frame_id, | 83 uint8 frame_id, |
| 83 uint16 packet_id, | 84 uint16 packet_id, |
| 84 uint16 max_packet_id, | 85 uint16 max_packet_id, |
| 85 int size) { | 86 size_t size) { |
| 86 // Does this packet belong to an existing event? | 87 // Does this packet belong to an existing event? |
| 87 PacketStatsMap::iterator it = packet_stats_.find(event); | 88 PacketStatsMap::iterator it = packet_stats_.find(event); |
| 88 if (it == packet_stats_.end()) { | 89 if (it == packet_stats_.end()) { |
| 89 // New event. | 90 // New event. |
| 90 start_time_[event] = clock_->NowTicks(); | 91 start_time_[event] = clock_->NowTicks(); |
| 91 packet_stats_.insert(std::make_pair(event, size)); | 92 packet_stats_.insert(std::make_pair(event, size)); |
| 92 } else { | 93 } else { |
| 93 // Add to existing. | 94 // Add to existing. |
| 94 it->second += size; | 95 it->second += size; |
| 95 } | 96 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // Compute averages. | 141 // Compute averages. |
| 141 GenericStatsMap::iterator it; | 142 GenericStatsMap::iterator it; |
| 142 for (it = generic_stats_.begin(); it != generic_stats_.end(); ++it) { | 143 for (it = generic_stats_.begin(); it != generic_stats_.end(); ++it) { |
| 143 it->second /= counts_[ it->first]; | 144 it->second /= counts_[ it->first]; |
| 144 } | 145 } |
| 145 return &generic_stats_; | 146 return &generic_stats_; |
| 146 } | 147 } |
| 147 | 148 |
| 148 } // namespace cast | 149 } // namespace cast |
| 149 } // namespace media | 150 } // namespace media |
| OLD | NEW |