Chromium Code Reviews| 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..804bc827c998214dd9661ef1bbaded1395399827 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/modules/mediacapturefromelement/HTMLCanvasElementCapture.cpp |
| @@ -0,0 +1,41 @@ |
| +// 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 "platform/Logging.h" |
| +#include "platform/NotImplemented.h" |
| +#include "platform/mediastream/MediaStreamCenter.h" |
| +#include "public/platform/Platform.h" |
| +#include "public/platform/WebCanvasCaptureHandler.h" |
| +#include "public/platform/WebMediaStream.h" |
| +#include "public/platform/WebMediaStreamSource.h" |
| +#include "public/platform/WebMediaStreamTrack.h" |
|
haraken
2015/12/04 03:55:07
You're including a bit too much.
emircan
2015/12/04 04:46:15
Oops. I am cleaning it up. Thanks for the catch.
|
| + |
| +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)); |
| + return CanvasCaptureMediaStream::create(stream, &element, handler.release()); |
| +} |
| + |
| +} // namespace blink |