Line data Source code
1 : /*
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_CALL_AUDIO_SEND_STREAM_H_
12 : #define WEBRTC_CALL_AUDIO_SEND_STREAM_H_
13 :
14 : #include <memory>
15 : #include <string>
16 : #include <vector>
17 :
18 : #include "webrtc/api/call/transport.h"
19 : #include "webrtc/base/optional.h"
20 : #include "webrtc/config.h"
21 : #include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
22 : #include "webrtc/typedefs.h"
23 :
24 : namespace webrtc {
25 :
26 : // 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 :
31 0 : class AudioSendStream {
32 : public:
33 0 : struct Stats {
34 : Stats();
35 : ~Stats();
36 :
37 : // 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;
44 : rtc::Optional<int> codec_payload_type;
45 : 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;
54 : float residual_echo_likelihood = -1.0f;
55 : float residual_echo_likelihood_recent_max = -1.0f;
56 : bool typing_noise_detected = false;
57 : };
58 :
59 0 : struct Config {
60 : Config() = delete;
61 : explicit Config(Transport* send_transport);
62 : ~Config();
63 : std::string ToString() const;
64 :
65 : // Send-stream specific RTP settings.
66 0 : struct Rtp {
67 : Rtp();
68 : ~Rtp();
69 : std::string ToString() const;
70 :
71 : // Sender SSRC.
72 : uint32_t ssrc = 0;
73 :
74 : // RTP header extensions used for the sent stream.
75 : std::vector<RtpExtension> extensions;
76 :
77 : // See NackConfig for description.
78 : NackConfig nack;
79 :
80 : // RTCP CNAME, see RFC 3550.
81 : std::string c_name;
82 : } rtp;
83 :
84 : // Transport for outgoing packets. The transport is expected to exist for
85 : // the entire life of the AudioSendStream and is owned by the API client.
86 : Transport* send_transport = nullptr;
87 :
88 : // Underlying VoiceEngine handle, used to map AudioSendStream to lower-level
89 : // components.
90 : // TODO(solenberg): Remove when VoiceEngine channels are created outside
91 : // of Call.
92 : int voe_channel_id = -1;
93 :
94 : // Bitrate limits used for variable audio bitrate streams. Set both to -1 to
95 : // disable audio bitrate adaptation.
96 : // Note: This is still an experimental feature and not ready for real usage.
97 : int min_bitrate_bps = -1;
98 : int max_bitrate_bps = -1;
99 :
100 : // Defines whether to turn on audio network adaptor, and defines its config
101 : // string.
102 : rtc::Optional<std::string> audio_network_adaptor_config;
103 :
104 : struct SendCodecSpec {
105 : SendCodecSpec();
106 : std::string ToString() const;
107 :
108 : bool operator==(const SendCodecSpec& rhs) const;
109 : bool operator!=(const SendCodecSpec& rhs) const {
110 : return !(*this == rhs);
111 : }
112 :
113 : bool nack_enabled = false;
114 : bool transport_cc_enabled = false;
115 : bool enable_codec_fec = false;
116 : bool enable_opus_dtx = false;
117 : int opus_max_playback_rate = 0;
118 : int cng_payload_type = -1;
119 : int cng_plfreq = -1;
120 : int max_ptime_ms = -1;
121 : int min_ptime_ms = -1;
122 : webrtc::CodecInst codec_inst;
123 : } send_codec_spec;
124 : };
125 :
126 : // Starts stream activity.
127 : // When a stream is active, it can receive, process and deliver packets.
128 : virtual void Start() = 0;
129 : // Stops stream activity.
130 : // When a stream is stopped, it can't receive, process or deliver packets.
131 : virtual void Stop() = 0;
132 :
133 : // TODO(solenberg): Make payload_type a config property instead.
134 : virtual bool SendTelephoneEvent(int payload_type, int payload_frequency,
135 : int event, int duration_ms) = 0;
136 :
137 : virtual void SetMuted(bool muted) = 0;
138 :
139 : virtual Stats GetStats() const = 0;
140 :
141 : protected:
142 0 : virtual ~AudioSendStream() {}
143 : };
144 : } // namespace webrtc
145 :
146 : #endif // WEBRTC_CALL_AUDIO_SEND_STREAM_H_
|