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 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1925 base::Bind(&WebMediaPlayerImpl::FinishMemoryUsageReport, AsWeakPtr())); | 1925 base::Bind(&WebMediaPlayerImpl::FinishMemoryUsageReport, AsWeakPtr())); |
1926 } else { | 1926 } else { |
1927 FinishMemoryUsageReport(0); | 1927 FinishMemoryUsageReport(0); |
1928 } | 1928 } |
1929 } | 1929 } |
1930 | 1930 |
1931 void WebMediaPlayerImpl::FinishMemoryUsageReport(int64_t demuxer_memory_usage) { | 1931 void WebMediaPlayerImpl::FinishMemoryUsageReport(int64_t demuxer_memory_usage) { |
1932 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1932 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1933 | 1933 |
1934 const PipelineStatistics stats = pipeline_.GetStatistics(); | 1934 const PipelineStatistics stats = pipeline_.GetStatistics(); |
1935 const int64_t data_source_memory_usage = | |
1936 data_source_ ? data_source_->GetMemoryUsage() : 0; | |
1935 const int64_t current_memory_usage = | 1937 const int64_t current_memory_usage = |
1936 stats.audio_memory_usage + stats.video_memory_usage + | 1938 stats.audio_memory_usage + stats.video_memory_usage + |
1937 (data_source_ ? data_source_->GetMemoryUsage() : 0) + | 1939 data_source_memory_usage + demuxer_memory_usage; |
1938 demuxer_memory_usage; | |
1939 | 1940 |
1940 // Note, this isn't entirely accurate, there may be VideoFrames held by the | 1941 // Note, this isn't entirely accurate, there may be VideoFrames held by the |
1941 // compositor or other resources that we're unaware of. | 1942 // compositor or other resources that we're unaware of. |
1942 | 1943 |
1943 DVLOG(2) << "Memory Usage -- Audio: " << stats.audio_memory_usage | 1944 DVLOG(2) << "Memory Usage -- Audio: " << stats.audio_memory_usage |
1944 << ", Video: " << stats.video_memory_usage << ", DataSource: " | 1945 << ", Video: " << stats.video_memory_usage |
1945 << (data_source_ ? data_source_->GetMemoryUsage() : 0) | 1946 << ", DataSource: " << data_source_memory_usage |
1946 << ", Demuxer: " << demuxer_memory_usage; | 1947 << ", Demuxer: " << demuxer_memory_usage; |
1947 | 1948 |
1948 const int64_t delta = current_memory_usage - last_reported_memory_usage_; | 1949 const int64_t delta = current_memory_usage - last_reported_memory_usage_; |
1949 last_reported_memory_usage_ = current_memory_usage; | 1950 last_reported_memory_usage_ = current_memory_usage; |
1950 adjust_allocated_memory_cb_.Run(delta); | 1951 adjust_allocated_memory_cb_.Run(delta); |
1952 | |
1953 if (stats.audio_memory_usage > 0) { | |
DaleCurtis
2016/12/14 20:38:55
I think you want hasAudio(), hasVideo(), hasDataSo
servolk
2016/12/14 21:42:00
Done.
| |
1954 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.Audio", | |
1955 stats.audio_memory_usage / 1024); | |
1956 } | |
1957 if (stats.video_memory_usage > 0) { | |
1958 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.Video", | |
1959 stats.video_memory_usage / 1024); | |
1960 } | |
1961 if (data_source_memory_usage > 0) { | |
1962 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.DataSource", | |
1963 data_source_memory_usage / 1024); | |
1964 } | |
1965 if (demuxer_memory_usage > 0) { | |
1966 UMA_HISTOGRAM_MEMORY_KB("Media.WebMediaPlayerImpl.Memory.Demuxer", | |
1967 demuxer_memory_usage / 1024); | |
1968 } | |
1951 } | 1969 } |
1952 | 1970 |
1953 void WebMediaPlayerImpl::ScheduleIdlePauseTimer() { | 1971 void WebMediaPlayerImpl::ScheduleIdlePauseTimer() { |
1954 // Only schedule the pause timer if we're playing and are suspended. | 1972 // Only schedule the pause timer if we're playing and are suspended. |
1955 if (paused_ || !pipeline_controller_.IsSuspended()) | 1973 if (paused_ || !pipeline_controller_.IsSuspended()) |
1956 return; | 1974 return; |
1957 | 1975 |
1958 #if defined(OS_ANDROID) | 1976 #if defined(OS_ANDROID) |
1959 // Remote players will be suspended and locally paused. | 1977 // Remote players will be suspended and locally paused. |
1960 if (isRemote()) | 1978 if (isRemote()) |
(...skipping 18 matching lines...) Expand all Loading... | |
1979 watch_time_reporter_->OnShown(); | 1997 watch_time_reporter_->OnShown(); |
1980 } | 1998 } |
1981 | 1999 |
1982 bool WebMediaPlayerImpl::IsHidden() const { | 2000 bool WebMediaPlayerImpl::IsHidden() const { |
1983 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 2001 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1984 | 2002 |
1985 return delegate_ && delegate_->IsHidden(); | 2003 return delegate_ && delegate_->IsHidden(); |
1986 } | 2004 } |
1987 | 2005 |
1988 } // namespace media | 2006 } // namespace media |
OLD | NEW |