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