Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: content/renderer/media/canvas_capture_handler.h

Issue 1467103003: Basic use implementation for MediaStream from Canvas: captureStream() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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.h"
12 #include "base/threading/thread_checker.h"
13 #include "content/common/content_export.h"
14 #include "media/base/video_capturer_source.h"
15 #include "media/base/video_frame_pool.h"
16 #include "media/base/video_types.h"
17 #include "third_party/WebKit/public/platform/WebCanvasCaptureHandler.h"
18 #include "third_party/WebKit/public/platform/WebMediaStream.h"
19 #include "third_party/WebKit/public/platform/WebSize.h"
20 #include "third_party/WebKit/public/platform/WebSkImage.h"
21 #include "third_party/skia/include/core/SkImage.h"
22
23 namespace content {
24
25 class CONTENT_EXPORT CanvasCaptureHandler final
26 : public NON_EXPORTED_BASE(blink::WebCanvasCaptureHandler) {
27 public:
28 CanvasCaptureHandler(const blink::WebSize& size,
29 blink::WebMediaStream* stream);
30
31 // blink::WebCanvasCaptureHandler Implementation.
32 void sendNewFrame(const blink::WebSkImage& image) override;
33 bool needsNewFrameCapture() const override;
34
35 // media::VideoCapturerSource Implementation.
36 void StartVideoCapture(
37 const media::VideoCaptureParams& params,
38 const media::VideoCapturerSource::VideoCaptureDeliverFrameCB&
39 new_frame_callback,
40 const media::VideoCapturerSource::RunningCallback& running_callback);
41 void StopVideoCapture();
42 blink::WebSize GetSourceSize() { return size_; }
43
44 private:
45 virtual ~CanvasCaptureHandler();
46
47 class VideoCapturerSource;
48 // An object that does all the work of running |new_frame_callback_|.
49 // Destroyed on |io_task_runner_| after the class is destroyed.
50 class CanvasCaptureHandlerDelegate;
51 scoped_ptr<CanvasCaptureHandlerDelegate> delegate_;
52 void createNewFrame(const blink::WebSkImage& image);
53
54 media::VideoCaptureFormat capture_format_;
55 bool ask_for_new_frame_;
56
57 const blink::WebSize size_;
58 gfx::Size last_size;
59 std::vector<uint8> temp_data_;
60 size_t row_bytes_;
61 SkImageInfo image_info_;
62 media::VideoFramePool frame_pool_;
63
64 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
65 // Bound to the main render thread.
66 base::ThreadChecker thread_checker_;
67
68 DISALLOW_COPY_AND_ASSIGN(CanvasCaptureHandler);
69 };
70
71 } // namespace content
72
73 #endif // CONTENT_RENDERER_MEDIA_CANVAS_CAPTURE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698