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

Side by Side Diff: third_party/WebKit/Source/modules/mediarecorder/MediaRecorder.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 | « third_party/WebKit/Source/modules/mediacapturefromelement/HTMLCanvasElementCapture.cpp ('k') | no next file » | 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/mediarecorder/MediaRecorder.h" 5 #include "modules/mediarecorder/MediaRecorder.h"
6 6
7 #include "bindings/core/v8/Dictionary.h" 7 #include "bindings/core/v8/Dictionary.h"
8 #include "core/events/Event.h" 8 #include "core/events/Event.h"
9 #include "core/fileapi/Blob.h" 9 #include "core/fileapi/Blob.h"
10 #include "core/inspector/ConsoleMessage.h" 10 #include "core/inspector/ConsoleMessage.h"
(...skipping 20 matching lines...) Expand all
31 { 31 {
32 switch (state) { 32 switch (state) {
33 case MediaRecorder::State::Inactive: 33 case MediaRecorder::State::Inactive:
34 return "inactive"; 34 return "inactive";
35 case MediaRecorder::State::Recording: 35 case MediaRecorder::State::Recording:
36 return "recording"; 36 return "recording";
37 case MediaRecorder::State::Paused: 37 case MediaRecorder::State::Paused:
38 return "paused"; 38 return "paused";
39 } 39 }
40 40
41 ASSERT_NOT_REACHED(); 41 NOTREACHED();
42 return String(); 42 return String();
43 } 43 }
44 44
45 // Allocates the requested bit rates from |bitrateOptions| into the respective 45 // Allocates the requested bit rates from |bitrateOptions| into the respective
46 // |{audio,video}BitsPerSecond| (where a value of zero indicates Platform to use 46 // |{audio,video}BitsPerSecond| (where a value of zero indicates Platform to use
47 // whatever it sees fit). If |options.bitsPerSecond()| is specified, it 47 // whatever it sees fit). If |options.bitsPerSecond()| is specified, it
48 // overrides any specific bitrate, and the UA is free to allocate as desired: 48 // overrides any specific bitrate, and the UA is free to allocate as desired:
49 // here a 90%/10% video/audio is used. In all cases where a value is explicited 49 // here a 90%/10% video/audio is used. In all cases where a value is explicited
50 // or calculated, values are clamped in sane ranges. 50 // or calculated, values are clamped in sane ranges.
51 // This method throws NotSupportedError. 51 // This method throws NotSupportedError.
(...skipping 29 matching lines...) Expand all
81 if (audioBps > kLargestAutoAllocatedOpusBitRate) { 81 if (audioBps > kLargestAutoAllocatedOpusBitRate) {
82 context->addConsoleMessage(ConsoleMessage::create(JSMessageSourc e, WarningMessageLevel, "Clamping calculated audio bitrate (" + String::number(a udioBps) + "bps) to the maximum (" + String::number(kLargestAutoAllocatedOpusBit Rate) + "bps)")); 82 context->addConsoleMessage(ConsoleMessage::create(JSMessageSourc e, WarningMessageLevel, "Clamping calculated audio bitrate (" + String::number(a udioBps) + "bps) to the maximum (" + String::number(kLargestAutoAllocatedOpusBit Rate) + "bps)"));
83 audioBps = kLargestAutoAllocatedOpusBitRate; 83 audioBps = kLargestAutoAllocatedOpusBitRate;
84 } 84 }
85 85
86 if (audioBps < kSmallestPossibleOpusBitRate) { 86 if (audioBps < kSmallestPossibleOpusBitRate) {
87 context->addConsoleMessage(ConsoleMessage::create(JSMessageSourc e, WarningMessageLevel, "Clamping calculated audio bitrate (" + String::number(a udioBps) + "bps) to the minimum (" + String::number(kSmallestPossibleOpusBitRate ) + "bps)")); 87 context->addConsoleMessage(ConsoleMessage::create(JSMessageSourc e, WarningMessageLevel, "Clamping calculated audio bitrate (" + String::number(a udioBps) + "bps) to the minimum (" + String::number(kSmallestPossibleOpusBitRate ) + "bps)"));
88 audioBps = kSmallestPossibleOpusBitRate; 88 audioBps = kSmallestPossibleOpusBitRate;
89 } 89 }
90 } else { 90 } else {
91 ASSERT(!audioBps); 91 DCHECK(!audioBps);
92 } 92 }
93 } 93 }
94 94
95 if (useVideo) { 95 if (useVideo) {
96 // Allocate the remaining |overallBps|, if any, to video. 96 // Allocate the remaining |overallBps|, if any, to video.
97 if (options.hasBitsPerSecond()) 97 if (options.hasBitsPerSecond())
98 videoBps = overallBps - audioBps; 98 videoBps = overallBps - audioBps;
99 // Clamp the video bit rate. Avoid clamping if the user has not set it e xplicitly. 99 // Clamp the video bit rate. Avoid clamping if the user has not set it e xplicitly.
100 if (options.hasVideoBitsPerSecond() || options.hasBitsPerSecond()) { 100 if (options.hasVideoBitsPerSecond() || options.hasBitsPerSecond()) {
101 if (videoBps < kSmallestPossibleVpxBitRate) { 101 if (videoBps < kSmallestPossibleVpxBitRate) {
102 context->addConsoleMessage(ConsoleMessage::create(JSMessageSourc e, WarningMessageLevel, "Clamping calculated video bitrate (" + String::number(v ideoBps) + "bps) to the minimum (" + String::number(kSmallestPossibleVpxBitRate) + "bps)")); 102 context->addConsoleMessage(ConsoleMessage::create(JSMessageSourc e, WarningMessageLevel, "Clamping calculated video bitrate (" + String::number(v ideoBps) + "bps) to the minimum (" + String::number(kSmallestPossibleVpxBitRate) + "bps)"));
103 videoBps = kSmallestPossibleVpxBitRate; 103 videoBps = kSmallestPossibleVpxBitRate;
104 } 104 }
105 } else { 105 } else {
106 ASSERT(!videoBps); 106 DCHECK(!videoBps);
107 } 107 }
108 } 108 }
109 109
110 *videoBitsPerSecond = videoBps; 110 *videoBitsPerSecond = videoBps;
111 *audioBitsPerSecond = audioBps; 111 *audioBitsPerSecond = audioBps;
112 return; 112 return;
113 } 113 }
114 114
115 } // namespace 115 } // namespace
116 116
(...skipping 19 matching lines...) Expand all
136 , m_stream(stream) 136 , m_stream(stream)
137 , m_streamAmountOfTracks(stream->getTracks().size()) 137 , m_streamAmountOfTracks(stream->getTracks().size())
138 , m_mimeType(options.mimeType()) 138 , m_mimeType(options.mimeType())
139 , m_stopped(true) 139 , m_stopped(true)
140 , m_ignoreMutedMedia(true) 140 , m_ignoreMutedMedia(true)
141 , m_audioBitsPerSecond(0) 141 , m_audioBitsPerSecond(0)
142 , m_videoBitsPerSecond(0) 142 , m_videoBitsPerSecond(0)
143 , m_state(State::Inactive) 143 , m_state(State::Inactive)
144 , m_dispatchScheduledEventRunner(AsyncMethodRunner<MediaRecorder>::create(th is, &MediaRecorder::dispatchScheduledEvent)) 144 , m_dispatchScheduledEventRunner(AsyncMethodRunner<MediaRecorder>::create(th is, &MediaRecorder::dispatchScheduledEvent))
145 { 145 {
146 ASSERT(m_stream->getTracks().size()); 146 DCHECK(m_stream->getTracks().size());
147 147
148 m_recorderHandler = adoptPtr(Platform::current()->createMediaRecorderHandler ()); 148 m_recorderHandler = adoptPtr(Platform::current()->createMediaRecorderHandler ());
149 ASSERT(m_recorderHandler); 149 DCHECK(m_recorderHandler);
150 150
151 if (!m_recorderHandler) { 151 if (!m_recorderHandler) {
152 exceptionState.throwDOMException(NotSupportedError, "No MediaRecorder ha ndler can be created."); 152 exceptionState.throwDOMException(NotSupportedError, "No MediaRecorder ha ndler can be created.");
153 return; 153 return;
154 } 154 }
155 155
156 AllocateVideoAndAudioBitrates(exceptionState, context, options, stream, &m_a udioBitsPerSecond, &m_videoBitsPerSecond); 156 AllocateVideoAndAudioBitrates(exceptionState, context, options, stream, &m_a udioBitsPerSecond, &m_videoBitsPerSecond);
157 157
158 const ContentType contentType(m_mimeType); 158 const ContentType contentType(m_mimeType);
159 if (!m_recorderHandler->initialize(this, stream->descriptor(), contentType.t ype(), contentType.parameter("codecs"), m_audioBitsPerSecond, m_videoBitsPerSeco nd)) { 159 if (!m_recorderHandler->initialize(this, stream->descriptor(), contentType.t ype(), contentType.parameter("codecs"), m_audioBitsPerSecond, m_videoBitsPerSeco nd)) {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 316 }
317 317
318 void MediaRecorder::createBlobEvent(Blob* blob) 318 void MediaRecorder::createBlobEvent(Blob* blob)
319 { 319 {
320 // TODO(mcasas): Consider launching an Event with a TypedArray inside, see h ttps://github.com/w3c/mediacapture-record/issues/17. 320 // TODO(mcasas): Consider launching an Event with a TypedArray inside, see h ttps://github.com/w3c/mediacapture-record/issues/17.
321 scheduleDispatchEvent(BlobEvent::create(EventTypeNames::dataavailable, blob) ); 321 scheduleDispatchEvent(BlobEvent::create(EventTypeNames::dataavailable, blob) );
322 } 322 }
323 323
324 void MediaRecorder::stopRecording() 324 void MediaRecorder::stopRecording()
325 { 325 {
326 ASSERT(m_state != State::Inactive); 326 DCHECK(m_state != State::Inactive);
327 m_state = State::Inactive; 327 m_state = State::Inactive;
328 328
329 m_recorderHandler->stop(); 329 m_recorderHandler->stop();
330 330
331 writeData(nullptr /* data */, 0 /* length */, true /* lastInSlice */); 331 writeData(nullptr /* data */, 0 /* length */, true /* lastInSlice */);
332 scheduleDispatchEvent(Event::create(EventTypeNames::stop)); 332 scheduleDispatchEvent(Event::create(EventTypeNames::stop));
333 } 333 }
334 334
335 void MediaRecorder::scheduleDispatchEvent(RawPtr<Event> event) 335 void MediaRecorder::scheduleDispatchEvent(RawPtr<Event> event)
336 { 336 {
(...skipping 14 matching lines...) Expand all
351 DEFINE_TRACE(MediaRecorder) 351 DEFINE_TRACE(MediaRecorder)
352 { 352 {
353 visitor->trace(m_stream); 353 visitor->trace(m_stream);
354 visitor->trace(m_dispatchScheduledEventRunner); 354 visitor->trace(m_dispatchScheduledEventRunner);
355 visitor->trace(m_scheduledEvents); 355 visitor->trace(m_scheduledEvents);
356 RefCountedGarbageCollectedEventTargetWithInlineData<MediaRecorder>::trace(vi sitor); 356 RefCountedGarbageCollectedEventTargetWithInlineData<MediaRecorder>::trace(vi sitor);
357 ActiveDOMObject::trace(visitor); 357 ActiveDOMObject::trace(visitor);
358 } 358 }
359 359
360 } // namespace blink 360 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/mediacapturefromelement/HTMLCanvasElementCapture.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698