From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- dom/media/utils/PerformanceRecorder.cpp | 2 + dom/media/utils/PerformanceRecorder.h | 1 + dom/media/utils/TelemetryProbesReporter.cpp | 71 +++++++++++++++++++++++------ dom/media/utils/TelemetryProbesReporter.h | 22 +++++++-- 4 files changed, 78 insertions(+), 18 deletions(-) (limited to 'dom/media/utils') diff --git a/dom/media/utils/PerformanceRecorder.cpp b/dom/media/utils/PerformanceRecorder.cpp index d6124e8cf6..3dc2c24a5d 100644 --- a/dom/media/utils/PerformanceRecorder.cpp +++ b/dom/media/utils/PerformanceRecorder.cpp @@ -140,6 +140,8 @@ static void AppendImageFormatToName(nsCString& aName, return "gbrp,"; case DecodeStage::ANDROID_SURFACE: return "android.Surface,"; + case DecodeStage::VAAPI_SURFACE: + return "VAAPI.Surface,"; } MOZ_ASSERT_UNREACHABLE("Unhandled DecodeStage::ImageFormat"); return ""; diff --git a/dom/media/utils/PerformanceRecorder.h b/dom/media/utils/PerformanceRecorder.h index 34c6676b01..e423c3fb5d 100644 --- a/dom/media/utils/PerformanceRecorder.h +++ b/dom/media/utils/PerformanceRecorder.h @@ -216,6 +216,7 @@ class DecodeStage { RGB24, GBRP, ANDROID_SURFACE, + VAAPI_SURFACE, }; DecodeStage(nsCString aSource, TrackingId aTrackingId, MediaInfoFlag aFlag) diff --git a/dom/media/utils/TelemetryProbesReporter.cpp b/dom/media/utils/TelemetryProbesReporter.cpp index 8c5614c048..377cee9abc 100644 --- a/dom/media/utils/TelemetryProbesReporter.cpp +++ b/dom/media/utils/TelemetryProbesReporter.cpp @@ -293,23 +293,30 @@ void TelemetryProbesReporter::OnDecodeResumed() { } void TelemetryProbesReporter::OntFirstFrameLoaded( - const TimeDuration& aLoadedFirstFrameTime, bool aIsMSE, - bool aIsExternalEngineStateMachine) { - const MediaInfo& info = mOwner->GetMediaInfo(); - MOZ_ASSERT(info.HasVideo()); + const double aLoadedFirstFrameTime, const double aLoadedMetadataTime, + const double aTotalWaitingDataTime, const double aTotalBufferingTime, + const FirstFrameLoadedFlagSet aFlags, const MediaInfo& aInfo) { + MOZ_ASSERT(aInfo.HasVideo()); nsCString resolution; - DetermineResolutionForTelemetry(info, resolution); + DetermineResolutionForTelemetry(aInfo, resolution); + + const bool isMSE = aFlags.contains(FirstFrameLoadedFlag::IsMSE); + const bool isExternalEngineStateMachine = + aFlags.contains(FirstFrameLoadedFlag::IsExternalEngineStateMachine); glean::media_playback::FirstFrameLoadedExtra extraData; - extraData.firstFrameLoadedTime = Some(aLoadedFirstFrameTime.ToMilliseconds()); - if (!aIsMSE && !aIsExternalEngineStateMachine) { + extraData.firstFrameLoadedTime = Some(aLoadedFirstFrameTime); + extraData.metadataLoadedTime = Some(aLoadedMetadataTime); + extraData.totalWaitingDataTime = Some(aTotalWaitingDataTime); + extraData.bufferingTime = Some(aTotalBufferingTime); + if (!isMSE && !isExternalEngineStateMachine) { extraData.playbackType = Some("Non-MSE playback"_ns); - } else if (aIsMSE && !aIsExternalEngineStateMachine) { + } else if (isMSE && !isExternalEngineStateMachine) { extraData.playbackType = !mOwner->IsEncrypted() ? Some("MSE playback"_ns) : Some("EME playback"_ns); - } else if (!aIsMSE && aIsExternalEngineStateMachine) { + } else if (!isMSE && isExternalEngineStateMachine) { extraData.playbackType = Some("Non-MSE media-engine playback"_ns); - } else if (aIsMSE && aIsExternalEngineStateMachine) { + } else if (isMSE && isExternalEngineStateMachine) { extraData.playbackType = !mOwner->IsEncrypted() ? Some("MSE media-engine playback"_ns) : Some("EME media-engine playback"_ns); @@ -317,18 +324,35 @@ void TelemetryProbesReporter::OntFirstFrameLoaded( extraData.playbackType = Some("ERROR TYPE"_ns); MOZ_ASSERT(false, "Unexpected playback type!"); } - extraData.videoCodec = Some(info.mVideo.mMimeType); + extraData.videoCodec = Some(aInfo.mVideo.mMimeType); extraData.resolution = Some(resolution); if (const auto keySystem = mOwner->GetKeySystem()) { extraData.keySystem = Some(NS_ConvertUTF16toUTF8(*keySystem)); } + if (aFlags.contains(FirstFrameLoadedFlag::IsHardwareDecoding)) { + extraData.isHardwareDecoding = Some(true); + } + +#ifdef MOZ_WIDGET_ANDROID + if (aFlags.contains(FirstFrameLoadedFlag::IsHLS)) { + extraData.hlsDecoder = Some(true); + } +#endif if (MOZ_LOG_TEST(gTelemetryProbesReporterLog, LogLevel::Debug)) { nsPrintfCString logMessage{ - "Media_Playabck First_Frame_Loaded event, time(ms)=%f, " - "playback-type=%s, videoCodec=%s, resolution=%s", - aLoadedFirstFrameTime.ToMilliseconds(), extraData.playbackType->get(), - extraData.videoCodec->get(), extraData.resolution->get()}; + "Media_Playabck First_Frame_Loaded event, time(ms)=[" + "full:%f, loading-meta:%f, waiting-data:%f, buffering:%f], " + "playback-type=%s, " + "videoCodec=%s, resolution=%s, hardware=%d", + aLoadedFirstFrameTime, + aLoadedMetadataTime, + aTotalWaitingDataTime, + aTotalBufferingTime, + extraData.playbackType->get(), + extraData.videoCodec->get(), + extraData.resolution->get(), + aFlags.contains(FirstFrameLoadedFlag::IsHardwareDecoding)}; if (const auto keySystem = mOwner->GetKeySystem()) { logMessage.Append(nsPrintfCString{ ", keySystem=%s", NS_ConvertUTF16toUTF8(*keySystem).get()}); @@ -336,6 +360,7 @@ void TelemetryProbesReporter::OntFirstFrameLoaded( LOG("%s", logMessage.get()); } glean::media_playback::first_frame_loaded.Record(Some(extraData)); + mOwner->DispatchAsyncTestingEvent(u"mozfirstframeloadedprobe"_ns); } void TelemetryProbesReporter::OnShutdown() { @@ -465,6 +490,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 +545,10 @@ void TelemetryProbesReporter::ReportResultForVideo() { ReportResultForMFCDMPlaybackIfNeeded(totalVideoPlayTimeS, key); } #endif + if (keySystem) { + ReportPlaytimeForKeySystem(*keySystem, totalVideoPlayTimeS, + info.mVideo.mMimeType, key); + } } #ifdef MOZ_WMF_CDM @@ -564,6 +594,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. diff --git a/dom/media/utils/TelemetryProbesReporter.h b/dom/media/utils/TelemetryProbesReporter.h index be81e8022c..43e05dcadd 100644 --- a/dom/media/utils/TelemetryProbesReporter.h +++ b/dom/media/utils/TelemetryProbesReporter.h @@ -8,6 +8,7 @@ #include "MediaInfo.h" #include "mozilla/Maybe.h" #include "mozilla/AwakeTimeStamp.h" +#include "mozilla/EnumSet.h" #include "AudioChannelService.h" #include "nsISupportsImpl.h" @@ -66,8 +67,20 @@ class TelemetryProbesReporter final { void OnMutedChanged(bool aMuted); void OnDecodeSuspended(); void OnDecodeResumed(); - void OntFirstFrameLoaded(const TimeDuration& aLoadedFirstFrameTime, - bool aIsMSE, bool aIsExternalEngineStateMachine); + + enum class FirstFrameLoadedFlag { + IsMSE, + IsExternalEngineStateMachine, + IsHLS, + IsHardwareDecoding, + }; + using FirstFrameLoadedFlagSet = EnumSet; + void OntFirstFrameLoaded(const double aLoadedFirstFrameTime, + const double aLoadedMetadataTime, + const double aTotalWaitingDataTime, + const double aTotalBufferingTime, + const FirstFrameLoadedFlagSet aFlags, + const MediaInfo& aInfo); double GetTotalVideoPlayTimeInSeconds() const; double GetTotalVideoHDRPlayTimeInSeconds() const; @@ -100,7 +113,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: -- cgit v1.2.3