]> git.vomp.tv Git - vompserver.git/commitdiff
Fix for chasing playback by allowing the client to rescan the length
authorChris Tallon <chris@vomp.tv>
Thu, 11 Aug 2005 23:09:33 +0000 (23:09 +0000)
committerChris Tallon <chris@vomp.tv>
Thu, 11 Aug 2005 23:09:33 +0000 (23:09 +0000)
mvpclient.c
mvpclient.h
recplayer.c
recplayer.h

index 1fe4cd2d270c21d4b637e33eec4efaf546e5392e..eb52477e643e76151bf23cceda36a0afc859dbb0 100644 (file)
@@ -220,6 +220,9 @@ void MVPClient::run2()
       case 12:
         processConfigLoad(data, packetLength);
         break;
+      case 13:
+        processReScanRecording(data, packetLength);
+        break;
     }
 
     free(buffer);
@@ -525,6 +528,28 @@ void MVPClient::processStartStreamingRecording(unsigned char* data, int length)
   }
 }
 
+void MVPClient::processReScanRecording(unsigned char* 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();
+  }
+
+  unsigned char sendBuffer[12];
+  *(unsigned long*)&sendBuffer[0] = htonl(8);
+  *(ULLONG*)&sendBuffer[4] = htonll(retval);
+
+  tcp.sendPacket(sendBuffer, 12);
+  log->log("Client", Log::DEBUG, "Rescan recording, wrote new length to client");
+}
+
 void MVPClient::processGetChannelSchedule(unsigned char* data, int length)
 {
   ULONG channelNumber = ntohl(*(ULLONG*)data);
index 3658d0089225b9dda1da2c522b346551c26833d8..0049d56ebc3db0438c39689706d69d8844066acf 100644 (file)
@@ -69,6 +69,7 @@ class MVPClient
     void processGetBlock(unsigned char* data, int length);
     void processStopStreaming(unsigned char* data, int length);
     void processStartStreamingRecording(unsigned char* data, int length);
+    void processReScanRecording(unsigned char* data, int length);
     void processGetChannelSchedule(unsigned char* data, int length);
     void processConfigSave(unsigned char* data, int length);
     void processConfigLoad(unsigned char* data, int length);
index 8e688ca550a8626e4f09d0add37387126bc25284..a13a64e35cb19864f9af5c5e2aa9952415b9bee8 100644 (file)
 
 RecPlayer::RecPlayer(cRecording* rec)
 {
+  log = Log::getInstance();
   file = NULL;
-  totalLength = 0;
+  fileOpen = 0;
   lastPosition = 0;
-  log = Log::getInstance();
   recording = rec;
+  for(int i = 1; i < 1000; i++) segments[i] = NULL;
 
   // FIXME find out max file path / name lengths
 
+  scan();
+}
+
+void RecPlayer::scan()
+{
+  if (file) fclose(file);
+  totalLength = 0;
+  fileOpen = 0;
+
+  int i = 1;
+  while(segments[i++]) delete segments[i];
 
   char fileName[2048];
-  for(int i = 1; i < 1001; i++)
+  for(i = 1; i < 1000; i++)
   {
-    snprintf(fileName, 2047, "%s/%03i.vdr", rec->FileName(), i);
+    snprintf(fileName, 2047, "%s/%03i.vdr", recording->FileName(), i);
     log->log("RecPlayer", Log::DEBUG, "FILENAME: %s", fileName);
     file = fopen(fileName, "r");
-    if (file)
-    {
-      segments[i] = new Segment();
-      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);
-      segments[i]->end = totalLength;
-      fclose(file);
-    }
-    else
-    {
-      segments[i] = NULL;
-      break;
-    }
+    if (!file) break;
+
+    segments[i] = new Segment();
+    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);
+    segments[i]->end = totalLength;
+    fclose(file);
   }
-  openFile(1);
+
+  file = NULL;
 }
 
 RecPlayer::~RecPlayer()
index d2ad4ecd25e66212340f99f557c05596408ea34e..5ab84d24433b18589632298dbcd92f9ffbb6c414 100644 (file)
@@ -44,13 +44,14 @@ class RecPlayer
     int openFile(int index);
     ULLONG getLastPosition();
     cRecording* getCurrentRecording();
+    void scan();
 
   private:
     Log* log;
     cRecording* recording;
     FILE* file;
     int fileOpen;
-    Segment* segments[1001];
+    Segment* segments[1000];
     ULLONG totalLength;
     ULLONG lastPosition;
 };