blob: 78ab8ec52e6ea32ab7e8f590a16fa67fb5477c94 [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 {
solenberg940b6d62016-10-25 11:19:07 -070033 Stats();
34
solenberg85a04962015-10-27 03:35:21 -070035 // TODO(solenberg): Harmonize naming and defaults with receive stream stats.
36 uint32_t local_ssrc = 0;
37 int64_t bytes_sent = 0;
38 int32_t packets_sent = 0;
39 int32_t packets_lost = -1;
40 float fraction_lost = -1.0f;
41 std::string codec_name;
42 int32_t ext_seqnum = -1;
43 int32_t jitter_ms = -1;
44 int64_t rtt_ms = -1;
45 int32_t audio_level = -1;
46 float aec_quality_min = -1.0f;
47 int32_t echo_delay_median_ms = -1;
48 int32_t echo_delay_std_ms = -1;
49 int32_t echo_return_loss = -100;
50 int32_t echo_return_loss_enhancement = -100;
ivoc8c63a822016-10-21 04:10:03 -070051 float residual_echo_likelihood = -1.0f;
solenberg85a04962015-10-27 03:35:21 -070052 bool typing_noise_detected = false;
53 };
Fredrik Solenberg04f49312015-06-08 13:04:56 +020054
55 struct Config {
solenberg4fbae2b2015-08-28 04:07:10 -070056 Config() = delete;
solenberg940b6d62016-10-25 11:19:07 -070057 explicit Config(Transport* send_transport);
minyue6b825df2016-10-31 04:08:32 -070058 ~Config();
Fredrik Solenberg04f49312015-06-08 13:04:56 +020059 std::string ToString() const;
60
solenberg971cab02016-06-14 10:02:41 -070061 // Send-stream specific RTP settings.
Fredrik Solenberg04f49312015-06-08 13:04:56 +020062 struct Rtp {
solenberg940b6d62016-10-25 11:19:07 -070063 Rtp();
64 ~Rtp();
Fredrik Solenberg04f49312015-06-08 13:04:56 +020065 std::string ToString() const;
66
67 // Sender SSRC.
68 uint32_t ssrc = 0;
69
Stefan Holmerb86d4e42015-12-07 10:26:18 +010070 // RTP header extensions used for the sent stream.
Fredrik Solenberg04f49312015-06-08 13:04:56 +020071 std::vector<RtpExtension> extensions;
solenberg3a941542015-11-16 07:34:50 -080072
solenberg971cab02016-06-14 10:02:41 -070073 // See NackConfig for description.
74 NackConfig nack;
75
solenberg3a941542015-11-16 07:34:50 -080076 // RTCP CNAME, see RFC 3550.
77 std::string c_name;
Fredrik Solenberg04f49312015-06-08 13:04:56 +020078 } rtp;
79
solenbergc7a8b082015-10-16 14:35:07 -070080 // Transport for outgoing packets. The transport is expected to exist for
81 // the entire life of the AudioSendStream and is owned by the API client.
pbos2d566682015-09-28 09:59:31 -070082 Transport* send_transport = nullptr;
solenberg4fbae2b2015-08-28 04:07:10 -070083
solenbergcf18b342015-10-01 08:13:42 -070084 // Underlying VoiceEngine handle, used to map AudioSendStream to lower-level
85 // components.
86 // TODO(solenberg): Remove when VoiceEngine channels are created outside
87 // of Call.
88 int voe_channel_id = -1;
89
mflodman86cc6ff2016-07-26 04:44:06 -070090 // Bitrate limits used for variable audio bitrate streams. Set both to -1 to
91 // disable audio bitrate adaptation.
92 // Note: This is still an experimental feature and not ready for real usage.
93 int min_bitrate_kbps = -1;
94 int max_bitrate_kbps = -1;
minyue7a973442016-10-20 03:27:12 -070095
minyue6b825df2016-10-31 04:08:32 -070096 // Defines whether to turn on audio network adaptor, and defines its config
97 // string.
98 rtc::Optional<std::string> audio_network_adaptor_config;
99
minyue7a973442016-10-20 03:27:12 -0700100 struct SendCodecSpec {
solenberg940b6d62016-10-25 11:19:07 -0700101 SendCodecSpec();
102 std::string ToString() const;
103
104 bool operator==(const SendCodecSpec& rhs) const;
minyue7a973442016-10-20 03:27:12 -0700105 bool operator!=(const SendCodecSpec& rhs) const {
106 return !(*this == rhs);
107 }
108
109 bool nack_enabled = false;
110 bool transport_cc_enabled = false;
111 bool enable_codec_fec = false;
112 bool enable_opus_dtx = false;
113 int opus_max_playback_rate = 0;
114 int cng_payload_type = -1;
115 int cng_plfreq = -1;
minyue6b825df2016-10-31 04:08:32 -0700116 int max_ptime_ms = -1;
117 int min_ptime_ms = -1;
minyue7a973442016-10-20 03:27:12 -0700118 webrtc::CodecInst codec_inst;
119 } send_codec_spec;
Fredrik Solenberg04f49312015-06-08 13:04:56 +0200120 };
121
pbos1ba8d392016-05-01 20:18:34 -0700122 // Starts stream activity.
123 // When a stream is active, it can receive, process and deliver packets.
124 virtual void Start() = 0;
125 // Stops stream activity.
126 // When a stream is stopped, it can't receive, process or deliver packets.
127 virtual void Stop() = 0;
128
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100129 // TODO(solenberg): Make payload_type a config property instead.
solenberg8842c3e2016-03-11 03:06:41 -0800130 virtual bool SendTelephoneEvent(int payload_type, int event,
131 int duration_ms) = 0;
solenberg94218532016-06-16 10:53:22 -0700132
133 virtual void SetMuted(bool muted) = 0;
134
Fredrik Solenberg04f49312015-06-08 13:04:56 +0200135 virtual Stats GetStats() const = 0;
pbos1ba8d392016-05-01 20:18:34 -0700136
137 protected:
138 virtual ~AudioSendStream() {}
Fredrik Solenberg04f49312015-06-08 13:04:56 +0200139};
140} // namespace webrtc
141
kjellandera69d9732016-08-31 07:33:05 -0700142#endif // WEBRTC_API_CALL_AUDIO_SEND_STREAM_H_