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