0

Set RTCEncodedVideoFrame's timestamp to capture_begin_time if available

Doc: go/capture-timestamp-flake


Bug: 333420614, 333739617
Change-Id: Ibed94b57dfcd79a35976e53ea4547b0a40d4dd26
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5493785
Reviewed-by: Guido Urdaneta <guidou@chromium.org>
Commit-Queue: Palak Agarwal <agpalak@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1295378}
This commit is contained in:
Palak Agarwal
2024-05-02 11:38:36 +00:00
committed by Chromium LUCI CQ
parent 48a945323a
commit 1c245af571
2 changed files with 10 additions and 4 deletions
third_party/blink
renderer
platform
web_tests

@ -262,9 +262,15 @@ void WebRtcVideoTrackSource::OnFrameCaptured(
}
std::optional<webrtc::Timestamp> capture_time_identifier;
// Set |capture_time_identifier| only when frame->timestamp() is a valid
// value (infinite values are invalid).
if (!frame->timestamp().is_inf()) {
// Set |capture_time_identifier| to capture_begin_time if available, else use
// frame->timestamp().
if (base::FeatureList::IsEnabled(features::kWebRtcUseCaptureBeginTimestamp) &&
frame->metadata().capture_begin_time) {
capture_time_identifier = webrtc::Timestamp::Micros(
frame->metadata().capture_begin_time->ToInternalValue());
} else if (!frame->timestamp().is_inf()) {
// Use only when frame->timestamp() is a valid value (infinite values are
// invalid).
capture_time_identifier =
webrtc::Timestamp::Micros(frame->timestamp().InMicroseconds());
}

@ -13,7 +13,7 @@ const callee = new RTCPeerConnection({ encodedInsertableStreams: true });
t.add_cleanup(() => callee.close());
exchangeIceCandidates(caller, callee);
const stream = await getNoiseStream({ video: true });
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
const videoTrack = stream.getVideoTracks()[0];
t.add_cleanup(() => videoTrack.stop());