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

Side by Side Diff: third_party/WebKit/Source/modules/mediacapturefromelement/HTMLCanvasElementCapture.cpp

Issue 1861963004: MediaRecorder: ASSERT-->DCHECK and a tiny cleanup in CanvasCapture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/mediarecorder/MediaRecorder.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 24 matching lines...) Expand all
35 } 35 }
36 36
37 MediaStream* HTMLCanvasElementCapture::captureStream(HTMLCanvasElement& element, bool givenFrameRate, double frameRate, ExceptionState& exceptionState) 37 MediaStream* HTMLCanvasElementCapture::captureStream(HTMLCanvasElement& element, bool givenFrameRate, double frameRate, ExceptionState& exceptionState)
38 { 38 {
39 if (!element.originClean()) { 39 if (!element.originClean()) {
40 exceptionState.throwSecurityError("Canvas is not origin-clean."); 40 exceptionState.throwSecurityError("Canvas is not origin-clean.");
41 return nullptr; 41 return nullptr;
42 } 42 }
43 43
44 WebMediaStreamTrack track; 44 WebMediaStreamTrack track;
45 WebSize size(element.width(), element.height()); 45 const WebSize size(element.width(), element.height());
46 OwnPtr<WebCanvasCaptureHandler> handler; 46 OwnPtr<WebCanvasCaptureHandler> handler;
47 if (givenFrameRate) 47 if (givenFrameRate)
48 handler = adoptPtr(Platform::current()->createCanvasCaptureHandler(size, frameRate, &track)); 48 handler = adoptPtr(Platform::current()->createCanvasCaptureHandler(size, frameRate, &track));
49 else 49 else
50 handler = adoptPtr(Platform::current()->createCanvasCaptureHandler(size, kDefaultFrameRate, &track)); 50 handler = adoptPtr(Platform::current()->createCanvasCaptureHandler(size, kDefaultFrameRate, &track));
51 ASSERT(handler); 51
52 if (!handler) { 52 if (!handler) {
53 exceptionState.throwDOMException(NotSupportedError, "No CanvasCapture ha ndler can be created."); 53 exceptionState.throwDOMException(NotSupportedError, "No CanvasCapture ha ndler can be created.");
54 return nullptr; 54 return nullptr;
55 } 55 }
56 56
57 CanvasCaptureMediaStreamTrack* canvasTrack; 57 CanvasCaptureMediaStreamTrack* canvasTrack;
58 if (givenFrameRate) 58 if (givenFrameRate)
59 canvasTrack = CanvasCaptureMediaStreamTrack::create(track, &element, han dler.release(), frameRate); 59 canvasTrack = CanvasCaptureMediaStreamTrack::create(track, &element, han dler.release(), frameRate);
60 else 60 else
61 canvasTrack = CanvasCaptureMediaStreamTrack::create(track, &element, han dler.release()); 61 canvasTrack = CanvasCaptureMediaStreamTrack::create(track, &element, han dler.release());
62 // We want to capture a frame in the beginning. 62 // We want to capture a frame in the beginning.
63 canvasTrack->requestFrame(); 63 canvasTrack->requestFrame();
64 64
65 MediaStreamTrackVector tracks; 65 MediaStreamTrackVector tracks;
66 tracks.append(canvasTrack); 66 tracks.append(canvasTrack);
67 return MediaStream::create(element.getExecutionContext(), tracks); 67 return MediaStream::create(element.getExecutionContext(), tracks);
68 } 68 }
69 69
70 } // namespace blink 70 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/mediarecorder/MediaRecorder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698