| 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/mediarecorder/MediaRecorder.h" | 5 #include "modules/mediarecorder/MediaRecorder.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include "bindings/core/v8/Dictionary.h" | 9 #include "bindings/core/v8/Dictionary.h" |
| 10 #include "core/events/Event.h" | 10 #include "core/events/Event.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 mime_type_(options.hasMimeType() ? options.mimeType() : kDefaultMimeType), | 166 mime_type_(options.hasMimeType() ? options.mimeType() : kDefaultMimeType), |
| 167 stopped_(true), | 167 stopped_(true), |
| 168 audio_bits_per_second_(0), | 168 audio_bits_per_second_(0), |
| 169 video_bits_per_second_(0), | 169 video_bits_per_second_(0), |
| 170 state_(State::kInactive), | 170 state_(State::kInactive), |
| 171 dispatch_scheduled_event_runner_(AsyncMethodRunner<MediaRecorder>::Create( | 171 dispatch_scheduled_event_runner_(AsyncMethodRunner<MediaRecorder>::Create( |
| 172 this, | 172 this, |
| 173 &MediaRecorder::DispatchScheduledEvent)) { | 173 &MediaRecorder::DispatchScheduledEvent)) { |
| 174 DCHECK(stream_->getTracks().size()); | 174 DCHECK(stream_->getTracks().size()); |
| 175 | 175 |
| 176 recorder_handler_ = Platform::Current()->CreateMediaRecorderHandler(); | 176 recorder_handler_ = |
| 177 WTF::WrapUnique(Platform::Current()->CreateMediaRecorderHandler()); |
| 177 DCHECK(recorder_handler_); | 178 DCHECK(recorder_handler_); |
| 178 | 179 |
| 179 if (!recorder_handler_) { | 180 if (!recorder_handler_) { |
| 180 exception_state.ThrowDOMException( | 181 exception_state.ThrowDOMException( |
| 181 kNotSupportedError, "No MediaRecorder handler can be created."); | 182 kNotSupportedError, "No MediaRecorder handler can be created."); |
| 182 return; | 183 return; |
| 183 } | 184 } |
| 184 | 185 |
| 185 AllocateVideoAndAudioBitrates(exception_state, context, options, stream, | 186 AllocateVideoAndAudioBitrates(exception_state, context, options, stream, |
| 186 &audio_bits_per_second_, | 187 &audio_bits_per_second_, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 exception_state.ThrowDOMException( | 277 exception_state.ThrowDOMException( |
| 277 kInvalidStateError, | 278 kInvalidStateError, |
| 278 "The MediaRecorder's state is '" + StateToString(state_) + "'."); | 279 "The MediaRecorder's state is '" + StateToString(state_) + "'."); |
| 279 return; | 280 return; |
| 280 } | 281 } |
| 281 WriteData(nullptr /* data */, 0 /* length */, true /* lastInSlice */, | 282 WriteData(nullptr /* data */, 0 /* length */, true /* lastInSlice */, |
| 282 WTF::CurrentTimeMS()); | 283 WTF::CurrentTimeMS()); |
| 283 } | 284 } |
| 284 | 285 |
| 285 bool MediaRecorder::isTypeSupported(const String& type) { | 286 bool MediaRecorder::isTypeSupported(const String& type) { |
| 286 std::unique_ptr<WebMediaRecorderHandler> handler = | 287 WebMediaRecorderHandler* handler = |
| 287 Platform::Current()->CreateMediaRecorderHandler(); | 288 Platform::Current()->CreateMediaRecorderHandler(); |
| 288 if (!handler) | 289 if (!handler) |
| 289 return false; | 290 return false; |
| 290 | 291 |
| 291 // If true is returned from this method, it only indicates that the | 292 // If true is returned from this method, it only indicates that the |
| 292 // MediaRecorder implementation is capable of recording Blob objects for the | 293 // MediaRecorder implementation is capable of recording Blob objects for the |
| 293 // specified MIME type. Recording may still fail if sufficient resources are | 294 // specified MIME type. Recording may still fail if sufficient resources are |
| 294 // not available to support the concrete media encoding. | 295 // not available to support the concrete media encoding. |
| 295 // [1] https://w3c.github.io/mediacapture-record/MediaRecorder.html#methods | 296 // [1] https://w3c.github.io/mediacapture-record/MediaRecorder.html#methods |
| 296 ContentType content_type(type); | 297 ContentType content_type(type); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 | 388 |
| 388 DEFINE_TRACE(MediaRecorder) { | 389 DEFINE_TRACE(MediaRecorder) { |
| 389 visitor->Trace(stream_); | 390 visitor->Trace(stream_); |
| 390 visitor->Trace(dispatch_scheduled_event_runner_); | 391 visitor->Trace(dispatch_scheduled_event_runner_); |
| 391 visitor->Trace(scheduled_events_); | 392 visitor->Trace(scheduled_events_); |
| 392 EventTargetWithInlineData::Trace(visitor); | 393 EventTargetWithInlineData::Trace(visitor); |
| 393 SuspendableObject::Trace(visitor); | 394 SuspendableObject::Trace(visitor); |
| 394 } | 395 } |
| 395 | 396 |
| 396 } // namespace blink | 397 } // namespace blink |
| OLD | NEW |