From 434bf12f92051fe0ff936b73c7b97fc9de299e84 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 11 Jun 2006 15:12:05 +0000 Subject: [PATCH] Update for sending total length in frames --- mvpclient.c | 28 +++++++++++++--------------- recplayer.c | 11 +++++++++-- recplayer.h | 4 +++- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/mvpclient.c b/mvpclient.c index 69973af..afdb9bb 100644 --- a/mvpclient.c +++ b/mvpclient.c @@ -780,11 +780,12 @@ int MVPClient::processStartStreamingRecording(UCHAR* data, int length) { rp = new RecPlayer(recording); - UCHAR sendBuffer[12]; - *(ULONG*)&sendBuffer[0] = htonl(8); - *(ULLONG*)&sendBuffer[4] = htonll(rp->getTotalLength()); + UCHAR sendBuffer[16]; + *(ULONG*)&sendBuffer[0] = htonl(12); + *(ULLONG*)&sendBuffer[4] = htonll(rp->getLengthBytes()); + *(ULONG*)&sendBuffer[12] = htonl(rp->getLengthFrames()); - tcp.sendPacket(sendBuffer, 12); + tcp.sendPacket(sendBuffer, 16); log->log("Client", Log::DEBUG, "written totalLength"); } else @@ -797,23 +798,20 @@ int MVPClient::processStartStreamingRecording(UCHAR* data, int length) int MVPClient::processReScanRecording(UCHAR* data, int length) { - ULLONG retval = 0; - if (!rp) { log->log("Client", Log::DEBUG, "Rescan recording called when no recording being played!"); - } - else - { - rp->scan(); - retval = rp->getTotalLength(); + return 0; } - UCHAR sendBuffer[12]; - *(ULONG*)&sendBuffer[0] = htonl(8); - *(ULLONG*)&sendBuffer[4] = htonll(retval); + rp->scan(); - tcp.sendPacket(sendBuffer, 12); + UCHAR sendBuffer[16]; + *(ULONG*)&sendBuffer[0] = htonl(12); + *(ULLONG*)&sendBuffer[4] = htonll(rp->getLengthBytes()); + *(ULONG*)&sendBuffer[12] = htonl(rp->getLengthFrames()); + + tcp.sendPacket(sendBuffer, 16); log->log("Client", Log::DEBUG, "Rescan recording, wrote new length to client"); return 1; } diff --git a/recplayer.c b/recplayer.c index c99f04d..fadf522 100644 --- a/recplayer.c +++ b/recplayer.c @@ -42,6 +42,7 @@ void RecPlayer::scan() if (file) fclose(file); totalLength = 0; fileOpen = 0; + totalFrames = 0; int i = 1; while(segments[i++]) delete segments[i]; @@ -58,7 +59,8 @@ void RecPlayer::scan() segments[i]->start = totalLength; fseek(file, 0, SEEK_END); totalLength += ftell(file); - log->log("RecPlayer", Log::DEBUG, "File %i found, totalLength now %llu", i, totalLength); + totalFrames = indexFile->Last(); + log->log("RecPlayer", Log::DEBUG, "File %i found, totalLength now %llu, numFrames = %lu", i, totalLength, totalFrames); segments[i]->end = totalLength; fclose(file); } @@ -93,11 +95,16 @@ int RecPlayer::openFile(int index) return 1; } -ULLONG RecPlayer::getTotalLength() +ULLONG RecPlayer::getLengthBytes() { return totalLength; } +ULONG RecPlayer::getLengthFrames() +{ + return totalFrames; +} + unsigned long RecPlayer::getBlock(unsigned char* buffer, ULLONG position, unsigned long amount) { if ((amount > totalLength) || (amount > 500000)) diff --git a/recplayer.h b/recplayer.h index ddbef0a..5795fcb 100644 --- a/recplayer.h +++ b/recplayer.h @@ -39,7 +39,8 @@ class RecPlayer public: RecPlayer(cRecording* rec); ~RecPlayer(); - ULLONG getTotalLength(); + ULLONG getLengthBytes(); + ULONG getLengthFrames(); unsigned long getBlock(unsigned char* buffer, ULLONG position, unsigned long amount); int openFile(int index); ULLONG getLastPosition(); @@ -57,6 +58,7 @@ class RecPlayer Segment* segments[1000]; ULLONG totalLength; ULLONG lastPosition; + ULONG totalFrames; }; #endif -- 2.39.2