blob: 69705cc6ee71a16196d063a41631d1cf1bd7c2c4 [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"
38#include "talk/media/webrtc/webrtcexport.h"
39#include "talk/media/webrtc/webrtcvoe.h"
40#include "talk/session/media/channel.h"
buildbot@webrtc.orga09a9992014-08-13 17:26:08 +000041#include "webrtc/base/buffer.h"
42#include "webrtc/base/byteorder.h"
43#include "webrtc/base/logging.h"
44#include "webrtc/base/scoped_ptr.h"
45#include "webrtc/base/stream.h"
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +000046#include "webrtc/common.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000047
48#if !defined(LIBPEERCONNECTION_LIB) && \
49 !defined(LIBPEERCONNECTION_IMPLEMENTATION)
buildbot@webrtc.org6b21b712014-07-31 15:08:53 +000050// If you hit this, then you've tried to include this header from outside
51// the shared library. An instance of this class must only be created from
52// within the library that actually implements it. Otherwise use the
53// WebRtcMediaEngine to construct an instance.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000054#error "Bogus include."
55#endif
56
henrike@webrtc.org28e20752013-07-10 00:45:36 +000057namespace cricket {
58
59// WebRtcSoundclipStream is an adapter object that allows a memory stream to be
60// passed into WebRtc, and support looping.
61class WebRtcSoundclipStream : public webrtc::InStream {
62 public:
63 WebRtcSoundclipStream(const char* buf, size_t len)
64 : mem_(buf, len), loop_(true) {
65 }
66 void set_loop(bool loop) { loop_ = loop; }
67 virtual int Read(void* buf, int len);
68 virtual int Rewind();
69
70 private:
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000071 rtc::MemoryStream mem_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000072 bool loop_;
73};
74
75// WebRtcMonitorStream is used to monitor a stream coming from WebRtc.
76// For now we just dump the data.
77class WebRtcMonitorStream : public webrtc::OutStream {
78 virtual bool Write(const void *buf, int len) {
79 return true;
80 }
81};
82
83class AudioDeviceModule;
henrike@webrtc.org1e09a712013-07-26 19:17:59 +000084class AudioRenderer;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000085class VoETraceWrapper;
86class VoEWrapper;
87class VoiceProcessor;
88class WebRtcSoundclipMedia;
89class WebRtcVoiceMediaChannel;
90
91// WebRtcVoiceEngine is a class to be used with CompositeMediaEngine.
92// It uses the WebRtc VoiceEngine library for audio handling.
93class WebRtcVoiceEngine
94 : public webrtc::VoiceEngineObserver,
95 public webrtc::TraceCallback,
96 public webrtc::VoEMediaProcess {
97 public:
98 WebRtcVoiceEngine();
99 // Dependency injection for testing.
100 WebRtcVoiceEngine(VoEWrapper* voe_wrapper,
101 VoEWrapper* voe_wrapper_sc,
102 VoETraceWrapper* tracing);
103 ~WebRtcVoiceEngine();
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000104 bool Init(rtc::Thread* worker_thread);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000105 void Terminate();
106
107 int GetCapabilities();
108 VoiceMediaChannel* CreateChannel();
109
110 SoundclipMedia* CreateSoundclip();
111
mallinath@webrtc.orga27be8e2013-09-27 23:04:10 +0000112 AudioOptions GetOptions() const { return options_; }
113 bool SetOptions(const AudioOptions& options);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000114 // Overrides, when set, take precedence over the options on a
115 // per-option basis. For example, if AGC is set in options and AEC
116 // is set in overrides, AGC and AEC will be both be set. Overrides
117 // can also turn off options. For example, if AGC is set to "on" in
118 // options and AGC is set to "off" in overrides, the result is that
119 // AGC will be off until different overrides are applied or until
120 // the overrides are cleared. Only one set of overrides is present
121 // at a time (they do not "stack"). And when the overrides are
122 // cleared, the media engine's state reverts back to the options set
123 // via SetOptions. This allows us to have both "persistent options"
124 // (the normal options) and "temporary options" (overrides).
125 bool SetOptionOverrides(const AudioOptions& options);
126 bool ClearOptionOverrides();
127 bool SetDelayOffset(int offset);
128 bool SetDevices(const Device* in_device, const Device* out_device);
129 bool GetOutputVolume(int* level);
130 bool SetOutputVolume(int level);
131 int GetInputLevel();
132 bool SetLocalMonitor(bool enable);
133
134 const std::vector<AudioCodec>& codecs();
135 bool FindCodec(const AudioCodec& codec);
136 bool FindWebRtcCodec(const AudioCodec& codec, webrtc::CodecInst* gcodec);
137
138 const std::vector<RtpHeaderExtension>& rtp_header_extensions() const;
139
140 void SetLogging(int min_sev, const char* filter);
141
142 bool RegisterProcessor(uint32 ssrc,
143 VoiceProcessor* voice_processor,
144 MediaProcessorDirection direction);
145 bool UnregisterProcessor(uint32 ssrc,
146 VoiceProcessor* voice_processor,
147 MediaProcessorDirection direction);
148
149 // Method from webrtc::VoEMediaProcess
150 virtual void Process(int channel,
151 webrtc::ProcessingTypes type,
152 int16_t audio10ms[],
153 int length,
154 int sampling_freq,
155 bool is_stereo);
156
157 // For tracking WebRtc channels. Needed because we have to pause them
158 // all when switching devices.
159 // May only be called by WebRtcVoiceMediaChannel.
160 void RegisterChannel(WebRtcVoiceMediaChannel *channel);
161 void UnregisterChannel(WebRtcVoiceMediaChannel *channel);
162
163 // May only be called by WebRtcSoundclipMedia.
164 void RegisterSoundclip(WebRtcSoundclipMedia *channel);
165 void UnregisterSoundclip(WebRtcSoundclipMedia *channel);
166
167 // Called by WebRtcVoiceMediaChannel to set a gain offset from
168 // the default AGC target level.
169 bool AdjustAgcLevel(int delta);
170
171 VoEWrapper* voe() { return voe_wrapper_.get(); }
172 VoEWrapper* voe_sc() { return voe_wrapper_sc_.get(); }
173 int GetLastEngineError();
174
175 // Set the external ADMs. This can only be called before Init.
176 bool SetAudioDeviceModule(webrtc::AudioDeviceModule* adm,
177 webrtc::AudioDeviceModule* adm_sc);
178
wu@webrtc.orga9890802013-12-13 00:21:03 +0000179 // Starts AEC dump using existing file.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000180 bool StartAecDump(rtc::PlatformFile file);
wu@webrtc.orga9890802013-12-13 00:21:03 +0000181
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000182 // Check whether the supplied trace should be ignored.
183 bool ShouldIgnoreTrace(const std::string& trace);
184
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000185 // Create a VoiceEngine Channel.
186 int CreateMediaVoiceChannel();
187 int CreateSoundclipVoiceChannel();
188
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000189 private:
190 typedef std::vector<WebRtcSoundclipMedia *> SoundclipList;
191 typedef std::vector<WebRtcVoiceMediaChannel *> ChannelList;
192 typedef sigslot::
193 signal3<uint32, MediaProcessorDirection, AudioFrame*> FrameSignal;
194
195 void Construct();
196 void ConstructCodecs();
197 bool InitInternal();
wu@webrtc.org4551b792013-10-09 15:37:36 +0000198 bool EnsureSoundclipEngineInit();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000199 void SetTraceFilter(int filter);
200 void SetTraceOptions(const std::string& options);
201 // Applies either options or overrides. Every option that is "set"
202 // will be applied. Every option not "set" will be ignored. This
203 // allows us to selectively turn on and off different options easily
204 // at any time.
205 bool ApplyOptions(const AudioOptions& options);
206 virtual void Print(webrtc::TraceLevel level, const char* trace, int length);
207 virtual void CallbackOnError(int channel, int errCode);
208 // Given the device type, name, and id, find device id. Return true and
209 // set the output parameter rtc_id if successful.
210 bool FindWebRtcAudioDeviceId(
211 bool is_input, const std::string& dev_name, int dev_id, int* rtc_id);
212 bool FindChannelAndSsrc(int channel_num,
213 WebRtcVoiceMediaChannel** channel,
214 uint32* ssrc) const;
215 bool FindChannelNumFromSsrc(uint32 ssrc,
216 MediaProcessorDirection direction,
217 int* channel_num);
218 bool ChangeLocalMonitor(bool enable);
219 bool PauseLocalMonitor();
220 bool ResumeLocalMonitor();
221
222 bool UnregisterProcessorChannel(MediaProcessorDirection channel_direction,
223 uint32 ssrc,
224 VoiceProcessor* voice_processor,
225 MediaProcessorDirection processor_direction);
226
227 void StartAecDump(const std::string& filename);
228 void StopAecDump();
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000229 int CreateVoiceChannel(VoEWrapper* voe);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000230
231 // When a voice processor registers with the engine, it is connected
232 // to either the Rx or Tx signals, based on the direction parameter.
233 // SignalXXMediaFrame will be invoked for every audio packet.
234 FrameSignal SignalRxMediaFrame;
235 FrameSignal SignalTxMediaFrame;
236
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000237 static const int kDefaultLogSeverity = rtc::LS_WARNING;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000238
239 // The primary instance of WebRtc VoiceEngine.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000240 rtc::scoped_ptr<VoEWrapper> voe_wrapper_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000241 // A secondary instance, for playing out soundclips (on the 'ring' device).
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000242 rtc::scoped_ptr<VoEWrapper> voe_wrapper_sc_;
wu@webrtc.org4551b792013-10-09 15:37:36 +0000243 bool voe_wrapper_sc_initialized_;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000244 rtc::scoped_ptr<VoETraceWrapper> tracing_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000245 // The external audio device manager
246 webrtc::AudioDeviceModule* adm_;
247 webrtc::AudioDeviceModule* adm_sc_;
248 int log_filter_;
249 std::string log_options_;
250 bool is_dumping_aec_;
251 std::vector<AudioCodec> codecs_;
252 std::vector<RtpHeaderExtension> rtp_header_extensions_;
253 bool desired_local_monitor_enable_;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000254 rtc::scoped_ptr<WebRtcMonitorStream> monitor_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000255 SoundclipList soundclips_;
256 ChannelList channels_;
257 // channels_ can be read from WebRtc callback thread. We need a lock on that
258 // callback as well as the RegisterChannel/UnregisterChannel.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000259 rtc::CriticalSection channels_cs_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000260 webrtc::AgcConfig default_agc_config_;
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000261
262 webrtc::Config voe_config_;
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +0000263
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000264 bool initialized_;
265 // See SetOptions and SetOptionOverrides for a description of the
266 // difference between options and overrides.
267 // options_ are the base options, which combined with the
268 // option_overrides_, create the current options being used.
269 // options_ is stored so that when option_overrides_ is cleared, we
270 // can restore the options_ without the option_overrides.
271 AudioOptions options_;
272 AudioOptions option_overrides_;
273
274 // When the media processor registers with the engine, the ssrc is cached
275 // here so that a look up need not be made when the callback is invoked.
276 // This is necessary because the lookup results in mux_channels_cs lock being
277 // held and if a remote participant leaves the hangout at the same time
278 // we hit a deadlock.
279 uint32 tx_processor_ssrc_;
280 uint32 rx_processor_ssrc_;
281
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000282 rtc::CriticalSection signal_media_critical_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000283};
284
285// WebRtcMediaChannel is a class that implements the common WebRtc channel
286// functionality.
287template <class T, class E>
288class WebRtcMediaChannel : public T, public webrtc::Transport {
289 public:
290 WebRtcMediaChannel(E *engine, int channel)
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000291 : engine_(engine), voe_channel_(channel) {}
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000292 E *engine() { return engine_; }
293 int voe_channel() const { return voe_channel_; }
294 bool valid() const { return voe_channel_ != -1; }
295
296 protected:
297 // implements Transport interface
298 virtual int SendPacket(int channel, const void *data, int len) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000299 rtc::Buffer packet(data, len, kMaxRtpPacketLen);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000300 if (!T::SendPacket(&packet)) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000301 return -1;
302 }
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000303 return len;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000304 }
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000305
306 virtual int SendRTCPPacket(int channel, const void *data, int len) {
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000307 rtc::Buffer packet(data, len, kMaxRtpPacketLen);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000308 return T::SendRtcp(&packet) ? len : -1;
309 }
310
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000311 private:
312 E *engine_;
313 int voe_channel_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000314};
315
316// WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses
317// WebRtc Voice Engine.
318class WebRtcVoiceMediaChannel
319 : public WebRtcMediaChannel<VoiceMediaChannel, WebRtcVoiceEngine> {
320 public:
321 explicit WebRtcVoiceMediaChannel(WebRtcVoiceEngine *engine);
322 virtual ~WebRtcVoiceMediaChannel();
323 virtual bool SetOptions(const AudioOptions& options);
324 virtual bool GetOptions(AudioOptions* options) const {
325 *options = options_;
326 return true;
327 }
328 virtual bool SetRecvCodecs(const std::vector<AudioCodec> &codecs);
329 virtual bool SetSendCodecs(const std::vector<AudioCodec> &codecs);
330 virtual bool SetRecvRtpHeaderExtensions(
331 const std::vector<RtpHeaderExtension>& extensions);
332 virtual bool SetSendRtpHeaderExtensions(
333 const std::vector<RtpHeaderExtension>& extensions);
334 virtual bool SetPlayout(bool playout);
335 bool PausePlayout();
336 bool ResumePlayout();
337 virtual bool SetSend(SendFlags send);
338 bool PauseSend();
339 bool ResumeSend();
340 virtual bool AddSendStream(const StreamParams& sp);
341 virtual bool RemoveSendStream(uint32 ssrc);
342 virtual bool AddRecvStream(const StreamParams& sp);
343 virtual bool RemoveRecvStream(uint32 ssrc);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000344 virtual bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer);
345 virtual bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000346 virtual bool GetActiveStreams(AudioInfo::StreamList* actives);
347 virtual int GetOutputLevel();
348 virtual int GetTimeSinceLastTyping();
349 virtual void SetTypingDetectionParameters(int time_window,
350 int cost_per_typing, int reporting_threshold, int penalty_decay,
351 int type_event_delay);
352 virtual bool SetOutputScaling(uint32 ssrc, double left, double right);
353 virtual bool GetOutputScaling(uint32 ssrc, double* left, double* right);
354
355 virtual bool SetRingbackTone(const char *buf, int len);
356 virtual bool PlayRingbackTone(uint32 ssrc, bool play, bool loop);
357 virtual bool CanInsertDtmf();
358 virtual bool InsertDtmf(uint32 ssrc, int event, int duration, int flags);
359
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000360 virtual void OnPacketReceived(rtc::Buffer* packet,
361 const rtc::PacketTime& packet_time);
362 virtual void OnRtcpReceived(rtc::Buffer* packet,
363 const rtc::PacketTime& packet_time);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000364 virtual void OnReadyToSend(bool ready) {}
365 virtual bool MuteStream(uint32 ssrc, bool on);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000366 virtual bool SetStartSendBandwidth(int bps);
367 virtual bool SetMaxSendBandwidth(int bps);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000368 virtual bool GetStats(VoiceMediaInfo* info);
369 // Gets last reported error from WebRtc voice engine. This should be only
370 // called in response a failure.
371 virtual void GetLastMediaError(uint32* ssrc,
372 VoiceMediaChannel::Error* error);
373 bool FindSsrc(int channel_num, uint32* ssrc);
374 void OnError(uint32 ssrc, int error);
375
376 bool sending() const { return send_ != SEND_NOTHING; }
377 int GetReceiveChannelNum(uint32 ssrc);
378 int GetSendChannelNum(uint32 ssrc);
379
380 protected:
381 int GetLastEngineError() { return engine()->GetLastEngineError(); }
382 int GetOutputLevel(int channel);
383 bool GetRedSendCodec(const AudioCodec& red_codec,
384 const std::vector<AudioCodec>& all_codecs,
385 webrtc::CodecInst* send_codec);
386 bool EnableRtcp(int channel);
387 bool ResetRecvCodecs(int channel);
388 bool SetPlayout(int channel, bool playout);
389 static uint32 ParseSsrc(const void* data, size_t len, bool rtcp);
390 static Error WebRtcErrorToChannelError(int err_code);
391
392 private:
mallinath@webrtc.org67ee6b92014-02-03 16:57:16 +0000393 class WebRtcVoiceChannelRenderer;
394 // Map of ssrc to WebRtcVoiceChannelRenderer object. A new object of
395 // WebRtcVoiceChannelRenderer will be created for every new stream and
396 // will be destroyed when the stream goes away.
397 typedef std::map<uint32, WebRtcVoiceChannelRenderer*> ChannelMap;
henrike@webrtc.org79047f92014-03-06 23:46:59 +0000398 typedef int (webrtc::VoERTP_RTCP::* ExtensionSetterFunction)(int, bool,
399 unsigned char);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000400
wu@webrtc.orgcadf9042013-08-30 21:24:16 +0000401 void SetNack(int channel, bool nack_enabled);
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000402 void SetNack(const ChannelMap& channels, bool nack_enabled);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000403 bool SetSendCodec(const webrtc::CodecInst& send_codec);
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000404 bool SetSendCodec(int channel, const webrtc::CodecInst& send_codec);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000405 bool ChangePlayout(bool playout);
406 bool ChangeSend(SendFlags send);
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000407 bool ChangeSend(int channel, SendFlags send);
408 void ConfigureSendChannel(int channel);
wu@webrtc.org78187522013-10-07 23:32:02 +0000409 bool ConfigureRecvChannel(int channel);
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000410 bool DeleteChannel(int channel);
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000411 bool InConferenceMode() const {
412 return options_.conference_mode.GetWithDefaultIfUnset(false);
413 }
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000414 bool IsDefaultChannel(int channel_id) const {
415 return channel_id == voe_channel();
416 }
wu@webrtc.orgcadf9042013-08-30 21:24:16 +0000417 bool SetSendCodecs(int channel, const std::vector<AudioCodec>& codecs);
sergeyu@chromium.org4b26e2e2014-01-15 23:15:54 +0000418 bool SetSendBandwidthInternal(int bps);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000419
henrike@webrtc.org79047f92014-03-06 23:46:59 +0000420 bool SetHeaderExtension(ExtensionSetterFunction setter, int channel_id,
421 const RtpHeaderExtension* extension);
422
buildbot@webrtc.org150835e2014-05-06 15:54:38 +0000423 bool SetChannelRecvRtpHeaderExtensions(
424 int channel_id,
425 const std::vector<RtpHeaderExtension>& extensions);
426 bool SetChannelSendRtpHeaderExtensions(
427 int channel_id,
428 const std::vector<RtpHeaderExtension>& extensions);
429
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000430 rtc::scoped_ptr<WebRtcSoundclipStream> ringback_tone_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000431 std::set<int> ringback_channels_; // channels playing ringback
432 std::vector<AudioCodec> recv_codecs_;
wu@webrtc.orgcadf9042013-08-30 21:24:16 +0000433 std::vector<AudioCodec> send_codecs_;
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000434 rtc::scoped_ptr<webrtc::CodecInst> send_codec_;
wu@webrtc.org1d1ffc92013-10-16 18:12:02 +0000435 bool send_bw_setting_;
wu@webrtc.org1d1ffc92013-10-16 18:12:02 +0000436 int send_bw_bps_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000437 AudioOptions options_;
438 bool dtmf_allowed_;
439 bool desired_playout_;
440 bool nack_enabled_;
441 bool playout_;
wu@webrtc.org967bfff2013-09-19 05:49:50 +0000442 bool typing_noise_detected_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000443 SendFlags desired_send_;
444 SendFlags send_;
445
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000446 // send_channels_ contains the channels which are being used for sending.
447 // When the default channel (voe_channel) is used for sending, it is
448 // contained in send_channels_, otherwise not.
449 ChannelMap send_channels_;
buildbot@webrtc.org150835e2014-05-06 15:54:38 +0000450 std::vector<RtpHeaderExtension> send_extensions_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000451 uint32 default_receive_ssrc_;
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000452 // Note the default channel (voe_channel()) can reside in both
wu@webrtc.org9dba5252013-08-05 20:36:57 +0000453 // receive_channels_ and send_channels_ in non-conference mode and in that
454 // case it will only be there if a non-zero default_receive_ssrc_ is set.
henrike@webrtc.org1e09a712013-07-26 19:17:59 +0000455 ChannelMap receive_channels_; // for multiple sources
456 // receive_channels_ can be read from WebRtc callback thread. Access from
457 // the WebRtc thread must be synchronized with edits on the worker thread.
458 // Reads on the worker thread are ok.
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000459 //
buildbot@webrtc.org150835e2014-05-06 15:54:38 +0000460 std::vector<RtpHeaderExtension> receive_extensions_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000461 // Do not lock this on the VoE media processor thread; potential for deadlock
462 // exists.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000463 mutable rtc::CriticalSection receive_channels_cs_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000464};
465
466} // namespace cricket
467
468#endif // TALK_MEDIA_WEBRTCVOICEENGINE_H_