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