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 #include "config.h" |
| 6 #include "modules/mediacapturefromelement/HTMLCanvasElementCapture.h" |
| 7 |
| 8 #include "core/dom/ExceptionCode.h" |
| 9 #include "core/html/HTMLCanvasElement.h" |
| 10 #include "modules/mediacapturefromelement/CanvasCaptureMediaStream.h" |
| 11 #include "public/platform/Platform.h" |
| 12 #include "public/platform/WebCanvasCaptureHandler.h" |
| 13 #include "public/platform/WebMediaStream.h" |
| 14 #include "public/platform/WebMediaStreamTrack.h" |
| 15 |
| 16 namespace { |
| 17 const double kDefaultFrameRate = 60.0; |
| 18 } // anonymous namespace |
| 19 |
| 20 namespace blink { |
| 21 |
| 22 CanvasCaptureMediaStream* HTMLCanvasElementCapture::captureStream(HTMLCanvasElem
ent& element, ExceptionState& exceptionState) |
| 23 { |
| 24 WebMediaStream stream; |
| 25 stream.initialize(WebVector<WebMediaStreamTrack>(), Vector<WebMediaStreamTra
ck>()); |
| 26 WebSize size(element.width(), element.height()); |
| 27 |
| 28 if (!element.originClean()) { |
| 29 exceptionState.throwDOMException(SecurityError, "Canvas is not origin-cl
ean."); |
| 30 return CanvasCaptureMediaStream::create(stream, &element); |
| 31 } |
| 32 |
| 33 OwnPtr<WebCanvasCaptureHandler> handler = adoptPtr(Platform::current()->crea
teCanvasCaptureHandler(size, kDefaultFrameRate, &stream)); |
| 34 ASSERT(handler); |
| 35 if (!handler) { |
| 36 exceptionState.throwDOMException(NotSupportedError, "No CanvasCapture ha
ndler can be created."); |
| 37 return CanvasCaptureMediaStream::create(stream, &element); |
| 38 } |
| 39 |
| 40 return CanvasCaptureMediaStream::create(stream, &element, handler.release())
; |
| 41 } |
| 42 |
| 43 } // namespace blink |
OLD | NEW |