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

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: 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 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 ret = false; 952 ret = false;
953 } 953 }
954 954
955 if (ret) { 955 if (ret) {
956 LOG(LS_INFO) << "Set microphone to (id=" << in_id 956 LOG(LS_INFO) << "Set microphone to (id=" << in_id
957 << ") and speaker to (id=" << out_id << ")"; 957 << ") and speaker to (id=" << out_id << ")";
958 } 958 }
959 #endif // !WEBRTC_IOS 959 #endif // !WEBRTC_IOS
960 } 960 }
961 961
962 // TODO(solenberg): Remove, once AudioMonitor is gone.
962 int WebRtcVoiceEngine::GetInputLevel() { 963 int WebRtcVoiceEngine::GetInputLevel() {
963 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 964 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
964 unsigned int ulevel; 965 int8_t currentLevel = transmit_mixer()->AudioLevel();
kwiberg-webrtc 2017/02/28 13:59:18 const? Also, why camelCase?
the sun 2017/03/02 00:36:25 a) Do you mean currentLevel (sic) should be const?
kwiberg-webrtc 2017/03/02 02:37:37 It just says "Use const whenever it makes sense."
965 return (voe_wrapper_->volume()->GetSpeechInputLevel(ulevel) != -1) ? 966 RTC_DCHECK_LE(0, currentLevel);
966 static_cast<int>(ulevel) : -1; 967 return currentLevel;
967 } 968 }
968 969
969 const std::vector<AudioCodec>& WebRtcVoiceEngine::send_codecs() const { 970 const std::vector<AudioCodec>& WebRtcVoiceEngine::send_codecs() const {
970 RTC_DCHECK(signal_thread_checker_.CalledOnValidThread()); 971 RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
971 return send_codecs_; 972 return send_codecs_;
972 } 973 }
973 974
974 const std::vector<AudioCodec>& WebRtcVoiceEngine::recv_codecs() const { 975 const std::vector<AudioCodec>& WebRtcVoiceEngine::recv_codecs() const {
975 RTC_DCHECK(signal_thread_checker_.CalledOnValidThread()); 976 RTC_DCHECK(signal_thread_checker_.CalledOnValidThread());
976 return recv_codecs_; 977 return recv_codecs_;
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 RecreateAudioReceiveStream(); 1570 RecreateAudioReceiveStream();
1570 } 1571 }
1571 } 1572 }
1572 1573
1573 webrtc::AudioReceiveStream::Stats GetStats() const { 1574 webrtc::AudioReceiveStream::Stats GetStats() const {
1574 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1575 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1575 RTC_DCHECK(stream_); 1576 RTC_DCHECK(stream_);
1576 return stream_->GetStats(); 1577 return stream_->GetStats();
1577 } 1578 }
1578 1579
1580 int GetOutputLevel() const {
1581 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1582 RTC_DCHECK(stream_);
1583 return stream_->GetOutputLevel();
1584 }
1585
1579 int channel() const { 1586 int channel() const {
1580 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1587 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1581 return config_.voe_channel_id; 1588 return config_.voe_channel_id;
1582 } 1589 }
1583 1590
1584 void SetRawAudioSink(std::unique_ptr<webrtc::AudioSinkInterface> sink) { 1591 void SetRawAudioSink(std::unique_ptr<webrtc::AudioSinkInterface> sink) {
1585 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1592 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1586 stream_->SetSink(std::move(sink)); 1593 stream_->SetSink(std::move(sink));
1587 } 1594 }
1588 1595
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
2338 2345
2339 if (source) { 2346 if (source) {
2340 it->second->SetSource(source); 2347 it->second->SetSource(source);
2341 } else { 2348 } else {
2342 it->second->ClearSource(); 2349 it->second->ClearSource();
2343 } 2350 }
2344 2351
2345 return true; 2352 return true;
2346 } 2353 }
2347 2354
2355 // TODO(solenberg): Remove, once AudioMonitor is gone.
2348 bool WebRtcVoiceMediaChannel::GetActiveStreams( 2356 bool WebRtcVoiceMediaChannel::GetActiveStreams(
2349 AudioInfo::StreamList* actives) { 2357 AudioInfo::StreamList* actives) {
2350 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2358 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2351 actives->clear(); 2359 actives->clear();
2352 for (const auto& ch : recv_streams_) { 2360 for (const auto& ch : recv_streams_) {
2353 int level = GetOutputLevel(ch.second->channel()); 2361 int level = ch.second->GetOutputLevel();
2354 if (level > 0) { 2362 if (level > 0) {
2355 actives->push_back(std::make_pair(ch.first, level)); 2363 actives->push_back(std::make_pair(ch.first, level));
2356 } 2364 }
2357 } 2365 }
2358 return true; 2366 return true;
2359 } 2367 }
2360 2368
2369 // TODO(solenberg): Remove, once AudioMonitor is gone.
2361 int WebRtcVoiceMediaChannel::GetOutputLevel() { 2370 int WebRtcVoiceMediaChannel::GetOutputLevel() {
2362 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2371 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2363 int highest = 0; 2372 int highest = 0;
2364 for (const auto& ch : recv_streams_) { 2373 for (const auto& ch : recv_streams_) {
2365 highest = std::max(GetOutputLevel(ch.second->channel()), highest); 2374 highest = std::max(ch.second->GetOutputLevel(), highest);
2366 } 2375 }
2367 return highest; 2376 return highest;
2368 } 2377 }
2369 2378
2370 bool WebRtcVoiceMediaChannel::SetOutputVolume(uint32_t ssrc, double volume) { 2379 bool WebRtcVoiceMediaChannel::SetOutputVolume(uint32_t ssrc, double volume) {
2371 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2380 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2372 if (ssrc == 0) { 2381 if (ssrc == 0) {
2373 default_recv_volume_ = volume; 2382 default_recv_volume_ = volume;
2374 if (default_recv_ssrc_ == -1) { 2383 if (default_recv_ssrc_ == -1) {
2375 return true; 2384 return true;
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
2636 return; 2645 return;
2637 } 2646 }
2638 const auto it = recv_streams_.find(ssrc); 2647 const auto it = recv_streams_.find(ssrc);
2639 if (it == recv_streams_.end()) { 2648 if (it == recv_streams_.end()) {
2640 LOG(LS_WARNING) << "SetRawAudioSink: no recv stream" << ssrc; 2649 LOG(LS_WARNING) << "SetRawAudioSink: no recv stream" << ssrc;
2641 return; 2650 return;
2642 } 2651 }
2643 it->second->SetRawAudioSink(std::move(sink)); 2652 it->second->SetRawAudioSink(std::move(sink));
2644 } 2653 }
2645 2654
2646 int WebRtcVoiceMediaChannel::GetOutputLevel(int channel) {
2647 unsigned int ulevel = 0;
2648 int ret = engine()->voe()->volume()->GetSpeechOutputLevel(channel, ulevel);
2649 return (ret == 0) ? static_cast<int>(ulevel) : -1;
2650 }
2651
2652 int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const { 2655 int WebRtcVoiceMediaChannel::GetReceiveChannelId(uint32_t ssrc) const {
2653 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2656 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2654 const auto it = recv_streams_.find(ssrc); 2657 const auto it = recv_streams_.find(ssrc);
2655 if (it != recv_streams_.end()) { 2658 if (it != recv_streams_.end()) {
2656 return it->second->channel(); 2659 return it->second->channel();
2657 } 2660 }
2658 return -1; 2661 return -1;
2659 } 2662 }
2660 2663
2661 int WebRtcVoiceMediaChannel::GetSendChannelId(uint32_t ssrc) const { 2664 int WebRtcVoiceMediaChannel::GetSendChannelId(uint32_t ssrc) const {
2662 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2665 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2663 const auto it = send_streams_.find(ssrc); 2666 const auto it = send_streams_.find(ssrc);
2664 if (it != send_streams_.end()) { 2667 if (it != send_streams_.end()) {
2665 return it->second->channel(); 2668 return it->second->channel();
2666 } 2669 }
2667 return -1; 2670 return -1;
2668 } 2671 }
2669 } // namespace cricket 2672 } // namespace cricket
2670 2673
2671 #endif // HAVE_WEBRTC_VOICE 2674 #endif // HAVE_WEBRTC_VOICE
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698