2011-07-07 08:21:25 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_VIDEO_CODING_CODEC_TIMER_H_
|
|
|
|
|
#define MODULES_VIDEO_CODING_CODEC_TIMER_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-03-22 05:12:09 -07:00
|
|
|
#include <queue>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/include/module_common_types.h"
|
|
|
|
|
#include "rtc_base/numerics/percentile_filter.h"
|
2017-09-15 13:58:09 +02:00
|
|
|
#include "typedefs.h" // NOLINT(build/include)
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-12-21 03:04:49 -08:00
|
|
|
namespace webrtc {
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-12-21 03:04:49 -08:00
|
|
|
class VCMCodecTimer {
|
|
|
|
|
public:
|
|
|
|
|
VCMCodecTimer();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-03-22 05:12:09 -07:00
|
|
|
// Add a new decode time to the filter.
|
|
|
|
|
void AddTiming(int64_t new_decode_time_ms, int64_t now_ms);
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-03-22 05:12:09 -07:00
|
|
|
// Get the required decode time in ms. It is the 95th percentile observed
|
|
|
|
|
// decode time within a time window.
|
|
|
|
|
int64_t RequiredDecodeTimeMs() const;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-12-21 03:04:49 -08:00
|
|
|
private:
|
2016-03-22 05:12:09 -07:00
|
|
|
struct Sample {
|
|
|
|
|
Sample(int64_t decode_time_ms, int64_t sample_time_ms);
|
|
|
|
|
int64_t decode_time_ms;
|
|
|
|
|
int64_t sample_time_ms;
|
|
|
|
|
};
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2015-12-21 03:04:49 -08:00
|
|
|
// The number of samples ignored so far.
|
2016-03-22 05:12:09 -07:00
|
|
|
int ignored_sample_count_;
|
|
|
|
|
// Queue with history of latest decode time values.
|
|
|
|
|
std::queue<Sample> history_;
|
|
|
|
|
// |filter_| contains the same values as |history_|, but in a data structure
|
|
|
|
|
// that allows efficient retrieval of the percentile value.
|
2016-11-30 06:51:57 -08:00
|
|
|
PercentileFilter<int64_t> filter_;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace webrtc
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_VIDEO_CODING_CODEC_TIMER_H_
|