| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/mediacapturefromelement/HTMLCanvasElementCapture.h" | 6 #include "modules/mediacapturefromelement/HTMLCanvasElementCapture.h" |
| 7 | 7 |
| 8 #include "core/dom/ExceptionCode.h" | 8 #include "core/dom/ExceptionCode.h" |
| 9 #include "core/html/HTMLCanvasElement.h" | 9 #include "core/html/HTMLCanvasElement.h" |
| 10 #include "modules/mediacapturefromelement/CanvasCaptureMediaStream.h" | 10 #include "modules/mediacapturefromelement/CanvasCaptureMediaStreamTrack.h" |
| 11 #include "modules/mediastream/MediaStream.h" |
| 11 #include "public/platform/Platform.h" | 12 #include "public/platform/Platform.h" |
| 12 #include "public/platform/WebCanvasCaptureHandler.h" | 13 #include "public/platform/WebCanvasCaptureHandler.h" |
| 13 #include "public/platform/WebMediaStream.h" | 14 #include "public/platform/WebMediaStream.h" |
| 14 #include "public/platform/WebMediaStreamTrack.h" | 15 #include "public/platform/WebMediaStreamTrack.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 const double kDefaultFrameRate = 60.0; | 18 const double kDefaultFrameRate = 60.0; |
| 18 } // anonymous namespace | 19 } // anonymous namespace |
| 19 | 20 |
| 20 namespace blink { | 21 namespace blink { |
| 21 | 22 |
| 22 CanvasCaptureMediaStream* HTMLCanvasElementCapture::captureStream(HTMLCanvasElem
ent& element, ExceptionState& exceptionState) | 23 MediaStream* HTMLCanvasElementCapture::captureStream(HTMLCanvasElement& element,
ExceptionState& exceptionState) |
| 23 { | 24 { |
| 24 WebMediaStream stream; | |
| 25 stream.initialize(WebVector<WebMediaStreamTrack>(), Vector<WebMediaStreamTra
ck>()); | |
| 26 WebSize size(element.width(), element.height()); | |
| 27 | |
| 28 if (!element.originClean()) { | 25 if (!element.originClean()) { |
| 29 exceptionState.throwDOMException(SecurityError, "Canvas is not origin-cl
ean."); | 26 exceptionState.throwDOMException(SecurityError, "Canvas is not origin-cl
ean."); |
| 30 return CanvasCaptureMediaStream::create(stream, &element); | 27 return MediaStream::create(element.executionContext()); |
| 31 } | 28 } |
| 32 | 29 |
| 33 OwnPtr<WebCanvasCaptureHandler> handler = adoptPtr(Platform::current()->crea
teCanvasCaptureHandler(size, kDefaultFrameRate, &stream)); | 30 WebMediaStreamTrack track; |
| 31 WebSize size(element.width(), element.height()); |
| 32 OwnPtr<WebCanvasCaptureHandler> handler = adoptPtr(Platform::current()->crea
teCanvasCaptureHandler(size, kDefaultFrameRate, &track)); |
| 34 ASSERT(handler); | 33 ASSERT(handler); |
| 35 if (!handler) { | 34 if (!handler) { |
| 36 exceptionState.throwDOMException(NotSupportedError, "No CanvasCapture ha
ndler can be created."); | 35 exceptionState.throwDOMException(NotSupportedError, "No CanvasCapture ha
ndler can be created."); |
| 37 return CanvasCaptureMediaStream::create(stream, &element); | 36 return MediaStream::create(element.executionContext()); |
| 38 } | 37 } |
| 39 | 38 |
| 40 return CanvasCaptureMediaStream::create(stream, &element, handler.release())
; | 39 MediaStreamTrackVector tracks; |
| 40 tracks.append(CanvasCaptureMediaStreamTrack::create(track, &element, handler
.release())); |
| 41 return MediaStream::create(element.executionContext(), tracks); |
| 41 } | 42 } |
| 42 | 43 |
| 43 } // namespace blink | 44 } // namespace blink |
| OLD | NEW |