Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_ |
| 12 | #define MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_ |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 13 | |
| 14 | #if defined(WEBRTC_WIN) |
| 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. |
| 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 |
| 19 | // may have been included and then implementing CreateEvent() causes compilation |
| 20 | // errors. So for consistency, we include the main windows header here. |
| 21 | #include <windows.h> |
| 22 | #endif |
| 23 | |
Ying Wang | 3b790f3 | 2018-01-19 17:58:57 +0100 | [diff] [blame^] | 24 | #include "api/fec_controller.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 25 | #include "api/video/video_frame.h" |
| 26 | #include "modules/include/module.h" |
| 27 | #include "modules/include/module_common_types.h" |
| 28 | #include "modules/video_coding/include/video_coding_defines.h" |
| 29 | #include "system_wrappers/include/event_wrapper.h" |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 30 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 31 | namespace webrtc { |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 32 | |
| 33 | class Clock; |
| 34 | class EncodedImageCallback; |
Peter Boström | ad6fc5a | 2016-05-12 03:01:31 +0200 | [diff] [blame] | 35 | // TODO(pbos): Remove VCMQMSettingsCallback completely. This might be done by |
| 36 | // removing the VCM and use VideoSender/VideoReceiver as a public interface |
| 37 | // directly. |
| 38 | class VCMQMSettingsCallback; |
Erik Språng | 08127a9 | 2016-11-16 16:41:30 +0100 | [diff] [blame] | 39 | class VideoBitrateAllocator; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 40 | class VideoEncoder; |
| 41 | class VideoDecoder; |
| 42 | struct CodecSpecificInfo; |
| 43 | |
| 44 | class EventFactory { |
| 45 | public: |
| 46 | virtual ~EventFactory() {} |
| 47 | |
| 48 | virtual EventWrapper* CreateEvent() = 0; |
| 49 | }; |
| 50 | |
| 51 | class EventFactoryImpl : public EventFactory { |
| 52 | public: |
| 53 | virtual ~EventFactoryImpl() {} |
| 54 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 55 | virtual EventWrapper* CreateEvent() { return EventWrapper::Create(); } |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | // Used to indicate which decode with errors mode should be used. |
| 59 | enum VCMDecodeErrorMode { |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 60 | kNoErrors, // Never decode with errors. Video will freeze |
| 61 | // if nack is disabled. |
| 62 | kSelectiveErrors, // Frames that are determined decodable in |
| 63 | // VCMSessionInfo may be decoded with missing |
| 64 | // packets. As not all incomplete frames will be |
| 65 | // decodable, video will freeze if nack is disabled. |
| 66 | kWithErrors // Release frames as needed. Errors may be |
| 67 | // introduced as some encoded frames may not be |
| 68 | // complete. |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 69 | }; |
| 70 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 71 | class VideoCodingModule : public Module { |
| 72 | public: |
| 73 | enum SenderNackMode { kNackNone, kNackAll, kNackSelective }; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 74 | |
tommi | a5c18d7 | 2017-03-20 10:43:23 -0700 | [diff] [blame] | 75 | // DEPRECATED. |
perkj | f5b2e51 | 2016-07-05 08:34:04 -0700 | [diff] [blame] | 76 | static VideoCodingModule* Create(Clock* clock, EventFactory* event_factory); |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 77 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 78 | /* |
| 79 | * Sender |
| 80 | */ |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 81 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 82 | // Registers a codec to be used for encoding. Calling this |
| 83 | // API multiple times overwrites any previously registered codecs. |
| 84 | // |
| 85 | // NOTE: Must be called on the thread that constructed the VCM instance. |
| 86 | // |
| 87 | // Input: |
| 88 | // - sendCodec : Settings for the codec to be registered. |
| 89 | // - numberOfCores : The number of cores the codec is allowed |
| 90 | // to use. |
| 91 | // - maxPayloadSize : The maximum size each payload is allowed |
| 92 | // to have. Usually MTU - overhead. |
| 93 | // |
| 94 | // Return value : VCM_OK, on success. |
| 95 | // < 0, on error. |
| 96 | virtual int32_t RegisterSendCodec(const VideoCodec* sendCodec, |
| 97 | uint32_t numberOfCores, |
| 98 | uint32_t maxPayloadSize) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 99 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 100 | // Register an external encoder object. This can not be used together with |
| 101 | // external decoder callbacks. |
| 102 | // |
| 103 | // Input: |
| 104 | // - externalEncoder : Encoder object to be used for encoding frames |
| 105 | // inserted |
| 106 | // with the AddVideoFrame API. |
| 107 | // - payloadType : The payload type bound which this encoder is bound |
| 108 | // to. |
| 109 | // |
| 110 | // Return value : VCM_OK, on success. |
| 111 | // < 0, on error. |
| 112 | // TODO(pbos): Remove return type when unused elsewhere. |
| 113 | virtual int32_t RegisterExternalEncoder(VideoEncoder* externalEncoder, |
| 114 | uint8_t payloadType, |
| 115 | bool internalSource = false) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 116 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 117 | // API to get currently configured encoder target bitrate in bits/s. |
| 118 | // |
| 119 | // Return value : 0, on success. |
| 120 | // < 0, on error. |
| 121 | virtual int Bitrate(unsigned int* bitrate) const = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 122 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 123 | // API to get currently configured encoder target frame rate. |
| 124 | // |
| 125 | // Return value : 0, on success. |
| 126 | // < 0, on error. |
| 127 | virtual int FrameRate(unsigned int* framerate) const = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 128 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 129 | // Sets the parameters describing the send channel. These parameters are |
| 130 | // inputs to the |
| 131 | // Media Optimization inside the VCM and also specifies the target bit rate |
| 132 | // for the |
| 133 | // encoder. Bit rate used by NACK should already be compensated for by the |
| 134 | // user. |
| 135 | // |
| 136 | // Input: |
| 137 | // - target_bitrate : The target bitrate for VCM in bits/s. |
| 138 | // - lossRate : Fractions of lost packets the past second. |
| 139 | // (loss rate in percent = 100 * packetLoss / |
| 140 | // 255) |
| 141 | // - rtt : Current round-trip time in ms. |
| 142 | // |
| 143 | // Return value : VCM_OK, on success. |
| 144 | // < 0, on error. |
| 145 | virtual int32_t SetChannelParameters(uint32_t target_bitrate, |
| 146 | uint8_t lossRate, |
| 147 | int64_t rtt) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 148 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 149 | // Sets the parameters describing the receive channel. These parameters are |
| 150 | // inputs to the |
| 151 | // Media Optimization inside the VCM. |
| 152 | // |
| 153 | // Input: |
| 154 | // - rtt : Current round-trip time in ms. |
| 155 | // with the most amount available bandwidth in |
| 156 | // a conference |
| 157 | // scenario |
| 158 | // |
| 159 | // Return value : VCM_OK, on success. |
| 160 | // < 0, on error. |
| 161 | virtual int32_t SetReceiveChannelParameters(int64_t rtt) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 162 | |
Per | 69b332d | 2016-06-02 15:45:42 +0200 | [diff] [blame] | 163 | // Deprecated: This method currently does not have any effect. |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 164 | // Register a video protection callback which will be called to deliver |
| 165 | // the requested FEC rate and NACK status (on/off). |
Per | 69b332d | 2016-06-02 15:45:42 +0200 | [diff] [blame] | 166 | // TODO(perkj): Remove once no projects use it. |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 167 | virtual int32_t RegisterProtectionCallback( |
| 168 | VCMProtectionCallback* protection) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 169 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 170 | // Enable or disable a video protection method. |
| 171 | // |
| 172 | // Input: |
| 173 | // - videoProtection : The method to enable or disable. |
| 174 | // - enable : True if the method should be enabled, false if |
| 175 | // it should be disabled. |
| 176 | // |
| 177 | // Return value : VCM_OK, on success. |
| 178 | // < 0, on error. |
| 179 | virtual int32_t SetVideoProtection(VCMVideoProtection videoProtection, |
| 180 | bool enable) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 181 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 182 | // Add one raw video frame to the encoder. This function does all the |
| 183 | // necessary |
| 184 | // processing, then decides what frame type to encode, or if the frame should |
| 185 | // be |
| 186 | // dropped. If the frame should be encoded it passes the frame to the encoder |
| 187 | // before it returns. |
| 188 | // |
| 189 | // Input: |
| 190 | // - videoFrame : Video frame to encode. |
| 191 | // - codecSpecificInfo : Extra codec information, e.g., pre-parsed |
| 192 | // in-band signaling. |
| 193 | // |
| 194 | // Return value : VCM_OK, on success. |
| 195 | // < 0, on error. |
| 196 | virtual int32_t AddVideoFrame( |
| 197 | const VideoFrame& videoFrame, |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 198 | const CodecSpecificInfo* codecSpecificInfo = NULL) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 199 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 200 | // Next frame encoded should be an intra frame (keyframe). |
| 201 | // |
| 202 | // Return value : VCM_OK, on success. |
| 203 | // < 0, on error. |
perkj | 600246e | 2016-05-04 11:26:51 -0700 | [diff] [blame] | 204 | virtual int32_t IntraFrameRequest(size_t stream_index) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 205 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 206 | // Frame Dropper enable. Can be used to disable the frame dropping when the |
| 207 | // encoder |
| 208 | // over-uses its bit rate. This API is designed to be used when the encoded |
| 209 | // frames |
| 210 | // are supposed to be stored to an AVI file, or when the I420 codec is used |
| 211 | // and the |
| 212 | // target bit rate shouldn't affect the frame rate. |
| 213 | // |
| 214 | // Input: |
| 215 | // - enable : True to enable the setting, false to disable it. |
| 216 | // |
| 217 | // Return value : VCM_OK, on success. |
| 218 | // < 0, on error. |
| 219 | virtual int32_t EnableFrameDropper(bool enable) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 220 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 221 | /* |
| 222 | * Receiver |
| 223 | */ |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 224 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 225 | // Register possible receive codecs, can be called multiple times for |
| 226 | // different codecs. |
| 227 | // The module will automatically switch between registered codecs depending on |
| 228 | // the |
| 229 | // payload type of incoming frames. The actual decoder will be created when |
| 230 | // needed. |
| 231 | // |
| 232 | // Input: |
| 233 | // - receiveCodec : Settings for the codec to be registered. |
| 234 | // - numberOfCores : Number of CPU cores that the decoder is allowed |
| 235 | // to use. |
| 236 | // - requireKeyFrame : Set this to true if you don't want any delta |
| 237 | // frames |
| 238 | // to be decoded until the first key frame has been |
| 239 | // decoded. |
| 240 | // |
| 241 | // Return value : VCM_OK, on success. |
| 242 | // < 0, on error. |
| 243 | virtual int32_t RegisterReceiveCodec(const VideoCodec* receiveCodec, |
| 244 | int32_t numberOfCores, |
| 245 | bool requireKeyFrame = false) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 246 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 247 | // Register an externally defined decoder/renderer object. Can be a decoder |
| 248 | // only or a |
| 249 | // decoder coupled with a renderer. Note that RegisterReceiveCodec must be |
| 250 | // called to |
| 251 | // be used for decoding incoming streams. |
| 252 | // |
| 253 | // Input: |
| 254 | // - externalDecoder : The external decoder/renderer object. |
| 255 | // - payloadType : The payload type which this decoder should |
| 256 | // be |
| 257 | // registered to. |
| 258 | // |
| 259 | virtual void RegisterExternalDecoder(VideoDecoder* externalDecoder, |
| 260 | uint8_t payloadType) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 261 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 262 | // Register a receive callback. Will be called whenever there is a new frame |
| 263 | // ready |
| 264 | // for rendering. |
| 265 | // |
| 266 | // Input: |
| 267 | // - receiveCallback : The callback object to be used by the |
| 268 | // module when a |
| 269 | // frame is ready for rendering. |
| 270 | // De-register with a NULL pointer. |
| 271 | // |
| 272 | // Return value : VCM_OK, on success. |
| 273 | // < 0, on error. |
| 274 | virtual int32_t RegisterReceiveCallback( |
| 275 | VCMReceiveCallback* receiveCallback) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 276 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 277 | // Register a receive statistics callback which will be called to deliver |
| 278 | // information |
| 279 | // about the video stream received by the receiving side of the VCM, for |
| 280 | // instance the |
| 281 | // average frame rate and bit rate. |
| 282 | // |
| 283 | // Input: |
| 284 | // - receiveStats : The callback object to register. |
| 285 | // |
| 286 | // Return value : VCM_OK, on success. |
| 287 | // < 0, on error. |
| 288 | virtual int32_t RegisterReceiveStatisticsCallback( |
| 289 | VCMReceiveStatisticsCallback* receiveStats) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 290 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 291 | // Register a frame type request callback. This callback will be called when |
| 292 | // the |
| 293 | // module needs to request specific frame types from the send side. |
| 294 | // |
| 295 | // Input: |
| 296 | // - frameTypeCallback : The callback object to be used by the |
| 297 | // module when |
| 298 | // requesting a specific type of frame from |
| 299 | // the send side. |
| 300 | // De-register with a NULL pointer. |
| 301 | // |
| 302 | // Return value : VCM_OK, on success. |
| 303 | // < 0, on error. |
| 304 | virtual int32_t RegisterFrameTypeCallback( |
| 305 | VCMFrameTypeCallback* frameTypeCallback) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 306 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 307 | // Registers a callback which is called whenever the receive side of the VCM |
| 308 | // encounters holes in the packet sequence and needs packets to be |
| 309 | // retransmitted. |
| 310 | // |
| 311 | // Input: |
| 312 | // - callback : The callback to be registered in the VCM. |
| 313 | // |
| 314 | // Return value : VCM_OK, on success. |
| 315 | // <0, on error. |
| 316 | virtual int32_t RegisterPacketRequestCallback( |
| 317 | VCMPacketRequestCallback* callback) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 318 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 319 | // Waits for the next frame in the jitter buffer to become complete |
| 320 | // (waits no longer than maxWaitTimeMs), then passes it to the decoder for |
| 321 | // decoding. |
| 322 | // Should be called as often as possible to get the most out of the decoder. |
| 323 | // |
| 324 | // Return value : VCM_OK, on success. |
| 325 | // < 0, on error. |
| 326 | virtual int32_t Decode(uint16_t maxWaitTimeMs = 200) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 327 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 328 | // Insert a parsed packet into the receiver side of the module. Will be placed |
| 329 | // in the |
| 330 | // jitter buffer waiting for the frame to become complete. Returns as soon as |
| 331 | // the packet |
| 332 | // has been placed in the jitter buffer. |
| 333 | // |
| 334 | // Input: |
| 335 | // - incomingPayload : Payload of the packet. |
| 336 | // - payloadLength : Length of the payload. |
| 337 | // - rtpInfo : The parsed header. |
| 338 | // |
| 339 | // Return value : VCM_OK, on success. |
| 340 | // < 0, on error. |
| 341 | virtual int32_t IncomingPacket(const uint8_t* incomingPayload, |
| 342 | size_t payloadLength, |
| 343 | const WebRtcRTPHeader& rtpInfo) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 344 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 345 | // Minimum playout delay (Used for lip-sync). This is the minimum delay |
| 346 | // required |
| 347 | // to sync with audio. Not included in VideoCodingModule::Delay() |
| 348 | // Defaults to 0 ms. |
| 349 | // |
| 350 | // Input: |
| 351 | // - minPlayoutDelayMs : Additional delay in ms. |
| 352 | // |
| 353 | // Return value : VCM_OK, on success. |
| 354 | // < 0, on error. |
| 355 | virtual int32_t SetMinimumPlayoutDelay(uint32_t minPlayoutDelayMs) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 356 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 357 | // Set the time required by the renderer to render a frame. |
| 358 | // |
| 359 | // Input: |
| 360 | // - timeMS : The time in ms required by the renderer to render a |
| 361 | // frame. |
| 362 | // |
| 363 | // Return value : VCM_OK, on success. |
| 364 | // < 0, on error. |
| 365 | virtual int32_t SetRenderDelay(uint32_t timeMS) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 366 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 367 | // The total delay desired by the VCM. Can be less than the minimum |
| 368 | // delay set with SetMinimumPlayoutDelay. |
| 369 | // |
| 370 | // Return value : Total delay in ms, on success. |
| 371 | // < 0, on error. |
| 372 | virtual int32_t Delay() const = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 373 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 374 | // Robustness APIs |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 375 | |
tommi | a5c18d7 | 2017-03-20 10:43:23 -0700 | [diff] [blame] | 376 | // DEPRECATED. |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 377 | // Set the receiver robustness mode. The mode decides how the receiver |
tommi | a5c18d7 | 2017-03-20 10:43:23 -0700 | [diff] [blame] | 378 | // responds to losses in the stream. The type of counter-measure is selected |
| 379 | // through the robustnessMode parameter. The errorMode parameter decides if it |
| 380 | // is allowed to display frames corrupted by losses. Note that not all |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 381 | // combinations of the two parameters are feasible. An error will be |
| 382 | // returned for invalid combinations. |
| 383 | // Input: |
| 384 | // - robustnessMode : selected robustness mode. |
| 385 | // - errorMode : selected error mode. |
| 386 | // |
| 387 | // Return value : VCM_OK, on success; |
| 388 | // < 0, on error. |
tommi | a5c18d7 | 2017-03-20 10:43:23 -0700 | [diff] [blame] | 389 | enum ReceiverRobustness { kNone, kHardNack }; |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 390 | virtual int SetReceiverRobustnessMode(ReceiverRobustness robustnessMode, |
| 391 | VCMDecodeErrorMode errorMode) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 392 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 393 | // Set the decode error mode. The mode decides which errors (if any) are |
| 394 | // allowed in decodable frames. Note that setting decode_error_mode to |
| 395 | // anything other than kWithErrors without enabling nack will cause |
| 396 | // long-term freezes (resulting from frequent key frame requests) if |
| 397 | // packet loss occurs. |
| 398 | virtual void SetDecodeErrorMode(VCMDecodeErrorMode decode_error_mode) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 399 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 400 | // Sets the maximum number of sequence numbers that we are allowed to NACK |
| 401 | // and the oldest sequence number that we will consider to NACK. If a |
| 402 | // sequence number older than |max_packet_age_to_nack| is missing |
| 403 | // a key frame will be requested. A key frame will also be requested if the |
| 404 | // time of incomplete or non-continuous frames in the jitter buffer is above |
| 405 | // |max_incomplete_time_ms|. |
| 406 | virtual void SetNackSettings(size_t max_nack_list_size, |
| 407 | int max_packet_age_to_nack, |
| 408 | int max_incomplete_time_ms) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 409 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 410 | // Setting a desired delay to the VCM receiver. Video rendering will be |
| 411 | // delayed by at least desired_delay_ms. |
| 412 | virtual int SetMinReceiverDelay(int desired_delay_ms) = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 413 | |
philipel | 9d3ab61 | 2015-12-21 04:12:39 -0800 | [diff] [blame] | 414 | virtual void RegisterPostEncodeImageCallback( |
| 415 | EncodedImageCallback* post_encode_callback) = 0; |
| 416 | // Releases pending decode calls, permitting faster thread shutdown. |
| 417 | virtual void TriggerDecoderShutdown() = 0; |
Henrik Kjellander | 2557b86 | 2015-11-18 22:00:21 +0100 | [diff] [blame] | 418 | }; |
| 419 | |
| 420 | } // namespace webrtc |
| 421 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 422 | #endif // MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_ |