Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: webrtc/video_send_stream.h

Issue 3000253002: Move video send/receive stream headers to webrtc/call. (Closed)
Patch Set: Headers moved to 'webrtc/call' instead of 'webrtc/api'. Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« webrtc/BUILD.gn ('K') | « webrtc/video_receive_stream.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_VIDEO_SEND_STREAM_H_
12 #define WEBRTC_VIDEO_SEND_STREAM_H_ 12 #define WEBRTC_VIDEO_SEND_STREAM_H_
13 13
14 #include <map> 14 #include "webrtc/call/video_send_stream.h"
15 #include <string> 15 // The contents header have moved to webrtc/call/video_send_stream.h. This
16 #include <utility> 16 // file is deprecated. See http://bugs.webrtc.org/8107.
17 #include <vector>
18 #include <utility>
19
20 #include "webrtc/api/call/transport.h"
21 #include "webrtc/common_types.h"
22 #include "webrtc/common_video/include/frame_callback.h"
23 #include "webrtc/config.h"
24 #include "webrtc/media/base/videosinkinterface.h"
25 #include "webrtc/media/base/videosourceinterface.h"
26 #include "webrtc/rtc_base/platform_file.h"
27
28 namespace webrtc {
29
30 class VideoEncoder;
31
32 class VideoSendStream {
33 public:
34 struct StreamStats {
35 std::string ToString() const;
36
37 FrameCounts frame_counts;
38 bool is_rtx = false;
39 bool is_flexfec = false;
40 int width = 0;
41 int height = 0;
42 // TODO(holmer): Move bitrate_bps out to the webrtc::Call layer.
43 int total_bitrate_bps = 0;
44 int retransmit_bitrate_bps = 0;
45 int avg_delay_ms = 0;
46 int max_delay_ms = 0;
47 StreamDataCounters rtp_stats;
48 RtcpPacketTypeCounter rtcp_packet_type_counts;
49 RtcpStatistics rtcp_stats;
50 };
51
52 struct Stats {
53 std::string ToString(int64_t time_ms) const;
54 std::string encoder_implementation_name = "unknown";
55 int input_frame_rate = 0;
56 int encode_frame_rate = 0;
57 int avg_encode_time_ms = 0;
58 int encode_usage_percent = 0;
59 uint32_t frames_encoded = 0;
60 rtc::Optional<uint64_t> qp_sum;
61 // Bitrate the encoder is currently configured to use due to bandwidth
62 // limitations.
63 int target_media_bitrate_bps = 0;
64 // Bitrate the encoder is actually producing.
65 int media_bitrate_bps = 0;
66 // Media bitrate this VideoSendStream is configured to prefer if there are
67 // no bandwidth limitations.
68 int preferred_media_bitrate_bps = 0;
69 bool suspended = false;
70 bool bw_limited_resolution = false;
71 bool cpu_limited_resolution = false;
72 bool bw_limited_framerate = false;
73 bool cpu_limited_framerate = false;
74 // Total number of times resolution as been requested to be changed due to
75 // CPU/quality adaptation.
76 int number_of_cpu_adapt_changes = 0;
77 int number_of_quality_adapt_changes = 0;
78 std::map<uint32_t, StreamStats> substreams;
79 };
80
81 struct Config {
82 public:
83 Config() = delete;
84 Config(Config&&) = default;
85 explicit Config(Transport* send_transport)
86 : send_transport(send_transport) {}
87
88 Config& operator=(Config&&) = default;
89 Config& operator=(const Config&) = delete;
90
91 // Mostly used by tests. Avoid creating copies if you can.
92 Config Copy() const { return Config(*this); }
93
94 std::string ToString() const;
95
96 struct EncoderSettings {
97 EncoderSettings() = default;
98 EncoderSettings(std::string payload_name,
99 int payload_type,
100 VideoEncoder* encoder)
101 : payload_name(std::move(payload_name)),
102 payload_type(payload_type),
103 encoder(encoder) {}
104 std::string ToString() const;
105
106 std::string payload_name;
107 int payload_type = -1;
108
109 // TODO(sophiechang): Delete this field when no one is using internal
110 // sources anymore.
111 bool internal_source = false;
112
113 // Allow 100% encoder utilization. Used for HW encoders where CPU isn't
114 // expected to be the limiting factor, but a chip could be running at
115 // 30fps (for example) exactly.
116 bool full_overuse_time = false;
117
118 // Uninitialized VideoEncoder instance to be used for encoding. Will be
119 // initialized from inside the VideoSendStream.
120 VideoEncoder* encoder = nullptr;
121 } encoder_settings;
122
123 static const size_t kDefaultMaxPacketSize = 1500 - 40; // TCP over IPv4.
124 struct Rtp {
125 std::string ToString() const;
126
127 std::vector<uint32_t> ssrcs;
128
129 // See RtcpMode for description.
130 RtcpMode rtcp_mode = RtcpMode::kCompound;
131
132 // Max RTP packet size delivered to send transport from VideoEngine.
133 size_t max_packet_size = kDefaultMaxPacketSize;
134
135 // RTP header extensions to use for this send stream.
136 std::vector<RtpExtension> extensions;
137
138 // See NackConfig for description.
139 NackConfig nack;
140
141 // See UlpfecConfig for description.
142 UlpfecConfig ulpfec;
143
144 struct Flexfec {
145 // Payload type of FlexFEC. Set to -1 to disable sending FlexFEC.
146 int payload_type = -1;
147
148 // SSRC of FlexFEC stream.
149 uint32_t ssrc = 0;
150
151 // Vector containing a single element, corresponding to the SSRC of the
152 // media stream being protected by this FlexFEC stream.
153 // The vector MUST have size 1.
154 //
155 // TODO(brandtr): Update comment above when we support
156 // multistream protection.
157 std::vector<uint32_t> protected_media_ssrcs;
158 } flexfec;
159
160 // Settings for RTP retransmission payload format, see RFC 4588 for
161 // details.
162 struct Rtx {
163 std::string ToString() const;
164 // SSRCs to use for the RTX streams.
165 std::vector<uint32_t> ssrcs;
166
167 // Payload type to use for the RTX stream.
168 int payload_type = -1;
169 } rtx;
170
171 // RTCP CNAME, see RFC 3550.
172 std::string c_name;
173 } rtp;
174
175 // Transport for outgoing packets.
176 Transport* send_transport = nullptr;
177
178 // Called for each I420 frame before encoding the frame. Can be used for
179 // effects, snapshots etc. 'nullptr' disables the callback.
180 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback = nullptr;
181
182 // Called for each encoded frame, e.g. used for file storage. 'nullptr'
183 // disables the callback. Also measures timing and passes the time
184 // spent on encoding. This timing will not fire if encoding takes longer
185 // than the measuring window, since the sample data will have been dropped.
186 EncodedFrameObserver* post_encode_callback = nullptr;
187
188 // Expected delay needed by the renderer, i.e. the frame will be delivered
189 // this many milliseconds, if possible, earlier than expected render time.
190 // Only valid if |local_renderer| is set.
191 int render_delay_ms = 0;
192
193 // Target delay in milliseconds. A positive value indicates this stream is
194 // used for streaming instead of a real-time call.
195 int target_delay_ms = 0;
196
197 // True if the stream should be suspended when the available bitrate fall
198 // below the minimum configured bitrate. If this variable is false, the
199 // stream may send at a rate higher than the estimated available bitrate.
200 bool suspend_below_min_bitrate = false;
201
202 // Enables periodic bandwidth probing in application-limited region.
203 bool periodic_alr_bandwidth_probing = false;
204
205 private:
206 // Access to the copy constructor is private to force use of the Copy()
207 // method for those exceptional cases where we do use it.
208 Config(const Config&) = default;
209 };
210
211 // Starts stream activity.
212 // When a stream is active, it can receive, process and deliver packets.
213 virtual void Start() = 0;
214 // Stops stream activity.
215 // When a stream is stopped, it can't receive, process or deliver packets.
216 virtual void Stop() = 0;
217
218 // Based on the spec in
219 // https://w3c.github.io/webrtc-pc/#idl-def-rtcdegradationpreference.
220 // These options are enforced on a best-effort basis. For instance, all of
221 // these options may suffer some frame drops in order to avoid queuing.
222 // TODO(sprang): Look into possibility of more strictly enforcing the
223 // maintain-framerate option.
224 enum class DegradationPreference {
225 // Don't take any actions based on over-utilization signals.
226 kDegradationDisabled,
227 // On over-use, request lower frame rate, possibly causing frame drops.
228 kMaintainResolution,
229 // On over-use, request lower resolution, possibly causing down-scaling.
230 kMaintainFramerate,
231 // Try to strike a "pleasing" balance between frame rate or resolution.
232 kBalanced,
233 };
234
235 virtual void SetSource(
236 rtc::VideoSourceInterface<webrtc::VideoFrame>* source,
237 const DegradationPreference& degradation_preference) = 0;
238
239 // Set which streams to send. Must have at least as many SSRCs as configured
240 // in the config. Encoder settings are passed on to the encoder instance along
241 // with the VideoStream settings.
242 virtual void ReconfigureVideoEncoder(VideoEncoderConfig config) = 0;
243
244 virtual Stats GetStats() = 0;
245
246 // Takes ownership of each file, is responsible for closing them later.
247 // Calling this method will close and finalize any current logs.
248 // Some codecs produce multiple streams (VP8 only at present), each of these
249 // streams will log to a separate file. kMaxSimulcastStreams in common_types.h
250 // gives the max number of such streams. If there is no file for a stream, or
251 // the file is rtc::kInvalidPlatformFileValue, frames from that stream will
252 // not be logged.
253 // If a frame to be written would make the log too large the write fails and
254 // the log is closed and finalized. A |byte_limit| of 0 means no limit.
255 virtual void EnableEncodedFrameRecording(
256 const std::vector<rtc::PlatformFile>& files,
257 size_t byte_limit) = 0;
258 inline void DisableEncodedFrameRecording() {
259 EnableEncodedFrameRecording(std::vector<rtc::PlatformFile>(), 0);
260 }
261
262 protected:
263 virtual ~VideoSendStream() {}
264 };
265
266 } // namespace webrtc
267 17
268 #endif // WEBRTC_VIDEO_SEND_STREAM_H_ 18 #endif // WEBRTC_VIDEO_SEND_STREAM_H_
OLDNEW
« webrtc/BUILD.gn ('K') | « webrtc/video_receive_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698