Skip to content

Commit

Permalink
Add jitterBufferTarget attribute to RTCRtpReceiver interface accordin…
Browse files Browse the repository at this point in the history
…g to the spec.

Audio test case in WPT RTCRtpReceiver-jitterBufferTarget-stats.html remains failing due to a problem that without audio tag webrtc receive streams can not be played back and because of that jitter buffer stats are empty. Otherwise it was manually verified that when adding audio tag  the test case would start passing.

Bug: 324276557

Change-Id: I06cbba95a7f78c20cc7bf803819fcfb5ef2f6be5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5278176
Commit-Queue: Philipp Hancke <[email protected]>
Reviewed-by: Henrik Boström <[email protected]>
Reviewed-by: Harald Alvestrand <[email protected]>
Reviewed-by: Rick Byers <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1262622}
  • Loading branch information
eldarrello authored and Chromium LUCI CQ committed Feb 20, 2024
1 parent 88b0eca commit 8734f19
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 30 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ Egor Starkov <[email protected]>
Ehsan Akhgari <[email protected]>
Ehsan Akhgari <[email protected]>
Elan Ruusamäe <[email protected]>
Eldar Rello <[email protected]>
Ely Ronnen <[email protected]>
Emil Suleymanov <[email protected]>
Ergun Erdogmus <[email protected]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4223,6 +4223,8 @@ enum WebFeature {
kV8PointerEvent_GetCoalescedEvents_Method = 4859,
kCSSFunctions = 4861,
kCSSPageRule = 4862,
kV8RTCRtpReceiver_JitterBufferTarget_AttributeGetter = 4863,
kV8RTCRtpReceiver_JitterBufferTarget_AttributeSetter = 4864,

// Add new features immediately above this line. Don't change assigned
// numbers of any item, and don't reuse removed slots.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,29 @@ void RTCRtpReceiver::setPlayoutDelayHint(std::optional<double> hint,
receiver_->SetJitterBufferMinimumDelay(playout_delay_hint_);
}

std::optional<double> RTCRtpReceiver::jitterBufferTarget() const {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
return jitter_buffer_target_;
}

void RTCRtpReceiver::setJitterBufferTarget(std::optional<double> target,
ExceptionState& exception_state) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (target.has_value() && (target.value() < 0.0 || target.value() > 4000.0)) {
exception_state.ThrowRangeError(
"jitterBufferTarget is out of expected range 0 to 4000 ms");
return;
}

jitter_buffer_target_ = target;
if (jitter_buffer_target_.has_value()) {
receiver_->SetJitterBufferMinimumDelay(jitter_buffer_target_.value() /
1000.0);
} else {
receiver_->SetJitterBufferMinimumDelay(std::nullopt);
}
}

HeapVector<Member<RTCRtpSynchronizationSource>>
RTCRtpReceiver::getSynchronizationSources(ScriptState* script_state,
ExceptionState& exception_state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class RTCRtpReceiver final : public ScriptWrappable,
RTCDtlsTransport* rtcpTransport();
std::optional<double> playoutDelayHint() const;
void setPlayoutDelayHint(std::optional<double>, ExceptionState&);
std::optional<double> jitterBufferTarget() const;
void setJitterBufferTarget(std::optional<double>, ExceptionState&);
RTCRtpReceiveParameters* getParameters();
HeapVector<Member<RTCRtpSynchronizationSource>> getSynchronizationSources(
ScriptState*,
Expand Down Expand Up @@ -141,6 +143,7 @@ class RTCRtpReceiver final : public ScriptWrappable,
// observed delay may differ depending on the congestion control. |nullopt|
// means default value must be used.
std::optional<double> playout_delay_hint_;
std::optional<double> jitter_buffer_target_;

THREAD_CHECKER(thread_checker_);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ interface RTCRtpReceiver {
readonly attribute RTCDtlsTransport? rtcpTransport;
// https://henbos.github.io/webrtc-extensions/#dom-rtcrtpreceiver-playoutdelayhint
[RaisesException=Setter, Measure] attribute double? playoutDelayHint;
// https://w3c.github.io/webrtc-extensions/#dom-rtcrtpreceiver-jitterbuffertarget
[RaisesException=Setter, Measure, RuntimeEnabled=RTCJitterBufferTarget] attribute double? jitterBufferTarget;
[CallWith=ScriptState, HighEntropy, Measure] static RTCRtpCapabilities? getCapabilities(DOMString kind);
RTCRtpReceiveParameters getParameters();
[CallWith=ScriptState, RaisesException] sequence<RTCRtpSynchronizationSource> getSynchronizationSources();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3152,6 +3152,12 @@
name: "RTCEncodedVideoFrameAdditionalMetadata",
status: "experimental",
},
// Enables the use of jitterBufferTarget attribute in WebRTC.
// Spec: https://w3c.github.io/webrtc-extensions/#dom-rtcrtpreceiver-jitterbuffertarget
{
name: "RTCJitterBufferTarget",
status: "stable",
},
// Legacy callback-based getStats() has limited availability unless this
// Deprecation Trial is enabled.
// TODO(https://crbug.com/822696): Remove when origin trial ends.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
This is a testharness.js-based test.
[FAIL] measure raising and lowering video jitterBufferTarget
assert_equals: jitterBufferTarget supported for video expected (object) null but got (undefined) undefined
[FAIL] measure raising and lowering audio jitterBufferTarget
assert_equals: jitterBufferTarget supported for audio expected (object) null but got (undefined) undefined
assert_greater_than: audio increased delay NaN greater than base delay NaN expected a number greater than NaN but got NaN
Harness: the test ran to completion.

Original file line number Diff line number Diff line change
Expand Up @@ -6739,6 +6739,7 @@ interface RTCPeerConnectionIceEvent : Event
interface RTCRtpReceiver
static method getCapabilities
attribute @@toStringTag
getter jitterBufferTarget
getter playoutDelayHint
getter rtcpTransport
getter track
Expand All @@ -6749,6 +6750,7 @@ interface RTCRtpReceiver
method getParameters
method getStats
method getSynchronizationSources
setter jitterBufferTarget
setter playoutDelayHint
interface RTCRtpSender
static method getCapabilities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7746,6 +7746,7 @@ interface RTCPeerConnectionIceEvent : Event
interface RTCRtpReceiver
static method getCapabilities
attribute @@toStringTag
getter jitterBufferTarget
getter playoutDelayHint
getter rtcpTransport
getter track
Expand All @@ -7756,6 +7757,7 @@ interface RTCRtpReceiver
method getParameters
method getStats
method getSynchronizationSources
setter jitterBufferTarget
setter playoutDelayHint
interface RTCRtpSender
static method getCapabilities
Expand Down
4 changes: 4 additions & 0 deletions tools/metrics/histograms/enums.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11240,6 +11240,10 @@ Called by update_use_counter_feature_enum.py.-->
<int value="4859" label="V8PointerEvent_GetCoalescedEvents_Method"/>
<int value="4861" label="CSSFunctions"/>
<int value="4862" label="CSSPageRule"/>
<int value="4863"
label="V8RTCRtpReceiver_JitterBufferTarget_AttributeGetter"/>
<int value="4864"
label="V8RTCRtpReceiver_JitterBufferTarget_AttributeSetter"/>
</enum>

<enum name="FeaturePolicyFeature">
Expand Down

0 comments on commit 8734f19

Please sign in to comment.