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