blob: 213f1b393f9e2ca28e059f05cf11a5e3f6c28e44 [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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MEDIA_ENGINE_WEBRTCVOICEENGINE_H_
12#define MEDIA_ENGINE_WEBRTCVOICEENGINE_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"
20#include "api/rtpreceiverinterface.h"
21#include "call/audio_state.h"
22#include "call/call.h"
23#include "media/base/rtputils.h"
24#include "media/engine/apm_helpers.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020025#include "modules/audio_processing/include/audio_processing.h"
26#include "pc/channel.h"
27#include "rtc_base/buffer.h"
28#include "rtc_base/constructormagic.h"
29#include "rtc_base/networkroute.h"
30#include "rtc_base/scoped_ref_ptr.h"
31#include "rtc_base/task_queue.h"
32#include "rtc_base/thread_checker.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000033
henrike@webrtc.org28e20752013-07-10 00:45:36 +000034namespace cricket {
35
henrike@webrtc.org28e20752013-07-10 00:45:36 +000036class AudioDeviceModule;
gyzhou95aa9642016-12-13 14:06:26 -080037class AudioMixer;
Taylor Brandstetter1a018dc2016-03-08 12:37:39 -080038class AudioSource;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000039class WebRtcVoiceMediaChannel;
40
41// WebRtcVoiceEngine is a class to be used with CompositeMediaEngine.
42// It uses the WebRtc VoiceEngine library for audio handling.
Sebastian Jansson84848f22018-11-16 10:40:36 +010043class WebRtcVoiceEngine final : public VoiceEngineInterface {
Jelena Marusicc28a8962015-05-29 15:05:44 +020044 friend class WebRtcVoiceMediaChannel;
Yves Gerey665174f2018-06-19 15:03:05 +020045
henrike@webrtc.org28e20752013-07-10 00:45:36 +000046 public:
ossu29b1a8d2016-06-13 07:34:51 -070047 WebRtcVoiceEngine(
48 webrtc::AudioDeviceModule* adm,
ossueb1fde42017-05-02 06:46:30 -070049 const rtc::scoped_refptr<webrtc::AudioEncoderFactory>& encoder_factory,
gyzhou95aa9642016-12-13 14:06:26 -080050 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& decoder_factory,
peaha9cc40b2017-06-29 08:32:09 -070051 rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer,
52 rtc::scoped_refptr<webrtc::AudioProcessing> audio_processing);
Sebastian Jansson84848f22018-11-16 10:40:36 +010053 ~WebRtcVoiceEngine() override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000054
deadbeefeb02c032017-06-15 08:29:25 -070055 // Does initialization that needs to occur on the worker thread.
Sebastian Jansson84848f22018-11-16 10:40:36 +010056 void Init() override;
deadbeefeb02c032017-06-15 08:29:25 -070057
Sebastian Jansson84848f22018-11-16 10:40:36 +010058 rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const override;
59 VoiceMediaChannel* CreateMediaChannel(
60 webrtc::Call* call,
61 const MediaConfig& config,
62 const AudioOptions& options,
63 const webrtc::CryptoOptions& crypto_options) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000064
Sebastian Jansson84848f22018-11-16 10:40:36 +010065 const std::vector<AudioCodec>& send_codecs() const override;
66 const std::vector<AudioCodec>& recv_codecs() const override;
67 RtpCapabilities GetCapabilities() const override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000068
henrike@webrtc.org28e20752013-07-10 00:45:36 +000069 // For tracking WebRtc channels. Needed because we have to pause them
70 // all when switching devices.
71 // May only be called by WebRtcVoiceMediaChannel.
solenberg63b34542015-09-29 06:06:31 -070072 void RegisterChannel(WebRtcVoiceMediaChannel* channel);
73 void UnregisterChannel(WebRtcVoiceMediaChannel* channel);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000074
ivocd66b44d2016-01-15 03:06:36 -080075 // Starts AEC dump using an existing file. A maximum file size in bytes can be
76 // specified. When the maximum file size is reached, logging is stopped and
77 // the file is closed. If max_size_bytes is set to <= 0, no limit will be
78 // used.
Sebastian Jansson84848f22018-11-16 10:40:36 +010079 bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) override;
wu@webrtc.orga9890802013-12-13 00:21:03 +000080
ivoc797ef122015-10-22 03:25:41 -070081 // Stops AEC dump.
Sebastian Jansson84848f22018-11-16 10:40:36 +010082 void StopAecDump() override;
ivoc797ef122015-10-22 03:25:41 -070083
peahb1c9d1d2017-07-25 15:45:24 -070084 const webrtc::AudioProcessing::Config GetApmConfigForTest() const {
85 return apm()->GetConfig();
peah8271d042016-11-22 07:24:52 -080086 }
87
henrike@webrtc.org28e20752013-07-10 00:45:36 +000088 private:
solenberg63b34542015-09-29 06:06:31 -070089 // Every option that is "set" will be applied. Every option not "set" will be
90 // ignored. This allows us to selectively turn on and off different options
91 // easily at any time.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000092 bool ApplyOptions(const AudioOptions& options);
xians@webrtc.org3cefbc92014-10-10 09:42:53 +000093
henrike@webrtc.org28e20752013-07-10 00:45:36 +000094 void StartAecDump(const std::string& filename);
solenberg0a617e22015-10-20 15:49:38 -070095 int CreateVoEChannel();
aleloi048cbdd2017-05-29 02:56:27 -070096
deadbeefeb02c032017-06-15 08:29:25 -070097 std::unique_ptr<rtc::TaskQueue> low_priority_worker_queue_;
aleloi048cbdd2017-05-29 02:56:27 -070098
solenberg5b5129a2016-04-08 05:35:48 -070099 webrtc::AudioDeviceModule* adm();
peahb1c9d1d2017-07-25 15:45:24 -0700100 webrtc::AudioProcessing* apm() const;
Fredrik Solenberg2a877972017-12-15 16:42:15 +0100101 webrtc::AudioState* audio_state();
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000102
ossu20a4b3f2017-04-27 02:08:52 -0700103 AudioCodecs CollectCodecs(
104 const std::vector<webrtc::AudioCodecSpec>& specs) const;
ossuc54071d2016-08-17 02:45:41 -0700105
solenberg566ef242015-11-06 15:34:49 -0800106 rtc::ThreadChecker signal_thread_checker_;
107 rtc::ThreadChecker worker_thread_checker_;
108
Fredrik Solenberg2a877972017-12-15 16:42:15 +0100109 // The audio device module.
solenbergff976312016-03-30 23:28:51 -0700110 rtc::scoped_refptr<webrtc::AudioDeviceModule> adm_;
ossu20a4b3f2017-04-27 02:08:52 -0700111 rtc::scoped_refptr<webrtc::AudioEncoderFactory> encoder_factory_;
ossu29b1a8d2016-06-13 07:34:51 -0700112 rtc::scoped_refptr<webrtc::AudioDecoderFactory> decoder_factory_;
deadbeefeb02c032017-06-15 08:29:25 -0700113 rtc::scoped_refptr<webrtc::AudioMixer> audio_mixer_;
Fredrik Solenberg2a877972017-12-15 16:42:15 +0100114 // The audio processing module.
peaha9cc40b2017-06-29 08:32:09 -0700115 rtc::scoped_refptr<webrtc::AudioProcessing> apm_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000116 // The primary instance of WebRtc VoiceEngine.
solenberg566ef242015-11-06 15:34:49 -0800117 rtc::scoped_refptr<webrtc::AudioState> audio_state_;
ossuc54071d2016-08-17 02:45:41 -0700118 std::vector<AudioCodec> send_codecs_;
119 std::vector<AudioCodec> recv_codecs_;
solenberg63b34542015-09-29 06:06:31 -0700120 std::vector<WebRtcVoiceMediaChannel*> channels_;
solenberg246b8172015-12-08 09:50:23 -0800121 bool is_dumping_aec_ = false;
deadbeefeb02c032017-06-15 08:29:25 -0700122 bool initialized_ = false;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000123
solenberg246b8172015-12-08 09:50:23 -0800124 webrtc::AgcConfig default_agc_config_;
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.
133 size_t audio_jitter_buffer_max_packets_ = 50;
134 bool audio_jitter_buffer_fast_accelerate_ = false;
Jakob Ivarsson10403ae2018-11-27 15:45:20 +0100135 int audio_jitter_buffer_min_delay_ms_ = 0;
solenbergc96df772015-10-21 13:01:53 -0700136
solenbergff976312016-03-30 23:28:51 -0700137 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcVoiceEngine);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000138};
139
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000140// WebRtcVoiceMediaChannel is an implementation of VoiceMediaChannel that uses
141// WebRtc Voice Engine.
solenberg566ef242015-11-06 15:34:49 -0800142class WebRtcVoiceMediaChannel final : public VoiceMediaChannel,
143 public webrtc::Transport {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000144 public:
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200145 WebRtcVoiceMediaChannel(WebRtcVoiceEngine* engine,
nisse51542be2016-02-12 02:27:06 -0800146 const MediaConfig& config,
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200147 const AudioOptions& options,
Benjamin Wrightbfb444c2018-10-15 10:20:24 -0700148 const webrtc::CryptoOptions& crypto_options,
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200149 webrtc::Call* call);
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200150 ~WebRtcVoiceMediaChannel() override;
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200151
solenberg66f43392015-09-09 01:36:22 -0700152 const AudioOptions& options() const { return options_; }
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200153
nisse51542be2016-02-12 02:27:06 -0800154 rtc::DiffServCodePoint PreferredDscp() const override;
155
Peter Thatcherc2ee2c82015-08-07 16:05:34 -0700156 bool SetSendParameters(const AudioSendParameters& params) override;
157 bool SetRecvParameters(const AudioRecvParameters& params) override;
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700158 webrtc::RtpParameters GetRtpSendParameters(uint32_t ssrc) const override;
Zach Steinba37b4b2018-01-23 15:02:36 -0800159 webrtc::RTCError SetRtpSendParameters(
160 uint32_t ssrc,
161 const webrtc::RtpParameters& parameters) override;
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700162 webrtc::RtpParameters GetRtpReceiveParameters(uint32_t ssrc) const override;
163 bool SetRtpReceiveParameters(
164 uint32_t ssrc,
165 const webrtc::RtpParameters& parameters) override;
skvlade0d46372016-04-07 22:59:22 -0700166
aleloi84ef6152016-08-04 05:28:21 -0700167 void SetPlayout(bool playout) override;
Taylor Brandstetter1a018dc2016-03-08 12:37:39 -0800168 void SetSend(bool send) override;
Peter Boström0c4e06b2015-10-07 12:23:21 +0200169 bool SetAudioSend(uint32_t ssrc,
170 bool enable,
171 const AudioOptions* options,
Taylor Brandstetter1a018dc2016-03-08 12:37:39 -0800172 AudioSource* source) override;
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200173 bool AddSendStream(const StreamParams& sp) override;
Peter Boström0c4e06b2015-10-07 12:23:21 +0200174 bool RemoveSendStream(uint32_t ssrc) override;
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200175 bool AddRecvStream(const StreamParams& sp) override;
Peter Boström0c4e06b2015-10-07 12:23:21 +0200176 bool RemoveRecvStream(uint32_t ssrc) override;
Benjamin Wright84583f62018-10-04 14:22:34 -0700177
178 // E2EE Frame API
179 // Set a frame decryptor to a particular ssrc that will intercept all
180 // incoming audio payloads and attempt to decrypt them before forwarding the
181 // result.
182 void SetFrameDecryptor(uint32_t ssrc,
183 rtc::scoped_refptr<webrtc::FrameDecryptorInterface>
184 frame_decryptor) override;
185 // Set a frame encryptor to a particular ssrc that will intercept all
186 // outgoing audio payloads frames and attempt to encrypt them and forward the
187 // result to the packetizer.
188 void SetFrameEncryptor(uint32_t ssrc,
189 rtc::scoped_refptr<webrtc::FrameEncryptorInterface>
190 frame_encryptor) override;
191
solenberg2100c0b2017-03-01 11:29:29 -0800192 // SSRC=0 will apply the new volume to current and future unsignaled streams.
solenberg4bac9c52015-10-09 02:32:53 -0700193 bool SetOutputVolume(uint32_t ssrc, double volume) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000194
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200195 bool CanInsertDtmf() override;
solenberg1d63dd02015-12-02 12:35:09 -0800196 bool InsertDtmf(uint32_t ssrc, int event, int duration) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000197
jbaucheec21bd2016-03-20 06:15:43 -0700198 void OnPacketReceived(rtc::CopyOnWriteBuffer* packet,
Niels Möllere6933812018-11-05 13:01:41 +0100199 int64_t packet_time_us) override;
jbaucheec21bd2016-03-20 06:15:43 -0700200 void OnRtcpReceived(rtc::CopyOnWriteBuffer* packet,
Niels Möllere6933812018-11-05 13:01:41 +0100201 int64_t packet_time_us) override;
Honghai Zhangcc411c02016-03-29 17:27:21 -0700202 void OnNetworkRouteChanged(const std::string& transport_name,
Honghai Zhang0e533ef2016-04-19 15:41:36 -0700203 const rtc::NetworkRoute& network_route) override;
skvlad7a43d252016-03-22 15:32:27 -0700204 void OnReadyToSend(bool ready) override;
Fredrik Solenbergaaf8ff22015-05-07 16:05:53 +0200205 bool GetStats(VoiceMediaInfo* info) override;
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200206
solenberg2100c0b2017-03-01 11:29:29 -0800207 // SSRC=0 will set the audio sink on the latest unsignaled stream, future or
208 // current. Only one stream at a time will use the sink.
Tommif888bb52015-12-12 01:37:01 +0100209 void SetRawAudioSink(
210 uint32_t ssrc,
kwiberg686a8ef2016-02-26 03:00:35 -0800211 std::unique_ptr<webrtc::AudioSinkInterface> sink) override;
Tommif888bb52015-12-12 01:37:01 +0100212
zhihuang38ede132017-06-15 12:52:32 -0700213 std::vector<webrtc::RtpSource> GetSources(uint32_t ssrc) const override;
hbos8d609f62017-04-10 07:39:05 -0700214
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200215 // implements Transport interface
stefan1d8a5062015-10-02 03:39:33 -0700216 bool SendRtp(const uint8_t* data,
217 size_t len,
218 const webrtc::PacketOptions& options) override {
jbaucheec21bd2016-03-20 06:15:43 -0700219 rtc::CopyOnWriteBuffer packet(data, len, kMaxRtpPacketLen);
stefanc1aeaf02015-10-15 07:26:07 -0700220 rtc::PacketOptions rtc_options;
221 rtc_options.packet_id = options.packet_id;
Tim Haloun6ca98362018-09-17 17:06:08 -0700222 if (DscpEnabled()) {
223 rtc_options.dscp = PreferredDscp();
224 }
Sebastian Jansson03789972018-10-09 18:27:57 +0200225 rtc_options.info_signaled_after_sent.included_in_feedback =
226 options.included_in_feedback;
227 rtc_options.info_signaled_after_sent.included_in_allocation =
228 options.included_in_allocation;
stefanc1aeaf02015-10-15 07:26:07 -0700229 return VoiceMediaChannel::SendPacket(&packet, rtc_options);
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200230 }
231
pbos2d566682015-09-28 09:59:31 -0700232 bool SendRtcp(const uint8_t* data, size_t len) override {
jbaucheec21bd2016-03-20 06:15:43 -0700233 rtc::CopyOnWriteBuffer packet(data, len, kMaxRtpPacketLen);
Qingsi Wang6e641e62018-04-11 20:14:17 -0700234 rtc::PacketOptions rtc_options;
Tim Haloun6ca98362018-09-17 17:06:08 -0700235 if (DscpEnabled()) {
236 rtc_options.dscp = PreferredDscp();
237 }
Tim Haloun648d28a2018-10-18 16:52:22 -0700238
Qingsi Wang6e641e62018-04-11 20:14:17 -0700239 return VoiceMediaChannel::SendRtcp(&packet, rtc_options);
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200240 }
241
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200242 private:
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200243 bool SetOptions(const AudioOptions& options);
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200244 bool SetRecvCodecs(const std::vector<AudioCodec>& codecs);
solenberg72e29d22016-03-08 06:35:16 -0800245 bool SetSendCodecs(const std::vector<AudioCodec>& codecs);
Taylor Brandstetter1a018dc2016-03-08 12:37:39 -0800246 bool SetLocalSource(uint32_t ssrc, AudioSource* source);
Peter Boström0c4e06b2015-10-07 12:23:21 +0200247 bool MuteStream(uint32_t ssrc, bool mute);
Fredrik Solenbergb071a192015-09-17 16:42:56 +0200248
Fredrik Solenberge444a3d2015-05-07 16:42:08 +0200249 WebRtcVoiceEngine* engine() { return engine_; }
kwiberg37b8b112016-11-03 02:46:53 -0700250 void ChangePlayout(bool playout);
solenberg0a617e22015-10-20 15:49:38 -0700251 int CreateVoEChannel();
solenberg7add0582015-11-20 09:59:34 -0800252 bool DeleteVoEChannel(int channel);
deadbeef80346142016-04-27 14:17:10 -0700253 bool SetMaxSendBitrate(int bps);
solenbergd53a3f92016-04-14 13:56:37 -0700254 void SetupRecording();
solenberg2100c0b2017-03-01 11:29:29 -0800255 // Check if 'ssrc' is an unsignaled stream, and if so mark it as not being
256 // unsignaled anymore (i.e. it is now removed, or signaled), and return true.
257 bool MaybeDeregisterUnsignaledRecvStream(uint32_t ssrc);
Fredrik Solenberg4b60c732015-05-07 14:07:48 +0200258
solenberg566ef242015-11-06 15:34:49 -0800259 rtc::ThreadChecker worker_thread_checker_;
Fredrik Solenberg4b60c732015-05-07 14:07:48 +0200260
solenberg566ef242015-11-06 15:34:49 -0800261 WebRtcVoiceEngine* const engine_ = nullptr;
Taylor Brandstetter0cd086b2016-04-20 16:23:10 -0700262 std::vector<AudioCodec> send_codecs_;
kwiberg1c07c702017-03-27 07:15:49 -0700263
264 // TODO(kwiberg): decoder_map_ and recv_codecs_ store the exact same
265 // information, in slightly different formats. Eliminate recv_codecs_.
266 std::map<int, webrtc::SdpAudioFormat> decoder_map_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000267 std::vector<AudioCodec> recv_codecs_;
kwiberg1c07c702017-03-27 07:15:49 -0700268
deadbeef80346142016-04-27 14:17:10 -0700269 int max_send_bitrate_bps_ = 0;
Tim Haloun648d28a2018-10-18 16:52:22 -0700270 rtc::DiffServCodePoint preferred_dscp_ = rtc::DSCP_DEFAULT;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000271 AudioOptions options_;
Danil Chapovalov00c71832018-06-15 15:58:38 +0200272 absl::optional<int> dtmf_payload_type_;
solenbergffbbcac2016-11-17 05:25:37 -0800273 int dtmf_payload_freq_ = -1;
solenberg72e29d22016-03-08 06:35:16 -0800274 bool recv_transport_cc_enabled_ = false;
solenberg8189b022016-06-14 12:13:00 -0700275 bool recv_nack_enabled_ = false;
solenbergffbbcac2016-11-17 05:25:37 -0800276 bool desired_playout_ = false;
solenberg566ef242015-11-06 15:34:49 -0800277 bool playout_ = false;
Taylor Brandstetter1a018dc2016-03-08 12:37:39 -0800278 bool send_ = false;
solenberg566ef242015-11-06 15:34:49 -0800279 webrtc::Call* const call_ = nullptr;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000280
Jiawei Ou55718122018-11-09 13:17:39 -0800281 const MediaConfig::Audio audio_config_;
282
solenberg2100c0b2017-03-01 11:29:29 -0800283 // Queue of unsignaled SSRCs; oldest at the beginning.
284 std::vector<uint32_t> unsignaled_recv_ssrcs_;
285
Seth Hampson5897a6e2018-04-03 11:16:33 -0700286 // This is a stream param that comes from the remote description, but wasn't
287 // signaled with any a=ssrc lines. It holds the information that was signaled
288 // before the unsignaled receive stream is created when the first packet is
289 // received.
290 StreamParams unsignaled_stream_params_;
291
solenberg2100c0b2017-03-01 11:29:29 -0800292 // Volume for unsignaled streams, which may be set before the stream exists.
solenberg1ac56142015-10-13 03:58:19 -0700293 double default_recv_volume_ = 1.0;
solenberg2100c0b2017-03-01 11:29:29 -0800294 // Sink for latest unsignaled stream - may be set before the stream exists.
kwiberg686a8ef2016-02-26 03:00:35 -0800295 std::unique_ptr<webrtc::AudioSinkInterface> default_sink_;
solenberg8093d542015-11-12 06:02:30 -0800296 // Default SSRC to use for RTCP receiver reports in case of no signaled
solenberg0a617e22015-10-20 15:49:38 -0700297 // send streams. See: https://code.google.com/p/webrtc/issues/detail?id=4740
solenberg8093d542015-11-12 06:02:30 -0800298 // and https://code.google.com/p/chromium/issues/detail?id=547661
299 uint32_t receiver_reports_ssrc_ = 0xFA17FA17u;
solenberg1ac56142015-10-13 03:58:19 -0700300
solenbergc96df772015-10-21 13:01:53 -0700301 class WebRtcAudioSendStream;
302 std::map<uint32_t, WebRtcAudioSendStream*> send_streams_;
solenberg3a941542015-11-16 07:34:50 -0800303 std::vector<webrtc::RtpExtension> send_rtp_extensions_;
Steve Antonbb50ce52018-03-26 10:24:32 -0700304 std::string mid_;
solenbergc96df772015-10-21 13:01:53 -0700305
306 class WebRtcAudioReceiveStream;
solenberg7add0582015-11-20 09:59:34 -0800307 std::map<uint32_t, WebRtcAudioReceiveStream*> recv_streams_;
Fredrik Solenberg4b60c732015-05-07 14:07:48 +0200308 std::vector<webrtc::RtpExtension> recv_rtp_extensions_;
solenbergc96df772015-10-21 13:01:53 -0700309
Danil Chapovalov00c71832018-06-15 15:58:38 +0200310 absl::optional<webrtc::AudioSendStream::Config::SendCodecSpec>
ossu20a4b3f2017-04-27 02:08:52 -0700311 send_codec_spec_;
solenberg72e29d22016-03-08 06:35:16 -0800312
Karl Wiberg08126342018-03-20 19:18:55 +0100313 // TODO(kwiberg): Per-SSRC codec pair IDs?
314 const webrtc::AudioCodecPairId codec_pair_id_ =
315 webrtc::AudioCodecPairId::Create();
316
Benjamin Wrightbfb444c2018-10-15 10:20:24 -0700317 // Per peer connection crypto options that last for the lifetime of the peer
318 // connection.
319 const webrtc::CryptoOptions crypto_options_;
Benjamin Wright84583f62018-10-04 14:22:34 -0700320 // Unsignaled streams have an option to have a frame decryptor set on them.
321 rtc::scoped_refptr<webrtc::FrameDecryptorInterface>
322 unsignaled_frame_decryptor_;
323
solenbergc96df772015-10-21 13:01:53 -0700324 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcVoiceMediaChannel);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000325};
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000326} // namespace cricket
327
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200328#endif // MEDIA_ENGINE_WEBRTCVOICEENGINE_H_