| 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 { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 119 } |
| 120 | 120 |
| 121 const FrameStatsMap* LoggingStats::GetFrameStatsData( | 121 const FrameStatsMap* LoggingStats::GetFrameStatsData( |
| 122 const base::TimeTicks& now) { | 122 const base::TimeTicks& now) { |
| 123 // Compute framerate and bitrate (when available). | 123 // Compute framerate and bitrate (when available). |
| 124 FrameStatsMap::iterator it; | 124 FrameStatsMap::iterator it; |
| 125 for (it = frame_stats_.begin(); it != frame_stats_.end(); ++it) { | 125 for (it = frame_stats_.begin(); it != frame_stats_.end(); ++it) { |
| 126 base::TimeDelta time_diff = now - start_time_[it->first]; | 126 base::TimeDelta time_diff = now - start_time_[it->first]; |
| 127 it->second->framerate_fps = counts_[it->first] / time_diff.InSecondsF(); | 127 it->second->framerate_fps = counts_[it->first] / time_diff.InSecondsF(); |
| 128 if (it->second->bitrate_kbps > 0) { | 128 if (it->second->bitrate_kbps > 0) { |
| 129 it->second->bitrate_kbps = (8 / 1000) * | 129 it->second->bitrate_kbps = (8 / 1000) * it->second->bitrate_kbps / |
| 130 it->second->bitrate_kbps / time_diff.InSecondsF(); | 130 time_diff.InSecondsF(); |
| 131 } | 131 } |
| 132 if (it->second->avg_delay_ms > 0) | 132 if (it->second->avg_delay_ms > 0) |
| 133 it->second->avg_delay_ms /= counts_[it->first]; | 133 it->second->avg_delay_ms /= counts_[it->first]; |
| 134 } | 134 } |
| 135 return &frame_stats_; | 135 return &frame_stats_; |
| 136 } | 136 } |
| 137 | 137 |
| 138 const PacketStatsMap* LoggingStats::GetPacketStatsData( | 138 const PacketStatsMap* LoggingStats::GetPacketStatsData( |
| 139 const base::TimeTicks& now) { | 139 const base::TimeTicks& now) { |
| 140 PacketStatsMap::iterator it; | 140 PacketStatsMap::iterator it; |
| 141 for (it = packet_stats_.begin(); it != packet_stats_.end(); ++it) { | 141 for (it = packet_stats_.begin(); it != packet_stats_.end(); ++it) { |
| 142 if (counts_[it->first] == 0) continue; | 142 if (counts_[it->first] == 0) continue; |
| 143 base::TimeDelta time_diff = now - start_time_[it->first]; | 143 base::TimeDelta time_diff = now - start_time_[it->first]; |
| 144 it->second = (8 / 1000) * it->second / time_diff.InSecondsF(); | 144 it->second = (8 / 1000) * it->second / time_diff.InSecondsF(); |
| 145 } | 145 } |
| 146 return &packet_stats_; | 146 return &packet_stats_; |
| 147 } | 147 } |
| 148 | 148 |
| 149 const GenericStatsMap* LoggingStats::GetGenericStatsData() { | 149 const GenericStatsMap* LoggingStats::GetGenericStatsData() { |
| 150 // Compute averages. | 150 // Compute averages. |
| 151 GenericStatsMap::iterator it; | 151 GenericStatsMap::iterator it; |
| 152 for (it = generic_stats_.begin(); it != generic_stats_.end(); ++it) { | 152 for (it = generic_stats_.begin(); it != generic_stats_.end(); ++it) { |
| 153 it->second /= counts_[ it->first]; | 153 it->second /= counts_[ it->first]; |
| 154 } | 154 } |
| 155 return &generic_stats_; | 155 return &generic_stats_; |
| 156 } | 156 } |
| 157 | 157 |
| 158 } // namespace cast | 158 } // namespace cast |
| 159 } // namespace media | 159 } // namespace media |
| OLD | NEW |