| 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" |
| 11 #include "core/fileapi/Blob.h" | 11 #include "core/fileapi/Blob.h" |
| 12 #include "core/inspector/ConsoleMessage.h" | 12 #include "core/inspector/ConsoleMessage.h" |
| 13 #include "modules/EventTargetModules.h" | 13 #include "modules/EventTargetModules.h" |
| 14 #include "modules/mediarecorder/BlobEvent.h" | 14 #include "modules/mediarecorder/BlobEvent.h" |
| 15 #include "platform/blob/BlobData.h" | 15 #include "platform/blob/BlobData.h" |
| 16 #include "platform/network/mime/ContentType.h" | 16 #include "platform/network/mime/ContentType.h" |
| 17 #include "platform/wtf/CurrentTime.h" | 17 #include "platform/wtf/CurrentTime.h" |
| 18 #include "platform/wtf/PtrUtil.h" | 18 #include "platform/wtf/PtrUtil.h" |
| 19 #include "public/platform/Platform.h" | 19 #include "public/platform/Platform.h" |
| 20 #include "public/platform/WebMediaStream.h" | 20 #include "public/platform/WebMediaStream.h" |
| 21 | 21 |
| 22 namespace blink { | 22 namespace blink { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 const char* g_k_default_mime_type = "video/webm"; | 26 const char kDefaultMimeType[] = "video/webm"; |
| 27 | 27 |
| 28 // Boundaries of Opus bitrate from https://www.opus-codec.org/. | 28 // Boundaries of Opus bitrate from https://www.opus-codec.org/. |
| 29 const int kSmallestPossibleOpusBitRate = 6000; | 29 const int kSmallestPossibleOpusBitRate = 6000; |
| 30 const int kLargestAutoAllocatedOpusBitRate = 128000; | 30 const int kLargestAutoAllocatedOpusBitRate = 128000; |
| 31 | 31 |
| 32 // Smallest Vpx bitrate that can be requested. | 32 // Smallest Vpx bitrate that can be requested. |
| 33 const int kSmallestPossibleVpxBitRate = 100000; | 33 const int kSmallestPossibleVpxBitRate = 100000; |
| 34 | 34 |
| 35 String StateToString(MediaRecorder::State state) { | 35 String StateToString(MediaRecorder::State state) { |
| 36 switch (state) { | 36 switch (state) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 return recorder; | 157 return recorder; |
| 158 } | 158 } |
| 159 | 159 |
| 160 MediaRecorder::MediaRecorder(ExecutionContext* context, | 160 MediaRecorder::MediaRecorder(ExecutionContext* context, |
| 161 MediaStream* stream, | 161 MediaStream* stream, |
| 162 const MediaRecorderOptions& options, | 162 const MediaRecorderOptions& options, |
| 163 ExceptionState& exception_state) | 163 ExceptionState& exception_state) |
| 164 : SuspendableObject(context), | 164 : SuspendableObject(context), |
| 165 stream_(stream), | 165 stream_(stream), |
| 166 mime_type_(options.hasMimeType() ? options.mimeType() | 166 mime_type_(options.hasMimeType() ? options.mimeType() : kDefaultMimeType), |
| 167 : g_k_default_mime_type), | |
| 168 stopped_(true), | 167 stopped_(true), |
| 169 audio_bits_per_second_(0), | 168 audio_bits_per_second_(0), |
| 170 video_bits_per_second_(0), | 169 video_bits_per_second_(0), |
| 171 state_(State::kInactive), | 170 state_(State::kInactive), |
| 172 dispatch_scheduled_event_runner_(AsyncMethodRunner<MediaRecorder>::Create( | 171 dispatch_scheduled_event_runner_(AsyncMethodRunner<MediaRecorder>::Create( |
| 173 this, | 172 this, |
| 174 &MediaRecorder::DispatchScheduledEvent)) { | 173 &MediaRecorder::DispatchScheduledEvent)) { |
| 175 DCHECK(stream_->getTracks().size()); | 174 DCHECK(stream_->getTracks().size()); |
| 176 | 175 |
| 177 recorder_handler_ = | 176 recorder_handler_ = |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 | 388 |
| 390 DEFINE_TRACE(MediaRecorder) { | 389 DEFINE_TRACE(MediaRecorder) { |
| 391 visitor->Trace(stream_); | 390 visitor->Trace(stream_); |
| 392 visitor->Trace(dispatch_scheduled_event_runner_); | 391 visitor->Trace(dispatch_scheduled_event_runner_); |
| 393 visitor->Trace(scheduled_events_); | 392 visitor->Trace(scheduled_events_); |
| 394 EventTargetWithInlineData::Trace(visitor); | 393 EventTargetWithInlineData::Trace(visitor); |
| 395 SuspendableObject::Trace(visitor); | 394 SuspendableObject::Trace(visitor); |
| 396 } | 395 } |
| 397 | 396 |
| 398 } // namespace blink | 397 } // namespace blink |
| OLD | NEW |