OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_VIDEO_SEND_STREAM_H_ | 11 #ifndef WEBRTC_CALL_VIDEO_SEND_STREAM_H_ |
12 #define WEBRTC_VIDEO_SEND_STREAM_H_ | 12 #define WEBRTC_CALL_VIDEO_SEND_STREAM_H_ |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <string> | 15 #include <string> |
16 #include <utility> | 16 #include <utility> |
17 #include <vector> | 17 #include <vector> |
18 #include <utility> | |
19 | 18 |
20 #include "webrtc/api/call/transport.h" | 19 #include "webrtc/api/call/transport.h" |
21 #include "webrtc/common_types.h" | 20 #include "webrtc/common_types.h" |
22 #include "webrtc/common_video/include/frame_callback.h" | 21 #include "webrtc/common_video/include/frame_callback.h" |
23 #include "webrtc/config.h" | 22 #include "webrtc/config.h" |
24 #include "webrtc/media/base/videosinkinterface.h" | 23 #include "webrtc/media/base/videosinkinterface.h" |
25 #include "webrtc/media/base/videosourceinterface.h" | 24 #include "webrtc/media/base/videosourceinterface.h" |
26 #include "webrtc/rtc_base/platform_file.h" | 25 #include "webrtc/rtc_base/platform_file.h" |
27 | 26 |
28 namespace webrtc { | 27 namespace webrtc { |
29 | 28 |
30 class VideoEncoder; | 29 class VideoEncoder; |
31 | 30 |
32 class VideoSendStream { | 31 class VideoSendStream { |
33 public: | 32 public: |
34 struct StreamStats { | 33 struct StreamStats { |
| 34 StreamStats(); |
| 35 ~StreamStats(); |
| 36 |
35 std::string ToString() const; | 37 std::string ToString() const; |
36 | 38 |
37 FrameCounts frame_counts; | 39 FrameCounts frame_counts; |
38 bool is_rtx = false; | 40 bool is_rtx = false; |
39 bool is_flexfec = false; | 41 bool is_flexfec = false; |
40 int width = 0; | 42 int width = 0; |
41 int height = 0; | 43 int height = 0; |
42 // TODO(holmer): Move bitrate_bps out to the webrtc::Call layer. | 44 // TODO(holmer): Move bitrate_bps out to the webrtc::Call layer. |
43 int total_bitrate_bps = 0; | 45 int total_bitrate_bps = 0; |
44 int retransmit_bitrate_bps = 0; | 46 int retransmit_bitrate_bps = 0; |
45 int avg_delay_ms = 0; | 47 int avg_delay_ms = 0; |
46 int max_delay_ms = 0; | 48 int max_delay_ms = 0; |
47 StreamDataCounters rtp_stats; | 49 StreamDataCounters rtp_stats; |
48 RtcpPacketTypeCounter rtcp_packet_type_counts; | 50 RtcpPacketTypeCounter rtcp_packet_type_counts; |
49 RtcpStatistics rtcp_stats; | 51 RtcpStatistics rtcp_stats; |
50 }; | 52 }; |
51 | 53 |
52 struct Stats { | 54 struct Stats { |
| 55 Stats(); |
| 56 ~Stats(); |
53 std::string ToString(int64_t time_ms) const; | 57 std::string ToString(int64_t time_ms) const; |
54 std::string encoder_implementation_name = "unknown"; | 58 std::string encoder_implementation_name = "unknown"; |
55 int input_frame_rate = 0; | 59 int input_frame_rate = 0; |
56 int encode_frame_rate = 0; | 60 int encode_frame_rate = 0; |
57 int avg_encode_time_ms = 0; | 61 int avg_encode_time_ms = 0; |
58 int encode_usage_percent = 0; | 62 int encode_usage_percent = 0; |
59 uint32_t frames_encoded = 0; | 63 uint32_t frames_encoded = 0; |
60 rtc::Optional<uint64_t> qp_sum; | 64 rtc::Optional<uint64_t> qp_sum; |
61 // Bitrate the encoder is currently configured to use due to bandwidth | 65 // Bitrate the encoder is currently configured to use due to bandwidth |
62 // limitations. | 66 // limitations. |
(...skipping 11 matching lines...) Expand all Loading... |
74 // Total number of times resolution as been requested to be changed due to | 78 // Total number of times resolution as been requested to be changed due to |
75 // CPU/quality adaptation. | 79 // CPU/quality adaptation. |
76 int number_of_cpu_adapt_changes = 0; | 80 int number_of_cpu_adapt_changes = 0; |
77 int number_of_quality_adapt_changes = 0; | 81 int number_of_quality_adapt_changes = 0; |
78 std::map<uint32_t, StreamStats> substreams; | 82 std::map<uint32_t, StreamStats> substreams; |
79 }; | 83 }; |
80 | 84 |
81 struct Config { | 85 struct Config { |
82 public: | 86 public: |
83 Config() = delete; | 87 Config() = delete; |
84 Config(Config&&) = default; | 88 Config(Config&&); |
85 explicit Config(Transport* send_transport) | 89 explicit Config(Transport* send_transport); |
86 : send_transport(send_transport) {} | |
87 | 90 |
88 Config& operator=(Config&&) = default; | 91 Config& operator=(Config&&); |
89 Config& operator=(const Config&) = delete; | 92 Config& operator=(const Config&) = delete; |
90 | 93 |
| 94 ~Config(); |
| 95 |
91 // Mostly used by tests. Avoid creating copies if you can. | 96 // Mostly used by tests. Avoid creating copies if you can. |
92 Config Copy() const { return Config(*this); } | 97 Config Copy() const { return Config(*this); } |
93 | 98 |
94 std::string ToString() const; | 99 std::string ToString() const; |
95 | 100 |
96 struct EncoderSettings { | 101 struct EncoderSettings { |
97 EncoderSettings() = default; | 102 EncoderSettings() = default; |
98 EncoderSettings(std::string payload_name, | 103 EncoderSettings(std::string payload_name, |
99 int payload_type, | 104 int payload_type, |
100 VideoEncoder* encoder) | 105 VideoEncoder* encoder) |
(...skipping 14 matching lines...) Expand all Loading... |
115 // 30fps (for example) exactly. | 120 // 30fps (for example) exactly. |
116 bool full_overuse_time = false; | 121 bool full_overuse_time = false; |
117 | 122 |
118 // Uninitialized VideoEncoder instance to be used for encoding. Will be | 123 // Uninitialized VideoEncoder instance to be used for encoding. Will be |
119 // initialized from inside the VideoSendStream. | 124 // initialized from inside the VideoSendStream. |
120 VideoEncoder* encoder = nullptr; | 125 VideoEncoder* encoder = nullptr; |
121 } encoder_settings; | 126 } encoder_settings; |
122 | 127 |
123 static const size_t kDefaultMaxPacketSize = 1500 - 40; // TCP over IPv4. | 128 static const size_t kDefaultMaxPacketSize = 1500 - 40; // TCP over IPv4. |
124 struct Rtp { | 129 struct Rtp { |
| 130 Rtp(); |
| 131 Rtp(const Rtp&); |
| 132 ~Rtp(); |
125 std::string ToString() const; | 133 std::string ToString() const; |
126 | 134 |
127 std::vector<uint32_t> ssrcs; | 135 std::vector<uint32_t> ssrcs; |
128 | 136 |
129 // See RtcpMode for description. | 137 // See RtcpMode for description. |
130 RtcpMode rtcp_mode = RtcpMode::kCompound; | 138 RtcpMode rtcp_mode = RtcpMode::kCompound; |
131 | 139 |
132 // Max RTP packet size delivered to send transport from VideoEngine. | 140 // Max RTP packet size delivered to send transport from VideoEngine. |
133 size_t max_packet_size = kDefaultMaxPacketSize; | 141 size_t max_packet_size = kDefaultMaxPacketSize; |
134 | 142 |
135 // RTP header extensions to use for this send stream. | 143 // RTP header extensions to use for this send stream. |
136 std::vector<RtpExtension> extensions; | 144 std::vector<RtpExtension> extensions; |
137 | 145 |
138 // See NackConfig for description. | 146 // See NackConfig for description. |
139 NackConfig nack; | 147 NackConfig nack; |
140 | 148 |
141 // See UlpfecConfig for description. | 149 // See UlpfecConfig for description. |
142 UlpfecConfig ulpfec; | 150 UlpfecConfig ulpfec; |
143 | 151 |
144 struct Flexfec { | 152 struct Flexfec { |
| 153 Flexfec(); |
| 154 Flexfec(const Flexfec&); |
| 155 ~Flexfec(); |
145 // Payload type of FlexFEC. Set to -1 to disable sending FlexFEC. | 156 // Payload type of FlexFEC. Set to -1 to disable sending FlexFEC. |
146 int payload_type = -1; | 157 int payload_type = -1; |
147 | 158 |
148 // SSRC of FlexFEC stream. | 159 // SSRC of FlexFEC stream. |
149 uint32_t ssrc = 0; | 160 uint32_t ssrc = 0; |
150 | 161 |
151 // Vector containing a single element, corresponding to the SSRC of the | 162 // Vector containing a single element, corresponding to the SSRC of the |
152 // media stream being protected by this FlexFEC stream. | 163 // media stream being protected by this FlexFEC stream. |
153 // The vector MUST have size 1. | 164 // The vector MUST have size 1. |
154 // | 165 // |
155 // TODO(brandtr): Update comment above when we support | 166 // TODO(brandtr): Update comment above when we support |
156 // multistream protection. | 167 // multistream protection. |
157 std::vector<uint32_t> protected_media_ssrcs; | 168 std::vector<uint32_t> protected_media_ssrcs; |
158 } flexfec; | 169 } flexfec; |
159 | 170 |
160 // Settings for RTP retransmission payload format, see RFC 4588 for | 171 // Settings for RTP retransmission payload format, see RFC 4588 for |
161 // details. | 172 // details. |
162 struct Rtx { | 173 struct Rtx { |
| 174 Rtx(); |
| 175 Rtx(const Rtx&); |
| 176 ~Rtx(); |
163 std::string ToString() const; | 177 std::string ToString() const; |
164 // SSRCs to use for the RTX streams. | 178 // SSRCs to use for the RTX streams. |
165 std::vector<uint32_t> ssrcs; | 179 std::vector<uint32_t> ssrcs; |
166 | 180 |
167 // Payload type to use for the RTX stream. | 181 // Payload type to use for the RTX stream. |
168 int payload_type = -1; | 182 int payload_type = -1; |
169 } rtx; | 183 } rtx; |
170 | 184 |
171 // RTCP CNAME, see RFC 3550. | 185 // RTCP CNAME, see RFC 3550. |
172 std::string c_name; | 186 std::string c_name; |
(...skipping 25 matching lines...) Expand all Loading... |
198 // below the minimum configured bitrate. If this variable is false, the | 212 // below the minimum configured bitrate. If this variable is false, the |
199 // stream may send at a rate higher than the estimated available bitrate. | 213 // stream may send at a rate higher than the estimated available bitrate. |
200 bool suspend_below_min_bitrate = false; | 214 bool suspend_below_min_bitrate = false; |
201 | 215 |
202 // Enables periodic bandwidth probing in application-limited region. | 216 // Enables periodic bandwidth probing in application-limited region. |
203 bool periodic_alr_bandwidth_probing = false; | 217 bool periodic_alr_bandwidth_probing = false; |
204 | 218 |
205 private: | 219 private: |
206 // Access to the copy constructor is private to force use of the Copy() | 220 // Access to the copy constructor is private to force use of the Copy() |
207 // method for those exceptional cases where we do use it. | 221 // method for those exceptional cases where we do use it. |
208 Config(const Config&) = default; | 222 Config(const Config&); |
209 }; | 223 }; |
210 | 224 |
211 // Starts stream activity. | 225 // Starts stream activity. |
212 // When a stream is active, it can receive, process and deliver packets. | 226 // When a stream is active, it can receive, process and deliver packets. |
213 virtual void Start() = 0; | 227 virtual void Start() = 0; |
214 // Stops stream activity. | 228 // Stops stream activity. |
215 // When a stream is stopped, it can't receive, process or deliver packets. | 229 // When a stream is stopped, it can't receive, process or deliver packets. |
216 virtual void Stop() = 0; | 230 virtual void Stop() = 0; |
217 | 231 |
218 // Based on the spec in | 232 // Based on the spec in |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 inline void DisableEncodedFrameRecording() { | 272 inline void DisableEncodedFrameRecording() { |
259 EnableEncodedFrameRecording(std::vector<rtc::PlatformFile>(), 0); | 273 EnableEncodedFrameRecording(std::vector<rtc::PlatformFile>(), 0); |
260 } | 274 } |
261 | 275 |
262 protected: | 276 protected: |
263 virtual ~VideoSendStream() {} | 277 virtual ~VideoSendStream() {} |
264 }; | 278 }; |
265 | 279 |
266 } // namespace webrtc | 280 } // namespace webrtc |
267 | 281 |
268 #endif // WEBRTC_VIDEO_SEND_STREAM_H_ | 282 #endif // WEBRTC_CALL_VIDEO_SEND_STREAM_H_ |
OLD | NEW |