Bug 1289668 - HTMLMediaElement uses video decoder's frame statistics - r=kamidphish
HTMLVideoElement can expose its thread-safe FrameStatistics object, so that HTMLMediaElement can access more adequate data for its telemetry, without having to use an intermediary (and potentially less accurate) VideoPlaybackQuality object. This will also help with accessing other/new FrameStatistics members later on. MozReview-Commit-ID: AT7mEGy0zGr
This commit is contained in:
@@ -3084,18 +3084,19 @@ HTMLMediaElement::ReportTelemetry()
|
||||
LOG(LogLevel::Debug, ("%p VIDEO_UNLOAD_STATE = %d", this, state));
|
||||
|
||||
if (HTMLVideoElement* vid = HTMLVideoElement::FromContentOrNull(this)) {
|
||||
RefPtr<VideoPlaybackQuality> quality = vid->GetVideoPlaybackQuality();
|
||||
uint32_t totalFrames = quality->TotalVideoFrames();
|
||||
if (totalFrames) {
|
||||
uint32_t droppedFrames = quality->DroppedVideoFrames();
|
||||
MOZ_ASSERT(droppedFrames <= totalFrames);
|
||||
// Dropped frames <= total frames, so 'percentage' cannot be higher than
|
||||
// 100 and therefore can fit in a uint32_t (that Telemetry takes).
|
||||
uint32_t percentage = 100 * droppedFrames / totalFrames;
|
||||
LOG(LogLevel::Debug,
|
||||
("Reporting telemetry DROPPED_FRAMES_IN_VIDEO_PLAYBACK"));
|
||||
Telemetry::Accumulate(Telemetry::VIDEO_DROPPED_FRAMES_PROPORTION,
|
||||
percentage);
|
||||
FrameStatistics* stats = vid->GetFrameStatistics();
|
||||
if (stats) {
|
||||
FrameStatisticsData data = stats->GetFrameStatisticsData();
|
||||
if (data.mParsedFrames) {
|
||||
MOZ_ASSERT(data.mDroppedFrames <= data.mParsedFrames);
|
||||
// Dropped frames <= total frames, so 'percentage' cannot be higher than
|
||||
// 100 and therefore can fit in a uint32_t (that Telemetry takes).
|
||||
uint32_t percentage = 100 * data.mDroppedFrames / data.mParsedFrames;
|
||||
LOG(LogLevel::Debug,
|
||||
("Reporting telemetry DROPPED_FRAMES_IN_VIDEO_PLAYBACK"));
|
||||
Telemetry::Accumulate(Telemetry::VIDEO_DROPPED_FRAMES_PROPORTION,
|
||||
percentage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user