This PR fixes negative metrics increments when toggling AirPlay (external playback).
These occur because the AVPlayerItemAccessLog is cleared when transitioning between devices, leading to a decrease in totals and thus to negative increments.
Fixing this issue requires seing local and remote sessions as separate. We cannot namely reliably merge local and distant sessions, as this would require us to be able to capture the most recent AVPlayerItemAccessLogEvent values just before AirPlay is toggled. The issue is that we are often too late when we can detect that AirPlay has been toggled, so that we cannot capture most recent values, only new ones (empty just after the transition into / out of AirPlay).
Changes made
Make MetricsState construction simpler. We had inherited an update-based API from our many iterations, but this was not used at all.
Remove cached metrics from PlayerProperties. Those were always calculated from scratch anyway.
Clear metrics when toggling external playback.
Remove CombineLatest8 which is not needed anymore.
Checklist
[x] APIs have been properly documented (if relevant).
[x] The documentation has been updated (if relevant).
[x] New unit tests have been written (if relevant).
Description
This PR fixes negative metrics increments when toggling AirPlay (external playback).
These occur because the
AVPlayerItemAccessLog
is cleared when transitioning between devices, leading to a decrease in totals and thus to negative increments.Fixing this issue requires seing local and remote sessions as separate. We cannot namely reliably merge local and distant sessions, as this would require us to be able to capture the most recent
AVPlayerItemAccessLogEvent
values just before AirPlay is toggled. The issue is that we are often too late when we can detect that AirPlay has been toggled, so that we cannot capture most recent values, only new ones (empty just after the transition into / out of AirPlay).Changes made
MetricsState
construction simpler. We had inherited an update-based API from our many iterations, but this was not used at all.PlayerProperties
. Those were always calculated from scratch anyway.CombineLatest8
which is not needed anymore.Checklist