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 <vector> |
16 | 17 |
17 #include "webrtc/common_types.h" | 18 #include "webrtc/common_types.h" |
18 #include "webrtc/common_video/include/frame_callback.h" | 19 #include "webrtc/common_video/include/frame_callback.h" |
19 #include "webrtc/config.h" | 20 #include "webrtc/config.h" |
20 #include "webrtc/media/base/videosinkinterface.h" | 21 #include "webrtc/media/base/videosinkinterface.h" |
21 #include "webrtc/transport.h" | 22 #include "webrtc/transport.h" |
22 #include "webrtc/media/base/videosinkinterface.h" | |
23 | 23 |
24 namespace webrtc { | 24 namespace webrtc { |
25 | 25 |
26 class LoadObserver; | 26 class LoadObserver; |
27 class VideoEncoder; | 27 class VideoEncoder; |
28 | 28 |
29 // Class to deliver captured frame to the video send stream. | 29 // Class to deliver captured frame to the video send stream. |
30 class VideoCaptureInput { | 30 class VideoCaptureInput { |
31 public: | 31 public: |
32 // These methods do not lock internally and must be called sequentially. | 32 // These methods do not lock internally and must be called sequentially. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 int avg_encode_time_ms = 0; | 65 int avg_encode_time_ms = 0; |
66 int encode_usage_percent = 0; | 66 int encode_usage_percent = 0; |
67 int target_media_bitrate_bps = 0; | 67 int target_media_bitrate_bps = 0; |
68 int media_bitrate_bps = 0; | 68 int media_bitrate_bps = 0; |
69 bool suspended = false; | 69 bool suspended = false; |
70 bool bw_limited_resolution = false; | 70 bool bw_limited_resolution = false; |
71 std::map<uint32_t, StreamStats> substreams; | 71 std::map<uint32_t, StreamStats> substreams; |
72 }; | 72 }; |
73 | 73 |
74 struct Config { | 74 struct Config { |
| 75 public: |
75 Config() = delete; | 76 Config() = delete; |
| 77 Config(Config&&) = default; |
76 explicit Config(Transport* send_transport) | 78 explicit Config(Transport* send_transport) |
77 : send_transport(send_transport) {} | 79 : send_transport(send_transport) {} |
78 | 80 |
| 81 Config& operator=(Config&&) = default; |
| 82 Config& operator=(const Config&) = delete; |
| 83 |
| 84 // Mostly used by tests. Avoid creating copies if you can. |
| 85 Config Copy() const { return Config(*this); } |
| 86 |
79 std::string ToString() const; | 87 std::string ToString() const; |
80 | 88 |
81 struct EncoderSettings { | 89 struct EncoderSettings { |
| 90 EncoderSettings() = default; |
| 91 EncoderSettings(std::string payload_name, |
| 92 int payload_type, |
| 93 VideoEncoder* encoder) |
| 94 : payload_name(std::move(payload_name)), |
| 95 payload_type(payload_type), |
| 96 encoder(encoder) {} |
82 std::string ToString() const; | 97 std::string ToString() const; |
83 | 98 |
84 std::string payload_name; | 99 std::string payload_name; |
85 int payload_type = -1; | 100 int payload_type = -1; |
86 | 101 |
87 // TODO(sophiechang): Delete this field when no one is using internal | 102 // TODO(sophiechang): Delete this field when no one is using internal |
88 // sources anymore. | 103 // sources anymore. |
89 bool internal_source = false; | 104 bool internal_source = false; |
90 | 105 |
91 // Allow 100% encoder utilization. Used for HW encoders where CPU isn't | 106 // Allow 100% encoder utilization. Used for HW encoders where CPU isn't |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 // Called for each I420 frame before encoding the frame. Can be used for | 159 // Called for each I420 frame before encoding the frame. Can be used for |
145 // effects, snapshots etc. 'nullptr' disables the callback. | 160 // effects, snapshots etc. 'nullptr' disables the callback. |
146 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback = nullptr; | 161 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback = nullptr; |
147 | 162 |
148 // Called for each encoded frame, e.g. used for file storage. 'nullptr' | 163 // Called for each encoded frame, e.g. used for file storage. 'nullptr' |
149 // disables the callback. Also measures timing and passes the time | 164 // disables the callback. Also measures timing and passes the time |
150 // spent on encoding. This timing will not fire if encoding takes longer | 165 // spent on encoding. This timing will not fire if encoding takes longer |
151 // than the measuring window, since the sample data will have been dropped. | 166 // than the measuring window, since the sample data will have been dropped. |
152 EncodedFrameObserver* post_encode_callback = nullptr; | 167 EncodedFrameObserver* post_encode_callback = nullptr; |
153 | 168 |
154 // Renderer for local preview. The local renderer will be called even if | |
155 // sending hasn't started. 'nullptr' disables local rendering. | |
156 rtc::VideoSinkInterface<VideoFrame>* local_renderer = nullptr; | |
157 | |
158 // Expected delay needed by the renderer, i.e. the frame will be delivered | 169 // Expected delay needed by the renderer, i.e. the frame will be delivered |
159 // this many milliseconds, if possible, earlier than expected render time. | 170 // this many milliseconds, if possible, earlier than expected render time. |
160 // Only valid if |local_renderer| is set. | 171 // Only valid if |local_renderer| is set. |
161 int render_delay_ms = 0; | 172 int render_delay_ms = 0; |
162 | 173 |
163 // Target delay in milliseconds. A positive value indicates this stream is | 174 // Target delay in milliseconds. A positive value indicates this stream is |
164 // used for streaming instead of a real-time call. | 175 // used for streaming instead of a real-time call. |
165 int target_delay_ms = 0; | 176 int target_delay_ms = 0; |
166 | 177 |
167 // True if the stream should be suspended when the available bitrate fall | 178 // True if the stream should be suspended when the available bitrate fall |
168 // below the minimum configured bitrate. If this variable is false, the | 179 // below the minimum configured bitrate. If this variable is false, the |
169 // stream may send at a rate higher than the estimated available bitrate. | 180 // stream may send at a rate higher than the estimated available bitrate. |
170 bool suspend_below_min_bitrate = false; | 181 bool suspend_below_min_bitrate = false; |
| 182 |
| 183 private: |
| 184 // Access to the copy constructor is private to force use of the Copy() |
| 185 // method for those exceptional cases where we do use it. |
| 186 Config(const Config&) = default; |
171 }; | 187 }; |
172 | 188 |
173 // Starts stream activity. | 189 // Starts stream activity. |
174 // When a stream is active, it can receive, process and deliver packets. | 190 // When a stream is active, it can receive, process and deliver packets. |
175 virtual void Start() = 0; | 191 virtual void Start() = 0; |
176 // Stops stream activity. | 192 // Stops stream activity. |
177 // When a stream is stopped, it can't receive, process or deliver packets. | 193 // When a stream is stopped, it can't receive, process or deliver packets. |
178 virtual void Stop() = 0; | 194 virtual void Stop() = 0; |
179 | 195 |
180 // Gets interface used to insert captured frames. Valid as long as the | 196 // Gets interface used to insert captured frames. Valid as long as the |
181 // VideoSendStream is valid. | 197 // VideoSendStream is valid. |
182 virtual VideoCaptureInput* Input() = 0; | 198 virtual VideoCaptureInput* Input() = 0; |
183 | 199 |
184 // Set which streams to send. Must have at least as many SSRCs as configured | 200 // Set which streams to send. Must have at least as many SSRCs as configured |
185 // in the config. Encoder settings are passed on to the encoder instance along | 201 // in the config. Encoder settings are passed on to the encoder instance along |
186 // with the VideoStream settings. | 202 // with the VideoStream settings. |
187 virtual void ReconfigureVideoEncoder(const VideoEncoderConfig& config) = 0; | 203 virtual void ReconfigureVideoEncoder(VideoEncoderConfig config) = 0; |
188 | 204 |
189 virtual Stats GetStats() = 0; | 205 virtual Stats GetStats() = 0; |
190 | 206 |
191 protected: | 207 protected: |
192 virtual ~VideoSendStream() {} | 208 virtual ~VideoSendStream() {} |
193 }; | 209 }; |
194 | 210 |
195 } // namespace webrtc | 211 } // namespace webrtc |
196 | 212 |
197 #endif // WEBRTC_VIDEO_SEND_STREAM_H_ | 213 #endif // WEBRTC_VIDEO_SEND_STREAM_H_ |
OLD | NEW |