New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unclear how the getStats
track selector works in the context of RtpSenders.
#572
Comments
Spec says for getStats: "If selectorArg is neither null nor a valid selector, return a promise rejected with a TypeError." |
Since track B is the selector (not sender B), I'd expect seeing packets only for track B (not having checked yet what implementations do). |
Maybe we should consider senders (and receivers) as selectors? |
That's probably a good idea. But assuming we continue to allow tracks as selectors for backwards compatibility (and in case you do want the per-track stats), I think we'd still want to clarify this behavior. |
Typically, if the track is closed, the getstats returns the last stats with the corresponding timestamp. I'd imagine using the selector as track A, it would return 100 and if the selector is set to track B should return 200. |
I agree with Varun on what's reasonable to return (100 for A, 200 for B). And agree that considering an rtpsender as selector makes sense (and should return 300). We always thought the selector should be multi-type eventually, we chose "track" rather than "any" to keep track of what we thought it should work with. |
So it sounds like people are in agreement that:
This does add some complexity though, as it means the selector doesn't only filter which If this is what we want, I think there should be some text explicitly calling this out. |
I agree with 1 (or rather, the RtpSender is irrelevant atm). I don't think anyone needs the complexity of 2. I find no requirement in the spec that history needs to be kept, or that selector is anything but a filter. I know there was talk about adding language about |
@vr000m what do you think? This is a stats issue.... |
I would like to understand what is the complexity of keeping the last snapshot for all the tracks an RtpSender may have seen. Consider the following case, where the getStats are polled regularly by a third-party library, which is not the app. The third party does not know that a track was going to be removed. Removing a track may fire an event and the third party library may catch it and poll for the stats for the track. I would love to be able to do that. |
re-reading the above. I could live with following:
This way, the getStats returns active SSRCs, and if needed the third-party library detects some tracks missing, it could fetch the last stats for those missing track. |
@alvestrand This is definitely a stats issue, should it be tackled in webrtc-pc or webrtc-stats, is a matter of opinion. On what the selector can be and where should it be documented. |
@vr000m how would (2) work if you remove a track from the connection and add it back later? This seems like a confusing handle. Maybe it was a mistake to add track as a selector in the first place? We didn't have senders and receivers back then. Tracks are used for all kinds of (even non-peer connection) things, and aren't really specific to transmission. I'm inclined to switch focus to senders and receivers, and look to deprecating tracks as selectors. |
Hm.... are we getting to a point where there's a suggestion to drop the selector parameter to getStats()? |
Not from me. I was merely wondering if senders and receivers made for better selectors. This is moving a little fast for me. In my mind (and implementation), any selector is merely a filter applied to the getStats snowball. This changed with w3c/webrtc-stats#8 (which has already merged) and marks a departure where we're suddenly talking about storing stats for objects that are no longer attached to the peer connection. Does this mean the selector is no longer a filter, or am I to infer that This feels odd to implement, since there's no caching of stats in our implementation, all data is live and fresh. The only snapshoting that happens in Firefox is at close, and that's just a grab of the whole snowball at a high level. It's also odd to see us cementing the snapshot idea without much discussion. It always felt like a hack to me, where these at-close snapshots feel like poor substitutes for stats representing an "overall" call, and I worry people will mistake them for that. For stats that accumulate, like packets received, the last stat is also the overall stat, but for something like, say, jitter, the last jitter reported may be very different and inconsequential compared to the overall average jitter jitter for the call, if that makes any sense. |
Closing this issue for now, it seems that we don't want to add those things as selectors at the moment. |
Suppose you have an
RtpSender
sending trackA
. It send 100 packets with this track.Then you call
sender.replaceTrack(B)
, and the sender sends 200 packets from the new track.Now, if you call
pc.getStats(A)
, what happens? The spec says:So is the promise rejected with an error, since track
A
is no longer being sent?Conversely, if you call
pc.getStats(B)
, do you see stats from only the period when the sender was sending trackB
(packetsSent
is 200), or from the entire history of the sender (packetsSent
is 300)?The text was updated successfully, but these errors were encountered: