Create api/video/timing directory. Add `VideoJitterTimingInterface` and `VideoJitterTimingFactory` for creating instances of it. Bug: b/493549134 Change-Id: Ib62cbe421adc967e68983ded85776f2bb31af305 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/482400 Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> Commit-Queue: Åsa Persson <asapersson@webrtc.org> Cr-Commit-Position: refs/heads/main@{#48055}
diff --git a/api/video/timing/BUILD.gn b/api/video/timing/BUILD.gn new file mode 100644 index 0000000..9cb217d --- /dev/null +++ b/api/video/timing/BUILD.gn
@@ -0,0 +1,30 @@ +# Copyright (c) 2026 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. + +import("../../../webrtc.gni") + +rtc_source_set("video_jitter_timing_interface") { + visibility = [ "*" ] + sources = [ "video_jitter_timing_interface.h" ] + deps = [ + "../../environment", + "../../units:data_size", + "../../units:time_delta", + "../../units:timestamp", + ] +} + +rtc_source_set("video_jitter_timing_factory") { + visibility = [ "*" ] + sources = [ "video_jitter_timing_factory.h" ] + + deps = [ + ":video_jitter_timing_interface", + "../../environment", + ] +}
diff --git a/api/video/timing/OWNERS b/api/video/timing/OWNERS new file mode 100644 index 0000000..0fe225b --- /dev/null +++ b/api/video/timing/OWNERS
@@ -0,0 +1,2 @@ +brandtr@webrtc.org +asapersson@webrtc.org
diff --git a/api/video/timing/video_jitter_timing_factory.h b/api/video/timing/video_jitter_timing_factory.h new file mode 100644 index 0000000..64646df --- /dev/null +++ b/api/video/timing/video_jitter_timing_factory.h
@@ -0,0 +1,32 @@ +/* + * Copyright (c) 2026 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. + */ + +#ifndef API_VIDEO_TIMING_VIDEO_JITTER_TIMING_FACTORY_H_ +#define API_VIDEO_TIMING_VIDEO_JITTER_TIMING_FACTORY_H_ + +#include <memory> + +#include "api/environment/environment.h" +#include "api/video/timing/video_jitter_timing_interface.h" + +namespace webrtc { + +// Creates VideoJitterTimingInterface instances. +class VideoJitterTimingFactory { + public: + virtual ~VideoJitterTimingFactory() = default; + + virtual std::unique_ptr<VideoJitterTimingInterface> Create( + const Environment& env) const = 0; +}; + +} // namespace webrtc + +#endif // API_VIDEO_TIMING_VIDEO_JITTER_TIMING_FACTORY_H_
diff --git a/api/video/timing/video_jitter_timing_interface.h b/api/video/timing/video_jitter_timing_interface.h new file mode 100644 index 0000000..3af95bd --- /dev/null +++ b/api/video/timing/video_jitter_timing_interface.h
@@ -0,0 +1,61 @@ +/* + * Copyright (c) 2026 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. + */ + +#ifndef API_VIDEO_TIMING_VIDEO_JITTER_TIMING_INTERFACE_H_ +#define API_VIDEO_TIMING_VIDEO_JITTER_TIMING_INTERFACE_H_ + +#include <cstdint> +#include <optional> + +#include "api/units/data_size.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" + +namespace webrtc { + +// NOTE: This class is still under development and may change without notice. +class VideoJitterTimingInterface { + public: + struct TemporalUnitInfo { + uint32_t rtp_timestamp = 0; + DataSize size = DataSize::Zero(); + Timestamp time = Timestamp::PlusInfinity(); + bool was_retransmitted = false; + }; + + struct NetworkInfo { + TimeDelta rtt = TimeDelta::PlusInfinity(); + }; + + virtual ~VideoJitterTimingInterface() = default; + + // Resets the model to its initial state. + virtual void Reset() = 0; + + // Updates the model with the timestamp of a complete frame. + virtual void OnCompleteFrame(uint32_t rtp_timestamp, + Timestamp receive_time) = 0; + + // Returns the estimated local clock time for a given RTP timestamp (or + // nullopt if not available). + virtual std::optional<Timestamp> LocalTime(uint32_t rtp_timestamp) const = 0; + + // Updates the model with information of a decodable temporal unit. + // Returns the estimated jitter delay (or nullopt if not available). + virtual std::optional<TimeDelta> OnDecodableTemporalUnit( + const TemporalUnitInfo& info) = 0; + + // Updates the model with network information. + virtual void OnNetworkUpdate(const NetworkInfo& info) = 0; +}; + +} // namespace webrtc + +#endif // API_VIDEO_TIMING_VIDEO_JITTER_TIMING_INTERFACE_H_