blob: eb9f3ad4f54ef6b992cebff4090f4a33027b9d57 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellander1afca732016-02-07 20:46:45 -08002 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003 *
kjellander1afca732016-02-07 20:46:45 -08004 * 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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00009 */
10
Steve Anton10542f22019-01-11 09:11:00 -080011#ifndef MEDIA_ENGINE_WEBRTC_VOICE_ENGINE_H_
12#define MEDIA_ENGINE_WEBRTC_VOICE_ENGINE_H_
henrike@webrtc.org28e20752013-07-10 00:45:36 +000013
14#include <map>
kwiberg686a8ef2016-02-26 03:00:35 -080015#include <memory>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000016#include <string>
17#include <vector>
18
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "api/audio_codecs/audio_encoder_factory.h"
Steve Anton10542f22019-01-11 09:11:00 -080020#include "api/rtp_receiver_interface.h"
Mirko Bonadeid9708072019-01-25 20:26:48 +010021#include "api/scoped_refptr.h"
Danil Chapovalov4c7112a2019-03-27 18:51:45 +010022#include "api/task_queue/task_queue_factory.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020023#include "call/audio_state.h"
24#include "call/call.h"
Steve Anton10542f22019-01-11 09:11:00 -080025#include "media/base/rtp_utils.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020026#include "media/engine/apm_helpers.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020027#include "modules/audio_processing/include/audio_processing.h"
28#include "pc/channel.h"
29#include "rtc_base/buffer.h"
Steve Anton10542f22019-01-11 09:11:00 -080030#include "rtc_base/constructor_magic.h"
Sebastian Jansson470a5ea2019-01-23 12:37:49 +010031#include "rtc_base/experiments/audio_allocation_settings.h"
Steve Anton10542f22019-01-11 09:11:00 -080032#include "rtc_base/network_route.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020033#include "rtc_base/task_queue.h"
34#include "rtc_base/thread_checker.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000035
henrike@webrtc.org28e20752013-07-10 00:45:36 +000036namespace cricket {
37
henrike@webrtc.org28e20752013-07-10 00:45:36 +000038class AudioDeviceModule;
gyzhou95aa9642016-12-13 14:06:26 -080039class AudioMixer;
Taylor Brandstetter1a018dc2016-03-08 12:37:39 -080040class AudioSource;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000041class WebRtcVoiceMediaChannel;
42
43// WebRtcVoiceEngine is a class to be used with CompositeMediaEngine.
44// It uses the WebRtc VoiceEngine library for audio handling.
Sebastian Jansson84848f22018-11-16 10:40:36 +010045class WebRtcVoiceEngine final : public VoiceEngineInterface {
Jelena Marusicc28a8962015-05-29 15:05:44 +020046 friend class WebRtcVoiceMediaChannel;
Yves Gerey665174f2018-06-19 15:03:05 +020047
henrike@webrtc.org28e20752013-07-10 00:45:36 +000048 public:
ossu29b1a8d2016-06-13 07:34:51 -070049 WebRtcVoiceEngine(
Danil Chapovalov4c7112a2019-03-27 18:51:45 +010050 webrtc::TaskQueueFactory* task_queue_factory,
ossu29b1a8d2016-06-13 07:34:51 -070051 webrtc::AudioDeviceModule* adm,
ossueb1fde42017-05-02 06:46:30 -070052 const rtc::scoped_refptr<webrtc::AudioEncoderFactory>& encoder_factory,
gyzhou95aa9642016-12-13 14:06:26 -080053 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory,
peaha9cc40b2017-06-29 08:32:09 -070054 rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer,
55 rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing);
Sebastian Jansson84848f22018-11-16 10:40:36 +010056 ~WebRtcVoiceEngine() override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000057
deadbeefeb02c032017-06-15 08:29:25 -070058 // Does initialization that needs to occur on the worker thread.
Sebastian Jansson84848f22018-11-16 10:40:36 +010059 void Init() override;
deadbeefeb02c032017-06-15 08:29:25 -070060
Sebastian Jansson84848f22018-11-16 10:40:36 +010061 rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const override;
62 VoiceMediaChannel* CreateMediaChannel(
63 webrtc::Call* call,
64 const MediaConfig& config,
65 const AudioOptions& options,
66 const webrtc::CryptoOptions& crypto_options) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000067
Sebastian Jansson84848f22018-11-16 10:40:36 +010068 const std::vector<AudioCodec>& send_codecs() const override;
69 const std::vector<AudioCodec>& recv_codecs() const override;
70 RtpCapabilities GetCapabilities() const override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000071
henrike@webrtc.org28e20752013-07-10 00:45:36 +000072 // For tracking WebRtc channels. Needed because we have to pause them
73 // all when switching devices.
74 // May only be called by WebRtcVoiceMediaChannel.
solenberg63b34542015-09-29 06:06:31 -070075 void RegisterChannel(WebRtcVoiceMediaChannel* channel);
76 void UnregisterChannel(WebRtcVoiceMediaChannel* channel);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000077
ivocd66b44d2016-01-15 03:06:36 -080078 // Starts AEC dump using an existing file. A maximum file size in bytes can be
79 // specified. When the maximum file size is reached, logging is stopped and
80 // the file is closed. If max_size_bytes is set to <= 0, no limit will be
81 // used.
Sebastian Jansson84848f22018-11-16 10:40:36 +010082 bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) override;
wu@webrtc.orga9890802013-12-13 00:21:03 +000083
ivoc797ef122015-10-22 03:25:41 -070084 // Stops AEC dump.
Sebastian Jansson84848f22018-11-16 10:40:36 +010085 void StopAecDump() override;
ivoc797ef122015-10-22 03:25:41 -070086
henrike@webrtc.org28e20752013-07-10 00:45:36 +000087 private:
solenberg63b34542015-09-29 06:06:31 -070088 // Every option that is "set" will be applied. Every option not "set" will be
89 // ignored. This allows us to selectively turn on and off different options
90 // easily at any time.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000091 bool ApplyOptions(const AudioOptions& options);
xians@webrtc.org3cefbc92014-10-10 09:42:53 +000092
solenberg0a617e22015-10-20 15:49:38 -070093 int CreateVoEChannel();
aleloi048cbdd2017-05-29 02:56:27 -070094
Danil Chapovalov4c7112a2019-03-27 18:51:45 +010095 webrtc::TaskQueueFactory* const task_queue_factory_;
Amit Hilbuche27ccf92019-03-26 17:36:53 +000096 std::unique_ptr<rtc::TaskQueue> low_priority_worker_queue_;
aleloi048cbdd2017-05-29 02:56:27 -070097
solenberg5b5129a2016-04-08 05:35:48 -070098 webrtc::AudioDeviceModule* adm();
peahb1c9d1d2017-07-25 15:45:24 -070099 webrtc::AudioProcessing* apm() const;
Fredrik Solenberg2a877972017-12-15 16:42:15 +0100100 webrtc::AudioState* audio_state();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000101
ossu20a4b3f2017-04-27 02:08:52 -0700102 AudioCodecs CollectCodecs(
103 const std::vector<webrtc::AudioCodecSpec>& specs) const;
ossuc54071d2016-08-17 02:45:41 -0700104
solenberg566ef242015-11-06 15:34:49 -0800105 rtc::ThreadChecker signal_thread_checker_;
106 rtc::ThreadChecker worker_thread_checker_;
107
Sebastian Jansson470a5ea2019-01-23 12:37:49 +0100108 const webrtc::AudioAllocationSettings allocation_settings_;
109
Fredrik Solenberg2a877972017-12-15 16:42:15 +0100110 // The audio device module.
solenbergff976312016-03-30 23:28:51 -0700111 rtc::scoped_refptr<webrtc::AudioDeviceModule> adm_;
ossu20a4b3f2017-04-27 02:08:52 -0700112 rtc::scoped_refptr<webrtc::AudioEncoderFactory> encoder_factory_;
ossu29b1a8d2016-06-13 07:34:51 -0700113 rtc::scoped_refptr<webrtc::AudioDecoderFactory> decoder_factory_;
deadbeefeb02c032017-06-15 08:29:25 -0700114 rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer_;
Fredrik Solenberg2a877972017-12-15 16:42:15 +0100115 // The audio processing module.
peaha9cc40b2017-06-29 08:32:09 -0700116 rtc::scoped_refptr<webrtc::AudioProcessing> apm_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000117 // The primary instance of WebRtc VoiceEngine.
solenberg566ef242015-11-06 15:34:49 -0800118 rtc::scoped_refptr<webrtc::AudioState> audio_state_;
ossuc54071d2016-08-17 02:45:41 -0700119 std::vector<AudioCodec> send_codecs_;
120 std::vector<AudioCodec> recv_codecs_;
solenberg63b34542015-09-29 06:06:31 -0700121 std::vector<WebRtcVoiceMediaChannel*> channels_;
solenberg246b8172015-12-08 09:50:23 -0800122 bool is_dumping_aec_ = false;
deadbeefeb02c032017-06-15 08:29:25 -0700123 bool initialized_ = false;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000124
Alessio Bazzicacc22f512018-08-30 13:01:34 +0200125 // Cache received extended_filter_aec, delay_agnostic_aec and experimental_ns
126 // values, and apply them in case they are missing in the audio options.
127 // We need to do this because SetExtraOptions() will revert to defaults for
128 // options which are not provided.
Danil Chapovalov00c71832018-06-15 15:58:38 +0200129 absl::optional<bool> extended_filter_aec_;
130 absl::optional<bool> delay_agnostic_aec_;
131 absl::optional<bool> experimental_ns_;
Fredrik Solenberg8f5787a2018-01-11 13:52:30 +0100132 // Jitter buffer settings for new streams.
Jakob Ivarsson647d5e62019-03-15 10:37:31 +0100133 size_t audio_jitter_buffer_max_packets_ = 200;
Fredrik Solenberg8f5787a2018-01-11 13:52:30 +0100134 bool audio_jitter_buffer_fast_accelerate_ = false;
Jakob Ivarsson10403ae2018-11-27 15:45:20 +0100135 int audio_jitter_buffer_min_delay_ms_ = 0;
Jakob Ivarsson53eae872019-01-10 15:58:36 +0100136 bool audio_jitter_buffer_enable_rtx_handling_ = false;
solenbergc96df772015-10-21 13:01:53 -0700137
solenbergff976312016-03-30 23:28:51 -0700138 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcVoiceEngine);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000139};
140
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000141// WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses
142// WebRtc Voice Engine.
solenberg566ef242015-11-06 15:34:49 -0800143class WebRtcVoiceMediaChannel final : public VoiceMediaChannel,
144 public webrtc::Transport {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000145 public:
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200146 WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine,
nisse51542be2016-02-12 02:27:06 -0800147 const MediaConfig& config,
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200148 const AudioOptions& options,
Benjamin Wrightbfb444c2018-10-15 10:20:24 -0700149 const webrtc::CryptoOptions& crypto_options,
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200150 webrtc::Call* call);
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200151 ~WebRtcVoiceMediaChannel() override;
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200152
solenberg66f43392015-09-09 01:36:22 -0700153 const AudioOptions& options() const { return options_; }
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200154
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700155 bool SetSendParameters(const AudioSendParameters& params) override;
156 bool SetRecvParameters(const AudioRecvParameters& params) override;
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700157 webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const override;
Zach Steinba37b4b2018-01-23 15:02:36 -0800158 webrtc::RTCError SetRtpSendParameters(
159 uint32_t ssrc,
160 const webrtc::RtpParameters& parameters) override;
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700161 webrtc::RtpParameters GetRtpReceiveParameters(uint32_t ssrc) const override;
162 bool SetRtpReceiveParameters(
163 uint32_t ssrc,
164 const webrtc::RtpParameters& parameters) override;
skvlade0d46372016-04-07 22:59:22 -0700165
aleloi84ef6152016-08-04 05:28:21 -0700166 void SetPlayout(bool playout) override;
Taylor Brandstetter1a018dc2016-03-08 12:37:39 -0800167 void SetSend(bool send) override;
Peter Boström0c4e06b2015-10-07 12:23:21 +0200168 bool SetAudioSend(uint32_t ssrc,
169 bool enable,
170 const AudioOptions* options,
Taylor Brandstetter1a018dc2016-03-08 12:37:39 -0800171 AudioSource* source) override;
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200172 bool AddSendStream(const StreamParams& sp) override;
Peter Boström0c4e06b2015-10-07 12:23:21 +0200173 bool RemoveSendStream(uint32_t ssrc) override;
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200174 bool AddRecvStream(const StreamParams& sp) override;
Peter Boström0c4e06b2015-10-07 12:23:21 +0200175 bool RemoveRecvStream(uint32_t ssrc) override;
Benjamin Wright84583f62018-10-04 14:22:34 -0700176
177 // E2EE Frame API
178 // Set a frame decryptor to a particular ssrc that will intercept all
179 // incoming audio payloads and attempt to decrypt them before forwarding the
180 // result.
181 void SetFrameDecryptor(uint32_t ssrc,
182 rtc::scoped_refptr<webrtc::FrameDecryptorInterface>
183 frame_decryptor) override;
184 // Set a frame encryptor to a particular ssrc that will intercept all
185 // outgoing audio payloads frames and attempt to encrypt them and forward the
186 // result to the packetizer.
187 void SetFrameEncryptor(uint32_t ssrc,
188 rtc::scoped_refptr<webrtc::FrameEncryptorInterface>
189 frame_encryptor) override;
190
solenberg2100c0b2017-03-01 11:29:29 -0800191 // SSRC=0 will apply the new volume to current and future unsignaled streams.
solenberg4bac9c52015-10-09 02:32:53 -0700192 bool SetOutputVolume(uint32_t ssrc, double volume) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000193
Ruslan Burakov7ea46052019-02-16 02:07:05 +0100194 bool SetBaseMinimumPlayoutDelayMs(uint32_t ssrc, int delay_ms) override;
195 absl::optional<int> GetBaseMinimumPlayoutDelayMs(
196 uint32_t ssrc) const override;
197
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200198 bool CanInsertDtmf() override;
solenberg1d63dd02015-12-02 12:35:09 -0800199 bool InsertDtmf(uint32_t ssrc, int event, int duration) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000200
Amit Hilbuche7a5f7b2019-03-12 11:10:27 -0700201 void OnPacketReceived(rtc::CopyOnWriteBuffer packet,
Niels Möllere6933812018-11-05 13:01:41 +0100202 int64_t packet_time_us) override;
Amit Hilbuche7a5f7b2019-03-12 11:10:27 -0700203 void OnRtcpReceived(rtc::CopyOnWriteBuffer packet,
Niels Möllere6933812018-11-05 13:01:41 +0100204 int64_t packet_time_us) override;
Honghai Zhangcc411c02016-03-29 17:27:21 -0700205 void OnNetworkRouteChanged(const std::string& transport_name,
Honghai Zhang0e533ef2016-04-19 15:41:36 -0700206 const rtc::NetworkRoute& network_route) override;
skvlad7a43d252016-03-22 15:32:27 -0700207 void OnReadyToSend(bool ready) override;
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200208 bool GetStats(VoiceMediaInfo* info) override;
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200209
solenberg2100c0b2017-03-01 11:29:29 -0800210 // SSRC=0 will set the audio sink on the latest unsignaled stream, future or
211 // current. Only one stream at a time will use the sink.
Tommif888bb52015-12-12 01:37:01 +0100212 void SetRawAudioSink(
213 uint32_t ssrc,
kwiberg686a8ef2016-02-26 03:00:35 -0800214 std::unique_ptr<webrtc::AudioSinkInterface> sink) override;
Tommif888bb52015-12-12 01:37:01 +0100215
zhihuang38ede132017-06-15 12:52:32 -0700216 std::vector<webrtc::RtpSource> GetSources(uint32_t ssrc) const override;
hbos8d609f62017-04-10 07:39:05 -0700217
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200218 // implements Transport interface
stefan1d8a5062015-10-02 03:39:33 -0700219 bool SendRtp(const uint8_t* data,
220 size_t len,
221 const webrtc::PacketOptions& options) override {
jbaucheec21bd2016-03-20 06:15:43 -0700222 rtc::CopyOnWriteBuffer packet(data, len, kMaxRtpPacketLen);
stefanc1aeaf02015-10-15 07:26:07 -0700223 rtc::PacketOptions rtc_options;
224 rtc_options.packet_id = options.packet_id;
Tim Haloun6ca98362018-09-17 17:06:08 -0700225 if (DscpEnabled()) {
226 rtc_options.dscp = PreferredDscp();
227 }
Sebastian Jansson03789972018-10-09 18:27:57 +0200228 rtc_options.info_signaled_after_sent.included_in_feedback =
229 options.included_in_feedback;
230 rtc_options.info_signaled_after_sent.included_in_allocation =
231 options.included_in_allocation;
stefanc1aeaf02015-10-15 07:26:07 -0700232 return VoiceMediaChannel::SendPacket(&packet, rtc_options);
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200233 }
234
pbos2d566682015-09-28 09:59:31 -0700235 bool SendRtcp(const uint8_t* data, size_t len) override {
jbaucheec21bd2016-03-20 06:15:43 -0700236 rtc::CopyOnWriteBuffer packet(data, len, kMaxRtpPacketLen);
Qingsi Wang6e641e62018-04-11 20:14:17 -0700237 rtc::PacketOptions rtc_options;
Tim Haloun6ca98362018-09-17 17:06:08 -0700238 if (DscpEnabled()) {
239 rtc_options.dscp = PreferredDscp();
240 }
Tim Haloun648d28a2018-10-18 16:52:22 -0700241
Qingsi Wang6e641e62018-04-11 20:14:17 -0700242 return VoiceMediaChannel::SendRtcp(&packet, rtc_options);
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200243 }
244
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200245 private:
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200246 bool SetOptions(const AudioOptions& options);
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200247 bool SetRecvCodecs(const std::vector<AudioCodec>& codecs);
solenberg72e29d22016-03-08 06:35:16 -0800248 bool SetSendCodecs(const std::vector<AudioCodec>& codecs);
Taylor Brandstetter1a018dc2016-03-08 12:37:39 -0800249 bool SetLocalSource(uint32_t ssrc, AudioSource* source);
Peter Boström0c4e06b2015-10-07 12:23:21 +0200250 bool MuteStream(uint32_t ssrc, bool mute);
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200251
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200252 WebRtcVoiceEngine* engine() { return engine_; }
kwiberg37b8b112016-11-03 02:46:53 -0700253 void ChangePlayout(bool playout);
solenberg0a617e22015-10-20 15:49:38 -0700254 int CreateVoEChannel();
solenberg7add0582015-11-20 09:59:34 -0800255 bool DeleteVoEChannel(int channel);
deadbeef80346142016-04-27 14:17:10 -0700256 bool SetMaxSendBitrate(int bps);
solenbergd53a3f92016-04-14 13:56:37 -0700257 void SetupRecording();
solenberg2100c0b2017-03-01 11:29:29 -0800258 // Check if 'ssrc' is an unsignaled stream, and if so mark it as not being
259 // unsignaled anymore (i.e. it is now removed, or signaled), and return true.
260 bool MaybeDeregisterUnsignaledRecvStream(uint32_t ssrc);
Fredrik Solenberg4b60c732015-05-07 14:07:48 +0200261
solenberg566ef242015-11-06 15:34:49 -0800262 rtc::ThreadChecker worker_thread_checker_;
Fredrik Solenberg4b60c732015-05-07 14:07:48 +0200263
solenberg566ef242015-11-06 15:34:49 -0800264 WebRtcVoiceEngine* const engine_ = nullptr;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700265 std::vector<AudioCodec> send_codecs_;
kwiberg1c07c702017-03-27 07:15:49 -0700266
267 // TODO(kwiberg): decoder_map_ and recv_codecs_ store the exact same
268 // information, in slightly different formats. Eliminate recv_codecs_.
269 std::map<int, webrtc::SdpAudioFormat> decoder_map_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000270 std::vector<AudioCodec> recv_codecs_;
kwiberg1c07c702017-03-27 07:15:49 -0700271
deadbeef80346142016-04-27 14:17:10 -0700272 int max_send_bitrate_bps_ = 0;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000273 AudioOptions options_;
Danil Chapovalov00c71832018-06-15 15:58:38 +0200274 absl::optional<int> dtmf_payload_type_;
solenbergffbbcac2016-11-17 05:25:37 -0800275 int dtmf_payload_freq_ = -1;
solenberg72e29d22016-03-08 06:35:16 -0800276 bool recv_transport_cc_enabled_ = false;
solenberg8189b022016-06-14 12:13:00 -0700277 bool recv_nack_enabled_ = false;
solenbergffbbcac2016-11-17 05:25:37 -0800278 bool desired_playout_ = false;
solenberg566ef242015-11-06 15:34:49 -0800279 bool playout_ = false;
Taylor Brandstetter1a018dc2016-03-08 12:37:39 -0800280 bool send_ = false;
solenberg566ef242015-11-06 15:34:49 -0800281 webrtc::Call* const call_ = nullptr;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000282
Jiawei Ou55718122018-11-09 13:17:39 -0800283 const MediaConfig::Audio audio_config_;
284
solenberg2100c0b2017-03-01 11:29:29 -0800285 // Queue of unsignaled SSRCs; oldest at the beginning.
286 std::vector<uint32_t> unsignaled_recv_ssrcs_;
287
Seth Hampson5897a6e2018-04-03 11:16:33 -0700288 // This is a stream param that comes from the remote description, but wasn't
289 // signaled with any a=ssrc lines. It holds the information that was signaled
290 // before the unsignaled receive stream is created when the first packet is
291 // received.
292 StreamParams unsignaled_stream_params_;
293
solenberg2100c0b2017-03-01 11:29:29 -0800294 // Volume for unsignaled streams, which may be set before the stream exists.
solenberg1ac56142015-10-13 03:58:19 -0700295 double default_recv_volume_ = 1.0;
Ruslan Burakov7ea46052019-02-16 02:07:05 +0100296
297 // Delay for unsignaled streams, which may be set before the stream exists.
298 int default_recv_base_minimum_delay_ms_ = 0;
299
solenberg2100c0b2017-03-01 11:29:29 -0800300 // Sink for latest unsignaled stream - may be set before the stream exists.
kwiberg686a8ef2016-02-26 03:00:35 -0800301 std::unique_ptr<webrtc::AudioSinkInterface> default_sink_;
solenberg8093d542015-11-12 06:02:30 -0800302 // Default SSRC to use for RTCP receiver reports in case of no signaled
solenberg0a617e22015-10-20 15:49:38 -0700303 // send streams. See: https://code.google.com/p/webrtc/issues/detail?id=4740
solenberg8093d542015-11-12 06:02:30 -0800304 // and https://code.google.com/p/chromium/issues/detail?id=547661
305 uint32_t receiver_reports_ssrc_ = 0xFA17FA17u;
solenberg1ac56142015-10-13 03:58:19 -0700306
solenbergc96df772015-10-21 13:01:53 -0700307 class WebRtcAudioSendStream;
308 std::map<uint32_t, WebRtcAudioSendStream*> send_streams_;
solenberg3a941542015-11-16 07:34:50 -0800309 std::vector<webrtc::RtpExtension> send_rtp_extensions_;
Steve Antonbb50ce52018-03-26 10:24:32 -0700310 std::string mid_;
solenbergc96df772015-10-21 13:01:53 -0700311
312 class WebRtcAudioReceiveStream;
solenberg7add0582015-11-20 09:59:34 -0800313 std::map<uint32_t, WebRtcAudioReceiveStream*> recv_streams_;
Fredrik Solenberg4b60c732015-05-07 14:07:48 +0200314 std::vector<webrtc::RtpExtension> recv_rtp_extensions_;
solenbergc96df772015-10-21 13:01:53 -0700315
Danil Chapovalov00c71832018-06-15 15:58:38 +0200316 absl::optional<webrtc::AudioSendStream::Config::SendCodecSpec>
ossu20a4b3f2017-04-27 02:08:52 -0700317 send_codec_spec_;
solenberg72e29d22016-03-08 06:35:16 -0800318
Karl Wiberg08126342018-03-20 19:18:55 +0100319 // TODO(kwiberg): Per-SSRC codec pair IDs?
320 const webrtc::AudioCodecPairId codec_pair_id_ =
321 webrtc::AudioCodecPairId::Create();
322
Benjamin Wrightbfb444c2018-10-15 10:20:24 -0700323 // Per peer connection crypto options that last for the lifetime of the peer
324 // connection.
325 const webrtc::CryptoOptions crypto_options_;
Benjamin Wright84583f62018-10-04 14:22:34 -0700326 // Unsignaled streams have an option to have a frame decryptor set on them.
327 rtc::scoped_refptr<webrtc::FrameDecryptorInterface>
328 unsignaled_frame_decryptor_;
329
solenbergc96df772015-10-21 13:01:53 -0700330 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcVoiceMediaChannel);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000331};
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000332} // namespace cricket
333
Steve Anton10542f22019-01-11 09:11:00 -0800334#endif // MEDIA_ENGINE_WEBRTC_VOICE_ENGINE_H_