Display capture file size in capture connection window. Closes #1723

This commit is contained in:
baldurk
2020-02-14 19:31:59 +00:00
parent 4241e0ec55
commit f7cb742a4c
7 changed files with 61 additions and 8 deletions
+7 -3
View File
@@ -673,11 +673,14 @@ QString LiveCapture::MakeText(Capture *cap)
text += lit("\n") + cap->api;
if(cap->frameNumber == ~0U)
text += tr("\nUser-defined Capture ");
text += tr("\nUser-defined Capture");
else
text += tr("\nFrame #%1 ").arg(cap->frameNumber);
text += tr("\nFrame #%1").arg(cap->frameNumber);
text += cap->timestamp.toString(lit("yyyy-MM-dd HH:mm:ss"));
if(cap->byteSize > 0)
text += QFormatStr(" (%1 MB)").arg(double(cap->byteSize) / 1000000.0, 0, 'f', 2);
text += cap->timestamp.toString(lit("\nyyyy-MM-dd HH:mm:ss"));
return text;
}
@@ -1045,6 +1048,7 @@ void LiveCapture::captureAdded(const NewCaptureData &newCapture)
cap->timestamp =
QDateTime(QDate(1970, 1, 1), QTime(0, 0, 0), Qt::UTC).addSecs(newCapture.timestamp).toLocalTime();
cap->byteSize = newCapture.byteSize;
cap->thumb = QImage(newCapture.thumbnail.data(), newCapture.thumbWidth, newCapture.thumbHeight,
newCapture.thumbWidth * 3, QImage::Format_RGB888)
+1
View File
@@ -103,6 +103,7 @@ private:
QString api;
QDateTime timestamp;
uint32_t frameNumber;
uint64_t byteSize;
QImage thumb;
+2
View File
@@ -468,6 +468,8 @@ struct NewCaptureData
uint32_t frameNumber = 0;
DOCUMENT("The time the capture was created, as a unix timestamp in UTC.");
uint64_t timestamp = 0;
DOCUMENT("The size of the capture, in bytes.");
uint64_t byteSize = 0;
DOCUMENT("The raw bytes that contain the capture thumbnail, as RGB8 data.");
bytebuf thumbnail;
DOCUMENT("The width of the image contained in :data:`thumbnail`.");
+21 -4
View File
@@ -32,7 +32,7 @@
#include "replay/replay_driver.h"
#include "serialise/serialiser.h"
static const uint32_t TargetControlProtocolVersion = 5;
static const uint32_t TargetControlProtocolVersion = 6;
static bool IsProtocolVersionSupported(const uint32_t protocolVersion)
{
@@ -48,6 +48,10 @@ static bool IsProtocolVersionSupported(const uint32_t protocolVersion)
if(protocolVersion == 4)
return true;
// 5 -> 6 return byte size with new captures
if(protocolVersion == 5)
return true;
if(protocolVersion == TargetControlProtocolVersion)
return true;
@@ -232,6 +236,11 @@ void RenderDoc::TargetControlClientThread(uint32_t version, Network::Socket *cli
{
SERIALISE_ELEMENT(captures.back().frameNumber);
}
if(version >= 6)
{
uint64_t byteSize = FileIO::GetFileSize(captures.back().path);
SERIALISE_ELEMENT(byteSize);
}
}
}
else if(childprocs.size() != children.size())
@@ -755,6 +764,14 @@ public:
{
msg.newCapture.frameNumber = msg.newCapture.captureId + 1;
}
if(m_Version >= 6)
{
SERIALISE_ELEMENT(msg.newCapture.byteSize).Named("byteSize"_lit);
}
else
{
msg.newCapture.byteSize = 0;
}
}
if(driver != RDCDriver::Unknown)
@@ -762,9 +779,9 @@ public:
msg.newCapture.local = FileIO::exists(msg.newCapture.path.c_str());
RDCLOG("Got a new capture: %d (frame %u) (time %llu) %d byte thumbnail",
msg.newCapture.captureId, msg.newCapture.frameNumber, msg.newCapture.timestamp,
thumbnail.count());
RDCLOG("Got a new capture: %d (frame %u) (%u bytes) (time %llu) %d byte thumbnail",
msg.newCapture.captureId, msg.newCapture.frameNumber, msg.newCapture.byteSize,
msg.newCapture.timestamp, thumbnail.count());
int w = 0;
int h = 0;
+1
View File
@@ -291,6 +291,7 @@ void GetExecutableFilename(rdcstr &selfName);
void GetLibraryFilename(rdcstr &selfName);
uint64_t GetModifiedTimestamp(const rdcstr &filename);
uint64_t GetFileSize(const rdcstr &filename);
bool Copy(const char *from, const char *to, bool allowOverwrite);
bool Move(const char *from, const char *to, bool allowOverwrite);
+13
View File
@@ -249,6 +249,19 @@ uint64_t GetModifiedTimestamp(const rdcstr &filename)
return 0;
}
uint64_t GetFileSize(const rdcstr &filename)
{
struct ::stat st;
int res = stat(filename.c_str(), &st);
if(res == 0)
{
return (uint64_t)st.st_size;
}
return 0;
}
bool Copy(const char *from, const char *to, bool allowOverwrite)
{
if(from[0] == 0 || to[0] == 0)
+16 -1
View File
@@ -430,6 +430,21 @@ uint64_t GetModifiedTimestamp(const rdcstr &filename)
return 0;
}
uint64_t GetFileSize(const rdcstr &filename)
{
rdcwstr wfn = StringFormat::UTF82Wide(filename);
struct __stat64 st;
int res = _wstat64(wfn.c_str(), &st);
if(res == 0)
{
return (uint64_t)st.st_size;
}
return 0;
}
bool Copy(const char *from, const char *to, bool allowOverwrite)
{
rdcwstr wfrom = StringFormat::UTF82Wide(from);
@@ -696,7 +711,7 @@ rdcstr logfile_readall(const char *filename)
}
else
{
DWORD len = GetFileSize(h, NULL);
DWORD len = ::GetFileSize(h, NULL);
if(len == INVALID_FILE_SIZE)
{