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