From 9b6b0df3127f09dc87db62ee6be9379db71dadc5 Mon Sep 17 00:00:00 2001 From: Marcin Mielczarczyk Date: Fri, 13 Dec 2024 08:18:30 +0100 Subject: [PATCH] ONEM-38082: Redesigned telemetry module --- Source/CMakeLists.txt | 6 +- Source/ThirdParty/telemetry/CMakeLists.txt | 25 +-- .../telemetry/include/DummyTelemetryReport.h | 23 +++ .../ThirdParty/telemetry/include/ITelemetry.h | 100 +++++++++++ .../telemetry/include/RdkTelemetryReport.h | 24 +++ .../telemetry/include/TelemetryReport.h | 20 +++ .../telemetry/src/DummyTelemetryReport.cpp | 53 ++++++ .../telemetry/src/RdkTelemetryReport.cpp | 131 ++++++++++++++ .../telemetry/src/TelemetryReport.cpp | 162 ------------------ .../telemetry/src/TelemetryReport.h | 96 ----------- Source/WTF/wtf/CMakeLists.txt | 4 +- Source/WTF/wtf/PlatformWPE.cmake | 4 + .../platform/graphics/egl/GLContextEGL.cpp | 8 +- .../platform/graphics/egl/GLContextEGL.h | 3 +- .../gstreamer/MediaPlayerPrivateGStreamer.cpp | 44 +++-- .../gstreamer/MediaPlayerPrivateGStreamer.h | 3 +- Source/cmake/OptionsWPE.cmake | 2 +- 17 files changed, 405 insertions(+), 303 deletions(-) create mode 100644 Source/ThirdParty/telemetry/include/DummyTelemetryReport.h create mode 100644 Source/ThirdParty/telemetry/include/ITelemetry.h create mode 100644 Source/ThirdParty/telemetry/include/RdkTelemetryReport.h create mode 100644 Source/ThirdParty/telemetry/include/TelemetryReport.h create mode 100644 Source/ThirdParty/telemetry/src/DummyTelemetryReport.cpp create mode 100644 Source/ThirdParty/telemetry/src/RdkTelemetryReport.cpp delete mode 100644 Source/ThirdParty/telemetry/src/TelemetryReport.cpp delete mode 100644 Source/ThirdParty/telemetry/src/TelemetryReport.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index a453b328be7c8..e08fd9dc9fc79 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -5,8 +5,12 @@ if (NOT USE_SYSTEM_MALLOC) add_subdirectory(bmalloc) endif () -add_subdirectory(WTF) add_subdirectory(ThirdParty/telemetry) +if (USE_RDK_TELEMETRY) + add_definitions(-DRDK_TELEMETRY) +endif () + +add_subdirectory(WTF) if (USE_CAPSTONE) add_subdirectory(ThirdParty/capstone) diff --git a/Source/ThirdParty/telemetry/CMakeLists.txt b/Source/ThirdParty/telemetry/CMakeLists.txt index 7a0912398d623..00526fd8637e1 100644 --- a/Source/ThirdParty/telemetry/CMakeLists.txt +++ b/Source/ThirdParty/telemetry/CMakeLists.txt @@ -2,14 +2,10 @@ set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(TELEMETRY_DIR "${THIRDPARTY_DIR}/telemetry") set(TELEMETRY_INCLUDE_DIRECTORIES - "${TELEMETRY_DIR}/src" + "${TELEMETRY_DIR}/include" "${CMAKE_BINARY_DIR}" ) -set(TELEMETRY_SOURCES - ${TELEMETRY_DIR}/src/TelemetryReport.cpp -) - include_directories("${TELEMETRY_INCLUDE_DIRECTORIES}") if (USE_RDK_TELEMETRY) @@ -24,15 +20,24 @@ if (USE_RDK_TELEMETRY) endif () include_directories( - ${OdhErrTelemetry_INCLUDE_DIR} - ${OdhOttTelemetry_INCLUDE_DIR} + ${OdhErrTelemetry_INCLUDE_DIR} + ${OdhOttTelemetry_INCLUDE_DIR} ) set(TELEMETRY_LIBRARIES - ${OdhErrTelemetry_LIBRARIES} - ${OdhOttTelemetry_LIBRARIES} + ${OdhErrTelemetry_LIBRARIES} + ${OdhOttTelemetry_LIBRARIES} + ) + + set(TELEMETRY_SOURCES + ${TELEMETRY_DIR}/src/RdkTelemetryReport.cpp + ) + + add_definitions(-DRDK_TELEMETRY) +else () + set(TELEMETRY_SOURCES + ${TELEMETRY_DIR}/src/DummyTelemetryReport.cpp ) - add_definitions(-DUSE_RDK_TELEMETRY) endif () add_library(telemetry STATIC ${TELEMETRY_SOURCES}) diff --git a/Source/ThirdParty/telemetry/include/DummyTelemetryReport.h b/Source/ThirdParty/telemetry/include/DummyTelemetryReport.h new file mode 100644 index 0000000000000..fcc5b3b85c9fb --- /dev/null +++ b/Source/ThirdParty/telemetry/include/DummyTelemetryReport.h @@ -0,0 +1,23 @@ +#pragma once + +#include "ITelemetry.h" + +namespace Telemetry { + +class DummyTelemetryReport: public IReport { + +public: + void reportPlaybackState( + AVPipelineState state, + const std::string &additionalInfo = "", + MediaType mediaType = MediaType::NONE) override; + void reportDrmInfo( + DrmType drmType, + const std::string &additionalInfo = "") override; + void reportWaylandInfo( + const IWaylandInfoGetter &getter, + WaylandAction action, + WaylandGraphicsState gfxState, + WaylandInputsState inputsState) override; +}; +} diff --git a/Source/ThirdParty/telemetry/include/ITelemetry.h b/Source/ThirdParty/telemetry/include/ITelemetry.h new file mode 100644 index 0000000000000..8698bc95a1a20 --- /dev/null +++ b/Source/ThirdParty/telemetry/include/ITelemetry.h @@ -0,0 +1,100 @@ +#pragma once + +#include + +namespace Telemetry { + +/* +* Helper function to get some telemetry data from Wayland. +*/ +class IWaylandInfoGetter { +public: + /* + * Don't include: + * #include + * #include + * since there are import order issues. + * Defining needed types as void*, like WebKit does. + */ + typedef void *EGLConfig; + typedef void *EGLContext; + typedef void *EGLDisplay; + typedef void *EGLSurface; + + virtual EGLDisplay getEGLDisplay() const = 0; + virtual EGLConfig getEGLConfig() const = 0; + virtual EGLSurface getEGLSurface() const = 0; + virtual EGLContext getEGLContext() const = 0; + virtual unsigned int getWindowWidth() const = 0; + virtual unsigned int getWindowHeight() const = 0; +}; + +class IReport +{ +public: + enum class AVPipelineState { + CREATE, + PLAY, + PAUSE, + STOP, + DESTROY, + FIRST_FRAME_DECODED, + END_OF_STREAM, + DECRYPT_ERROR, + PLAYBACK_ERROR, + DRM_ERROR, + ERROR, + SEEK_START, + SEEK_DONE, + VIDEO_RESOLUTION_CHANGED, + UNKNOWN + }; + + enum class MediaType { + AUDIO, + VIDEO, + NONE + }; + + enum class DrmType { + PLAYREADY, + WIDEVINE, + NONE, + UNKNOWN + }; + + enum class WaylandAction + { + INIT_GFX, + DEINIT_GFX, + INIT_INPUTS, + DEINIT_INPUTS + }; + + enum class WaylandGraphicsState + { + GFX_NOT_INITIALIZED, + GFX_INITIALIZED + }; + + enum class WaylandInputsState + { + INPUTS_NOT_INITIALIZED, + INPUTS_INITIALIZED + }; + + virtual ~IReport() = default; + virtual void reportPlaybackState( + AVPipelineState state, + const std::string &additionalInfo, + MediaType mediaType) = 0; + virtual void reportDrmInfo( + DrmType drmType, + const std::string &additionalInfo) = 0; + virtual void reportWaylandInfo( + const IWaylandInfoGetter &getter, + WaylandAction action, + WaylandGraphicsState gfxState, + WaylandInputsState inputsState) = 0; +}; +} diff --git a/Source/ThirdParty/telemetry/include/RdkTelemetryReport.h b/Source/ThirdParty/telemetry/include/RdkTelemetryReport.h new file mode 100644 index 0000000000000..f81716079167b --- /dev/null +++ b/Source/ThirdParty/telemetry/include/RdkTelemetryReport.h @@ -0,0 +1,24 @@ +#pragma once + +#include +#include "ITelemetry.h" + +namespace Telemetry { + +class RdkTelemetryReport: public IReport { + +public: + void reportPlaybackState( + AVPipelineState state, + const std::string &additionalInfo = "", + MediaType mediaType = MediaType::NONE) override; + void reportDrmInfo( + DrmType drmType, + const std::string &additionalInfo = "") override; + void reportWaylandInfo( + const IWaylandInfoGetter &getter, + WaylandAction action, + WaylandGraphicsState gfxState, + WaylandInputsState inputsState) override; +}; +} diff --git a/Source/ThirdParty/telemetry/include/TelemetryReport.h b/Source/ThirdParty/telemetry/include/TelemetryReport.h new file mode 100644 index 0000000000000..85830661486dc --- /dev/null +++ b/Source/ThirdParty/telemetry/include/TelemetryReport.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include + +#if defined(RDK_TELEMETRY) + #include "RdkTelemetryReport.h" + using TelemetryImpl = Telemetry::RdkTelemetryReport; +#else + #include "DummyTelemetryReport.h" + using TelemetryImpl = Telemetry::DummyTelemetryReport; +#endif + +namespace Telemetry +{ + void init(const std::string &name = "WebKitBrowser"); + void deinit(); + void reportErrorV(const char* file, int line, const char* function, const char* format, va_list args); + void reportError(const char* file, int line, const char* function, const char* format, ...); +} diff --git a/Source/ThirdParty/telemetry/src/DummyTelemetryReport.cpp b/Source/ThirdParty/telemetry/src/DummyTelemetryReport.cpp new file mode 100644 index 0000000000000..62aee783ab5f3 --- /dev/null +++ b/Source/ThirdParty/telemetry/src/DummyTelemetryReport.cpp @@ -0,0 +1,53 @@ +#include "TelemetryReport.h" + +namespace Telemetry { + +void init(const std::string &name) { + (void)name; +} + +void deinit() { +} + +void reportErrorV(const char* file, int line, const char* function, const char* format, va_list args) { + (void)file; + (void)line; + (void)function; + (void)format; + (void)args; +} + +void reportError(const char* file, int line, const char* function, const char* format, ...) { + (void)file; + (void)line; + (void)function; + (void)format; +} + +void DummyTelemetryReport::reportPlaybackState( + AVPipelineState state, + const std::string &additionalInfo, + MediaType mediaType) { + (void)state; + (void)additionalInfo; + (void)mediaType; +} + +void DummyTelemetryReport::reportDrmInfo( + DrmType drmType, + const std::string &additionalInfo) { + (void)drmType; + (void)additionalInfo; +} + +void DummyTelemetryReport::reportWaylandInfo( + const IWaylandInfoGetter &getter, + WaylandAction action, + WaylandGraphicsState gfxState, + WaylandInputsState inputsState) { + (void)getter; + (void)action; + (void)gfxState; + (void)inputsState; +} +} diff --git a/Source/ThirdParty/telemetry/src/RdkTelemetryReport.cpp b/Source/ThirdParty/telemetry/src/RdkTelemetryReport.cpp new file mode 100644 index 0000000000000..2976f7db26338 --- /dev/null +++ b/Source/ThirdParty/telemetry/src/RdkTelemetryReport.cpp @@ -0,0 +1,131 @@ +#include +#include +#include + +#include "TelemetryReport.h" +#include "av_pipeline.h" +#include "odhott_wl.h" +#include "odherr_ctx.h" + +namespace AVP = OttReports::AvPipeline; + +namespace Telemetry { + +static AVP::AvPipeline avPipelineReport{OttReports::Owner::type::Wpe}; + +void init(const std::string &name) { + odh_error_report_init(name.c_str()); +} + +void deinit() { + odh_error_report_deinit(ODH_ERROR_REPORT_DEINIT_MODE_DEFERRED); +} + +void reportErrorV(const char* file, int line, const char* function, const char* format, va_list args) +{ + int length = vsnprintf(NULL, 0, format, args); + if (length < 0) return; + + char *msg = (char*)malloc(length + 1); + if (!msg) return; + + vsnprintf(msg, length + 1, format, args); + + char* backtrace = odh_error_report_sprintf("%s:%d %s", file, line, function); + char* ctx = odh_ctx_create_json("wpe", "ss", + "function", function, + "file", file); + odh_error_report_send_v3(ODH_ERROR_REPORT_SENSITIVITY_NONSENSITIVE, + ODH_ERROR_REPORT_LEVEL_ERROR, + "WPE0050", + nullptr, + msg, + ctx, + backtrace, + "browser"); + free(ctx); + free(backtrace); + free(msg); +} + +void reportError(const char* file, int line, const char* function, const char* format, ...) +{ + va_list args; + va_start(args, format); + reportErrorV(file, line, function, format, args); + va_end(args); +} + +static std::map pipelineStateMap { + {IReport::AVPipelineState::CREATE, AVP::State::type::Create}, + {IReport::AVPipelineState::PLAY, AVP::State::type::Play}, + {IReport::AVPipelineState::PAUSE, AVP::State::type::Pause}, + {IReport::AVPipelineState::STOP, AVP::State::type::Stop}, + {IReport::AVPipelineState::DESTROY, AVP::State::type::Destroy}, + {IReport::AVPipelineState::FIRST_FRAME_DECODED, AVP::State::type::FirstFrameDecoded}, + {IReport::AVPipelineState::END_OF_STREAM, AVP::State::type::EndOfStream}, + {IReport::AVPipelineState::DECRYPT_ERROR, AVP::State::type::DecryptError}, + {IReport::AVPipelineState::PLAYBACK_ERROR, AVP::State::type::PlaybackError}, + {IReport::AVPipelineState::DRM_ERROR, AVP::State::type::DrmError}, + {IReport::AVPipelineState::ERROR, AVP::State::type::Error}, + {IReport::AVPipelineState::SEEK_START, AVP::State::type::SeekStart}, + {IReport::AVPipelineState::SEEK_DONE, AVP::State::type::SeekDone}, + {IReport::AVPipelineState::VIDEO_RESOLUTION_CHANGED, AVP::State::type::VideoResolutionChanged}, + {IReport::AVPipelineState::UNKNOWN, AVP::State::type::Unknown} +}; + +static std::map drmTypeMap { + {IReport::DrmType::PLAYREADY, AVP::Drm::type::Playready}, + {IReport::DrmType::WIDEVINE, AVP::Drm::type::Widevine}, + {IReport::DrmType::NONE, AVP::Drm::type::None}, + {IReport::DrmType::UNKNOWN, AVP::Drm::type::Unknown}, +}; + +static std::map waylandActionMap { + {IReport::WaylandAction::INIT_GFX , odh_report_wayland_action_t::ODH_REPORT_WAYLAND_ACTION_INIT_GFX}, + {IReport::WaylandAction::DEINIT_GFX, odh_report_wayland_action_t::ODH_REPORT_WAYLAND_ACTION_DEINIT_GFX}, + {IReport::WaylandAction::INIT_INPUTS, odh_report_wayland_action_t::ODH_REPORT_WAYLAND_ACTION_INIT_INPUTS}, + {IReport::WaylandAction::DEINIT_INPUTS, odh_report_wayland_action_t::ODH_REPORT_WAYLAND_ACTION_DEINIT_INPUTS} +}; + +static std::map waylandGraphicsStateMap { + {IReport::WaylandGraphicsState::GFX_NOT_INITIALIZED, false}, + {IReport::WaylandGraphicsState::GFX_INITIALIZED, true} +}; + +static std::map waylandInputsStateMap { + {IReport::WaylandInputsState::INPUTS_NOT_INITIALIZED, false}, + {IReport::WaylandInputsState::INPUTS_INITIALIZED, true} +}; + +void RdkTelemetryReport::reportPlaybackState( + IReport::AVPipelineState state, + const std::string &additionalInfo, + MediaType mediaType) { + avPipelineReport.setSource(AVP::Source::type::Unknown); + avPipelineReport.setAdditionalInfo(additionalInfo.empty() ? "" : additionalInfo); + avPipelineReport.send(pipelineStateMap[state]); +} + +void RdkTelemetryReport::reportDrmInfo( + IReport::DrmType drmType, + const std::string &additionalInfo) { + avPipelineReport.setDrm(drmTypeMap[drmType]); + avPipelineReport.setSource(AVP::Source::type::Unknown); + avPipelineReport.setAdditionalInfo(additionalInfo.empty() ? "" : additionalInfo); + avPipelineReport.send(AVP::State::type::Unknown); +} + +void RdkTelemetryReport::reportWaylandInfo( + const IWaylandInfoGetter &getter, + IReport::WaylandAction action, + IReport::WaylandGraphicsState gfxState, + IReport::WaylandInputsState inputsState) { + odh_ott_wayland_report( + reinterpret_cast(getter), + ODH_REPORT_WAYLAND_OWNER_WPE, + waylandActionMap[action], + waylandGraphicsStateMap[gfxState], + waylandInputsStateMap[inputsState]); +} +} diff --git a/Source/ThirdParty/telemetry/src/TelemetryReport.cpp b/Source/ThirdParty/telemetry/src/TelemetryReport.cpp deleted file mode 100644 index 791320ecfb5c6..0000000000000 --- a/Source/ThirdParty/telemetry/src/TelemetryReport.cpp +++ /dev/null @@ -1,162 +0,0 @@ -#include "TelemetryReport.h" -#include -#include -#include - -#ifdef USE_RDK_TELEMETRY -#include "av_pipeline.h" -#include "odhott_wl.h" -#include "odherr_ctx.h" -#endif - -namespace Telemetry -{ - -#ifdef USE_RDK_TELEMETRY - -namespace AVP = OttReports::AvPipeline; - -static AVP::AvPipeline AvPipelineReport(OttReports::Owner::type::Wpe); - -static std::map pipelineState { - {avpipeline_state_t::CREATE, AVP::State::type::Create}, - {avpipeline_state_t::PLAY, AVP::State::type::Play}, - {avpipeline_state_t::PAUSE, AVP::State::type::Pause}, - {avpipeline_state_t::STOP, AVP::State::type::Stop}, - {avpipeline_state_t::DESTROY, AVP::State::type::Destroy}, - {avpipeline_state_t::FIRST_FRAME_DECODED, AVP::State::type::FirstFrameDecoded}, - {avpipeline_state_t::END_OF_STREAM, AVP::State::type::EndOfStream}, - {avpipeline_state_t::DECRYPT_ERROR, AVP::State::type::DecryptError}, - {avpipeline_state_t::PLAYBACK_ERROR, AVP::State::type::PlaybackError}, - {avpipeline_state_t::DRM_ERROR, AVP::State::type::DrmError}, - {avpipeline_state_t::ERROR, AVP::State::type::Error}, - {avpipeline_state_t::SEEK_START, AVP::State::type::SeekStart}, - {avpipeline_state_t::SEEK_DONE, AVP::State::type::SeekDone}, - {avpipeline_state_t::VIDEO_RESOLUTION_CHANGED, AVP::State::type::VideoResolutionChanged}, - {avpipeline_state_t::UNKNOWN,AVP::State::type::Unknown} -}; - -static std::map drmType { - {drm_type_t::PLAYREADY, AVP::Drm::type::Playready}, - {drm_type_t::WIDEVINE, AVP::Drm::type::Widevine}, - {drm_type_t::NONE, AVP::Drm::type::None}, - {drm_type_t::UNKNOWN, AVP::Drm::type::Unknown}, -}; - -static std::map waylandAction { - {wayland_action_t::INIT_GFX , odh_report_wayland_action_t::ODH_REPORT_WAYLAND_ACTION_INIT_GFX}, - {wayland_action_t::DEINIT_GFX, odh_report_wayland_action_t::ODH_REPORT_WAYLAND_ACTION_DEINIT_GFX}, - {wayland_action_t::INIT_INPUTS, odh_report_wayland_action_t::ODH_REPORT_WAYLAND_ACTION_INIT_INPUTS}, - {wayland_action_t::DEINIT_INPUTS, odh_report_wayland_action_t::ODH_REPORT_WAYLAND_ACTION_DEINIT_INPUTS} -}; - -static std::map waylandGraphicsState { - {wayland_graphics_state_t::GFX_NOT_INITIALIZED, false}, - {wayland_graphics_state_t::GFX_INITIALIZED, true} -}; - -static std::map waylandInputsState { - {wayland_inputs_state_t::INPUTS_NOT_INITIALIZED, false}, - {wayland_inputs_state_t::INPUTS_INITIALIZED, true} -}; - -void init(const std::string &name) -{ - odh_error_report_init(name.c_str()); -} - -void deinit() -{ - odh_error_report_deinit(ODH_ERROR_REPORT_DEINIT_MODE_DEFERRED); -} - -void reportPlaybackState(avpipeline_state_t state, const std::string &additional_info, media_type_t media) -{ - // TODO: Set source type (audio codec or video codec) depending on media input parameter - AvPipelineReport.setSource(AVP::Source::type::Unknown); - AvPipelineReport.setAdditionalInfo(additional_info.empty() ? "" : additional_info); - AvPipelineReport.send(pipelineState[state]); -} - -void reportDrmInfo(const drm_type_t drm, const std::string &additional_info) -{ - AvPipelineReport.setDrm(drmType[drm]); - AvPipelineReport.setSource(AVP::Source::type::Unknown); - AvPipelineReport.setAdditionalInfo(additional_info.empty() ? "" : additional_info); - AvPipelineReport.send(AVP::State::type::Unknown); -} - -void reportWaylandInfo(const WaylandInfoGetter &getter, wayland_action_t action, wayland_graphics_state_t gfx_state, wayland_inputs_state_t inputs_state) -{ - odh_ott_wayland_report(reinterpret_cast(getter), ODH_REPORT_WAYLAND_OWNER_WPE, - waylandAction[action], waylandGraphicsState[gfx_state], waylandInputsState[inputs_state]); -} - -void reportErrorV(const char* file, int line, const char* function, const char* format, va_list args) -{ - int length = vsnprintf(NULL, 0, format, args); - if (length < 0) return; - - char *msg = (char*)malloc(length + 1); - if (!msg) return; - - vsnprintf(msg, length + 1, format, args); - - char* backtrace = odh_error_report_sprintf("%s:%d %s", file, line, function); - char* ctx = odh_ctx_create_json("wpe", "ss", - "function", function, - "file", file); - odh_error_report_send_v3(ODH_ERROR_REPORT_SENSITIVITY_NONSENSITIVE, - ODH_ERROR_REPORT_LEVEL_ERROR, - "WPE0050", - nullptr, - msg, - ctx, - backtrace, - "browser"); - free(ctx); - free(backtrace); - free(msg); -} - -void reportError(const char* file, int line, const char* function, const char* format, ...) -{ - va_list args; - va_start(args, format); - reportErrorV(file, line, function, format, args); - va_end(args); -} - -#else - -void init(const std::string &name) -{ -} - -void deinit() -{ -} - -void reportPlaybackState(avpipeline_state_t state, const std::string &additional_info, media_type_t media) -{ -} - -void reportDrmInfo(drm_type_t drm, const std::string &additional_info) -{ -} - -void reportWaylandInfo(const WaylandInfoGetter &getter, wayland_action_t action, wayland_graphics_state_t gfx_state, wayland_inputs_state_t inputs_state) -{ -} - -void reportErrorV(const char* file, int line, const char* function, const char* format, va_list args) -{ -} - -void reportError(const char* file, int line, const char* function, const char* format, ...) -{ -} - -#endif // USE(RDK_TELEMETRY) - -} // namespace Telemetry diff --git a/Source/ThirdParty/telemetry/src/TelemetryReport.h b/Source/ThirdParty/telemetry/src/TelemetryReport.h deleted file mode 100644 index bac7175beea0e..0000000000000 --- a/Source/ThirdParty/telemetry/src/TelemetryReport.h +++ /dev/null @@ -1,96 +0,0 @@ -#pragma once - -#include -#include -#include - -namespace Telemetry -{ - -/* - * Don't include: - * #include - * #include - * since there are import order issues. - * Defining needed types as void*, like WebKit does. -*/ -typedef void *EGLConfig; -typedef void *EGLContext; -typedef void *EGLDisplay; -typedef void *EGLSurface; - -/* - * Helper function to get some telemetry data from Wayland. - */ -class WaylandInfoGetter { -public: - virtual EGLDisplay getEGLDisplay() const = 0; - virtual EGLConfig getEGLConfig() const = 0; - virtual EGLSurface getEGLSurface() const = 0; - virtual EGLContext getEGLContext() const = 0; - virtual unsigned int getWindowWidth() const = 0; - virtual unsigned int getWindowHeight() const = 0; -}; - - -enum class avpipeline_state_t -{ - CREATE, - PLAY, - PAUSE, - STOP, - DESTROY, - FIRST_FRAME_DECODED, - END_OF_STREAM, - DECRYPT_ERROR, - PLAYBACK_ERROR, - DRM_ERROR, - ERROR, - SEEK_START, - SEEK_DONE, - VIDEO_RESOLUTION_CHANGED, - UNKNOWN -}; - -enum class media_type_t { - AUDIO, - VIDEO, - NONE -}; - -enum class drm_type_t { - PLAYREADY, - WIDEVINE, - NONE, - UNKNOWN -}; - -enum class wayland_action_t -{ - INIT_GFX, - DEINIT_GFX, - INIT_INPUTS, - DEINIT_INPUTS -}; - -enum class wayland_graphics_state_t -{ - GFX_NOT_INITIALIZED, - GFX_INITIALIZED -}; - -enum class wayland_inputs_state_t -{ - INPUTS_NOT_INITIALIZED, - INPUTS_INITIALIZED -}; - - -void init(const std::string &name=std::string("WebKitBrowser")); -void deinit(); -void reportPlaybackState(avpipeline_state_t state, const std::string &additional_info=std::string(), media_type_t media=media_type_t::NONE); -void reportDrmInfo(drm_type_t drm, const std::string &additional_info=std::string()); -void reportWaylandInfo(const WaylandInfoGetter &getter, wayland_action_t action, wayland_graphics_state_t gfx_state, wayland_inputs_state_t inputs_state); -void reportErrorV(const char* file, int line, const char* function, const char* format, va_list args); -void reportError(const char* file, int line, const char* function, const char* format, ...); -} //namespace telemetry diff --git a/Source/WTF/wtf/CMakeLists.txt b/Source/WTF/wtf/CMakeLists.txt index 5025bd4058fb3..aa132b0870e6b 100644 --- a/Source/WTF/wtf/CMakeLists.txt +++ b/Source/WTF/wtf/CMakeLists.txt @@ -555,7 +555,6 @@ set(WTF_SOURCES set(WTF_PRIVATE_INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}" - "${THIRDPARTY_DIR}/telemetry/src" "${WTF_DERIVED_SOURCES_DIR}" "${WTF_DIR}" "${WTF_DIR}/wtf" @@ -572,7 +571,6 @@ set(WTF_LIBRARIES ICU::data ICU::i18n ICU::uc - telemetry ) if (NOT USE_SYSTEM_MALLOC) @@ -590,7 +588,7 @@ if (COMPILER_IS_GCC_OR_CLANG) endif () set(WTF_INTERFACE_LIBRARIES WTF) -set(WTF_INTERFACE_INCLUDE_DIRECTORIES ${WTF_FRAMEWORK_HEADERS_DIR} "${THIRDPARTY_DIR}/telemetry/src") +set(WTF_INTERFACE_INCLUDE_DIRECTORIES ${WTF_FRAMEWORK_HEADERS_DIR}) set(WTF_INTERFACE_DEPENDENCIES WTF_CopyHeaders) WEBKIT_FRAMEWORK_DECLARE(WTF) diff --git a/Source/WTF/wtf/PlatformWPE.cmake b/Source/WTF/wtf/PlatformWPE.cmake index 7bcf1e2ffd481..1c7b547d3ae13 100644 --- a/Source/WTF/wtf/PlatformWPE.cmake +++ b/Source/WTF/wtf/PlatformWPE.cmake @@ -62,6 +62,10 @@ if (RdkLogger_FOUND) list(APPEND WTF_LIBRARIES RdkLogger::RdkLogger) endif () +list(APPEND WTF_PRIVATE_INCLUDE_DIRECTORIES "${THIRDPARTY_DIR}/telemetry/include") +list(APPEND WTF_INTERFACE_INCLUDE_DIRECTORIES "${THIRDPARTY_DIR}/telemetry/include") +list(APPEND WTF_LIBRARIES "telemetry") + list(APPEND WTF_SYSTEM_INCLUDE_DIRECTORIES ${GIO_UNIX_INCLUDE_DIRS} ${GLIB_INCLUDE_DIRS} diff --git a/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp b/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp index fb90f50665898..154e9608ebc82 100644 --- a/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp +++ b/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp @@ -382,8 +382,8 @@ GLContextEGL::GLContextEGL(PlatformDisplay& display, EGLContext context, EGLSurf RELEASE_ASSERT(!m_eglCreateImageKHR == !m_eglDestroyImageKHR); } if(m_type == WindowSurface) { - Telemetry::reportWaylandInfo(*this, Telemetry::wayland_action_t::INIT_GFX, - Telemetry::wayland_graphics_state_t::GFX_INITIALIZED, Telemetry::wayland_inputs_state_t::INPUTS_INITIALIZED); + m_telemetry.reportWaylandInfo(*this, Telemetry::IReport::WaylandAction::INIT_GFX, + Telemetry::IReport::WaylandGraphicsState::GFX_INITIALIZED, Telemetry::IReport::WaylandInputsState::INPUTS_INITIALIZED); } } @@ -406,8 +406,8 @@ GLContextEGL::~GLContextEGL() destroyWPETarget(); #endif if(m_type == WindowSurface) { - Telemetry::reportWaylandInfo(*this, Telemetry::wayland_action_t::DEINIT_GFX, - Telemetry::wayland_graphics_state_t::GFX_NOT_INITIALIZED, Telemetry::wayland_inputs_state_t::INPUTS_INITIALIZED); + m_telemetry.reportWaylandInfo(*this, Telemetry::IReport::WaylandAction::DEINIT_GFX, + Telemetry::IReport::WaylandGraphicsState::GFX_NOT_INITIALIZED, Telemetry::IReport::WaylandInputsState::INPUTS_INITIALIZED); } } diff --git a/Source/WebCore/platform/graphics/egl/GLContextEGL.h b/Source/WebCore/platform/graphics/egl/GLContextEGL.h index 920d9dd54224d..646963ee3ae75 100644 --- a/Source/WebCore/platform/graphics/egl/GLContextEGL.h +++ b/Source/WebCore/platform/graphics/egl/GLContextEGL.h @@ -65,7 +65,7 @@ typedef EGLBoolean (*PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay, EGLImageKHR); namespace WebCore { -class GLContextEGL final : public GLContext, public Telemetry::WaylandInfoGetter { +class GLContextEGL final : public GLContext, public Telemetry::IWaylandInfoGetter { WTF_MAKE_NONCOPYABLE(GLContextEGL); public: static std::unique_ptr createContext(GLNativeWindowType, PlatformDisplay&); @@ -136,6 +136,7 @@ class GLContextEGL final : public GLContext, public Telemetry::WaylandInfoGetter PFNEGLDESTROYIMAGEPROC m_eglDestroyImage { nullptr }; PFNEGLCREATEIMAGEKHRPROC m_eglCreateImageKHR { nullptr }; PFNEGLDESTROYIMAGEKHRPROC m_eglDestroyImageKHR { nullptr }; + TelemetryImpl m_telemetry; #if PLATFORM(X11) XUniquePixmap m_pixmap; #endif diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp index 26894a9c90934..51eb4ede01101 100644 --- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp @@ -212,7 +212,7 @@ MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer() { GST_DEBUG_OBJECT(pipeline(), "Disposing player"); m_isPlayerShuttingDown.store(true); - Telemetry::reportPlaybackState(Telemetry::avpipeline_state_t::STOP); + m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::STOP); #if USE(GSTREAMER_HOLEPUNCH) if (m_gstreamerHolePunchHost) @@ -282,7 +282,7 @@ MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer() m_player = nullptr; m_notifier->invalidate(); - Telemetry::reportPlaybackState(Telemetry::avpipeline_state_t::DESTROY); + m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::DESTROY); } bool MediaPlayerPrivateGStreamer::isAvailable() @@ -424,7 +424,7 @@ void MediaPlayerPrivateGStreamer::play() m_preload = MediaPlayer::Preload::Auto; updateDownloadBufferingFlag(); GST_INFO_OBJECT(pipeline(), "Play"); - Telemetry::reportPlaybackState(Telemetry::avpipeline_state_t::PLAY); + m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::PLAY); } else loadingFailed(MediaPlayer::NetworkState::Empty); } @@ -442,7 +442,7 @@ void MediaPlayerPrivateGStreamer::pause() if (changePipelineState(GST_STATE_PAUSED)) { GST_INFO_OBJECT(pipeline(), "Pause"); - Telemetry::reportPlaybackState(Telemetry::avpipeline_state_t::PAUSE); + m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::PAUSE); } else loadingFailed(MediaPlayer::NetworkState::Empty); } @@ -515,7 +515,7 @@ void MediaPlayerPrivateGStreamer::seek(const MediaTime& mediaTime) MediaTime time = std::min(mediaTime, durationMediaTime()); GST_INFO_OBJECT(pipeline(), "[Seek] seeking to %s", toString(time).utf8().data()); - Telemetry::reportPlaybackState(Telemetry::avpipeline_state_t::SEEK_START, + m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::SEEK_START, "seek_from:"+std::to_string(playbackPosition().toDouble())+", seek_to:"+std::to_string(time.toDouble())); if (m_isSeeking) { @@ -1795,7 +1795,7 @@ void MediaPlayerPrivateGStreamer::handleMessage(GstMessage* message) m_errorMessage = String::fromLatin1(err->message); error = MediaPlayer::NetworkState::Empty; - Telemetry::reportPlaybackState(Telemetry::avpipeline_state_t::PLAYBACK_ERROR, std::string(err->message)); + m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::PLAYBACK_ERROR, std::string(err->message)); if (g_error_matches(err.get(), GST_STREAM_ERROR, GST_STREAM_ERROR_CODEC_NOT_FOUND) || g_error_matches(err.get(), GST_STREAM_ERROR, GST_STREAM_ERROR_DECRYPT) @@ -2444,7 +2444,7 @@ void MediaPlayerPrivateGStreamer::purgeOldDownloadFiles(const String& downloadFi void MediaPlayerPrivateGStreamer::finishSeek() { GST_DEBUG_OBJECT(pipeline(), "[Seek] seeked to %s", toString(m_seekTime).utf8().data()); - Telemetry::reportPlaybackState(Telemetry::avpipeline_state_t::SEEK_DONE, "seek_to:"+std::to_string(m_seekTime.toDouble())); + m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::SEEK_DONE, "seek_to:"+std::to_string(m_seekTime.toDouble())); m_isSeeking = false; invalidateCachedPosition(); @@ -2797,7 +2797,7 @@ void MediaPlayerPrivateGStreamer::didEnd() #endif } timeChanged(); - Telemetry::reportPlaybackState(Telemetry::avpipeline_state_t::END_OF_STREAM); + m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::END_OF_STREAM); } void MediaPlayerPrivateGStreamer::getSupportedTypes(HashSet& types) @@ -3064,8 +3064,8 @@ void MediaPlayerPrivateGStreamer::createGSTPlayBin(const URL& url) if (m_videoSink) configureElementPlatformQuirks(m_videoSink.get()); #endif - Telemetry::reportDrmInfo(getDrm()); - Telemetry::reportPlaybackState(Telemetry::avpipeline_state_t::CREATE); + m_telemetry.reportDrmInfo(getDrm()); + m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::CREATE); } void MediaPlayerPrivateGStreamer::configureVideoDecoder(GstElement* decoder) @@ -3155,7 +3155,7 @@ void MediaPlayerPrivateGStreamer::pausedTimerFired() { GST_DEBUG_OBJECT(pipeline(), "In PAUSED for too long. Releasing pipeline resources."); changePipelineState(GST_STATE_NULL); - Telemetry::reportPlaybackState(Telemetry::avpipeline_state_t::DESTROY); + m_telemetry.reportPlaybackState(Telemetry::IReport::AVPipelineState::DESTROY); } void MediaPlayerPrivateGStreamer::acceleratedRenderingStateChanged() @@ -4594,44 +4594,40 @@ void MediaPlayerPrivateGStreamer::checkPlayingConsistency() } } -Telemetry::drm_type_t MediaPlayerPrivateGStreamer::getDrm() +Telemetry::IReport::DrmType MediaPlayerPrivateGStreamer::getDrm() const { -#if USE(RDK_TELEMETRY) if (m_pipeline.get()) { GstContext* drmCdmInstanceContext = gst_element_get_context(GST_ELEMENT(m_pipeline.get()), "drm-cdm-instance"); if (!drmCdmInstanceContext) { - return {Telemetry::drm_type_t::NONE}; + return {Telemetry::IReport::DrmType::NONE}; } const GstStructure* drmCdmInstanceStructure = gst_context_get_structure(drmCdmInstanceContext); if (!drmCdmInstanceStructure) { - return {Telemetry::drm_type_t::NONE}; + return {Telemetry::IReport::DrmType::NONE}; } const GValue* drmCdmInstanceVal = gst_structure_get_value(drmCdmInstanceStructure, "cdm-instance"); if (!drmCdmInstanceVal) { - return {Telemetry::drm_type_t::NONE}; + return {Telemetry::IReport::DrmType::NONE}; } const CDMInstance* drmCdmInstance = (const CDMInstance*)g_value_get_pointer(drmCdmInstanceVal); if (!drmCdmInstance) { - return {Telemetry::drm_type_t::NONE}; + return {Telemetry::IReport::DrmType::NONE}; } const std::string keySystem = drmCdmInstance->keySystem().utf8().data(); if (keySystem.find("playready") != string::npos) { - return {Telemetry::drm_type_t::PLAYREADY}; + return {Telemetry::IReport::DrmType::PLAYREADY}; } else if (keySystem.find("widevine") != string::npos) { - return {Telemetry::drm_type_t::WIDEVINE}; + return {Telemetry::IReport::DrmType::WIDEVINE}; } else { - return {Telemetry::drm_type_t::UNKNOWN}; + return {Telemetry::IReport::DrmType::UNKNOWN}; } } - return {Telemetry::drm_type_t::NONE}; -#else - return {Telemetry::drm_type_t::UNKNOWN}; -#endif // USE(RDK_TELEMETRY) + return {Telemetry::IReport::DrmType::NONE}; } } diff --git a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h index cd17c3d20e974..f9af0acee7a36 100644 --- a/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h +++ b/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h @@ -552,7 +552,7 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface InitData parseInitDataFromProtectionMessage(GstMessage*); bool waitForCDMAttachment(); #endif - Telemetry::drm_type_t getDrm(); + Telemetry::IReport::DrmType getDrm() const; void configureMediaStreamAudioTracks(); void invalidateCachedPositionOnNextIteration() const; @@ -576,6 +576,7 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface Lock m_drawLock; RunLoop::Timer m_drawTimer WTF_GUARDED_BY_LOCK(m_drawLock); RunLoop::Timer m_pausedTimerHandler; + TelemetryImpl m_telemetry; #if USE(TEXTURE_MAPPER_GL) #if USE(NICOSIA) RefPtr m_nicosiaLayer; diff --git a/Source/cmake/OptionsWPE.cmake b/Source/cmake/OptionsWPE.cmake index 1f2b89bbbd19d..67cf59b37240a 100644 --- a/Source/cmake/OptionsWPE.cmake +++ b/Source/cmake/OptionsWPE.cmake @@ -96,8 +96,8 @@ WEBKIT_OPTION_DEFINE(ENABLE_WPE_QT_API "Whether to enable support for the Qt5/QM WEBKIT_OPTION_DEFINE(USE_AVIF "Whether to enable support for AVIF images." PUBLIC ${ENABLE_EXPERIMENTAL_FEATURES}) WEBKIT_OPTION_DEFINE(USE_JPEGXL "Whether to enable support for JPEG-XL images." PUBLIC ${ENABLE_EXPERIMENTAL_FEATURES}) WEBKIT_OPTION_DEFINE(USE_LCMS "Whether to enable support for image color management using libcms2." PUBLIC ON) -WEBKIT_OPTION_DEFINE(USE_RDK_TELEMETRY "Whether to enable support for ODH telemetry." PUBLIC ON) WEBKIT_OPTION_DEFINE(USE_OPENJPEG "Whether to enable support for JPEG2000 images." PUBLIC ON) +WEBKIT_OPTION_DEFINE(USE_RDK_TELEMETRY "Whether to enable support for ODH telemetry." PUBLIC OFF) WEBKIT_OPTION_DEFINE(USE_SOUP2 "Whether to enable usage of Soup 2 instead of Soup 3." PUBLIC OFF) WEBKIT_OPTION_DEFINE(USE_WOFF2 "Whether to enable support for WOFF2 Web Fonts." PUBLIC ON)