OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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_MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_ | 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_ |
12 #define WEBRTC_MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_ | 12 #define WEBRTC_MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_ |
13 | 13 |
14 #if defined(WEBRTC_WIN) | 14 #if defined(WEBRTC_WIN) |
15 // This is a workaround on Windows due to the fact that some Windows | 15 // This is a workaround on Windows due to the fact that some Windows |
16 // headers define CreateEvent as a macro to either CreateEventW or CreateEventA. | 16 // headers define CreateEvent as a macro to either CreateEventW or CreateEventA. |
17 // This can cause problems since we use that name as well and could | 17 // This can cause problems since we use that name as well and could |
18 // declare them as one thing here whereas in another place a windows header | 18 // declare them as one thing here whereas in another place a windows header |
19 // may have been included and then implementing CreateEvent() causes compilation | 19 // may have been included and then implementing CreateEvent() causes compilation |
20 // errors. So for consistency, we include the main windows header here. | 20 // errors. So for consistency, we include the main windows header here. |
21 #include <windows.h> | 21 #include <windows.h> |
22 #endif | 22 #endif |
23 | 23 |
24 #include "webrtc/modules/include/module.h" | 24 #include "webrtc/modules/include/module.h" |
25 #include "webrtc/modules/include/module_common_types.h" | 25 #include "webrtc/modules/include/module_common_types.h" |
26 #include "webrtc/modules/video_coding/include/video_coding_defines.h" | 26 #include "webrtc/modules/video_coding/include/video_coding_defines.h" |
27 #include "webrtc/system_wrappers/include/event_wrapper.h" | 27 #include "webrtc/system_wrappers/include/event_wrapper.h" |
28 #include "webrtc/video_frame.h" | 28 #include "webrtc/video_frame.h" |
29 | 29 |
30 namespace webrtc | 30 namespace webrtc { |
31 { | |
32 | 31 |
33 class Clock; | 32 class Clock; |
34 class EncodedImageCallback; | 33 class EncodedImageCallback; |
35 class VideoEncoder; | 34 class VideoEncoder; |
36 class VideoDecoder; | 35 class VideoDecoder; |
37 struct CodecSpecificInfo; | 36 struct CodecSpecificInfo; |
38 | 37 |
39 class EventFactory { | 38 class EventFactory { |
40 public: | 39 public: |
41 virtual ~EventFactory() {} | 40 virtual ~EventFactory() {} |
42 | 41 |
43 virtual EventWrapper* CreateEvent() = 0; | 42 virtual EventWrapper* CreateEvent() = 0; |
44 }; | 43 }; |
45 | 44 |
46 class EventFactoryImpl : public EventFactory { | 45 class EventFactoryImpl : public EventFactory { |
47 public: | 46 public: |
48 virtual ~EventFactoryImpl() {} | 47 virtual ~EventFactoryImpl() {} |
49 | 48 |
50 virtual EventWrapper* CreateEvent() { | 49 virtual EventWrapper* CreateEvent() { return EventWrapper::Create(); } |
51 return EventWrapper::Create(); | |
52 } | |
53 }; | 50 }; |
54 | 51 |
55 // Used to indicate which decode with errors mode should be used. | 52 // Used to indicate which decode with errors mode should be used. |
56 enum VCMDecodeErrorMode { | 53 enum VCMDecodeErrorMode { |
57 kNoErrors, // Never decode with errors. Video will freeze | 54 kNoErrors, // Never decode with errors. Video will freeze |
58 // if nack is disabled. | 55 // if nack is disabled. |
59 kSelectiveErrors, // Frames that are determined decodable in | 56 kSelectiveErrors, // Frames that are determined decodable in |
60 // VCMSessionInfo may be decoded with missing | 57 // VCMSessionInfo may be decoded with missing |
61 // packets. As not all incomplete frames will be | 58 // packets. As not all incomplete frames will be |
62 // decodable, video will freeze if nack is disabled. | 59 // decodable, video will freeze if nack is disabled. |
63 kWithErrors // Release frames as needed. Errors may be | 60 kWithErrors // Release frames as needed. Errors may be |
64 // introduced as some encoded frames may not be | 61 // introduced as some encoded frames may not be |
65 // complete. | 62 // complete. |
66 }; | 63 }; |
67 | 64 |
68 class VideoCodingModule : public Module | 65 class VideoCodingModule : public Module { |
69 { | 66 public: |
70 public: | 67 enum SenderNackMode { kNackNone, kNackAll, kNackSelective }; |
71 enum SenderNackMode { | 68 |
72 kNackNone, | 69 enum ReceiverRobustness { kNone, kHardNack, kSoftNack, kReferenceSelection }; |
73 kNackAll, | 70 |
74 kNackSelective | 71 static VideoCodingModule* Create( |
75 }; | 72 Clock* clock, |
76 | 73 VideoEncoderRateObserver* encoder_rate_observer, |
77 enum ReceiverRobustness { | 74 VCMQMSettingsCallback* qm_settings_callback); |
78 kNone, | 75 |
79 kHardNack, | 76 static VideoCodingModule* Create(Clock* clock, EventFactory* event_factory); |
80 kSoftNack, | 77 |
81 kReferenceSelection | 78 static void Destroy(VideoCodingModule* module); |
82 }; | 79 |
83 | 80 // Get number of supported codecs |
84 static VideoCodingModule* Create( | 81 // |
85 Clock* clock, | 82 // Return value : Number of supported codecs |
86 VideoEncoderRateObserver* encoder_rate_observer, | 83 static uint8_t NumberOfCodecs(); |
87 VCMQMSettingsCallback* qm_settings_callback); | 84 |
88 | 85 // Get supported codec settings with using id |
89 static VideoCodingModule* Create(Clock* clock, EventFactory* event_factory); | 86 // |
90 | 87 // Input: |
91 static void Destroy(VideoCodingModule* module); | 88 // - listId : Id or index of the codec to look up |
92 | 89 // - codec : Memory where the codec settings will be stored |
93 // Get number of supported codecs | 90 // |
94 // | 91 // Return value : VCM_OK, on success |
95 // Return value : Number of supported codecs | 92 // VCM_PARAMETER_ERROR if codec not supported or id too |
96 static uint8_t NumberOfCodecs(); | 93 // high |
97 | 94 static int32_t Codec(const uint8_t listId, VideoCodec* codec); |
98 // Get supported codec settings with using id | 95 |
99 // | 96 // Get supported codec settings using codec type |
100 // Input: | 97 // |
101 // - listId : Id or index of the codec to look up | 98 // Input: |
102 // - codec : Memory where the codec settings will be stored | 99 // - codecType : The codec type to get settings for |
103 // | 100 // - codec : Memory where the codec settings will be stored |
104 // Return value : VCM_OK, on success | 101 // |
105 // VCM_PARAMETER_ERROR if codec not supported or id too
high | 102 // Return value : VCM_OK, on success |
106 static int32_t Codec(const uint8_t listId, VideoCodec* codec); | 103 // VCM_PARAMETER_ERROR if codec not supported |
107 | 104 static int32_t Codec(VideoCodecType codecType, VideoCodec* codec); |
108 // Get supported codec settings using codec type | 105 |
109 // | 106 /* |
110 // Input: | 107 * Sender |
111 // - codecType : The codec type to get settings for | 108 */ |
112 // - codec : Memory where the codec settings will be stored | 109 |
113 // | 110 // Registers a codec to be used for encoding. Calling this |
114 // Return value : VCM_OK, on success | 111 // API multiple times overwrites any previously registered codecs. |
115 // VCM_PARAMETER_ERROR if codec not supported | 112 // |
116 static int32_t Codec(VideoCodecType codecType, VideoCodec* codec); | 113 // NOTE: Must be called on the thread that constructed the VCM instance. |
117 | 114 // |
118 /* | 115 // Input: |
119 * Sender | 116 // - sendCodec : Settings for the codec to be registered. |
120 */ | 117 // - numberOfCores : The number of cores the codec is allowed |
121 | 118 // to use. |
122 // Registers a codec to be used for encoding. Calling this | 119 // - maxPayloadSize : The maximum size each payload is allowed |
123 // API multiple times overwrites any previously registered codecs. | 120 // to have. Usually MTU - overhead. |
124 // | 121 // |
125 // NOTE: Must be called on the thread that constructed the VCM instance. | 122 // Return value : VCM_OK, on success. |
126 // | 123 // < 0, on error. |
127 // Input: | 124 virtual int32_t RegisterSendCodec(const VideoCodec* sendCodec, |
128 // - sendCodec : Settings for the codec to be registered. | 125 uint32_t numberOfCores, |
129 // - numberOfCores : The number of cores the codec is allowed | 126 uint32_t maxPayloadSize) = 0; |
130 // to use. | 127 |
131 // - maxPayloadSize : The maximum size each payload is allowed | 128 // Get the current send codec in use. |
132 // to have. Usually MTU - overhead. | 129 // |
133 // | 130 // If a codec has not been set yet, the |id| property of the return value |
134 // Return value : VCM_OK, on success. | 131 // will be 0 and |name| empty. |
135 // < 0, on error. | 132 // |
136 virtual int32_t RegisterSendCodec(const VideoCodec* sendCodec, | 133 // NOTE: This method intentionally does not hold locks and minimizes data |
137 uint32_t numberOfCores, | 134 // copying. It must be called on the thread where the VCM was constructed. |
138 uint32_t maxPayloadSize) = 0; | 135 virtual const VideoCodec& GetSendCodec() const = 0; |
139 | 136 |
140 // Get the current send codec in use. | 137 // DEPRECATED: Use GetSendCodec() instead. |
141 // | 138 // |
142 // If a codec has not been set yet, the |id| property of the return value | 139 // API to get the current send codec in use. |
143 // will be 0 and |name| empty. | 140 // |
144 // | 141 // Input: |
145 // NOTE: This method intentionally does not hold locks and minimizes data | 142 // - currentSendCodec : Address where the sendCodec will be written. |
146 // copying. It must be called on the thread where the VCM was constructed. | 143 // |
147 virtual const VideoCodec& GetSendCodec() const = 0; | 144 // Return value : VCM_OK, on success. |
148 | 145 // < 0, on error. |
149 // DEPRECATED: Use GetSendCodec() instead. | 146 // |
150 // | 147 // NOTE: The returned codec information is not guaranteed to be current when |
151 // API to get the current send codec in use. | 148 // the call returns. This method acquires a lock that is aligned with |
152 // | 149 // video encoding, so it should be assumed to be allowed to block for |
153 // Input: | 150 // several milliseconds. |
154 // - currentSendCodec : Address where the sendCodec will be written. | 151 virtual int32_t SendCodec(VideoCodec* currentSendCodec) const = 0; |
155 // | 152 |
156 // Return value : VCM_OK, on success. | 153 // DEPRECATED: Use GetSendCodec() instead. |
157 // < 0, on error. | 154 // |
158 // | 155 // API to get the current send codec type |
159 // NOTE: The returned codec information is not guaranteed to be current when | 156 // |
160 // the call returns. This method acquires a lock that is aligned with | 157 // Return value : Codec type, on success. |
161 // video encoding, so it should be assumed to be allowed to block for | 158 // kVideoCodecUnknown, on error or if no send codec is set |
162 // several milliseconds. | 159 // NOTE: Same notes apply as for SendCodec() above. |
163 virtual int32_t SendCodec(VideoCodec* currentSendCodec) const = 0; | 160 virtual VideoCodecType SendCodec() const = 0; |
164 | 161 |
165 // DEPRECATED: Use GetSendCodec() instead. | 162 // Register an external encoder object. This can not be used together with |
166 // | 163 // external decoder callbacks. |
167 // API to get the current send codec type | 164 // |
168 // | 165 // Input: |
169 // Return value : Codec type, on success. | 166 // - externalEncoder : Encoder object to be used for encoding frames |
170 // kVideoCodecUnknown, on error or if no send codec is s
et | 167 // inserted |
171 // NOTE: Same notes apply as for SendCodec() above. | 168 // with the AddVideoFrame API. |
172 virtual VideoCodecType SendCodec() const = 0; | 169 // - payloadType : The payload type bound which this encoder is bound |
173 | 170 // to. |
174 // Register an external encoder object. This can not be used together with | 171 // |
175 // external decoder callbacks. | 172 // Return value : VCM_OK, on success. |
176 // | 173 // < 0, on error. |
177 // Input: | 174 // TODO(pbos): Remove return type when unused elsewhere. |
178 // - externalEncoder : Encoder object to be used for encoding frames in
serted | 175 virtual int32_t RegisterExternalEncoder(VideoEncoder* externalEncoder, |
179 // with the AddVideoFrame API. | 176 uint8_t payloadType, |
180 // - payloadType : The payload type bound which this encoder is bou
nd to. | 177 bool internalSource = false) = 0; |
181 // | 178 |
182 // Return value : VCM_OK, on success. | 179 // API to get currently configured encoder target bitrate in bits/s. |
183 // < 0, on error. | 180 // |
184 // TODO(pbos): Remove return type when unused elsewhere. | 181 // Return value : 0, on success. |
185 virtual int32_t RegisterExternalEncoder(VideoEncoder* externalEncoder, | 182 // < 0, on error. |
186 uint8_t payloadType, | 183 virtual int Bitrate(unsigned int* bitrate) const = 0; |
187 bool internalSource = false) = 0; | 184 |
188 | 185 // API to get currently configured encoder target frame rate. |
189 // API to get currently configured encoder target bitrate in bits/s. | 186 // |
190 // | 187 // Return value : 0, on success. |
191 // Return value : 0, on success. | 188 // < 0, on error. |
192 // < 0, on error. | 189 virtual int FrameRate(unsigned int* framerate) const = 0; |
193 virtual int Bitrate(unsigned int* bitrate) const = 0; | 190 |
194 | 191 // Sets the parameters describing the send channel. These parameters are |
195 // API to get currently configured encoder target frame rate. | 192 // inputs to the |
196 // | 193 // Media Optimization inside the VCM and also specifies the target bit rate |
197 // Return value : 0, on success. | 194 // for the |
198 // < 0, on error. | 195 // encoder. Bit rate used by NACK should already be compensated for by the |
199 virtual int FrameRate(unsigned int* framerate) const = 0; | 196 // user. |
200 | 197 // |
201 // Sets the parameters describing the send channel. These parameters are inp
uts to the | 198 // Input: |
202 // Media Optimization inside the VCM and also specifies the target bit rate
for the | 199 // - target_bitrate : The target bitrate for VCM in bits/s. |
203 // encoder. Bit rate used by NACK should already be compensated for by the u
ser. | 200 // - lossRate : Fractions of lost packets the past second. |
204 // | 201 // (loss rate in percent = 100 * packetLoss / |
205 // Input: | 202 // 255) |
206 // - target_bitrate : The target bitrate for VCM in bits/s. | 203 // - rtt : Current round-trip time in ms. |
207 // - lossRate : Fractions of lost packets the past second. | 204 // |
208 // (loss rate in percent = 100 * packetLoss /
255) | 205 // Return value : VCM_OK, on success. |
209 // - rtt : Current round-trip time in ms. | 206 // < 0, on error. |
210 // | 207 virtual int32_t SetChannelParameters(uint32_t target_bitrate, |
211 // Return value : VCM_OK, on success. | 208 uint8_t lossRate, |
212 // < 0, on error. | 209 int64_t rtt) = 0; |
213 virtual int32_t SetChannelParameters(uint32_t target_bitrate, | 210 |
214 uint8_t lossRate, | 211 // Sets the parameters describing the receive channel. These parameters are |
215 int64_t rtt) = 0; | 212 // inputs to the |
216 | 213 // Media Optimization inside the VCM. |
217 // Sets the parameters describing the receive channel. These parameters are
inputs to the | 214 // |
218 // Media Optimization inside the VCM. | 215 // Input: |
219 // | 216 // - rtt : Current round-trip time in ms. |
220 // Input: | 217 // with the most amount available bandwidth in |
221 // - rtt : Current round-trip time in ms. | 218 // a conference |
222 // with the most amount available bandwidth i
n a conference | 219 // scenario |
223 // scenario | 220 // |
224 // | 221 // Return value : VCM_OK, on success. |
225 // Return value : VCM_OK, on success. | 222 // < 0, on error. |
226 // < 0, on error. | 223 virtual int32_t SetReceiveChannelParameters(int64_t rtt) = 0; |
227 virtual int32_t SetReceiveChannelParameters(int64_t rtt) = 0; | 224 |
228 | 225 // Register a transport callback which will be called to deliver the encoded |
229 // Register a transport callback which will be called to deliver the encoded
data and | 226 // data and |
230 // side information. | 227 // side information. |
231 // | 228 // |
232 // Input: | 229 // Input: |
233 // - transport : The callback object to register. | 230 // - transport : The callback object to register. |
234 // | 231 // |
235 // Return value : VCM_OK, on success. | 232 // Return value : VCM_OK, on success. |
236 // < 0, on error. | 233 // < 0, on error. |
237 virtual int32_t RegisterTransportCallback(VCMPacketizationCallback* transpor
t) = 0; | 234 virtual int32_t RegisterTransportCallback( |
238 | 235 VCMPacketizationCallback* transport) = 0; |
239 // Register video output information callback which will be called to delive
r information | 236 |
240 // about the video stream produced by the encoder, for instance the average
frame rate and | 237 // Register video output information callback which will be called to deliver |
241 // bit rate. | 238 // information |
242 // | 239 // about the video stream produced by the encoder, for instance the average |
243 // Input: | 240 // frame rate and |
244 // - outputInformation : The callback object to register. | 241 // bit rate. |
245 // | 242 // |
246 // Return value : VCM_OK, on success. | 243 // Input: |
247 // < 0, on error. | 244 // - outputInformation : The callback object to register. |
248 virtual int32_t RegisterSendStatisticsCallback( | 245 // |
249 VCMSendStatisticsCallback* sendStats) = 0; | 246 // Return value : VCM_OK, on success. |
250 | 247 // < 0, on error. |
251 // Register a video protection callback which will be called to deliver | 248 virtual int32_t RegisterSendStatisticsCallback( |
252 // the requested FEC rate and NACK status (on/off). | 249 VCMSendStatisticsCallback* sendStats) = 0; |
253 // | 250 |
254 // Input: | 251 // Register a video protection callback which will be called to deliver |
255 // - protection : The callback object to register. | 252 // the requested FEC rate and NACK status (on/off). |
256 // | 253 // |
257 // Return value : VCM_OK, on success. | 254 // Input: |
258 // < 0, on error. | 255 // - protection : The callback object to register. |
259 virtual int32_t RegisterProtectionCallback(VCMProtectionCallback* protection
) = 0; | 256 // |
260 | 257 // Return value : VCM_OK, on success. |
261 // Enable or disable a video protection method. | 258 // < 0, on error. |
262 // | 259 virtual int32_t RegisterProtectionCallback( |
263 // Input: | 260 VCMProtectionCallback* protection) = 0; |
264 // - videoProtection : The method to enable or disable. | 261 |
265 // - enable : True if the method should be enabled, false if | 262 // Enable or disable a video protection method. |
266 // it should be disabled. | 263 // |
267 // | 264 // Input: |
268 // Return value : VCM_OK, on success. | 265 // - videoProtection : The method to enable or disable. |
269 // < 0, on error. | 266 // - enable : True if the method should be enabled, false if |
270 virtual int32_t SetVideoProtection(VCMVideoProtection videoProtection, | 267 // it should be disabled. |
271 bool enable) = 0; | 268 // |
272 | 269 // Return value : VCM_OK, on success. |
273 // Add one raw video frame to the encoder. This function does all the necess
ary | 270 // < 0, on error. |
274 // processing, then decides what frame type to encode, or if the frame shoul
d be | 271 virtual int32_t SetVideoProtection(VCMVideoProtection videoProtection, |
275 // dropped. If the frame should be encoded it passes the frame to the encode
r | 272 bool enable) = 0; |
276 // before it returns. | 273 |
277 // | 274 // Add one raw video frame to the encoder. This function does all the |
278 // Input: | 275 // necessary |
279 // - videoFrame : Video frame to encode. | 276 // processing, then decides what frame type to encode, or if the frame should |
280 // - codecSpecificInfo : Extra codec information, e.g., pre-parsed in-b
and signaling. | 277 // be |
281 // | 278 // dropped. If the frame should be encoded it passes the frame to the encoder |
282 // Return value : VCM_OK, on success. | 279 // before it returns. |
283 // < 0, on error. | 280 // |
284 virtual int32_t AddVideoFrame( | 281 // Input: |
285 const VideoFrame& videoFrame, | 282 // - videoFrame : Video frame to encode. |
286 const VideoContentMetrics* contentMetrics = NULL, | 283 // - codecSpecificInfo : Extra codec information, e.g., pre-parsed |
287 const CodecSpecificInfo* codecSpecificInfo = NULL) = 0; | 284 // in-band signaling. |
288 | 285 // |
289 // Next frame encoded should be an intra frame (keyframe). | 286 // Return value : VCM_OK, on success. |
290 // | 287 // < 0, on error. |
291 // Return value : VCM_OK, on success. | 288 virtual int32_t AddVideoFrame( |
292 // < 0, on error. | 289 const VideoFrame& videoFrame, |
293 virtual int32_t IntraFrameRequest(int stream_index) = 0; | 290 const VideoContentMetrics* contentMetrics = NULL, |
294 | 291 const CodecSpecificInfo* codecSpecificInfo = NULL) = 0; |
295 // Frame Dropper enable. Can be used to disable the frame dropping when the
encoder | 292 |
296 // over-uses its bit rate. This API is designed to be used when the encoded
frames | 293 // Next frame encoded should be an intra frame (keyframe). |
297 // are supposed to be stored to an AVI file, or when the I420 codec is used
and the | 294 // |
298 // target bit rate shouldn't affect the frame rate. | 295 // Return value : VCM_OK, on success. |
299 // | 296 // < 0, on error. |
300 // Input: | 297 virtual int32_t IntraFrameRequest(int stream_index) = 0; |
301 // - enable : True to enable the setting, false to disable i
t. | 298 |
302 // | 299 // Frame Dropper enable. Can be used to disable the frame dropping when the |
303 // Return value : VCM_OK, on success. | 300 // encoder |
304 // < 0, on error. | 301 // over-uses its bit rate. This API is designed to be used when the encoded |
305 virtual int32_t EnableFrameDropper(bool enable) = 0; | 302 // frames |
306 | 303 // are supposed to be stored to an AVI file, or when the I420 codec is used |
307 | 304 // and the |
308 /* | 305 // target bit rate shouldn't affect the frame rate. |
309 * Receiver | 306 // |
310 */ | 307 // Input: |
311 | 308 // - enable : True to enable the setting, false to disable it. |
312 // Register possible receive codecs, can be called multiple times for differ
ent codecs. | 309 // |
313 // The module will automatically switch between registered codecs depending
on the | 310 // Return value : VCM_OK, on success. |
314 // payload type of incoming frames. The actual decoder will be created when
needed. | 311 // < 0, on error. |
315 // | 312 virtual int32_t EnableFrameDropper(bool enable) = 0; |
316 // Input: | 313 |
317 // - receiveCodec : Settings for the codec to be registered. | 314 /* |
318 // - numberOfCores : Number of CPU cores that the decoder is allowe
d to use. | 315 * Receiver |
319 // - requireKeyFrame : Set this to true if you don't want any delta f
rames | 316 */ |
320 // to be decoded until the first key frame has be
en decoded. | 317 |
321 // | 318 // Register possible receive codecs, can be called multiple times for |
322 // Return value : VCM_OK, on success. | 319 // different codecs. |
323 // < 0, on error. | 320 // The module will automatically switch between registered codecs depending on |
324 virtual int32_t RegisterReceiveCodec(const VideoCodec* receiveCodec, | 321 // the |
325 int32_t numberOfCores, | 322 // payload type of incoming frames. The actual decoder will be created when |
326 bool requireKeyFrame = false) = 0; | 323 // needed. |
327 | 324 // |
328 // Register an externally defined decoder/renderer object. Can be a decoder
only or a | 325 // Input: |
329 // decoder coupled with a renderer. Note that RegisterReceiveCodec must be c
alled to | 326 // - receiveCodec : Settings for the codec to be registered. |
330 // be used for decoding incoming streams. | 327 // - numberOfCores : Number of CPU cores that the decoder is allowed |
331 // | 328 // to use. |
332 // Input: | 329 // - requireKeyFrame : Set this to true if you don't want any delta |
333 // - externalDecoder : The external decoder/renderer object. | 330 // frames |
334 // - payloadType : The payload type which this decoder shoul
d be | 331 // to be decoded until the first key frame has been |
335 // registered to. | 332 // decoded. |
336 // | 333 // |
337 virtual void RegisterExternalDecoder(VideoDecoder* externalDecoder, | 334 // Return value : VCM_OK, on success. |
338 uint8_t payloadType) = 0; | 335 // < 0, on error. |
339 | 336 virtual int32_t RegisterReceiveCodec(const VideoCodec* receiveCodec, |
340 // Register a receive callback. Will be called whenever there is a new frame
ready | 337 int32_t numberOfCores, |
341 // for rendering. | 338 bool requireKeyFrame = false) = 0; |
342 // | 339 |
343 // Input: | 340 // Register an externally defined decoder/renderer object. Can be a decoder |
344 // - receiveCallback : The callback object to be used by the mod
ule when a | 341 // only or a |
345 // frame is ready for rendering. | 342 // decoder coupled with a renderer. Note that RegisterReceiveCodec must be |
346 // De-register with a NULL pointer. | 343 // called to |
347 // | 344 // be used for decoding incoming streams. |
348 // Return value : VCM_OK, on success. | 345 // |
349 // < 0, on error. | 346 // Input: |
350 virtual int32_t RegisterReceiveCallback(VCMReceiveCallback* receiveCallback)
= 0; | 347 // - externalDecoder : The external decoder/renderer object. |
351 | 348 // - payloadType : The payload type which this decoder should |
352 // Register a receive statistics callback which will be called to deliver in
formation | 349 // be |
353 // about the video stream received by the receiving side of the VCM, for ins
tance the | 350 // registered to. |
354 // average frame rate and bit rate. | 351 // |
355 // | 352 virtual void RegisterExternalDecoder(VideoDecoder* externalDecoder, |
356 // Input: | 353 uint8_t payloadType) = 0; |
357 // - receiveStats : The callback object to register. | 354 |
358 // | 355 // Register a receive callback. Will be called whenever there is a new frame |
359 // Return value : VCM_OK, on success. | 356 // ready |
360 // < 0, on error. | 357 // for rendering. |
361 virtual int32_t RegisterReceiveStatisticsCallback( | 358 // |
362 VCMReceiveStatisticsCallback* receiveStats) = 0; | 359 // Input: |
363 | 360 // - receiveCallback : The callback object to be used by the |
364 // Register a decoder timing callback which will be called to deliver | 361 // module when a |
365 // information about the timing of the decoder in the receiving side of the | 362 // frame is ready for rendering. |
366 // VCM, for instance the current and maximum frame decode latency. | 363 // De-register with a NULL pointer. |
367 // | 364 // |
368 // Input: | 365 // Return value : VCM_OK, on success. |
369 // - decoderTiming : The callback object to register. | 366 // < 0, on error. |
370 // | 367 virtual int32_t RegisterReceiveCallback( |
371 // Return value : VCM_OK, on success. | 368 VCMReceiveCallback* receiveCallback) = 0; |
372 // < 0, on error. | 369 |
373 virtual int32_t RegisterDecoderTimingCallback( | 370 // Register a receive statistics callback which will be called to deliver |
374 VCMDecoderTimingCallback* decoderTiming) = 0; | 371 // information |
375 | 372 // about the video stream received by the receiving side of the VCM, for |
376 // Register a frame type request callback. This callback will be called when
the | 373 // instance the |
377 // module needs to request specific frame types from the send side. | 374 // average frame rate and bit rate. |
378 // | 375 // |
379 // Input: | 376 // Input: |
380 // - frameTypeCallback : The callback object to be used by the mod
ule when | 377 // - receiveStats : The callback object to register. |
381 // requesting a specific type of frame from
the send side. | 378 // |
382 // De-register with a NULL pointer. | 379 // Return value : VCM_OK, on success. |
383 // | 380 // < 0, on error. |
384 // Return value : VCM_OK, on success. | 381 virtual int32_t RegisterReceiveStatisticsCallback( |
385 // < 0, on error. | 382 VCMReceiveStatisticsCallback* receiveStats) = 0; |
386 virtual int32_t RegisterFrameTypeCallback( | 383 |
387 VCMFrameTypeCallback* frameTypeCallback) = 0; | 384 // Register a decoder timing callback which will be called to deliver |
388 | 385 // information about the timing of the decoder in the receiving side of the |
389 // Registers a callback which is called whenever the receive side of the VCM | 386 // VCM, for instance the current and maximum frame decode latency. |
390 // encounters holes in the packet sequence and needs packets to be retransmi
tted. | 387 // |
391 // | 388 // Input: |
392 // Input: | 389 // - decoderTiming : The callback object to register. |
393 // - callback : The callback to be registered in the VCM. | 390 // |
394 // | 391 // Return value : VCM_OK, on success. |
395 // Return value : VCM_OK, on success. | 392 // < 0, on error. |
396 // <0, on error. | 393 virtual int32_t RegisterDecoderTimingCallback( |
397 virtual int32_t RegisterPacketRequestCallback( | 394 VCMDecoderTimingCallback* decoderTiming) = 0; |
398 VCMPacketRequestCallback* callback) = 0; | 395 |
399 | 396 // Register a frame type request callback. This callback will be called when |
400 // Waits for the next frame in the jitter buffer to become complete | 397 // the |
401 // (waits no longer than maxWaitTimeMs), then passes it to the decoder for d
ecoding. | 398 // module needs to request specific frame types from the send side. |
402 // Should be called as often as possible to get the most out of the decoder. | 399 // |
403 // | 400 // Input: |
404 // Return value : VCM_OK, on success. | 401 // - frameTypeCallback : The callback object to be used by the |
405 // < 0, on error. | 402 // module when |
406 virtual int32_t Decode(uint16_t maxWaitTimeMs = 200) = 0; | 403 // requesting a specific type of frame from |
407 | 404 // the send side. |
408 // Registers a callback which conveys the size of the render buffer. | 405 // De-register with a NULL pointer. |
409 virtual int RegisterRenderBufferSizeCallback( | 406 // |
410 VCMRenderBufferSizeCallback* callback) = 0; | 407 // Return value : VCM_OK, on success. |
411 | 408 // < 0, on error. |
412 // Reset the decoder state to the initial state. | 409 virtual int32_t RegisterFrameTypeCallback( |
413 // | 410 VCMFrameTypeCallback* frameTypeCallback) = 0; |
414 // Return value : VCM_OK, on success. | 411 |
415 // < 0, on error. | 412 // Registers a callback which is called whenever the receive side of the VCM |
416 virtual int32_t ResetDecoder() = 0; | 413 // encounters holes in the packet sequence and needs packets to be |
417 | 414 // retransmitted. |
418 // API to get the codec which is currently used for decoding by the module. | 415 // |
419 // | 416 // Input: |
420 // Input: | 417 // - callback : The callback to be registered in the VCM. |
421 // - currentReceiveCodec : Settings for the codec to be registered
. | 418 // |
422 // | 419 // Return value : VCM_OK, on success. |
423 // Return value : VCM_OK, on success. | 420 // <0, on error. |
424 // < 0, on error. | 421 virtual int32_t RegisterPacketRequestCallback( |
425 virtual int32_t ReceiveCodec(VideoCodec* currentReceiveCodec) const = 0; | 422 VCMPacketRequestCallback* callback) = 0; |
426 | 423 |
427 // API to get the codec type currently used for decoding by the module. | 424 // Waits for the next frame in the jitter buffer to become complete |
428 // | 425 // (waits no longer than maxWaitTimeMs), then passes it to the decoder for |
429 // Return value : codecy type, on success. | 426 // decoding. |
430 // kVideoCodecUnknown, on error or if no receive codec i
s registered | 427 // Should be called as often as possible to get the most out of the decoder. |
431 virtual VideoCodecType ReceiveCodec() const = 0; | 428 // |
432 | 429 // Return value : VCM_OK, on success. |
433 // Insert a parsed packet into the receiver side of the module. Will be plac
ed in the | 430 // < 0, on error. |
434 // jitter buffer waiting for the frame to become complete. Returns as soon a
s the packet | 431 virtual int32_t Decode(uint16_t maxWaitTimeMs = 200) = 0; |
435 // has been placed in the jitter buffer. | 432 |
436 // | 433 // Registers a callback which conveys the size of the render buffer. |
437 // Input: | 434 virtual int RegisterRenderBufferSizeCallback( |
438 // - incomingPayload : Payload of the packet. | 435 VCMRenderBufferSizeCallback* callback) = 0; |
439 // - payloadLength : Length of the payload. | 436 |
440 // - rtpInfo : The parsed header. | 437 // Reset the decoder state to the initial state. |
441 // | 438 // |
442 // Return value : VCM_OK, on success. | 439 // Return value : VCM_OK, on success. |
443 // < 0, on error. | 440 // < 0, on error. |
444 virtual int32_t IncomingPacket(const uint8_t* incomingPayload, | 441 virtual int32_t ResetDecoder() = 0; |
445 size_t payloadLength, | 442 |
446 const WebRtcRTPHeader& rtpInfo) = 0; | 443 // API to get the codec which is currently used for decoding by the module. |
447 | 444 // |
448 // Minimum playout delay (Used for lip-sync). This is the minimum delay requ
ired | 445 // Input: |
449 // to sync with audio. Not included in VideoCodingModule::Delay() | 446 // - currentReceiveCodec : Settings for the codec to be registered. |
450 // Defaults to 0 ms. | 447 // |
451 // | 448 // Return value : VCM_OK, on success. |
452 // Input: | 449 // < 0, on error. |
453 // - minPlayoutDelayMs : Additional delay in ms. | 450 virtual int32_t ReceiveCodec(VideoCodec* currentReceiveCodec) const = 0; |
454 // | 451 |
455 // Return value : VCM_OK, on success. | 452 // API to get the codec type currently used for decoding by the module. |
456 // < 0, on error. | 453 // |
457 virtual int32_t SetMinimumPlayoutDelay(uint32_t minPlayoutDelayMs) = 0; | 454 // Return value : codecy type, on success. |
458 | 455 // kVideoCodecUnknown, on error or if no receive codec is |
459 // Set the time required by the renderer to render a frame. | 456 // registered |
460 // | 457 virtual VideoCodecType ReceiveCodec() const = 0; |
461 // Input: | 458 |
462 // - timeMS : The time in ms required by the renderer to render
a frame. | 459 // Insert a parsed packet into the receiver side of the module. Will be placed |
463 // | 460 // in the |
464 // Return value : VCM_OK, on success. | 461 // jitter buffer waiting for the frame to become complete. Returns as soon as |
465 // < 0, on error. | 462 // the packet |
466 virtual int32_t SetRenderDelay(uint32_t timeMS) = 0; | 463 // has been placed in the jitter buffer. |
467 | 464 // |
468 // The total delay desired by the VCM. Can be less than the minimum | 465 // Input: |
469 // delay set with SetMinimumPlayoutDelay. | 466 // - incomingPayload : Payload of the packet. |
470 // | 467 // - payloadLength : Length of the payload. |
471 // Return value : Total delay in ms, on success. | 468 // - rtpInfo : The parsed header. |
472 // < 0, on error. | 469 // |
473 virtual int32_t Delay() const = 0; | 470 // Return value : VCM_OK, on success. |
474 | 471 // < 0, on error. |
475 // Returns the number of packets discarded by the jitter buffer due to being | 472 virtual int32_t IncomingPacket(const uint8_t* incomingPayload, |
476 // too late. This can include duplicated packets which arrived after the | 473 size_t payloadLength, |
477 // frame was sent to the decoder. Therefore packets which were prematurely | 474 const WebRtcRTPHeader& rtpInfo) = 0; |
478 // NACKed will be counted. | 475 |
479 virtual uint32_t DiscardedPackets() const = 0; | 476 // Minimum playout delay (Used for lip-sync). This is the minimum delay |
480 | 477 // required |
481 | 478 // to sync with audio. Not included in VideoCodingModule::Delay() |
482 // Robustness APIs | 479 // Defaults to 0 ms. |
483 | 480 // |
484 // Set the receiver robustness mode. The mode decides how the receiver | 481 // Input: |
485 // responds to losses in the stream. The type of counter-measure (soft or | 482 // - minPlayoutDelayMs : Additional delay in ms. |
486 // hard NACK, dual decoder, RPS, etc.) is selected through the | 483 // |
487 // robustnessMode parameter. The errorMode parameter decides if it is | 484 // Return value : VCM_OK, on success. |
488 // allowed to display frames corrupted by losses. Note that not all | 485 // < 0, on error. |
489 // combinations of the two parameters are feasible. An error will be | 486 virtual int32_t SetMinimumPlayoutDelay(uint32_t minPlayoutDelayMs) = 0; |
490 // returned for invalid combinations. | 487 |
491 // Input: | 488 // Set the time required by the renderer to render a frame. |
492 // - robustnessMode : selected robustness mode. | 489 // |
493 // - errorMode : selected error mode. | 490 // Input: |
494 // | 491 // - timeMS : The time in ms required by the renderer to render a |
495 // Return value : VCM_OK, on success; | 492 // frame. |
496 // < 0, on error. | 493 // |
497 virtual int SetReceiverRobustnessMode(ReceiverRobustness robustnessMode, | 494 // Return value : VCM_OK, on success. |
498 VCMDecodeErrorMode errorMode) = 0; | 495 // < 0, on error. |
499 | 496 virtual int32_t SetRenderDelay(uint32_t timeMS) = 0; |
500 // Set the decode error mode. The mode decides which errors (if any) are | 497 |
501 // allowed in decodable frames. Note that setting decode_error_mode to | 498 // The total delay desired by the VCM. Can be less than the minimum |
502 // anything other than kWithErrors without enabling nack will cause | 499 // delay set with SetMinimumPlayoutDelay. |
503 // long-term freezes (resulting from frequent key frame requests) if | 500 // |
504 // packet loss occurs. | 501 // Return value : Total delay in ms, on success. |
505 virtual void SetDecodeErrorMode(VCMDecodeErrorMode decode_error_mode) = 0; | 502 // < 0, on error. |
506 | 503 virtual int32_t Delay() const = 0; |
507 // Sets the maximum number of sequence numbers that we are allowed to NACK | 504 |
508 // and the oldest sequence number that we will consider to NACK. If a | 505 // Returns the number of packets discarded by the jitter buffer due to being |
509 // sequence number older than |max_packet_age_to_nack| is missing | 506 // too late. This can include duplicated packets which arrived after the |
510 // a key frame will be requested. A key frame will also be requested if the | 507 // frame was sent to the decoder. Therefore packets which were prematurely |
511 // time of incomplete or non-continuous frames in the jitter buffer is above | 508 // NACKed will be counted. |
512 // |max_incomplete_time_ms|. | 509 virtual uint32_t DiscardedPackets() const = 0; |
513 virtual void SetNackSettings(size_t max_nack_list_size, | 510 |
514 int max_packet_age_to_nack, | 511 // Robustness APIs |
515 int max_incomplete_time_ms) = 0; | 512 |
516 | 513 // Set the receiver robustness mode. The mode decides how the receiver |
517 // Setting a desired delay to the VCM receiver. Video rendering will be | 514 // responds to losses in the stream. The type of counter-measure (soft or |
518 // delayed by at least desired_delay_ms. | 515 // hard NACK, dual decoder, RPS, etc.) is selected through the |
519 virtual int SetMinReceiverDelay(int desired_delay_ms) = 0; | 516 // robustnessMode parameter. The errorMode parameter decides if it is |
520 | 517 // allowed to display frames corrupted by losses. Note that not all |
521 // Lets the sender suspend video when the rate drops below | 518 // combinations of the two parameters are feasible. An error will be |
522 // |threshold_bps|, and turns back on when the rate goes back up above | 519 // returned for invalid combinations. |
523 // |threshold_bps| + |window_bps|. | 520 // Input: |
524 virtual void SuspendBelowMinBitrate() = 0; | 521 // - robustnessMode : selected robustness mode. |
525 | 522 // - errorMode : selected error mode. |
526 // Returns true if SuspendBelowMinBitrate is engaged and the video has been | 523 // |
527 // suspended due to bandwidth limitations; otherwise false. | 524 // Return value : VCM_OK, on success; |
528 virtual bool VideoSuspended() const = 0; | 525 // < 0, on error. |
529 | 526 virtual int SetReceiverRobustnessMode(ReceiverRobustness robustnessMode, |
530 virtual void RegisterPreDecodeImageCallback( | 527 VCMDecodeErrorMode errorMode) = 0; |
531 EncodedImageCallback* observer) = 0; | 528 |
532 virtual void RegisterPostEncodeImageCallback( | 529 // Set the decode error mode. The mode decides which errors (if any) are |
533 EncodedImageCallback* post_encode_callback) = 0; | 530 // allowed in decodable frames. Note that setting decode_error_mode to |
534 // Releases pending decode calls, permitting faster thread shutdown. | 531 // anything other than kWithErrors without enabling nack will cause |
535 virtual void TriggerDecoderShutdown() = 0; | 532 // long-term freezes (resulting from frequent key frame requests) if |
| 533 // packet loss occurs. |
| 534 virtual void SetDecodeErrorMode(VCMDecodeErrorMode decode_error_mode) = 0; |
| 535 |
| 536 // Sets the maximum number of sequence numbers that we are allowed to NACK |
| 537 // and the oldest sequence number that we will consider to NACK. If a |
| 538 // sequence number older than |max_packet_age_to_nack| is missing |
| 539 // a key frame will be requested. A key frame will also be requested if the |
| 540 // time of incomplete or non-continuous frames in the jitter buffer is above |
| 541 // |max_incomplete_time_ms|. |
| 542 virtual void SetNackSettings(size_t max_nack_list_size, |
| 543 int max_packet_age_to_nack, |
| 544 int max_incomplete_time_ms) = 0; |
| 545 |
| 546 // Setting a desired delay to the VCM receiver. Video rendering will be |
| 547 // delayed by at least desired_delay_ms. |
| 548 virtual int SetMinReceiverDelay(int desired_delay_ms) = 0; |
| 549 |
| 550 // Lets the sender suspend video when the rate drops below |
| 551 // |threshold_bps|, and turns back on when the rate goes back up above |
| 552 // |threshold_bps| + |window_bps|. |
| 553 virtual void SuspendBelowMinBitrate() = 0; |
| 554 |
| 555 // Returns true if SuspendBelowMinBitrate is engaged and the video has been |
| 556 // suspended due to bandwidth limitations; otherwise false. |
| 557 virtual bool VideoSuspended() const = 0; |
| 558 |
| 559 virtual void RegisterPreDecodeImageCallback( |
| 560 EncodedImageCallback* observer) = 0; |
| 561 virtual void RegisterPostEncodeImageCallback( |
| 562 EncodedImageCallback* post_encode_callback) = 0; |
| 563 // Releases pending decode calls, permitting faster thread shutdown. |
| 564 virtual void TriggerDecoderShutdown() = 0; |
536 }; | 565 }; |
537 | 566 |
538 } // namespace webrtc | 567 } // namespace webrtc |
539 | 568 |
540 #endif // WEBRTC_MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_ | 569 #endif // WEBRTC_MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_ |
OLD | NEW |