blob: e8d6a031ddf1a13baf5e1baacee5eec0f6dd2f33 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
stefan@webrtc.org29794612012-02-08 08:58:55 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_VIDEO_CODING_JITTER_BUFFER_H_
12#define MODULES_VIDEO_CODING_JITTER_BUFFER_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
stefan@webrtc.org4cf1a8a2013-06-27 15:20:14 +000014#include <list>
stefan@webrtc.org50fb4af2013-06-17 07:33:58 +000015#include <map>
kwiberg3f55dea2016-02-29 05:51:59 -080016#include <memory>
stefan@webrtc.orga64300a2013-03-04 15:24:40 +000017#include <set>
stefan@webrtc.orgbecf9c82013-02-01 15:09:57 +000018#include <vector>
stefan@webrtc.org29794612012-02-08 08:58:55 +000019
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "modules/include/module_common_types.h"
21#include "modules/utility/include/process_thread.h"
22#include "modules/video_coding/decoding_state.h"
23#include "modules/video_coding/include/video_coding.h"
24#include "modules/video_coding/include/video_coding_defines.h"
25#include "modules/video_coding/inter_frame_delay.h"
26#include "modules/video_coding/jitter_buffer_common.h"
27#include "modules/video_coding/jitter_estimator.h"
Steve Anton10542f22019-01-11 09:11:00 -080028#include "rtc_base/constructor_magic.h"
29#include "rtc_base/critical_section.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020030#include "rtc_base/thread_annotations.h"
Niels Möllerebad1772018-12-04 13:15:37 +010031#include "system_wrappers/include/event_wrapper.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000032
stefan@webrtc.org912981f2012-10-12 07:04:52 +000033namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000034
philipel9d3ab612015-12-21 04:12:39 -080035enum VCMNackMode { kNack, kNoNack };
niklase@google.com470e71d2011-07-07 08:21:25 +000036
37// forward declarations
stefan@webrtc.orga678a3b2013-01-21 07:42:11 +000038class Clock;
niklase@google.com470e71d2011-07-07 08:21:25 +000039class VCMFrameBuffer;
40class VCMPacket;
41class VCMEncodedFrame;
42
stefan@webrtc.org4cf1a8a2013-06-27 15:20:14 +000043typedef std::list<VCMFrameBuffer*> UnorderedFrameList;
44
stefan@webrtc.org912981f2012-10-12 07:04:52 +000045struct VCMJitterSample {
46 VCMJitterSample() : timestamp(0), frame_size(0), latest_packet_time(-1) {}
47 uint32_t timestamp;
48 uint32_t frame_size;
49 int64_t latest_packet_time;
niklase@google.com470e71d2011-07-07 08:21:25 +000050};
51
stefan@webrtc.org50fb4af2013-06-17 07:33:58 +000052class TimestampLessThan {
53 public:
philipel9d3ab612015-12-21 04:12:39 -080054 bool operator()(uint32_t timestamp1, uint32_t timestamp2) const {
stefan@webrtc.org50fb4af2013-06-17 07:33:58 +000055 return IsNewerTimestamp(timestamp2, timestamp1);
56 }
57};
58
agalusza@google.comd818dcb2013-07-29 21:48:11 +000059class FrameList
60 : public std::map<uint32_t, VCMFrameBuffer*, TimestampLessThan> {
stefan@webrtc.orgc8b29a22013-06-17 07:13:16 +000061 public:
62 void InsertFrame(VCMFrameBuffer* frame);
stefan@webrtc.orgc8b29a22013-06-17 07:13:16 +000063 VCMFrameBuffer* PopFrame(uint32_t timestamp);
stefan@webrtc.org50fb4af2013-06-17 07:33:58 +000064 VCMFrameBuffer* Front() const;
65 VCMFrameBuffer* Back() const;
stefan@webrtc.org4cf1a8a2013-06-27 15:20:14 +000066 int RecycleFramesUntilKeyFrame(FrameList::iterator* key_frame_it,
philipel9d3ab612015-12-21 04:12:39 -080067 UnorderedFrameList* free_frames);
pbos@webrtc.org4f16c872014-11-24 09:06:48 +000068 void CleanUpOldOrEmptyFrames(VCMDecodingState* decoding_state,
69 UnorderedFrameList* free_frames);
stefan@webrtc.org4cf1a8a2013-06-27 15:20:14 +000070 void Reset(UnorderedFrameList* free_frames);
stefan@webrtc.orgc8b29a22013-06-17 07:13:16 +000071};
72
asapersson9a4cd872015-10-23 00:27:14 -070073class Vp9SsMap {
74 public:
75 typedef std::map<uint32_t, GofInfoVP9, TimestampLessThan> SsMap;
Stefan Holmerdbdb3a02018-07-17 16:03:46 +020076 Vp9SsMap();
77 ~Vp9SsMap();
78
asapersson9a4cd872015-10-23 00:27:14 -070079 bool Insert(const VCMPacket& packet);
80 void Reset();
81
82 // Removes SS data that are older than |timestamp|.
83 // The |timestamp| should be an old timestamp, i.e. packets with older
84 // timestamps should no longer be inserted.
85 void RemoveOld(uint32_t timestamp);
86
87 bool UpdatePacket(VCMPacket* packet);
88 void UpdateFrames(FrameList* frames);
89
90 // Public for testing.
91 // Returns an iterator to the corresponding SS data for the input |timestamp|.
92 bool Find(uint32_t timestamp, SsMap::iterator* it);
93
94 private:
95 // These two functions are called by RemoveOld.
96 // Checks if it is time to do a clean up (done each kSsCleanupIntervalSec).
97 bool TimeForCleanup(uint32_t timestamp) const;
98
99 // Advances the oldest SS data to handle timestamp wrap in cases where SS data
100 // are received very seldom (e.g. only once in beginning, second when
101 // IsNewerTimestamp is not true).
102 void AdvanceFront(uint32_t timestamp);
103
104 SsMap ss_map_;
105};
106
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000107class VCMJitterBuffer {
108 public:
philipel83f831a2016-03-12 03:30:23 -0800109 VCMJitterBuffer(Clock* clock,
110 std::unique_ptr<EventWrapper> event,
111 NackSender* nack_sender = nullptr,
112 KeyFrameRequestSender* keyframe_request_sender = nullptr);
Qiang Chend4cec152015-06-19 09:17:00 -0700113
Wan-Teh Chang6a1ba8c2015-05-26 14:11:41 -0700114 ~VCMJitterBuffer();
niklase@google.com470e71d2011-07-07 08:21:25 +0000115
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000116 // Initializes and starts jitter buffer.
117 void Start();
niklase@google.com470e71d2011-07-07 08:21:25 +0000118
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000119 // Signals all internal events and stops the jitter buffer.
120 void Stop();
niklase@google.com470e71d2011-07-07 08:21:25 +0000121
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000122 // Returns true if the jitter buffer is running.
123 bool Running() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000124
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000125 // Empty the jitter buffer of all its data.
126 void Flush();
stefan@webrtc.org791eec72011-10-11 07:53:43 +0000127
asapersson@webrtc.org96dc6852014-11-03 14:40:38 +0000128 // Gets number of packets received.
129 int num_packets() const;
130
131 // Gets number of duplicated packets received.
132 int num_duplicated_packets() const;
133
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000134 // Statistics, Calculate frame and bit rates.
philipel9d3ab612015-12-21 04:12:39 -0800135 void IncomingRateStatistics(unsigned int* framerate, unsigned int* bitrate);
niklase@google.com470e71d2011-07-07 08:21:25 +0000136
mikhal@webrtc.org759b0412013-05-07 16:36:00 +0000137 // Wait |max_wait_time_ms| for a complete frame to arrive.
isheriff6b4b5f32016-06-08 00:24:21 -0700138 // If found, a pointer to the frame is returned. Returns nullptr otherwise.
139 VCMEncodedFrame* NextCompleteFrame(uint32_t max_wait_time_ms);
niklase@google.com470e71d2011-07-07 08:21:25 +0000140
mikhal@webrtc.org759b0412013-05-07 16:36:00 +0000141 // Extract frame corresponding to input timestamp.
142 // Frame will be set to a decoding state.
143 VCMEncodedFrame* ExtractAndSetDecode(uint32_t timestamp);
niklase@google.com470e71d2011-07-07 08:21:25 +0000144
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000145 // Releases a frame returned from the jitter buffer, should be called when
146 // done with decoding.
147 void ReleaseFrame(VCMEncodedFrame* frame);
niklase@google.com470e71d2011-07-07 08:21:25 +0000148
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000149 // Returns the time in ms when the latest packet was inserted into the frame.
150 // Retransmitted is set to true if any of the packets belonging to the frame
151 // has been retransmitted.
stefan@webrtc.org3417eb42013-05-21 15:25:53 +0000152 int64_t LastPacketTime(const VCMEncodedFrame* frame,
153 bool* retransmitted) const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000154
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000155 // Inserts a packet into a frame returned from GetFrame().
stefan@webrtc.orgc8b29a22013-06-17 07:13:16 +0000156 // If the return value is <= 0, |frame| is invalidated and the pointer must
157 // be dropped after this function returns.
philipel9d3ab612015-12-21 04:12:39 -0800158 VCMFrameBufferEnum InsertPacket(const VCMPacket& packet, bool* retransmitted);
niklase@google.com470e71d2011-07-07 08:21:25 +0000159
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000160 // Returns the estimated jitter in milliseconds.
161 uint32_t EstimatedJitterMs();
niklase@google.com470e71d2011-07-07 08:21:25 +0000162
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000163 // Updates the round-trip time estimate.
pkasting@chromium.org16825b12015-01-12 21:51:21 +0000164 void UpdateRtt(int64_t rtt_ms);
niklase@google.com470e71d2011-07-07 08:21:25 +0000165
Wan-Teh Chang603175a2015-05-28 14:10:14 -0700166 // Set the NACK mode. |high_rtt_nack_threshold_ms| is an RTT threshold in ms
Wan-Teh Changf2912872015-06-05 13:16:45 -0700167 // above which NACK will be disabled if the NACK mode is |kNack|, -1 meaning
168 // that NACK is always enabled in the |kNack| mode.
Wan-Teh Chang603175a2015-05-28 14:10:14 -0700169 // |low_rtt_nack_threshold_ms| is an RTT threshold in ms below which we expect
170 // to rely on NACK only, and therefore are using larger buffers to have time
171 // to wait for retransmissions.
philipel9d3ab612015-12-21 04:12:39 -0800172 void SetNackMode(VCMNackMode mode,
173 int64_t low_rtt_nack_threshold_ms,
pkasting@chromium.org16825b12015-01-12 21:51:21 +0000174 int64_t high_rtt_nack_threshold_ms);
niklase@google.com470e71d2011-07-07 08:21:25 +0000175
stefan@webrtc.orgbecf9c82013-02-01 15:09:57 +0000176 void SetNackSettings(size_t max_nack_list_size,
stefan@webrtc.orgef144882013-05-07 19:16:33 +0000177 int max_packet_age_to_nack,
178 int max_incomplete_time_ms);
stefan@webrtc.orgbecf9c82013-02-01 15:09:57 +0000179
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000180 // Returns the current NACK mode.
181 VCMNackMode nack_mode() const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000182
stefan@webrtc.orga64300a2013-03-04 15:24:40 +0000183 // Returns a list of the sequence numbers currently missing.
Wan-Teh Changb1825a42015-06-03 15:03:35 -0700184 std::vector<uint16_t> GetNackList(bool* request_key_frame);
niklase@google.com470e71d2011-07-07 08:21:25 +0000185
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000186 private:
stefan@webrtc.orga64300a2013-03-04 15:24:40 +0000187 class SequenceNumberLessThan {
188 public:
philipel9d3ab612015-12-21 04:12:39 -0800189 bool operator()(const uint16_t& sequence_number1,
190 const uint16_t& sequence_number2) const {
stefan@webrtc.org7bc465b2013-04-11 17:48:02 +0000191 return IsNewerSequenceNumber(sequence_number2, sequence_number1);
stefan@webrtc.orga64300a2013-03-04 15:24:40 +0000192 }
193 };
194 typedef std::set<uint16_t, SequenceNumberLessThan> SequenceNumberSet;
195
stefan@webrtc.org3417eb42013-05-21 15:25:53 +0000196 // Gets the frame assigned to the timestamp of the packet. May recycle
197 // existing frames if no free frames are available. Returns an error code if
pbos@webrtc.org4f16c872014-11-24 09:06:48 +0000198 // failing, or kNoError on success. |frame_list| contains which list the
199 // packet was in, or NULL if it was not in a FrameList (a new frame).
200 VCMFrameBufferEnum GetFrame(const VCMPacket& packet,
201 VCMFrameBuffer** frame,
202 FrameList** frame_list)
danilchap56359be2017-09-07 07:53:45 -0700203 RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
asapersson@webrtc.org83b52002014-11-28 10:17:13 +0000204
stefan@webrtc.orgc8b29a22013-06-17 07:13:16 +0000205 // Returns true if |frame| is continuous in |decoding_state|, not taking
206 // decodable frames into account.
207 bool IsContinuousInState(const VCMFrameBuffer& frame,
pbos@webrtc.org4f16c872014-11-24 09:06:48 +0000208 const VCMDecodingState& decoding_state) const
danilchap56359be2017-09-07 07:53:45 -0700209 RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
stefan@webrtc.orgc8b29a22013-06-17 07:13:16 +0000210 // Returns true if |frame| is continuous in the |last_decoded_state_|, taking
211 // all decodable frames into account.
pbos@webrtc.org4f16c872014-11-24 09:06:48 +0000212 bool IsContinuous(const VCMFrameBuffer& frame) const
danilchap56359be2017-09-07 07:53:45 -0700213 RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
Noah Richardse4cb4e92015-05-22 14:03:00 -0700214 // Looks for frames in |incomplete_frames_| which are continuous in the
215 // provided |decoded_state|. Starts the search from the timestamp of
216 // |decoded_state|.
217 void FindAndInsertContinuousFramesWithState(
218 const VCMDecodingState& decoded_state)
danilchap56359be2017-09-07 07:53:45 -0700219 RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
stefan@webrtc.orgc8b29a22013-06-17 07:13:16 +0000220 // Looks for frames in |incomplete_frames_| which are continuous in
221 // |last_decoded_state_| taking all decodable frames into account. Starts
222 // the search from |new_frame|.
pbos@webrtc.org4f16c872014-11-24 09:06:48 +0000223 void FindAndInsertContinuousFrames(const VCMFrameBuffer& new_frame)
danilchap56359be2017-09-07 07:53:45 -0700224 RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
225 VCMFrameBuffer* NextFrame() const RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
stefan@webrtc.orga64300a2013-03-04 15:24:40 +0000226 // Returns true if the NACK list was updated to cover sequence numbers up to
227 // |sequence_number|. If false a key frame is needed to get into a state where
228 // we can continue decoding.
pbos@webrtc.org4f16c872014-11-24 09:06:48 +0000229 bool UpdateNackList(uint16_t sequence_number)
danilchap56359be2017-09-07 07:53:45 -0700230 RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
stefan@webrtc.orga64300a2013-03-04 15:24:40 +0000231 bool TooLargeNackList() const;
232 // Returns true if the NACK list was reduced without problem. If false a key
233 // frame is needed to get into a state where we can continue decoding.
danilchap56359be2017-09-07 07:53:45 -0700234 bool HandleTooLargeNackList() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
pbos@webrtc.org4f16c872014-11-24 09:06:48 +0000235 bool MissingTooOldPacket(uint16_t latest_sequence_number) const
danilchap56359be2017-09-07 07:53:45 -0700236 RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
stefan@webrtc.orga64300a2013-03-04 15:24:40 +0000237 // Returns true if the too old packets was successfully removed from the NACK
238 // list. If false, a key frame is needed to get into a state where we can
239 // continue decoding.
pbos@webrtc.org4f16c872014-11-24 09:06:48 +0000240 bool HandleTooOldPackets(uint16_t latest_sequence_number)
danilchap56359be2017-09-07 07:53:45 -0700241 RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
stefan@webrtc.orga64300a2013-03-04 15:24:40 +0000242 // Drops all packets in the NACK list up until |last_decoded_sequence_number|.
243 void DropPacketsFromNackList(uint16_t last_decoded_sequence_number);
244
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000245 // Gets an empty frame, creating a new frame if necessary (i.e. increases
246 // jitter buffer size).
danilchap56359be2017-09-07 07:53:45 -0700247 VCMFrameBuffer* GetEmptyFrame() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000248
stefan@webrtc.org4cf1a8a2013-06-27 15:20:14 +0000249 // Attempts to increase the size of the jitter buffer. Returns true on
250 // success, false otherwise.
danilchap56359be2017-09-07 07:53:45 -0700251 bool TryToIncreaseJitterBufferSize() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
stefan@webrtc.org4cf1a8a2013-06-27 15:20:14 +0000252
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000253 // Recycles oldest frames until a key frame is found. Used if jitter buffer is
254 // completely full. Returns true if a key frame was found.
danilchap56359be2017-09-07 07:53:45 -0700255 bool RecycleFramesUntilKeyFrame() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000256
stefan@webrtc.org4cf1a8a2013-06-27 15:20:14 +0000257 // Updates the frame statistics.
agalusza@google.comd177c102013-08-08 01:12:33 +0000258 // Counts only complete frames, so decodable incomplete frames will not be
259 // counted.
pbos@webrtc.orgce4e9a32014-12-18 13:50:16 +0000260 void CountFrame(const VCMFrameBuffer& frame)
danilchap56359be2017-09-07 07:53:45 -0700261 RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
stefan@webrtc.org791eec72011-10-11 07:53:43 +0000262
agalusza@google.comd818dcb2013-07-29 21:48:11 +0000263 // Update rolling average of packets per frame.
264 void UpdateAveragePacketsPerFrame(int current_number_packets_);
265
mikhal@webrtc.org381da4b2013-04-25 21:45:29 +0000266 // Cleans the frame list in the JB from old/empty frames.
267 // Should only be called prior to actual use.
danilchap56359be2017-09-07 07:53:45 -0700268 void CleanUpOldOrEmptyFrames() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
niklase@google.com470e71d2011-07-07 08:21:25 +0000269
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000270 // Returns true if |packet| is likely to have been retransmitted.
271 bool IsPacketRetransmitted(const VCMPacket& packet) const;
henrik.lundin@webrtc.orgbaf6db52011-11-02 18:58:39 +0000272
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000273 // The following three functions update the jitter estimate with the
274 // payload size, receive time and RTP timestamp of a frame.
275 void UpdateJitterEstimate(const VCMJitterSample& sample,
276 bool incomplete_frame);
277 void UpdateJitterEstimate(const VCMFrameBuffer& frame, bool incomplete_frame);
278 void UpdateJitterEstimate(int64_t latest_packet_time_ms,
279 uint32_t timestamp,
280 unsigned int frame_size,
281 bool incomplete_frame);
282
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000283 // Returns true if we should wait for retransmissions, false otherwise.
284 bool WaitForRetransmissions();
285
danilchap56359be2017-09-07 07:53:45 -0700286 int NonContinuousOrIncompleteDuration()
287 RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
stefan@webrtc.orgef144882013-05-07 19:16:33 +0000288
289 uint16_t EstimatedLowSequenceNumber(const VCMFrameBuffer& frame) const;
290
sprang22691e02016-07-13 10:57:07 -0700291 // Reset frame buffer and return it to free_frames_.
292 void RecycleFrameBuffer(VCMFrameBuffer* frame)
danilchap56359be2017-09-07 07:53:45 -0700293 RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
sprang22691e02016-07-13 10:57:07 -0700294
stefan@webrtc.orga678a3b2013-01-21 07:42:11 +0000295 Clock* clock_;
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000296 // If we are running (have started) or not.
297 bool running_;
kthelgasonff046c72017-03-31 02:03:55 -0700298 rtc::CriticalSection crit_sect_;
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000299 // Event to signal when we have a frame ready for decoder.
kwiberg3f55dea2016-02-29 05:51:59 -0800300 std::unique_ptr<EventWrapper> frame_event_;
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000301 // Number of allocated frames.
302 int max_number_of_frames_;
danilchap56359be2017-09-07 07:53:45 -0700303 UnorderedFrameList free_frames_ RTC_GUARDED_BY(crit_sect_);
304 FrameList decodable_frames_ RTC_GUARDED_BY(crit_sect_);
305 FrameList incomplete_frames_ RTC_GUARDED_BY(crit_sect_);
306 VCMDecodingState last_decoded_state_ RTC_GUARDED_BY(crit_sect_);
stefan@webrtc.org3417eb42013-05-21 15:25:53 +0000307 bool first_packet_since_reset_;
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000308
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000309 // Latest calculated frame rates of incoming stream.
310 unsigned int incoming_frame_rate_;
311 unsigned int incoming_frame_count_;
312 int64_t time_last_incoming_frame_count_;
313 unsigned int incoming_bit_count_;
314 unsigned int incoming_bit_rate_;
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000315 // Number of packets in a row that have been too old.
316 int num_consecutive_old_packets_;
asapersson@webrtc.org96dc6852014-11-03 14:40:38 +0000317 // Number of packets received.
danilchap56359be2017-09-07 07:53:45 -0700318 int num_packets_ RTC_GUARDED_BY(crit_sect_);
asapersson@webrtc.org96dc6852014-11-03 14:40:38 +0000319 // Number of duplicated packets received.
danilchap56359be2017-09-07 07:53:45 -0700320 int num_duplicated_packets_ RTC_GUARDED_BY(crit_sect_);
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000321
322 // Jitter estimation.
323 // Filter for estimating jitter.
324 VCMJitterEstimator jitter_estimate_;
325 // Calculates network delays used for jitter calculations.
326 VCMInterFrameDelay inter_frame_delay_;
327 VCMJitterSample waiting_for_completion_;
pkasting@chromium.org16825b12015-01-12 21:51:21 +0000328 int64_t rtt_ms_;
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000329
330 // NACK and retransmissions.
331 VCMNackMode nack_mode_;
pkasting@chromium.org16825b12015-01-12 21:51:21 +0000332 int64_t low_rtt_nack_threshold_ms_;
333 int64_t high_rtt_nack_threshold_ms_;
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000334 // Holds the internal NACK list (the missing sequence numbers).
stefan@webrtc.orga64300a2013-03-04 15:24:40 +0000335 SequenceNumberSet missing_sequence_numbers_;
336 uint16_t latest_received_sequence_number_;
stefan@webrtc.orgbecf9c82013-02-01 15:09:57 +0000337 size_t max_nack_list_size_;
338 int max_packet_age_to_nack_; // Measured in sequence numbers.
stefan@webrtc.orgef144882013-05-07 19:16:33 +0000339 int max_incomplete_time_ms_;
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000340
agalusza@google.comd818dcb2013-07-29 21:48:11 +0000341 // Estimated rolling average of packets per frame
342 float average_packets_per_frame_;
343 // average_packets_per_frame converges fast if we have fewer than this many
344 // frames.
345 int frame_counter_;
philipel83f831a2016-03-12 03:30:23 -0800346
henrikg3c089d72015-09-16 05:37:44 -0700347 RTC_DISALLOW_COPY_AND_ASSIGN(VCMJitterBuffer);
niklase@google.com470e71d2011-07-07 08:21:25 +0000348};
stefan@webrtc.org912981f2012-10-12 07:04:52 +0000349} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +0000350
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200351#endif // MODULES_VIDEO_CODING_JITTER_BUFFER_H_