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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } | 154 } |
155 | 155 |
156 AudioTrackRecorder::AudioEncoder::~AudioEncoder() { | 156 AudioTrackRecorder::AudioEncoder::~AudioEncoder() { |
157 // We don't DCHECK that we're on the encoder thread here, as it should have | 157 // We don't DCHECK that we're on the encoder thread here, as it should have |
158 // already been deleted at this point. | 158 // already been deleted at this point. |
159 DestroyExistingOpusEncoder(); | 159 DestroyExistingOpusEncoder(); |
160 } | 160 } |
161 | 161 |
162 void AudioTrackRecorder::AudioEncoder::OnSetFormat( | 162 void AudioTrackRecorder::AudioEncoder::OnSetFormat( |
163 const media::AudioParameters& input_params) { | 163 const media::AudioParameters& input_params) { |
164 DVLOG(1) << __FUNCTION__; | 164 DVLOG(1) << __func__; |
165 DCHECK(encoder_thread_checker_.CalledOnValidThread()); | 165 DCHECK(encoder_thread_checker_.CalledOnValidThread()); |
166 if (input_params_.Equals(input_params)) | 166 if (input_params_.Equals(input_params)) |
167 return; | 167 return; |
168 | 168 |
169 DestroyExistingOpusEncoder(); | 169 DestroyExistingOpusEncoder(); |
170 | 170 |
171 if (!input_params.IsValid()) { | 171 if (!input_params.IsValid()) { |
172 DLOG(ERROR) << "Invalid params: " << input_params.AsHumanReadableString(); | 172 DLOG(ERROR) << "Invalid params: " << input_params.AsHumanReadableString(); |
173 return; | 173 return; |
174 } | 174 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 (bits_per_second_ > 0) ? bits_per_second_ : OPUS_AUTO; | 221 (bits_per_second_ > 0) ? bits_per_second_ : OPUS_AUTO; |
222 if (opus_encoder_ctl(opus_encoder_, OPUS_SET_BITRATE(bitrate)) != OPUS_OK) { | 222 if (opus_encoder_ctl(opus_encoder_, OPUS_SET_BITRATE(bitrate)) != OPUS_OK) { |
223 DLOG(ERROR) << "Failed to set opus bitrate: " << bitrate; | 223 DLOG(ERROR) << "Failed to set opus bitrate: " << bitrate; |
224 return; | 224 return; |
225 } | 225 } |
226 } | 226 } |
227 | 227 |
228 void AudioTrackRecorder::AudioEncoder::EncodeAudio( | 228 void AudioTrackRecorder::AudioEncoder::EncodeAudio( |
229 std::unique_ptr<media::AudioBus> input_bus, | 229 std::unique_ptr<media::AudioBus> input_bus, |
230 const base::TimeTicks& capture_time) { | 230 const base::TimeTicks& capture_time) { |
231 DVLOG(3) << __FUNCTION__ << ", #frames " << input_bus->frames(); | 231 DVLOG(3) << __func__ << ", #frames " << input_bus->frames(); |
232 DCHECK(encoder_thread_checker_.CalledOnValidThread()); | 232 DCHECK(encoder_thread_checker_.CalledOnValidThread()); |
233 DCHECK_EQ(input_bus->channels(), input_params_.channels()); | 233 DCHECK_EQ(input_bus->channels(), input_params_.channels()); |
234 DCHECK(!capture_time.is_null()); | 234 DCHECK(!capture_time.is_null()); |
235 DCHECK(converter_); | 235 DCHECK(converter_); |
236 | 236 |
237 if (!is_initialized() || paused_) | 237 if (!is_initialized() || paused_) |
238 return; | 238 return; |
239 // TODO(mcasas): Consider using a std::deque<std::unique_ptr<AudioBus>> | 239 // TODO(mcasas): Consider using a std::deque<std::unique_ptr<AudioBus>> |
240 // instead of | 240 // instead of |
241 // an AudioFifo, to avoid copying data needlessly since we know the sizes of | 241 // an AudioFifo, to avoid copying data needlessly since we know the sizes of |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 } | 339 } |
340 | 340 |
341 void AudioTrackRecorder::Resume() { | 341 void AudioTrackRecorder::Resume() { |
342 DCHECK(main_render_thread_checker_.CalledOnValidThread()); | 342 DCHECK(main_render_thread_checker_.CalledOnValidThread()); |
343 DCHECK(encoder_); | 343 DCHECK(encoder_); |
344 encoder_thread_.task_runner()->PostTask( | 344 encoder_thread_.task_runner()->PostTask( |
345 FROM_HERE, base::Bind(&AudioEncoder::set_paused, encoder_, false)); | 345 FROM_HERE, base::Bind(&AudioEncoder::set_paused, encoder_, false)); |
346 } | 346 } |
347 | 347 |
348 } // namespace content | 348 } // namespace content |
OLD | NEW |