blob: 1956b97bd42e4ea67bc82cfa7412a16fc63f0157 [file] [log] [blame]
Fredrik Solenberg04f49312015-06-08 13:04:56 +02001/*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
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
kjellandera69d9732016-08-31 07:33:05 -070011#ifndef WEBRTC_API_CALL_AUDIO_SEND_STREAM_H_
12#define WEBRTC_API_CALL_AUDIO_SEND_STREAM_H_
Fredrik Solenberg04f49312015-06-08 13:04:56 +020013
kwibergbfefb032016-05-01 14:53:46 -070014#include <memory>
Fredrik Solenberg04f49312015-06-08 13:04:56 +020015#include <string>
16#include <vector>
17
Fredrik Solenberg04f49312015-06-08 13:04:56 +020018#include "webrtc/config.h"
19#include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
solenberg4fbae2b2015-08-28 04:07:10 -070020#include "webrtc/transport.h"
Fredrik Solenberg04f49312015-06-08 13:04:56 +020021#include "webrtc/typedefs.h"
22
23namespace webrtc {
24
Fredrik Solenberga4527c82015-12-03 13:06:20 +010025// WORK IN PROGRESS
26// This class is under development and is not yet intended for for use outside
27// of WebRtc/Libjingle. Please use the VoiceEngine API instead.
28// See: https://bugs.chromium.org/p/webrtc/issues/detail?id=4690
29
pbos1ba8d392016-05-01 20:18:34 -070030class AudioSendStream {
Fredrik Solenberg04f49312015-06-08 13:04:56 +020031 public:
solenberg85a04962015-10-27 03:35:21 -070032 struct Stats {
33 // TODO(solenberg): Harmonize naming and defaults with receive stream stats.
34 uint32_t local_ssrc = 0;
35 int64_t bytes_sent = 0;
36 int32_t packets_sent = 0;
37 int32_t packets_lost = -1;
38 float fraction_lost = -1.0f;
39 std::string codec_name;
40 int32_t ext_seqnum = -1;
41 int32_t jitter_ms = -1;
42 int64_t rtt_ms = -1;
43 int32_t audio_level = -1;
44 float aec_quality_min = -1.0f;
45 int32_t echo_delay_median_ms = -1;
46 int32_t echo_delay_std_ms = -1;
47 int32_t echo_return_loss = -100;
48 int32_t echo_return_loss_enhancement = -100;
ivoc8c63a822016-10-21 04:10:03 -070049 float residual_echo_likelihood = -1.0f;
solenberg85a04962015-10-27 03:35:21 -070050 bool typing_noise_detected = false;
51 };
Fredrik Solenberg04f49312015-06-08 13:04:56 +020052
53 struct Config {
solenberg4fbae2b2015-08-28 04:07:10 -070054 Config() = delete;
pbos2d566682015-09-28 09:59:31 -070055 explicit Config(Transport* send_transport)
solenberg4fbae2b2015-08-28 04:07:10 -070056 : send_transport(send_transport) {}
57
Fredrik Solenberg04f49312015-06-08 13:04:56 +020058 std::string ToString() const;
59
solenberg971cab02016-06-14 10:02:41 -070060 // Send-stream specific RTP settings.
Fredrik Solenberg04f49312015-06-08 13:04:56 +020061 struct Rtp {
62 std::string ToString() const;
63
64 // Sender SSRC.
65 uint32_t ssrc = 0;
66
Stefan Holmerb86d4e42015-12-07 10:26:18 +010067 // RTP header extensions used for the sent stream.
Fredrik Solenberg04f49312015-06-08 13:04:56 +020068 std::vector<RtpExtension> extensions;
solenberg3a941542015-11-16 07:34:50 -080069
solenberg971cab02016-06-14 10:02:41 -070070 // See NackConfig for description.
71 NackConfig nack;
72
solenberg3a941542015-11-16 07:34:50 -080073 // RTCP CNAME, see RFC 3550.
74 std::string c_name;
Fredrik Solenberg04f49312015-06-08 13:04:56 +020075 } rtp;
76
solenbergc7a8b082015-10-16 14:35:07 -070077 // Transport for outgoing packets. The transport is expected to exist for
78 // the entire life of the AudioSendStream and is owned by the API client.
pbos2d566682015-09-28 09:59:31 -070079 Transport* send_transport = nullptr;
solenberg4fbae2b2015-08-28 04:07:10 -070080
solenbergcf18b342015-10-01 08:13:42 -070081 // Underlying VoiceEngine handle, used to map AudioSendStream to lower-level
82 // components.
83 // TODO(solenberg): Remove when VoiceEngine channels are created outside
84 // of Call.
85 int voe_channel_id = -1;
86
mflodman86cc6ff2016-07-26 04:44:06 -070087 // Bitrate limits used for variable audio bitrate streams. Set both to -1 to
88 // disable audio bitrate adaptation.
89 // Note: This is still an experimental feature and not ready for real usage.
90 int min_bitrate_kbps = -1;
91 int max_bitrate_kbps = -1;
minyue7a973442016-10-20 03:27:12 -070092
93 struct SendCodecSpec {
94 SendCodecSpec() {
95 webrtc::CodecInst empty_inst = {0};
96 codec_inst = empty_inst;
97 codec_inst.pltype = -1;
98 }
99 bool operator==(const SendCodecSpec& rhs) const {
100 {
101 if (nack_enabled != rhs.nack_enabled) {
102 return false;
103 }
104 if (transport_cc_enabled != rhs.transport_cc_enabled) {
105 return false;
106 }
107 if (enable_codec_fec != rhs.enable_codec_fec) {
108 return false;
109 }
110 if (enable_opus_dtx != rhs.enable_opus_dtx) {
111 return false;
112 }
113 if (opus_max_playback_rate != rhs.opus_max_playback_rate) {
114 return false;
115 }
116 if (cng_payload_type != rhs.cng_payload_type) {
117 return false;
118 }
119 if (cng_plfreq != rhs.cng_plfreq) {
120 return false;
121 }
122 if (codec_inst != rhs.codec_inst) {
123 return false;
124 }
125 return true;
126 }
127 }
128 bool operator!=(const SendCodecSpec& rhs) const {
129 return !(*this == rhs);
130 }
131
132 bool nack_enabled = false;
133 bool transport_cc_enabled = false;
134 bool enable_codec_fec = false;
135 bool enable_opus_dtx = false;
136 int opus_max_playback_rate = 0;
137 int cng_payload_type = -1;
138 int cng_plfreq = -1;
139 webrtc::CodecInst codec_inst;
140 } send_codec_spec;
Fredrik Solenberg04f49312015-06-08 13:04:56 +0200141 };
142
pbos1ba8d392016-05-01 20:18:34 -0700143 // Starts stream activity.
144 // When a stream is active, it can receive, process and deliver packets.
145 virtual void Start() = 0;
146 // Stops stream activity.
147 // When a stream is stopped, it can't receive, process or deliver packets.
148 virtual void Stop() = 0;
149
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100150 // TODO(solenberg): Make payload_type a config property instead.
solenberg8842c3e2016-03-11 03:06:41 -0800151 virtual bool SendTelephoneEvent(int payload_type, int event,
152 int duration_ms) = 0;
solenberg94218532016-06-16 10:53:22 -0700153
154 virtual void SetMuted(bool muted) = 0;
155
Fredrik Solenberg04f49312015-06-08 13:04:56 +0200156 virtual Stats GetStats() const = 0;
pbos1ba8d392016-05-01 20:18:34 -0700157
158 protected:
159 virtual ~AudioSendStream() {}
Fredrik Solenberg04f49312015-06-08 13:04:56 +0200160};
161} // namespace webrtc
162
kjellandera69d9732016-08-31 07:33:05 -0700163#endif // WEBRTC_API_CALL_AUDIO_SEND_STREAM_H_