2 * Copyright 2021 The WebRTC Project Authors. All rights reserved.
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.
11 #ifndef COMMON_VIDEO_FRAMERATE_CONTROLLER_H_
12 #define COMMON_VIDEO_FRAMERATE_CONTROLLER_H_
16 #include "absl/types/optional.h"
20 // Determines which frames that should be dropped based on input framerate and
21 // requested framerate.
22 class FramerateController
{
24 FramerateController();
25 explicit FramerateController(double max_framerate
);
26 ~FramerateController();
28 // Sets max framerate (default is maxdouble).
29 void SetMaxFramerate(double max_framerate
);
30 double GetMaxFramerate() const;
32 // Returns true if the frame should be dropped, false otherwise.
33 bool ShouldDropFrame(int64_t in_timestamp_ns
);
37 void KeepFrame(int64_t in_timestamp_ns
);
40 double max_framerate_
;
41 absl::optional
<int64_t> next_frame_timestamp_ns_
;
46 #endif // COMMON_VIDEO_FRAMERATE_CONTROLLER_H_