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> | |
17 | 16 |
18 #include "webrtc/common_types.h" | 17 #include "webrtc/common_types.h" |
19 #include "webrtc/common_video/include/frame_callback.h" | 18 #include "webrtc/common_video/include/frame_callback.h" |
20 #include "webrtc/config.h" | 19 #include "webrtc/config.h" |
21 #include "webrtc/media/base/videosinkinterface.h" | 20 #include "webrtc/media/base/videosinkinterface.h" |
22 #include "webrtc/transport.h" | 21 #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: | |
76 Config() = delete; | 75 Config() = delete; |
77 Config(Config&&) = default; | |
78 explicit Config(Transport* send_transport) | 76 explicit Config(Transport* send_transport) |
79 : send_transport(send_transport) {} | 77 : send_transport(send_transport) {} |
80 | 78 |
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 | |
87 std::string ToString() const; | 79 std::string ToString() const; |
88 | 80 |
89 struct EncoderSettings { | 81 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) {} | |
97 std::string ToString() const; | 82 std::string ToString() const; |
98 | 83 |
99 std::string payload_name; | 84 std::string payload_name; |
100 int payload_type = -1; | 85 int payload_type = -1; |
101 | 86 |
102 // TODO(sophiechang): Delete this field when no one is using internal | 87 // TODO(sophiechang): Delete this field when no one is using internal |
103 // sources anymore. | 88 // sources anymore. |
104 bool internal_source = false; | 89 bool internal_source = false; |
105 | 90 |
106 // Allow 100% encoder utilization. Used for HW encoders where CPU isn't | 91 // 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... |
159 // Called for each I420 frame before encoding the frame. Can be used for | 144 // Called for each I420 frame before encoding the frame. Can be used for |
160 // effects, snapshots etc. 'nullptr' disables the callback. | 145 // effects, snapshots etc. 'nullptr' disables the callback. |
161 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback = nullptr; | 146 rtc::VideoSinkInterface<VideoFrame>* pre_encode_callback = nullptr; |
162 | 147 |
163 // Called for each encoded frame, e.g. used for file storage. 'nullptr' | 148 // Called for each encoded frame, e.g. used for file storage. 'nullptr' |
164 // disables the callback. Also measures timing and passes the time | 149 // disables the callback. Also measures timing and passes the time |
165 // spent on encoding. This timing will not fire if encoding takes longer | 150 // 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. | 151 // than the measuring window, since the sample data will have been dropped. |
167 EncodedFrameObserver* post_encode_callback = nullptr; | 152 EncodedFrameObserver* post_encode_callback = nullptr; |
168 | 153 |
| 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 |
169 // Expected delay needed by the renderer, i.e. the frame will be delivered | 158 // Expected delay needed by the renderer, i.e. the frame will be delivered |
170 // this many milliseconds, if possible, earlier than expected render time. | 159 // this many milliseconds, if possible, earlier than expected render time. |
171 // Only valid if |local_renderer| is set. | 160 // Only valid if |local_renderer| is set. |
172 int render_delay_ms = 0; | 161 int render_delay_ms = 0; |
173 | 162 |
174 // Target delay in milliseconds. A positive value indicates this stream is | 163 // Target delay in milliseconds. A positive value indicates this stream is |
175 // used for streaming instead of a real-time call. | 164 // used for streaming instead of a real-time call. |
176 int target_delay_ms = 0; | 165 int target_delay_ms = 0; |
177 | 166 |
178 // True if the stream should be suspended when the available bitrate fall | 167 // True if the stream should be suspended when the available bitrate fall |
179 // below the minimum configured bitrate. If this variable is false, the | 168 // below the minimum configured bitrate. If this variable is false, the |
180 // stream may send at a rate higher than the estimated available bitrate. | 169 // stream may send at a rate higher than the estimated available bitrate. |
181 bool suspend_below_min_bitrate = false; | 170 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; | |
187 }; | 171 }; |
188 | 172 |
189 // Starts stream activity. | 173 // Starts stream activity. |
190 // When a stream is active, it can receive, process and deliver packets. | 174 // When a stream is active, it can receive, process and deliver packets. |
191 virtual void Start() = 0; | 175 virtual void Start() = 0; |
192 // Stops stream activity. | 176 // Stops stream activity. |
193 // When a stream is stopped, it can't receive, process or deliver packets. | 177 // When a stream is stopped, it can't receive, process or deliver packets. |
194 virtual void Stop() = 0; | 178 virtual void Stop() = 0; |
195 | 179 |
196 // Gets interface used to insert captured frames. Valid as long as the | 180 // Gets interface used to insert captured frames. Valid as long as the |
197 // VideoSendStream is valid. | 181 // VideoSendStream is valid. |
198 virtual VideoCaptureInput* Input() = 0; | 182 virtual VideoCaptureInput* Input() = 0; |
199 | 183 |
200 // Set which streams to send. Must have at least as many SSRCs as configured | 184 // Set which streams to send. Must have at least as many SSRCs as configured |
201 // in the config. Encoder settings are passed on to the encoder instance along | 185 // in the config. Encoder settings are passed on to the encoder instance along |
202 // with the VideoStream settings. | 186 // with the VideoStream settings. |
203 virtual void ReconfigureVideoEncoder(VideoEncoderConfig config) = 0; | 187 virtual void ReconfigureVideoEncoder(const VideoEncoderConfig& config) = 0; |
204 | 188 |
205 virtual Stats GetStats() = 0; | 189 virtual Stats GetStats() = 0; |
206 | 190 |
207 protected: | 191 protected: |
208 virtual ~VideoSendStream() {} | 192 virtual ~VideoSendStream() {} |
209 }; | 193 }; |
210 | 194 |
211 } // namespace webrtc | 195 } // namespace webrtc |
212 | 196 |
213 #endif // WEBRTC_VIDEO_SEND_STREAM_H_ | 197 #endif // WEBRTC_VIDEO_SEND_STREAM_H_ |
OLD | NEW |