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());
// 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");
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
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)
{
void handleCommand(int);
void doStandby();
void doJustConnected(VConnect* vconnect);
+ void doWallpaper();
static Command* instance;
pid_t mainPid;
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)
*/\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;
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
// 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
\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
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
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
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
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
time_t prevHour(time_t* t);\r
VVideoLive* videoLive;\r
ViewMan* viewman;\r
+ UINT gridRows;\r
};\r
\r
#endif\r
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);
case Remote::GUIDE:
case Remote::RED:
{
- if (!epgmode)
- {
- showEPG();
- }
- epgmode=!epgmode;
+ showEPG();
return 2;
}
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();
}
{
// 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]);
{
// 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]);
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
{
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);
}
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;
UINT downChannel();
void doBanner(bool takesCommands);
void showUnavailable(int active);
- VEpg* vepg;
int xpos;
- bool epgmode;
void showEPG();
void doNoSuchChannel();
int videoMode;
#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:
#include "colour.h"
#include "osd.h"
+//#include "vepg.h" // for testing EPG in NTSC with a NTSC test video
+
class VVideoRec : public View
{
public: