]> git.vomp.tv Git - vompserver.git/commitdiff
Update for sending total length in frames
authorChris Tallon <chris@vomp.tv>
Sun, 11 Jun 2006 15:12:05 +0000 (15:12 +0000)
committerChris Tallon <chris@vomp.tv>
Sun, 11 Jun 2006 15:12:05 +0000 (15:12 +0000)
mvpclient.c
recplayer.c
recplayer.h

index 69973af6f5117a3d58c379a7d9abd58dd605ea13..afdb9bb7828f8f0ac65209d4ab35c693505fb04d 100644 (file)
@@ -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;
 }
index c99f04d3a8026db1177364111e317a8812f67901..fadf522365c79af345baa2993d9e537e8511f7a4 100644 (file)
@@ -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))
index ddbef0ac3016e8b6fd6736ad364ebc320166d28b..5795fcb6f7027954faeba5789c536e1c11863da4 100644 (file)
@@ -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