| 1 |
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
| 2 |
/* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
| 3 |
/* This Source Code Form is subject to the terms of the Mozilla Public |
| 4 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 |
|
| 7 |
#ifndef BaseProfilerMarkerTypes_h |
| 8 |
#define BaseProfilerMarkerTypes_h |
| 9 |
|
| 10 |
// This header contains common marker type definitions. |
| 11 |
// |
| 12 |
// It #include's "mozilla/BaseProfilerMarkers.h", see that file for how to |
| 13 |
// define other marker types, and how to add markers to the profiler buffers. |
| 14 |
// |
| 15 |
// If you don't need to use these common types, #include |
| 16 |
// "mozilla/BaseProfilerMarkers.h" instead. |
| 17 |
// |
| 18 |
// Types in this files can be defined without relying on xpcom. |
| 19 |
// Others are defined in "ProfilerMarkerTypes.h". |
| 20 |
|
| 21 |
// !!! /!\ WORK IN PROGRESS /!\ !!! |
| 22 |
// This file contains draft marker definitions, but most are not used yet. |
| 23 |
// Further work is needed to complete these definitions, and use them to convert |
| 24 |
// existing PROFILER_ADD_MARKER calls. See meta bug 1661394. |
| 25 |
|
| 26 |
#include "mozilla/BaseProfilerMarkers.h" |
| 27 |
|
| 28 |
namespace mozilla::baseprofiler::markers { |
| 29 |
|
| 30 |
struct MediaSampleMarker { |
| 31 |
static constexpr Span<const char> MarkerTypeName() { |
| 32 |
return MakeStringSpan("MediaSample"); |
| 33 |
} |
| 34 |
static void StreamJSONMarkerData(SpliceableJSONWriter& aWriter, |
| 35 |
int64_t aSampleStartTimeUs, |
| 36 |
int64_t aSampleEndTimeUs, |
| 37 |
int64_t aQueueLength) { |
| 38 |
aWriter.IntProperty("sampleStartTimeUs", aSampleStartTimeUs); |
| 39 |
aWriter.IntProperty("sampleEndTimeUs", aSampleEndTimeUs); |
| 40 |
aWriter.IntProperty("queueLength", aQueueLength); |
| 41 |
} |
| 42 |
static MarkerSchema MarkerTypeDisplay() { |
| 43 |
using MS = MarkerSchema; |
| 44 |
MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable}; |
| 45 |
schema.AddKeyLabelFormat("sampleStartTimeUs", "Sample start time", |
| 46 |
MS::Format::Microseconds); |
| 47 |
schema.AddKeyLabelFormat("sampleEndTimeUs", "Sample end time", |
| 48 |
MS::Format::Microseconds); |
| 49 |
schema.AddKeyLabelFormat("queueLength", "Queue length", |
| 50 |
MS::Format::Integer); |
| 51 |
return schema; |
| 52 |
} |
| 53 |
}; |
| 54 |
|
| 55 |
struct VideoFallingBehindMarker { |
| 56 |
static constexpr Span<const char> MarkerTypeName() { |
| 57 |
return MakeStringSpan("VideoFallingBehind"); |
| 58 |
} |
| 59 |
static void StreamJSONMarkerData(SpliceableJSONWriter& aWriter, |
| 60 |
int64_t aVideoFrameStartTimeUs, |
| 61 |
int64_t aMediaCurrentTimeUs) { |
| 62 |
aWriter.IntProperty("videoFrameStartTimeUs", aVideoFrameStartTimeUs); |
| 63 |
aWriter.IntProperty("mediaCurrentTimeUs", aMediaCurrentTimeUs); |
| 64 |
} |
| 65 |
static MarkerSchema MarkerTypeDisplay() { |
| 66 |
using MS = MarkerSchema; |
| 67 |
MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable}; |
| 68 |
schema.AddKeyLabelFormat("videoFrameStartTimeUs", "Video frame start time", |
| 69 |
MS::Format::Microseconds); |
| 70 |
schema.AddKeyLabelFormat("mediaCurrentTimeUs", "Media current time", |
| 71 |
MS::Format::Microseconds); |
| 72 |
return schema; |
| 73 |
} |
| 74 |
}; |
| 75 |
|
| 76 |
struct ContentBuildMarker { |
| 77 |
static constexpr Span<const char> MarkerTypeName() { |
| 78 |
return MakeStringSpan("CONTENT_FULL_PAINT_TIME"); |
| 79 |
} |
| 80 |
static void StreamJSONMarkerData(SpliceableJSONWriter& aWriter) {} |
| 81 |
static MarkerSchema MarkerTypeDisplay() { |
| 82 |
using MS = MarkerSchema; |
| 83 |
MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable}; |
| 84 |
return schema; |
| 85 |
} |
| 86 |
}; |
| 87 |
|
| 88 |
struct MediaEngineMarker { |
| 89 |
static constexpr Span<const char> MarkerTypeName() { |
| 90 |
return MakeStringSpan("MediaEngine"); |
| 91 |
} |
| 92 |
static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter, |
| 93 |
uint64_t aMediaEngineId) { |
| 94 |
aWriter.IntProperty("id", aMediaEngineId); |
| 95 |
} |
| 96 |
static MarkerSchema MarkerTypeDisplay() { |
| 97 |
using MS = MarkerSchema; |
| 98 |
MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable}; |
| 99 |
schema.AddKeyLabelFormat("id", "Id", MS::Format::Integer); |
| 100 |
return schema; |
| 101 |
} |
| 102 |
}; |
| 103 |
|
| 104 |
struct MediaEngineTextMarker { |
| 105 |
static constexpr Span<const char> MarkerTypeName() { |
| 106 |
return MakeStringSpan("MediaEngineText"); |
| 107 |
} |
| 108 |
static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter, |
| 109 |
uint64_t aMediaEngineId, |
| 110 |
const ProfilerString8View& aText) { |
| 111 |
aWriter.IntProperty("id", aMediaEngineId); |
| 112 |
aWriter.StringProperty("text", aText); |
| 113 |
} |
| 114 |
static MarkerSchema MarkerTypeDisplay() { |
| 115 |
using MS = MarkerSchema; |
| 116 |
MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable}; |
| 117 |
schema.AddKeyLabelFormat("id", "Id", MS::Format::Integer); |
| 118 |
schema.AddKeyLabelFormat("text", "Details", MS::Format::String); |
| 119 |
return schema; |
| 120 |
} |
| 121 |
}; |
| 122 |
|
| 123 |
struct VideoSinkRenderMarker { |
| 124 |
static constexpr Span<const char> MarkerTypeName() { |
| 125 |
return MakeStringSpan("VideoSinkRender"); |
| 126 |
} |
| 127 |
static void StreamJSONMarkerData(baseprofiler::SpliceableJSONWriter& aWriter, |
| 128 |
int64_t aClockTimeUs) { |
| 129 |
aWriter.IntProperty("clockTimeUs", aClockTimeUs); |
| 130 |
} |
| 131 |
static MarkerSchema MarkerTypeDisplay() { |
| 132 |
using MS = MarkerSchema; |
| 133 |
MS schema{MS::Location::MarkerChart, MS::Location::MarkerTable}; |
| 134 |
schema.AddKeyLabelFormat("clockTimeUs", "Clock time", |
| 135 |
MS::Format::Microseconds); |
| 136 |
return schema; |
| 137 |
} |
| 138 |
}; |
| 139 |
|
| 140 |
} // namespace mozilla::baseprofiler::markers |
| 141 |
|
| 142 |
#endif // BaseProfilerMarkerTypes_h |