2015-06-08 13:04:56 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef CALL_AUDIO_SEND_STREAM_H_
|
|
|
|
|
#define CALL_AUDIO_SEND_STREAM_H_
|
2015-06-08 13:04:56 +02:00
|
|
|
|
2016-05-01 14:53:46 -07:00
|
|
|
#include <memory>
|
2015-06-08 13:04:56 +02:00
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2018-06-15 12:28:07 +02:00
|
|
|
#include "absl/types/optional.h"
|
2018-03-21 15:18:42 +01:00
|
|
|
#include "api/audio_codecs/audio_codec_pair_id.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/audio_codecs/audio_encoder.h"
|
|
|
|
|
#include "api/audio_codecs/audio_encoder_factory.h"
|
|
|
|
|
#include "api/audio_codecs/audio_format.h"
|
|
|
|
|
#include "api/call/transport.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/crypto/crypto_options.h"
|
|
|
|
|
#include "api/crypto/frame_encryptor_interface.h"
|
2018-10-26 12:57:07 +02:00
|
|
|
#include "api/media_transport_interface.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/rtp_parameters.h"
|
2019-01-25 20:26:48 +01:00
|
|
|
#include "api/scoped_refptr.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "call/rtp_config.h"
|
2017-11-24 17:29:59 +01:00
|
|
|
#include "modules/audio_processing/include/audio_processing_statistics.h"
|
2015-06-08 13:04:56 +02:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
class AudioFrame;
|
|
|
|
|
|
2016-05-01 20:18:34 -07:00
|
|
|
class AudioSendStream {
|
2015-06-08 13:04:56 +02:00
|
|
|
public:
|
2015-10-27 03:35:21 -07:00
|
|
|
struct Stats {
|
2016-10-25 11:19:07 -07:00
|
|
|
Stats();
|
2016-11-17 23:43:29 -08:00
|
|
|
~Stats();
|
2016-10-25 11:19:07 -07:00
|
|
|
|
2015-10-27 03:35:21 -07:00
|
|
|
// TODO(solenberg): Harmonize naming and defaults with receive stream stats.
|
|
|
|
|
uint32_t local_ssrc = 0;
|
|
|
|
|
int64_t bytes_sent = 0;
|
|
|
|
|
int32_t packets_sent = 0;
|
|
|
|
|
int32_t packets_lost = -1;
|
|
|
|
|
float fraction_lost = -1.0f;
|
|
|
|
|
std::string codec_name;
|
2018-06-15 12:28:07 +02:00
|
|
|
absl::optional<int> codec_payload_type;
|
2015-10-27 03:35:21 -07:00
|
|
|
int32_t ext_seqnum = -1;
|
|
|
|
|
int32_t jitter_ms = -1;
|
|
|
|
|
int64_t rtt_ms = -1;
|
|
|
|
|
int32_t audio_level = -1;
|
2017-07-14 12:17:49 -07:00
|
|
|
// See description of "totalAudioEnergy" in the WebRTC stats spec:
|
|
|
|
|
// https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy
|
|
|
|
|
double total_input_energy = 0.0;
|
|
|
|
|
double total_input_duration = 0.0;
|
2015-10-27 03:35:21 -07:00
|
|
|
bool typing_noise_detected = false;
|
2017-11-24 17:29:59 +01:00
|
|
|
|
2017-09-08 08:13:19 -07:00
|
|
|
ANAStats ana_statistics;
|
2017-11-24 17:29:59 +01:00
|
|
|
AudioProcessingStats apm_statistics;
|
2018-10-25 16:22:02 +02:00
|
|
|
|
|
|
|
|
int64_t target_bitrate_bps = 0;
|
2015-10-27 03:35:21 -07:00
|
|
|
};
|
2015-06-08 13:04:56 +02:00
|
|
|
|
|
|
|
|
struct Config {
|
2015-08-28 04:07:10 -07:00
|
|
|
Config() = delete;
|
2018-10-26 12:57:07 +02:00
|
|
|
Config(Transport* send_transport, MediaTransportInterface* media_transport);
|
2016-10-25 11:19:07 -07:00
|
|
|
explicit Config(Transport* send_transport);
|
2016-10-31 04:08:32 -07:00
|
|
|
~Config();
|
2015-06-08 13:04:56 +02:00
|
|
|
std::string ToString() const;
|
|
|
|
|
|
2016-06-14 10:02:41 -07:00
|
|
|
// Send-stream specific RTP settings.
|
2015-06-08 13:04:56 +02:00
|
|
|
struct Rtp {
|
2016-10-25 11:19:07 -07:00
|
|
|
Rtp();
|
|
|
|
|
~Rtp();
|
2015-06-08 13:04:56 +02:00
|
|
|
std::string ToString() const;
|
|
|
|
|
|
|
|
|
|
// Sender SSRC.
|
|
|
|
|
uint32_t ssrc = 0;
|
|
|
|
|
|
2018-12-21 09:23:38 -08:00
|
|
|
// The value to send in the RID RTP header extension if the extension is
|
|
|
|
|
// included in the list of extensions.
|
|
|
|
|
std::string rid;
|
|
|
|
|
|
2018-03-26 10:24:32 -07:00
|
|
|
// The value to send in the MID RTP header extension if the extension is
|
|
|
|
|
// included in the list of extensions.
|
|
|
|
|
std::string mid;
|
|
|
|
|
|
2018-10-29 11:22:05 +01:00
|
|
|
// Corresponds to the SDP attribute extmap-allow-mixed.
|
|
|
|
|
bool extmap_allow_mixed = false;
|
|
|
|
|
|
2015-12-07 10:26:18 +01:00
|
|
|
// RTP header extensions used for the sent stream.
|
2015-06-08 13:04:56 +02:00
|
|
|
std::vector<RtpExtension> extensions;
|
2015-11-16 07:34:50 -08:00
|
|
|
|
|
|
|
|
// RTCP CNAME, see RFC 3550.
|
|
|
|
|
std::string c_name;
|
2015-06-08 13:04:56 +02:00
|
|
|
} rtp;
|
|
|
|
|
|
2018-11-09 13:17:39 -08:00
|
|
|
// Time interval between RTCP report for audio
|
|
|
|
|
int rtcp_report_interval_ms = 5000;
|
|
|
|
|
|
2015-10-16 14:35:07 -07:00
|
|
|
// Transport for outgoing packets. The transport is expected to exist for
|
|
|
|
|
// the entire life of the AudioSendStream and is owned by the API client.
|
2015-09-28 09:59:31 -07:00
|
|
|
Transport* send_transport = nullptr;
|
2015-08-28 04:07:10 -07:00
|
|
|
|
2018-10-26 12:57:07 +02:00
|
|
|
MediaTransportInterface* media_transport = nullptr;
|
|
|
|
|
|
2016-07-26 04:44:06 -07:00
|
|
|
// Bitrate limits used for variable audio bitrate streams. Set both to -1 to
|
|
|
|
|
// disable audio bitrate adaptation.
|
|
|
|
|
// Note: This is still an experimental feature and not ready for real usage.
|
2016-11-07 09:29:22 -08:00
|
|
|
int min_bitrate_bps = -1;
|
|
|
|
|
int max_bitrate_bps = -1;
|
2016-10-20 03:27:12 -07:00
|
|
|
|
2017-12-22 09:36:42 -08:00
|
|
|
double bitrate_priority = 1.0;
|
2018-10-18 16:52:22 -07:00
|
|
|
bool has_dscp = false;
|
2017-12-22 09:36:42 -08:00
|
|
|
|
2016-10-31 04:08:32 -07:00
|
|
|
// Defines whether to turn on audio network adaptor, and defines its config
|
|
|
|
|
// string.
|
2018-06-15 12:28:07 +02:00
|
|
|
absl::optional<std::string> audio_network_adaptor_config;
|
2016-10-31 04:08:32 -07:00
|
|
|
|
2016-10-20 03:27:12 -07:00
|
|
|
struct SendCodecSpec {
|
2017-04-27 02:08:52 -07:00
|
|
|
SendCodecSpec(int payload_type, const SdpAudioFormat& format);
|
|
|
|
|
~SendCodecSpec();
|
2016-10-25 11:19:07 -07:00
|
|
|
std::string ToString() const;
|
|
|
|
|
|
|
|
|
|
bool operator==(const SendCodecSpec& rhs) const;
|
2016-10-20 03:27:12 -07:00
|
|
|
bool operator!=(const SendCodecSpec& rhs) const {
|
|
|
|
|
return !(*this == rhs);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-27 02:08:52 -07:00
|
|
|
int payload_type;
|
|
|
|
|
SdpAudioFormat format;
|
2016-10-20 03:27:12 -07:00
|
|
|
bool nack_enabled = false;
|
|
|
|
|
bool transport_cc_enabled = false;
|
2018-06-15 12:28:07 +02:00
|
|
|
absl::optional<int> cng_payload_type;
|
2017-04-27 02:08:52 -07:00
|
|
|
// If unset, use the encoder's default target bitrate.
|
2018-06-15 12:28:07 +02:00
|
|
|
absl::optional<int> target_bitrate_bps;
|
2017-04-27 02:08:52 -07:00
|
|
|
};
|
|
|
|
|
|
2018-06-15 12:28:07 +02:00
|
|
|
absl::optional<SendCodecSpec> send_codec_spec;
|
2017-04-27 02:08:52 -07:00
|
|
|
rtc::scoped_refptr<AudioEncoderFactory> encoder_factory;
|
2018-06-15 12:28:07 +02:00
|
|
|
absl::optional<AudioCodecPairId> codec_pair_id;
|
2017-10-13 14:56:18 +02:00
|
|
|
|
|
|
|
|
// Track ID as specified during track creation.
|
|
|
|
|
std::string track_id;
|
2018-10-04 14:22:34 -07:00
|
|
|
|
2018-10-15 10:20:24 -07:00
|
|
|
// Per PeerConnection crypto options.
|
|
|
|
|
webrtc::CryptoOptions crypto_options;
|
|
|
|
|
|
2018-10-04 14:22:34 -07:00
|
|
|
// An optional custom frame encryptor that allows the entire frame to be
|
|
|
|
|
// encryptor in whatever way the caller choses. This is not required by
|
|
|
|
|
// default.
|
|
|
|
|
rtc::scoped_refptr<webrtc::FrameEncryptorInterface> frame_encryptor;
|
2015-06-08 13:04:56 +02:00
|
|
|
};
|
|
|
|
|
|
2017-07-26 02:09:44 -07:00
|
|
|
virtual ~AudioSendStream() = default;
|
|
|
|
|
|
|
|
|
|
virtual const webrtc::AudioSendStream::Config& GetConfig() const = 0;
|
|
|
|
|
|
2017-04-27 02:08:52 -07:00
|
|
|
// Reconfigure the stream according to the Configuration.
|
|
|
|
|
virtual void Reconfigure(const Config& config) = 0;
|
|
|
|
|
|
2016-05-01 20:18:34 -07:00
|
|
|
// Starts stream activity.
|
|
|
|
|
// When a stream is active, it can receive, process and deliver packets.
|
|
|
|
|
virtual void Start() = 0;
|
|
|
|
|
// Stops stream activity.
|
|
|
|
|
// When a stream is stopped, it can't receive, process or deliver packets.
|
|
|
|
|
virtual void Stop() = 0;
|
|
|
|
|
|
Remove voe::TransmitMixer
TransmitMixer's functionality is moved into the AudioTransportProxy
owned by AudioState. This removes the need for an AudioTransport
implementation in VoEBaseImpl, which means that the proxy is no longer
a proxy, hence AudioTransportProxy is renamed to AudioTransportImpl.
In the short term, AudioState needs to know which AudioDeviceModule is
used, so it is added in AudioState::Config. AudioTransportImpl needs
to know which AudioSendStream:s are currently enabled to send, so
AudioState maintains a map of them, which is reduced into a simple
vector for AudioTransportImpl.
To encode and transmit audio,
AudioSendStream::OnAudioData(std::unique_ptr<AudioFrame> audio_frame)
is introduced, which is used in both the Chromium and standalone use
cases. This removes the need for two different instances of
voe::Channel::ProcessAndEncodeAudio(), so there is now only one,
taking an AudioFrame as argument. Callers need to allocate their own
AudioFrame:s, which is wasteful but not a regression since this was
already happening in the voe::Channel functions.
Most of the logic changed resides in
AudioTransportImpl::RecordedDataIsAvailable(), where two strange
things were found:
1. The clock drift parameter was ineffective since
apm->echo_cancellation()->enable_drift_compensation(false) is
called during initialization.
2. The output parameter 'new_mic_volume' was never set - instead it
was returned as a result, causing the ADM to never update the
analog mic gain
(https://cs.chromium.org/chromium/src/third_party/webrtc/voice_engine/voe_base_impl.cc?q=voe_base_impl.cc&dr&l=100).
Besides this, tests are updated, and some dead code is removed which
was found in the process.
Bug: webrtc:4690, webrtc:8591
Change-Id: I789d5296bf5efb7299a5ee05a4f3ce6abf9124b2
Reviewed-on: https://webrtc-review.googlesource.com/26681
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21301}
2017-12-15 16:42:15 +01:00
|
|
|
// Encode and send audio.
|
|
|
|
|
virtual void SendAudioData(
|
|
|
|
|
std::unique_ptr<webrtc::AudioFrame> audio_frame) = 0;
|
|
|
|
|
|
2015-12-04 15:22:19 +01:00
|
|
|
// TODO(solenberg): Make payload_type a config property instead.
|
2016-11-17 05:25:37 -08:00
|
|
|
virtual bool SendTelephoneEvent(int payload_type,
|
|
|
|
|
int payload_frequency,
|
|
|
|
|
int event,
|
|
|
|
|
int duration_ms) = 0;
|
2016-06-16 10:53:22 -07:00
|
|
|
|
|
|
|
|
virtual void SetMuted(bool muted) = 0;
|
|
|
|
|
|
2015-06-08 13:04:56 +02:00
|
|
|
virtual Stats GetStats() const = 0;
|
2017-11-24 17:29:59 +01:00
|
|
|
virtual Stats GetStats(bool has_remote_tracks) const = 0;
|
2015-06-08 13:04:56 +02:00
|
|
|
};
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // CALL_AUDIO_SEND_STREAM_H_
|