blob: 7f0e89c13e7c5fa2ec5dbe45e30423c8d6857f71 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
2 * libjingle
3 * Copyright 2004 Google Inc.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef TALK_MEDIA_WEBRTCVOICEENGINE_H_
29#define TALK_MEDIA_WEBRTCVOICEENGINE_H_
30
31#include <map>
32#include <set>
33#include <string>
34#include <vector>
35
henrike@webrtc.org28e20752013-07-10 00:45:36 +000036#include "talk/media/base/rtputils.h"
37#include "talk/media/webrtc/webrtccommon.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000038#include "talk/media/webrtc/webrtcvoe.h"
39#include "talk/session/media/channel.h"
buildbot@webrtc.orga09a9992014-08-13 17:26:08 +000040#include "webrtc/base/buffer.h"
41#include "webrtc/base/byteorder.h"
42#include "webrtc/base/logging.h"
43#include "webrtc/base/scoped_ptr.h"
44#include "webrtc/base/stream.h"
Fredrik Solenberg4b60c732015-05-07 14:07:48 +020045#include "webrtc/base/thread_checker.h"
46#include "webrtc/call.h"
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +000047#include "webrtc/common.h"
Henrik Lundin64dad832015-05-11 12:44:23 +020048#include "webrtc/config.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000049
henrike@webrtc.org28e20752013-07-10 00:45:36 +000050namespace cricket {
51
henrike@webrtc.org28e20752013-07-10 00:45:36 +000052class AudioDeviceModule;
henrike@webrtc.org1e09a712013-07-26 19:17:59 +000053class AudioRenderer;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000054class VoETraceWrapper;
55class VoEWrapper;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000056class WebRtcVoiceMediaChannel;
57
58// WebRtcVoiceEngine is a class to be used with CompositeMediaEngine.
59// It uses the WebRtc VoiceEngine library for audio handling.
60class WebRtcVoiceEngine
61 : public webrtc::VoiceEngineObserver,
Fredrik Solenberg7d173362015-09-23 12:23:21 +020062 public webrtc::TraceCallback {
Jelena Marusicc28a8962015-05-29 15:05:44 +020063 friend class WebRtcVoiceMediaChannel;
64
henrike@webrtc.org28e20752013-07-10 00:45:36 +000065 public:
66 WebRtcVoiceEngine();
67 // Dependency injection for testing.
Fredrik Solenbergccb49e72015-05-19 11:37:56 +020068 WebRtcVoiceEngine(VoEWrapper* voe_wrapper, VoETraceWrapper* tracing);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000069 ~WebRtcVoiceEngine();
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000070 bool Init(rtc::Thread* worker_thread);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000071 void Terminate();
72
Fredrik Solenberg709ed672015-09-15 12:26:33 +020073 webrtc::VoiceEngine* GetVoE() { return voe()->engine(); }
74 VoiceMediaChannel* CreateChannel(webrtc::Call* call,
75 const AudioOptions& options);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000076
mallinath@webrtc.orga27be8e2013-09-27 23:04:10 +000077 AudioOptions GetOptions() const { return options_; }
78 bool SetOptions(const AudioOptions& options);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000079 bool SetDevices(const Device* in_device, const Device* out_device);
80 bool GetOutputVolume(int* level);
81 bool SetOutputVolume(int level);
82 int GetInputLevel();
henrike@webrtc.org28e20752013-07-10 00:45:36 +000083
84 const std::vector<AudioCodec>& codecs();
85 bool FindCodec(const AudioCodec& codec);
86 bool FindWebRtcCodec(const AudioCodec& codec, webrtc::CodecInst* gcodec);
87
88 const std::vector<RtpHeaderExtension>& rtp_header_extensions() const;
89
90 void SetLogging(int min_sev, const char* filter);
91
henrike@webrtc.org28e20752013-07-10 00:45:36 +000092 // For tracking WebRtc channels. Needed because we have to pause them
93 // all when switching devices.
94 // May only be called by WebRtcVoiceMediaChannel.
solenberg63b34542015-09-29 06:06:31 -070095 void RegisterChannel(WebRtcVoiceMediaChannel* channel);
96 void UnregisterChannel(WebRtcVoiceMediaChannel* channel);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000097
henrike@webrtc.org28e20752013-07-10 00:45:36 +000098 // Called by WebRtcVoiceMediaChannel to set a gain offset from
99 // the default AGC target level.
100 bool AdjustAgcLevel(int delta);
101
102 VoEWrapper* voe() { return voe_wrapper_.get(); }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000103 int GetLastEngineError();
104
Fredrik Solenbergccb49e72015-05-19 11:37:56 +0200105 // Set the external ADM. This can only be called before Init.
106 bool SetAudioDeviceModule(webrtc::AudioDeviceModule* adm);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000107
wu@webrtc.orga9890802013-12-13 00:21:03 +0000108 // Starts AEC dump using existing file.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000109 bool StartAecDump(rtc::PlatformFile file);
wu@webrtc.orga9890802013-12-13 00:21:03 +0000110
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000111 // Create a VoiceEngine Channel.
112 int CreateMediaVoiceChannel();
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000113
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000114 private:
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000115 void Construct();
116 void ConstructCodecs();
henrik.lundin@webrtc.org8038d422014-11-11 08:38:24 +0000117 bool GetVoeCodec(int index, webrtc::CodecInst* codec);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000118 bool InitInternal();
119 void SetTraceFilter(int filter);
120 void SetTraceOptions(const std::string& options);
solenberg63b34542015-09-29 06:06:31 -0700121 // Every option that is "set" will be applied. Every option not "set" will be
122 // ignored. This allows us to selectively turn on and off different options
123 // easily at any time.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000124 bool ApplyOptions(const AudioOptions& options);
xians@webrtc.org3cefbc92014-10-10 09:42:53 +0000125
126 // webrtc::TraceCallback:
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000127 void Print(webrtc::TraceLevel level, const char* trace, int length) override;
xians@webrtc.org3cefbc92014-10-10 09:42:53 +0000128
129 // webrtc::VoiceEngineObserver:
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000130 void CallbackOnError(int channel, int errCode) override;
xians@webrtc.org3cefbc92014-10-10 09:42:53 +0000131
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000132 // Given the device type, name, and id, find device id. Return true and
133 // set the output parameter rtc_id if successful.
134 bool FindWebRtcAudioDeviceId(
135 bool is_input, const std::string& dev_name, int dev_id, int* rtc_id);
136 bool FindChannelAndSsrc(int channel_num,
137 WebRtcVoiceMediaChannel** channel,
138 uint32* ssrc) const;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000139
140 void StartAecDump(const std::string& filename);
141 void StopAecDump();
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000142 int CreateVoiceChannel(VoEWrapper* voe);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000143
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000144 static const int kDefaultLogSeverity = rtc::LS_WARNING;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000145
146 // The primary instance of WebRtc VoiceEngine.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000147 rtc::scoped_ptr<VoEWrapper> voe_wrapper_;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000148 rtc::scoped_ptr<VoETraceWrapper> tracing_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000149 // The external audio device manager
150 webrtc::AudioDeviceModule* adm_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000151 int log_filter_;
152 std::string log_options_;
153 bool is_dumping_aec_;
154 std::vector<AudioCodec> codecs_;
155 std::vector<RtpHeaderExtension> rtp_header_extensions_;
solenberg63b34542015-09-29 06:06:31 -0700156 std::vector<WebRtcVoiceMediaChannel*> channels_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000157 // channels_ can be read from WebRtc callback thread. We need a lock on that
158 // callback as well as the RegisterChannel/UnregisterChannel.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000159 rtc::CriticalSection channels_cs_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000160 webrtc::AgcConfig default_agc_config_;
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000161
162 webrtc::Config voe_config_;
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000163
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000164 bool initialized_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000165 AudioOptions options_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000166
Henrik Lundin441f6342015-06-09 16:03:13 +0200167 // Cache received extended_filter_aec, delay_agnostic_aec and experimental_ns
Bjorn Volckerbf395c12015-03-25 22:45:56 +0100168 // values, and apply them in case they are missing in the audio options. We
169 // need to do this because SetExtraOptions() will revert to defaults for
170 // options which are not provided.
Henrik Lundin441f6342015-06-09 16:03:13 +0200171 Settable<bool> extended_filter_aec_;
Bjorn Volckerbf395c12015-03-25 22:45:56 +0100172 Settable<bool> delay_agnostic_aec_;
buildbot@webrtc.org1f8a2372014-08-28 10:52:44 +0000173 Settable<bool> experimental_ns_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000174};
175
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000176// WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses
177// WebRtc Voice Engine.
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200178class WebRtcVoiceMediaChannel : public VoiceMediaChannel,
179 public webrtc::Transport {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000180 public:
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200181 WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine,
182 const AudioOptions& options,
183 webrtc::Call* call);
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200184 ~WebRtcVoiceMediaChannel() override;
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200185
186 int voe_channel() const { return voe_channel_; }
187 bool valid() const { return voe_channel_ != -1; }
solenberg66f43392015-09-09 01:36:22 -0700188 const AudioOptions& options() const { return options_; }
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200189
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700190 bool SetSendParameters(const AudioSendParameters& params) override;
191 bool SetRecvParameters(const AudioRecvParameters& params) override;
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200192 bool SetPlayout(bool playout) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000193 bool PausePlayout();
194 bool ResumePlayout();
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200195 bool SetSend(SendFlags send) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000196 bool PauseSend();
197 bool ResumeSend();
solenberg1dd98f32015-09-10 01:57:14 -0700198 bool SetAudioSend(uint32 ssrc, bool mute, const AudioOptions* options,
199 AudioRenderer* renderer) override;
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200200 bool AddSendStream(const StreamParams& sp) override;
201 bool RemoveSendStream(uint32 ssrc) override;
202 bool AddRecvStream(const StreamParams& sp) override;
203 bool RemoveRecvStream(uint32 ssrc) override;
204 bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) override;
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200205 bool GetActiveStreams(AudioInfo::StreamList* actives) override;
206 int GetOutputLevel() override;
207 int GetTimeSinceLastTyping() override;
208 void SetTypingDetectionParameters(int time_window,
209 int cost_per_typing,
210 int reporting_threshold,
211 int penalty_decay,
212 int type_event_delay) override;
213 bool SetOutputScaling(uint32 ssrc, double left, double right) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000214
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200215 bool CanInsertDtmf() override;
216 bool InsertDtmf(uint32 ssrc, int event, int duration, int flags) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000217
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200218 void OnPacketReceived(rtc::Buffer* packet,
219 const rtc::PacketTime& packet_time) override;
220 void OnRtcpReceived(rtc::Buffer* packet,
221 const rtc::PacketTime& packet_time) override;
222 void OnReadyToSend(bool ready) override {}
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200223 bool GetStats(VoiceMediaInfo* info) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000224 // Gets last reported error from WebRtc voice engine. This should be only
225 // called in response a failure.
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200226 void GetLastMediaError(uint32* ssrc,
227 VoiceMediaChannel::Error* error) override;
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200228
229 // implements Transport interface
pbos2d566682015-09-28 09:59:31 -0700230 bool SendRtp(const uint8_t* data, size_t len) override {
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200231 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len,
232 kMaxRtpPacketLen);
pbos2d566682015-09-28 09:59:31 -0700233 return VoiceMediaChannel::SendPacket(&packet);
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200234 }
235
pbos2d566682015-09-28 09:59:31 -0700236 bool SendRtcp(const uint8_t* data, size_t len) override {
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200237 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len,
238 kMaxRtpPacketLen);
pbos2d566682015-09-28 09:59:31 -0700239 return VoiceMediaChannel::SendRtcp(&packet);
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200240 }
241
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000242 bool FindSsrc(int channel_num, uint32* ssrc);
243 void OnError(uint32 ssrc, int error);
244
245 bool sending() const { return send_ != SEND_NOTHING; }
Fredrik Solenbergaf9fb212015-08-26 10:45:53 +0200246 int GetReceiveChannelNum(uint32 ssrc) const;
247 int GetSendChannelNum(uint32 ssrc) const;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000248
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200249 private:
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200250 bool SetSendCodecs(const std::vector<AudioCodec>& codecs);
251 bool SetSendRtpHeaderExtensions(
252 const std::vector<RtpHeaderExtension>& extensions);
253 bool SetOptions(const AudioOptions& options);
254 bool SetMaxSendBandwidth(int bps);
255 bool SetRecvCodecs(const std::vector<AudioCodec>& codecs);
256 bool SetRecvRtpHeaderExtensions(
257 const std::vector<RtpHeaderExtension>& extensions);
solenberg1dd98f32015-09-10 01:57:14 -0700258 bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer);
259 bool MuteStream(uint32 ssrc, bool mute);
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200260
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200261 WebRtcVoiceEngine* engine() { return engine_; }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000262 int GetLastEngineError() { return engine()->GetLastEngineError(); }
263 int GetOutputLevel(int channel);
264 bool GetRedSendCodec(const AudioCodec& red_codec,
265 const std::vector<AudioCodec>& all_codecs,
266 webrtc::CodecInst* send_codec);
267 bool EnableRtcp(int channel);
268 bool ResetRecvCodecs(int channel);
269 bool SetPlayout(int channel, bool playout);
270 static uint32 ParseSsrc(const void* data, size_t len, bool rtcp);
271 static Error WebRtcErrorToChannelError(int err_code);
272
mallinath@webrtc.org67ee6b92014-02-03 16:57:16 +0000273 class WebRtcVoiceChannelRenderer;
274 // Map of ssrc to WebRtcVoiceChannelRenderer object. A new object of
275 // WebRtcVoiceChannelRenderer will be created for every new stream and
276 // will be destroyed when the stream goes away.
277 typedef std::map<uint32, WebRtcVoiceChannelRenderer*> ChannelMap;
henrike@webrtc.org79047f92014-03-06 23:46:59 +0000278 typedef int (webrtc::VoERTP_RTCP::* ExtensionSetterFunction)(int, bool,
279 unsigned char);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000280
wu@webrtc.orgcadf9042013-08-30 21:24:16 +0000281 void SetNack(int channel, bool nack_enabled);
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000282 void SetNack(const ChannelMap& channels, bool nack_enabled);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000283 bool SetSendCodec(const webrtc::CodecInst& send_codec);
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000284 bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000285 bool ChangePlayout(bool playout);
286 bool ChangeSend(SendFlags send);
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000287 bool ChangeSend(int channel, SendFlags send);
288 void ConfigureSendChannel(int channel);
wu@webrtc.org78187522013-10-07 23:32:02 +0000289 bool ConfigureRecvChannel(int channel);
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000290 bool DeleteChannel(int channel);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000291 bool InConferenceMode() const {
292 return options_.conference_mode.GetWithDefaultIfUnset(false);
293 }
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000294 bool IsDefaultChannel(int channel_id) const {
295 return channel_id == voe_channel();
296 }
wu@webrtc.orgcadf9042013-08-30 21:24:16 +0000297 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs);
minyue@webrtc.org26236952014-10-29 02:27:08 +0000298 bool SetSendBitrateInternal(int bps);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000299
henrike@webrtc.org79047f92014-03-06 23:46:59 +0000300 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id,
301 const RtpHeaderExtension* extension);
Fredrik Solenberg709ed672015-09-15 12:26:33 +0200302 void RecreateAudioReceiveStreams();
303 void AddAudioReceiveStream(uint32 ssrc);
304 void RemoveAudioReceiveStream(uint32 ssrc);
Fredrik Solenbergaf9fb212015-08-26 10:45:53 +0200305 bool SetRecvCodecsInternal(const std::vector<AudioCodec>& new_codecs);
Fredrik Solenberg4b60c732015-05-07 14:07:48 +0200306
buildbot@webrtc.org150835e2014-05-06 15:54:38 +0000307 bool SetChannelRecvRtpHeaderExtensions(
308 int channel_id,
309 const std::vector<RtpHeaderExtension>& extensions);
310 bool SetChannelSendRtpHeaderExtensions(
311 int channel_id,
312 const std::vector<RtpHeaderExtension>& extensions);
313
Fredrik Solenberg4b60c732015-05-07 14:07:48 +0200314 rtc::ThreadChecker thread_checker_;
315
Fredrik Solenberg709ed672015-09-15 12:26:33 +0200316 WebRtcVoiceEngine* const engine_;
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200317 const int voe_channel_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000318 std::vector<AudioCodec> recv_codecs_;
wu@webrtc.orgcadf9042013-08-30 21:24:16 +0000319 std::vector<AudioCodec> send_codecs_;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000320 rtc::scoped_ptr<webrtc::CodecInst> send_codec_;
minyue@webrtc.org26236952014-10-29 02:27:08 +0000321 bool send_bitrate_setting_;
322 int send_bitrate_bps_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000323 AudioOptions options_;
324 bool dtmf_allowed_;
325 bool desired_playout_;
326 bool nack_enabled_;
327 bool playout_;
wu@webrtc.org967bfff2013-09-19 05:49:50 +0000328 bool typing_noise_detected_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000329 SendFlags desired_send_;
330 SendFlags send_;
Fredrik Solenberg709ed672015-09-15 12:26:33 +0200331 webrtc::Call* const call_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000332
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000333 // send_channels_ contains the channels which are being used for sending.
334 // When the default channel (voe_channel) is used for sending, it is
335 // contained in send_channels_, otherwise not.
336 ChannelMap send_channels_;
buildbot@webrtc.org150835e2014-05-06 15:54:38 +0000337 std::vector<RtpHeaderExtension> send_extensions_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000338 uint32 default_receive_ssrc_;
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000339 // Note the default channel (voe_channel()) can reside in both
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000340 // receive_channels_ and send_channels_ in non-conference mode and in that
341 // case it will only be there if a non-zero default_receive_ssrc_ is set.
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000342 ChannelMap receive_channels_; // for multiple sources
Fredrik Solenberg4b60c732015-05-07 14:07:48 +0200343 std::map<uint32, webrtc::AudioReceiveStream*> receive_streams_;
pbos8fc7fa72015-07-15 08:02:58 -0700344 std::map<uint32, StreamParams> receive_stream_params_;
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000345 // receive_channels_ can be read from WebRtc callback thread. Access from
346 // the WebRtc thread must be synchronized with edits on the worker thread.
347 // Reads on the worker thread are ok.
buildbot@webrtc.org150835e2014-05-06 15:54:38 +0000348 std::vector<RtpHeaderExtension> receive_extensions_;
Fredrik Solenberg4b60c732015-05-07 14:07:48 +0200349 std::vector<webrtc::RtpExtension> recv_rtp_extensions_;
350
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000351 // Do not lock this on the VoE media processor thread; potential for deadlock
352 // exists.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000353 mutable rtc::CriticalSection receive_channels_cs_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000354};
355
356} // namespace cricket
357
358#endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_