| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/webrtc_audio_capturer.h" | 5 #include "content/renderer/media/webrtc_audio_capturer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 TrackList::ItemList tracks; | 453 TrackList::ItemList tracks; |
| 454 TrackList::ItemList tracks_to_notify_format; | 454 TrackList::ItemList tracks_to_notify_format; |
| 455 int current_volume = 0; | 455 int current_volume = 0; |
| 456 base::TimeDelta audio_delay; | 456 base::TimeDelta audio_delay; |
| 457 bool need_audio_processing = true; | 457 bool need_audio_processing = true; |
| 458 { | 458 { |
| 459 base::AutoLock auto_lock(lock_); | 459 base::AutoLock auto_lock(lock_); |
| 460 if (!running_) | 460 if (!running_) |
| 461 return; | 461 return; |
| 462 | 462 |
| 463 // Map internal volume range of [0.0, 1.0] into [0, 255] used by the | 463 // Map internal volume range of [0.0, 1.0] into [0, 255] used by AGC. |
| 464 // webrtc::VoiceEngine. webrtc::VoiceEngine will handle the case when the | 464 // The volume can be higher than 255 on Linux, and it will be cropped to |
| 465 // volume is higher than 255. | 465 // 255 since AGC does not allow values out of range. |
| 466 volume_ = static_cast<int>((volume * MaxVolume()) + 0.5); | 466 volume_ = static_cast<int>((volume * MaxVolume()) + 0.5); |
| 467 current_volume = volume_; | 467 current_volume = volume_ > MaxVolume() ? MaxVolume() : volume_; |
| 468 audio_delay = base::TimeDelta::FromMilliseconds(audio_delay_milliseconds); | 468 audio_delay = base::TimeDelta::FromMilliseconds(audio_delay_milliseconds); |
| 469 audio_delay_ = audio_delay; | 469 audio_delay_ = audio_delay; |
| 470 key_pressed_ = key_pressed; | 470 key_pressed_ = key_pressed; |
| 471 tracks = tracks_.Items(); | 471 tracks = tracks_.Items(); |
| 472 tracks_.RetrieveAndClearTags(&tracks_to_notify_format); | 472 tracks_.RetrieveAndClearTags(&tracks_to_notify_format); |
| 473 | 473 |
| 474 // Set the flag to turn on the audio processing in PeerConnection level. | 474 // Set the flag to turn on the audio processing in PeerConnection level. |
| 475 // Note that, we turn off the audio processing in PeerConnection if the | 475 // Note that, we turn off the audio processing in PeerConnection if the |
| 476 // processor has already processed the data. | 476 // processor has already processed the data. |
| 477 need_audio_processing = need_audio_processing_ ? | 477 need_audio_processing = need_audio_processing_ ? |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 DCHECK_NE(aec_dump_file, base::kInvalidPlatformFileValue); | 605 DCHECK_NE(aec_dump_file, base::kInvalidPlatformFileValue); |
| 606 audio_processor_->StartAecDump(aec_dump_file); | 606 audio_processor_->StartAecDump(aec_dump_file); |
| 607 } | 607 } |
| 608 | 608 |
| 609 void WebRtcAudioCapturer::StopAecDump() { | 609 void WebRtcAudioCapturer::StopAecDump() { |
| 610 DCHECK(thread_checker_.CalledOnValidThread()); | 610 DCHECK(thread_checker_.CalledOnValidThread()); |
| 611 audio_processor_->StopAecDump(); | 611 audio_processor_->StopAecDump(); |
| 612 } | 612 } |
| 613 | 613 |
| 614 } // namespace content | 614 } // namespace content |
| OLD | NEW |