blob: 18e71253f1158dfe5681c79000d77f2f7faedc46 [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
18#include "webrtc/base/scoped_ptr.h"
19#include "webrtc/config.h"
20#include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
Jelena Marusiccd670222015-07-16 09:30:09 +020021#include "webrtc/stream.h"
solenberg4fbae2b2015-08-28 04:07:10 -070022#include "webrtc/transport.h"
Fredrik Solenberg04f49312015-06-08 13:04:56 +020023#include "webrtc/typedefs.h"
24
25namespace webrtc {
26
Fredrik Solenberga4527c82015-12-03 13:06:20 +010027// WORK IN PROGRESS
28// This class is under development and is not yet intended for for use outside
29// of WebRtc/Libjingle. Please use the VoiceEngine API instead.
30// See: https://bugs.chromium.org/p/webrtc/issues/detail?id=4690
31
Jelena Marusiccd670222015-07-16 09:30:09 +020032class AudioSendStream : public SendStream {
Fredrik Solenberg04f49312015-06-08 13:04:56 +020033 public:
solenberg85a04962015-10-27 03:35:21 -070034 struct Stats {
35 // 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;
51 bool typing_noise_detected = false;
52 };
Fredrik Solenberg04f49312015-06-08 13:04:56 +020053
54 struct Config {
solenberg4fbae2b2015-08-28 04:07:10 -070055 Config() = delete;
pbos2d566682015-09-28 09:59:31 -070056 explicit Config(Transport* send_transport)
solenberg4fbae2b2015-08-28 04:07:10 -070057 : send_transport(send_transport) {}
58
Fredrik Solenberg04f49312015-06-08 13:04:56 +020059 std::string ToString() const;
60
61 // Receive-stream specific RTP settings.
62 struct Rtp {
63 std::string ToString() const;
64
65 // Sender SSRC.
66 uint32_t ssrc = 0;
67
Stefan Holmerb86d4e42015-12-07 10:26:18 +010068 // RTP header extensions used for the sent stream.
Fredrik Solenberg04f49312015-06-08 13:04:56 +020069 std::vector<RtpExtension> extensions;
solenberg3a941542015-11-16 07:34:50 -080070
71 // RTCP CNAME, see RFC 3550.
72 std::string c_name;
Fredrik Solenberg04f49312015-06-08 13:04:56 +020073 } rtp;
74
solenbergc7a8b082015-10-16 14:35:07 -070075 // Transport for outgoing packets. The transport is expected to exist for
76 // the entire life of the AudioSendStream and is owned by the API client.
pbos2d566682015-09-28 09:59:31 -070077 Transport* send_transport = nullptr;
solenberg4fbae2b2015-08-28 04:07:10 -070078
solenbergcf18b342015-10-01 08:13:42 -070079 // Underlying VoiceEngine handle, used to map AudioSendStream to lower-level
80 // components.
81 // TODO(solenberg): Remove when VoiceEngine channels are created outside
82 // of Call.
83 int voe_channel_id = -1;
84
solenbergc7a8b082015-10-16 14:35:07 -070085 // Ownership of the encoder object is transferred to Call when the config is
86 // passed to Call::CreateAudioSendStream().
87 // TODO(solenberg): Implement, once we configure codecs through the new API.
kwibergbfefb032016-05-01 14:53:46 -070088 // std::unique_ptr<AudioEncoder> encoder;
Fredrik Solenberg04f49312015-06-08 13:04:56 +020089 int cng_payload_type = -1; // pt, or -1 to disable Comfort Noise Generator.
90 int red_payload_type = -1; // pt, or -1 to disable REDundant coding.
91 };
92
Fredrik Solenbergb5727682015-12-04 15:22:19 +010093 // TODO(solenberg): Make payload_type a config property instead.
solenberg8842c3e2016-03-11 03:06:41 -080094 virtual bool SendTelephoneEvent(int payload_type, int event,
95 int duration_ms) = 0;
Fredrik Solenberg04f49312015-06-08 13:04:56 +020096 virtual Stats GetStats() const = 0;
Fredrik Solenberg04f49312015-06-08 13:04:56 +020097};
98} // namespace webrtc
99
100#endif // WEBRTC_AUDIO_SEND_STREAM_H_