]> git.vomp.tv Git - vompclient-marten.git/commitdiff
EPG tweaks, EPG made NTSC compatible
authorChris Tallon <chris@vomp.tv>
Tue, 13 Dec 2005 18:13:48 +0000 (18:13 +0000)
committerChris Tallon <chris@vomp.tv>
Tue, 13 Dec 2005 18:13:48 +0000 (18:13 +0000)
PAL/NTSC overridable from config file

command.cc
command.h
main.cc
vepg.cc
vepg.h
vvideolive.cc
vvideolive.h
vvideorec.cc
vvideorec.h

index 5c7731339dbe29e20ba0e0479ed3c2c0f2b15d03..a21a09731f0cd3fd7a6b04de0d7cf0f73abe63f9 100644 (file)
@@ -74,23 +74,10 @@ void Command::stop()
   irun = 0;
 }
 
-void Command::run()
+void Command::doWallpaper()
 {
-  if (!initted) return;
-  irun = 1;
-
-  mainPid = getpid();
-
   Video* video = Video::getInstance();
 
-  UCHAR screenSize = video->getFormat();
-
-  // moved from startup because surface delete doesn't work
-
-  // just in case
-  video->signalOn();
-  Led::getInstance()->on();
-
   // Blue background
   View* v = new View();
   v->create(video->getScreenWidth(), video->getScreenHeight());
@@ -102,7 +89,7 @@ void Command::run()
 
   // Wallpaper
   wallpaper = new VWallpaper();
-  if (screenSize == Video::PAL)
+  if (video->getFormat() == Video::PAL)
   {
     logger->log("Command", Log::DEBUG, "PAL wallpaper selected");
     wallpaper->init("/wallpaperPAL.jpg");
@@ -115,6 +102,20 @@ void Command::run()
   wallpaper->draw();
   viewman->add(wallpaper);
   viewman->updateView(wallpaper);
+}
+
+void Command::run()
+{
+  if (!initted) return;
+  irun = 1;
+
+  mainPid = getpid();
+
+  // just in case
+  Video::getInstance()->signalOn();
+  Led::getInstance()->on();
+
+  doWallpaper();
 
   // End of startup. Lock the mutex and put the first view up
 
@@ -330,6 +331,63 @@ void Command::doJustConnected(VConnect* vconnect)
   VDR* vdr = VDR::getInstance();
   char* config;
 
+  // See if config says to override video format (PAL/NTSC)
+  config = vdr->configLoad("General", "Override Video Format");
+  if (config)
+  {
+    logger->log("Command", Log::DEBUG, "Override Video Format is present");
+
+    if (   (!strcmp(config, "PAL") && (video->getFormat() == Video::NTSC))
+        || (!strcmp(config, "NTSC") && (video->getFormat() == Video::PAL))  )
+    {
+      // Oh sheesh, need to switch format. Bye bye TV...
+
+      // Take everything down
+      viewman->removeAll();
+      viewman->removeView(wallpaper);
+      Osd* osd = Osd::getInstance();
+      osd->shutdown();
+      video->shutdown();
+
+      // Get video and osd back up with the new mode
+      if (!strcmp(config, "PAL"))
+      {
+        logger->log("Command", Log::DEBUG, "Switching to PAL");
+        video->init(Video::PAL);
+      }
+      else if (!strcmp(config, "NTSC"))
+      {
+        logger->log("Command", Log::DEBUG, "Switching to NTSC");
+        video->init(Video::NTSC);
+      }
+      osd->init("/dev/stbgfx");
+
+      // Put the wallpaper back
+      doWallpaper();
+
+      // Re add the vinfo
+      vi = new VInfo();
+      vi->create(400, 200);
+      if (video->getFormat() == Video::PAL)
+        vi->setScreenPos(170, 200);
+      else
+        vi->setScreenPos(160, 150);
+
+      vi->setOneLiner(tr("Connected, loading config"));
+      vi->draw();
+      viewman->add(vi);
+      viewman->updateView(vi);
+    }
+    else
+    {
+      logger->log("Command", Log::DEBUG, "Already in requested mode, or request was not 'PAL' or 'NTSC'");
+    }
+  }
+  else
+  {
+    logger->log("Command", Log::DEBUG, "Phew, no dangerous on-the-fly mode switching to do!");
+  }
+
   // Power off if first boot and config says so
   if (firstBoot)
   {
index 3fe958ec61d8bbf6646ae25e57c96d8a57d64130..2da9f7812440cab76ae19fcc9b5765d1d2e03085 100644 (file)
--- a/command.h
+++ b/command.h
@@ -75,6 +75,7 @@ class Command : public MessageQueue
     void handleCommand(int);
     void doStandby();
     void doJustConnected(VConnect* vconnect);
+    void doWallpaper();
 
     static Command* instance;
     pid_t mainPid;
diff --git a/main.cc b/main.cc
index 723ea6b5c9a51aa5f5682d4da7fb551a97805cd7..2f9a5767b97f8f3eeb1119126457bb67c809d0a9 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -209,7 +209,7 @@ int main(int argc, char** argv)
   else if (videoFormat == Video::NTSC) logger->log("Core", Log::INFO, "Read from MTD: NTSC 720x480");
   else                                 logger->log("Core", Log::INFO, "No help from MTD. Assuming NTSC 720x480");
 
-//  videoFormat = Video::NTSC; // enable this line to test NTSC in PAL land
+  //videoFormat = Video::NTSC; // enable this line to test NTSC in PAL land
 
   success = video->init(videoFormat);
   if (success)
diff --git a/vepg.cc b/vepg.cc
index af6d2dae804126e4d2fdb041cf5243ef2eed6539..50c9d479fe96de3e2ee678bec21c2c996eeda383 100644 (file)
--- a/vepg.cc
+++ b/vepg.cc
 */\r
 \r
 #include "vepg.h"\r
+
+VEpg* VEpg::instance = NULL;
 \r
 VEpg::VEpg(VVideoLive* v, UINT currentChannel)\r
 {\r
+  instance = this;
+
+  // PAL / NTSC sizes -----------------------
+
+  int xsize, ysize;
+  int xpos, ypos;
+  int summaryLines, summaryLowerPadding;
+  int chanNameYpos;
+  //UINT gridRows; // is a class member
+
+  if (Video::getInstance()->getFormat() == Video::PAL)
+  {
+    xsize = 632;
+    ysize = 541;
+    xpos = 60;
+    ypos = 16;
+    summaryLines = 8;
+    summaryLowerPadding = 12;
+    chanNameYpos = 244;
+    gridRows = 7;
+  }
+  else
+  {
+    xsize = 632;
+    ysize = 452;
+    xpos = 50;
+    ypos = 10;
+    summaryLines = 6;
+    summaryLowerPadding = 26;
+    chanNameYpos = 206;
+    gridRows = 5;
+  }
+
   // initialise variables and pointers
   viewman = ViewMan::getInstance();\r
   videoLive = v;
@@ -42,7 +77,7 @@ VEpg::VEpg(VVideoLive* v, UINT currentChannel)
   chanList = VDR::getInstance()->getChannelsList(VDR::VIDEO); //TODO want to be able to display video and radio together
   e = 0;
 \r
-  for(UINT listIndex = 0; listIndex < 7; listIndex++)\r
+  for(UINT listIndex = 0; listIndex < gridRows; listIndex++)\r
   {\r
     // initialise array of pointers to eventlist structures\r
     eventLista[listIndex] = NULL;\r
@@ -51,46 +86,38 @@ VEpg::VEpg(VVideoLive* v, UINT currentChannel)
   // Create pallet on which to paint our epg view and position it in centre of screen.\r
   // Need to reduce size to deal with overscanning TVs.\r
 
-  // FIXME have size for ntsc\r
-  if (Video::getInstance()->getFormat() == Video::PAL)\r
-  {\r
-    create(632, 541);\r
-    setScreenPos(60, 16);\r
-  }\r
-  else\r
-  {\r
-    create(632, 440);\r
-    setScreenPos(50, 10);\r
-  }\r
+  create(xsize, ysize);\r
+  setScreenPos(xpos, ypos);\r
 \r
-// beautify\r
+  // beautify\r
   Colour transparent = Colour(0, 0, 0, 0);\r
   setBackgroundColour(transparent);\r
 
   progTitle.setSurface(surface);\r
   progTitle.setSurfaceOffset(0,0);\r
-  progTitle.setDimensions(300,(Surface::getFontHeight() + 6) * 2 + 16); //paragraph line seperation is 6 pixels\r
+  progTitle.setDimensions(300,(Surface::getFontHeight() + 4) * 2 + 16); //paragraph line seperation is 4 pixels\r
   progTitle.setBackgroundColour(Colour::TITLEBARBACKGROUND);\r
   progTitle.setTextPos(5, 16);
+  progTitle.setGap(4);
 
   progInfo.setSurface(surface);\r
   progInfo.setSurfaceOffset(0, progTitle.getOffsetY() + progTitle.getHeight());\r
-  progInfo.setDimensions(300,(Surface::getFontHeight() + 4) * 8 + 12);\r
+  progInfo.setDimensions(300,((Surface::getFontHeight() + 4) * summaryLines) + summaryLowerPadding);\r
   progInfo.setGap(4);
 
   chanName.setSurface(surface);\r
   chanName.setDimensions(510, (Surface::getFontHeight() + 4));\r
-  chanName.setSurfaceOffset(305,244);\r
+  chanName.setSurfaceOffset(305, chanNameYpos);\r
   chanName.setBackgroundColour(Colour(0, 0, 0, 90));\r
 
   // create area to display list of channels\r
   chanListbox.setSurface(surface); // add channel list\r
   chanListbox.setSurfaceOffset(0, progInfo.getOffsetY() + progInfo.getHeight() + Surface::getFontHeight() + 8); // position channel list\r
-  chanListbox.setDimensions(150, (Surface::getFontHeight() + 2) * 7 + 5); //listbox line seperation is 1 pixel\r
+  chanListbox.setDimensions(150, ((Surface::getFontHeight() + 2) * gridRows) + 5); //listbox line seperation is 2 pixels\r
   chanListbox.setGap(2);
 
 
-// populate channel list\r
+  // populate channel list\r
   Channel* chan;\r
   int first = 1;\r
   for (UINT i = 0; i < chanList->size(); i++)\r
@@ -112,18 +139,25 @@ VEpg::VEpg(VVideoLive* v, UINT currentChannel)
 \r
 VEpg::~VEpg()\r
 {\r
-   for(int listIndex = 0; listIndex < 7; listIndex++)\r
-   {\r
-     if (eventLista[listIndex])\r
-     {\r
-       (eventLista)[listIndex]->clear();\r
-       delete eventLista[listIndex];\r
-     }\r
-   }\r
-//  delete [] eventLista;\r
+  instance = NULL;
+
+  for(UINT listIndex = 0; listIndex < gridRows; listIndex++)\r
+  {\r
+    if (eventLista[listIndex])\r
+    {\r
+      (eventLista)[listIndex]->clear();\r
+      delete eventLista[listIndex];\r
+    }\r
+  }\r
+  //  delete [] eventLista;\r
 \r
-// destroy dynamically allocated memory\r
+  // destroy dynamically allocated memory\r
 }\r
+
+VEpg* VEpg::getInstance()
+{
+  return instance;
+}
 \r
 void VEpg::setInfo(Event* event)\r
 {\r
@@ -328,7 +362,7 @@ int VEpg::handleCommand(int command)
     case Remote::GUIDE:\r
     {\r
       // return to normal TV mode\r
-      videoLive->setEpgMode(FALSE);\r
+      if (videoLive) videoLive->resetPictureSize(); // ptr check done in case being tested from videorec\r
       return 4;\r
     }\r
     case Remote::CHANNELUP:\r
@@ -413,11 +447,11 @@ void VEpg::drawgrid() // redraws grid and select programme
   int y = chanListbox.getOffsetY() + 5; // vertical position of cell\r
   Colour bg, fg; // background colour of cells in grid\r
   // for each displayed channel, find programmes that fall in 2.5 hour time window\r
-  for(int listIndex = 0; listIndex < 7; listIndex++)\r
+  for(UINT listIndex = 0; listIndex < gridRows; listIndex++)\r
   {\r
-    if (listTop + listIndex >= chanListbox.getBottomOption())\r
+    if (listTop + (int)listIndex >= chanListbox.getBottomOption())\r
       continue; // ensure nothing populates grid below last channel\r
-    currentRow = (listTop + listIndex == chanListbox.getCurrentOption());\r
+    currentRow = (listTop + (int)listIndex == chanListbox.getCurrentOption());\r
     noevent.time = ltime;\r
     noevent.duration = WINDOW_WIDTH * 60;\r
     noevent.settitle("");\r
@@ -499,7 +533,7 @@ void VEpg::drawgrid() // redraws grid and select programme
 void VEpg::updateEventList()\r
 {\r
   Channel* chan;\r
-  for(UINT listIndex = 0; listIndex < 7; listIndex++)\r
+  for(UINT listIndex = 0; listIndex < gridRows; listIndex++)\r
   {\r
     if (eventLista[listIndex])\r
     {\r
diff --git a/vepg.h b/vepg.h
index d9c786f46ea4270335d15ffd7139635e70ea2339..4d48c503bbb99035a8a4d716e7adc3e5d70bd68b 100644 (file)
--- a/vepg.h
+++ b/vepg.h
@@ -47,12 +47,15 @@ class VEpg : public View
   public:\r
     VEpg(VVideoLive* v, UINT currentChannel = 0);\r
     ~VEpg();\r
+    static VEpg* getInstance();\r
 \r
     int handleCommand(int command); // deal with commands (from remote control)\r
     void draw(); // draw epg view\r
     void setCurrentChannel(char* chname);\r
 \r
   private:\r
+    static VEpg* instance;\r
+\r
     void setInfo(Event* event); // display details of selected programme\r
     void drawgrid(); // redraws grid and select programme\r
     void drawData();\r
@@ -79,6 +82,7 @@ class VEpg : public View
     time_t prevHour(time_t* t);\r
     VVideoLive* videoLive;\r
     ViewMan* viewman;\r
+    UINT gridRows;\r
 };\r
 \r
 #endif\r
index 6a39630264175c9d79caed2eb7f4a8fb6dd2ef6f..5321c51a5bf2af8fb0fe5a757b3bfed9bd3b2d46 100644 (file)
@@ -33,7 +33,6 @@ VVideoLive::VVideoLive(ChannelList* tchanList, ULONG tstreamType)
   unavailable = 0;
   unavailableView = NULL;
   streamType = tstreamType;
-  epgmode=false;
   videoMode = Video::getInstance()->getMode();
   if (streamType == VDR::RADIO) player = new PlayerVideo(Command::getInstance(), 0, 1);
   else                          player = new PlayerVideo(Command::getInstance(), 0, 0);
@@ -124,11 +123,7 @@ int VVideoLive::handleCommand(int command)
     case Remote::GUIDE:
     case Remote::RED:
     {
-      if (!epgmode)
-      {
-        showEPG();
-      }
-      epgmode=!epgmode;
+      showEPG();
       return 2;
     }
 
@@ -189,9 +184,9 @@ void VVideoLive::channelChange(UCHAR changeType, UINT newData)
 
   if (unavailable) showUnavailable(0);
   else stop(1);
-  if(epgmode)
-    if(vepg)
-      vepg->setCurrentChannel((*chanList)[currentChannel]->name);
+
+  VEpg* vepg = VEpg::getInstance();
+  if(vepg) vepg->setCurrentChannel((*chanList)[currentChannel]->name);
   play();
 }
 
@@ -205,7 +200,7 @@ void VVideoLive::processMessage(Message* m)
   {
     // this message is from vlivebanner
     channelChange(OFFSET, UP);
-    if(!epgmode)
+    if(!VEpg::getInstance())
     {
       VLiveBanner* vlb = VLiveBanner::getInstance(); // guaranteed to be one
       vlb->setChannel((*chanList)[currentChannel]);
@@ -217,7 +212,7 @@ void VVideoLive::processMessage(Message* m)
   {
     // this message is from vlivebanner
     channelChange(OFFSET, DOWN);
-    if(!epgmode)
+    if(!VEpg::getInstance())
     {
       VLiveBanner* vlb = VLiveBanner::getInstance(); // guaranteed to be one
       vlb->setChannel((*chanList)[currentChannel]);
@@ -234,19 +229,13 @@ void VVideoLive::processMessage(Message* m)
   else if (m->message == Message::EPG)
   {
     Log::getInstance()->log("VVideoLive", Log::DEBUG, "EPG requested from live banner");
-
-    if (!epgmode)
-    {
-      showEPG();
-      epgmode=!epgmode; // shouldn't this be within the braces? // same for above in handleCommand, ask Brian FIXME
-    }
+    showEPG();
   }
 }
 
 void VVideoLive::doBanner(bool bannerTakesCommands)
 {
-  if(epgmode)
-    return;
+  if (VEpg::getInstance()) return;
 
   if (VLiveBanner::getInstance()) return; // there already is one
 
@@ -354,24 +343,20 @@ void VVideoLive::showEPG()
 {
   if (unavailable) showUnavailable(0);
 
+  if (VEpg::getInstance()) return; // already showing!
+
   Video::getInstance()->setMode(Video::QUARTER);
   Video::getInstance()->setPosition(170, 5); //TODO need to deal with 4:3 switching
 
-  vepg = new VEpg(this, currentChannel);
+  VEpg* vepg = new VEpg(this, currentChannel);
   vepg->draw();
 
   viewman->add(vepg);
   viewman->updateView(vepg);
 }
 
-void VVideoLive::setEpgMode(bool mode)
+void VVideoLive::resetPictureSize()
 {
-  epgmode = mode;
-
-  // Ok so we do need this function
-  // but FIXME improve this, integrate with live mode switching from remote
-  if (mode == FALSE)
-  {
-    Video::getInstance()->setMode(videoMode);
-  }
+  // called by VEpg when it closes
+  Video::getInstance()->setMode(videoMode);
 }
index a6eca7126cfbc2234bfe623560ea2f859c651fba..2f1e72282b4c0c5dd9fd4bb55606c69a23670e61 100644 (file)
@@ -61,7 +61,7 @@ class VVideoLive : public View
 
     void play(int noShowVLB = 0);
     void stop(int noRemoveVLB = 0);
-    void setEpgMode(bool mode);
+    void resetPictureSize();
 
     const static UCHAR INDEX = 1;
     const static UCHAR NUMBER = 2;
@@ -86,9 +86,7 @@ class VVideoLive : public View
     UINT downChannel();
     void doBanner(bool takesCommands);
     void showUnavailable(int active);
-    VEpg* vepg;
     int xpos;
-    bool epgmode;
     void showEPG();
     void doNoSuchChannel();
     int videoMode;
index 5622e187666cc0d404089a7204086efcf356925a..18e0c8a11561854df1bfccf12c26382ec7a288ab 100644 (file)
@@ -116,7 +116,18 @@ int VVideoRec::handleCommand(int command)
 #ifdef DEV
     case Remote::RED:
     {
-      player->test1();
+      //player->test1();
+
+      /*
+      // for testing EPG in NTSC with a NTSC test video
+      Video::getInstance()->setMode(Video::QUARTER);
+      Video::getInstance()->setPosition(170, 5);
+      VEpg* vepg = new VEpg(NULL, 0);
+      vepg->draw();
+      ViewMan::getInstance()->add(vepg);
+      ViewMan::getInstance()->updateView(vepg);
+      */
+
       return 2;
     }
     case Remote::GREEN:
index f33c1c73fdcdb0638c6ba47ca6656ae391feef93..cfaf2f5f79d9c1de6bb68afb4cac93f21cf4a225 100644 (file)
@@ -31,6 +31,8 @@
 #include "colour.h"
 #include "osd.h"
 
+//#include "vepg.h" // for testing EPG in NTSC with a NTSC test video
+
 class VVideoRec : public View
 {
   public: