1 /* 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 MODULES_VIDEO_CODING_TIMING_INTER_FRAME_DELAY_H_ 12 #define MODULES_VIDEO_CODING_TIMING_INTER_FRAME_DELAY_H_ 13 14 #include <stdint.h> 15 16 #include "absl/types/optional.h" 17 #include "api/units/time_delta.h" 18 #include "api/units/timestamp.h" 19 #include "modules/include/module_common_types_public.h" 20 21 namespace webrtc { 22 23 class InterFrameDelay { 24 public: 25 InterFrameDelay(); 26 27 // Resets the estimate. Zeros are given as parameters. 28 void Reset(); 29 30 // Calculates the delay of a frame with the given timestamp. 31 // This method is called when the frame is complete. 32 absl::optional<TimeDelta> CalculateDelay(uint32_t rtp_timestamp, 33 Timestamp now); 34 35 private: 36 // The previous rtp timestamp passed to the delay estimate 37 int64_t prev_rtp_timestamp_unwrapped_; 38 TimestampUnwrapper unwrapper_; 39 40 // The previous wall clock timestamp used by the delay estimate 41 absl::optional<Timestamp> prev_wall_clock_; 42 }; 43 44 } // namespace webrtc 45 46 #endif // MODULES_VIDEO_CODING_TIMING_INTER_FRAME_DELAY_H_ 47