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 #ifndef CONTENT_RENDERER_MEDIA_CAPTURE_FROM_ELEMENT_HTML_VIDEO_ELEMENT_CAPTURER_
SOURCE_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_CAPTURE_FROM_ELEMENT_HTML_VIDEO_ELEMENT_CAPTURER_
SOURCE_H_ |
6 #define CONTENT_RENDERER_MEDIA_CAPTURE_FROM_ELEMENT_HTML_VIDEO_ELEMENT_CAPTURER_
SOURCE_H_ | 6 #define CONTENT_RENDERER_MEDIA_CAPTURE_FROM_ELEMENT_HTML_VIDEO_ELEMENT_CAPTURER_
SOURCE_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "cc/paint/paint_surface.h" | |
13 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
14 #include "media/base/video_frame_pool.h" | 13 #include "media/base/video_frame_pool.h" |
15 #include "media/base/video_types.h" | 14 #include "media/base/video_types.h" |
16 #include "media/capture/video_capturer_source.h" | 15 #include "media/capture/video_capturer_source.h" |
17 #include "third_party/WebKit/public/platform/WebSize.h" | 16 #include "third_party/WebKit/public/platform/WebSize.h" |
18 #include "third_party/skia/include/core/SkRefCnt.h" | 17 #include "third_party/skia/include/core/SkRefCnt.h" |
19 | 18 |
20 namespace base{ | 19 namespace base{ |
21 class SingleThreadTaskRunner; | 20 class SingleThreadTaskRunner; |
22 } | 21 } |
23 | 22 |
24 namespace blink { | 23 namespace blink { |
25 class WebMediaPlayer; | 24 class WebMediaPlayer; |
26 } // namespace blink | 25 } // namespace blink |
27 | 26 |
| 27 namespace cc { |
| 28 class PaintCanvas; |
| 29 } // namespace cc |
| 30 |
28 namespace content { | 31 namespace content { |
29 | 32 |
30 // This class is a VideoCapturerSource taking video snapshots of the ctor-passed | 33 // This class is a VideoCapturerSource taking video snapshots of the ctor-passed |
31 // blink::WebMediaPlayer on Render Main thread. The captured data is converted | 34 // blink::WebMediaPlayer on Render Main thread. The captured data is converted |
32 // and sent back to |io_task_runner_| via the registered |new_frame_callback_|. | 35 // and sent back to |io_task_runner_| via the registered |new_frame_callback_|. |
33 class CONTENT_EXPORT HtmlVideoElementCapturerSource final | 36 class CONTENT_EXPORT HtmlVideoElementCapturerSource final |
34 : public media::VideoCapturerSource { | 37 : public media::VideoCapturerSource { |
35 public: | 38 public: |
36 static std::unique_ptr<HtmlVideoElementCapturerSource> | 39 static std::unique_ptr<HtmlVideoElementCapturerSource> |
37 CreateFromWebMediaPlayerImpl( | 40 CreateFromWebMediaPlayerImpl( |
(...skipping 15 matching lines...) Expand all Loading... |
53 const VideoCaptureDeliverFrameCB& new_frame_callback, | 56 const VideoCaptureDeliverFrameCB& new_frame_callback, |
54 const RunningCallback& running_callback) override; | 57 const RunningCallback& running_callback) override; |
55 void StopCapture() override; | 58 void StopCapture() override; |
56 | 59 |
57 private: | 60 private: |
58 // This method includes collecting data from the WebMediaPlayer and converting | 61 // This method includes collecting data from the WebMediaPlayer and converting |
59 // it into a format suitable for MediaStreams. | 62 // it into a format suitable for MediaStreams. |
60 void sendNewFrame(); | 63 void sendNewFrame(); |
61 | 64 |
62 media::VideoFramePool frame_pool_; | 65 media::VideoFramePool frame_pool_; |
63 sk_sp<cc::PaintSurface> surface_; | 66 std::unique_ptr<cc::PaintCanvas> canvas_; |
64 | 67 |
65 const base::WeakPtr<blink::WebMediaPlayer> web_media_player_; | 68 const base::WeakPtr<blink::WebMediaPlayer> web_media_player_; |
66 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 69 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
67 | 70 |
68 // These three configuration items are passed on StartCapture(); | 71 // These three configuration items are passed on StartCapture(); |
69 RunningCallback running_callback_; | 72 RunningCallback running_callback_; |
70 VideoCaptureDeliverFrameCB new_frame_callback_; | 73 VideoCaptureDeliverFrameCB new_frame_callback_; |
71 double capture_frame_rate_; | 74 double capture_frame_rate_; |
72 | 75 |
73 // Target time for the next frame. | 76 // Target time for the next frame. |
74 base::TimeTicks next_capture_time_; | 77 base::TimeTicks next_capture_time_; |
75 | 78 |
76 // Bound to the main render thread. | 79 // Bound to the main render thread. |
77 base::ThreadChecker thread_checker_; | 80 base::ThreadChecker thread_checker_; |
78 | 81 |
79 // Used on main render thread to schedule future capture events. | 82 // Used on main render thread to schedule future capture events. |
80 base::WeakPtrFactory<HtmlVideoElementCapturerSource> weak_factory_; | 83 base::WeakPtrFactory<HtmlVideoElementCapturerSource> weak_factory_; |
81 | 84 |
82 DISALLOW_COPY_AND_ASSIGN(HtmlVideoElementCapturerSource); | 85 DISALLOW_COPY_AND_ASSIGN(HtmlVideoElementCapturerSource); |
83 }; | 86 }; |
84 | 87 |
85 } // namespace content | 88 } // namespace content |
86 | 89 |
87 #endif // CONTENT_RENDERER_MEDIA_CAPTURE_FROM_ELEMENT_HTML_VIDEO_ELEMENT_CAPTUR
ER_SOURCE_H_ | 90 #endif // CONTENT_RENDERER_MEDIA_CAPTURE_FROM_ELEMENT_HTML_VIDEO_ELEMENT_CAPTUR
ER_SOURCE_H_ |
OLD | NEW |