Skip to content

Commit 867e295

Browse files
committed
remove last_user_timestamp
1 parent a60654f commit 867e295

8 files changed

Lines changed: 5 additions & 69 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/local_video/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "local_video"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition.workspace = true
55
publish = false
66

examples/local_video/src/subscriber.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ fn current_timestamp_us() -> i64 {
135135
}
136136

137137
/// Format a user timestamp (microseconds since Unix epoch) as
138-
/// `yyyy-mm-dd hh:mm:ss.ssss`.
138+
/// `yyyy-mm-dd hh:mm:ss:xxx` where xxx is milliseconds.
139139
fn format_timestamp_us(ts_us: i64) -> String {
140140
DateTime::<Utc>::from_timestamp_micros(ts_us)
141-
.map(|dt| dt.format("%Y-%m-%d %H:%M:%S%.4f").to_string())
141+
.map(|dt| dt.format("%Y-%m-%d %H:%M:%S:").to_string() + &format!("{:03}", dt.timestamp_subsec_millis()))
142142
.unwrap_or_else(|| format!("<invalid timestamp {ts_us}>"))
143143
}
144144

libwebrtc/src/native/user_timestamp.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,6 @@ impl UserTimestampHandler {
6060
self.sys_handle.enabled()
6161
}
6262

63-
/// Get the last received user timestamp (receiver side only).
64-
/// Returns None if no timestamp has been received yet.
65-
pub fn last_user_timestamp(&self) -> Option<i64> {
66-
if self.sys_handle.has_user_timestamp() {
67-
let ts = self.sys_handle.last_user_timestamp();
68-
if ts >= 0 {
69-
Some(ts)
70-
} else {
71-
None
72-
}
73-
} else {
74-
None
75-
}
76-
}
77-
7863
/// Lookup the user timestamp for a given RTP timestamp (receiver side).
7964
/// Returns None if no timestamp was found for this RTP timestamp.
8065
/// The entry is removed from the map after a successful lookup.

livekit/src/room/track/remote_video_track.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,6 @@ impl RemoteVideoTrack {
9494
true
9595
}
9696

97-
/// Returns the last parsed user timestamp (in microseconds) for this
98-
/// remote video track, if the user timestamp transformer is enabled and
99-
/// a timestamp has been received.
100-
pub fn last_user_timestamp(&self) -> Option<i64> {
101-
self.rtc_track()
102-
.user_timestamp_handler()
103-
.and_then(|h| h.last_user_timestamp())
104-
}
105-
10697
/// Returns a clone of the user timestamp handler, if one has been set.
10798
pub fn user_timestamp_handler(&self) -> Option<UserTimestampHandler> {
10899
self.rtc_track().user_timestamp_handler()

webrtc-sys/include/livekit/user_timestamp.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ class UserTimestampTransformer : public webrtc::FrameTransformerInterface {
8282
void set_enabled(bool enabled);
8383
bool enabled() const;
8484

85-
/// Get the last received user timestamp (receiver side only)
86-
std::optional<int64_t> last_user_timestamp() const;
87-
8885
/// Lookup the user timestamp associated with a given RTP timestamp.
8986
/// Returns the user timestamp if found, nullopt otherwise.
9087
/// The entry is removed from the map after lookup.
@@ -121,9 +118,6 @@ class UserTimestampTransformer : public webrtc::FrameTransformerInterface {
121118
std::unordered_map<uint32_t,
122119
rtc::scoped_refptr<webrtc::TransformedFrameCallback>>
123120
sink_callbacks_;
124-
mutable std::atomic<int64_t> last_user_timestamp_{0};
125-
mutable std::atomic<bool> has_last_user_timestamp_{false};
126-
127121
// Send-side map: capture timestamp (us) -> user timestamp (us).
128122
// Populated by store_user_timestamp(), consumed by TransformSend()
129123
// via CaptureTime() lookup.
@@ -159,17 +153,10 @@ class UserTimestampHandler {
159153
void set_enabled(bool enabled) const;
160154
bool enabled() const;
161155

162-
/// Get the last received user timestamp (receiver side only)
163-
/// Returns -1 if no timestamp has been received yet
164-
int64_t last_user_timestamp() const;
165-
166156
/// Lookup the user timestamp for a given RTP timestamp (receiver side).
167157
/// Returns -1 if not found.
168158
int64_t lookup_user_timestamp(uint32_t rtp_timestamp) const;
169159

170-
/// Check if a user timestamp has been received
171-
bool has_user_timestamp() const;
172-
173160
/// Store a user timestamp for a given capture timestamp (sender side).
174161
/// Call this when capturing a video frame with a user timestamp.
175162
void store_user_timestamp(int64_t capture_timestamp_us,

webrtc-sys/src/user_timestamp.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,6 @@ void UserTimestampTransformer::TransformReceive(
170170
double recv_latency_ms =
171171
static_cast<double>(now_us - user_ts.value()) / 1000.0;
172172

173-
// Store the extracted timestamp for later retrieval (legacy atomic)
174-
last_user_timestamp_.store(user_ts.value());
175-
has_last_user_timestamp_.store(true);
176-
177173
// Store in the receive map keyed by RTP timestamp so decoded frames
178174
// can look up their user timestamp regardless of frame drops.
179175
{
@@ -333,14 +329,6 @@ bool UserTimestampTransformer::enabled() const {
333329
return enabled_.load();
334330
}
335331

336-
std::optional<int64_t> UserTimestampTransformer::last_user_timestamp()
337-
const {
338-
if (!has_last_user_timestamp_.load()) {
339-
return std::nullopt;
340-
}
341-
return last_user_timestamp_.load();
342-
}
343-
344332
std::optional<int64_t> UserTimestampTransformer::lookup_user_timestamp(
345333
uint32_t rtp_timestamp) {
346334
webrtc::MutexLock lock(&recv_map_mutex_);
@@ -422,20 +410,11 @@ bool UserTimestampHandler::enabled() const {
422410
return transformer_->enabled();
423411
}
424412

425-
int64_t UserTimestampHandler::last_user_timestamp() const {
426-
auto ts = transformer_->last_user_timestamp();
427-
return ts.value_or(-1);
428-
}
429-
430413
int64_t UserTimestampHandler::lookup_user_timestamp(uint32_t rtp_timestamp) const {
431414
auto ts = transformer_->lookup_user_timestamp(rtp_timestamp);
432415
return ts.value_or(-1);
433416
}
434417

435-
bool UserTimestampHandler::has_user_timestamp() const {
436-
return transformer_->last_user_timestamp().has_value();
437-
}
438-
439418
void UserTimestampHandler::store_user_timestamp(
440419
int64_t capture_timestamp_us,
441420
int64_t user_timestamp_us) const {

webrtc-sys/src/user_timestamp.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,10 @@ pub mod ffi {
3535
/// Check if timestamp embedding is enabled.
3636
fn enabled(self: &UserTimestampHandler) -> bool;
3737

38-
/// Get the last received user timestamp (receiver side only).
39-
/// Returns -1 if no timestamp has been received yet.
40-
fn last_user_timestamp(self: &UserTimestampHandler) -> i64;
41-
4238
/// Lookup the user timestamp for a given RTP timestamp (receiver side).
4339
/// Returns -1 if not found. The entry is removed after lookup.
4440
fn lookup_user_timestamp(self: &UserTimestampHandler, rtp_timestamp: u32) -> i64;
4541

46-
/// Check if a user timestamp has been received.
47-
fn has_user_timestamp(self: &UserTimestampHandler) -> bool;
48-
4942
/// Store a user timestamp for a given capture timestamp (sender side).
5043
/// Call this when capturing a video frame with a user timestamp.
5144
fn store_user_timestamp(

0 commit comments

Comments
 (0)