OLD | NEW |
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 14 matching lines...) Expand all Loading... |
25 #include "webrtc/base/constructormagic.h" | 25 #include "webrtc/base/constructormagic.h" |
26 #include "webrtc/base/helpers.h" | 26 #include "webrtc/base/helpers.h" |
27 #include "webrtc/base/logging.h" | 27 #include "webrtc/base/logging.h" |
28 #include "webrtc/base/race_checker.h" | 28 #include "webrtc/base/race_checker.h" |
29 #include "webrtc/base/stringencode.h" | 29 #include "webrtc/base/stringencode.h" |
30 #include "webrtc/base/stringutils.h" | 30 #include "webrtc/base/stringutils.h" |
31 #include "webrtc/base/trace_event.h" | 31 #include "webrtc/base/trace_event.h" |
32 #include "webrtc/media/base/audiosource.h" | 32 #include "webrtc/media/base/audiosource.h" |
33 #include "webrtc/media/base/mediaconstants.h" | 33 #include "webrtc/media/base/mediaconstants.h" |
34 #include "webrtc/media/base/streamparams.h" | 34 #include "webrtc/media/base/streamparams.h" |
| 35 #include "webrtc/media/engine/adm_helpers.h" |
35 #include "webrtc/media/engine/apm_helpers.h" | 36 #include "webrtc/media/engine/apm_helpers.h" |
36 #include "webrtc/media/engine/payload_type_mapper.h" | 37 #include "webrtc/media/engine/payload_type_mapper.h" |
37 #include "webrtc/media/engine/webrtcmediaengine.h" | 38 #include "webrtc/media/engine/webrtcmediaengine.h" |
38 #include "webrtc/media/engine/webrtcvoe.h" | 39 #include "webrtc/media/engine/webrtcvoe.h" |
39 #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" | 40 #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" |
40 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" | 41 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" |
41 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 42 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
42 #include "webrtc/system_wrappers/include/field_trial.h" | 43 #include "webrtc/system_wrappers/include/field_trial.h" |
43 #include "webrtc/system_wrappers/include/metrics.h" | 44 #include "webrtc/system_wrappers/include/metrics.h" |
44 #include "webrtc/system_wrappers/include/trace.h" | 45 #include "webrtc/system_wrappers/include/trace.h" |
45 #include "webrtc/voice_engine/transmit_mixer.h" | 46 #include "webrtc/voice_engine/transmit_mixer.h" |
46 | 47 |
47 namespace cricket { | 48 namespace cricket { |
48 namespace { | 49 namespace { |
49 | 50 |
50 constexpr size_t kMaxUnsignaledRecvStreams = 1; | 51 constexpr size_t kMaxUnsignaledRecvStreams = 1; |
51 | 52 |
52 const int kDefaultTraceFilter = webrtc::kTraceNone | webrtc::kTraceTerseInfo | | 53 const int kDefaultTraceFilter = webrtc::kTraceNone | webrtc::kTraceTerseInfo | |
53 webrtc::kTraceWarning | webrtc::kTraceError | | 54 webrtc::kTraceWarning | webrtc::kTraceError | |
54 webrtc::kTraceCritical; | 55 webrtc::kTraceCritical; |
55 const int kElevatedTraceFilter = kDefaultTraceFilter | webrtc::kTraceStateInfo | | 56 const int kElevatedTraceFilter = kDefaultTraceFilter | webrtc::kTraceStateInfo | |
56 webrtc::kTraceInfo; | 57 webrtc::kTraceInfo; |
57 | 58 |
58 // On Windows Vista and newer, Microsoft introduced the concept of "Default | |
59 // Communications Device". This means that there are two types of default | |
60 // devices (old Wave Audio style default and Default Communications Device). | |
61 // | |
62 // On Windows systems which only support Wave Audio style default, uses either | |
63 // -1 or 0 to select the default device. | |
64 #ifdef WIN32 | |
65 const int kDefaultAudioDeviceId = -1; | |
66 #elif !defined(WEBRTC_IOS) | |
67 const int kDefaultAudioDeviceId = 0; | |
68 #endif | |
69 | |
70 constexpr int kNackRtpHistoryMs = 5000; | 59 constexpr int kNackRtpHistoryMs = 5000; |
71 | 60 |
72 // Check to verify that the define for the intelligibility enhancer is properly | 61 // Check to verify that the define for the intelligibility enhancer is properly |
73 // set. | 62 // set. |
74 #if !defined(WEBRTC_INTELLIGIBILITY_ENHANCER) || \ | 63 #if !defined(WEBRTC_INTELLIGIBILITY_ENHANCER) || \ |
75 (WEBRTC_INTELLIGIBILITY_ENHANCER != 0 && \ | 64 (WEBRTC_INTELLIGIBILITY_ENHANCER != 0 && \ |
76 WEBRTC_INTELLIGIBILITY_ENHANCER != 1) | 65 WEBRTC_INTELLIGIBILITY_ENHANCER != 1) |
77 #error "Set WEBRTC_INTELLIGIBILITY_ENHANCER to either 0 or 1" | 66 #error "Set WEBRTC_INTELLIGIBILITY_ENHANCER to either 0 or 1" |
78 #endif | 67 #endif |
79 | 68 |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 options.extended_filter_aec = rtc::Optional<bool>(false); | 637 options.extended_filter_aec = rtc::Optional<bool>(false); |
649 options.delay_agnostic_aec = rtc::Optional<bool>(false); | 638 options.delay_agnostic_aec = rtc::Optional<bool>(false); |
650 options.experimental_ns = rtc::Optional<bool>(false); | 639 options.experimental_ns = rtc::Optional<bool>(false); |
651 options.intelligibility_enhancer = rtc::Optional<bool>(false); | 640 options.intelligibility_enhancer = rtc::Optional<bool>(false); |
652 options.level_control = rtc::Optional<bool>(false); | 641 options.level_control = rtc::Optional<bool>(false); |
653 options.residual_echo_detector = rtc::Optional<bool>(true); | 642 options.residual_echo_detector = rtc::Optional<bool>(true); |
654 bool error = ApplyOptions(options); | 643 bool error = ApplyOptions(options); |
655 RTC_DCHECK(error); | 644 RTC_DCHECK(error); |
656 } | 645 } |
657 | 646 |
658 SetDefaultDevices(); | 647 // Set default audio devices. |
| 648 #if !defined(WEBRTC_IOS) |
| 649 webrtc::adm_helpers::SetRecordingDevice(adm_); |
| 650 apm()->Initialize(); |
| 651 webrtc::adm_helpers::SetPlayoutDevice(adm_); |
| 652 #endif // !WEBRTC_IOS |
659 } | 653 } |
660 | 654 |
661 WebRtcVoiceEngine::~WebRtcVoiceEngine() { | 655 WebRtcVoiceEngine::~WebRtcVoiceEngine() { |
662 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 656 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
663 LOG(LS_INFO) << "WebRtcVoiceEngine::~WebRtcVoiceEngine"; | 657 LOG(LS_INFO) << "WebRtcVoiceEngine::~WebRtcVoiceEngine"; |
664 StopAecDump(); | 658 StopAecDump(); |
665 voe_wrapper_->base()->Terminate(); | 659 voe_wrapper_->base()->Terminate(); |
666 webrtc::Trace::SetTraceCallback(nullptr); | 660 webrtc::Trace::SetTraceCallback(nullptr); |
667 } | 661 } |
668 | 662 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 | 921 |
928 if (options.playout_sample_rate) { | 922 if (options.playout_sample_rate) { |
929 LOG(LS_INFO) << "Playout sample rate is " << *options.playout_sample_rate; | 923 LOG(LS_INFO) << "Playout sample rate is " << *options.playout_sample_rate; |
930 if (adm()->SetPlayoutSampleRate(*options.playout_sample_rate)) { | 924 if (adm()->SetPlayoutSampleRate(*options.playout_sample_rate)) { |
931 LOG_RTCERR1(SetPlayoutSampleRate, *options.playout_sample_rate); | 925 LOG_RTCERR1(SetPlayoutSampleRate, *options.playout_sample_rate); |
932 } | 926 } |
933 } | 927 } |
934 return true; | 928 return true; |
935 } | 929 } |
936 | 930 |
937 void WebRtcVoiceEngine::SetDefaultDevices() { | |
938 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
939 #if !defined(WEBRTC_IOS) | |
940 int in_id = kDefaultAudioDeviceId; | |
941 int out_id = kDefaultAudioDeviceId; | |
942 LOG(LS_INFO) << "Setting microphone to (id=" << in_id | |
943 << ") and speaker to (id=" << out_id << ")"; | |
944 | |
945 bool ret = true; | |
946 if (voe_wrapper_->hw()->SetRecordingDevice(in_id) == -1) { | |
947 LOG_RTCERR1(SetRecordingDevice, in_id); | |
948 ret = false; | |
949 } | |
950 | |
951 apm()->Initialize(); | |
952 | |
953 if (voe_wrapper_->hw()->SetPlayoutDevice(out_id) == -1) { | |
954 LOG_RTCERR1(SetPlayoutDevice, out_id); | |
955 ret = false; | |
956 } | |
957 | |
958 if (ret) { | |
959 LOG(LS_INFO) << "Set microphone to (id=" << in_id | |
960 << ") and speaker to (id=" << out_id << ")"; | |
961 } | |
962 #endif // !WEBRTC_IOS | |
963 } | |
964 | |
965 // TODO(solenberg): Remove, once AudioMonitor is gone. | 931 // TODO(solenberg): Remove, once AudioMonitor is gone. |
966 int WebRtcVoiceEngine::GetInputLevel() { | 932 int WebRtcVoiceEngine::GetInputLevel() { |
967 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 933 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
968 int8_t level = transmit_mixer()->AudioLevel(); | 934 int8_t level = transmit_mixer()->AudioLevel(); |
969 RTC_DCHECK_LE(0, level); | 935 RTC_DCHECK_LE(0, level); |
970 return level; | 936 return level; |
971 } | 937 } |
972 | 938 |
973 const std::vector<AudioCodec>& WebRtcVoiceEngine::send_codecs() const { | 939 const std::vector<AudioCodec>& WebRtcVoiceEngine::send_codecs() const { |
974 RTC_DCHECK(signal_thread_checker_.CalledOnValidThread()); | 940 RTC_DCHECK(signal_thread_checker_.CalledOnValidThread()); |
(...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2693 ssrc); | 2659 ssrc); |
2694 if (it != unsignaled_recv_ssrcs_.end()) { | 2660 if (it != unsignaled_recv_ssrcs_.end()) { |
2695 unsignaled_recv_ssrcs_.erase(it); | 2661 unsignaled_recv_ssrcs_.erase(it); |
2696 return true; | 2662 return true; |
2697 } | 2663 } |
2698 return false; | 2664 return false; |
2699 } | 2665 } |
2700 } // namespace cricket | 2666 } // namespace cricket |
2701 | 2667 |
2702 #endif // HAVE_WEBRTC_VOICE | 2668 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |