Re: [webrtc-pc] Add paragraph about RtpContributingSources being updated simultaneously.

@jan-ivar Putting this in the form of an algorithm is probably a good idea since that's what we do in most places.

Would we be covered if I just replaced "when X happens, the relevant `RTCRtpContributingSource` objects are updated" with "when X happens, the user agent MUST queue a task to update the relevant `RTCRtpContributingSource` objects"? The actual implementation would still be allowed to do something different, due to this paragraph:

> Conformance requirements phrased as algorithms or specific steps may be implemented in any manner, so long as the end result is equivalent. (In particular, the algorithms defined in this specification are intended to be easy to follow, and not intended to be performant.)

Can you confirm that this is flexible enough to make Chrome's current implementation legal? Since queuing a task for each packet received is obviously bad for performance, it's doing the equivalent of this instead (code simplified for brevity):

```
RTCContributingSources RTCRtpReceiver::getContributingSources() {
  if (should_update_) {
    UpdateRTCContributingSources(internal_receiver_->GetContributingSources());
    should_update_ = false;
  }
  queueMicrotask([this] { should_update_ = true; });
  return contributing_sources_;
}

// Many, many layers of code deeper:
void InternalRtpReceiver::OnPacketReceived(Packet* p) {
  ScopedCriticalSection(cs_);
  UpdateContributingSources(p);
  // ...
}

ContributingSources InternalRtpReceiver::GetContributingSources() {
  ScopedCriticalSection(cs_);
  return contributing_sources_;
}
```

The full code can be seen [here](https://cs.chromium.org/chromium/src/third_party/WebKit/Source/modules/peerconnection/RTCRtpReceiver.cpp?type=cs&q=getcontributingsources&l=26).

Anyway, this ensures:

1. Within a single event loop task execution, the attributes of a given `RTCRtpContributingSource` will not change.
2. Within a single event loop task execution, all of the `RTCRtpContributingSource` objects for a given receiver will return information for the same point in the RTP stream.

Those are the requirements I really wanted to convey, but I was unsure how to phrase them in terminology that's consistent with the rest of the spec.

-- 
GitHub Notification of comment by taylor-b
Please view or discuss this issue at https://github.com/w3c/webrtc-pc/pull/1149#issuecomment-299309610 using your GitHub account

Received on Thursday, 4 May 2017 21:08:21 UTC