OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/renderer/media/html_video_element_capturer_source.h" | 5 #include "content/renderer/media/html_video_element_capturer_source.h" |
6 | 6 |
7 #include "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "content/public/renderer/render_thread.h" | 9 #include "content/public/renderer/render_thread.h" |
10 #include "content/renderer/media/media_stream_video_source.h" | 10 #include "content/renderer/media/media_stream_video_source.h" |
| 11 #include "content/renderer/media/webrtc_uma_histograms.h" |
11 #include "media/base/limits.h" | 12 #include "media/base/limits.h" |
12 #include "media/blink/webmediaplayer_impl.h" | 13 #include "media/blink/webmediaplayer_impl.h" |
13 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | 14 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" |
14 #include "third_party/WebKit/public/platform/WebRect.h" | 15 #include "third_party/WebKit/public/platform/WebRect.h" |
15 #include "third_party/WebKit/public/platform/WebSize.h" | 16 #include "third_party/WebKit/public/platform/WebSize.h" |
16 #include "third_party/libyuv/include/libyuv.h" | 17 #include "third_party/libyuv/include/libyuv.h" |
17 #include "third_party/skia/include/core/SkCanvas.h" | 18 #include "third_party/skia/include/core/SkCanvas.h" |
18 #include "third_party/skia/include/core/SkXfermode.h" | 19 #include "third_party/skia/include/core/SkXfermode.h" |
19 | 20 |
20 namespace { | 21 namespace { |
21 const float kMinFramesPerSecond = 1.0; | 22 const float kMinFramesPerSecond = 1.0; |
22 } // anonymous namespace | 23 } // anonymous namespace |
23 | 24 |
24 namespace content { | 25 namespace content { |
25 | 26 |
26 //static | 27 //static |
27 scoped_ptr<HtmlVideoElementCapturerSource> | 28 scoped_ptr<HtmlVideoElementCapturerSource> |
28 HtmlVideoElementCapturerSource::CreateFromWebMediaPlayerImpl( | 29 HtmlVideoElementCapturerSource::CreateFromWebMediaPlayerImpl( |
29 blink::WebMediaPlayer* player, | 30 blink::WebMediaPlayer* player, |
30 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) { | 31 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) { |
| 32 // Save histogram data so we can see how much HTML Video capture is used. |
| 33 // The histogram counts the number of calls to the JS API. |
| 34 UpdateWebRTCMethodCount(WEBKIT_VIDEO_CAPTURE_STREAM); |
| 35 |
31 return make_scoped_ptr(new HtmlVideoElementCapturerSource( | 36 return make_scoped_ptr(new HtmlVideoElementCapturerSource( |
32 static_cast<media::WebMediaPlayerImpl*>(player)->AsWeakPtr(), | 37 static_cast<media::WebMediaPlayerImpl*>(player)->AsWeakPtr(), |
33 io_task_runner)); | 38 io_task_runner)); |
34 } | 39 } |
35 | 40 |
36 HtmlVideoElementCapturerSource::HtmlVideoElementCapturerSource( | 41 HtmlVideoElementCapturerSource::HtmlVideoElementCapturerSource( |
37 const base::WeakPtr<blink::WebMediaPlayer>& player, | 42 const base::WeakPtr<blink::WebMediaPlayer>& player, |
38 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) | 43 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner) |
39 : web_media_player_(player), | 44 : web_media_player_(player), |
40 io_task_runner_(io_task_runner), | 45 io_task_runner_(io_task_runner), |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 next_capture_time_ = current_time; | 180 next_capture_time_ = current_time; |
176 } | 181 } |
177 // Schedule next capture. | 182 // Schedule next capture. |
178 base::MessageLoop::current()->PostDelayedTask( | 183 base::MessageLoop::current()->PostDelayedTask( |
179 FROM_HERE, base::Bind(&HtmlVideoElementCapturerSource::sendNewFrame, | 184 FROM_HERE, base::Bind(&HtmlVideoElementCapturerSource::sendNewFrame, |
180 weak_factory_.GetWeakPtr()), | 185 weak_factory_.GetWeakPtr()), |
181 next_capture_time_ - current_time); | 186 next_capture_time_ - current_time); |
182 } | 187 } |
183 | 188 |
184 } // namespace content | 189 } // namespace content |
OLD | NEW |