Add some more frame stats granularity, skip frame stats on no-data calls
This commit is contained in:
@@ -1085,6 +1085,9 @@ void EncodeManager::writeRects(const Region& changed, const PixelBuffer* pb,
|
||||
|
||||
// In case the current resolution is above the max video res, and video was detected,
|
||||
// scale to that res, keeping aspect ratio
|
||||
struct timeval scalestart;
|
||||
gettimeofday(&scalestart, NULL);
|
||||
|
||||
const PixelBuffer *scaledpb = NULL;
|
||||
if (videoDetected &&
|
||||
(maxVideoX < pb->getRect().width() || maxVideoY < pb->getRect().height())) {
|
||||
@@ -1133,6 +1136,7 @@ void EncodeManager::writeRects(const Region& changed, const PixelBuffer* pb,
|
||||
}
|
||||
}
|
||||
}
|
||||
scalingTime = msSince(&scalestart);
|
||||
|
||||
#pragma omp parallel for schedule(dynamic, 1)
|
||||
for (i = 0; i < subrects.size(); ++i) {
|
||||
|
||||
@@ -68,9 +68,16 @@ namespace rfb {
|
||||
const RenderedCursor* renderedCursor,
|
||||
size_t maxUpdateSize);
|
||||
|
||||
void clearEncodingTime() {
|
||||
encodingTime = 0;
|
||||
};
|
||||
|
||||
unsigned getEncodingTime() const {
|
||||
return encodingTime;
|
||||
};
|
||||
unsigned getScalingTime() const {
|
||||
return scalingTime;
|
||||
};
|
||||
|
||||
struct codecstats_t {
|
||||
uint32_t ms;
|
||||
@@ -192,6 +199,7 @@ namespace rfb {
|
||||
bool webpTookTooLong;
|
||||
unsigned encodingTime;
|
||||
unsigned maxEncodingTime, framesSinceEncPrint;
|
||||
unsigned scalingTime;
|
||||
|
||||
EncCache *encCache;
|
||||
|
||||
|
||||
@@ -1194,6 +1194,7 @@ bool VNCSConnectionST::isCongested()
|
||||
void VNCSConnectionST::writeFramebufferUpdate()
|
||||
{
|
||||
congestion.updatePosition(sock->outStream().length());
|
||||
encodeManager.clearEncodingTime();
|
||||
|
||||
// We're in the middle of processing a command that's supposed to be
|
||||
// synchronised. Allowing an update to slip out right now might violate
|
||||
|
||||
@@ -186,6 +186,13 @@ namespace rfb {
|
||||
return encodeManager.webpstats;
|
||||
}
|
||||
|
||||
unsigned getEncodingTime() const {
|
||||
return encodeManager.getEncodingTime();
|
||||
}
|
||||
unsigned getScalingTime() const {
|
||||
return encodeManager.getScalingTime();
|
||||
}
|
||||
|
||||
private:
|
||||
// SConnection callbacks
|
||||
|
||||
|
||||
@@ -1006,14 +1006,20 @@ void VNCServerST::writeUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
unsigned shottime = 0;
|
||||
if (apimessager) {
|
||||
struct timeval shotstart;
|
||||
gettimeofday(&shotstart, NULL);
|
||||
apimessager->mainUpdateScreen(pb);
|
||||
shottime = msSince(&shotstart);
|
||||
|
||||
trackingFrameStats = 0;
|
||||
checkAPIMessages(apimessager, trackingFrameStats, trackingClient);
|
||||
}
|
||||
const rdr::U8 origtrackingFrameStats = trackingFrameStats;
|
||||
|
||||
EncodeManager::codecstats_t jpegstats, webpstats;
|
||||
unsigned enctime = 0, scaletime = 0;
|
||||
memset(&jpegstats, 0, sizeof(EncodeManager::codecstats_t));
|
||||
memset(&webpstats, 0, sizeof(EncodeManager::codecstats_t));
|
||||
|
||||
@@ -1053,20 +1059,38 @@ void VNCServerST::writeUpdate()
|
||||
webpstats.ms += subwebp.ms;
|
||||
webpstats.area += subwebp.area;
|
||||
webpstats.rects += subwebp.rects;
|
||||
|
||||
enctime += (*ci)->getEncodingTime();
|
||||
scaletime += (*ci)->getScalingTime();
|
||||
}
|
||||
}
|
||||
|
||||
if (trackingFrameStats) {
|
||||
const unsigned totalMs = msSince(&start);
|
||||
if (enctime) {
|
||||
const unsigned totalMs = msSince(&start);
|
||||
|
||||
if (apimessager)
|
||||
apimessager->mainUpdateServerFrameStats(comparer->changedPerc, totalMs,
|
||||
jpegstats.ms, webpstats.ms,
|
||||
analysisMs,
|
||||
jpegstats.area, webpstats.area,
|
||||
jpegstats.rects, webpstats.rects,
|
||||
pb->getRect().width(),
|
||||
pb->getRect().height());
|
||||
if (apimessager)
|
||||
apimessager->mainUpdateServerFrameStats(comparer->changedPerc, totalMs,
|
||||
jpegstats.ms, webpstats.ms,
|
||||
analysisMs,
|
||||
jpegstats.area, webpstats.area,
|
||||
jpegstats.rects, webpstats.rects,
|
||||
enctime, scaletime, shottime,
|
||||
pb->getRect().width(),
|
||||
pb->getRect().height());
|
||||
} else {
|
||||
// Zero encoding time means this was a no-data frame; restore the stats request
|
||||
if (apimessager && pthread_mutex_lock(&apimessager->userMutex) == 0) {
|
||||
|
||||
network::GetAPIMessager::action_data act;
|
||||
act.action = (network::GetAPIMessager::USER_ACTION) origtrackingFrameStats;
|
||||
memcpy(act.data.password, trackingClient, 128);
|
||||
|
||||
apimessager->actionQueue.push_back(act);
|
||||
|
||||
pthread_mutex_unlock(&apimessager->userMutex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user