Health
This commit is contained in:
@@ -1,43 +1,141 @@
|
||||
#include "stdafx.h"
|
||||
#include "HealthTelemetry.h"
|
||||
|
||||
#include "RuntimeHost.h"
|
||||
|
||||
HealthTelemetry::HealthTelemetry(RuntimeHost& runtimeHost) :
|
||||
mRuntimeHost(runtimeHost)
|
||||
{
|
||||
}
|
||||
|
||||
void HealthTelemetry::ReportSignalStatus(bool hasSignal, unsigned width, unsigned height, const std::string& modeName)
|
||||
{
|
||||
mRuntimeHost.WriteSignalStatus(hasSignal, width, height, modeName);
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
mSignalStatus.hasSignal = hasSignal;
|
||||
mSignalStatus.width = width;
|
||||
mSignalStatus.height = height;
|
||||
mSignalStatus.modeName = modeName;
|
||||
}
|
||||
|
||||
bool HealthTelemetry::TryReportSignalStatus(bool hasSignal, unsigned width, unsigned height, const std::string& modeName)
|
||||
{
|
||||
return mRuntimeHost.TryWriteSignalStatus(hasSignal, width, height, modeName);
|
||||
std::unique_lock<std::mutex> lock(mMutex, std::try_to_lock);
|
||||
if (!lock.owns_lock())
|
||||
return false;
|
||||
|
||||
mSignalStatus.hasSignal = hasSignal;
|
||||
mSignalStatus.width = width;
|
||||
mSignalStatus.height = height;
|
||||
mSignalStatus.modeName = modeName;
|
||||
return true;
|
||||
}
|
||||
|
||||
void HealthTelemetry::ReportVideoIOStatus(const std::string& backendName, const std::string& modelName,
|
||||
bool supportsInternalKeying, bool supportsExternalKeying, bool keyerInterfaceAvailable,
|
||||
bool externalKeyingRequested, bool externalKeyingActive, const std::string& statusMessage)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
mVideoIOStatus.backendName = backendName;
|
||||
mVideoIOStatus.modelName = modelName;
|
||||
mVideoIOStatus.supportsInternalKeying = supportsInternalKeying;
|
||||
mVideoIOStatus.supportsExternalKeying = supportsExternalKeying;
|
||||
mVideoIOStatus.keyerInterfaceAvailable = keyerInterfaceAvailable;
|
||||
mVideoIOStatus.externalKeyingRequested = externalKeyingRequested;
|
||||
mVideoIOStatus.externalKeyingActive = externalKeyingActive;
|
||||
mVideoIOStatus.statusMessage = statusMessage;
|
||||
}
|
||||
|
||||
bool HealthTelemetry::TryReportVideoIOStatus(const std::string& backendName, const std::string& modelName,
|
||||
bool supportsInternalKeying, bool supportsExternalKeying, bool keyerInterfaceAvailable,
|
||||
bool externalKeyingRequested, bool externalKeyingActive, const std::string& statusMessage)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mMutex, std::try_to_lock);
|
||||
if (!lock.owns_lock())
|
||||
return false;
|
||||
|
||||
mVideoIOStatus.backendName = backendName;
|
||||
mVideoIOStatus.modelName = modelName;
|
||||
mVideoIOStatus.supportsInternalKeying = supportsInternalKeying;
|
||||
mVideoIOStatus.supportsExternalKeying = supportsExternalKeying;
|
||||
mVideoIOStatus.keyerInterfaceAvailable = keyerInterfaceAvailable;
|
||||
mVideoIOStatus.externalKeyingRequested = externalKeyingRequested;
|
||||
mVideoIOStatus.externalKeyingActive = externalKeyingActive;
|
||||
mVideoIOStatus.statusMessage = statusMessage;
|
||||
return true;
|
||||
}
|
||||
|
||||
void HealthTelemetry::RecordPerformanceStats(double frameBudgetMilliseconds, double renderMilliseconds)
|
||||
{
|
||||
mRuntimeHost.WritePerformanceStats(frameBudgetMilliseconds, renderMilliseconds);
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
mPerformance.frameBudgetMilliseconds = std::max(frameBudgetMilliseconds, 0.0);
|
||||
mPerformance.renderMilliseconds = std::max(renderMilliseconds, 0.0);
|
||||
if (mPerformance.smoothedRenderMilliseconds <= 0.0)
|
||||
mPerformance.smoothedRenderMilliseconds = mPerformance.renderMilliseconds;
|
||||
else
|
||||
mPerformance.smoothedRenderMilliseconds = mPerformance.smoothedRenderMilliseconds * 0.9 + mPerformance.renderMilliseconds * 0.1;
|
||||
}
|
||||
|
||||
bool HealthTelemetry::TryRecordPerformanceStats(double frameBudgetMilliseconds, double renderMilliseconds)
|
||||
{
|
||||
return mRuntimeHost.TryWritePerformanceStats(frameBudgetMilliseconds, renderMilliseconds);
|
||||
std::unique_lock<std::mutex> lock(mMutex, std::try_to_lock);
|
||||
if (!lock.owns_lock())
|
||||
return false;
|
||||
|
||||
mPerformance.frameBudgetMilliseconds = std::max(frameBudgetMilliseconds, 0.0);
|
||||
mPerformance.renderMilliseconds = std::max(renderMilliseconds, 0.0);
|
||||
if (mPerformance.smoothedRenderMilliseconds <= 0.0)
|
||||
mPerformance.smoothedRenderMilliseconds = mPerformance.renderMilliseconds;
|
||||
else
|
||||
mPerformance.smoothedRenderMilliseconds = mPerformance.smoothedRenderMilliseconds * 0.9 + mPerformance.renderMilliseconds * 0.1;
|
||||
return true;
|
||||
}
|
||||
|
||||
void HealthTelemetry::RecordFramePacingStats(double completionIntervalMilliseconds, double smoothedCompletionIntervalMilliseconds,
|
||||
double maxCompletionIntervalMilliseconds, uint64_t lateFrameCount, uint64_t droppedFrameCount, uint64_t flushedFrameCount)
|
||||
{
|
||||
mRuntimeHost.WriteFramePacingStats(completionIntervalMilliseconds, smoothedCompletionIntervalMilliseconds,
|
||||
maxCompletionIntervalMilliseconds, lateFrameCount, droppedFrameCount, flushedFrameCount);
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
mPerformance.completionIntervalMilliseconds = std::max(completionIntervalMilliseconds, 0.0);
|
||||
mPerformance.smoothedCompletionIntervalMilliseconds = std::max(smoothedCompletionIntervalMilliseconds, 0.0);
|
||||
mPerformance.maxCompletionIntervalMilliseconds = std::max(maxCompletionIntervalMilliseconds, 0.0);
|
||||
mPerformance.lateFrameCount = lateFrameCount;
|
||||
mPerformance.droppedFrameCount = droppedFrameCount;
|
||||
mPerformance.flushedFrameCount = flushedFrameCount;
|
||||
}
|
||||
|
||||
bool HealthTelemetry::TryRecordFramePacingStats(double completionIntervalMilliseconds, double smoothedCompletionIntervalMilliseconds,
|
||||
double maxCompletionIntervalMilliseconds, uint64_t lateFrameCount, uint64_t droppedFrameCount, uint64_t flushedFrameCount)
|
||||
{
|
||||
return mRuntimeHost.TryWriteFramePacingStats(completionIntervalMilliseconds, smoothedCompletionIntervalMilliseconds,
|
||||
maxCompletionIntervalMilliseconds, lateFrameCount, droppedFrameCount, flushedFrameCount);
|
||||
std::unique_lock<std::mutex> lock(mMutex, std::try_to_lock);
|
||||
if (!lock.owns_lock())
|
||||
return false;
|
||||
|
||||
mPerformance.completionIntervalMilliseconds = std::max(completionIntervalMilliseconds, 0.0);
|
||||
mPerformance.smoothedCompletionIntervalMilliseconds = std::max(smoothedCompletionIntervalMilliseconds, 0.0);
|
||||
mPerformance.maxCompletionIntervalMilliseconds = std::max(maxCompletionIntervalMilliseconds, 0.0);
|
||||
mPerformance.lateFrameCount = lateFrameCount;
|
||||
mPerformance.droppedFrameCount = droppedFrameCount;
|
||||
mPerformance.flushedFrameCount = flushedFrameCount;
|
||||
return true;
|
||||
}
|
||||
|
||||
HealthTelemetry::SignalStatusSnapshot HealthTelemetry::GetSignalStatusSnapshot() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
return mSignalStatus;
|
||||
}
|
||||
|
||||
HealthTelemetry::VideoIOStatusSnapshot HealthTelemetry::GetVideoIOStatusSnapshot() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
return mVideoIOStatus;
|
||||
}
|
||||
|
||||
HealthTelemetry::PerformanceSnapshot HealthTelemetry::GetPerformanceSnapshot() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
return mPerformance;
|
||||
}
|
||||
|
||||
HealthTelemetry::Snapshot HealthTelemetry::GetSnapshot() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
|
||||
Snapshot snapshot;
|
||||
snapshot.signal = mSignalStatus;
|
||||
snapshot.videoIO = mVideoIOStatus;
|
||||
snapshot.performance = mPerformance;
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user