blob: b4ba61549f6d54851fb2dbd451d104208975cce7 [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
hbos1acfbd22016-11-17 23:43:29 -080018#include "webrtc/base/optional.h"
Fredrik Solenberg04f49312015-06-08 13:04:56 +020019#include "webrtc/config.h"
20#include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
solenberg4fbae2b2015-08-28 04:07:10 -070021#include "webrtc/transport.h"
Fredrik Solenberg04f49312015-06-08 13:04:56 +020022#include "webrtc/typedefs.h"
23
24namespace webrtc {
25
Fredrik Solenberga4527c82015-12-03 13:06:20 +010026// WORK IN PROGRESS
27// This class is under development and is not yet intended for for use outside
28// of WebRtc/Libjingle. Please use the VoiceEngine API instead.
29// See: https://bugs.chromium.org/p/webrtc/issues/detail?id=4690
30
pbos1ba8d392016-05-01 20:18:34 -070031class AudioSendStream {
Fredrik Solenberg04f49312015-06-08 13:04:56 +020032 public:
solenberg85a04962015-10-27 03:35:21 -070033 struct Stats {
solenberg940b6d62016-10-25 11:19:07 -070034 Stats();
hbos1acfbd22016-11-17 23:43:29 -080035 ~Stats();
solenberg940b6d62016-10-25 11:19:07 -070036
solenberg85a04962015-10-27 03:35:21 -070037 // TODO(solenberg): Harmonize naming and defaults with receive stream stats.
38 uint32_t local_ssrc = 0;
39 int64_t bytes_sent = 0;
40 int32_t packets_sent = 0;
41 int32_t packets_lost = -1;
42 float fraction_lost = -1.0f;
43 std::string codec_name;
hbos1acfbd22016-11-17 23:43:29 -080044 rtc::Optional<int> codec_payload_type;
solenberg85a04962015-10-27 03:35:21 -070045 int32_t ext_seqnum = -1;
46 int32_t jitter_ms = -1;
47 int64_t rtt_ms = -1;
48 int32_t audio_level = -1;
49 float aec_quality_min = -1.0f;
50 int32_t echo_delay_median_ms = -1;
51 int32_t echo_delay_std_ms = -1;
52 int32_t echo_return_loss = -100;
53 int32_t echo_return_loss_enhancement = -100;
ivoc8c63a822016-10-21 04:10:03 -070054 float residual_echo_likelihood = -1.0f;
solenberg85a04962015-10-27 03:35:21 -070055 bool typing_noise_detected = false;
56 };
Fredrik Solenberg04f49312015-06-08 13:04:56 +020057
58 struct Config {
solenberg4fbae2b2015-08-28 04:07:10 -070059 Config() = delete;
solenberg940b6d62016-10-25 11:19:07 -070060 explicit Config(Transport* send_transport);
minyue6b825df2016-10-31 04:08:32 -070061 ~Config();
Fredrik Solenberg04f49312015-06-08 13:04:56 +020062 std::string ToString() const;
63
solenberg971cab02016-06-14 10:02:41 -070064 // Send-stream specific RTP settings.
Fredrik Solenberg04f49312015-06-08 13:04:56 +020065 struct Rtp {
solenberg940b6d62016-10-25 11:19:07 -070066 Rtp();
67 ~Rtp();
Fredrik Solenberg04f49312015-06-08 13:04:56 +020068 std::string ToString() const;
69
70 // Sender SSRC.
71 uint32_t ssrc = 0;
72
Stefan Holmerb86d4e42015-12-07 10:26:18 +010073 // RTP header extensions used for the sent stream.
Fredrik Solenberg04f49312015-06-08 13:04:56 +020074 std::vector<RtpExtension> extensions;
solenberg3a941542015-11-16 07:34:50 -080075
solenberg971cab02016-06-14 10:02:41 -070076 // See NackConfig for description.
77 NackConfig nack;
78
solenberg3a941542015-11-16 07:34:50 -080079 // RTCP CNAME, see RFC 3550.
80 std::string c_name;
Fredrik Solenberg04f49312015-06-08 13:04:56 +020081 } rtp;
82
solenbergc7a8b082015-10-16 14:35:07 -070083 // Transport for outgoing packets. The transport is expected to exist for
84 // the entire life of the AudioSendStream and is owned by the API client.
pbos2d566682015-09-28 09:59:31 -070085 Transport* send_transport = nullptr;
solenberg4fbae2b2015-08-28 04:07:10 -070086
solenbergcf18b342015-10-01 08:13:42 -070087 // Underlying VoiceEngine handle, used to map AudioSendStream to lower-level
88 // components.
89 // TODO(solenberg): Remove when VoiceEngine channels are created outside
90 // of Call.
91 int voe_channel_id = -1;
92
mflodman86cc6ff2016-07-26 04:44:06 -070093 // Bitrate limits used for variable audio bitrate streams. Set both to -1 to
94 // disable audio bitrate adaptation.
95 // Note: This is still an experimental feature and not ready for real usage.
minyue10cbb462016-11-07 09:29:22 -080096 int min_bitrate_bps = -1;
97 int max_bitrate_bps = -1;
minyue7a973442016-10-20 03:27:12 -070098
minyue6b825df2016-10-31 04:08:32 -070099 // Defines whether to turn on audio network adaptor, and defines its config
100 // string.
101 rtc::Optional<std::string> audio_network_adaptor_config;
102
minyue7a973442016-10-20 03:27:12 -0700103 struct SendCodecSpec {
solenberg940b6d62016-10-25 11:19:07 -0700104 SendCodecSpec();
105 std::string ToString() const;
106
107 bool operator==(const SendCodecSpec& rhs) const;
minyue7a973442016-10-20 03:27:12 -0700108 bool operator!=(const SendCodecSpec& rhs) const {
109 return !(*this == rhs);
110 }
111
112 bool nack_enabled = false;
113 bool transport_cc_enabled = false;
114 bool enable_codec_fec = false;
115 bool enable_opus_dtx = false;
116 int opus_max_playback_rate = 0;
117 int cng_payload_type = -1;
118 int cng_plfreq = -1;
minyue6b825df2016-10-31 04:08:32 -0700119 int max_ptime_ms = -1;
120 int min_ptime_ms = -1;
minyue7a973442016-10-20 03:27:12 -0700121 webrtc::CodecInst codec_inst;
122 } send_codec_spec;
Fredrik Solenberg04f49312015-06-08 13:04:56 +0200123 };
124
pbos1ba8d392016-05-01 20:18:34 -0700125 // Starts stream activity.
126 // When a stream is active, it can receive, process and deliver packets.
127 virtual void Start() = 0;
128 // Stops stream activity.
129 // When a stream is stopped, it can't receive, process or deliver packets.
130 virtual void Stop() = 0;
131
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100132 // TODO(solenberg): Make payload_type a config property instead.
solenbergffbbcac2016-11-17 05:25:37 -0800133 virtual bool SendTelephoneEvent(int payload_type, int payload_frequency,
134 int event, int duration_ms) = 0;
solenberg94218532016-06-16 10:53:22 -0700135
136 virtual void SetMuted(bool muted) = 0;
137
Fredrik Solenberg04f49312015-06-08 13:04:56 +0200138 virtual Stats GetStats() const = 0;
pbos1ba8d392016-05-01 20:18:34 -0700139
140 protected:
141 virtual ~AudioSendStream() {}
Fredrik Solenberg04f49312015-06-08 13:04:56 +0200142};
143} // namespace webrtc
144
kjellandera69d9732016-08-31 07:33:05 -0700145#endif // WEBRTC_API_CALL_AUDIO_SEND_STREAM_H_