| 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> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
| 15 #include "base/callback.h" | 15 #include "base/callback.h" |
| 16 #include "base/callback_helpers.h" | 16 #include "base/callback_helpers.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/debug/alias.h" | 18 #include "base/debug/alias.h" |
| 19 #include "base/debug/crash_logging.h" | 19 #include "base/debug/crash_logging.h" |
| 20 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
| 21 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
| 22 #include "base/strings/string_number_conversions.h" |
| 22 #include "base/task_runner_util.h" | 23 #include "base/task_runner_util.h" |
| 23 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
| 24 #include "base/trace_event/trace_event.h" | 25 #include "base/trace_event/trace_event.h" |
| 25 #include "build/build_config.h" | 26 #include "build/build_config.h" |
| 26 #include "cc/blink/web_layer_impl.h" | 27 #include "cc/blink/web_layer_impl.h" |
| 27 #include "cc/layers/video_layer.h" | 28 #include "cc/layers/video_layer.h" |
| 28 #include "media/audio/null_audio_sink.h" | 29 #include "media/audio/null_audio_sink.h" |
| 29 #include "media/base/bind_to_current_loop.h" | 30 #include "media/base/bind_to_current_loop.h" |
| 30 #include "media/base/cdm_context.h" | 31 #include "media/base/cdm_context.h" |
| 31 #include "media/base/limits.h" | 32 #include "media/base/limits.h" |
| (...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 std::unique_ptr<MediaTracks> tracks) { | 838 std::unique_ptr<MediaTracks> tracks) { |
| 838 // For MSE/chunk_demuxer case the media track updates are handled by | 839 // For MSE/chunk_demuxer case the media track updates are handled by |
| 839 // WebSourceBufferImpl. | 840 // WebSourceBufferImpl. |
| 840 DCHECK(demuxer_.get()); | 841 DCHECK(demuxer_.get()); |
| 841 DCHECK(!chunk_demuxer_); | 842 DCHECK(!chunk_demuxer_); |
| 842 | 843 |
| 843 // Report the media track information to blink. | 844 // Report the media track information to blink. |
| 844 for (const auto& track : tracks->tracks()) { | 845 for (const auto& track : tracks->tracks()) { |
| 845 if (track->type() == MediaTrack::Audio) { | 846 if (track->type() == MediaTrack::Audio) { |
| 846 auto track_id = client_->addAudioTrack( | 847 auto track_id = client_->addAudioTrack( |
| 847 blink::WebString::fromUTF8(track->id()), | 848 blink::WebString::fromUTF8( |
| 849 base::UintToString(track->bytestream_track_id())), |
| 848 blink::WebMediaPlayerClient::AudioTrackKindMain, | 850 blink::WebMediaPlayerClient::AudioTrackKindMain, |
| 849 blink::WebString::fromUTF8(track->label()), | 851 blink::WebString::fromUTF8(track->label()), |
| 850 blink::WebString::fromUTF8(track->language()), | 852 blink::WebString::fromUTF8(track->language()), |
| 851 /*enabled*/ true); | 853 /*enabled*/ true); |
| 852 (void)track_id; | 854 (void)track_id; |
| 853 } else if (track->type() == MediaTrack::Video) { | 855 } else if (track->type() == MediaTrack::Video) { |
| 854 auto track_id = client_->addVideoTrack( | 856 auto track_id = client_->addVideoTrack( |
| 855 blink::WebString::fromUTF8(track->id()), | 857 blink::WebString::fromUTF8( |
| 858 base::UintToString(track->bytestream_track_id())), |
| 856 blink::WebMediaPlayerClient::VideoTrackKindMain, | 859 blink::WebMediaPlayerClient::VideoTrackKindMain, |
| 857 blink::WebString::fromUTF8(track->label()), | 860 blink::WebString::fromUTF8(track->label()), |
| 858 blink::WebString::fromUTF8(track->language()), | 861 blink::WebString::fromUTF8(track->language()), |
| 859 /*selected*/ true); | 862 /*selected*/ true); |
| 860 (void)track_id; | 863 (void)track_id; |
| 861 } else { | 864 } else { |
| 862 // Text tracks are not supported through this code path yet. | 865 // Text tracks are not supported through this code path yet. |
| 863 NOTREACHED(); | 866 NOTREACHED(); |
| 864 } | 867 } |
| 865 } | 868 } |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1613 << ", Video: " << stats.video_memory_usage << ", DataSource: " | 1616 << ", Video: " << stats.video_memory_usage << ", DataSource: " |
| 1614 << (data_source_ ? data_source_->GetMemoryUsage() : 0) | 1617 << (data_source_ ? data_source_->GetMemoryUsage() : 0) |
| 1615 << ", Demuxer: " << demuxer_memory_usage; | 1618 << ", Demuxer: " << demuxer_memory_usage; |
| 1616 | 1619 |
| 1617 const int64_t delta = current_memory_usage - last_reported_memory_usage_; | 1620 const int64_t delta = current_memory_usage - last_reported_memory_usage_; |
| 1618 last_reported_memory_usage_ = current_memory_usage; | 1621 last_reported_memory_usage_ = current_memory_usage; |
| 1619 adjust_allocated_memory_cb_.Run(delta); | 1622 adjust_allocated_memory_cb_.Run(delta); |
| 1620 } | 1623 } |
| 1621 | 1624 |
| 1622 } // namespace media | 1625 } // namespace media |
| OLD | NEW |