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