mainPid = getpid();
- UCHAR screenSize = Osd::getInstance()->getScreenSize();
+ Video* video = Video::getInstance();
+
+ UCHAR screenSize = video->getFormat();
// moved from startup because surface delete doesn't work
// just in case
- Video::getInstance()->signalOn();
+ video->signalOn();
Led::getInstance()->on();
// Blue background
View* v = new View();
- v->setDimensions(Osd::getInstance()->getScreenHeight(), Osd::getInstance()->getScreenWidth());
+ v->setDimensions(video->getScreenHeight(), video->getScreenWidth());
v->setBackgroundColour(Colour::VIDEOBLUE);
v->draw();
v->show();
// Wallpaper
VWallpaper* w = new VWallpaper();
- if (screenSize == Osd::PAL)
+ if (screenSize == Video::PAL)
{
- Log::getInstance()->log("Command", Log::DEBUG, "PAL wallpaper selected");
+ logger->log("Command", Log::DEBUG, "PAL wallpaper selected");
w->init("/wallpaperPAL.jpg");
}
else
{
- Log::getInstance()->log("Command", Log::DEBUG, "NTSC wallpaper selected");
+ logger->log("Command", Log::DEBUG, "NTSC wallpaper selected");
w->init("/wallpaperNTSC.jpg");
}
w->draw();
if (state == 3)
{
- Log::getInstance()->log("Command", Log::DEBUG, "Server selected: %i", selectServer);
+ logger->log("Command", Log::DEBUG, "Server selected: %i", selectServer);
int success = connectToServer(selectServer);
clearServerIPs();
vw->show();
viewman->add(vw);
state = 4;
+
+ // test area for just after connect
+ char* svideo = VDR::getInstance()->configLoad("TV", "S-Video");
+
+ if (svideo)
+ {
+ if (!strcasecmp(svideo, "Yes"))
+ {
+ logger->log("Command", Log::INFO, "Switching to S-Video as S-Video=%s", svideo);
+ video->setConnection(Video::SVIDEO);
+ }
+ else
+ {
+ logger->log("Command", Log::INFO, "Leaving video output as S-Video=%s", svideo);
+ }
+ }
+ else
+ {
+ logger->log("Command", Log::INFO, "Config TV/S-Video not found");
+ }
+
+/*
+
+ if ((isWidescreen != NULL) && (!strcmp(isWidescreen, "Yes")))
+ {
+ logger->log("Command", Log::DEBUG, "Setting 16x9");
+
+ int a = video->setAspectRatio(Video::ASPECT16X9);
+ printf("success = %i\n", a);
+ video->reset();
+ }
+ else
+ {
+ //temp
+ logger->log("Command", Log::DEBUG, "Setting 4x3");
+ int a = video->setAspectRatio(Video::ASPECT4X3);
+ printf("success = %i\n", a);
+ video->reset();
+ }
+*/
+
+ // end of test area
+
}
else
{
void Command::processMessage(Message* m)
{
- Log::getInstance()->log("Command", Log::DEBUG, "processing message %i", m->message);
+ logger->log("Command", Log::DEBUG, "processing message %i", m->message);
switch(m->message)
{
{
VInfo* viewWait = new VInfo();
viewWait->setDimensions(200, 400);
- if (Osd::getInstance()->getScreenSize() == Osd::PAL)
+ if (Video::getInstance()->getFormat() == Video::PAL)
{
viewWait->setScreenPos(170, 200);
}
VInfo* viewWait = new VInfo();
viewWait->setDimensions(200, 400);
- if (Osd::getInstance()->getScreenSize() == Osd::PAL)
+ if (Video::getInstance()->getFormat() == Video::PAL)
{
viewWait->setScreenPos(170, 200);
}
if (success)
{
- Log::getInstance()->log("Command", Log::DEBUG, "Connected ok, doing login");
+ logger->log("Command", Log::DEBUG, "Connected ok, doing login");
success = vdr->doLogin();
if (success)
Video* video;
Audio* audio;
-int SCREENWIDTH = 0;
-int SCREENHEIGHT = 0;
-
int main(int argc, char** argv)
{
if ((argc > 1) && (!strcmp(argv[1], "-d"))) debugEnabled = 1;
shutdown(1);
}
- // Need to init SCREENWIDTH, SCREENHEIGHT and ready the pal/ntsc connection stuff immediately
- UCHAR videoFormat = 0;
- UCHAR videoConnection = 0;
+ UCHAR videoFormat = (UCHAR)mtd->getPALorNTSC();
+ if (videoFormat == Video::PAL) logger->log("Core", Log::INFO, "Read from MTD: PAL 720x576");
+ 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");
- short mtdVideoMode = mtd->getVideoMode();
- if (mtdVideoMode == 0)
- {
- SCREENWIDTH = 720;
- SCREENHEIGHT = 480;
- videoFormat = Video::NTSC;
- videoConnection = Video::COMPOSITE;
- logger->log("Core", Log::INFO, "Read from MTD: NTSC 720x480 composite");
- }
- else if (mtdVideoMode == 1)
- {
- SCREENWIDTH = 720;
- SCREENHEIGHT = 576;
- videoFormat = Video::PAL;
- videoConnection = Video::SCART;
- logger->log("Core", Log::INFO, "Read from MTD: PAL 720x576 RGB");
- }
- else if (mtdVideoMode == 2)
- {
- SCREENWIDTH = 720;
- SCREENHEIGHT = 576;
- videoFormat = Video::PAL;
- videoConnection = Video::COMPOSITE;
- logger->log("Core", Log::INFO, "Read from MTD: PAL 720x576 composite");
- }
- else
- {
- // ?
-
- SCREENWIDTH = 720;
- SCREENHEIGHT = 480;
- videoFormat = Video::NTSC;
- videoConnection = Video::COMPOSITE;
- logger->log("Core", Log::INFO, "MTD gave us no help. Guessing NTSC.");
- }
-
- // temp hack - simulate ntsc on pal
-// SCREENHEIGHT = 480;
-// videoFormat = Video::NTSC;
-
- success = osd->init("/dev/stbgfx", SCREENHEIGHT, SCREENWIDTH, videoFormat, 1);
+ success = video->init(videoFormat);
if (success)
{
- logger->log("Core", Log::INFO, "OSD module initialised");
+ logger->log("Core", Log::INFO, "Video module initialised");
}
else
{
- logger->log("Core", Log::EMERG, "OSD module failed to initialise");
+ logger->log("Core", Log::EMERG, "Video module failed to initialise");
shutdown(1);
}
- success = vdr->init(3024);
+ success = osd->init("/dev/stbgfx", 1);
if (success)
{
- logger->log("Core", Log::INFO, "VDR module initialised");
+ logger->log("Core", Log::INFO, "OSD module initialised");
}
else
{
- logger->log("Core", Log::EMERG, "VDR module failed to initialise");
+ logger->log("Core", Log::EMERG, "OSD module failed to initialise");
shutdown(1);
}
- success = video->init(videoFormat, videoConnection, Video::ASPECT4X3, Video::NORMAL);
+ success = audio->init(Audio::MPEG2_PES);
if (success)
{
- logger->log("Core", Log::INFO, "Video module initialised");
+ logger->log("Core", Log::INFO, "Audio module initialised");
}
else
{
- logger->log("Core", Log::EMERG, "Video module failed to initialise");
+ logger->log("Core", Log::EMERG, "Audio module failed to initialise");
shutdown(1);
}
- success = audio->init(Audio::MPEG2_PES);
+ success = viewman->init();
if (success)
{
- logger->log("Core", Log::INFO, "Audio module initialised");
+ logger->log("Core", Log::INFO, "ViewMan module initialised");
}
else
{
- logger->log("Core", Log::EMERG, "Audio module failed to initialise");
+ logger->log("Core", Log::EMERG, "ViewMan module failed to initialise");
shutdown(1);
}
- success = viewman->init();
+ success = vdr->init(3024);
if (success)
{
- logger->log("Core", Log::INFO, "ViewMan module initialised");
+ logger->log("Core", Log::INFO, "VDR module initialised");
}
else
{
- logger->log("Core", Log::EMERG, "ViewMan module failed to initialise");
+ logger->log("Core", Log::EMERG, "VDR module failed to initialise");
shutdown(1);
}
logger->log("Core", Log::NOTICE, "Command module shut down");
}
+ if (vdr)
+ {
+ vdr->shutdown();
+ delete vdr;
+ logger->log("Core", Log::NOTICE, "VDR module shut down");
+ }
+
if (viewman)
{
viewman->shutdown();
logger->log("Core", Log::NOTICE, "ViewMan module shut down");
}
+ if (osd)
+ {
+ osd->shutdown();
+ delete osd;
+ logger->log("Core", Log::NOTICE, "OSD module shut down");
+ }
+
if (audio)
{
audio->shutdown();
logger->log("Core", Log::NOTICE, "Video module shut down");
}
- if (vdr)
- {
- vdr->shutdown();
- delete vdr;
- logger->log("Core", Log::NOTICE, "VDR module shut down");
- }
-
- if (osd)
- {
- osd->shutdown();
- delete osd;
- logger->log("Core", Log::NOTICE, "OSD module shut down");
- }
-
if (mtd)
{
mtd->shutdown();
return 1;
}
-short Mtd::getVideoMode()
+short Mtd::getPALorNTSC()
{
return data[2119];
}
{
Log* logger = Log::getInstance();
- logger->log("MTD", Log::DEBUG, "Mode: %i", getVideoMode());
+ logger->log("MTD", Log::DEBUG, "Mode: %i", getPALorNTSC());
logger->log("MTD", Log::DEBUG, "Aspect: %i", getAspect());
logger->log("MTD", Log::DEBUG, "Flicker: %i", getFlicker());
logger->log("MTD", Log::DEBUG, "Bootlogo output: %i", getBootLogoOutput());
int init(char* device);
int shutdown();
- short getVideoMode();
+ short getPALorNTSC();
short getAspect();
short getFlicker();
short getBootLogoOutput();
return fdOsd;
}
-int Osd::getScreenHeight()
-{
- return height;
-}
-
-int Osd::getScreenWidth()
-{
- return width;
-}
-
-int Osd::getScreenSize()
-{
- return screenSize;
-}
-
-int Osd::init(char* device, int height, int width, UCHAR tscreenSize, int doubleBuffering)
+int Osd::init(char* device, int doubleBuffering)
{
if (initted) return 0;
initted = 1; // must set this here or create surface won't work
- this->height = height;
- this->width = width;
- screenSize = tscreenSize;
-
Surface::initConversionTables();
+ Video* video = Video::getInstance();
+
screen = new Surface(fdOsd, Surface::SCREEN);
- screen->create(height, width);
+ screen->create(video->getScreenHeight(), video->getScreenWidth());
screen->display();
if (doubleBuffering)
{
buffer = new Surface(fdOsd, Surface::BUFFER);
- buffer->create(height, width);
+ buffer->create(video->getScreenHeight(), video->getScreenWidth());
}
else
{
#include "defines.h"
#include "log.h"
#include "surface.h"
+#include "video.h"
class Osd
{
~Osd();
static Osd* getInstance();
- int init(char* device, int height, int width, UCHAR tscreenSize, int doubleBuffering);
+ int init(char* device, int doubleBuffering);
int shutdown();
int getFD();
- int getScreenHeight();
- int getScreenWidth();
- int getScreenSize();
void screenShot(char* fileName);
- // Video formats - AV_SET_VID_DISP_FMT // here, video, everywhere!
- const static UCHAR NTSC = 0;
- const static UCHAR PAL = 1;
-
private:
static Osd* instance;
int initted;
Surface* buffer;
int fdOsd;
- int width;
- int height;
UCHAR screenSize;
};
{
Log::getInstance()->log("Player", Log::DEBUG, "PLAYER TEST");
-// video->test();
+/*
-// static int flipflop = 0;
+// video->test();
-// if (flipflop) video->setAspectRatio(Video::ASPECT16X9);
-// else video->setAspectRatio(Video::ASPECT4X3);
+ static int flipflop = 0;
-// flipflop = !flipflop;
+ int a;
+ if (flipflop) a = video->setAspectRatio(Video::ASPECT16X9);
+ else a = video->setAspectRatio(Video::ASPECT4X3);
+ flipflop = !flipflop;
+ printf("A = %i\n", a);
+*/
}
void Player::test2()
VChannelList::VChannelList(ULONG type)
{
- if (Osd::getInstance()->getScreenSize() == Osd::PAL)
+ if (Video::getInstance()->getFormat() == Video::PAL)
{
setScreenPos(80, 70);
}
#include "vvideolive.h"
#include "vradiolive.h"
#include "colour.h"
+#include "video.h"
class VChannelList : public View
{
connection = 0;
aspectRatio = 0;
mode = 0;
+
+ screenWidth = 0;
+ screenHeight = 0;
}
Video::~Video()
return instance;
}
-int Video::init(UCHAR format, UCHAR connection, UCHAR aspectRatio, UCHAR mode)
+int Video::init(UCHAR tformat)
{
if (initted) return 0;
initted = 1;
-// if ((fdVideo = open("/dev/vdec_dev", O_RDWR | O_NONBLOCK)) < 0) return 0;
if ((fdVideo = open("/dev/vdec_dev", O_WRONLY)) < 0) return 0;
- this->format = format;
- this->connection = connection;
- this->aspectRatio = aspectRatio;
- this->mode = mode;
-
- if (!initAllParams())
- {
- shutdown();
- return 0;
- }
+ if (!setFormat(tformat)) { shutdown(); return 0; }
+ if (!setConnection(COMPOSITERGB)) { shutdown(); return 0; }
+ if (!setAspectRatio(ASPECT4X3)) { shutdown(); return 0; }
+ if (!setMode(NORMAL)) { shutdown(); return 0; }
+ if (!setSource()) { shutdown(); return 0; }
+ if (!attachFrameBuffer()) { shutdown(); return 0; }
- attachFrameBuffer();
stop();
return 1;
}
-int Video::initAllParams()
-{
- return (setFormat(format) && setConnection(connection) &&
- setAspectRatio(aspectRatio) && setMode(mode) && setSource());
-}
-
int Video::shutdown()
{
if (!initted) return 0;
return 1;//write(fdVideo, buf, len);
}
-int Video::setFormat(UCHAR format)
+int Video::checkSCART()
+{
+ // Returns 3 for SCART Composite out
+ // Returns 3 for SCART S-Video out
+ // Returns 2 for SCART RGB out
+ // Returns 3 for SCART not plugged in
+
+ // So, as you can have RGB and composite out simultaneously,
+ // and it can't detect S-Video, what is the point of this?
+
+ int scart;
+ if (ioctl(fdVideo, AV_CHK_SCART, &scart) != 0) return -10;
+
+ return scart;
+}
+
+int Video::setFormat(UCHAR tformat)
{
if (!initted) return 0;
- if ((format != PAL) && (format != NTSC)) return 0;
+ if ((tformat != PAL) && (tformat != NTSC)) return 0;
+ format = tformat;
if (ioctl(fdVideo, AV_SET_VID_DISP_FMT, format) != 0) return 0;
- this->format = format;
+
+ if (format == NTSC)
+ {
+ screenWidth = 720;
+ screenHeight = 480;
+ }
+ if (format == PAL)
+ {
+ screenWidth = 720;
+ screenHeight = 576;
+ }
+
return 1;
}
-int Video::setConnection(UCHAR connection)
+int Video::setConnection(UCHAR tconnection)
{
if (!initted) return 0;
- if ((connection != SCART) && (connection != COMPOSITE) && (connection != SVIDEO)) return 0;
+ if ((tconnection != COMPOSITERGB) && (tconnection != SVIDEO)) return 0;
+ connection = tconnection;
if (ioctl(fdVideo, AV_SET_VID_OUTPUT, connection) != 0) return 0;
- this->connection = connection;
return 1;
}
-int Video::setAspectRatio(UCHAR aspectRatio)
+int Video::setAspectRatio(UCHAR taspectRatio)
{
if (!initted) return 0;
- if ((aspectRatio != ASPECT4X3) && (aspectRatio != ASPECT16X9)) return 0;
+ if ((taspectRatio != ASPECT4X3) && (taspectRatio != ASPECT16X9)) return 0;
+ aspectRatio = taspectRatio;
if (ioctl(fdVideo, AV_SET_VID_RATIO, aspectRatio) != 0) return 0;
- this->aspectRatio = aspectRatio;
return 1;
}
-int Video::setMode(UCHAR mode)
+int Video::setMode(UCHAR tmode)
{
if (!initted) return 0;
- if ((mode != NORMAL) && (mode != LETTERBOX) && (mode != UNKNOWN2) && (mode != QUARTER) && (mode != EIGHTH)
- && (mode != ZOOM) && (mode != UNKNOWN6)) return 0;
+ if ((tmode != NORMAL) && (tmode != LETTERBOX) && (tmode != UNKNOWN2) && (tmode != QUARTER) && (tmode != EIGHTH)
+ && (tmode != ZOOM) && (tmode != UNKNOWN6)) return 0;
+ mode = tmode;
// mode = LETTERBOX;
if (ioctl(fdVideo, AV_SET_VID_MODE, mode) != 0) return 0;
- this->mode = mode;
return 1;
}
return fdVideo;
}
+
+UCHAR Video::getFormat()
+{
+ return format;
+}
+
+UINT Video::getScreenWidth()
+{
+ return screenWidth;
+}
+
+UINT Video::getScreenHeight()
+{
+ return screenHeight;
+}
~Video();
static Video* getInstance();
- int init(UCHAR format, UCHAR connection, UCHAR aspectRatio, UCHAR mode);
+ int init(UCHAR format);
int shutdown();
// Video formats - AV_SET_VID_DISP_FMT
const static UCHAR PAL = 1;
// Video connections - AV_SET_VID_OUTPUT
- const static UCHAR SCART = 0;
- const static UCHAR COMPOSITE = 1;
+ const static UCHAR COMPOSITERGB = 1;
const static UCHAR SVIDEO = 2;
// Video aspect ratios - AV_SET_VID_RATIO
int write(char *buf, int len);
int getFD();
+ UCHAR getFormat();
+ UINT getScreenWidth();
+ UINT getScreenHeight();
private:
+ int checkSCART();
+
static Video* instance;
int initted;
- int initAllParams();
-
int fdVideo;
UCHAR format;
UCHAR connection;
UCHAR aspectRatio;
UCHAR mode;
+
+ UINT screenWidth;
+ UINT screenHeight;
};
#endif
VLiveBanner::VLiveBanner()
{
- if (Osd::getInstance()->getScreenSize() == Osd::PAL)
+ if (Video::getInstance()->getFormat() == Video::PAL)
{
setScreenPos(130, 370);
}
#include "vdr.h"
#include "wselectlist.h"
#include "colour.h"
-#include "osd.h"
+#include "video.h"
class VLiveBanner : public View
{
{
isMuted = Audio::getInstance()->toggleUserMute();
- if (Osd::getInstance()->getScreenSize() == Osd::PAL)
+ if (Video::getInstance()->getFormat() == Video::PAL)
{
setScreenPos(600, 500);
}
#include "audio.h"
#include "wsymbol.h"
#include "colour.h"
-#include "osd.h"
+#include "video.h"
class VMute : public View
{
VRecordingList::VRecordingList()
{
- if (Osd::getInstance()->getScreenSize() == Osd::PAL)
+ if (Video::getInstance()->getFormat() == Video::PAL)
{
setScreenPos(80, 70);
}
#include "vdr.h"
#include "vvideorec.h"
#include "colour.h"
+#include "video.h"
class VRecordingList : public View
{
{
rec = NULL;
- if (Osd::getInstance()->getScreenSize() == Osd::PAL)
+ if (Video::getInstance()->getFormat() == Video::PAL)
{
setScreenPos(260, 190);
}
vi->setExitable();
if (summary) vi->setMainText(summary);
else vi->setMainText("Summary unavailable");
- if (Osd::getInstance()->getScreenSize() == Osd::PAL)
+ if (Video::getInstance()->getFormat() == Video::PAL)
{
vi->setScreenPos(120, 130);
}
v->setTitleText("Delete recording");
v->setMainText("Are you sure you want to delete this recording?");
v->setDefault(VQuestion::NO);
- if (Osd::getInstance()->getScreenSize() == Osd::PAL)
+ if (Video::getInstance()->getFormat() == Video::PAL)
{
v->setScreenPos(230, 160);
}
#include "vinfo.h"
#include "vdr.h"
#include "colour.h"
-#include "osd.h"
+#include "video.h"
class VRecordingList;
// anyway, now it doesn't use a object wide reference.
selectServer = tselectServer;
- if (Osd::getInstance()->getScreenSize() == Osd::PAL)
+ if (Video::getInstance()->getFormat() == Video::PAL)
{
setScreenPos(220, 200);
}
#include "remote.h"
#include "wselectlist.h"
#include "colour.h"
-#include "osd.h"
+#include "video.h"
class VServerSelect : public View
{
chanList = tchanList;
currentChannel = 0;
- setDimensions(Osd::getInstance()->getScreenHeight(), Osd::getInstance()->getScreenWidth());
+ Video* video = Video::getInstance();
+ setDimensions(video->getScreenHeight(), video->getScreenWidth());
Colour transparent(0, 0, 0, 0);
setBackgroundColour(transparent);
}
myRec = rec;
- setDimensions(Osd::getInstance()->getScreenHeight(), Osd::getInstance()->getScreenWidth());
+ Video* video = Video::getInstance();
+ setDimensions(video->getScreenHeight(), video->getScreenWidth());
Colour transparent(0, 0, 0, 0);
setBackgroundColour(transparent);
}
// return 2;
// }
+ case Remote::RED:
+ {
+ player->test();
+ return 2;
+ }
+
case Remote::ZERO: player->jumpToPercent(0); return 2;
case Remote::ONE: player->jumpToPercent(10); return 2;
case Remote::TWO: player->jumpToPercent(20); return 2;
{
displayVolume = Audio::getInstance()->getVolume();
- if (Osd::getInstance()->getScreenSize() == Osd::PAL)
+ if (Video::getInstance()->getFormat() == Video::PAL)
{
setScreenPos(100, 499);
}
#include "audio.h"
#include "wsymbol.h"
#include "colour.h"
-#include "osd.h"
+#include "video.h"
class VVolume : public View
{
{
jpeg.init(name);
- Osd* o = Osd::getInstance();
- setDimensions(o->getScreenHeight(), o->getScreenWidth());
+ Video* video = Video::getInstance();
+ setDimensions(video->getScreenHeight(), video->getScreenWidth());
// Now override the surface pointer found in Box to a seperate wallpaper surface
// but only for the wjpeg, not for this object
- wallpaperSurface = new Surface(o->getFD(), 0);
+ wallpaperSurface = new Surface(Osd::getInstance()->getFD(), 0);
wallpaperSurface->create(height, width);
jpeg.overrideSurface(wallpaperSurface);
#include "osd.h"
#include "surface.h"
+#include "video.h"
class VWallpaper : public View
{
{
setDimensions(190, 460);
- if (Osd::getInstance()->getScreenSize() == Osd::PAL)
+ if (Video::getInstance()->getFormat() == Video::PAL)
{
setScreenPos(140, 170);
}
VInfo* viewWait = new VInfo();
viewWait->setDimensions(190, 460);
- if (Osd::getInstance()->getScreenSize() == Osd::PAL)
+ if (Video::getInstance()->getFormat() == Video::PAL)
{
viewWait->setScreenPos(140, 170);
}
#include "command.h"
#include "message.h"
#include "colour.h"
-#include "osd.h"
+#include "video.h"
class VWelcome : public View
{