summaryrefslogtreecommitdiffstats
path: root/dom/media/utils
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:29 +0000
commit59203c63bb777a3bacec32fb8830fba33540e809 (patch)
tree58298e711c0ff0575818c30485b44a2f21bf28a0 /dom/media/utils
parentAdding upstream version 126.0.1. (diff)
downloadfirefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz
firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/utils')
-rw-r--r--dom/media/utils/PerformanceRecorder.cpp26
-rw-r--r--dom/media/utils/PerformanceRecorder.h56
-rw-r--r--dom/media/utils/TelemetryProbesReporter.cpp28
-rw-r--r--dom/media/utils/TelemetryProbesReporter.h4
4 files changed, 99 insertions, 15 deletions
diff --git a/dom/media/utils/PerformanceRecorder.cpp b/dom/media/utils/PerformanceRecorder.cpp
index 3dc2c24a5d..dda76e0d99 100644
--- a/dom/media/utils/PerformanceRecorder.cpp
+++ b/dom/media/utils/PerformanceRecorder.cpp
@@ -245,6 +245,19 @@ ProfilerString8View PlaybackStage::Name() const {
return *mName;
}
+void PlaybackStage::AddMarker(MarkerOptions&& aOption) {
+ if (mStartAndEndTimeUs) {
+ auto& pair = *mStartAndEndTimeUs;
+ profiler_add_marker(Name(), Category(),
+ std::forward<MarkerOptions&&>(aOption),
+ geckoprofiler::markers::MediaSampleMarker{}, pair.first,
+ pair.second, 1 /* queue length */);
+ } else {
+ profiler_add_marker(Name(), Category(),
+ std::forward<MarkerOptions&&>(aOption));
+ }
+}
+
ProfilerString8View CaptureStage::Name() const {
if (!mName) {
auto imageTypeToStr = [](ImageType aType) -> const char* {
@@ -307,4 +320,17 @@ ProfilerString8View DecodeStage::Name() const {
return *mName;
}
+void DecodeStage::AddMarker(MarkerOptions&& aOption) {
+ if (mStartAndEndTimeUs) {
+ auto& pair = *mStartAndEndTimeUs;
+ profiler_add_marker(Name(), Category(),
+ std::forward<MarkerOptions&&>(aOption),
+ geckoprofiler::markers::MediaSampleMarker{}, pair.first,
+ pair.second, 1 /* queue length */);
+ } else {
+ profiler_add_marker(Name(), Category(),
+ std::forward<MarkerOptions&&>(aOption));
+ }
+}
+
} // namespace mozilla
diff --git a/dom/media/utils/PerformanceRecorder.h b/dom/media/utils/PerformanceRecorder.h
index e423c3fb5d..95fdab90ba 100644
--- a/dom/media/utils/PerformanceRecorder.h
+++ b/dom/media/utils/PerformanceRecorder.h
@@ -8,11 +8,13 @@
#define mozilla_PerformanceRecorder_h
#include <type_traits>
+#include <utility>
#include "mozilla/Attributes.h"
#include "mozilla/BaseProfilerMarkersPrerequisites.h"
#include "mozilla/Maybe.h"
#include "mozilla/Mutex.h"
+#include "mozilla/ProfilerMarkerTypes.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/TypedEnumBits.h"
#include "nsStringFwd.h"
@@ -118,7 +120,19 @@ enum class MediaStage : uint8_t {
CopyDecodedVideo,
};
-class PlaybackStage {
+class StageBase {
+ public:
+ virtual void AddMarker(MarkerOptions&& aOption) {
+ profiler_add_marker(Name(), Category(),
+ std::forward<MarkerOptions&&>(aOption));
+ }
+
+ protected:
+ virtual ProfilerString8View Name() const = 0;
+ virtual const MarkerCategory& Category() const = 0;
+};
+
+class PlaybackStage : public StageBase {
public:
explicit PlaybackStage(MediaStage aStage, int32_t aHeight = 0,
MediaInfoFlag aFlag = MediaInfoFlag::None)
@@ -126,20 +140,28 @@ class PlaybackStage {
MOZ_ASSERT(aStage != MediaStage::Invalid);
}
- ProfilerString8View Name() const;
- const MarkerCategory& Category() const {
+ ProfilerString8View Name() const override;
+ const MarkerCategory& Category() const override {
return baseprofiler::category::MEDIA_PLAYBACK;
}
+ void AddMarker(MarkerOptions&& aOption) override;
+
+ void SetStartTimeAndEndTime(uint64_t aStartTime, uint64_t aEndTime) {
+ mStartAndEndTimeUs =
+ Some(std::pair<uint64_t, uint64_t>{aStartTime, aEndTime});
+ }
MediaStage mStage;
int32_t mHeight;
MediaInfoFlag mFlag;
+ Maybe<std::pair<uint64_t, uint64_t>> mStartAndEndTimeUs;
+
private:
mutable Maybe<nsCString> mName;
};
-class CaptureStage {
+class CaptureStage : public StageBase {
public:
enum class ImageType : uint8_t {
Unknown,
@@ -160,8 +182,8 @@ class CaptureStage {
mHeight(aHeight),
mImageType(aImageType) {}
- ProfilerString8View Name() const;
- const MarkerCategory& Category() const {
+ ProfilerString8View Name() const override;
+ const MarkerCategory& Category() const override {
return baseprofiler::category::MEDIA_RT;
}
@@ -175,7 +197,7 @@ class CaptureStage {
mutable Maybe<nsCString> mName;
};
-class CopyVideoStage {
+class CopyVideoStage : public StageBase {
public:
CopyVideoStage(nsCString aSource, TrackingId aTrackingId, int32_t aWidth,
int32_t aHeight)
@@ -184,8 +206,8 @@ class CopyVideoStage {
mWidth(aWidth),
mHeight(aHeight) {}
- ProfilerString8View Name() const;
- const MarkerCategory& Category() const {
+ ProfilerString8View Name() const override;
+ const MarkerCategory& Category() const override {
return baseprofiler::category::MEDIA_RT;
}
@@ -201,7 +223,7 @@ class CopyVideoStage {
mutable Maybe<nsCString> mName;
};
-class DecodeStage {
+class DecodeStage : public StageBase {
public:
enum ImageFormat : uint8_t {
YUV420P,
@@ -223,8 +245,8 @@ class DecodeStage {
: mSource(std::move(aSource)),
mTrackingId(std::move(aTrackingId)),
mFlag(aFlag) {}
- ProfilerString8View Name() const;
- const MarkerCategory& Category() const {
+ ProfilerString8View Name() const override;
+ const MarkerCategory& Category() const override {
return baseprofiler::category::MEDIA_PLAYBACK;
}
@@ -242,6 +264,11 @@ class DecodeStage {
void SetColorDepth(gfx::ColorDepth aColorDepth) {
mColorDepth = Some(aColorDepth);
}
+ void SetStartTimeAndEndTime(uint64_t aStartTime, uint64_t aEndTime) {
+ mStartAndEndTimeUs =
+ Some(std::pair<uint64_t, uint64_t>{aStartTime, aEndTime});
+ }
+ void AddMarker(MarkerOptions&& aOption) override;
// The name of the source that performs this stage.
nsCString mSource;
@@ -256,6 +283,7 @@ class DecodeStage {
Maybe<gfx::ColorRange> mColorRange;
Maybe<gfx::ColorDepth> mColorDepth;
mutable Maybe<nsCString> mName;
+ Maybe<std::pair<uint64_t, uint64_t>> mStartAndEndTimeUs;
};
class PerformanceRecorderBase {
@@ -325,9 +353,7 @@ class PerformanceRecorderImpl : public PerformanceRecorderBase {
MOZ_ASSERT(elapsedTimeUs >= 0, "Elapsed time can't be less than 0!");
aStageMutator(stage);
AUTO_PROFILER_STATS(PROFILER_MARKER_UNTYPED);
- profiler_add_marker(
- stage.Name(), stage.Category(),
- MarkerOptions(MarkerTiming::Interval(startTime, now)));
+ stage.AddMarker(MarkerOptions(MarkerTiming::Interval(startTime, now)));
}
return static_cast<float>(elapsedTimeUs);
}
diff --git a/dom/media/utils/TelemetryProbesReporter.cpp b/dom/media/utils/TelemetryProbesReporter.cpp
index 377cee9abc..e702ae14c5 100644
--- a/dom/media/utils/TelemetryProbesReporter.cpp
+++ b/dom/media/utils/TelemetryProbesReporter.cpp
@@ -7,6 +7,7 @@
#include <cmath>
#include "FrameStatistics.h"
+#include "MediaCodecsSupport.h"
#include "VideoUtils.h"
#include "mozilla/EMEUtils.h"
#include "mozilla/Logging.h"
@@ -791,5 +792,32 @@ double TelemetryProbesReporter::GetAudiblePlayTimeInSeconds() const {
return GetTotalAudioPlayTimeInSeconds() - GetInaudiblePlayTimeInSeconds();
}
+/* static */
+void TelemetryProbesReporter::ReportDeviceMediaCodecSupported(
+ const media::MediaCodecsSupported& aSupported) {
+ static bool sReported = false;
+ if (sReported) {
+ return;
+ }
+ MOZ_ASSERT(ContainHardwareCodecsSupported(aSupported));
+ sReported = true;
+
+ glean::media_playback::device_hardware_decoder_support.Get("h264"_ns).Set(
+ aSupported.contains(
+ mozilla::media::MediaCodecsSupport::H264HardwareDecode));
+ glean::media_playback::device_hardware_decoder_support.Get("vp8"_ns).Set(
+ aSupported.contains(
+ mozilla::media::MediaCodecsSupport::VP8HardwareDecode));
+ glean::media_playback::device_hardware_decoder_support.Get("vp9"_ns).Set(
+ aSupported.contains(
+ mozilla::media::MediaCodecsSupport::VP9HardwareDecode));
+ glean::media_playback::device_hardware_decoder_support.Get("av1"_ns).Set(
+ aSupported.contains(
+ mozilla::media::MediaCodecsSupport::AV1HardwareDecode));
+ glean::media_playback::device_hardware_decoder_support.Get("hevc"_ns).Set(
+ aSupported.contains(
+ mozilla::media::MediaCodecsSupport::HEVCHardwareDecode));
+}
+
#undef LOG
} // namespace mozilla
diff --git a/dom/media/utils/TelemetryProbesReporter.h b/dom/media/utils/TelemetryProbesReporter.h
index 43e05dcadd..2f0e7f1b44 100644
--- a/dom/media/utils/TelemetryProbesReporter.h
+++ b/dom/media/utils/TelemetryProbesReporter.h
@@ -5,6 +5,7 @@
#ifndef DOM_TelemetryProbesReporter_H_
#define DOM_TelemetryProbesReporter_H_
+#include "MediaCodecsSupport.h"
#include "MediaInfo.h"
#include "mozilla/Maybe.h"
#include "mozilla/AwakeTimeStamp.h"
@@ -56,6 +57,9 @@ class TelemetryProbesReporter final {
using AudibleState = dom::AudioChannelService::AudibleState;
+ static void ReportDeviceMediaCodecSupported(
+ const media::MediaCodecsSupported& aSupported);
+
// State transitions
void OnPlay(Visibility aVisibility, MediaContent aContent, bool aIsMuted);
void OnPause(Visibility aVisibility);