blob: 853e2a15fcd9af32e71b5738ffb46e8ef82674ed [file] [log] [blame]
Henrik Kjellander2557b862015-11-18 22:00:21 +01001/*
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
24#include "webrtc/modules/include/module.h"
25#include "webrtc/modules/include/module_common_types.h"
26#include "webrtc/modules/video_coding/include/video_coding_defines.h"
27#include "webrtc/system_wrappers/include/event_wrapper.h"
28#include "webrtc/video_frame.h"
29
philipel9d3ab612015-12-21 04:12:39 -080030namespace webrtc {
Henrik Kjellander2557b862015-11-18 22:00:21 +010031
32class Clock;
33class EncodedImageCallback;
34class VideoEncoder;
35class VideoDecoder;
36struct CodecSpecificInfo;
37
38class EventFactory {
39 public:
40 virtual ~EventFactory() {}
41
42 virtual EventWrapper* CreateEvent() = 0;
43};
44
45class EventFactoryImpl : public EventFactory {
46 public:
47 virtual ~EventFactoryImpl() {}
48
philipel9d3ab612015-12-21 04:12:39 -080049 virtual EventWrapper* CreateEvent() { return EventWrapper::Create(); }
Henrik Kjellander2557b862015-11-18 22:00:21 +010050};
51
52// Used to indicate which decode with errors mode should be used.
53enum VCMDecodeErrorMode {
philipel9d3ab612015-12-21 04:12:39 -080054 kNoErrors, // Never decode with errors. Video will freeze
55 // if nack is disabled.
56 kSelectiveErrors, // Frames that are determined decodable in
57 // VCMSessionInfo may be decoded with missing
58 // packets. As not all incomplete frames will be
59 // decodable, video will freeze if nack is disabled.
60 kWithErrors // Release frames as needed. Errors may be
61 // introduced as some encoded frames may not be
62 // complete.
Henrik Kjellander2557b862015-11-18 22:00:21 +010063};
64
philipel9d3ab612015-12-21 04:12:39 -080065class VideoCodingModule : public Module {
66 public:
67 enum SenderNackMode { kNackNone, kNackAll, kNackSelective };
Henrik Kjellander2557b862015-11-18 22:00:21 +010068
philipel9d3ab612015-12-21 04:12:39 -080069 enum ReceiverRobustness { kNone, kHardNack, kSoftNack, kReferenceSelection };
Henrik Kjellander2557b862015-11-18 22:00:21 +010070
philipel9d3ab612015-12-21 04:12:39 -080071 static VideoCodingModule* Create(
72 Clock* clock,
73 VideoEncoderRateObserver* encoder_rate_observer,
74 VCMQMSettingsCallback* qm_settings_callback);
Henrik Kjellander2557b862015-11-18 22:00:21 +010075
philipel9d3ab612015-12-21 04:12:39 -080076 static VideoCodingModule* Create(Clock* clock, EventFactory* event_factory);
Henrik Kjellander2557b862015-11-18 22:00:21 +010077
philipel9d3ab612015-12-21 04:12:39 -080078 static void Destroy(VideoCodingModule* module);
Henrik Kjellander2557b862015-11-18 22:00:21 +010079
philipel9d3ab612015-12-21 04:12:39 -080080 // Get number of supported codecs
81 //
82 // Return value : Number of supported codecs
83 static uint8_t NumberOfCodecs();
Henrik Kjellander2557b862015-11-18 22:00:21 +010084
philipel9d3ab612015-12-21 04:12:39 -080085 // Get supported codec settings with using id
86 //
87 // Input:
88 // - listId : Id or index of the codec to look up
89 // - codec : Memory where the codec settings will be stored
90 //
91 // Return value : VCM_OK, on success
92 // VCM_PARAMETER_ERROR if codec not supported or id too
93 // high
94 static int32_t Codec(const uint8_t listId, VideoCodec* codec);
Henrik Kjellander2557b862015-11-18 22:00:21 +010095
philipel9d3ab612015-12-21 04:12:39 -080096 // Get supported codec settings using codec type
97 //
98 // Input:
99 // - codecType : The codec type to get settings for
100 // - codec : Memory where the codec settings will be stored
101 //
102 // Return value : VCM_OK, on success
103 // VCM_PARAMETER_ERROR if codec not supported
104 static int32_t Codec(VideoCodecType codecType, VideoCodec* codec);
Henrik Kjellander2557b862015-11-18 22:00:21 +0100105
philipel9d3ab612015-12-21 04:12:39 -0800106 /*
107 * Sender
108 */
Henrik Kjellander2557b862015-11-18 22:00:21 +0100109
philipel9d3ab612015-12-21 04:12:39 -0800110 // Registers a codec to be used for encoding. Calling this
111 // API multiple times overwrites any previously registered codecs.
112 //
113 // NOTE: Must be called on the thread that constructed the VCM instance.
114 //
115 // Input:
116 // - sendCodec : Settings for the codec to be registered.
117 // - numberOfCores : The number of cores the codec is allowed
118 // to use.
119 // - maxPayloadSize : The maximum size each payload is allowed
120 // to have. Usually MTU - overhead.
121 //
122 // Return value : VCM_OK, on success.
123 // < 0, on error.
124 virtual int32_t RegisterSendCodec(const VideoCodec* sendCodec,
125 uint32_t numberOfCores,
126 uint32_t maxPayloadSize) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100127
philipel9d3ab612015-12-21 04:12:39 -0800128 // Get the current send codec in use.
129 //
130 // If a codec has not been set yet, the |id| property of the return value
131 // will be 0 and |name| empty.
132 //
133 // NOTE: This method intentionally does not hold locks and minimizes data
134 // copying. It must be called on the thread where the VCM was constructed.
135 virtual const VideoCodec& GetSendCodec() const = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100136
philipel9d3ab612015-12-21 04:12:39 -0800137 // DEPRECATED: Use GetSendCodec() instead.
138 //
139 // API to get the current send codec in use.
140 //
141 // Input:
142 // - currentSendCodec : Address where the sendCodec will be written.
143 //
144 // Return value : VCM_OK, on success.
145 // < 0, on error.
146 //
147 // NOTE: The returned codec information is not guaranteed to be current when
148 // the call returns. This method acquires a lock that is aligned with
149 // video encoding, so it should be assumed to be allowed to block for
150 // several milliseconds.
151 virtual int32_t SendCodec(VideoCodec* currentSendCodec) const = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100152
philipel9d3ab612015-12-21 04:12:39 -0800153 // DEPRECATED: Use GetSendCodec() instead.
154 //
155 // API to get the current send codec type
156 //
157 // Return value : Codec type, on success.
158 // kVideoCodecUnknown, on error or if no send codec is set
159 // NOTE: Same notes apply as for SendCodec() above.
160 virtual VideoCodecType SendCodec() const = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100161
philipel9d3ab612015-12-21 04:12:39 -0800162 // Register an external encoder object. This can not be used together with
163 // external decoder callbacks.
164 //
165 // Input:
166 // - externalEncoder : Encoder object to be used for encoding frames
167 // inserted
168 // with the AddVideoFrame API.
169 // - payloadType : The payload type bound which this encoder is bound
170 // to.
171 //
172 // Return value : VCM_OK, on success.
173 // < 0, on error.
174 // TODO(pbos): Remove return type when unused elsewhere.
175 virtual int32_t RegisterExternalEncoder(VideoEncoder* externalEncoder,
176 uint8_t payloadType,
177 bool internalSource = false) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100178
philipel9d3ab612015-12-21 04:12:39 -0800179 // API to get currently configured encoder target bitrate in bits/s.
180 //
181 // Return value : 0, on success.
182 // < 0, on error.
183 virtual int Bitrate(unsigned int* bitrate) const = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100184
philipel9d3ab612015-12-21 04:12:39 -0800185 // API to get currently configured encoder target frame rate.
186 //
187 // Return value : 0, on success.
188 // < 0, on error.
189 virtual int FrameRate(unsigned int* framerate) const = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100190
philipel9d3ab612015-12-21 04:12:39 -0800191 // Sets the parameters describing the send channel. These parameters are
192 // inputs to the
193 // Media Optimization inside the VCM and also specifies the target bit rate
194 // for the
195 // encoder. Bit rate used by NACK should already be compensated for by the
196 // user.
197 //
198 // Input:
199 // - target_bitrate : The target bitrate for VCM in bits/s.
200 // - lossRate : Fractions of lost packets the past second.
201 // (loss rate in percent = 100 * packetLoss /
202 // 255)
203 // - rtt : Current round-trip time in ms.
204 //
205 // Return value : VCM_OK, on success.
206 // < 0, on error.
207 virtual int32_t SetChannelParameters(uint32_t target_bitrate,
208 uint8_t lossRate,
209 int64_t rtt) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100210
philipel9d3ab612015-12-21 04:12:39 -0800211 // Sets the parameters describing the receive channel. These parameters are
212 // inputs to the
213 // Media Optimization inside the VCM.
214 //
215 // Input:
216 // - rtt : Current round-trip time in ms.
217 // with the most amount available bandwidth in
218 // a conference
219 // scenario
220 //
221 // Return value : VCM_OK, on success.
222 // < 0, on error.
223 virtual int32_t SetReceiveChannelParameters(int64_t rtt) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100224
philipel9d3ab612015-12-21 04:12:39 -0800225 // Register a transport callback which will be called to deliver the encoded
226 // data and
227 // side information.
228 //
229 // Input:
230 // - transport : The callback object to register.
231 //
232 // Return value : VCM_OK, on success.
233 // < 0, on error.
234 virtual int32_t RegisterTransportCallback(
235 VCMPacketizationCallback* transport) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100236
philipel9d3ab612015-12-21 04:12:39 -0800237 // Register video output information callback which will be called to deliver
238 // information
239 // about the video stream produced by the encoder, for instance the average
240 // frame rate and
241 // bit rate.
242 //
243 // Input:
244 // - outputInformation : The callback object to register.
245 //
246 // Return value : VCM_OK, on success.
247 // < 0, on error.
248 virtual int32_t RegisterSendStatisticsCallback(
249 VCMSendStatisticsCallback* sendStats) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100250
philipel9d3ab612015-12-21 04:12:39 -0800251 // Register a video protection callback which will be called to deliver
252 // the requested FEC rate and NACK status (on/off).
253 //
254 // Input:
255 // - protection : The callback object to register.
256 //
257 // Return value : VCM_OK, on success.
258 // < 0, on error.
259 virtual int32_t RegisterProtectionCallback(
260 VCMProtectionCallback* protection) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100261
philipel9d3ab612015-12-21 04:12:39 -0800262 // Enable or disable a video protection method.
263 //
264 // Input:
265 // - videoProtection : The method to enable or disable.
266 // - enable : True if the method should be enabled, false if
267 // it should be disabled.
268 //
269 // Return value : VCM_OK, on success.
270 // < 0, on error.
271 virtual int32_t SetVideoProtection(VCMVideoProtection videoProtection,
272 bool enable) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100273
philipel9d3ab612015-12-21 04:12:39 -0800274 // Add one raw video frame to the encoder. This function does all the
275 // necessary
276 // processing, then decides what frame type to encode, or if the frame should
277 // be
278 // dropped. If the frame should be encoded it passes the frame to the encoder
279 // before it returns.
280 //
281 // Input:
282 // - videoFrame : Video frame to encode.
283 // - codecSpecificInfo : Extra codec information, e.g., pre-parsed
284 // in-band signaling.
285 //
286 // Return value : VCM_OK, on success.
287 // < 0, on error.
288 virtual int32_t AddVideoFrame(
289 const VideoFrame& videoFrame,
290 const VideoContentMetrics* contentMetrics = NULL,
291 const CodecSpecificInfo* codecSpecificInfo = NULL) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100292
philipel9d3ab612015-12-21 04:12:39 -0800293 // Next frame encoded should be an intra frame (keyframe).
294 //
295 // Return value : VCM_OK, on success.
296 // < 0, on error.
297 virtual int32_t IntraFrameRequest(int stream_index) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100298
philipel9d3ab612015-12-21 04:12:39 -0800299 // Frame Dropper enable. Can be used to disable the frame dropping when the
300 // encoder
301 // over-uses its bit rate. This API is designed to be used when the encoded
302 // frames
303 // are supposed to be stored to an AVI file, or when the I420 codec is used
304 // and the
305 // target bit rate shouldn't affect the frame rate.
306 //
307 // Input:
308 // - enable : True to enable the setting, false to disable it.
309 //
310 // Return value : VCM_OK, on success.
311 // < 0, on error.
312 virtual int32_t EnableFrameDropper(bool enable) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100313
philipel9d3ab612015-12-21 04:12:39 -0800314 /*
315 * Receiver
316 */
Henrik Kjellander2557b862015-11-18 22:00:21 +0100317
philipel9d3ab612015-12-21 04:12:39 -0800318 // Register possible receive codecs, can be called multiple times for
319 // different codecs.
320 // The module will automatically switch between registered codecs depending on
321 // the
322 // payload type of incoming frames. The actual decoder will be created when
323 // needed.
324 //
325 // Input:
326 // - receiveCodec : Settings for the codec to be registered.
327 // - numberOfCores : Number of CPU cores that the decoder is allowed
328 // to use.
329 // - requireKeyFrame : Set this to true if you don't want any delta
330 // frames
331 // to be decoded until the first key frame has been
332 // decoded.
333 //
334 // Return value : VCM_OK, on success.
335 // < 0, on error.
336 virtual int32_t RegisterReceiveCodec(const VideoCodec* receiveCodec,
337 int32_t numberOfCores,
338 bool requireKeyFrame = false) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100339
philipel9d3ab612015-12-21 04:12:39 -0800340 // Register an externally defined decoder/renderer object. Can be a decoder
341 // only or a
342 // decoder coupled with a renderer. Note that RegisterReceiveCodec must be
343 // called to
344 // be used for decoding incoming streams.
345 //
346 // Input:
347 // - externalDecoder : The external decoder/renderer object.
348 // - payloadType : The payload type which this decoder should
349 // be
350 // registered to.
351 //
352 virtual void RegisterExternalDecoder(VideoDecoder* externalDecoder,
353 uint8_t payloadType) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100354
philipel9d3ab612015-12-21 04:12:39 -0800355 // Register a receive callback. Will be called whenever there is a new frame
356 // ready
357 // for rendering.
358 //
359 // Input:
360 // - receiveCallback : The callback object to be used by the
361 // module when a
362 // frame is ready for rendering.
363 // De-register with a NULL pointer.
364 //
365 // Return value : VCM_OK, on success.
366 // < 0, on error.
367 virtual int32_t RegisterReceiveCallback(
368 VCMReceiveCallback* receiveCallback) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100369
philipel9d3ab612015-12-21 04:12:39 -0800370 // Register a receive statistics callback which will be called to deliver
371 // information
372 // about the video stream received by the receiving side of the VCM, for
373 // instance the
374 // average frame rate and bit rate.
375 //
376 // Input:
377 // - receiveStats : The callback object to register.
378 //
379 // Return value : VCM_OK, on success.
380 // < 0, on error.
381 virtual int32_t RegisterReceiveStatisticsCallback(
382 VCMReceiveStatisticsCallback* receiveStats) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100383
philipel9d3ab612015-12-21 04:12:39 -0800384 // Register a decoder timing callback which will be called to deliver
385 // information about the timing of the decoder in the receiving side of the
386 // VCM, for instance the current and maximum frame decode latency.
387 //
388 // Input:
389 // - decoderTiming : The callback object to register.
390 //
391 // Return value : VCM_OK, on success.
392 // < 0, on error.
393 virtual int32_t RegisterDecoderTimingCallback(
394 VCMDecoderTimingCallback* decoderTiming) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100395
philipel9d3ab612015-12-21 04:12:39 -0800396 // Register a frame type request callback. This callback will be called when
397 // the
398 // module needs to request specific frame types from the send side.
399 //
400 // Input:
401 // - frameTypeCallback : The callback object to be used by the
402 // module when
403 // requesting a specific type of frame from
404 // the send side.
405 // De-register with a NULL pointer.
406 //
407 // Return value : VCM_OK, on success.
408 // < 0, on error.
409 virtual int32_t RegisterFrameTypeCallback(
410 VCMFrameTypeCallback* frameTypeCallback) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100411
philipel9d3ab612015-12-21 04:12:39 -0800412 // Registers a callback which is called whenever the receive side of the VCM
413 // encounters holes in the packet sequence and needs packets to be
414 // retransmitted.
415 //
416 // Input:
417 // - callback : The callback to be registered in the VCM.
418 //
419 // Return value : VCM_OK, on success.
420 // <0, on error.
421 virtual int32_t RegisterPacketRequestCallback(
422 VCMPacketRequestCallback* callback) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100423
philipel9d3ab612015-12-21 04:12:39 -0800424 // Waits for the next frame in the jitter buffer to become complete
425 // (waits no longer than maxWaitTimeMs), then passes it to the decoder for
426 // decoding.
427 // Should be called as often as possible to get the most out of the decoder.
428 //
429 // Return value : VCM_OK, on success.
430 // < 0, on error.
431 virtual int32_t Decode(uint16_t maxWaitTimeMs = 200) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100432
philipel9d3ab612015-12-21 04:12:39 -0800433 // Registers a callback which conveys the size of the render buffer.
434 virtual int RegisterRenderBufferSizeCallback(
435 VCMRenderBufferSizeCallback* callback) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100436
philipel9d3ab612015-12-21 04:12:39 -0800437 // Reset the decoder state to the initial state.
438 //
439 // Return value : VCM_OK, on success.
440 // < 0, on error.
441 virtual int32_t ResetDecoder() = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100442
philipel9d3ab612015-12-21 04:12:39 -0800443 // API to get the codec which is currently used for decoding by the module.
444 //
445 // Input:
446 // - currentReceiveCodec : Settings for the codec to be registered.
447 //
448 // Return value : VCM_OK, on success.
449 // < 0, on error.
450 virtual int32_t ReceiveCodec(VideoCodec* currentReceiveCodec) const = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100451
philipel9d3ab612015-12-21 04:12:39 -0800452 // API to get the codec type currently used for decoding by the module.
453 //
454 // Return value : codecy type, on success.
455 // kVideoCodecUnknown, on error or if no receive codec is
456 // registered
457 virtual VideoCodecType ReceiveCodec() const = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100458
philipel9d3ab612015-12-21 04:12:39 -0800459 // Insert a parsed packet into the receiver side of the module. Will be placed
460 // in the
461 // jitter buffer waiting for the frame to become complete. Returns as soon as
462 // the packet
463 // has been placed in the jitter buffer.
464 //
465 // Input:
466 // - incomingPayload : Payload of the packet.
467 // - payloadLength : Length of the payload.
468 // - rtpInfo : The parsed header.
469 //
470 // Return value : VCM_OK, on success.
471 // < 0, on error.
472 virtual int32_t IncomingPacket(const uint8_t* incomingPayload,
473 size_t payloadLength,
474 const WebRtcRTPHeader& rtpInfo) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100475
philipel9d3ab612015-12-21 04:12:39 -0800476 // Minimum playout delay (Used for lip-sync). This is the minimum delay
477 // required
478 // to sync with audio. Not included in VideoCodingModule::Delay()
479 // Defaults to 0 ms.
480 //
481 // Input:
482 // - minPlayoutDelayMs : Additional delay in ms.
483 //
484 // Return value : VCM_OK, on success.
485 // < 0, on error.
486 virtual int32_t SetMinimumPlayoutDelay(uint32_t minPlayoutDelayMs) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100487
philipel9d3ab612015-12-21 04:12:39 -0800488 // Set the time required by the renderer to render a frame.
489 //
490 // Input:
491 // - timeMS : The time in ms required by the renderer to render a
492 // frame.
493 //
494 // Return value : VCM_OK, on success.
495 // < 0, on error.
496 virtual int32_t SetRenderDelay(uint32_t timeMS) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100497
philipel9d3ab612015-12-21 04:12:39 -0800498 // The total delay desired by the VCM. Can be less than the minimum
499 // delay set with SetMinimumPlayoutDelay.
500 //
501 // Return value : Total delay in ms, on success.
502 // < 0, on error.
503 virtual int32_t Delay() const = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100504
philipel9d3ab612015-12-21 04:12:39 -0800505 // Returns the number of packets discarded by the jitter buffer due to being
506 // too late. This can include duplicated packets which arrived after the
507 // frame was sent to the decoder. Therefore packets which were prematurely
508 // NACKed will be counted.
509 virtual uint32_t DiscardedPackets() const = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100510
philipel9d3ab612015-12-21 04:12:39 -0800511 // Robustness APIs
Henrik Kjellander2557b862015-11-18 22:00:21 +0100512
philipel9d3ab612015-12-21 04:12:39 -0800513 // Set the receiver robustness mode. The mode decides how the receiver
514 // responds to losses in the stream. The type of counter-measure (soft or
515 // hard NACK, dual decoder, RPS, etc.) is selected through the
516 // robustnessMode parameter. The errorMode parameter decides if it is
517 // allowed to display frames corrupted by losses. Note that not all
518 // combinations of the two parameters are feasible. An error will be
519 // returned for invalid combinations.
520 // Input:
521 // - robustnessMode : selected robustness mode.
522 // - errorMode : selected error mode.
523 //
524 // Return value : VCM_OK, on success;
525 // < 0, on error.
526 virtual int SetReceiverRobustnessMode(ReceiverRobustness robustnessMode,
527 VCMDecodeErrorMode errorMode) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100528
philipel9d3ab612015-12-21 04:12:39 -0800529 // Set the decode error mode. The mode decides which errors (if any) are
530 // allowed in decodable frames. Note that setting decode_error_mode to
531 // anything other than kWithErrors without enabling nack will cause
532 // long-term freezes (resulting from frequent key frame requests) if
533 // packet loss occurs.
534 virtual void SetDecodeErrorMode(VCMDecodeErrorMode decode_error_mode) = 0;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100535
philipel9d3ab612015-12-21 04:12:39 -0800536 // 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;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100545
philipel9d3ab612015-12-21 04:12:39 -0800546 // 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;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100549
philipel9d3ab612015-12-21 04:12:39 -0800550 // 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;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100554
philipel9d3ab612015-12-21 04:12:39 -0800555 // 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;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100558
philipel9d3ab612015-12-21 04:12:39 -0800559 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;
Henrik Kjellander2557b862015-11-18 22:00:21 +0100565};
566
567} // namespace webrtc
568
philipel9d3ab612015-12-21 04:12:39 -0800569#endif // WEBRTC_MODULES_VIDEO_CODING_INCLUDE_VIDEO_CODING_H_