| 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 "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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 const MediaRecorderOptions& options, | 58 const MediaRecorderOptions& options, |
| 59 MediaStream* stream, | 59 MediaStream* stream, |
| 60 int* audio_bits_per_second, | 60 int* audio_bits_per_second, |
| 61 int* video_bits_per_second) { | 61 int* video_bits_per_second) { |
| 62 const bool use_video = !stream->getVideoTracks().IsEmpty(); | 62 const bool use_video = !stream->getVideoTracks().IsEmpty(); |
| 63 const bool use_audio = !stream->getAudioTracks().IsEmpty(); | 63 const bool use_audio = !stream->getAudioTracks().IsEmpty(); |
| 64 | 64 |
| 65 // Clamp incoming values into a signed integer's range. | 65 // Clamp incoming values into a signed integer's range. |
| 66 // TODO(mcasas): This section would no be needed if the bit rates are signed | 66 // TODO(mcasas): This section would no be needed if the bit rates are signed |
| 67 // or double, see https://github.com/w3c/mediacapture-record/issues/48. | 67 // or double, see https://github.com/w3c/mediacapture-record/issues/48. |
| 68 const unsigned k_max_int_as_unsigned = std::numeric_limits<int>::max(); | 68 const unsigned kMaxIntAsUnsigned = std::numeric_limits<int>::max(); |
| 69 | 69 |
| 70 int overall_bps = 0; | 70 int overall_bps = 0; |
| 71 if (options.hasBitsPerSecond()) | 71 if (options.hasBitsPerSecond()) |
| 72 overall_bps = std::min(options.bitsPerSecond(), k_max_int_as_unsigned); | 72 overall_bps = std::min(options.bitsPerSecond(), kMaxIntAsUnsigned); |
| 73 int video_bps = 0; | 73 int video_bps = 0; |
| 74 if (options.hasVideoBitsPerSecond() && use_video) | 74 if (options.hasVideoBitsPerSecond() && use_video) |
| 75 video_bps = std::min(options.videoBitsPerSecond(), k_max_int_as_unsigned); | 75 video_bps = std::min(options.videoBitsPerSecond(), kMaxIntAsUnsigned); |
| 76 int audio_bps = 0; | 76 int audio_bps = 0; |
| 77 if (options.hasAudioBitsPerSecond() && use_audio) | 77 if (options.hasAudioBitsPerSecond() && use_audio) |
| 78 audio_bps = std::min(options.audioBitsPerSecond(), k_max_int_as_unsigned); | 78 audio_bps = std::min(options.audioBitsPerSecond(), kMaxIntAsUnsigned); |
| 79 | 79 |
| 80 if (use_audio) { | 80 if (use_audio) { |
| 81 // |overallBps| overrides the specific audio and video bit rates. | 81 // |overallBps| overrides the specific audio and video bit rates. |
| 82 if (options.hasBitsPerSecond()) { | 82 if (options.hasBitsPerSecond()) { |
| 83 if (use_video) | 83 if (use_video) |
| 84 audio_bps = overall_bps / 10; | 84 audio_bps = overall_bps / 10; |
| 85 else | 85 else |
| 86 audio_bps = overall_bps; | 86 audio_bps = overall_bps; |
| 87 } | 87 } |
| 88 // Limit audio bitrate values if set explicitly or calculated. | 88 // Limit audio bitrate values if set explicitly or calculated. |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 | 389 |
| 390 DEFINE_TRACE(MediaRecorder) { | 390 DEFINE_TRACE(MediaRecorder) { |
| 391 visitor->Trace(stream_); | 391 visitor->Trace(stream_); |
| 392 visitor->Trace(dispatch_scheduled_event_runner_); | 392 visitor->Trace(dispatch_scheduled_event_runner_); |
| 393 visitor->Trace(scheduled_events_); | 393 visitor->Trace(scheduled_events_); |
| 394 EventTargetWithInlineData::Trace(visitor); | 394 EventTargetWithInlineData::Trace(visitor); |
| 395 SuspendableObject::Trace(visitor); | 395 SuspendableObject::Trace(visitor); |
| 396 } | 396 } |
| 397 | 397 |
| 398 } // namespace blink | 398 } // namespace blink |
| OLD | NEW |