From 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:33 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- dom/media/utils/TelemetryProbesReporter.cpp | 46 +++++++++++++++++++++++++++++ dom/media/utils/TelemetryProbesReporter.h | 2 ++ 2 files changed, 48 insertions(+) (limited to 'dom/media/utils') diff --git a/dom/media/utils/TelemetryProbesReporter.cpp b/dom/media/utils/TelemetryProbesReporter.cpp index a2854812ba..8c5614c048 100644 --- a/dom/media/utils/TelemetryProbesReporter.cpp +++ b/dom/media/utils/TelemetryProbesReporter.cpp @@ -292,6 +292,52 @@ void TelemetryProbesReporter::OnDecodeResumed() { mOwner->DispatchAsyncTestingEvent(u"mozvideodecodesuspendedpaused"_ns); } +void TelemetryProbesReporter::OntFirstFrameLoaded( + const TimeDuration& aLoadedFirstFrameTime, bool aIsMSE, + bool aIsExternalEngineStateMachine) { + const MediaInfo& info = mOwner->GetMediaInfo(); + MOZ_ASSERT(info.HasVideo()); + nsCString resolution; + DetermineResolutionForTelemetry(info, resolution); + + glean::media_playback::FirstFrameLoadedExtra extraData; + extraData.firstFrameLoadedTime = Some(aLoadedFirstFrameTime.ToMilliseconds()); + if (!aIsMSE && !aIsExternalEngineStateMachine) { + extraData.playbackType = Some("Non-MSE playback"_ns); + } else if (aIsMSE && !aIsExternalEngineStateMachine) { + extraData.playbackType = !mOwner->IsEncrypted() ? Some("MSE playback"_ns) + : Some("EME playback"_ns); + } else if (!aIsMSE && aIsExternalEngineStateMachine) { + extraData.playbackType = Some("Non-MSE media-engine playback"_ns); + } else if (aIsMSE && aIsExternalEngineStateMachine) { + extraData.playbackType = !mOwner->IsEncrypted() + ? Some("MSE media-engine playback"_ns) + : Some("EME media-engine playback"_ns); + } else { + extraData.playbackType = Some("ERROR TYPE"_ns); + MOZ_ASSERT(false, "Unexpected playback type!"); + } + extraData.videoCodec = Some(info.mVideo.mMimeType); + extraData.resolution = Some(resolution); + if (const auto keySystem = mOwner->GetKeySystem()) { + extraData.keySystem = Some(NS_ConvertUTF16toUTF8(*keySystem)); + } + + 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()}; + if (const auto keySystem = mOwner->GetKeySystem()) { + logMessage.Append(nsPrintfCString{ + ", keySystem=%s", NS_ConvertUTF16toUTF8(*keySystem).get()}); + } + LOG("%s", logMessage.get()); + } + glean::media_playback::first_frame_loaded.Record(Some(extraData)); +} + void TelemetryProbesReporter::OnShutdown() { AssertOnMainThreadAndNotShutdown(); LOG("Shutdown"); diff --git a/dom/media/utils/TelemetryProbesReporter.h b/dom/media/utils/TelemetryProbesReporter.h index 51ae2f12bb..be81e8022c 100644 --- a/dom/media/utils/TelemetryProbesReporter.h +++ b/dom/media/utils/TelemetryProbesReporter.h @@ -66,6 +66,8 @@ class TelemetryProbesReporter final { void OnMutedChanged(bool aMuted); void OnDecodeSuspended(); void OnDecodeResumed(); + void OntFirstFrameLoaded(const TimeDuration& aLoadedFirstFrameTime, + bool aIsMSE, bool aIsExternalEngineStateMachine); double GetTotalVideoPlayTimeInSeconds() const; double GetTotalVideoHDRPlayTimeInSeconds() const; -- cgit v1.2.3