]> git.vomp.tv Git - vompclient-marten.git/commitdiff
Half way through recording playback OSD stuff
authorChris Tallon <chris@vomp.tv>
Mon, 6 Mar 2006 01:19:21 +0000 (01:19 +0000)
committerChris Tallon <chris@vomp.tv>
Mon, 6 Mar 2006 01:19:21 +0000 (01:19 +0000)
command.cc
player.h
playervideo.cc
playervideo.h
stb.h
video.cc
video.h
vvideorec.cc
wsymbol.cc
wsymbol.h

index 0aa5162a774eb70e1df15b173984344bc708a71b..7409b3076aa48da881912c78b98d1efdb68c7154 100644 (file)
@@ -578,7 +578,6 @@ void Command::doJustConnected(VConnect* vconnect)
 //  handleCommand(Remote::THREE);
 //  handleCommand(Remote::DOWN);
 //  handleCommand(Remote::OK);
-//  handleCommand(Remote::OK);
-//  handleCommand(Remote::OK);
+//  handleCommand(Remote::PLAY);
 
 }
index c4591d15d5220b1112ad66876df13550a9f0e807..0032356b5805adffda0fef4465aea2b4ca09bd71 100644 (file)
--- a/player.h
+++ b/player.h
@@ -48,6 +48,8 @@ class Player : public Thread, public Callback
     virtual bool isPaused()=0;
     virtual bool isFfwd()=0;
     virtual bool isFbwd()=0;
+    virtual ULLONG getPositionTS()=0;
+    virtual ULLONG getEndTS()=0;
 
 #ifdef DEV
     virtual void test1()=0;
index ef72f099d731ea2be81788276533dc7dc2bdd4c0..3a27a71f3f21a0268275f0a7b8be10e148af34c1 100644 (file)
@@ -34,6 +34,8 @@ PlayerVideo::PlayerVideo(MessageQueue* messageQueue, UCHAR tIsRecording, UCHAR i
   feedMode = MODE_NORMAL;
   isRecording = tIsRecording;
   lastRescan = 0;
+  startTS = 0;
+  endTS = 0;
   threadBuffer = NULL;
 
   if (isRadio)
@@ -497,6 +499,19 @@ void PlayerVideo::jumpToPercent(int percent)
   video->sync();
 }
 
+ULLONG PlayerVideo::getPositionTS()
+{
+  long long currentTS = video->getCurrentTimestamp() - startTS;
+  if (currentTS < 0) currentTS += 7776000000ULL;
+  return (ULLONG)currentTS;
+}
+
+ULLONG PlayerVideo::getEndTS()
+{
+  long long rendTS = endTS - startTS;
+  if (rendTS < 0) rendTS += 7776000000ULL;
+  return (ULLONG)rendTS;
+}
 
 void PlayerVideo::call(void* caller)
 {
@@ -558,6 +573,7 @@ void PlayerVideo::threadMethod()
       streamLength = vdr->rescanRecording();
       Log::getInstance()->log("PlayerVideo", Log::DEBUG, "Rescanned and reset length: %llu", streamLength);
       lastRescan = time(NULL);
+      setEndTS();
     }
 
     if (streamLength) // is playing a recording
@@ -595,6 +611,10 @@ void PlayerVideo::threadMethod()
       int a_stream = demuxer.scan(threadBuffer, thisRead);
       demuxer.setAudioStream(a_stream);
       Log::getInstance()->log("Player", Log::DEBUG, "Startup Audio stream chosen %x", a_stream);
+
+      demuxer.findVideoPTS(threadBuffer, thisRead, &startTS);
+      if (isRecording) setEndTS();
+
       startup = 0;
     }
 
@@ -662,6 +682,18 @@ void PlayerVideo::threadPostStopCleanup()
   }
 }
 
+void PlayerVideo::setEndTS()
+{
+  Log::getInstance()->log("Player", Log::DEBUG, "Setting end TS");
+
+  UINT thisRead;
+  UCHAR* tempBuffer = VDR::getInstance()->getBlock((streamLength - 100000), 100000, &thisRead);
+  if (!tempBuffer) return;
+  if (thisRead) demuxer.findVideoPTS(tempBuffer, thisRead, &endTS);
+  free(tempBuffer);
+  Log::getInstance()->log("Player", Log::DEBUG, "Set end TS");
+}
+
 #ifdef DEV
 void PlayerVideo::test1()
 {
index 7d3908bf9e685f8617bdbe91fdbd27ead0917963..19a2e9cb85863ab1967293680e29fc6c6bdec3d1 100644 (file)
@@ -57,6 +57,8 @@ class PlayerVideo : public Player
     void setPosition(ULLONG position);
     void setLength(ULLONG length);
     void resyncAudio();
+    ULLONG getPositionTS();
+    ULLONG getEndTS();
 
     bool isPaused() { return paused; }
     bool isFfwd() { return ffwd; }
@@ -71,6 +73,8 @@ class PlayerVideo : public Player
     void threadPostStopCleanup();
 
   private:
+    void setEndTS();
+
     MessageQueue* commandMessageQueue;
     Log* logger;
     Video* video;
@@ -78,6 +82,9 @@ class PlayerVideo : public Player
     int startup;
     VFeed vfeed;
     AFeed afeed;
+
+    ULLONG startTS;
+    ULLONG endTS;
     ULLONG feedPosition;
     UCHAR feedMode;
     UCHAR isRecording;
diff --git a/stb.h b/stb.h
index bcc3f93a9b309a395c15888ea5acd6a91e5e04d7..ef828f4afbcbd760a3746a81ab8dd4cfd2f5dcf1 100644 (file)
--- a/stb.h
+++ b/stb.h
@@ -125,12 +125,14 @@ typedef struct {
 } vid_pos_regs_t;
 //
 
+/*
 typedef struct {
   int stc_b32;
   int stc_b0;
   int pts_b32;
   int pts_b0;
 } pts_sync_data_t;
+*/
 
 typedef struct {
   int parm1;
@@ -179,7 +181,7 @@ typedef struct {
 #define AV_GET_AUD_VOLUME _IOR('a',14,int)
 #define AV_SET_AUD_STREAMTYPE _IOW('a',15,int)
 #define AV_SET_AUD_FORMAT _IOW('a',16,int)
-#define AV_GET_AUD_SYNC   _IOR('a',21,pts_sync_data_t*)
+#define AV_GET_AUD_TIMESTAMPS  _IOR('a',21, sync_data_t*)
 #define AV_SET_AUD_STC    _IOW('a',22,uint64_t *)
 #define AV_SET_AUD_SYNC   _IOW('a',23,int)
 #define AV_SET_AUD_DISABLE_SYNC _IOW('a',24,aud_sync_parms_t*)
@@ -208,7 +210,7 @@ typedef struct {
 #define AV_SET_VID_POSITION _IOW('v',36,vid_pos_regs_t*)
 #define AV_SET_VID_SCALE_ON _IOW('v',37,int)
 #define AV_SET_VID_SCALE_OFF  _IOW('v',38,int)
-#define AV_GET_VID_SYNC   _IOR('v',39,int)
+#define AV_GET_VID_TIMESTAMPS   _IOR('v',39, sync_data_t*)
 #define AV_SET_VID_STC    _IOW('v',40,uint64_t *)
 #define AV_SET_VID_RATIO  _IOW('v',41,int)
 #define AV_SET_VID_SYNC   _IOW('v',42,int)
index c0fc1b56c215dd997e5c468132790395aefcb42a..f129df15039d6e79726ead6d083f2bacae5c2a67 100644 (file)
--- a/video.cc
+++ b/video.cc
@@ -370,6 +370,24 @@ UCHAR Video::getTVsize()
   return tvsize;
 }
 
+ULLONG Video::getCurrentTimestamp()
+{
+  sync_data_t timestamps;
+  if (ioctl(fdVideo, AV_GET_VID_TIMESTAMPS, &timestamps) == 0)
+  {
+    // FIXME are these the right way around?
+
+    timestamps.stc = (timestamps.stc >> 31 ) | (timestamps.stc & 1);
+    timestamps.pts = (timestamps.pts >> 31 ) | (timestamps.pts & 1);
+
+    return timestamps.stc;
+  }
+  else
+  {
+    return 0;
+  }
+}
+
 #ifdef DEV
 int Video::test()
 {
diff --git a/video.h b/video.h
index a8106f04e04f40668e1f891f5787219ce1ce4fd8..11497f92bfe2beb99321c713ecb2865a978771ba 100644 (file)
--- a/video.h
+++ b/video.h
@@ -120,6 +120,7 @@ class Video
     UINT getScreenWidth();
     UINT getScreenHeight();
     UCHAR getTVsize();
+    ULLONG getCurrentTimestamp();
 
   private:
     int checkSCART();
index 3d5bd41549378251a1ca0804d9f72c47234ab45e..5deb105b01dd1ae0c800d182c55b6097cd4b2397 100644 (file)
@@ -138,6 +138,7 @@ int VVideoRec::handleCommand(int command)
     case Remote::FORWARD:
     {
       player->toggleFastForward();
+      doBar(0);
       return 2;
     }
     case Remote::YELLOW:
@@ -263,13 +264,28 @@ void VVideoRec::doBar(int action)
   else
   {
     if (player->isPaused())     w.nextSymbol = WSymbol::PAUSE;
-    else if (player->isFfwd())  ;
-    else if (player->isFbwd())  ;
+    else if (player->isFfwd())  w.nextSymbol = WSymbol::FFWD;
+    else if (player->isFbwd())  w.nextSymbol = WSymbol::FBWD;
     else                        w.nextSymbol = WSymbol::PLAY;
   }
 
   w.draw();
 
+  ULONG currentTS = (player->getPositionTS() / 90000);
+  int chours = currentTS / 3600;
+  int cminutes = (currentTS - (chours * 3600)) / 60;
+  int cseconds = currentTS - (chours * 3600) - (cminutes * 60);
+
+  ULONG endTS = (player->getEndTS() / 90000);
+  int ehours = endTS / 3600;
+  int eminutes = (endTS - (ehours * 3600)) / 60;
+  int eseconds = endTS - (ehours * 3600) - (eminutes * 60);
+
+  char buffer[100];
+  snprintf(buffer, 99, "%01i:%02i:%02i / %01i:%02i:%02i", chours, cminutes, cseconds, ehours, eminutes, eseconds);
+
+  drawText(buffer, barRegion.x + 180, barRegion.y + 12, Colour::LIGHTTEXT);
+
   ViewMan::getInstance()->updateView(this, &barRegion);
   Timers::getInstance()->setTimer(this, 1, (struct timespec){4, 0});
 }
index 959b875a5447a181d7d2148ca8167b5b498d2292..8de9f14441176825760339a1356e202fa150d5cc 100644 (file)
@@ -20,8 +20,8 @@
 
 #include "wsymbol.h"
 
-UCHAR WSymbol::widths[] = { 2, 2, 4, 4, 1, 1, 3, 3, 3, 3, 3, 4, 4, 2, 2, 3, 5, 5};
-UCHAR WSymbol::heights[] = { 8, 8, 12, 12, 24, 4, 18, 18, 18, 18, 18, 30, 30, 16, 16, 18, 18, 18};
+UCHAR WSymbol::widths[] = { 2, 2, 4, 4, 1, 1, 3, 3, 3, 3, 3, 4, 4, 2, 2, 3, 5, 5, 4, 4};
+UCHAR WSymbol::heights[] = { 8, 8, 12, 12, 24, 4, 18, 18, 18, 18, 18, 30, 30, 16, 16, 18, 18, 18, 16, 16};
 
 UCHAR WSymbol::symbols[] = {
 
@@ -722,6 +722,78 @@ UCHAR WSymbol::symbols[] = {
 0x3C, 0x00, 0x0F, 0x00, 0x03,
 0x30, 0x00, 0x0C, 0x00, 0x03,
 
+/*
+00000000 00000011 00000000 00000011
+00000000 00001111 00000000 00001111
+00000000 00111111 00000000 00111111
+00000000 11111111 00000000 11111111
+00000011 11111111 00000011 11111111
+00001111 11111111 00001111 11111111
+00111111 11111111 00111111 11111111
+11111111 11111111 11111111 11111111
+11111111 11111111 11111111 11111111
+00111111 11111111 00111111 11111111
+00001111 11111111 00001111 11111111
+00000011 11111111 00000011 11111111
+00000000 11111111 00000000 11111111
+00000000 00111111 00000000 00111111
+00000000 00001111 00000000 00001111
+00000000 00000011 00000000 00000011
+*/
+
+0x00, 0x03, 0x00, 0x03,
+0x00, 0x07, 0x00, 0x07,
+0x00, 0x3F, 0x00, 0x3F,
+0x00, 0xFF, 0x00, 0xFF,
+0x03, 0xFF, 0x03, 0xFF,
+0x07, 0xFF, 0x07, 0xFF,
+0x3F, 0xFF, 0x3F, 0xFF,
+0xFF, 0xFF, 0xFF, 0xFF,
+0xFF, 0xFF, 0xFF, 0xFF,
+0x3F, 0xFF, 0x3F, 0xFF,
+0x07, 0xFF, 0x07, 0xFF,
+0x03, 0xFF, 0x03, 0xFF,
+0x00, 0xFF, 0x00, 0xFF,
+0x00, 0x3F, 0x00, 0x3F,
+0x00, 0x07, 0x00, 0x07,
+0x00, 0x03, 0x00, 0x03,
+
+/*
+11000000 00000000 11000000 00000000
+11110000 00000000 11110000 00000000
+11111100 00000000 11111100 00000000
+11111111 00000000 11111111 00000000
+11111111 11000000 11111111 11000000
+11111111 11110000 11111111 11110000
+11111111 11111100 11111111 11111100
+11111111 11111111 11111111 11111111
+11111111 11111111 11111111 11111111
+11111111 11111100 11111111 11111100
+11111111 11110000 11111111 11110000
+11111111 11000000 11111111 11000000
+11111111 00000000 11111111 00000000
+11111100 00000000 11111100 00000000
+11110000 00000000 11110000 00000000
+11000000 00000000 11000000 00000000
+*/
+
+0xC0, 0x00, 0xC0, 0x00,
+0xF0, 0x00, 0xF0, 0x00,
+0xFC, 0x00, 0xFC, 0x00,
+0xFF, 0x00, 0xFF, 0x00,
+0xFF, 0xC0, 0xFF, 0xC0,
+0xFF, 0xF0, 0xFF, 0xF0,
+0xFF, 0xFC, 0xFF, 0xFC,
+0xFF, 0xFF, 0xFF, 0xFF,
+0xFF, 0xFF, 0xFF, 0xFF,
+0xFF, 0xFC, 0xFF, 0xFC,
+0xFF, 0xF0, 0xFF, 0xF0,
+0xFF, 0xC0, 0xFF, 0xC0,
+0xFF, 0x00, 0xFF, 0x00,
+0xFC, 0x00, 0xFC, 0x00,
+0xF0, 0x00, 0xF0, 0x00,
+0xC0, 0x00, 0xC0, 0x00,
+
 };
 
 WSymbol::WSymbol()
index 3074e127d2b1c01da75d89b392a27806aff0a9d9..bffb69d3f516bfea48f02a7e0e1e2419fdbe2074 100644 (file)
--- a/wsymbol.h
+++ b/wsymbol.h
@@ -52,6 +52,8 @@ class WSymbol : public Widget
     const static UCHAR PAUSE = 15;
     const static UCHAR SKIPBACK2 = 16;
     const static UCHAR SKIPFORWARD2 = 17;
+    const static UCHAR FBWD = 18;
+    const static UCHAR FFWD = 19;
 
   private:
     static UCHAR symbols[];