niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
leozwang@webrtc.org | 813e4b0 | 2012-03-01 18:34:25 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 3 | * |
| 4 | * 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. |
| 9 | */ |
| 10 | |
andrew@webrtc.org | 382c0c2 | 2014-05-05 18:22:21 +0000 | [diff] [blame] | 11 | #ifndef WEBRTC_VOICE_ENGINE_CHANNEL_H_ |
| 12 | #define WEBRTC_VOICE_ENGINE_CHANNEL_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
kwiberg | b7f89d6 | 2016-02-17 10:04:18 -0800 | [diff] [blame] | 14 | #include <memory> |
| 15 | |
aleloi | aed581a | 2016-10-20 06:32:39 -0700 | [diff] [blame] | 16 | #include "webrtc/api/audio/audio_mixer.h" |
ossu | eb1fde4 | 2017-05-02 06:46:30 -0700 | [diff] [blame] | 17 | #include "webrtc/api/audio_codecs/audio_encoder.h" |
kjellander | a69d973 | 2016-08-31 07:33:05 -0700 | [diff] [blame] | 18 | #include "webrtc/api/call/audio_sink.h" |
kwiberg | 84f6a3f | 2017-09-05 08:43:13 -0700 | [diff] [blame] | 19 | #include "webrtc/api/optional.h" |
xians@webrtc.org | 2f84afa | 2013-07-31 16:23:37 +0000 | [diff] [blame] | 20 | #include "webrtc/common_audio/resampler/include/push_resampler.h" |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 21 | #include "webrtc/common_types.h" |
kwiberg | c8d071e | 2016-04-06 12:22:38 -0700 | [diff] [blame] | 22 | #include "webrtc/modules/audio_coding/acm2/codec_manager.h" |
| 23 | #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" |
kjellander | 3e6db23 | 2015-11-26 04:44:54 -0800 | [diff] [blame] | 24 | #include "webrtc/modules/audio_coding/include/audio_coding_module.h" |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 25 | #include "webrtc/modules/audio_conference_mixer/include/audio_conference_mixer_defines.h" |
andrew@webrtc.org | 382c0c2 | 2014-05-05 18:22:21 +0000 | [diff] [blame] | 26 | #include "webrtc/modules/audio_processing/rms_level.h" |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 27 | #include "webrtc/modules/rtp_rtcp/include/remote_ntp_time_estimator.h" |
| 28 | #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
hbos | 8d609f6 | 2017-04-10 07:39:05 -0700 | [diff] [blame] | 29 | #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 30 | #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
Edward Lemur | c20978e | 2017-07-06 19:44:34 +0200 | [diff] [blame] | 31 | #include "webrtc/rtc_base/criticalsection.h" |
| 32 | #include "webrtc/rtc_base/event.h" |
Edward Lemur | c20978e | 2017-07-06 19:44:34 +0200 | [diff] [blame] | 33 | #include "webrtc/rtc_base/thread_checker.h" |
henrik.lundin | 92a7a18 | 2017-03-07 01:58:55 -0800 | [diff] [blame] | 34 | #include "webrtc/voice_engine/audio_level.h" |
kwiberg | 9774447 | 2017-01-10 01:12:51 -0800 | [diff] [blame] | 35 | #include "webrtc/voice_engine/file_player.h" |
| 36 | #include "webrtc/voice_engine/file_recorder.h" |
solenberg | 88499ec | 2016-09-07 07:34:41 -0700 | [diff] [blame] | 37 | #include "webrtc/voice_engine/include/voe_base.h" |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 38 | #include "webrtc/voice_engine/include/voe_network.h" |
turaj@webrtc.org | 6388c3e | 2013-02-12 21:42:18 +0000 | [diff] [blame] | 39 | #include "webrtc/voice_engine/shared_data.h" |
| 40 | #include "webrtc/voice_engine/voice_engine_defines.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | |
wu@webrtc.org | 94454b7 | 2014-06-05 20:34:08 +0000 | [diff] [blame] | 42 | namespace rtc { |
wu@webrtc.org | 94454b7 | 2014-06-05 20:34:08 +0000 | [diff] [blame] | 43 | class TimestampWrapAroundHandler; |
| 44 | } |
| 45 | |
andrew@webrtc.org | eb524d9 | 2013-09-23 23:02:24 +0000 | [diff] [blame] | 46 | namespace webrtc { |
| 47 | |
tnakamura@webrtc.org | aa4d96a | 2013-07-16 19:25:04 +0000 | [diff] [blame] | 48 | class AudioDeviceModule; |
tnakamura@webrtc.org | aa4d96a | 2013-07-16 19:25:04 +0000 | [diff] [blame] | 49 | class FileWrapper; |
Stefan Holmer | b86d4e4 | 2015-12-07 10:26:18 +0100 | [diff] [blame] | 50 | class PacketRouter; |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 51 | class ProcessThread; |
Erik Språng | 737336d | 2016-07-29 12:59:36 +0200 | [diff] [blame] | 52 | class RateLimiter; |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 53 | class ReceiveStatistics; |
wu@webrtc.org | 82c4b85 | 2014-05-20 22:55:01 +0000 | [diff] [blame] | 54 | class RemoteNtpTimeEstimator; |
ivoc | b04965c | 2015-09-09 00:09:43 -0700 | [diff] [blame] | 55 | class RtcEventLog; |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 56 | class RTPPayloadRegistry; |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 57 | class RTPReceiverAudio; |
nisse | 657bab2 | 2017-02-21 06:28:10 -0800 | [diff] [blame] | 58 | class RtpPacketReceived; |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 59 | class RtpRtcp; |
nisse | b8f9a32 | 2017-03-27 05:36:15 -0700 | [diff] [blame] | 60 | class RtpTransportControllerSendInterface; |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 61 | class TelephoneEventHandler; |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 62 | class VoERTPObserver; |
| 63 | class VoiceEngineObserver; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 64 | |
| 65 | struct CallStatistics; |
henrika@webrtc.org | 8a2fc88 | 2012-08-22 08:53:55 +0000 | [diff] [blame] | 66 | struct ReportBlock; |
| 67 | struct SenderInfo; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 68 | |
andrew@webrtc.org | eb524d9 | 2013-09-23 23:02:24 +0000 | [diff] [blame] | 69 | namespace voe { |
| 70 | |
mflodman@webrtc.org | 0a7d4ee | 2015-02-17 12:57:14 +0000 | [diff] [blame] | 71 | class OutputMixer; |
ivoc | 14d5dbe | 2016-07-04 07:06:55 -0700 | [diff] [blame] | 72 | class RtcEventLogProxy; |
michaelt | 9332b7d | 2016-11-30 07:51:13 -0800 | [diff] [blame] | 73 | class RtcpRttStatsProxy; |
Stefan Holmer | b86d4e4 | 2015-12-07 10:26:18 +0100 | [diff] [blame] | 74 | class RtpPacketSenderProxy; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 75 | class Statistics; |
Stefan Holmer | b86d4e4 | 2015-12-07 10:26:18 +0100 | [diff] [blame] | 76 | class TransportFeedbackProxy; |
Stefan Holmer | b86d4e4 | 2015-12-07 10:26:18 +0100 | [diff] [blame] | 77 | class TransportSequenceNumberProxy; |
mflodman@webrtc.org | 0a7d4ee | 2015-02-17 12:57:14 +0000 | [diff] [blame] | 78 | class VoERtcpObserver; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 79 | |
henrika@webrtc.org | 944cbeb | 2014-03-18 10:32:33 +0000 | [diff] [blame] | 80 | // Helper class to simplify locking scheme for members that are accessed from |
| 81 | // multiple threads. |
| 82 | // Example: a member can be set on thread T1 and read by an internal audio |
| 83 | // thread T2. Accessing the member via this class ensures that we are |
| 84 | // safe and also avoid TSan v2 warnings. |
| 85 | class ChannelState { |
| 86 | public: |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 87 | struct State { |
solenberg | 11ace15 | 2016-09-15 04:29:13 -0700 | [diff] [blame] | 88 | bool output_file_playing = false; |
| 89 | bool input_file_playing = false; |
| 90 | bool playing = false; |
| 91 | bool sending = false; |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 92 | }; |
henrika@webrtc.org | 944cbeb | 2014-03-18 10:32:33 +0000 | [diff] [blame] | 93 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 94 | ChannelState() {} |
| 95 | virtual ~ChannelState() {} |
henrika@webrtc.org | 944cbeb | 2014-03-18 10:32:33 +0000 | [diff] [blame] | 96 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 97 | void Reset() { |
| 98 | rtc::CritScope lock(&lock_); |
| 99 | state_ = State(); |
| 100 | } |
henrika@webrtc.org | 944cbeb | 2014-03-18 10:32:33 +0000 | [diff] [blame] | 101 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 102 | State Get() const { |
| 103 | rtc::CritScope lock(&lock_); |
| 104 | return state_; |
| 105 | } |
henrika@webrtc.org | 944cbeb | 2014-03-18 10:32:33 +0000 | [diff] [blame] | 106 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 107 | void SetOutputFilePlaying(bool enable) { |
| 108 | rtc::CritScope lock(&lock_); |
| 109 | state_.output_file_playing = enable; |
| 110 | } |
henrika@webrtc.org | 944cbeb | 2014-03-18 10:32:33 +0000 | [diff] [blame] | 111 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 112 | void SetInputFilePlaying(bool enable) { |
| 113 | rtc::CritScope lock(&lock_); |
| 114 | state_.input_file_playing = enable; |
| 115 | } |
henrika@webrtc.org | 944cbeb | 2014-03-18 10:32:33 +0000 | [diff] [blame] | 116 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 117 | void SetPlaying(bool enable) { |
| 118 | rtc::CritScope lock(&lock_); |
| 119 | state_.playing = enable; |
| 120 | } |
henrika@webrtc.org | 944cbeb | 2014-03-18 10:32:33 +0000 | [diff] [blame] | 121 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 122 | void SetSending(bool enable) { |
| 123 | rtc::CritScope lock(&lock_); |
| 124 | state_.sending = enable; |
| 125 | } |
henrika@webrtc.org | 944cbeb | 2014-03-18 10:32:33 +0000 | [diff] [blame] | 126 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 127 | private: |
pbos | d8de115 | 2016-02-01 09:00:51 -0800 | [diff] [blame] | 128 | rtc::CriticalSection lock_; |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 129 | State state_; |
henrika@webrtc.org | 944cbeb | 2014-03-18 10:32:33 +0000 | [diff] [blame] | 130 | }; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 131 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 132 | class Channel |
| 133 | : public RtpData, |
| 134 | public RtpFeedback, |
| 135 | public FileCallback, // receiving notification from file player & |
| 136 | // recorder |
| 137 | public Transport, |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 138 | public AudioPacketizationCallback, // receive encoded packets from the |
| 139 | // ACM |
michaelt | bf65be5 | 2016-12-15 06:24:49 -0800 | [diff] [blame] | 140 | public MixerParticipant, // supplies output mixer with audio frames |
| 141 | public OverheadObserver { |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 142 | public: |
| 143 | friend class VoERtcpObserver; |
mflodman@webrtc.org | 0a7d4ee | 2015-02-17 12:57:14 +0000 | [diff] [blame] | 144 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 145 | enum { KNumSocketThreads = 1 }; |
| 146 | enum { KNumberOfSocketBuffers = 8 }; |
| 147 | virtual ~Channel(); |
henrika | ec6fbd2 | 2017-03-31 05:43:36 -0700 | [diff] [blame] | 148 | static int32_t CreateChannel(Channel*& channel, |
| 149 | int32_t channelId, |
| 150 | uint32_t instanceId, |
| 151 | const VoEBase::ChannelConfig& config); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 152 | Channel(int32_t channelId, |
| 153 | uint32_t instanceId, |
solenberg | 88499ec | 2016-09-07 07:34:41 -0700 | [diff] [blame] | 154 | const VoEBase::ChannelConfig& config); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 155 | int32_t Init(); |
kwiberg | 1c07c70 | 2017-03-27 07:15:49 -0700 | [diff] [blame] | 156 | void RegisterLegacyReceiveCodecs(); |
tommi | 0a2391f | 2017-03-21 02:31:51 -0700 | [diff] [blame] | 157 | void Terminate(); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 158 | int32_t SetEngineInformation(Statistics& engineStatistics, |
| 159 | OutputMixer& outputMixer, |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 160 | ProcessThread& moduleProcessThread, |
| 161 | AudioDeviceModule& audioDeviceModule, |
| 162 | VoiceEngineObserver* voiceEngineObserver, |
henrika | ec6fbd2 | 2017-03-31 05:43:36 -0700 | [diff] [blame] | 163 | rtc::CriticalSection* callbackCritSect, |
| 164 | rtc::TaskQueue* encoder_queue); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 165 | |
kwiberg | b7f89d6 | 2016-02-17 10:04:18 -0800 | [diff] [blame] | 166 | void SetSink(std::unique_ptr<AudioSinkInterface> sink); |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 167 | |
ossu | 29b1a8d | 2016-06-13 07:34:51 -0700 | [diff] [blame] | 168 | // TODO(ossu): Don't use! It's only here to confirm that the decoder factory |
| 169 | // passed into AudioReceiveStream is the same as the one set when creating the |
| 170 | // ADM. Once Channel creation is moved into Audio{Send,Receive}Stream this can |
| 171 | // go. |
| 172 | const rtc::scoped_refptr<AudioDecoderFactory>& GetAudioDecoderFactory() const; |
| 173 | |
kwiberg | 1c07c70 | 2017-03-27 07:15:49 -0700 | [diff] [blame] | 174 | void SetReceiveCodecs(const std::map<int, SdpAudioFormat>& codecs); |
| 175 | |
ossu | 1ffbd6c | 2017-04-06 12:05:04 -0700 | [diff] [blame] | 176 | // Send using this encoder, with this payload type. |
| 177 | bool SetEncoder(int payload_type, std::unique_ptr<AudioEncoder> encoder); |
ossu | 20a4b3f | 2017-04-27 02:08:52 -0700 | [diff] [blame] | 178 | void ModifyEncoder( |
| 179 | rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier); |
ossu | 1ffbd6c | 2017-04-06 12:05:04 -0700 | [diff] [blame] | 180 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 181 | // API methods |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 182 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 183 | // VoEBase |
| 184 | int32_t StartPlayout(); |
| 185 | int32_t StopPlayout(); |
| 186 | int32_t StartSend(); |
henrika | ec6fbd2 | 2017-03-31 05:43:36 -0700 | [diff] [blame] | 187 | void StopSend(); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 188 | int32_t RegisterVoiceEngineObserver(VoiceEngineObserver& observer); |
| 189 | int32_t DeRegisterVoiceEngineObserver(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 190 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 191 | // VoECodec |
| 192 | int32_t GetSendCodec(CodecInst& codec); |
| 193 | int32_t GetRecCodec(CodecInst& codec); |
| 194 | int32_t SetSendCodec(const CodecInst& codec); |
minyue | 78b4d56 | 2016-11-30 04:47:39 -0800 | [diff] [blame] | 195 | void SetBitRate(int bitrate_bps, int64_t probing_interval_ms); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 196 | int32_t SetVADStatus(bool enableVAD, ACMVADMode mode, bool disableDTX); |
| 197 | int32_t GetVADStatus(bool& enabledVAD, ACMVADMode& mode, bool& disabledDTX); |
| 198 | int32_t SetRecPayloadType(const CodecInst& codec); |
kwiberg | d32bf75 | 2017-01-19 07:03:59 -0800 | [diff] [blame] | 199 | int32_t SetRecPayloadType(int payload_type, const SdpAudioFormat& format); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 200 | int32_t GetRecPayloadType(CodecInst& codec); |
| 201 | int32_t SetSendCNPayloadType(int type, PayloadFrequencies frequency); |
| 202 | int SetOpusMaxPlaybackRate(int frequency_hz); |
| 203 | int SetOpusDtx(bool enable_dtx); |
ivoc | 85228d6 | 2016-07-27 04:53:47 -0700 | [diff] [blame] | 204 | int GetOpusDtx(bool* enabled); |
minyue | 7e30432 | 2016-10-12 05:00:55 -0700 | [diff] [blame] | 205 | bool EnableAudioNetworkAdaptor(const std::string& config_string); |
| 206 | void DisableAudioNetworkAdaptor(); |
| 207 | void SetReceiverFrameLengthRange(int min_frame_length_ms, |
| 208 | int max_frame_length_ms); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 209 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 210 | // VoENetwork |
mflodman | 3d7db26 | 2016-04-29 00:57:13 -0700 | [diff] [blame] | 211 | int32_t RegisterExternalTransport(Transport* transport); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 212 | int32_t DeRegisterExternalTransport(); |
mflodman | 3d7db26 | 2016-04-29 00:57:13 -0700 | [diff] [blame] | 213 | int32_t ReceivedRTPPacket(const uint8_t* received_packet, |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 214 | size_t length, |
| 215 | const PacketTime& packet_time); |
nisse | 657bab2 | 2017-02-21 06:28:10 -0800 | [diff] [blame] | 216 | // TODO(nisse, solenberg): Delete when VoENetwork is deleted. |
mflodman | 3d7db26 | 2016-04-29 00:57:13 -0700 | [diff] [blame] | 217 | int32_t ReceivedRTCPPacket(const uint8_t* data, size_t length); |
nisse | 657bab2 | 2017-02-21 06:28:10 -0800 | [diff] [blame] | 218 | void OnRtpPacket(const RtpPacketReceived& packet); |
pwestin@webrtc.org | 684f057 | 2013-03-13 23:20:57 +0000 | [diff] [blame] | 219 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 220 | // VoEFile |
| 221 | int StartPlayingFileLocally(const char* fileName, |
| 222 | bool loop, |
| 223 | FileFormats format, |
| 224 | int startPosition, |
| 225 | float volumeScaling, |
| 226 | int stopPosition, |
| 227 | const CodecInst* codecInst); |
| 228 | int StartPlayingFileLocally(InStream* stream, |
| 229 | FileFormats format, |
| 230 | int startPosition, |
| 231 | float volumeScaling, |
| 232 | int stopPosition, |
| 233 | const CodecInst* codecInst); |
| 234 | int StopPlayingFileLocally(); |
| 235 | int IsPlayingFileLocally() const; |
| 236 | int RegisterFilePlayingToMixer(); |
| 237 | int StartPlayingFileAsMicrophone(const char* fileName, |
| 238 | bool loop, |
| 239 | FileFormats format, |
| 240 | int startPosition, |
| 241 | float volumeScaling, |
| 242 | int stopPosition, |
| 243 | const CodecInst* codecInst); |
| 244 | int StartPlayingFileAsMicrophone(InStream* stream, |
| 245 | FileFormats format, |
| 246 | int startPosition, |
| 247 | float volumeScaling, |
| 248 | int stopPosition, |
| 249 | const CodecInst* codecInst); |
| 250 | int StopPlayingFileAsMicrophone(); |
| 251 | int IsPlayingFileAsMicrophone() const; |
| 252 | int StartRecordingPlayout(const char* fileName, const CodecInst* codecInst); |
| 253 | int StartRecordingPlayout(OutStream* stream, const CodecInst* codecInst); |
| 254 | int StopRecordingPlayout(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 255 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 256 | void SetMixWithMicStatus(bool mix); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 257 | |
solenberg | 8d73f8c | 2017-03-08 01:52:20 -0800 | [diff] [blame] | 258 | // Muting, Volume and Level. |
| 259 | void SetInputMute(bool enable); |
| 260 | void SetChannelOutputVolumeScaling(float scaling); |
| 261 | int GetSpeechOutputLevel() const; |
| 262 | int GetSpeechOutputLevelFullRange() const; |
zstein | e76bd3a | 2017-07-14 12:17:49 -0700 | [diff] [blame] | 263 | // See description of "totalAudioEnergy" in the WebRTC stats spec: |
| 264 | // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy |
| 265 | double GetTotalOutputEnergy() const; |
| 266 | double GetTotalOutputDuration() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 267 | |
solenberg | c6192a9 | 2017-03-13 02:36:19 -0700 | [diff] [blame] | 268 | // Stats. |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 269 | int GetNetworkStatistics(NetworkStatistics& stats); |
| 270 | void GetDecodingCallStatistics(AudioDecodingCallStats* stats) const; |
ivoc | e1198e0 | 2017-09-08 08:13:19 -0700 | [diff] [blame^] | 271 | ANAStats GetANAStatistics() const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 272 | |
solenberg | c6192a9 | 2017-03-13 02:36:19 -0700 | [diff] [blame] | 273 | // Audio+Video Sync. |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 274 | uint32_t GetDelayEstimate() const; |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 275 | int SetMinimumPlayoutDelay(int delayMs); |
| 276 | int GetPlayoutTimestamp(unsigned int& timestamp); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 277 | int GetRtpRtcp(RtpRtcp** rtpRtcpModule, RtpReceiver** rtp_receiver) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 278 | |
solenberg | c6192a9 | 2017-03-13 02:36:19 -0700 | [diff] [blame] | 279 | // DTMF. |
solenberg | 8842c3e | 2016-03-11 03:06:41 -0800 | [diff] [blame] | 280 | int SendTelephoneEventOutband(int event, int duration_ms); |
solenberg | ffbbcac | 2016-11-17 05:25:37 -0800 | [diff] [blame] | 281 | int SetSendTelephoneEventPayloadType(int payload_type, int payload_frequency); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 282 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 283 | // VoERTP_RTCP |
| 284 | int SetLocalSSRC(unsigned int ssrc); |
| 285 | int GetLocalSSRC(unsigned int& ssrc); |
| 286 | int GetRemoteSSRC(unsigned int& ssrc); |
| 287 | int SetSendAudioLevelIndicationStatus(bool enable, unsigned char id); |
| 288 | int SetReceiveAudioLevelIndicationStatus(bool enable, unsigned char id); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 289 | void EnableSendTransportSequenceNumber(int id); |
| 290 | void EnableReceiveTransportSequenceNumber(int id); |
Stefan Holmer | b86d4e4 | 2015-12-07 10:26:18 +0100 | [diff] [blame] | 291 | |
stefan | 7de8d64 | 2017-02-07 07:14:08 -0800 | [diff] [blame] | 292 | void RegisterSenderCongestionControlObjects( |
nisse | b8f9a32 | 2017-03-27 05:36:15 -0700 | [diff] [blame] | 293 | RtpTransportControllerSendInterface* transport, |
stefan | 7de8d64 | 2017-02-07 07:14:08 -0800 | [diff] [blame] | 294 | RtcpBandwidthObserver* bandwidth_observer); |
| 295 | void RegisterReceiverCongestionControlObjects(PacketRouter* packet_router); |
nisse | fdbfdc9 | 2017-03-31 05:44:52 -0700 | [diff] [blame] | 296 | void ResetSenderCongestionControlObjects(); |
| 297 | void ResetReceiverCongestionControlObjects(); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 298 | void SetRTCPStatus(bool enable); |
| 299 | int GetRTCPStatus(bool& enabled); |
| 300 | int SetRTCP_CNAME(const char cName[256]); |
| 301 | int GetRemoteRTCP_CNAME(char cName[256]); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 302 | int SendApplicationDefinedRTCPPacket(unsigned char subType, |
| 303 | unsigned int name, |
| 304 | const char* data, |
| 305 | unsigned short dataLengthInBytes); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 306 | int GetRemoteRTCPReportBlocks(std::vector<ReportBlock>* report_blocks); |
| 307 | int GetRTPStatistics(CallStatistics& stats); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 308 | int SetCodecFECStatus(bool enable); |
| 309 | bool GetCodecFECStatus(); |
| 310 | void SetNACKStatus(bool enable, int maxNumberOfPackets); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 311 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 312 | // From AudioPacketizationCallback in the ACM |
| 313 | int32_t SendData(FrameType frameType, |
| 314 | uint8_t payloadType, |
| 315 | uint32_t timeStamp, |
| 316 | const uint8_t* payloadData, |
| 317 | size_t payloadSize, |
| 318 | const RTPFragmentationHeader* fragmentation) override; |
xians@webrtc.org | 3cefbc9 | 2014-10-10 09:42:53 +0000 | [diff] [blame] | 319 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 320 | // From RtpData in the RTP/RTCP module |
| 321 | int32_t OnReceivedPayloadData(const uint8_t* payloadData, |
| 322 | size_t payloadSize, |
| 323 | const WebRtcRTPHeader* rtpHeader) override; |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 324 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 325 | // From RtpFeedback in the RTP/RTCP module |
| 326 | int32_t OnInitializeDecoder(int8_t payloadType, |
| 327 | const char payloadName[RTP_PAYLOAD_NAME_SIZE], |
| 328 | int frequency, |
| 329 | size_t channels, |
| 330 | uint32_t rate) override; |
| 331 | void OnIncomingSSRCChanged(uint32_t ssrc) override; |
| 332 | void OnIncomingCSRCChanged(uint32_t CSRC, bool added) override; |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 333 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 334 | // From Transport (called by the RTP/RTCP module) |
| 335 | bool SendRtp(const uint8_t* data, |
| 336 | size_t len, |
| 337 | const PacketOptions& packet_options) override; |
| 338 | bool SendRtcp(const uint8_t* data, size_t len) override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 339 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 340 | // From MixerParticipant |
henrik.lundin | 42dda50 | 2016-05-18 05:36:01 -0700 | [diff] [blame] | 341 | MixerParticipant::AudioFrameInfo GetAudioFrameWithMuted( |
| 342 | int32_t id, |
| 343 | AudioFrame* audioFrame) override; |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 344 | int32_t NeededFrequency(int32_t id) const override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 345 | |
aleloi | aed581a | 2016-10-20 06:32:39 -0700 | [diff] [blame] | 346 | // From AudioMixer::Source. |
aleloi | 6c27849 | 2016-10-20 14:24:39 -0700 | [diff] [blame] | 347 | AudioMixer::Source::AudioFrameInfo GetAudioFrameWithInfo( |
| 348 | int sample_rate_hz, |
| 349 | AudioFrame* audio_frame); |
aleloi | aed581a | 2016-10-20 06:32:39 -0700 | [diff] [blame] | 350 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 351 | // From FileCallback |
| 352 | void PlayNotification(int32_t id, uint32_t durationMs) override; |
| 353 | void RecordNotification(int32_t id, uint32_t durationMs) override; |
| 354 | void PlayFileEnded(int32_t id) override; |
| 355 | void RecordFileEnded(int32_t id) override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 356 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 357 | uint32_t InstanceId() const { return _instanceId; } |
| 358 | int32_t ChannelId() const { return _channelId; } |
| 359 | bool Playing() const { return channel_state_.Get().playing; } |
| 360 | bool Sending() const { return channel_state_.Get().sending; } |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 361 | bool ExternalTransport() const { |
| 362 | rtc::CritScope cs(&_callbackCritSect); |
| 363 | return _externalTransport; |
| 364 | } |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 365 | RtpRtcp* RtpRtcpModulePtr() const { return _rtpRtcpModule.get(); } |
| 366 | int8_t OutputEnergyLevel() const { return _outputAudioLevel.Level(); } |
henrika | ec6fbd2 | 2017-03-31 05:43:36 -0700 | [diff] [blame] | 367 | |
| 368 | // ProcessAndEncodeAudio() creates an audio frame copy and posts a task |
| 369 | // on the shared encoder task queue, wich in turn calls (on the queue) |
| 370 | // ProcessAndEncodeAudioOnTaskQueue() where the actual processing of the |
| 371 | // audio takes place. The processing mainly consists of encoding and preparing |
| 372 | // the result for sending by adding it to a send queue. |
| 373 | // The main reason for using a task queue here is to release the native, |
| 374 | // OS-specific, audio capture thread as soon as possible to ensure that it |
| 375 | // can go back to sleep and be prepared to deliver an new captured audio |
| 376 | // packet. |
| 377 | void ProcessAndEncodeAudio(const AudioFrame& audio_input); |
| 378 | |
| 379 | // This version of ProcessAndEncodeAudio() is used by PushCaptureData() in |
| 380 | // VoEBase and the audio in |audio_data| has not been subject to any APM |
| 381 | // processing. Some extra steps are therfore needed when building up the |
| 382 | // audio frame copy before using the same task as in the default call to |
| 383 | // ProcessAndEncodeAudio(const AudioFrame& audio_input). |
| 384 | void ProcessAndEncodeAudio(const int16_t* audio_data, |
| 385 | int sample_rate, |
| 386 | size_t number_of_frames, |
| 387 | size_t number_of_channels); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 388 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 389 | // Associate to a send channel. |
| 390 | // Used for obtaining RTT for a receive-only channel. |
solenberg | 7602aab | 2016-11-14 11:30:07 -0800 | [diff] [blame] | 391 | void set_associate_send_channel(const ChannelOwner& channel); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 392 | // Disassociate a send channel if it was associated. |
| 393 | void DisassociateSendChannel(int channel_id); |
Minyue | 2013aec | 2015-05-13 14:14:42 +0200 | [diff] [blame] | 394 | |
ivoc | 14d5dbe | 2016-07-04 07:06:55 -0700 | [diff] [blame] | 395 | // Set a RtcEventLog logging object. |
| 396 | void SetRtcEventLog(RtcEventLog* event_log); |
| 397 | |
michaelt | 9332b7d | 2016-11-30 07:51:13 -0800 | [diff] [blame] | 398 | void SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats); |
nisse | 284542b | 2017-01-10 08:58:32 -0800 | [diff] [blame] | 399 | void SetTransportOverhead(size_t transport_overhead_per_packet); |
michaelt | 79e0588 | 2016-11-08 02:50:09 -0800 | [diff] [blame] | 400 | |
michaelt | bf65be5 | 2016-12-15 06:24:49 -0800 | [diff] [blame] | 401 | // From OverheadObserver in the RTP/RTCP module |
| 402 | void OnOverheadChanged(size_t overhead_bytes_per_packet) override; |
| 403 | |
elad.alon | d12a8e1 | 2017-03-23 11:04:48 -0700 | [diff] [blame] | 404 | // The existence of this function alongside OnUplinkPacketLossRate is |
| 405 | // a compromise. We want the encoder to be agnostic of the PLR source, but |
| 406 | // we also don't want it to receive conflicting information from TWCC and |
| 407 | // from RTCP-XR. |
| 408 | void OnTwccBasedUplinkPacketLossRate(float packet_loss_rate); |
minyue@webrtc.org | c1a40a7 | 2014-05-28 09:52:06 +0000 | [diff] [blame] | 409 | |
elad.alon | dadb4dc | 2017-03-23 15:29:50 -0700 | [diff] [blame] | 410 | void OnRecoverableUplinkPacketLossRate(float recoverable_packet_loss_rate); |
| 411 | |
hbos | 8d609f6 | 2017-04-10 07:39:05 -0700 | [diff] [blame] | 412 | std::vector<RtpSource> GetSources() const { |
| 413 | return rtp_receiver_->GetSources(); |
| 414 | } |
| 415 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 416 | private: |
henrika | ec6fbd2 | 2017-03-31 05:43:36 -0700 | [diff] [blame] | 417 | class ProcessAndEncodeAudioTask; |
elad.alon | d12a8e1 | 2017-03-23 11:04:48 -0700 | [diff] [blame] | 418 | |
henrika | ec6fbd2 | 2017-03-31 05:43:36 -0700 | [diff] [blame] | 419 | void OnUplinkPacketLossRate(float packet_loss_rate); |
solenberg | 8d73f8c | 2017-03-08 01:52:20 -0800 | [diff] [blame] | 420 | bool InputMute() const; |
nisse | 657bab2 | 2017-02-21 06:28:10 -0800 | [diff] [blame] | 421 | bool OnRtpPacketWithHeader(const uint8_t* received_packet, |
| 422 | size_t length, |
| 423 | RTPHeader *header); |
nisse | 30e8931 | 2017-05-29 08:16:37 -0700 | [diff] [blame] | 424 | bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length); |
| 425 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 426 | bool ReceivePacket(const uint8_t* packet, |
| 427 | size_t packet_length, |
| 428 | const RTPHeader& header, |
| 429 | bool in_order); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 430 | bool IsPacketInOrder(const RTPHeader& header) const; |
| 431 | bool IsPacketRetransmitted(const RTPHeader& header, bool in_order) const; |
| 432 | int ResendPackets(const uint16_t* sequence_numbers, int length); |
henrika | ec6fbd2 | 2017-03-31 05:43:36 -0700 | [diff] [blame] | 433 | int32_t MixOrReplaceAudioWithFile(AudioFrame* audio_frame); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 434 | int32_t MixAudioWithFile(AudioFrame& audioFrame, int mixingFrequency); |
| 435 | void UpdatePlayoutTimestamp(bool rtcp); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 436 | void RegisterReceiveCodecsToRTPModule(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 437 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 438 | int SetSendRtpHeaderExtension(bool enable, |
| 439 | RTPExtensionType type, |
| 440 | unsigned char id); |
andrew@webrtc.org | eb524d9 | 2013-09-23 23:02:24 +0000 | [diff] [blame] | 441 | |
hbos | 3fd31fe | 2017-02-28 05:43:16 -0800 | [diff] [blame] | 442 | void UpdateOverheadForEncoder() |
| 443 | EXCLUSIVE_LOCKS_REQUIRED(overhead_per_packet_lock_); |
nisse | 284542b | 2017-01-10 08:58:32 -0800 | [diff] [blame] | 444 | |
ossu | e280cde | 2016-10-12 11:04:10 -0700 | [diff] [blame] | 445 | int GetRtpTimestampRateHz() const; |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 446 | int64_t GetRTT(bool allow_associate_channel) const; |
wu@webrtc.org | 94454b7 | 2014-06-05 20:34:08 +0000 | [diff] [blame] | 447 | |
henrika | ec6fbd2 | 2017-03-31 05:43:36 -0700 | [diff] [blame] | 448 | // Called on the encoder task queue when a new input audio frame is ready |
| 449 | // for encoding. |
| 450 | void ProcessAndEncodeAudioOnTaskQueue(AudioFrame* audio_input); |
| 451 | |
| 452 | uint32_t _instanceId; |
| 453 | int32_t _channelId; |
| 454 | |
pbos | d8de115 | 2016-02-01 09:00:51 -0800 | [diff] [blame] | 455 | rtc::CriticalSection _fileCritSect; |
| 456 | rtc::CriticalSection _callbackCritSect; |
| 457 | rtc::CriticalSection volume_settings_critsect_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 458 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 459 | ChannelState channel_state_; |
henrika@webrtc.org | 944cbeb | 2014-03-18 10:32:33 +0000 | [diff] [blame] | 460 | |
ivoc | 14d5dbe | 2016-07-04 07:06:55 -0700 | [diff] [blame] | 461 | std::unique_ptr<voe::RtcEventLogProxy> event_log_proxy_; |
michaelt | 9332b7d | 2016-11-30 07:51:13 -0800 | [diff] [blame] | 462 | std::unique_ptr<voe::RtcpRttStatsProxy> rtcp_rtt_stats_proxy_; |
Ivo Creusen | ae856f2 | 2015-09-17 16:30:16 +0200 | [diff] [blame] | 463 | |
kwiberg | b7f89d6 | 2016-02-17 10:04:18 -0800 | [diff] [blame] | 464 | std::unique_ptr<RtpHeaderParser> rtp_header_parser_; |
| 465 | std::unique_ptr<RTPPayloadRegistry> rtp_payload_registry_; |
| 466 | std::unique_ptr<ReceiveStatistics> rtp_receive_statistics_; |
kwiberg | b7f89d6 | 2016-02-17 10:04:18 -0800 | [diff] [blame] | 467 | std::unique_ptr<RtpReceiver> rtp_receiver_; |
danilchap | 799a9d0 | 2016-09-22 03:36:27 -0700 | [diff] [blame] | 468 | TelephoneEventHandler* telephone_event_handler_; |
kwiberg | b7f89d6 | 2016-02-17 10:04:18 -0800 | [diff] [blame] | 469 | std::unique_ptr<RtpRtcp> _rtpRtcpModule; |
| 470 | std::unique_ptr<AudioCodingModule> audio_coding_; |
kwiberg | c8d071e | 2016-04-06 12:22:38 -0700 | [diff] [blame] | 471 | acm2::CodecManager codec_manager_; |
| 472 | acm2::RentACodec rent_a_codec_; |
kwiberg | b7f89d6 | 2016-02-17 10:04:18 -0800 | [diff] [blame] | 473 | std::unique_ptr<AudioSinkInterface> audio_sink_; |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 474 | AudioLevel _outputAudioLevel; |
| 475 | bool _externalTransport; |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 476 | // Downsamples to the codec rate if necessary. |
| 477 | PushResampler<int16_t> input_resampler_; |
kwiberg | 5a25d95 | 2016-08-17 07:31:12 -0700 | [diff] [blame] | 478 | std::unique_ptr<FilePlayer> input_file_player_; |
| 479 | std::unique_ptr<FilePlayer> output_file_player_; |
| 480 | std::unique_ptr<FileRecorder> output_file_recorder_; |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 481 | int _inputFilePlayerId; |
| 482 | int _outputFilePlayerId; |
| 483 | int _outputFileRecorderId; |
| 484 | bool _outputFileRecording; |
henrika | ec6fbd2 | 2017-03-31 05:43:36 -0700 | [diff] [blame] | 485 | uint32_t _timeStamp ACCESS_ON(encoder_queue_); |
turaj@webrtc.org | 167b6df | 2013-12-13 21:05:07 +0000 | [diff] [blame] | 486 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 487 | RemoteNtpTimeEstimator ntp_estimator_ GUARDED_BY(ts_stats_lock_); |
wu@webrtc.org | 82c4b85 | 2014-05-20 22:55:01 +0000 | [diff] [blame] | 488 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 489 | // Timestamp of the audio pulled from NetEq. |
henrik.lundin | 96bd502 | 2016-04-06 04:13:56 -0700 | [diff] [blame] | 490 | rtc::Optional<uint32_t> jitter_buffer_playout_timestamp_; |
solenberg | fe7dd6d | 2017-03-11 08:10:43 -0800 | [diff] [blame] | 491 | |
| 492 | rtc::CriticalSection video_sync_lock_; |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 493 | uint32_t playout_timestamp_rtp_ GUARDED_BY(video_sync_lock_); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 494 | uint32_t playout_delay_ms_ GUARDED_BY(video_sync_lock_); |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 495 | uint16_t send_sequence_number_; |
pwestin@webrtc.org | 1de0135 | 2013-04-11 20:23:35 +0000 | [diff] [blame] | 496 | |
pbos | d8de115 | 2016-02-01 09:00:51 -0800 | [diff] [blame] | 497 | rtc::CriticalSection ts_stats_lock_; |
wu@webrtc.org | cb711f7 | 2014-05-19 17:39:11 +0000 | [diff] [blame] | 498 | |
kwiberg | b7f89d6 | 2016-02-17 10:04:18 -0800 | [diff] [blame] | 499 | std::unique_ptr<rtc::TimestampWrapAroundHandler> rtp_ts_wraparound_handler_; |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 500 | // The rtp timestamp of the first played out audio frame. |
| 501 | int64_t capture_start_rtp_time_stamp_; |
| 502 | // The capture ntp time (in local timebase) of the first played out audio |
| 503 | // frame. |
| 504 | int64_t capture_start_ntp_time_ms_ GUARDED_BY(ts_stats_lock_); |
wu@webrtc.org | cb711f7 | 2014-05-19 17:39:11 +0000 | [diff] [blame] | 505 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 506 | // uses |
| 507 | Statistics* _engineStatisticsPtr; |
| 508 | OutputMixer* _outputMixerPtr; |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 509 | ProcessThread* _moduleProcessThreadPtr; |
| 510 | AudioDeviceModule* _audioDeviceModulePtr; |
| 511 | VoiceEngineObserver* _voiceEngineObserverPtr; // owned by base |
| 512 | rtc::CriticalSection* _callbackCritSectPtr; // owned by base |
| 513 | Transport* _transportPtr; // WebRtc socket or external transport |
henrika | ec6fbd2 | 2017-03-31 05:43:36 -0700 | [diff] [blame] | 514 | RmsLevel rms_level_ ACCESS_ON(encoder_queue_); |
solenberg | 1c2af8e | 2016-03-24 10:36:00 -0700 | [diff] [blame] | 515 | bool input_mute_ GUARDED_BY(volume_settings_critsect_); |
henrika | ec6fbd2 | 2017-03-31 05:43:36 -0700 | [diff] [blame] | 516 | bool previous_frame_muted_ ACCESS_ON(encoder_queue_); |
solenberg | 1c2af8e | 2016-03-24 10:36:00 -0700 | [diff] [blame] | 517 | float _outputGain GUARDED_BY(volume_settings_critsect_); |
solenberg | 8d73f8c | 2017-03-08 01:52:20 -0800 | [diff] [blame] | 518 | // VoEBase |
| 519 | bool _mixFileWithMicrophone; |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 520 | // VoeRTP_RTCP |
henrika | ec6fbd2 | 2017-03-31 05:43:36 -0700 | [diff] [blame] | 521 | // TODO(henrika): can today be accessed on the main thread and on the |
| 522 | // task queue; hence potential race. |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 523 | bool _includeAudioLevelIndication; |
hbos | 3fd31fe | 2017-02-28 05:43:16 -0800 | [diff] [blame] | 524 | size_t transport_overhead_per_packet_ GUARDED_BY(overhead_per_packet_lock_); |
| 525 | size_t rtp_overhead_per_packet_ GUARDED_BY(overhead_per_packet_lock_); |
| 526 | rtc::CriticalSection overhead_per_packet_lock_; |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 527 | // VoENetwork |
| 528 | AudioFrame::SpeechType _outputSpeechType; |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 529 | // RtcpBandwidthObserver |
kwiberg | b7f89d6 | 2016-02-17 10:04:18 -0800 | [diff] [blame] | 530 | std::unique_ptr<VoERtcpObserver> rtcp_observer_; |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 531 | // An associated send channel. |
pbos | d8de115 | 2016-02-01 09:00:51 -0800 | [diff] [blame] | 532 | rtc::CriticalSection assoc_send_channel_lock_; |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 533 | ChannelOwner associate_send_channel_ GUARDED_BY(assoc_send_channel_lock_); |
Stefan Holmer | b86d4e4 | 2015-12-07 10:26:18 +0100 | [diff] [blame] | 534 | |
kwiberg | 55b97fe | 2016-01-28 05:22:45 -0800 | [diff] [blame] | 535 | bool pacing_enabled_; |
| 536 | PacketRouter* packet_router_ = nullptr; |
kwiberg | b7f89d6 | 2016-02-17 10:04:18 -0800 | [diff] [blame] | 537 | std::unique_ptr<TransportFeedbackProxy> feedback_observer_proxy_; |
| 538 | std::unique_ptr<TransportSequenceNumberProxy> seq_num_allocator_proxy_; |
| 539 | std::unique_ptr<RtpPacketSenderProxy> rtp_packet_sender_proxy_; |
Erik Språng | 737336d | 2016-07-29 12:59:36 +0200 | [diff] [blame] | 540 | std::unique_ptr<RateLimiter> retransmission_rate_limiter_; |
ossu | 29b1a8d | 2016-06-13 07:34:51 -0700 | [diff] [blame] | 541 | |
| 542 | // TODO(ossu): Remove once GetAudioDecoderFactory() is no longer needed. |
| 543 | rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_; |
tommi | 0a2391f | 2017-03-21 02:31:51 -0700 | [diff] [blame] | 544 | |
ossu | 76d29f9 | 2017-06-09 07:30:13 -0700 | [diff] [blame] | 545 | rtc::Optional<CodecInst> cached_send_codec_; |
| 546 | |
tommi | 0a2391f | 2017-03-21 02:31:51 -0700 | [diff] [blame] | 547 | rtc::ThreadChecker construction_thread_; |
elad.alon | d12a8e1 | 2017-03-23 11:04:48 -0700 | [diff] [blame] | 548 | |
| 549 | const bool use_twcc_plr_for_ana_; |
henrika | ec6fbd2 | 2017-03-31 05:43:36 -0700 | [diff] [blame] | 550 | |
henrika | 4515fa0 | 2017-05-03 08:30:15 -0700 | [diff] [blame] | 551 | rtc::CriticalSection encoder_queue_lock_; |
| 552 | |
| 553 | bool encoder_queue_is_active_ GUARDED_BY(encoder_queue_lock_) = false; |
| 554 | |
henrika | ec6fbd2 | 2017-03-31 05:43:36 -0700 | [diff] [blame] | 555 | rtc::TaskQueue* encoder_queue_ = nullptr; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 556 | }; |
| 557 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 558 | } // namespace voe |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 +0000 | [diff] [blame] | 559 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 560 | |
andrew@webrtc.org | 382c0c2 | 2014-05-05 18:22:21 +0000 | [diff] [blame] | 561 | #endif // WEBRTC_VOICE_ENGINE_CHANNEL_H_ |