blob: 8ebd82ab9c240f38070f6ef23ec5fa0ae81ccec4 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
2 * Copyright (c) 2011 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_CODEC_TIMER_H_
12#define WEBRTC_MODULES_VIDEO_CODING_CODEC_TIMER_H_
13
Henrik Kjellanderff761fb2015-11-04 08:31:52 +010014#include "webrtc/modules/include/module_common_types.h"
pbos@webrtc.orga4407322013-07-16 12:32:05 +000015#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000016
philipelcce46fc2015-12-21 03:04:49 -080017namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:25 +000018
magjedc4a74e92016-03-16 07:51:44 -070019// MAX_HISTORY_SIZE * SHORT_FILTER_MS defines the window size in milliseconds
20#define MAX_HISTORY_SIZE 10
21#define SHORT_FILTER_MS 1000
22
23class VCMShortMaxSample {
24 public:
25 VCMShortMaxSample() : shortMax(0), timeMs(-1) {}
26
27 int32_t shortMax;
28 int64_t timeMs;
29};
30
philipelcce46fc2015-12-21 03:04:49 -080031class VCMCodecTimer {
32 public:
33 VCMCodecTimer();
niklase@google.com470e71d2011-07-07 08:21:25 +000034
magjedc4a74e92016-03-16 07:51:44 -070035 // Updates the max filtered decode time.
36 void MaxFilter(int32_t newDecodeTimeMs, int64_t nowMs);
niklase@google.com470e71d2011-07-07 08:21:25 +000037
magjedc4a74e92016-03-16 07:51:44 -070038 // Empty the list of timers.
39 void Reset();
40
41 // Get the required decode time in ms.
42 int32_t RequiredDecodeTimeMs(FrameType frameType) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000043
philipelcce46fc2015-12-21 03:04:49 -080044 private:
magjedc4a74e92016-03-16 07:51:44 -070045 void UpdateMaxHistory(int32_t decodeTime, int64_t now);
46 void ProcessHistory(int64_t nowMs);
niklase@google.com470e71d2011-07-07 08:21:25 +000047
magjedc4a74e92016-03-16 07:51:44 -070048 int32_t _filteredMax;
philipelcce46fc2015-12-21 03:04:49 -080049 // The number of samples ignored so far.
magjedc4a74e92016-03-16 07:51:44 -070050 int32_t _ignoredSampleCount;
51 int32_t _shortMax;
52 VCMShortMaxSample _history[MAX_HISTORY_SIZE];
niklase@google.com470e71d2011-07-07 08:21:25 +000053};
54
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000055} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000056
philipelcce46fc2015-12-21 03:04:49 -080057#endif // WEBRTC_MODULES_VIDEO_CODING_CODEC_TIMER_H_