OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_CANVAS_CAPTURE_HANDLER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_CANVAS_CAPTURE_HANDLER_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/threading/thread_checker.h" |
| 12 #include "content/common/content_export.h" |
| 13 #include "media/base/video_capturer_source.h" |
| 14 #include "media/base/video_frame_pool.h" |
| 15 #include "third_party/WebKit/public/platform/WebCanvasCaptureHandler.h" |
| 16 #include "third_party/WebKit/public/platform/WebMediaStream.h" |
| 17 #include "third_party/WebKit/public/platform/WebSize.h" |
| 18 #include "third_party/WebKit/public/platform/WebSkImage.h" |
| 19 #include "third_party/skia/include/core/SkImage.h" |
| 20 |
| 21 namespace content { |
| 22 |
| 23 class CONTENT_EXPORT CanvasCaptureHandler final |
| 24 : public NON_EXPORTED_BASE(blink::WebCanvasCaptureHandler) { |
| 25 public: |
| 26 CanvasCaptureHandler(const blink::WebSize& size, |
| 27 double frame_rate, |
| 28 blink::WebMediaStream* stream); |
| 29 |
| 30 // blink::WebCanvasCaptureHandler Implementation. |
| 31 void sendNewFrame(const blink::WebSkImage& image) override; |
| 32 bool needsNewFrameCapture() const override; |
| 33 |
| 34 // Functions called by media::VideoCapturerSource implementation. |
| 35 void StartVideoCapture( |
| 36 const media::VideoCaptureParams& params, |
| 37 const media::VideoCapturerSource::VideoCaptureDeliverFrameCB& |
| 38 new_frame_callback, |
| 39 const media::VideoCapturerSource::RunningCallback& running_callback); |
| 40 void StopVideoCapture(); |
| 41 blink::WebSize GetSourceSize() const { return size_; } |
| 42 double GetSourceFrameRate() const { return frame_rate_; } |
| 43 |
| 44 private: |
| 45 virtual ~CanvasCaptureHandler(); |
| 46 |
| 47 void CreateNewFrame(const blink::WebSkImage& image); |
| 48 |
| 49 // Implementation VideoCapturerSource that is owned by blink and delegates |
| 50 // the Start/Stop calls to CanvasCaptureHandler. |
| 51 class VideoCapturerSource; |
| 52 // Object that does all the work of running |new_frame_callback_|. |
| 53 // Destroyed on |io_task_runner_| after the class is destroyed. |
| 54 class CanvasCaptureHandlerDelegate; |
| 55 |
| 56 media::VideoCaptureFormat capture_format_; |
| 57 double frame_rate_; |
| 58 bool ask_for_new_frame_; |
| 59 |
| 60 const blink::WebSize size_; |
| 61 gfx::Size last_size; |
| 62 std::vector<uint8> temp_data_; |
| 63 size_t row_bytes_; |
| 64 SkImageInfo image_info_; |
| 65 media::VideoFramePool frame_pool_; |
| 66 |
| 67 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 68 scoped_ptr<CanvasCaptureHandlerDelegate> delegate_; |
| 69 // Bound to the main render thread. |
| 70 base::ThreadChecker thread_checker_; |
| 71 |
| 72 DISALLOW_COPY_AND_ASSIGN(CanvasCaptureHandler); |
| 73 }; |
| 74 |
| 75 } // namespace content |
| 76 |
| 77 #endif // CONTENT_RENDERER_MEDIA_CANVAS_CAPTURE_HANDLER_H_ |
OLD | NEW |