blob: cd792bcb435843fe2320cbc7bd3d42fa658220a2 [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
ivoc112a3d82015-10-16 02:22:18 -0700111 // Starts recording an RtcEventLog using an existing file until 10 minutes
112 // pass or the StopRtcEventLog function is called.
113 bool StartRtcEventLog(rtc::PlatformFile file);
114
115 // Stops recording the RtcEventLog.
116 void StopRtcEventLog();
117
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000118 // Create a VoiceEngine Channel.
119 int CreateMediaVoiceChannel();
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000120
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000121 private:
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000122 void Construct();
123 void ConstructCodecs();
henrik.lundin@webrtc.org8038d422014-11-11 08:38:24 +0000124 bool GetVoeCodec(int index, webrtc::CodecInst* codec);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000125 bool InitInternal();
126 void SetTraceFilter(int filter);
127 void SetTraceOptions(const std::string& options);
solenberg63b34542015-09-29 06:06:31 -0700128 // Every option that is "set" will be applied. Every option not "set" will be
129 // ignored. This allows us to selectively turn on and off different options
130 // easily at any time.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000131 bool ApplyOptions(const AudioOptions& options);
xians@webrtc.org3cefbc92014-10-10 09:42:53 +0000132
133 // webrtc::TraceCallback:
kjellander@webrtc.org14665ff2015-03-04 12:58:35 +0000134 void Print(webrtc::TraceLevel level, const char* trace, int length) override;
xians@webrtc.org3cefbc92014-10-10 09:42:53 +0000135
136 // webrtc::VoiceEngineObserver:
solenbergd97ec302015-10-07 01:40:33 -0700137 void CallbackOnError(int channel_id, int errCode) override;
xians@webrtc.org3cefbc92014-10-10 09:42:53 +0000138
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000139 // Given the device type, name, and id, find device id. Return true and
140 // set the output parameter rtc_id if successful.
141 bool FindWebRtcAudioDeviceId(
142 bool is_input, const std::string& dev_name, int dev_id, int* rtc_id);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000143
144 void StartAecDump(const std::string& filename);
145 void StopAecDump();
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000146 int CreateVoiceChannel(VoEWrapper* voe);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000147
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000148 static const int kDefaultLogSeverity = rtc::LS_WARNING;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000149
150 // The primary instance of WebRtc VoiceEngine.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000151 rtc::scoped_ptr<VoEWrapper> voe_wrapper_;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000152 rtc::scoped_ptr<VoETraceWrapper> tracing_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000153 // The external audio device manager
154 webrtc::AudioDeviceModule* adm_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000155 int log_filter_;
156 std::string log_options_;
157 bool is_dumping_aec_;
158 std::vector<AudioCodec> codecs_;
159 std::vector<RtpHeaderExtension> rtp_header_extensions_;
solenberg63b34542015-09-29 06:06:31 -0700160 std::vector<WebRtcVoiceMediaChannel*> channels_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000161 // channels_ can be read from WebRtc callback thread. We need a lock on that
162 // callback as well as the RegisterChannel/UnregisterChannel.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000163 rtc::CriticalSection channels_cs_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000164 webrtc::AgcConfig default_agc_config_;
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000165
166 webrtc::Config voe_config_;
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000167
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000168 bool initialized_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000169 AudioOptions options_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000170
Henrik Lundin441f6342015-06-09 16:03:13 +0200171 // Cache received extended_filter_aec, delay_agnostic_aec and experimental_ns
Bjorn Volckerbf395c12015-03-25 22:45:56 +0100172 // values, and apply them in case they are missing in the audio options. We
173 // need to do this because SetExtraOptions() will revert to defaults for
174 // options which are not provided.
Henrik Lundin441f6342015-06-09 16:03:13 +0200175 Settable<bool> extended_filter_aec_;
Bjorn Volckerbf395c12015-03-25 22:45:56 +0100176 Settable<bool> delay_agnostic_aec_;
buildbot@webrtc.org1f8a2372014-08-28 10:52:44 +0000177 Settable<bool> experimental_ns_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000178};
179
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000180// WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses
181// WebRtc Voice Engine.
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200182class WebRtcVoiceMediaChannel : public VoiceMediaChannel,
183 public webrtc::Transport {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000184 public:
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200185 WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine,
186 const AudioOptions& options,
187 webrtc::Call* call);
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200188 ~WebRtcVoiceMediaChannel() override;
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200189
solenberg8fb30c32015-10-13 03:06:58 -0700190 int default_send_channel_id() const { return default_send_channel_id_; }
191 bool valid() const { return default_send_channel_id_ != -1; }
solenberg66f43392015-09-09 01:36:22 -0700192 const AudioOptions& options() const { return options_; }
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200193
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700194 bool SetSendParameters(const AudioSendParameters& params) override;
195 bool SetRecvParameters(const AudioRecvParameters& params) override;
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200196 bool SetPlayout(bool playout) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000197 bool PausePlayout();
198 bool ResumePlayout();
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200199 bool SetSend(SendFlags send) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000200 bool PauseSend();
201 bool ResumeSend();
Peter Boström0c4e06b2015-10-07 12:23:21 +0200202 bool SetAudioSend(uint32_t ssrc,
203 bool enable,
204 const AudioOptions* options,
solenberg1dd98f32015-09-10 01:57:14 -0700205 AudioRenderer* renderer) override;
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200206 bool AddSendStream(const StreamParams& sp) override;
Peter Boström0c4e06b2015-10-07 12:23:21 +0200207 bool RemoveSendStream(uint32_t ssrc) override;
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200208 bool AddRecvStream(const StreamParams& sp) override;
Peter Boström0c4e06b2015-10-07 12:23:21 +0200209 bool RemoveRecvStream(uint32_t ssrc) override;
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200210 bool GetActiveStreams(AudioInfo::StreamList* actives) override;
211 int GetOutputLevel() override;
212 int GetTimeSinceLastTyping() override;
213 void SetTypingDetectionParameters(int time_window,
214 int cost_per_typing,
215 int reporting_threshold,
216 int penalty_decay,
217 int type_event_delay) override;
solenberg4bac9c52015-10-09 02:32:53 -0700218 bool SetOutputVolume(uint32_t ssrc, double volume) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000219
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200220 bool CanInsertDtmf() override;
Peter Boström0c4e06b2015-10-07 12:23:21 +0200221 bool InsertDtmf(uint32_t ssrc, int event, int duration, int flags) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000222
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200223 void OnPacketReceived(rtc::Buffer* packet,
224 const rtc::PacketTime& packet_time) override;
225 void OnRtcpReceived(rtc::Buffer* packet,
226 const rtc::PacketTime& packet_time) override;
227 void OnReadyToSend(bool ready) override {}
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200228 bool GetStats(VoiceMediaInfo* info) override;
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200229
230 // implements Transport interface
stefan1d8a5062015-10-02 03:39:33 -0700231 bool SendRtp(const uint8_t* data,
232 size_t len,
233 const webrtc::PacketOptions& options) override {
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200234 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len,
235 kMaxRtpPacketLen);
stefanc1aeaf02015-10-15 07:26:07 -0700236 rtc::PacketOptions rtc_options;
237 rtc_options.packet_id = options.packet_id;
238 return VoiceMediaChannel::SendPacket(&packet, rtc_options);
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200239 }
240
pbos2d566682015-09-28 09:59:31 -0700241 bool SendRtcp(const uint8_t* data, size_t len) override {
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200242 rtc::Buffer packet(reinterpret_cast<const uint8_t*>(data), len,
243 kMaxRtpPacketLen);
stefanc1aeaf02015-10-15 07:26:07 -0700244 return VoiceMediaChannel::SendRtcp(&packet, rtc::PacketOptions());
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200245 }
246
solenbergd97ec302015-10-07 01:40:33 -0700247 void OnError(int error);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000248
Peter Boström0c4e06b2015-10-07 12:23:21 +0200249 int GetReceiveChannelId(uint32_t ssrc) const;
250 int GetSendChannelId(uint32_t ssrc) const;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000251
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200252 private:
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200253 bool SetSendCodecs(const std::vector<AudioCodec>& codecs);
254 bool SetSendRtpHeaderExtensions(
255 const std::vector<RtpHeaderExtension>& extensions);
256 bool SetOptions(const AudioOptions& options);
257 bool SetMaxSendBandwidth(int bps);
258 bool SetRecvCodecs(const std::vector<AudioCodec>& codecs);
259 bool SetRecvRtpHeaderExtensions(
260 const std::vector<RtpHeaderExtension>& extensions);
Peter Boström0c4e06b2015-10-07 12:23:21 +0200261 bool SetLocalRenderer(uint32_t ssrc, AudioRenderer* renderer);
262 bool MuteStream(uint32_t ssrc, bool mute);
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200263
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200264 WebRtcVoiceEngine* engine() { return engine_; }
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000265 int GetLastEngineError() { return engine()->GetLastEngineError(); }
266 int GetOutputLevel(int channel);
267 bool GetRedSendCodec(const AudioCodec& red_codec,
268 const std::vector<AudioCodec>& all_codecs,
269 webrtc::CodecInst* send_codec);
270 bool EnableRtcp(int channel);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000271 bool SetPlayout(int channel, bool playout);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000272 static Error WebRtcErrorToChannelError(int err_code);
273
mallinath@webrtc.org67ee6b92014-02-03 16:57:16 +0000274 class WebRtcVoiceChannelRenderer;
275 // Map of ssrc to WebRtcVoiceChannelRenderer object. A new object of
276 // WebRtcVoiceChannelRenderer will be created for every new stream and
277 // will be destroyed when the stream goes away.
Peter Boström0c4e06b2015-10-07 12:23:21 +0200278 typedef std::map<uint32_t, WebRtcVoiceChannelRenderer*> ChannelMap;
henrike@webrtc.org79047f92014-03-06 23:46:59 +0000279 typedef int (webrtc::VoERTP_RTCP::* ExtensionSetterFunction)(int, bool,
280 unsigned char);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000281
wu@webrtc.orgcadf9042013-08-30 21:24:16 +0000282 void SetNack(int channel, bool nack_enabled);
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000283 void SetNack(const ChannelMap& channels, bool nack_enabled);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000284 bool SetSendCodec(const webrtc::CodecInst& send_codec);
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000285 bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000286 bool ChangePlayout(bool playout);
287 bool ChangeSend(SendFlags send);
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000288 bool ChangeSend(int channel, SendFlags send);
289 void ConfigureSendChannel(int channel);
wu@webrtc.org78187522013-10-07 23:32:02 +0000290 bool ConfigureRecvChannel(int channel);
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000291 bool DeleteChannel(int channel);
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000292 bool IsDefaultChannel(int channel_id) const {
solenberg8fb30c32015-10-13 03:06:58 -0700293 return channel_id == default_send_channel_id_;
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000294 }
solenberg1ac56142015-10-13 03:58:19 -0700295 bool IsDefaultRecvStream(uint32_t ssrc) {
296 return default_recv_ssrc_ == static_cast<int64_t>(ssrc);
297 }
wu@webrtc.orgcadf9042013-08-30 21:24:16 +0000298 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs);
minyue@webrtc.org26236952014-10-29 02:27:08 +0000299 bool SetSendBitrateInternal(int bps);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000300
henrike@webrtc.org79047f92014-03-06 23:46:59 +0000301 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id,
302 const RtpHeaderExtension* extension);
Fredrik Solenberg709ed672015-09-15 12:26:33 +0200303 void RecreateAudioReceiveStreams();
Peter Boström0c4e06b2015-10-07 12:23:21 +0200304 void AddAudioReceiveStream(uint32_t ssrc);
305 void RemoveAudioReceiveStream(uint32_t ssrc);
Fredrik Solenbergaf9fb212015-08-26 10:45:53 +0200306 bool SetRecvCodecsInternal(const std::vector<AudioCodec>& new_codecs);
Fredrik Solenberg4b60c732015-05-07 14:07:48 +0200307
buildbot@webrtc.org150835e2014-05-06 15:54:38 +0000308 bool SetChannelRecvRtpHeaderExtensions(
309 int channel_id,
310 const std::vector<RtpHeaderExtension>& extensions);
311 bool SetChannelSendRtpHeaderExtensions(
312 int channel_id,
313 const std::vector<RtpHeaderExtension>& extensions);
314
Fredrik Solenberg4b60c732015-05-07 14:07:48 +0200315 rtc::ThreadChecker thread_checker_;
316
Fredrik Solenberg709ed672015-09-15 12:26:33 +0200317 WebRtcVoiceEngine* const engine_;
solenberg8fb30c32015-10-13 03:06:58 -0700318 const int default_send_channel_id_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000319 std::vector<AudioCodec> recv_codecs_;
wu@webrtc.orgcadf9042013-08-30 21:24:16 +0000320 std::vector<AudioCodec> send_codecs_;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000321 rtc::scoped_ptr<webrtc::CodecInst> send_codec_;
minyue@webrtc.org26236952014-10-29 02:27:08 +0000322 bool send_bitrate_setting_;
323 int send_bitrate_bps_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000324 AudioOptions options_;
325 bool dtmf_allowed_;
326 bool desired_playout_;
327 bool nack_enabled_;
328 bool playout_;
wu@webrtc.org967bfff2013-09-19 05:49:50 +0000329 bool typing_noise_detected_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000330 SendFlags desired_send_;
331 SendFlags send_;
Fredrik Solenberg709ed672015-09-15 12:26:33 +0200332 webrtc::Call* const call_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000333
solenberg1ac56142015-10-13 03:58:19 -0700334 // SSRC of unsignalled receive stream, or -1 if there isn't one.
335 int64_t default_recv_ssrc_ = -1;
336 // Volume for unsignalled stream, which may be set before the stream exists.
337 double default_recv_volume_ = 1.0;
338
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000339 // send_channels_ contains the channels which are being used for sending.
solenberg8fb30c32015-10-13 03:06:58 -0700340 // When the default channel (default_send_channel_id) is used for sending, it
341 // is contained in send_channels_, otherwise not.
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000342 ChannelMap send_channels_;
buildbot@webrtc.org150835e2014-05-06 15:54:38 +0000343 std::vector<RtpHeaderExtension> send_extensions_;
solenberg1ac56142015-10-13 03:58:19 -0700344 ChannelMap receive_channels_;
Peter Boström0c4e06b2015-10-07 12:23:21 +0200345 std::map<uint32_t, webrtc::AudioReceiveStream*> receive_streams_;
346 std::map<uint32_t, StreamParams> receive_stream_params_;
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000347 // receive_channels_ can be read from WebRtc callback thread. Access from
348 // the WebRtc thread must be synchronized with edits on the worker thread.
349 // Reads on the worker thread are ok.
buildbot@webrtc.org150835e2014-05-06 15:54:38 +0000350 std::vector<RtpHeaderExtension> receive_extensions_;
Fredrik Solenberg4b60c732015-05-07 14:07:48 +0200351 std::vector<webrtc::RtpExtension> recv_rtp_extensions_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000352};
353
354} // namespace cricket
355
356#endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_