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

Unified Diff: third_party/WebKit/Source/modules/mediacapturefromelement/HTMLCanvasElementCapture.cpp

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
Index: third_party/WebKit/Source/modules/mediacapturefromelement/HTMLCanvasElementCapture.cpp
diff --git a/third_party/WebKit/Source/modules/mediacapturefromelement/HTMLCanvasElementCapture.cpp b/third_party/WebKit/Source/modules/mediacapturefromelement/HTMLCanvasElementCapture.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6b114fe34b0e286012a700f6820725cc9a9d0f95
--- /dev/null
+++ b/third_party/WebKit/Source/modules/mediacapturefromelement/HTMLCanvasElementCapture.cpp
@@ -0,0 +1,43 @@
+// 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.
+
+#include "config.h"
+#include "modules/mediacapturefromelement/HTMLCanvasElementCapture.h"
+
+#include "core/dom/ExceptionCode.h"
+#include "core/html/HTMLCanvasElement.h"
+#include "modules/mediacapturefromelement/CanvasCaptureMediaStream.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebCanvasCaptureHandler.h"
+#include "public/platform/WebMediaStream.h"
+#include "public/platform/WebMediaStreamTrack.h"
+
+namespace {
+const double kDefaultFrameRate = 60.0;
+} // anonymous namespace
+
+namespace blink {
+
+CanvasCaptureMediaStream* HTMLCanvasElementCapture::captureStream(HTMLCanvasElement& element, ExceptionState& exceptionState)
+{
+ WebMediaStream stream;
+ stream.initialize(WebVector<WebMediaStreamTrack>(), Vector<WebMediaStreamTrack>());
+ WebSize size(element.width(), element.height());
+
+ if (!element.originClean()) {
+ exceptionState.throwDOMException(SecurityError, "Canvas is not origin-clean.");
+ return CanvasCaptureMediaStream::create(stream, &element);
+ }
+
+ OwnPtr<WebCanvasCaptureHandler> handler = adoptPtr(Platform::current()->createCanvasCaptureHandler(size, kDefaultFrameRate, &stream));
+ ASSERT(handler);
+ if (!handler) {
+ exceptionState.throwDOMException(NotSupportedError, "No CanvasCapture handler can be created.");
+ return CanvasCaptureMediaStream::create(stream, &element);
+ }
+
+ return CanvasCaptureMediaStream::create(stream, &element, handler.release());
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698