Bug 1882567 - record EME playback info with Glean. r=alwu

Differential Revision: https://phabricator.services.mozilla.com/D204947
This commit is contained in:
John Lin 2024-03-28 19:57:53 +00:00
parent d9e043e222
commit 91c1230ee4
4 changed files with 63 additions and 1 deletions

View File

@ -0,0 +1,42 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# Adding a new metric? We have docs for that!
# https://firefox-source-docs.mozilla.org/toolkit/components/glean/user/new_definitions_file.html
---
$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0
$tags:
- 'Core :: Audio/Video'
mediadrm:
eme_playback:
type: event
description: >
Record the EME play time with the video codec and resolutions.
metadata:
tags:
- 'Core :: Audio/Video: Playback'
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1882567
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1882567#3
data_sensitivity:
- technical
notification_emails:
- media-alerts@mozilla.com
extra_keys:
key_system:
description: The key system used for the EME playback
type: string
played_time:
description: How many second the EME content has been played since last record
type: quantity
resolution:
description: The video resolution used for EME playback
type: string
video_codec:
description: The video codec used for EME playback
type: string
expires: never

View File

@ -465,6 +465,7 @@ void TelemetryProbesReporter::ReportResultForVideo() {
SECONDS_TO_MS(totalVideoPlayTimeS));
}
// TODO: deprecate the old probes.
// Report result for video using CDM
auto keySystem = mOwner->GetKeySystem();
if (keySystem) {
@ -519,6 +520,10 @@ void TelemetryProbesReporter::ReportResultForVideo() {
ReportResultForMFCDMPlaybackIfNeeded(totalVideoPlayTimeS, key);
}
#endif
if (keySystem) {
ReportPlaytimeForKeySystem(*keySystem, totalVideoPlayTimeS,
info.mVideo.mMimeType, key);
}
}
#ifdef MOZ_WMF_CDM
@ -564,6 +569,17 @@ void TelemetryProbesReporter::ReportResultForMFCDMPlaybackIfNeeded(
}
#endif
void TelemetryProbesReporter::ReportPlaytimeForKeySystem(
const nsAString& aKeySystem, const double aTotalPlayTimeS,
const nsCString& aCodec, const nsCString& aResolution) {
glean::mediadrm::EmePlaybackExtra extra = {
.keySystem = Some(NS_ConvertUTF16toUTF8(aKeySystem)),
.playedTime = Some(aTotalPlayTimeS),
.resolution = Some(aResolution),
.videoCodec = Some(aCodec)};
glean::mediadrm::eme_playback.Record(Some(extra));
}
void TelemetryProbesReporter::ReportResultForAudio() {
// Don't record telemetry for a media that didn't have a valid audio or video
// to play, or hasn't played.

View File

@ -100,7 +100,10 @@ class TelemetryProbesReporter final {
void ReportResultForMFCDMPlaybackIfNeeded(double aTotalPlayTimeS,
const nsCString& aResolution);
#endif
void ReportPlaytimeForKeySystem(const nsAString& aKeySystem,
const double aTotalPlayTimeS,
const nsCString& aCodec,
const nsCString& aResolution);
// Helper class to measure times for playback telemetry stats
class TimeDurationAccumulator {
public:

View File

@ -18,6 +18,7 @@ gecko_metrics = [
"browser/base/content/metrics.yaml",
"docshell/base/metrics.yaml",
"dom/base/use_counter_metrics.yaml",
"dom/media/eme/metrics.yaml",
"dom/media/hls/metrics.yaml",
"dom/media/metrics.yaml",
"dom/media/webrtc/metrics.yaml",