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 "modules/mediacapturefromelement/HTMLCanvasElementCapture.h" | 5 #include "modules/mediacapturefromelement/HTMLCanvasElementCapture.h" |
6 | 6 |
7 #include "core/dom/ExceptionCode.h" | 7 #include "core/dom/ExceptionCode.h" |
8 #include "core/html/HTMLCanvasElement.h" | 8 #include "core/html/HTMLCanvasElement.h" |
9 #include "modules/mediacapturefromelement/CanvasCaptureMediaStreamTrack.h" | 9 #include "modules/mediacapturefromelement/CanvasCaptureMediaStreamTrack.h" |
10 #include "modules/mediastream/MediaStream.h" | 10 #include "modules/mediastream/MediaStream.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 ExceptionState& exceptionState) { | 49 ExceptionState& exceptionState) { |
50 if (!element.originClean()) { | 50 if (!element.originClean()) { |
51 exceptionState.throwSecurityError("Canvas is not origin-clean."); | 51 exceptionState.throwSecurityError("Canvas is not origin-clean."); |
52 return nullptr; | 52 return nullptr; |
53 } | 53 } |
54 | 54 |
55 WebMediaStreamTrack track; | 55 WebMediaStreamTrack track; |
56 const WebSize size(element.width(), element.height()); | 56 const WebSize size(element.width(), element.height()); |
57 std::unique_ptr<WebCanvasCaptureHandler> handler; | 57 std::unique_ptr<WebCanvasCaptureHandler> handler; |
58 if (givenFrameRate) | 58 if (givenFrameRate) |
59 handler = wrapUnique(Platform::current()->createCanvasCaptureHandler( | 59 handler = WTF::wrapUnique(Platform::current()->createCanvasCaptureHandler( |
60 size, frameRate, &track)); | 60 size, frameRate, &track)); |
61 else | 61 else |
62 handler = wrapUnique(Platform::current()->createCanvasCaptureHandler( | 62 handler = WTF::wrapUnique(Platform::current()->createCanvasCaptureHandler( |
63 size, kDefaultFrameRate, &track)); | 63 size, kDefaultFrameRate, &track)); |
64 | 64 |
65 if (!handler) { | 65 if (!handler) { |
66 exceptionState.throwDOMException( | 66 exceptionState.throwDOMException( |
67 NotSupportedError, "No CanvasCapture handler can be created."); | 67 NotSupportedError, "No CanvasCapture handler can be created."); |
68 return nullptr; | 68 return nullptr; |
69 } | 69 } |
70 | 70 |
71 CanvasCaptureMediaStreamTrack* canvasTrack; | 71 CanvasCaptureMediaStreamTrack* canvasTrack; |
72 if (givenFrameRate) | 72 if (givenFrameRate) |
73 canvasTrack = CanvasCaptureMediaStreamTrack::create( | 73 canvasTrack = CanvasCaptureMediaStreamTrack::create( |
74 track, &element, std::move(handler), frameRate); | 74 track, &element, std::move(handler), frameRate); |
75 else | 75 else |
76 canvasTrack = CanvasCaptureMediaStreamTrack::create(track, &element, | 76 canvasTrack = CanvasCaptureMediaStreamTrack::create(track, &element, |
77 std::move(handler)); | 77 std::move(handler)); |
78 // We want to capture a frame in the beginning. | 78 // We want to capture a frame in the beginning. |
79 canvasTrack->requestFrame(); | 79 canvasTrack->requestFrame(); |
80 | 80 |
81 MediaStreamTrackVector tracks; | 81 MediaStreamTrackVector tracks; |
82 tracks.append(canvasTrack); | 82 tracks.append(canvasTrack); |
83 return MediaStream::create(element.getExecutionContext(), tracks); | 83 return MediaStream::create(element.getExecutionContext(), tracks); |
84 } | 84 } |
85 | 85 |
86 } // namespace blink | 86 } // namespace blink |
OLD | NEW |