Major switch to frame number navigation
authorChris Tallon <chris@vomp.tv>
Sun, 11 Jun 2006 20:18:59 +0000 (20:18 +0000)
committerChris Tallon <chris@vomp.tv>
Sun, 11 Jun 2006 20:18:59 +0000 (20:18 +0000)
player.cc
player.h
readme.win [new file with mode: 0644]
video.cc
video.h
vvideorec.cc

index 82c28f31a41bb1d072489bba33742c48a0f0fde6..66a31d11aaaedddc7c0d05eae675b2db8c080c44 100644 (file)
--- a/player.cc
+++ b/player.cc
@@ -39,8 +39,8 @@ Player::Player(MessageQueue* messageQueue, bool tIsRecording, bool tIsRadio)
   feedPosition = 0;
   feedMode = MODE_NORMAL;
   lastRescan = 0;
-  startTS = 0;
-  endTS = 0;
+//  startTS = 0;
+//  endTS = 0;
 
   videoStartup = false;
   preBuffering = false;
@@ -146,24 +146,31 @@ void Player::setLengthFrames(ULONG length)
   logger->log("Player", Log::DEBUG, "Player has received length frames of %lu", lengthFrames);
 }
 
+/*
 ULLONG Player::getEndTS() // FIXME delme - used only by bar clocks until current frame code is done
 {
   long long rendTS = endTS - startTS;
   if (rendTS < 0) rendTS += 8589934592ULL;
   return (ULLONG)rendTS;
 }
+*/
 
+/*
 hmsf Player::getEndHMSF()
 {
   return video->framesToHMSF(lengthFrames);
 }
+*/
 
-ULLONG Player::getPositionTS() // used internall (skip fw/bw)
+ULONG Player::getLengthFrames()
 {
-  if (startup) return 0ULL;
-  long long currentTS = video->getCurrentTimestamp() - startTS;
-  if (currentTS < 0) currentTS += 8589934592ULL;
-  return (ULLONG)currentTS;
+  return lengthFrames;
+}
+
+ULONG Player::getCurrentFrameNum()
+{
+  if (startup) return 0;
+  return demuxer->getFrameNumFromPTS(video->getCurrentTimestamp());
 }
 
 // ----------------------------------- Externally called events
@@ -433,21 +440,21 @@ void Player::toggleFastBackwardInt()
 void Player::skipForwardInt(int seconds)
 {
   logger->log("Player", Log::DEBUG, "SKIP FORWARD %i SECONDS", seconds);
-  restartAt(getPositionTS() + (seconds * 90000));
+  restartAtFrame(getCurrentFrameNum() + (seconds * video->getFPS()));
 }
 
 void Player::skipBackwardInt(int seconds)
 {
   logger->log("Player", Log::DEBUG, "SKIP BACKWARD %i SECONDS", seconds);
-  long long newTimeCode = getPositionTS() - (seconds * 90000);
-  if (newTimeCode < 0) newTimeCode = 0;
-  restartAt(newTimeCode);
+  long newFrameNum = getCurrentFrameNum() + (seconds * video->getFPS());
+  if (newFrameNum < 0) newFrameNum = 0;
+  restartAt(newFrameNum);
 }
 
 void Player::jumpToPercentInt(int percent)
 {
   logger->log("Player", Log::DEBUG, "JUMP TO %i%%", percent);
-  ULONG newFrame = (ULONG)(((float)percent / 100) * lengthFrames);
+  ULONG newFrame = percent * lengthFrames / 100;
   restartAtFrame(newFrame);
 }
 
@@ -538,6 +545,7 @@ void Player::restartAtFrame(ULONG newFrame)
   fbwd = false;
 }
 
+/*
 void Player::setStartTS(UINT dataInBuffer)
 {
 #ifndef NEW_DEMUXER
@@ -561,7 +569,9 @@ void Player::setStartTS(UINT dataInBuffer)
   startTS=0;
 #endif
 }
+*/
 
+/*
 void Player::setEndTS()
 {
   logger->log("Player", Log::DEBUG, "Setting end TS");
@@ -578,6 +588,7 @@ void Player::setEndTS()
  #endif
   logger->log("Player", Log::DEBUG, "Set end TS");
 }
+*/
 
 void Player::doConnectionLost()
 {
@@ -664,7 +675,7 @@ void Player::threadMethod()
       if (!vdr->isConnected()) { doConnectionLost(); return; }
       logger->log("Player", Log::DEBUG, "Rescanned and reset length: %llu", lengthBytes);
       lastRescan = time(NULL);
-      setEndTS();
+//      setEndTS();
     }
 
     if (lengthBytes) // is playing a recording
@@ -712,9 +723,9 @@ void Player::threadMethod()
       demuxer->setAudioStream(a_stream);
       logger->log("Player", Log::DEBUG, "Startup Audio stream chosen %x", a_stream);
 
-      setStartTS(thisRead);
+//      setStartTS(thisRead);
 
-      if (isRecording) setEndTS();
+//      if (isRecording) setEndTS();
 
       startup = false;
     }
index 96e599e0a15c1bfe8a64b9cb98bf6abe0a364557..cf25d4e5111a5125b7ea88306f00b93226f31684 100644 (file)
--- a/player.h
+++ b/player.h
@@ -64,9 +64,10 @@ class Player : public Thread_TYPE, public Callback
     bool isPaused() { return paused; }
     bool isFfwd() { return ffwd; }
     bool isFbwd() { return fbwd; }
-    ULLONG getPositionTS();
-    ULLONG getEndTS();
-    hmsf getEndHMSF();
+    ULONG getCurrentFrameNum();
+    ULONG getLengthFrames();
+//    ULLONG getEndTS();
+//    hmsf getEndHMSF();
 
     void call(void*); // for callback interface
 
@@ -89,7 +90,6 @@ class Player : public Thread_TYPE, public Callback
     void skipForwardInt(int seconds);
     void skipBackwardInt(int seconds);
 
-    void setStartTS(UINT dataInBuffer);
     void setEndTS();
     void doConnectionLost();
     void restartAt(ULLONG timeCode);
@@ -118,8 +118,7 @@ class Player : public Thread_TYPE, public Callback
     void lock();
     void unLock();
 
-    ULLONG startTS;
-    ULLONG endTS;
+//    ULLONG endTS;
     ULLONG lengthBytes;
     ULONG lengthFrames;
     ULLONG feedPosition;
diff --git a/readme.win b/readme.win
new file mode 100644 (file)
index 0000000..d487b4c
--- /dev/null
@@ -0,0 +1,105 @@
+Readme For Windows Port of Vomp-Client\r
+======================================\r
+\r
+This file contains notes regarding the Windows port of Vomp.\r
+Please read it carefully.\r
+\r
+License and Homepage\r
+====================\r
+\r
+The source code of vomp client is released under the General Public License (GPL).\r
+For further information consult the vomp homepage:\r
+http://www.loggytronic.com\r
+or vomp on SourceForge (including the source code on cvs):\r
+http://sourceforge.net/projects/vomp\r
+\r
+Requirements\r
+============\r
+\r
+The vomp client on Windows requires:\r
+\r
+* Windows 2000 or later\r
+* A DirectShow MPEG2 decoder, which supports Video Mixing Renderer 9 (VMR-9),\r
+  mostly included within DVD software player\r
+* A network connection to the vompserver computer\r
+\r
+Compatibility List for MPEG2 Decoders\r
+=====================================\r
+\r
+Compatible MPEG2 decoders:\r
+* Cyberlink PowerDVD 6\r
+\r
+Incompatible MPEG2 decoders:\r
+* Cyperlink PowerDVD 4\r
+\r
+This list will be extended, please report success or failure with your decoder\r
+at the forum at http://www.loggytronic.com .\r
+\r
+Remote Control Buttons Reference\r
+================================\r
+\r
+This table shows the Hauppauge MediaMVP remote control buttons and their\r
+corresponding Windows keyboard assignments:\r
+\r
+MediaMVP Button | Keyboard Shortcut\r
+----------------*------------------\r
+VOLUMEUP        | F10\r
+VOLUMEDOWN      | F9\r
+CHANNELUP       | "+", Ctrl+"+", Page down\r
+CHANNELDOWN     | Insert, Ctrl+Insert, Page up\r
+0               | 0\r
+1               | 1\r
+2               | 2\r
+3               | 3\r
+4               | 4\r
+5               | 5\r
+6               | 6\r
+7               | 7\r
+8               | 8\r
+9               | 9\r
+POWER           | Esc, Alt+F4\r
+GO              | j\r
+BACK            | Backspace\r
+MENU            | m\r
+RED             | r\r
+GREEN           | g\r
+YELLOW          | y\r
+BLUE            | b\r
+MUTE            | F8\r
+RADIO           | Not implemented\r
+REVERSE         | Not implemented (Can work on Remote Controls)\r
+PLAY            | Shift + P\r
+FORWARD         | Shift + F\r
+RECORD          | Ctrl + R\r
+STOP            | Ctrl + S\r
+PAUSE           | Ctrl + P\r
+SKIPBACK        | Ctrl + B\r
+SKIPFORWARD     | Ctrl + F\r
+OK              | Space, Return\r
+FULL            | Not implemented\r
+TV              | Not implemented\r
+VIDEOS          | Not implemented\r
+MUSIC           | Not implemented\r
+PICTURES        | Not implemented\r
+GUIDE           | Not implemented\r
+UP              | UP\r
+DOWN            | DOWN\r
+LEFT            | LEFT\r
+RIGHT           | RIGHT\r
+PREVCHANNEL     | Not implemented\r
+STAR            | *\r
+HASH            | Not implemented\r
+\r
+(Note: Remote Controls for Windows should work also for most buttons,\r
+but this is an yet untested feature.)\r
+\r
+Usage\r
+=====\r
+Start the client executable and enjoy, you should not have to configure\r
+anything if you met the requirements above.\r
+\r
+Firewall\r
+========\r
+If vomp for Windows stops at "Locating server" or "Connecting to VDR",\r
+please configure your firewall so that vomp for windows can communicate\r
+with the vompserver on port 3024 (UDP and TCP).\r
index d01bbf110dfa563a666b64caaabc2f7029238330..3cbb603962c5267d7e6002846e5badf9a7ccd778 100644 (file)
--- a/video.cc
+++ b/video.cc
@@ -74,3 +74,9 @@ hmsf Video::framesToHMSF(ULONG frames)
   }
   return ret;
 }
+
+UINT Video::getFPS()
+{
+  if (format == NTSC) return 30;
+  else return 25;
+}
diff --git a/video.h b/video.h
index 7f54b958b2597a29ffecbb42b40c945f14d7047e..660e3e95d3206bb302d766cfde81f05f79a9a28b 100644 (file)
--- a/video.h
+++ b/video.h
@@ -85,6 +85,7 @@ class Video: public DrainTarget
     UCHAR getTVsize()       { return tvsize; }
 
     hmsf framesToHMSF(ULONG frames);
+    UINT getFPS();
 
     // Video formats - AV_SET_VID_DISP_FMT
     const static UCHAR NTSC = 0;
index 6c5b9e44c82f7c7ce8fa55da07efcb24a3506bbb..5c1db8647fcf5e2cbc8561146a9d98213d839f36 100644 (file)
@@ -82,7 +82,7 @@ VVideoRec::VVideoRec(Recording* rec)
 VVideoRec::~VVideoRec()
 {
   if (playing) stopPlay();
-  Video::getInstance()->setDefaultAspect();
+  video->setDefaultAspect();
 
   timers->cancelTimer(this, 1);
   timers->cancelTimer(this, 2);
@@ -127,7 +127,7 @@ void VVideoRec::go(ULLONG startPosition)
 
     VInfo* vi = new VInfo();
     vi->create(400, 150);
-    if (Video::getInstance()->getFormat() == Video::PAL)
+    if (video->getFormat() == Video::PAL)
       vi->setScreenPos(170, 200);
     else
       vi->setScreenPos(160, 150);
@@ -379,30 +379,19 @@ void VVideoRec::drawBarClocks()
 
   rectangle(clocksRegion, barBlue);
 
-  ULONG currentTS = (player->getPositionTS() / 90000);
-  int chours = currentTS / 3600;
-  int cminutes = (currentTS - (chours * 3600)) / 60;
-  int cseconds = currentTS - (chours * 3600) - (cminutes * 60);
+  ULONG currentFrameNum = player->getCurrentFrameNum();
+  ULONG lengthFrames = player->getLengthFrames();
 
-  ULONG endTS = (player->getEndTS() / 90000);
-//  int ehours = endTS / 3600;
-//  int eminutes = (endTS - (ehours * 3600)) / 60;
-//  int eseconds = endTS - (ehours * 3600) - (eminutes * 60);
-
-  hmsf endHMSF = player->getEndHMSF();
+  hmsf currentFrameHMSF = video->framesToHMSF(currentFrameNum);
+  hmsf lengthHMSF = video->framesToHMSF(lengthFrames);
 
   char buffer[100];
-  if ((currentTS > 95441) // it's at the 33bit rollover point where the calc doesn't work because of the 1s diff
-                          // between demuxer values and video chip return values ... ?
-      || (!endTS) )        // No values yet
-  {
-    strcpy(buffer, "-:--:-- / -:--:--");
-  }
-  else
-  {
-    SNPRINTF(buffer, 99, "%01i:%02i:%02i / %01i:%02i:%02i", chours, cminutes, cseconds, endHMSF.hours, endHMSF.minutes, endHMSF.seconds);
+//  strcpy(buffer, "-:--:-- / -:--:--");
+//  else
+//  {
+    SNPRINTF(buffer, 99, "%01i:%02i:%02i / %01i:%02i:%02i", currentFrameHMSF.hours, currentFrameHMSF.minutes, currentFrameHMSF.seconds, lengthHMSF.hours, lengthHMSF.minutes, lengthHMSF.seconds);
     logger->log("VVideoRec", Log::DEBUG, buffer);
-  }
+//  }
 
   drawText(buffer, clocksRegion.x, clocksRegion.y, Colour::LIGHTTEXT);
 
@@ -411,9 +400,9 @@ void VVideoRec::drawBarClocks()
   rectangle(barRegion.x + 350, barRegion.y + 12, 310, 24, Colour::LIGHTTEXT);
   rectangle(barRegion.x + 352, barRegion.y + 14, 306, 20, barBlue);
 
-  if ((currentTS > 95441) || (!endTS)) return;    // No values yet
+//  if ((currentTS > 95441) || (!endTS)) return;    // No values yet
 
-  double progress01 = (double)currentTS / (double)endTS;
+  double progress01 = (double)currentFrameNum / (double)lengthFrames;
   // total width of bar = 302
   int progressWidth = (int)(302 * progress01);
 
@@ -423,13 +412,13 @@ void VVideoRec::drawBarClocks()
   double pos01;
   int posPix;
 
-  pos01 = (double)startMargin / (double)endTS;
+  pos01 = ((double)startMargin * video->getFPS()) / lengthFrames;
   posPix = (int)(302 * pos01);
 
   rectangle(barRegion.x + 352 + posPix, barRegion.y + 12 - 2, 2, 2, Colour::LIGHTTEXT);
   rectangle(barRegion.x + 352 + posPix, barRegion.y + 12 + 24, 2, 2, Colour::LIGHTTEXT);
 
-  pos01 = (double)(endTS - endMargin) / (double)endTS;
+  pos01 = lengthFrames - (endMargin * video->getFPS()) / lengthFrames;
   posPix = (int)(302 * pos01);
 
   rectangle(barRegion.x + 352 + posPix, barRegion.y + 12 - 2, 2, 2, Colour::LIGHTTEXT);