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 "media/blink/webmediaplayer_impl.h" | 5 #include "media/blink/webmediaplayer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <string> | 10 #include <string> |
(...skipping 2084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2095 FinishMemoryUsageReport(0); | 2095 FinishMemoryUsageReport(0); |
2096 } | 2096 } |
2097 } | 2097 } |
2098 | 2098 |
2099 void WebMediaPlayerImpl::FinishMemoryUsageReport(int64_t demuxer_memory_usage) { | 2099 void WebMediaPlayerImpl::FinishMemoryUsageReport(int64_t demuxer_memory_usage) { |
2100 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 2100 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
2101 | 2101 |
2102 const PipelineStatistics stats = GetPipelineStatistics(); | 2102 const PipelineStatistics stats = GetPipelineStatistics(); |
2103 const int64_t data_source_memory_usage = | 2103 const int64_t data_source_memory_usage = |
2104 data_source_ ? data_source_->GetMemoryUsage() : 0; | 2104 data_source_ ? data_source_->GetMemoryUsage() : 0; |
| 2105 |
| 2106 // If we have video and no video memory usage, assume the VideoFrameCompositor |
| 2107 // is holding onto the last frame after we've suspended the pipeline; which |
| 2108 // thus reports zero memory usage from the video renderer. |
| 2109 // |
| 2110 // Technically this should use the coded size, but that requires us to hop to |
| 2111 // the compositor to get and byte-perfect accuracy isn't important here. |
| 2112 const int64_t video_memory_usage = |
| 2113 stats.video_memory_usage + |
| 2114 (pipeline_metadata_.has_video && !stats.video_memory_usage |
| 2115 ? VideoFrame::AllocationSize(PIXEL_FORMAT_YV12, |
| 2116 pipeline_metadata_.natural_size) |
| 2117 : 0); |
| 2118 |
2105 const int64_t current_memory_usage = | 2119 const int64_t current_memory_usage = |
2106 stats.audio_memory_usage + stats.video_memory_usage + | 2120 stats.audio_memory_usage + video_memory_usage + data_source_memory_usage + |
2107 data_source_memory_usage + demuxer_memory_usage; | 2121 demuxer_memory_usage; |
2108 | 2122 |
2109 // Note, this isn't entirely accurate, there may be VideoFrames held by the | 2123 DVLOG(2) << "Memory Usage -- Total: " << current_memory_usage |
2110 // compositor or other resources that we're unaware of. | 2124 << " Audio: " << stats.audio_memory_usage |
2111 | 2125 << ", Video: " << video_memory_usage |
2112 DVLOG(2) << "Memory Usage -- Audio: " << stats.audio_memory_usage | |
2113 << ", Video: " << stats.video_memory_usage | |
2114 << ", DataSource: " << data_source_memory_usage | 2126 << ", DataSource: " << data_source_memory_usage |
2115 << ", Demuxer: " << demuxer_memory_usage; | 2127 << ", Demuxer: " << demuxer_memory_usage; |
2116 | 2128 |
2117 const int64_t delta = current_memory_usage - last_reported_memory_usage_; | 2129 const int64_t delta = current_memory_usage - last_reported_memory_usage_; |
2118 last_reported_memory_usage_ = current_memory_usage; | 2130 last_reported_memory_usage_ = current_memory_usage; |
2119 adjust_allocated_memory_cb_.Run(delta); | 2131 adjust_allocated_memory_cb_.Run(delta); |
2120 | 2132 |
2121 if (HasAudio()) { | 2133 if (HasAudio()) { |
2122 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.Audio", | 2134 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.Audio", |
2123 stats.audio_memory_usage / 1024); | 2135 stats.audio_memory_usage / 1024); |
2124 } | 2136 } |
2125 if (HasVideo()) { | 2137 if (HasVideo()) { |
2126 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.Video", | 2138 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.Video", |
2127 stats.video_memory_usage / 1024); | 2139 video_memory_usage / 1024); |
2128 } | 2140 } |
2129 if (data_source_) { | 2141 if (data_source_) { |
2130 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.DataSource", | 2142 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.DataSource", |
2131 data_source_memory_usage / 1024); | 2143 data_source_memory_usage / 1024); |
2132 } | 2144 } |
2133 if (demuxer_) { | 2145 if (demuxer_) { |
2134 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.Demuxer", | 2146 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.Demuxer", |
2135 demuxer_memory_usage / 1024); | 2147 demuxer_memory_usage / 1024); |
2136 } | 2148 } |
2137 } | 2149 } |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2359 | 2371 |
2360 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { | 2372 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { |
2361 DCHECK(data_source_ || chunk_demuxer_); | 2373 DCHECK(data_source_ || chunk_demuxer_); |
2362 if (data_source_) | 2374 if (data_source_) |
2363 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); | 2375 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); |
2364 else | 2376 else |
2365 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); | 2377 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); |
2366 } | 2378 } |
2367 | 2379 |
2368 } // namespace media | 2380 } // namespace media |
OLD | NEW |