Bug 1850713: remove duplicated setting of early hint preloader id in `ScriptLoader...
[gecko.git] / third_party / libwebrtc / common_video / framerate_controller.h
blob371ffd419f39487f40debce938654b4d3bfb2cbf
1 /*
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.
9 */
11 #ifndef COMMON_VIDEO_FRAMERATE_CONTROLLER_H_
12 #define COMMON_VIDEO_FRAMERATE_CONTROLLER_H_
14 #include <stdint.h>
16 #include "absl/types/optional.h"
18 namespace webrtc {
20 // Determines which frames that should be dropped based on input framerate and
21 // requested framerate.
22 class FramerateController {
23 public:
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);
35 void Reset();
37 void KeepFrame(int64_t in_timestamp_ns);
39 private:
40 double max_framerate_;
41 absl::optional<int64_t> next_frame_timestamp_ns_;
44 } // namespace webrtc
46 #endif // COMMON_VIDEO_FRAMERATE_CONTROLLER_H_