blob: a7abeb850e3e65da06e1bd33b14bd4802218e6d0 [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
17namespace webrtc
18{
19
20// MAX_HISTORY_SIZE * SHORT_FILTER_MS defines the window size in milliseconds
wuchengli@chromium.org30377c72013-09-28 06:06:18 +000021#define MAX_HISTORY_SIZE 10
niklase@google.com470e71d2011-07-07 08:21:25 +000022#define SHORT_FILTER_MS 1000
23
24class VCMShortMaxSample
25{
26public:
27 VCMShortMaxSample() : shortMax(0), timeMs(-1) {};
28
pbos@webrtc.org7b859cc2013-04-02 15:54:38 +000029 int32_t shortMax;
30 int64_t timeMs;
niklase@google.com470e71d2011-07-07 08:21:25 +000031};
32
33class VCMCodecTimer
34{
35public:
36 VCMCodecTimer();
37
Per327d8ba2015-11-10 14:00:27 +010038 // Updates the max filtered decode time.
39 void MaxFilter(int32_t newDecodeTimeMs, int64_t nowMs);
niklase@google.com470e71d2011-07-07 08:21:25 +000040
41 // Empty the list of timers.
42 void Reset();
43
44 // Get the required decode time in ms.
pbos@webrtc.org7b859cc2013-04-02 15:54:38 +000045 int32_t RequiredDecodeTimeMs(FrameType frameType) const;
niklase@google.com470e71d2011-07-07 08:21:25 +000046
47private:
pbos@webrtc.org7b859cc2013-04-02 15:54:38 +000048 void UpdateMaxHistory(int32_t decodeTime, int64_t now);
pbos@webrtc.org7b859cc2013-04-02 15:54:38 +000049 void ProcessHistory(int64_t nowMs);
niklase@google.com470e71d2011-07-07 08:21:25 +000050
pbos@webrtc.org7b859cc2013-04-02 15:54:38 +000051 int32_t _filteredMax;
wuchengli@chromium.org30377c72013-09-28 06:06:18 +000052 // The number of samples ignored so far.
53 int32_t _ignoredSampleCount;
pbos@webrtc.org7b859cc2013-04-02 15:54:38 +000054 int32_t _shortMax;
wuchengli@chromium.org30377c72013-09-28 06:06:18 +000055 VCMShortMaxSample _history[MAX_HISTORY_SIZE];
niklase@google.com470e71d2011-07-07 08:21:25 +000056
57};
58
pbos@webrtc.orgd900e8b2013-07-03 15:12:26 +000059} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25 +000060
61#endif // WEBRTC_MODULES_VIDEO_CODING_CODEC_TIMER_H_