New iframe navigation server side support
authorChris Tallon <chris@vomp.tv>
Wed, 20 Sep 2006 22:56:50 +0000 (22:56 +0000)
committerChris Tallon <chris@vomp.tv>
Wed, 20 Sep 2006 22:56:50 +0000 (22:56 +0000)
mvpclient.c
mvpclient.h
recplayer.c
recplayer.h

index 256a6a55430172a5b4ea645edf99ed4ae0cbb8a3..e66207b9404582ba5b83e54ddcfe66fd7bdac39c 100644 (file)
@@ -243,6 +243,9 @@ void MVPClient::run2()
       case 18:
         result = processMoveRecording(data, packetLength);
         break;
+      case 19:
+        result = processGetIFrame(data, packetLength);
+        break;
     }
 
     free(buffer);
@@ -869,6 +872,55 @@ int MVPClient::processFrameNumberFromPosition(UCHAR* data, int length)
   return 1;
 }
 
+int MVPClient::processGetIFrame(UCHAR* data, int length)
+{
+  bool success = false;
+
+  ULONG frameNumber = ntohl(*(ULONG*)data);
+  data += 4;
+  ULONG direction = ntohl(*(ULONG*)data);
+  data += 4;
+
+  ULLONG rfilePosition = 0;
+  ULONG rframeNumber = 0;
+  ULONG rframeLength = 0;
+
+  if (!rp)
+  {
+    log->log("Client", Log::DEBUG, "GetIFrame recording called when no recording being played!");
+  }
+  else
+  {
+    success = rp->getNextIFrame(frameNumber, direction, &rfilePosition, &rframeNumber, &rframeLength);
+  }
+
+  // returns file position, frame number, length
+
+  UCHAR sendBuffer[20];
+  int packetLength;
+
+  if (success)
+  {
+    packetLength = 20;
+    *(ULONG*)&sendBuffer[0] = htonl(16);
+    *(ULLONG*)&sendBuffer[4] = htonll(rfilePosition);
+    *(ULONG*)&sendBuffer[12] = htonl(rframeNumber);
+    *(ULONG*)&sendBuffer[16] = htonl(rframeLength);
+  }
+  else
+  {
+    packetLength = 8;
+    *(ULONG*)&sendBuffer[0] = htonl(4);
+    *(ULONG*)&sendBuffer[4] = 0;
+  }
+
+  log->log("Client", Log::DEBUG, "%llu %lu %lu", rfilePosition, rframeNumber, rframeLength);
+
+  tcp.sendPacket(sendBuffer, packetLength);
+  log->log("Client", Log::DEBUG, "Wrote GNIF reply to client");
+  return 1;
+}
+
 int MVPClient::processGetChannelSchedule(UCHAR* data, int length)
 {
   ULONG channelNumber = ntohl(*(ULONG*)data);
index 5d34f16716acb196d702936dbe1823d039621ade..5358d0976b2172c0d5da6e05f6d523a50cf744e0 100644 (file)
@@ -82,6 +82,7 @@ class MVPClient
     int processSetTimer(UCHAR* data, int length);
     int processPositionFromFrameNumber(UCHAR* data, int length);
     int processFrameNumberFromPosition(UCHAR* data, int length);
+    int processGetIFrame(UCHAR* data, int length);
 
     cChannel* channelFromNumber(ULONG channelNumber);
     void writeResumeData();
index fadf522365c79af345baa2993d9e537e8511f7a4..66475891748dda4ae609325a029cd3ca84274e6f 100644 (file)
@@ -225,3 +225,29 @@ ULONG RecPlayer::frameNumberFromPosition(ULLONG position)
   return indexFile->Get((int)segmentNumber, askposition);
 
 }
+
+
+bool RecPlayer::getNextIFrame(ULONG frameNumber, ULONG direction, ULLONG* rfilePosition, ULONG* rframeNumber, ULONG* rframeLength)
+{
+  // 0 = backwards
+  // 1 = forwards
+
+  if (!indexFile) return false;
+
+  uchar waste1;
+  int waste2;
+
+  int iframeLength;
+  int indexReturnFrameNumber;
+
+  indexReturnFrameNumber = (ULONG)indexFile->GetNextIFrame(frameNumber, (direction==1 ? true : false), &waste1, &waste2, &iframeLength);
+  log->log("RecPlayer", Log::DEBUG, "GNIF input framenumber:%lu, direction=%lu, output:framenumber=%i, framelength=%i", frameNumber, direction, indexReturnFrameNumber, iframeLength);
+
+  if (indexReturnFrameNumber == -1) return false;
+
+  *rfilePosition = positionFromFrameNumber(indexReturnFrameNumber);
+  *rframeNumber = (ULONG)indexReturnFrameNumber;
+  *rframeLength = (ULONG)iframeLength;
+
+  return true;
+}
index 5795fcb6f7027954faeba5789c536e1c11863da4..c3b1795a008b7e9d761451c37f245fd62ea5782a 100644 (file)
@@ -48,6 +48,7 @@ class RecPlayer
     void scan();
     ULLONG positionFromFrameNumber(ULONG frameNumber);
     ULONG frameNumberFromPosition(ULLONG position);
+    bool getNextIFrame(ULONG frameNumber, ULONG direction, ULLONG* rfilePosition, ULONG* rframeNumber, ULONG* rframeLength);
 
   private:
     Log* log;