Chromium Code Reviews| 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 "content/renderer/media/audio_track_recorder.h" | 5 #include "content/renderer/media/audio_track_recorder.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 } | 70 } |
| 71 // If |result| in {0,1}, do nothing; the documentation says that a return | 71 // If |result| in {0,1}, do nothing; the documentation says that a return |
| 72 // value of zero or one means the packet does not need to be transmitted. | 72 // value of zero or one means the packet does not need to be transmitted. |
| 73 // Otherwise, we have an error. | 73 // Otherwise, we have an error. |
| 74 DLOG_IF(ERROR, result < 0) << " encode failed: " << opus_strerror(result); | 74 DLOG_IF(ERROR, result < 0) << " encode failed: " << opus_strerror(result); |
| 75 return false; | 75 return false; |
| 76 } | 76 } |
| 77 | 77 |
| 78 // Interleaves |audio_bus| channels() of floats into a single output linear | 78 // Interleaves |audio_bus| channels() of floats into a single output linear |
| 79 // |buffer|. | 79 // |buffer|. |
| 80 // TODO(mcasas) https://crbug.com/580391 use AudioBus::ToInterleavedFloat(). | |
| 81 void ToInterleaved(media::AudioBus* audio_bus, float* buffer) { | 80 void ToInterleaved(media::AudioBus* audio_bus, float* buffer) { |
| 82 for (int ch = 0; ch < audio_bus->channels(); ++ch) { | 81 audio_bus->ToInterleavedFloat(0, 0, audio_bus->frames(), |
|
mcasas
2016/03/09 00:24:18
Please inline this call and remove ToInterleave()
eklavyamirani
2016/03/15 03:48:13
Done.
| |
| 83 const float* src = audio_bus->channel(ch); | 82 audio_bus->channels(), buffer); |
| 84 const float* const src_end = src + audio_bus->frames(); | |
| 85 float* dest = buffer + ch; | |
| 86 for (; src < src_end; ++src, dest += audio_bus->channels()) | |
| 87 *dest = *src; | |
| 88 } | |
| 89 } | 83 } |
| 90 | 84 |
| 91 } // anonymous namespace | 85 } // anonymous namespace |
| 92 | 86 |
| 93 // Nested class encapsulating opus-related encoding details. It contains an | 87 // Nested class encapsulating opus-related encoding details. It contains an |
| 94 // AudioConverter to adapt incoming data to the format Opus likes to have. | 88 // AudioConverter to adapt incoming data to the format Opus likes to have. |
| 95 // AudioEncoder is created and destroyed on ATR's main thread (usually the main | 89 // AudioEncoder is created and destroyed on ATR's main thread (usually the main |
| 96 // render thread) but otherwise should operate entirely on |encoder_thread_|, | 90 // render thread) but otherwise should operate entirely on |encoder_thread_|, |
| 97 // which is owned by AudioTrackRecorder. Be sure to delete |encoder_thread_| | 91 // which is owned by AudioTrackRecorder. Be sure to delete |encoder_thread_| |
| 98 // before deleting the AudioEncoder using it. | 92 // before deleting the AudioEncoder using it. |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 329 scoped_ptr<media::AudioBus> audio_data = | 323 scoped_ptr<media::AudioBus> audio_data = |
| 330 media::AudioBus::Create(audio_bus.channels(), audio_bus.frames()); | 324 media::AudioBus::Create(audio_bus.channels(), audio_bus.frames()); |
| 331 audio_bus.CopyTo(audio_data.get()); | 325 audio_bus.CopyTo(audio_data.get()); |
| 332 | 326 |
| 333 encoder_thread_.task_runner()->PostTask( | 327 encoder_thread_.task_runner()->PostTask( |
| 334 FROM_HERE, base::Bind(&AudioEncoder::EncodeAudio, encoder_, | 328 FROM_HERE, base::Bind(&AudioEncoder::EncodeAudio, encoder_, |
| 335 base::Passed(&audio_data), capture_time)); | 329 base::Passed(&audio_data), capture_time)); |
| 336 } | 330 } |
| 337 | 331 |
| 338 } // namespace content | 332 } // namespace content |
| OLD | NEW |