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

Unified 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: Added new interface to LayoutTests. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/media/canvas_capture_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/canvas_capture_handler.h
diff --git a/content/renderer/media/canvas_capture_handler.h b/content/renderer/media/canvas_capture_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..a7d54d2cb784768101cdc4b7daefd0258fa70ff8
--- /dev/null
+++ b/content/renderer/media/canvas_capture_handler.h
@@ -0,0 +1,76 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_MEDIA_CANVAS_CAPTURE_HANDLER_H_
+#define CONTENT_RENDERER_MEDIA_CANVAS_CAPTURE_HANDLER_H_
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/threading/thread_checker.h"
+#include "content/common/content_export.h"
+#include "media/base/video_capturer_source.h"
+#include "media/base/video_frame_pool.h"
+#include "third_party/WebKit/public/platform/WebCanvasCaptureHandler.h"
+#include "third_party/WebKit/public/platform/WebMediaStream.h"
+#include "third_party/WebKit/public/platform/WebSize.h"
+#include "third_party/WebKit/public/platform/WebSkImage.h"
+#include "third_party/skia/include/core/SkImage.h"
+
+namespace content {
+
+class CONTENT_EXPORT CanvasCaptureHandler final
+ : public NON_EXPORTED_BASE(blink::WebCanvasCaptureHandler) {
+ public:
+ CanvasCaptureHandler(const blink::WebSize& size,
+ double frame_rate,
+ blink::WebMediaStream* stream);
+
+ // blink::WebCanvasCaptureHandler Implementation.
+ void sendNewFrame(const blink::WebSkImage& image) override;
+ bool needsNewFrame() const override;
+
+ // Functions called by media::VideoCapturerSource implementation.
+ void StartVideoCapture(
+ const media::VideoCaptureParams& params,
+ const media::VideoCapturerSource::VideoCaptureDeliverFrameCB&
+ new_frame_callback,
+ const media::VideoCapturerSource::RunningCallback& running_callback);
+ void StopVideoCapture();
+ blink::WebSize GetSourceSize() const { return size_; }
+
+ private:
+ virtual ~CanvasCaptureHandler();
+
+ void CreateNewFrame(const blink::WebSkImage& image);
+
+ // Implementation VideoCapturerSource that is owned by blink and delegates
+ // the Start/Stop calls to CanvasCaptureHandler.
+ class VideoCapturerSource;
+ // Object that does all the work of running |new_frame_callback_|.
+ // Destroyed on |io_task_runner_| after the class is destroyed.
+ class CanvasCaptureHandlerDelegate;
+
+ media::VideoCaptureFormat capture_format_;
+ bool ask_for_new_frame_;
+
+ const blink::WebSize size_;
+ gfx::Size last_size;
+ std::vector<uint8> temp_data_;
+ size_t row_bytes_;
+ SkImageInfo image_info_;
+ media::VideoFramePool frame_pool_;
+
+ const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
+ scoped_ptr<CanvasCaptureHandlerDelegate> delegate_;
+ // Bound to the main render thread.
+ base::ThreadChecker thread_checker_;
+ base::WeakPtrFactory<CanvasCaptureHandler> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(CanvasCaptureHandler);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_MEDIA_CANVAS_CAPTURE_HANDLER_H_
« no previous file with comments | « content/content_renderer.gypi ('k') | content/renderer/media/canvas_capture_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698