| 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_CANVAS_CAPTURE_HANDLER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_CANVAS_CAPTURE_HANDLER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_CANVAS_CAPTURE_HANDLER_H_ | 6 #define CONTENT_RENDERER_MEDIA_CANVAS_CAPTURE_HANDLER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "content/renderer/render_view_impl.h" |
| 16 #include "media/base/video_capturer_source.h" | 17 #include "media/base/video_capturer_source.h" |
| 17 #include "media/base/video_frame_pool.h" | 18 #include "media/base/video_frame_pool.h" |
| 18 #include "third_party/WebKit/public/platform/WebCanvasCaptureHandler.h" | 19 #include "third_party/WebKit/public/platform/WebCanvasCaptureHandler.h" |
| 19 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 20 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 20 #include "third_party/WebKit/public/platform/WebSize.h" | 21 #include "third_party/WebKit/public/platform/WebSize.h" |
| 21 #include "third_party/skia/include/core/SkImage.h" | 22 #include "third_party/skia/include/core/SkImage.h" |
| 22 | 23 |
| 23 namespace content { | 24 namespace content { |
| 24 | 25 |
| 25 // CanvasCaptureHandler acts as the link between Blink side HTMLCanvasElement | 26 // CanvasCaptureHandler acts as the link between Blink side HTMLCanvasElement |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 blink::WebMediaStreamTrack* web_track); | 74 blink::WebMediaStreamTrack* web_track); |
| 74 | 75 |
| 75 // Implementation VideoCapturerSource that is owned by Blink and delegates | 76 // Implementation VideoCapturerSource that is owned by Blink and delegates |
| 76 // the Start/Stop calls to CanvasCaptureHandler. | 77 // the Start/Stop calls to CanvasCaptureHandler. |
| 77 class VideoCapturerSource; | 78 class VideoCapturerSource; |
| 78 | 79 |
| 79 // Object that does all the work of running |new_frame_callback_|. | 80 // Object that does all the work of running |new_frame_callback_|. |
| 80 // Destroyed on |frame_callback_task_runner_| after the class is destroyed. | 81 // Destroyed on |frame_callback_task_runner_| after the class is destroyed. |
| 81 class CanvasCaptureHandlerDelegate; | 82 class CanvasCaptureHandlerDelegate; |
| 82 | 83 |
| 84 RenderViewImpl* render_view_; |
| 85 |
| 83 media::VideoCaptureFormat capture_format_; | 86 media::VideoCaptureFormat capture_format_; |
| 84 bool ask_for_new_frame_; | 87 bool ask_for_new_frame_; |
| 85 | 88 |
| 86 const blink::WebSize size_; | 89 const blink::WebSize size_; |
| 87 gfx::Size last_size; | 90 gfx::Size last_size; |
| 88 std::vector<uint8_t> temp_data_; | 91 std::vector<uint8_t> temp_data_; |
| 89 size_t row_bytes_; | 92 size_t row_bytes_; |
| 90 SkImageInfo image_info_; | 93 SkImageInfo image_info_; |
| 91 media::VideoFramePool frame_pool_; | 94 media::VideoFramePool frame_pool_; |
| 92 | 95 |
| 96 // Keeps track of the capture count increment. Safe to use a boolean |
| 97 // since the methods are single threaded. |
| 98 bool capturer_count_incremented_; |
| 99 |
| 93 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 100 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 94 scoped_ptr<CanvasCaptureHandlerDelegate> delegate_; | 101 scoped_ptr<CanvasCaptureHandlerDelegate> delegate_; |
| 95 // Bound to the main render thread. | 102 // Bound to the main render thread. |
| 96 base::ThreadChecker thread_checker_; | 103 base::ThreadChecker thread_checker_; |
| 97 base::WeakPtrFactory<CanvasCaptureHandler> weak_ptr_factory_; | 104 base::WeakPtrFactory<CanvasCaptureHandler> weak_ptr_factory_; |
| 98 | 105 |
| 99 DISALLOW_COPY_AND_ASSIGN(CanvasCaptureHandler); | 106 DISALLOW_COPY_AND_ASSIGN(CanvasCaptureHandler); |
| 100 }; | 107 }; |
| 101 | 108 |
| 102 } // namespace content | 109 } // namespace content |
| 103 | 110 |
| 104 #endif // CONTENT_RENDERER_MEDIA_CANVAS_CAPTURE_HANDLER_H_ | 111 #endif // CONTENT_RENDERER_MEDIA_CANVAS_CAPTURE_HANDLER_H_ |
| OLD | NEW |