blob: c3d0d339de62e67730d1f8349db24e735812fc6c [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
11#ifndef WEBRTC_AUDIO_SEND_STREAM_H_
12#define WEBRTC_AUDIO_SEND_STREAM_H_
13
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;
49 bool typing_noise_detected = false;
50 };
Fredrik Solenberg04f49312015-06-08 13:04:56 +020051
52 struct Config {
solenberg4fbae2b2015-08-28 04:07:10 -070053 Config() = delete;
pbos2d566682015-09-28 09:59:31 -070054 explicit Config(Transport* send_transport)
solenberg4fbae2b2015-08-28 04:07:10 -070055 : send_transport(send_transport) {}
56
Fredrik Solenberg04f49312015-06-08 13:04:56 +020057 std::string ToString() const;
58
solenberg971cab02016-06-14 10:02:41 -070059 // Send-stream specific RTP settings.
Fredrik Solenberg04f49312015-06-08 13:04:56 +020060 struct Rtp {
61 std::string ToString() const;
62
63 // Sender SSRC.
64 uint32_t ssrc = 0;
65
Stefan Holmerb86d4e42015-12-07 10:26:18 +010066 // RTP header extensions used for the sent stream.
Fredrik Solenberg04f49312015-06-08 13:04:56 +020067 std::vector<RtpExtension> extensions;
solenberg3a941542015-11-16 07:34:50 -080068
solenberg971cab02016-06-14 10:02:41 -070069 // See NackConfig for description.
70 NackConfig nack;
71
solenberg3a941542015-11-16 07:34:50 -080072 // RTCP CNAME, see RFC 3550.
73 std::string c_name;
Fredrik Solenberg04f49312015-06-08 13:04:56 +020074 } rtp;
75
solenbergc7a8b082015-10-16 14:35:07 -070076 // Transport for outgoing packets. The transport is expected to exist for
77 // the entire life of the AudioSendStream and is owned by the API client.
pbos2d566682015-09-28 09:59:31 -070078 Transport* send_transport = nullptr;
solenberg4fbae2b2015-08-28 04:07:10 -070079
solenbergcf18b342015-10-01 08:13:42 -070080 // Underlying VoiceEngine handle, used to map AudioSendStream to lower-level
81 // components.
82 // TODO(solenberg): Remove when VoiceEngine channels are created outside
83 // of Call.
84 int voe_channel_id = -1;
85
solenbergc7a8b082015-10-16 14:35:07 -070086 // Ownership of the encoder object is transferred to Call when the config is
87 // passed to Call::CreateAudioSendStream().
88 // TODO(solenberg): Implement, once we configure codecs through the new API.
kwibergbfefb032016-05-01 14:53:46 -070089 // std::unique_ptr<AudioEncoder> encoder;
Fredrik Solenberg04f49312015-06-08 13:04:56 +020090 int cng_payload_type = -1; // pt, or -1 to disable Comfort Noise Generator.
mflodman86cc6ff2016-07-26 04:44:06 -070091
92 // Bitrate limits used for variable audio bitrate streams. Set both to -1 to
93 // disable audio bitrate adaptation.
94 // Note: This is still an experimental feature and not ready for real usage.
95 int min_bitrate_kbps = -1;
96 int max_bitrate_kbps = -1;
Fredrik Solenberg04f49312015-06-08 13:04:56 +020097 };
98
pbos1ba8d392016-05-01 20:18:34 -070099 // Starts stream activity.
100 // When a stream is active, it can receive, process and deliver packets.
101 virtual void Start() = 0;
102 // Stops stream activity.
103 // When a stream is stopped, it can't receive, process or deliver packets.
104 virtual void Stop() = 0;
105
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100106 // TODO(solenberg): Make payload_type a config property instead.
solenberg8842c3e2016-03-11 03:06:41 -0800107 virtual bool SendTelephoneEvent(int payload_type, int event,
108 int duration_ms) = 0;
solenberg94218532016-06-16 10:53:22 -0700109
110 virtual void SetMuted(bool muted) = 0;
111
Fredrik Solenberg04f49312015-06-08 13:04:56 +0200112 virtual Stats GetStats() const = 0;
pbos1ba8d392016-05-01 20:18:34 -0700113
114 protected:
115 virtual ~AudioSendStream() {}
Fredrik Solenberg04f49312015-06-08 13:04:56 +0200116};
117} // namespace webrtc
118
119#endif // WEBRTC_AUDIO_SEND_STREAM_H_