From 1e72fe97831c15dfb9d93e00f988602c0ea9c9b4 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 11 Mar 2006 23:27:36 +0000 Subject: [PATCH] Frame numbering stuff --- mvpclient.c | 34 +++++++++++++++++++++++++++++++--- mvpclient.h | 1 + recplayer.c | 22 ++++++++++++++++++++++ recplayer.h | 2 ++ 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/mvpclient.c b/mvpclient.c index b765a7e..0802127 100644 --- a/mvpclient.c +++ b/mvpclient.c @@ -227,6 +227,9 @@ void MVPClient::run2() case 15: result = processSetTimer(data, packetLength); break; + case 16: + result = processPositionFromFrameNumber(data, packetLength); + break; } free(buffer); @@ -612,13 +615,38 @@ int MVPClient::processReScanRecording(UCHAR* data, int length) return 1; } +int MVPClient::processPositionFromFrameNumber(UCHAR* data, int length) +{ + ULLONG retval = 0; + + ULONG frameNumber = ntohl(*(ULONG*)data); + data += 4; + + if (!rp) + { + log->log("Client", Log::DEBUG, "Rescan recording called when no recording being played!"); + } + else + { + retval = rp->positionFromFrameNumber(frameNumber); + } + + UCHAR sendBuffer[12]; + *(ULONG*)&sendBuffer[0] = htonl(8); + *(ULLONG*)&sendBuffer[4] = htonll(retval); + + tcp.sendPacket(sendBuffer, 12); + log->log("Client", Log::DEBUG, "Wrote posFromFrameNum reply to client"); + return 1; +} + int MVPClient::processGetChannelSchedule(UCHAR* data, int length) { - ULONG channelNumber = ntohl(*(ULLONG*)data); + ULONG channelNumber = ntohl(*(ULONG*)data); data += 4; - ULONG startTime = ntohl(*(ULLONG*)data); + ULONG startTime = ntohl(*(ULONG*)data); data += 4; - ULONG duration = ntohl(*(ULLONG*)data); + ULONG duration = ntohl(*(ULONG*)data); log->log("Client", Log::DEBUG, "get schedule called for channel %lu", channelNumber); diff --git a/mvpclient.h b/mvpclient.h index 6444cd7..fd26be7 100644 --- a/mvpclient.h +++ b/mvpclient.h @@ -78,6 +78,7 @@ class MVPClient int processConfigLoad(UCHAR* data, int length); int processGetTimers(UCHAR* data, int length); int processSetTimer(UCHAR* data, int length); + int processPositionFromFrameNumber(UCHAR* data, int length); cChannel* channelFromNumber(ULONG channelNumber); void writeResumeData(); diff --git a/recplayer.c b/recplayer.c index 0968d44..09186e2 100644 --- a/recplayer.c +++ b/recplayer.c @@ -31,6 +31,9 @@ RecPlayer::RecPlayer(cRecording* rec) // FIXME find out max file path / name lengths + indexFile = new cIndexFile(recording->FileName(), false); + if (!indexFile) log->log("RecPlayer", Log::ERR, "Failed to create indexfile!"); + scan(); } @@ -172,3 +175,22 @@ cRecording* RecPlayer::getCurrentRecording() { return recording; } + +ULLONG RecPlayer::positionFromFrameNumber(ULONG frameNumber) +{ + if (!indexFile) return 0; + + uchar retFileNumber; + int retFileOffset; + uchar retPicType; + int retLength; + + if (!indexFile->Get((int)frameNumber, &retFileNumber, &retFileOffset, &retPicType, &retLength)) + { + return 0; + } + + log->log("RecPlayer", Log::DEBUG, "FN: %u FO: %i PT: %u L: %i", retFileNumber, retFileOffset, retPicType, retLength); + + return 0; +} diff --git a/recplayer.h b/recplayer.h index 5ab84d2..0c75a50 100644 --- a/recplayer.h +++ b/recplayer.h @@ -45,10 +45,12 @@ class RecPlayer ULLONG getLastPosition(); cRecording* getCurrentRecording(); void scan(); + ULLONG positionFromFrameNumber(ULONG frameNumber); private: Log* log; cRecording* recording; + cIndexFile* indexFile; FILE* file; int fileOpen; Segment* segments[1000]; -- 2.39.5