forked from WebPlatformForEmbedded/WPEWebKit
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ONEM-38082: Redesigned telemetry module
- Loading branch information
1 parent
afa6c7d
commit 675a7a1
Showing
15 changed files
with
412 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
Source/ThirdParty/telemetry/include/DummyTelemetryReport.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include "ITelemetry.h" | ||
|
||
namespace Telemetry { | ||
|
||
class DummyTelemetryReport: public ITelemetry { | ||
|
||
public: | ||
DummyTelemetryReport(std::string &name); | ||
~DummyTelemetryReport(); | ||
void reportPlaybackState( | ||
AVPipelineState state, | ||
const std::string &additionalInfo, | ||
MediaType mediaType) override; | ||
void reportDrmInfo( | ||
DrmType drmType, | ||
const std::string &additionalInfo) override; | ||
void reportWaylandInfo( | ||
const WaylandInfoGetter &getter, | ||
WaylandAction action, | ||
WaylandGraphicsState gfxState, | ||
WaylandInputsState inputsState) override; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
namespace Telemetry { | ||
|
||
class ITelemetry | ||
{ | ||
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 ~ITelemetry() = default; | ||
virtual void reportPlaybackState( | ||
AVPipelineState state, | ||
const std::string &additionalInfo = "", | ||
MediaType mediaType = MediaType::NONE) = 0; | ||
virtual void reportDrmInfo( | ||
DrmType drmType, | ||
const std::string &additionalInfo = "") = 0; | ||
virtual void reportWaylandInfo( | ||
const WaylandInfoGetter &getter, | ||
WaylandAction action, | ||
WaylandGraphicsState gfxState, | ||
WaylandInputsState inputsState) = 0; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
#include "ITelemetry.h" | ||
|
||
namespace Telemetry { | ||
|
||
class RdkTelemetryReport: public ITelemetry { | ||
|
||
public: | ||
RdkTelemetryReport(std::string &name); | ||
~RdkTelemetryReport(); | ||
void reportPlaybackState( | ||
AVPipelineState state, | ||
const std::string &additionalInfo, | ||
MediaType mediaType) override; | ||
void reportDrmInfo( | ||
DrmType drmType, | ||
const std::string &additionalInfo) override; | ||
void reportWaylandInfo( | ||
const WaylandInfoGetter &getter, | ||
WaylandAction action, | ||
WaylandGraphicsState gfxState, | ||
WaylandInputsState inputsState) override; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#pragma once | ||
|
||
#include <stdarg.h> | ||
|
||
namespace Telemetry | ||
{ | ||
/* | ||
* Don't include: | ||
* #include <EGL/egl.h> | ||
* #include <EGL/eglplatform.h> | ||
* 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; | ||
}; | ||
|
||
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, ...); | ||
} | ||
|
||
#if defined(USE_RDK_TELEMETRY) | ||
#include "RdkTelemetryReport.h" | ||
using TelemetryImpl = Telemetry::RdkTelemetryReport; | ||
#else | ||
// #error "DummyTelemetry used!" | ||
// #include "DummyTelemetryReport.h" | ||
// using TelemetryImpl = DummyTelemetryReport; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "TelemetryReport.h" | ||
|
||
namespace Telemetry { | ||
|
||
void Telemetry::reportErrorV(const char* file, int line, const char* function, const char* format, va_list args) { | ||
} | ||
|
||
void Telemetry::reportError(const char* file, int line, const char* function, const char* format, ...) { | ||
} | ||
|
||
void DummyTelemetryReport::reportPlaybackState( | ||
AVPipelineState state, | ||
const std::string &additionalInfo, | ||
MediaType mediaType) { | ||
} | ||
|
||
void DummyTelemetryReport::reportDrmInfo( | ||
DrmType drmType, | ||
const std::string &additionalInfo) { | ||
} | ||
|
||
void DummyTelemetryReport::reportWaylandInfo( | ||
const WaylandInfoGetter &getter, | ||
WaylandAction action, | ||
WaylandGraphicsState gfxState, | ||
WaylandInputsState inputsState) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
#include <map> | ||
#include <string> | ||
#include <cstdarg> | ||
|
||
#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 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<ITelemetry::AVPipelineState, AVP::State::type> pipelineStateMap { | ||
{ITelemetry::AVPipelineState::CREATE, AVP::State::type::Create}, | ||
{ITelemetry::AVPipelineState::PLAY, AVP::State::type::Play}, | ||
{ITelemetry::AVPipelineState::PAUSE, AVP::State::type::Pause}, | ||
{ITelemetry::AVPipelineState::STOP, AVP::State::type::Stop}, | ||
{ITelemetry::AVPipelineState::DESTROY, AVP::State::type::Destroy}, | ||
{ITelemetry::AVPipelineState::FIRST_FRAME_DECODED, AVP::State::type::FirstFrameDecoded}, | ||
{ITelemetry::AVPipelineState::END_OF_STREAM, AVP::State::type::EndOfStream}, | ||
{ITelemetry::AVPipelineState::DECRYPT_ERROR, AVP::State::type::DecryptError}, | ||
{ITelemetry::AVPipelineState::PLAYBACK_ERROR, AVP::State::type::PlaybackError}, | ||
{ITelemetry::AVPipelineState::DRM_ERROR, AVP::State::type::DrmError}, | ||
{ITelemetry::AVPipelineState::ERROR, AVP::State::type::Error}, | ||
{ITelemetry::AVPipelineState::SEEK_START, AVP::State::type::SeekStart}, | ||
{ITelemetry::AVPipelineState::SEEK_DONE, AVP::State::type::SeekDone}, | ||
{ITelemetry::AVPipelineState::VIDEO_RESOLUTION_CHANGED, AVP::State::type::VideoResolutionChanged}, | ||
{ITelemetry::AVPipelineState::UNKNOWN, AVP::State::type::Unknown} | ||
}; | ||
|
||
static std::map<ITelemetry::DrmType, AVP::Drm::type> drmTypeMap { | ||
{ITelemetry::DrmType::PLAYREADY, AVP::Drm::type::Playready}, | ||
{ITelemetry::DrmType::WIDEVINE, AVP::Drm::type::Widevine}, | ||
{ITelemetry::DrmType::NONE, AVP::Drm::type::None}, | ||
{ITelemetry::DrmType::UNKNOWN, AVP::Drm::type::Unknown}, | ||
}; | ||
|
||
static std::map<ITelemetry::WaylandAction, odh_report_wayland_action_t> waylandActionMap { | ||
{ITelemetry::WaylandAction::INIT_GFX , odh_report_wayland_action_t::ODH_REPORT_WAYLAND_ACTION_INIT_GFX}, | ||
{ITelemetry::WaylandAction::DEINIT_GFX, odh_report_wayland_action_t::ODH_REPORT_WAYLAND_ACTION_DEINIT_GFX}, | ||
{ITelemetry::WaylandAction::INIT_INPUTS, odh_report_wayland_action_t::ODH_REPORT_WAYLAND_ACTION_INIT_INPUTS}, | ||
{ITelemetry::WaylandAction::DEINIT_INPUTS, odh_report_wayland_action_t::ODH_REPORT_WAYLAND_ACTION_DEINIT_INPUTS} | ||
}; | ||
|
||
static std::map<ITelemetry::WaylandGraphicsState, bool> waylandGraphicsStateMap { | ||
{ITelemetry::WaylandGraphicsState::GFX_NOT_INITIALIZED, false}, | ||
{ITelemetry::WaylandGraphicsState::GFX_INITIALIZED, true} | ||
}; | ||
|
||
static std::map<ITelemetry::WaylandInputsState, bool> waylandInputsStateMap { | ||
{ITelemetry::WaylandInputsState::INPUTS_NOT_INITIALIZED, false}, | ||
{ITelemetry::WaylandInputsState::INPUTS_INITIALIZED, true} | ||
}; | ||
|
||
RdkTelemetryReport::RdkTelemetryReport(std::string &name) { | ||
odh_error_report_init(name.c_str()); | ||
} | ||
|
||
RdkTelemetryReport::~RdkTelemetryReport() { | ||
odh_error_report_deinit(ODH_ERROR_REPORT_DEINIT_MODE_DEFERRED); | ||
} | ||
|
||
void RdkTelemetryReport::reportPlaybackState( | ||
ITelemetry::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( | ||
ITelemetry::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 WaylandInfoGetter &getter, | ||
ITelemetry::WaylandAction action, | ||
ITelemetry::WaylandGraphicsState gfxState, | ||
ITelemetry::WaylandInputsState inputsState) { | ||
odh_ott_wayland_report( | ||
reinterpret_cast<const WaylandContextInfoGetter&>(getter), | ||
ODH_REPORT_WAYLAND_OWNER_WPE, | ||
waylandActionMap[action], | ||
waylandGraphicsStateMap[gfxState], | ||
waylandInputsStateMap[inputsState]); | ||
} | ||
} |
Oops, something went wrong.