Skip to content

Commit c45d125

Browse files
authored
Merge pull request #240 from w3c/guidou/capture-timestamp
Add captureTime and senderCaptureTimeOffset to frame metadata
2 parents 9c84f99 + f259a4d commit c45d125

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

index.bs

+70
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ spec:webidl; type:dfn; text:resolve
4848
"CloneArrayBuffer": {
4949
"href": "https://tc39.es/ecma262/#sec-clonearraybuffer",
5050
"title": "CloneArrayBuffer"
51+
},
52+
"RTP-EXT-CAPTURE-TIME": {
53+
"href": "https://datatracker.ietf.org/doc/draft-ietf-avtcore-abs-capture-time/",
54+
"title": "RTP Header Extension for Absolute Capture Time",
55+
"publisher": "IETF"
5156
}
5257
}
5358
</pre>
@@ -134,6 +139,20 @@ The <dfn abstract-op>readEncodedData</dfn> algorithm is given a |rtcObject| as p
134139
1. Let |frame| be the newly produced frame.
135140
1. Set |frame|.`[[owner]]` to |rtcObject|.
136141
1. Set |frame|.`[[counter]]` to |rtcObject|.`[[lastEnqueuedFrameCounter]]`.
142+
1. If the frame has been produced by a {{RTCRtpReceiver}}:
143+
1. If the relevant RTP packet contains the
144+
[[RTP-EXT-CAPTURE-TIME|RTP Header Extension for Absolute Capture Time]], set |frame|.`[[captureTime]]` to the
145+
[[RTP-EXT-CAPTURE-TIME#absolute-capture-timestamp|absolute capture timestamp]] field and set |frame|.`[[senderCaptureTimeOffset]]`
146+
to the [[RTP-EXT-CAPTURE-TIME#estimated-capture-clock-offset|capture clock offset field]] if it is present.
147+
1. Otherwise, if the relevant RTP packet does not contain the
148+
[[RTP-EXT-CAPTURE-TIME|RTP Header Extension for Absolute Capture Time]] but a previous RTP packet did,
149+
set |frame|.`[[captureTime]]` to the result of calculating the absolute capture timestamp according to
150+
[[RTP-EXT-CAPTURE-TIME#timestamp-interpolation|timestamp interpolation]] and set |frame|.`[[senderCaptureTimeOffset]]`
151+
to the most recent value that was present.
152+
1. Otherwise, set |frame|.`[[captureTime]]` to undefined and set |frame|.`[[senderCaptureTimeOffset]]` to undefined.
153+
1. If the frame has been produced by a {{RTCRtpSender}}, set |frame|.`[[captureTime]]` to the capture timestamp
154+
using the methodology described in [[RTP-EXT-CAPTURE-TIME#absolute-capture-timestamp]] and set frame.`[[senderCaptureTimeOffset]]`
155+
to undefined.
137156
1. [=ReadableStream/Enqueue=] |frame| in |rtcObject|.`[[readable]]`.
138157

139158
The <dfn abstract-op>writeEncodedData</dfn> algorithm is given a |rtcObject| as parameter and a |frame| as input. It is defined by running the following steps:
@@ -293,6 +312,10 @@ The <dfn method for="SFrameTransform">setEncryptionKey(|key|, |keyID|)</dfn> met
293312

294313
# RTCRtpScriptTransform # {#scriptTransform}
295314

315+
In this section, the capture system refers to the system where media is sourced from and the sender system
316+
refers to the system that is sending RTP and RTCP packets to the receiver system where {{RTCEncodedVideoFrameMetadata}} data
317+
or {{RTCEncodedAudioFrameMetadata}} data is populated.
318+
296319
## <dfn enum>RTCEncodedVideoFrameType</dfn> dictionary ## {#RTCEncodedVideoFrameType}
297320
<pre class="idl">
298321
// New enum for video frame types. Will eventually re-use the equivalent defined
@@ -359,6 +382,8 @@ dictionary RTCEncodedVideoFrameMetadata {
359382
long long timestamp; // microseconds
360383
unsigned long rtpTimestamp;
361384
DOMHighResTimeStamp receiveTime;
385+
DOMHighResTimeStamp captureTime;
386+
DOMHighResTimeStamp senderCaptureTimeOffset;
362387
DOMString mimeType;
363388
};
364389
</pre>
@@ -444,6 +469,27 @@ dictionary RTCEncodedVideoFrameMetadata {
444469
Only exists for incoming video frames.
445470
</p>
446471
</dd>
472+
<dt>
473+
<dfn dict-member>captureTime</dfn> <span class="idlMemberType">DOMHighResTimeStamp</span>
474+
</dt>
475+
<dd>
476+
<p>
477+
The capture time of this frame in the capture system's clock.
478+
On populating this member, the user agent MUST return the value of the frame's `[[captureTime]]` slot,
479+
shifted to be relative to {{Performance}}.{{Performance/timeOrigin}}.
480+
</p>
481+
</dd>
482+
<dt>
483+
<dfn dict-member>senderCaptureTimeOffset</dfn> <span class="idlMemberType">DOMHighResTimeStamp</span>
484+
</dt>
485+
<dd>
486+
<p>
487+
The {{RTCEncodedVideoFrameMetadata/senderCaptureTimeOffset}} is the sender system's estimate of the offset
488+
between its own NTP clock and the capture system's NTP clock, for the same frame that the
489+
{{RTCEncodedVideoFrameMetadata/captureTime}} was originated from.
490+
On populating this member, the user agent MUST return the value of the frame's `[[senderCaptureTimeOffset]]` slot.
491+
</p>
492+
</dd>
447493
<dt>
448494
<dfn dict-member>mimeType</dfn> <span class="idlMemberType">DOMString</span>
449495
</dt>
@@ -628,6 +674,8 @@ dictionary RTCEncodedAudioFrameMetadata {
628674
short sequenceNumber;
629675
unsigned long rtpTimestamp;
630676
DOMHighResTimeStamp receiveTime;
677+
DOMHighResTimeStamp captureTime;
678+
DOMHighResTimeStamp senderCaptureTimeOffset;
631679
DOMString mimeType;
632680
};
633681
</pre>
@@ -692,6 +740,28 @@ dictionary RTCEncodedAudioFrameMetadata {
692740
timestamp is relative to {{Performance}}.{{Performance/timeOrigin}}.
693741
Only exists for incoming audio frames.
694742
</p>
743+
</dd>
744+
<dt>
745+
<dfn dict-member>captureTime</dfn> <span class="idlMemberType">DOMHighResTimeStamp</span>
746+
</dt>
747+
<dd>
748+
<p>
749+
The capture time of this frame in the capture system's clock.
750+
On populating this member, the user agent MUST return the value of the frame's `[[captureTime]]` slot,
751+
shifted to be relative to {{Performance}}.{{Performance/timeOrigin}}.
752+
</p>
753+
</dd>
754+
<dt>
755+
<dfn dict-member>senderCaptureTimeOffset</dfn> <span class="idlMemberType">DOMHighResTimeStamp</span>
756+
</dt>
757+
<dd>
758+
<p>
759+
The {{RTCEncodedAudioFrameMetadata/senderCaptureTimeOffset}} is the sender system's estimate of the offset
760+
between its own NTP clock and the capture system's NTP clock, for the same frame that the
761+
{{RTCEncodedAudioFrameMetadata/captureTime}} was originated from.
762+
On populating this member, the user agent MUST return the value of the frame's `[[senderCaptureTimeOffset]]` slot.
763+
</p>
764+
</dd>
695765
<dt>
696766
<dfn dict-member>mimeType</dfn> <span class="idlMemberType">DOMString</span>
697767
</dt>

0 commit comments

Comments
 (0)