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_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 <map> |
15 #include <string> | 15 #include <string> |
16 #include <utility> | 16 #include <utility> |
17 #include <vector> | 17 #include <vector> |
18 #include <utility> | 18 #include <utility> |
19 | 19 |
20 #include "webrtc/base/platform_file.h" | 20 #include "webrtc/base/platform_file.h" |
21 #include "webrtc/common_types.h" | 21 #include "webrtc/common_types.h" |
22 #include "webrtc/common_video/include/frame_callback.h" | 22 #include "webrtc/common_video/include/frame_callback.h" |
23 #include "webrtc/config.h" | 23 #include "webrtc/config.h" |
24 #include "webrtc/media/base/videosinkinterface.h" | 24 #include "webrtc/media/base/videosinkinterface.h" |
25 #include "webrtc/media/base/videosourceinterface.h" | 25 #include "webrtc/media/base/videosourceinterface.h" |
26 #include "webrtc/transport.h" | 26 #include "webrtc/transport.h" |
27 | 27 |
28 namespace webrtc { | 28 namespace webrtc { |
29 | 29 |
30 class LoadObserver; | |
31 class VideoEncoder; | 30 class VideoEncoder; |
32 | 31 |
33 class VideoSendStream { | 32 class VideoSendStream { |
34 public: | 33 public: |
35 struct StreamStats { | 34 struct StreamStats { |
36 std::string ToString() const; | 35 std::string ToString() const; |
37 | 36 |
38 FrameCounts frame_counts; | 37 FrameCounts frame_counts; |
39 bool is_rtx = false; | 38 bool is_rtx = false; |
40 int width = 0; | 39 int width = 0; |
(...skipping 19 matching lines...) Expand all Loading... | |
60 // Bitrate the encoder is currently configured to use due to bandwidth | 59 // Bitrate the encoder is currently configured to use due to bandwidth |
61 // limitations. | 60 // limitations. |
62 int target_media_bitrate_bps = 0; | 61 int target_media_bitrate_bps = 0; |
63 // Bitrate the encoder is actually producing. | 62 // Bitrate the encoder is actually producing. |
64 int media_bitrate_bps = 0; | 63 int media_bitrate_bps = 0; |
65 // Media bitrate this VideoSendStream is configured to prefer if there are | 64 // Media bitrate this VideoSendStream is configured to prefer if there are |
66 // no bandwidth limitations. | 65 // no bandwidth limitations. |
67 int preferred_media_bitrate_bps = 0; | 66 int preferred_media_bitrate_bps = 0; |
68 bool suspended = false; | 67 bool suspended = false; |
69 bool bw_limited_resolution = false; | 68 bool bw_limited_resolution = false; |
69 bool cpu_limited_resolution = false; | |
70 // Total number of times resolution as been requested to be changed due to | |
71 // CPU adaptation. | |
72 int number_of_cpu_adapt_changes = 0; | |
70 std::map<uint32_t, StreamStats> substreams; | 73 std::map<uint32_t, StreamStats> substreams; |
71 }; | 74 }; |
72 | 75 |
73 struct Config { | 76 struct Config { |
74 public: | 77 public: |
75 Config() = delete; | 78 Config() = delete; |
76 Config(Config&&) = default; | 79 Config(Config&&) = default; |
77 explicit Config(Transport* send_transport) | 80 explicit Config(Transport* send_transport) |
78 : send_transport(send_transport) {} | 81 : send_transport(send_transport) {} |
79 | 82 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 int payload_type = -1; | 147 int payload_type = -1; |
145 } rtx; | 148 } rtx; |
146 | 149 |
147 // RTCP CNAME, see RFC 3550. | 150 // RTCP CNAME, see RFC 3550. |
148 std::string c_name; | 151 std::string c_name; |
149 } rtp; | 152 } rtp; |
150 | 153 |
151 // Transport for outgoing packets. | 154 // Transport for outgoing packets. |
152 Transport* send_transport = nullptr; | 155 Transport* send_transport = nullptr; |
153 | 156 |
154 // Callback for overuse and normal usage based on the jitter of incoming | |
155 // captured frames. 'nullptr' disables the callback. | |
156 LoadObserver* overuse_callback = nullptr; | |
157 | |
158 // Called for each I420 frame before encoding the frame. Can be used for | 157 // Called for each I420 frame before encoding the frame. Can be used for |
159 // effects, snapshots etc. 'nullptr' disables the callback. | 158 // effects, snapshots etc. 'nullptr' disables the callback. |
160 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback = nullptr; | 159 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback = nullptr; |
161 | 160 |
162 // Called for each encoded frame, e.g. used for file storage. 'nullptr' | 161 // Called for each encoded frame, e.g. used for file storage. 'nullptr' |
163 // disables the callback. Also measures timing and passes the time | 162 // disables the callback. Also measures timing and passes the time |
164 // spent on encoding. This timing will not fire if encoding takes longer | 163 // spent on encoding. This timing will not fire if encoding takes longer |
165 // than the measuring window, since the sample data will have been dropped. | 164 // than the measuring window, since the sample data will have been dropped. |
166 EncodedFrameObserver* post_encode_callback = nullptr; | 165 EncodedFrameObserver* post_encode_callback = nullptr; |
167 | 166 |
(...skipping 17 matching lines...) Expand all Loading... | |
185 Config(const Config&) = default; | 184 Config(const Config&) = default; |
186 }; | 185 }; |
187 | 186 |
188 // Starts stream activity. | 187 // Starts stream activity. |
189 // When a stream is active, it can receive, process and deliver packets. | 188 // When a stream is active, it can receive, process and deliver packets. |
190 virtual void Start() = 0; | 189 virtual void Start() = 0; |
191 // Stops stream activity. | 190 // Stops stream activity. |
192 // When a stream is stopped, it can't receive, process or deliver packets. | 191 // When a stream is stopped, it can't receive, process or deliver packets. |
193 virtual void Stop() = 0; | 192 virtual void Stop() = 0; |
194 | 193 |
194 // Based on the spec in | |
195 // https://w3c.github.io/webrtc-pc/#idl-def-rtcdegradationpreference. | |
196 enum class DegradationPreference { | |
197 kMaintainResolution, | |
198 // TODO(perkj): Implement kMaintainFrameRate. kBalanced will drop frames | |
199 // if the encoder overshootor or the encoder can not encode fast enough. | |
nisse-webrtc
2016/10/28 10:53:44
"s " missing in "overshoots or"
perkj_webrtc
2016/10/28 14:05:34
Done.
| |
200 kBalanced, | |
201 }; | |
195 virtual void SetSource( | 202 virtual void SetSource( |
196 rtc::VideoSourceInterface<webrtc::VideoFrame>* source) = 0; | 203 rtc::VideoSourceInterface<webrtc::VideoFrame>* source, |
204 const DegradationPreference& degradation_preference) = 0; | |
197 | 205 |
198 // Set which streams to send. Must have at least as many SSRCs as configured | 206 // Set which streams to send. Must have at least as many SSRCs as configured |
199 // in the config. Encoder settings are passed on to the encoder instance along | 207 // in the config. Encoder settings are passed on to the encoder instance along |
200 // with the VideoStream settings. | 208 // with the VideoStream settings. |
201 virtual void ReconfigureVideoEncoder(VideoEncoderConfig config) = 0; | 209 virtual void ReconfigureVideoEncoder(VideoEncoderConfig config) = 0; |
202 | 210 |
203 virtual Stats GetStats() = 0; | 211 virtual Stats GetStats() = 0; |
204 | 212 |
205 // Takes ownership of each file, is responsible for closing them later. | 213 // Takes ownership of each file, is responsible for closing them later. |
206 // Calling this method will close and finalize any current logs. | 214 // Calling this method will close and finalize any current logs. |
(...skipping 11 matching lines...) Expand all Loading... | |
218 EnableEncodedFrameRecording(std::vector<rtc::PlatformFile>(), 0); | 226 EnableEncodedFrameRecording(std::vector<rtc::PlatformFile>(), 0); |
219 } | 227 } |
220 | 228 |
221 protected: | 229 protected: |
222 virtual ~VideoSendStream() {} | 230 virtual ~VideoSendStream() {} |
223 }; | 231 }; |
224 | 232 |
225 } // namespace webrtc | 233 } // namespace webrtc |
226 | 234 |
227 #endif // WEBRTC_VIDEO_SEND_STREAM_H_ | 235 #endif // WEBRTC_VIDEO_SEND_STREAM_H_ |
OLD | NEW |