Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: webrtc/media/engine/webrtcvoiceengine.cc

Issue 2721003002: Remove usage of VoEVolumeControl from WVoE and Audio[Send|Receive]Stream. (Closed)
Patch Set: rebase+comment Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 ret = false; 955 ret = false;
956 } 956 }
957 957
958 if (ret) { 958 if (ret) {
959 LOG(LS_INFO) << "Set microphone to (id=" << in_id 959 LOG(LS_INFO) << "Set microphone to (id=" << in_id
960 << ") and speaker to (id=" << out_id << ")"; 960 << ") and speaker to (id=" << out_id << ")";
961 } 961 }
962 #endif // !WEBRTC_IOS 962 #endif // !WEBRTC_IOS
963 } 963 }
964 964
965 // TODO(solenberg): Remove, once AudioMonitor is gone.
965 int WebRtcVoiceEngine::GetInputLevel() { 966 int WebRtcVoiceEngine::GetInputLevel() {
966 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 967 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
967 unsigned int ulevel; 968 int8_t level = transmit_mixer()->AudioLevel();
968 return (voe_wrapper_->volume()->GetSpeechInputLevel(ulevel) != -1) ? 969 RTC_DCHECK_LE(0, level);
969 static_cast<int>(ulevel) : -1; 970 return level;
970 } 971 }
971 972
972 const std::vector<AudioCodec>& WebRtcVoiceEngine::send_codecs() const { 973 const std::vector<AudioCodec>& WebRtcVoiceEngine::send_codecs() const {
973 RTC_DCHECK(signal_thread_checker_.CalledOnValidThread()); 974 RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
974 return send_codecs_; 975 return send_codecs_;
975 } 976 }
976 977
977 const std::vector<AudioCodec>& WebRtcVoiceEngine::recv_codecs() const { 978 const std::vector<AudioCodec>& WebRtcVoiceEngine::recv_codecs() const {
978 RTC_DCHECK(signal_thread_checker_.CalledOnValidThread()); 979 RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
979 return recv_codecs_; 980 return recv_codecs_;
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
1570 RecreateAudioReceiveStream(); 1571 RecreateAudioReceiveStream();
1571 } 1572 }
1572 } 1573 }
1573 1574
1574 webrtc::AudioReceiveStream::Stats GetStats() const { 1575 webrtc::AudioReceiveStream::Stats GetStats() const {
1575 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1576 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1576 RTC_DCHECK(stream_); 1577 RTC_DCHECK(stream_);
1577 return stream_->GetStats(); 1578 return stream_->GetStats();
1578 } 1579 }
1579 1580
1581 int GetOutputLevel() const {
1582 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1583 RTC_DCHECK(stream_);
1584 return stream_->GetOutputLevel();
1585 }
1586
1580 int channel() const { 1587 int channel() const {
1581 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1588 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1582 return config_.voe_channel_id; 1589 return config_.voe_channel_id;
1583 } 1590 }
1584 1591
1585 void SetRawAudioSink(std::unique_ptr<webrtc::AudioSinkInterface> sink) { 1592 void SetRawAudioSink(std::unique_ptr<webrtc::AudioSinkInterface> sink) {
1586 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1593 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1587 stream_->SetSink(std::move(sink)); 1594 stream_->SetSink(std::move(sink));
1588 } 1595 }
1589 1596
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 2341
2335 if (source) { 2342 if (source) {
2336 it->second->SetSource(source); 2343 it->second->SetSource(source);
2337 } else { 2344 } else {
2338 it->second->ClearSource(); 2345 it->second->ClearSource();
2339 } 2346 }
2340 2347
2341 return true; 2348 return true;
2342 } 2349 }
2343 2350
2351 // TODO(solenberg): Remove, once AudioMonitor is gone.
2344 bool WebRtcVoiceMediaChannel::GetActiveStreams( 2352 bool WebRtcVoiceMediaChannel::GetActiveStreams(
2345 AudioInfo::StreamList* actives) { 2353 AudioInfo::StreamList* actives) {
2346 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2354 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2347 actives->clear(); 2355 actives->clear();
2348 for (const auto& ch : recv_streams_) { 2356 for (const auto& ch : recv_streams_) {
2349 int level = GetOutputLevel(ch.second->channel()); 2357 int level = ch.second->GetOutputLevel();
2350 if (level > 0) { 2358 if (level > 0) {
2351 actives->push_back(std::make_pair(ch.first, level)); 2359 actives->push_back(std::make_pair(ch.first, level));
2352 } 2360 }
2353 } 2361 }
2354 return true; 2362 return true;
2355 } 2363 }
2356 2364
2365 // TODO(solenberg): Remove, once AudioMonitor is gone.
2357 int WebRtcVoiceMediaChannel::GetOutputLevel() { 2366 int WebRtcVoiceMediaChannel::GetOutputLevel() {
2358 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2367 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2359 int highest = 0; 2368 int highest = 0;
2360 for (const auto& ch : recv_streams_) { 2369 for (const auto& ch : recv_streams_) {
2361 highest = std::max(GetOutputLevel(ch.second->channel()), highest); 2370 highest = std::max(ch.second->GetOutputLevel(), highest);
2362 } 2371 }
2363 return highest; 2372 return highest;
2364 } 2373 }
2365 2374
2366 bool WebRtcVoiceMediaChannel::SetOutputVolume(uint32_t ssrc, double volume) { 2375 bool WebRtcVoiceMediaChannel::SetOutputVolume(uint32_t ssrc, double volume) {
2367 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2376 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2368 std::vector<uint32_t> ssrcs(1, ssrc); 2377 std::vector<uint32_t> ssrcs(1, ssrc);
2369 if (ssrc == 0) { 2378 if (ssrc == 0) {
2370 default_recv_volume_ = volume; 2379 default_recv_volume_ = volume;
2371 ssrcs = unsignaled_recv_ssrcs_; 2380 ssrcs = unsignaled_recv_ssrcs_;
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
2650 return; 2659 return;
2651 } 2660 }
2652 const auto it = recv_streams_.find(ssrc); 2661 const auto it = recv_streams_.find(ssrc);
2653 if (it == recv_streams_.end()) { 2662 if (it == recv_streams_.end()) {
2654 LOG(LS_WARNING) << "SetRawAudioSink: no recv stream " << ssrc; 2663 LOG(LS_WARNING) << "SetRawAudioSink: no recv stream " << ssrc;
2655 return; 2664 return;
2656 } 2665 }
2657 it->second->SetRawAudioSink(std::move(sink)); 2666 it->second->SetRawAudioSink(std::move(sink));
2658 } 2667 }
2659 2668
2660 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) {
2661 unsigned int ulevel = 0;
2662 int ret = engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel);
2663 return (ret == 0) ? static_cast<int>(ulevel) : -1;
2664 }
2665
2666 int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const { 2669 int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const {
2667 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2670 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2668 const auto it = recv_streams_.find(ssrc); 2671 const auto it = recv_streams_.find(ssrc);
2669 if (it != recv_streams_.end()) { 2672 if (it != recv_streams_.end()) {
2670 return it->second->channel(); 2673 return it->second->channel();
2671 } 2674 }
2672 return -1; 2675 return -1;
2673 } 2676 }
2674 2677
2675 int WebRtcVoiceMediaChannel::GetSendChannelId(uint32_t ssrc) const { 2678 int WebRtcVoiceMediaChannel::GetSendChannelId(uint32_t ssrc) const {
(...skipping 13 matching lines...) Expand all
2689 ssrc); 2692 ssrc);
2690 if (it != unsignaled_recv_ssrcs_.end()) { 2693 if (it != unsignaled_recv_ssrcs_.end()) {
2691 unsignaled_recv_ssrcs_.erase(it); 2694 unsignaled_recv_ssrcs_.erase(it);
2692 return true; 2695 return true;
2693 } 2696 }
2694 return false; 2697 return false;
2695 } 2698 }
2696 } // namespace cricket 2699 } // namespace cricket
2697 2700
2698 #endif // HAVE_WEBRTC_VOICE 2701 #endif // HAVE_WEBRTC_VOICE
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvoiceengine.h ('k') | webrtc/media/engine/webrtcvoiceengine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698