| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 bool FindCodec(const AudioCodec& codec); | 85 bool FindCodec(const AudioCodec& codec); |
| 86 bool FindWebRtcCodec(const AudioCodec& codec, webrtc::CodecInst* gcodec); | 86 bool FindWebRtcCodec(const AudioCodec& codec, webrtc::CodecInst* gcodec); |
| 87 | 87 |
| 88 const std::vector<RtpHeaderExtension>& rtp_header_extensions() const; | 88 const std::vector<RtpHeaderExtension>& rtp_header_extensions() const; |
| 89 | 89 |
| 90 void SetLogging(int min_sev, const char* filter); | 90 void SetLogging(int min_sev, const char* filter); |
| 91 | 91 |
| 92 // For tracking WebRtc channels. Needed because we have to pause them | 92 // For tracking WebRtc channels. Needed because we have to pause them |
| 93 // all when switching devices. | 93 // all when switching devices. |
| 94 // May only be called by WebRtcVoiceMediaChannel. | 94 // May only be called by WebRtcVoiceMediaChannel. |
| 95 void RegisterChannel(WebRtcVoiceMediaChannel *channel); | 95 void RegisterChannel(WebRtcVoiceMediaChannel* channel); |
| 96 void UnregisterChannel(WebRtcVoiceMediaChannel *channel); | 96 void UnregisterChannel(WebRtcVoiceMediaChannel* channel); |
| 97 | 97 |
| 98 // Called by WebRtcVoiceMediaChannel to set a gain offset from | 98 // Called by WebRtcVoiceMediaChannel to set a gain offset from |
| 99 // the default AGC target level. | 99 // the default AGC target level. |
| 100 bool AdjustAgcLevel(int delta); | 100 bool AdjustAgcLevel(int delta); |
| 101 | 101 |
| 102 VoEWrapper* voe() { return voe_wrapper_.get(); } | 102 VoEWrapper* voe() { return voe_wrapper_.get(); } |
| 103 int GetLastEngineError(); | 103 int GetLastEngineError(); |
| 104 | 104 |
| 105 // Set the external ADM. This can only be called before Init. | 105 // Set the external ADM. This can only be called before Init. |
| 106 bool SetAudioDeviceModule(webrtc::AudioDeviceModule* adm); | 106 bool SetAudioDeviceModule(webrtc::AudioDeviceModule* adm); |
| 107 | 107 |
| 108 // Starts AEC dump using existing file. | 108 // Starts AEC dump using existing file. |
| 109 bool StartAecDump(rtc::PlatformFile file); | 109 bool StartAecDump(rtc::PlatformFile file); |
| 110 | 110 |
| 111 // Create a VoiceEngine Channel. | 111 // Create a VoiceEngine Channel. |
| 112 int CreateMediaVoiceChannel(); | 112 int CreateMediaVoiceChannel(); |
| 113 | 113 |
| 114 private: | 114 private: |
| 115 typedef std::vector<WebRtcVoiceMediaChannel*> ChannelList; | |
| 116 | |
| 117 void Construct(); | 115 void Construct(); |
| 118 void ConstructCodecs(); | 116 void ConstructCodecs(); |
| 119 bool GetVoeCodec(int index, webrtc::CodecInst* codec); | 117 bool GetVoeCodec(int index, webrtc::CodecInst* codec); |
| 120 bool InitInternal(); | 118 bool InitInternal(); |
| 121 void SetTraceFilter(int filter); | 119 void SetTraceFilter(int filter); |
| 122 void SetTraceOptions(const std::string& options); | 120 void SetTraceOptions(const std::string& options); |
| 123 // Applies either options or overrides. Every option that is "set" | 121 // Every option that is "set" will be applied. Every option not "set" will be |
| 124 // will be applied. Every option not "set" will be ignored. This | 122 // ignored. This allows us to selectively turn on and off different options |
| 125 // allows us to selectively turn on and off different options easily | 123 // easily at any time. |
| 126 // at any time. | |
| 127 bool ApplyOptions(const AudioOptions& options); | 124 bool ApplyOptions(const AudioOptions& options); |
| 128 // Overrides, when set, take precedence over the options on a | |
| 129 // per-option basis. For example, if AGC is set in options and AEC | |
| 130 // is set in overrides, AGC and AEC will be both be set. Overrides | |
| 131 // can also turn off options. For example, if AGC is set to "on" in | |
| 132 // options and AGC is set to "off" in overrides, the result is that | |
| 133 // AGC will be off until different overrides are applied or until | |
| 134 // the overrides are cleared. Only one set of overrides is present | |
| 135 // at a time (they do not "stack"). And when the overrides are | |
| 136 // cleared, the media engine's state reverts back to the options set | |
| 137 // via SetOptions. This allows us to have both "persistent options" | |
| 138 // (the normal options) and "temporary options" (overrides). | |
| 139 bool SetOptionOverrides(const AudioOptions& options); | |
| 140 bool ClearOptionOverrides(); | |
| 141 | 125 |
| 142 // webrtc::TraceCallback: | 126 // webrtc::TraceCallback: |
| 143 void Print(webrtc::TraceLevel level, const char* trace, int length) override; | 127 void Print(webrtc::TraceLevel level, const char* trace, int length) override; |
| 144 | 128 |
| 145 // webrtc::VoiceEngineObserver: | 129 // webrtc::VoiceEngineObserver: |
| 146 void CallbackOnError(int channel, int errCode) override; | 130 void CallbackOnError(int channel, int errCode) override; |
| 147 | 131 |
| 148 // Given the device type, name, and id, find device id. Return true and | 132 // Given the device type, name, and id, find device id. Return true and |
| 149 // set the output parameter rtc_id if successful. | 133 // set the output parameter rtc_id if successful. |
| 150 bool FindWebRtcAudioDeviceId( | 134 bool FindWebRtcAudioDeviceId( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 162 // The primary instance of WebRtc VoiceEngine. | 146 // The primary instance of WebRtc VoiceEngine. |
| 163 rtc::scoped_ptr<VoEWrapper> voe_wrapper_; | 147 rtc::scoped_ptr<VoEWrapper> voe_wrapper_; |
| 164 rtc::scoped_ptr<VoETraceWrapper> tracing_; | 148 rtc::scoped_ptr<VoETraceWrapper> tracing_; |
| 165 // The external audio device manager | 149 // The external audio device manager |
| 166 webrtc::AudioDeviceModule* adm_; | 150 webrtc::AudioDeviceModule* adm_; |
| 167 int log_filter_; | 151 int log_filter_; |
| 168 std::string log_options_; | 152 std::string log_options_; |
| 169 bool is_dumping_aec_; | 153 bool is_dumping_aec_; |
| 170 std::vector<AudioCodec> codecs_; | 154 std::vector<AudioCodec> codecs_; |
| 171 std::vector<RtpHeaderExtension> rtp_header_extensions_; | 155 std::vector<RtpHeaderExtension> rtp_header_extensions_; |
| 172 ChannelList channels_; | 156 std::vector<WebRtcVoiceMediaChannel*> channels_; |
| 173 // channels_ can be read from WebRtc callback thread. We need a lock on that | 157 // channels_ can be read from WebRtc callback thread. We need a lock on that |
| 174 // callback as well as the RegisterChannel/UnregisterChannel. | 158 // callback as well as the RegisterChannel/UnregisterChannel. |
| 175 rtc::CriticalSection channels_cs_; | 159 rtc::CriticalSection channels_cs_; |
| 176 webrtc::AgcConfig default_agc_config_; | 160 webrtc::AgcConfig default_agc_config_; |
| 177 | 161 |
| 178 webrtc::Config voe_config_; | 162 webrtc::Config voe_config_; |
| 179 | 163 |
| 180 bool initialized_; | 164 bool initialized_; |
| 181 // See SetOptions and SetOptionOverrides for a description of the | |
| 182 // difference between options and overrides. | |
| 183 // options_ are the base options, which combined with the | |
| 184 // option_overrides_, create the current options being used. | |
| 185 // options_ is stored so that when option_overrides_ is cleared, we | |
| 186 // can restore the options_ without the option_overrides. | |
| 187 AudioOptions options_; | 165 AudioOptions options_; |
| 188 AudioOptions option_overrides_; | |
| 189 | 166 |
| 190 // Cache received extended_filter_aec, delay_agnostic_aec and experimental_ns | 167 // Cache received extended_filter_aec, delay_agnostic_aec and experimental_ns |
| 191 // values, and apply them in case they are missing in the audio options. We | 168 // values, and apply them in case they are missing in the audio options. We |
| 192 // need to do this because SetExtraOptions() will revert to defaults for | 169 // need to do this because SetExtraOptions() will revert to defaults for |
| 193 // options which are not provided. | 170 // options which are not provided. |
| 194 Settable<bool> extended_filter_aec_; | 171 Settable<bool> extended_filter_aec_; |
| 195 Settable<bool> delay_agnostic_aec_; | 172 Settable<bool> delay_agnostic_aec_; |
| 196 Settable<bool> experimental_ns_; | 173 Settable<bool> experimental_ns_; |
| 197 }; | 174 }; |
| 198 | 175 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; | 349 std::vector<webrtc::RtpExtension> recv_rtp_extensions_; |
| 373 | 350 |
| 374 // Do not lock this on the VoE media processor thread; potential for deadlock | 351 // Do not lock this on the VoE media processor thread; potential for deadlock |
| 375 // exists. | 352 // exists. |
| 376 mutable rtc::CriticalSection receive_channels_cs_; | 353 mutable rtc::CriticalSection receive_channels_cs_; |
| 377 }; | 354 }; |
| 378 | 355 |
| 379 } // namespace cricket | 356 } // namespace cricket |
| 380 | 357 |
| 381 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ | 358 #endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_ |
| OLD | NEW |