#include "vdr.h"
#include "log.h"
-#include "command.h"
+#include "control.h"
Channel::Channel()
{
VDR::getInstance()->getChannelPids(this); // FIXME sort out this system
if (!VDR::getInstance()->isConnected())
{
- Command::getInstance()->connectionLost();
+ Control::getInstance()->connectionLost();
return;
}
+++ /dev/null
-/*
- Copyright 2004-2020 Chris Tallon
-
- This file is part of VOMP.
-
- VOMP is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- VOMP is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with VOMP. If not, see <https://www.gnu.org/licenses/>.
-*/
-
-// FIXME rename to Control and move stuff from main to here
-
-
-#include "command.h"
-
-#ifdef WIN32
-#include "inputwin.h"
-#endif
-
-#ifdef __ANDROID__
-#include "inputandroid.h"
-#endif
-
-#include "led.h"
-#include "video.h"
-#include "audio.h"
-#include "vdr.h"
-#include "vvolume.h"
-#include "vserverselect.h"
-#include "vwelcome.h"
-#include "vmute.h"
-#include "colour.h"
-#include "osd.h"
-#include "i18n.h"
-#include "timers.h"
-#include "wol.h"
-#include "vconnect.h"
-#include "message.h"
-#include "inputman.h"
-#include "input.h"
-#include "vinfo.h"
-#include "boxx.h"
-#include "boxstack.h"
-#include "log.h"
-#include "vsleeptimer.h"
-#include "wjpeg.h"
-#include "osdvector.h"
-
-
-Command* Command::instance = NULL;
-
-Command::Command()
-{
- if (instance) return;
- instance = this;
-}
-
-Command::~Command()
-{
- flushMessageQueue();
- instance = NULL;
-}
-
-Command* Command::getInstance()
-{
- return instance;
-}
-
-int Command::init(bool tcrashed)
-{
- if (initted) return 0;
- initted = true;
- crashed = tcrashed;
-
- logger = Log::getInstance();
- boxstack = BoxStack::getInstance();
- inputMan = InputMan::getInstance();
-
- if (!logger || !boxstack || !inputMan)
- {
- initted = false;
- return 0;
- }
-
- SkinFactory::InitSkin(0);
-
- return 1;
-}
-
-int Command::shutdown()
-{
- if (!initted) return 0;
- initted = false;
- return 1;
-}
-
-void Command::stop()
-{
- logger->log("Command", Log::NOTICE, "Request stop");
-
- Message* m = new Message(); // break master loop
- m->message = Message::SHUTDOWN;
- m->p_to = Message::CONTROL;
- postMessage(m);
-}
-
-void Command::doWallpaper()
-{
- Video* video = Video::getInstance();
-
- // Blue background
- Boxx* bbg = new Boxx();
- bbg->setSize(video->getScreenWidth(), video->getScreenHeight());
- bbg->createBuffer();
- bbg->fillColour(DrawStyle::WALLPAPER);
- boxstack->add(bbg);
- boxstack->update(bbg);
- boxstack->remove(bbg);
-
- // Wallpaper
- wallpaper = new Boxx();
- wallpaper->setSize(video->getScreenWidth(), video->getScreenHeight());
- wallpaper->createBuffer();
- wallpaper->setBackgroundColour(DrawStyle::WALLPAPER);
-
- wallpaper_pict = new WJpegTYPE();
- wallpaper_pict->setSize(video->getScreenWidth(), video->getScreenHeight());
-
- if (video->getFormat() == Video::PAL)
- {
- logger->log("Command", Log::DEBUG, "PAL wallpaper selected");
-#ifndef _MIPS_ARCH
- wallpaper_pict->init("/wallpaperPAL.jpg");
-#else
- wallpaper_pict->init("wallpaperPAL.jpg");
-#endif
- }
- else
- {
- logger->log("Command", Log::DEBUG, "NTSC wallpaper selected");
- wallpaper_pict->init("/wallpaperNTSC.jpg");
- }
-
- if (DrawStyle::WALLPAPER.alpha)
- wallpaper_pict->setVisible(true);
- else
- wallpaper_pict->setVisible(false);
-
- wallpaper->add(wallpaper_pict);
- wallpaper->draw();
-
- boxstack->add(wallpaper);
- boxstack->update(wallpaper);
-
- OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
- if (osdv) osdv->updateBackgroundColor(DrawStyle::WALLPAPER);
-}
-
-void Command::run()
-{
- if (!initted) return;
- irun = true;
-
- // just in case
- Video::getInstance()->signalOn();
- Led::getInstance()->on();
-
- doWallpaper();
-
- if (crashed)
- {
- buildCrashedBox();
- }
- else
- {
- VConnect* vconnect = new VConnect();
- boxstack->add(vconnect);
- vconnect->run();
- }
-
-
- // FIXME Input::NA_SIGNAL is possibly obsolete now
-
- std::unique_lock<std::mutex> lockWrapper(messageQueueMutex); // locks. unlocks on out-of-scope
-
- inputMan->start();
-
- while(irun)
- {
- messageQueueCond.wait(lockWrapper, [&] { return !irun || !messages.empty(); });
- logger->log("Command", Log::DEBUG, "woke");
-
- if (!irun) break;
-
- while(!messages.empty())
- {
- Message* m = messages.front();
- messages.pop_front();
-
- lockWrapper.unlock();
-
- processMessage(m);
- delete m;
-
- lockWrapper.lock();
- }
- }
-
- inputMan->stop();
-
- boxstack->removeAllExceptWallpaper();
- boxstack->remove(wallpaper);
- delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL;
-}
-
-void Command::processMessage(Message* m)
-{
- // FIXME - a slight modification - how if messagereceivers were to register
- // themselves as receivers to avoid the calling-a-deleted-object problem
- // then only deliver/register/unregister would have to be protected
-
- logger->log("Command", Log::DEBUG, "processing message %i", m->message);
-
-
- if ((m->p_to == Message::CONTROL) || (m->to == this)) // Maybe don't check m->to here? Always use predefined?
- {
- switch(m->message)
- {
- case Message::SHUTDOWN:
- {
- irun = false;
- break;
- }
- // << FIXME OBSELETE
- case Message::STOP_PLAYBACK:
- {
- handleCommand(Input::STOP); // an odd way of doing it, but so simple
- break;
- }
- // Also connection_lost comes from player - anywhere else?
- // FIXME OBSELETE >>
-
-
- case Message::VDR_CONNECTED:
- {
- doJustConnected(static_cast<VConnect*>(m->from));
- break;
- }
- case Message::SCREENSHOT:
- {
- logger->log("Osd", Log::NOTICE, "Screenshot Message arrived");
- Osd::getInstance()->screenShot("out.jpg");
- break;
- }
- case Message::CONNECTION_LOST:
- {
- doFromTheTop(true);
- break;
- }
- case Message::INPUT_EVENT:
- {
- logger->log("Command", Log::NOTICE, "INPUT_EVENT %i", m->parameter);
-
- handleCommand(m->parameter);
- break;
- }
- case Message::CHANGE_LANGUAGE:
- {
- boxstack->removeAllExceptWallpaper();
- boxstack->update(wallpaper);
- I18n::initialize();
- if (!VDR::getInstance()->isConnected()) { connectionLost(); break; }
- VWelcome* vw = new VWelcome();
- vw->draw();
- boxstack->add(vw);
- boxstack->update(vw);
- break;
- }
- case Message::LAST_VIEW_CLOSE:
- {
- // Shouldn't be done like this. Some generic message pass back from vinfo perhaps
- if (crashed)
- {
- crashed = false;
- doFromTheTop(false);
- }
-
-// VWelcome* vw = new VWelcome();
-// vw->draw();
-// boxstack->add(vw);
-// boxstack->update(vw);
-
- break;
- }
- case Message::NEW_PICTURE:
- {
- //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE");
- OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
- if (osdv) osdv->informPicture(m->tag, reinterpret_cast<ImageIndex>(m->data));
- break;
- }
- case Message::NEW_PICTURE_STATIC:
- {
- //Log::getInstance()->log("Command", Log::DEBUG, "TVMedia NEW_PICTURE %x %x",m->tag,m->parameter);
- OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
- if (osdv) osdv->informPicture(static_cast<unsigned long long>(m->tag) << 32LL, reinterpret_cast<ImageIndex>(m->data));
- break;
- }
- }
- }
- else
- {
- /* FIXME
-
- Instead of sending through the boxstack, implement a more generic MessageReceiver interface
- and have potential receivers register with something
- When a message needs to be delivered, check if the receiver is still registered, if so, deliver the message
- This could all be done using the existing big command mutex to keep it simple
- */
-
- logger->log("Command", Log::DEBUG, "Sending message to boxstack");
- boxstack->processMessage(m);
- }
-}
-
-void Command::handleCommand(int button)
-{
- if (isStandby && (button != Input::POWER)
- && (button != Input::POWERON)
- && (button != Input::POWEROFF)) return;
-
- if (!connLost && boxstack->handleCommand(button)) return; // don't send to boxstack if connLost
-
- // command was not handled
-
- switch(button)
- {
- case Input::VOLUMEUP:
- case Input::VOLUMEDOWN:
- {
- if (inputMan->handlesVolume()) // CEC volume handler?
- {
- if (button == Input::VOLUMEDOWN)
- inputMan->volumeDown();
- else
- inputMan->volumeUp();
- }
- else
- {
- VVolume* v = new VVolume();
- boxstack->add(v);
- v->handleCommand(button); // this will draw+show
- }
- return;
- }
- case Input::MUTE:
- {
- if (inputMan->handlesVolume())
- {
- inputMan->volumeMute();
- }
- else
- {
- VMute* v = new VMute();
- v->draw();
- boxstack->add(v);
- boxstack->update(v);
- }
- return;
- }
- case Input::POWER:
- {
- doStandby();
- return;
- }
- case Input::POWERON:
- {
- doPowerOn();
- return;
- }
- case Input::POWEROFF:
- {
- doPowerOff();
- return;
- }
- case Input::OK:
- {
- // FIXME
- if (!connLost) return; // if connLost, handle Input::OK
- doFromTheTop(false);
- return;
- }
- case Input::GO:
- {
- VSleeptimer* sleep = new VSleeptimer();
- boxstack->add(sleep);
- sleep->handleCommand(button); // this will draw+show
- return;
- }
- }
-}
-
-/*
-void Command::sig1()
-{
-#ifdef DEV
- Message* m = new Message(); // break into master mutex
- m->message = Message::SCREENSHOT;
- m->to = this;
- postMessage(m);
-#endif
-}
-*/
-
-void Command::doStandby()
-{
- if (isStandby)
- {
- doPowerOn();
- }
- else
- {
- doPowerOff();
- }
-}
-
-
-void Command::doPowerOn()
-{
- if (isStandby)
- {
- Video::getInstance()->signalOn();
- Led::getInstance()->on();
- InputMan::getInstance()->changePowerState(true);
- isStandby = false;
-
- VConnect* vconnect = new VConnect();
- boxstack->add(vconnect);
- vconnect->run();
- }
-}
-
-void Command::doPowerOff()
-{
- if (!isStandby)
- {
- VDR::getInstance()->shutdownVDR();
- boxstack->removeAllExceptWallpaper();
- Video::getInstance()->signalOff();
- boxstack->update(wallpaper);
-
- VDR::getInstance()->configSave("General", "Last Power State", "Off");
- logger->unsetExternLogger();
- VDR::getInstance()->disconnect();
- Led::getInstance()->off();
- InputMan::getInstance()->changePowerState(false);
- isStandby = true;
- Sleeptimer::getInstance()->shutdown();
- }
-}
-
-void Command::doFromTheTop(bool which)
-{
- if (isStandby) return;
- if (which)
- {
- if (connLost)
- {
- logger->log("Command", Log::NOTICE, "Connection lost dialog already present");
- return;
- }
-
- logger->log("Command", Log::NOTICE, "Doing connection lost dialog");
- connLost = new VInfo();
- connLost->setSize(360, 200);
- connLost->createBuffer();
- if (Video::getInstance()->getFormat() == Video::PAL)
- connLost->setPosition(190, 170);
- else
- connLost->setPosition(180, 120);
- connLost->setOneLiner(tr("Connection lost"));
- connLost->setDropThrough();
- connLost->setBorderOn(1);
- connLost->setTitleBarColour(DrawStyle::DANGER);
- connLost->okButton();
- connLost->draw();
- boxstack->add(connLost);
- boxstack->update(connLost);
-
- clearMQInputEvents();
- }
- else
- {
- logger->unsetExternLogger();
- VDR::getInstance()->disconnect();
- boxstack->removeAllExceptWallpaper();
- boxstack->update(wallpaper);
- connLost = NULL;
-
- flushMessageQueue();
-
- // at this point, everything should be reset to first-go
-
- VConnect* vconnect = new VConnect();
- boxstack->add(vconnect);
- vconnect->run();
- }
-}
-
-void Command::clearMQInputEvents()
-{
- std::lock_guard<std::mutex> lg(messageQueueMutex); // Get the lock
-
- MQueueI i = messages.begin();
- while(i != messages.end())
- {
- Message* m = *i;
- if (m->message == Message::INPUT_EVENT)
- {
- delete m;
- i = messages.erase(i);
- }
- else
- {
- ++i;
- }
- }
-}
-
-void Command::doReboot()
-{
-
- logger->unsetExternLogger();
- VDR::getInstance()->disconnect();
- // just kill it...
- logger->log("Command", Log::NOTICE, "Reboot");
-#ifndef WIN32
-#ifndef VOMP_HAS_EXIT
- // some plattforms, want a proper deinitialisation of their hardware before reboot
- Osd::getInstance()->shutdown();
- Audio::getInstance()->shutdown();
- Video::getInstance()->shutdown();
- InputMan::getInstance()->shutdown();
-
- reboot(LINUX_REBOOT_CMD_RESTART);
- // if reboot is not allowed -> stop
- stop();
-
-
-#else
- stop();
-
-#ifdef __ANDROID__
- exit(0);
-#endif
-
-#endif
-#endif //Would we support this on windows?
-}
-
-void Command::connectionLost()
-{
- logger->unsetExternLogger();
- Message* m = new Message(); // break into master mutex
- m->message = Message::CONNECTION_LOST;
- m->p_to = Message::CONTROL;
- postMessage(m);
-}
-
-void Command::buildCrashedBox()
-{
- VInfo* crash = new VInfo();
- crash->setSize(360, 250);
- crash->createBuffer();
- if (Video::getInstance()->getFormat() == Video::PAL)
- crash->setPosition(190, 146);
- else
- crash->setPosition(180, 96);
- crash->setMainText("Oops, vomp crashed.. :(\nPlease report this crash to the author, with as much detail as possible about what you were doing at the time that might have caused the crash.");
- crash->setBorderOn(1);
- crash->setTitleBarColour(DrawStyle::DANGER);
- crash->okButton();
- crash->setExitable();
- crash->draw();
- boxstack->add(crash);
- boxstack->update(crash);
-}
-
-int Command::getLangPref(bool subtitle, const char* langcode)
-{
- std::vector<struct ASLPref>::iterator itty=langcodes.begin();
- char templangcode[4];
- templangcode[0] = langcode[0];
- templangcode[1] = langcode[1];
- templangcode[2] = langcode[2];
- templangcode[3] = '\0';
- int langpos = 0;
- while (itty != langcodes.end())
- {
- size_t pos = (*itty).langcode.find(templangcode);
- if (pos != std::string::npos)
- {
- //vector<struct ASLPref>::iterator itty2=langcodes.begin();
- for (unsigned int i = 0; i < langcodes.size(); i++)
- {
- int pref = 0;
- if (subtitle)
- pref = langcodes[i].subtitlepref;
- else
- pref = langcodes[i].audiopref;
- if (pref < 0) break;
-
- if (subtitle)
- {
- if (langcodes[i].subtitlepref==langpos) return i;
- }
- else
- {
- if (langcodes[i].audiopref==langpos) return i;
- }
- }
- break;
- }
- itty++;
- langpos++;
- }
- return langcodes.size(); //neutral
-}
-
-void Command::doJustConnected(VConnect* vconnect)
-{
- I18n::initialize();
- if (!VDR::getInstance()->isConnected()) { connectionLost(); return; }
- logger->log("Command", Log::INFO, "Entering doJustConnected");
-
- Video* video = Video::getInstance();
- Audio* audio = Audio::getInstance();
- boxstack->remove(vconnect);
-
- VInfo* vi = new VInfo();
- vi->setSize(400, 200);
- vi->createBuffer();
- if (video->getFormat() == Video::PAL)
- vi->setPosition(170, 200);
- else
- vi->setPosition(160, 150);
- vi->setOneLiner(tr("Connected, loading config"));
- vi->draw();
- boxstack->add(vi);
- boxstack->update(vi);
-
- // FIXME make config system
-
- VDR* vdr = VDR::getInstance();
- char* config;
-
- // See if we're supposed to do network logging
- config = vdr->configLoad("Advanced", "Network logging");
- if (config && !STRCASECMP(config, "On"))
- {
- logger->log("Command", Log::INFO, "Turning on network logging");
- logger->setExternLogger(vdr);
- }
- else
- {
- logger->unsetExternLogger();
- logger->log("Command", Log::INFO, "Turned off network logging");
- }
- if (config) delete[] config;
-
- config = vdr->configLoad("Advanced", "Skin Name");
- if (config)
- {
- const char **skinnames=SkinFactory::getSkinNames();
- for (int i=0;i<SkinFactory::getNumberofSkins();i++)
- {
- if (!STRCASECMP(config, skinnames[i]))
- {
- SkinFactory::InitSkin(i);
- break;
- }
- }
- delete[] config;
-
- if (wallpaper && wallpaper_pict)
- {
- if (DrawStyle::WALLPAPER.alpha)
- wallpaper_pict->setVisible(true);
- else
- wallpaper_pict->setVisible(false);
-
- wallpaper->draw();
- boxstack->update(wallpaper);
- }
- }
- else
- {
- SkinFactory::InitSkin(0);
- }
-
- // 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::PAL))
- || (!strcmp(config, "NTSC") && (video->getFormat() != Video::NTSC))
- || (!strcmp(config, "PAL_M") && (video->getFormat() != Video::PAL_M))
- || (!strcmp(config, "NTSC_J") && (video->getFormat() != Video::NTSC_J))
- )
- {
- // Oh sheesh, need to switch format. Bye bye TV...
-
- // Take everything down
- boxstack->removeAllExceptWallpaper();
- boxstack->remove(wallpaper);
- delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL;
-
- Osd* osd = Osd::getInstance();
-#ifndef __ANDROID__
- osd->shutdown();
-#endif
- video->shutdown();
-
- inputMan->shutdown(); // need on raspberry shut not do any harm, hopefully
- inputMan->init(); // FIXME this breaks badly now
-
- // 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);
- } else if (!strcmp(config, "PAL_M"))
- {
- logger->log("Command", Log::DEBUG, "Switching to PAL_M");
- video->init(Video::PAL_M);
- } else if (!strcmp(config, "NTSC_J"))
- {
- logger->log("Command", Log::DEBUG, "Switching to NTSC_J");
- video->init(Video::NTSC_J);
- }
- delete[] config;
-
-#ifndef __ANDROID__
- //we do not init twice
- osd->init();
-#endif
-
- // Put the wallpaper back
- doWallpaper();
-
- // Re add the vinfo
- vi = new VInfo();
- vi->setSize(400, 200);
- vi->createBuffer();
- if (video->getFormat() == Video::PAL)
- vi->setPosition(170, 200);
- else
- vi->setPosition(160, 150);
-
- vi->setOneLiner(tr("Connected, loading config"));
- vi->draw();
- boxstack->add(vi);
- boxstack->update(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)
- {
- firstBoot = false;
-
- logger->log("Command", Log::DEBUG, "Load power after boot");
-
- config = vdr->configLoad("General", "Power After Boot");
-
- if (config)
- {
- if (!STRCASECMP(config, "On"))
- {
- logger->log("Command", Log::INFO, "Config says Power After Boot = On");
- }
- else if (!STRCASECMP(config, "Off"))
- {
- logger->log("Command", Log::INFO, "Config says Power After Boot = Off");
- doStandby();
- delete[] config;
- return; // quit here
- }
- else if (!STRCASECMP(config, "Last state"))
- {
- char* lastPowerState = vdr->configLoad("General", "Last Power State");
- if (lastPowerState)
- {
- if (!STRCASECMP(lastPowerState, "On"))
- {
- logger->log("Command", Log::INFO, "Config says Last Power State = On");
- }
- else if (!STRCASECMP(lastPowerState, "Off"))
- {
- logger->log("Command", Log::INFO, "Config says Last Power State = Off");
- doStandby();
- delete[] config;
- return; // quit here
- }
- else
- {
- logger->log("Command", Log::INFO, "Config General/Last Power State not understood");
- }
- }
- else
- {
- logger->log("Command", Log::INFO, "Config General/Last Power State not found");
- }
- }
- else
- {
- logger->log("Command", Log::INFO, "Config/Power After Boot not understood");
- }
- delete[] config;
- }
- else
- {
- logger->log("Command", Log::INFO, "Config General/Power After Boot not found");
- }
- }
-
-
- // Go S-Video if config says so
-
- config = vdr->configLoad("TV", "Connection");
-
- if (config)
- {
- if (!STRCASECMP(config, "S-Video"))
- {
- logger->log("Command", Log::INFO, "Switching to S-Video as Connection=%s", config);
- video->setConnection(Video::SVIDEO);
- } else if (!STRCASECMP(config, "HDMI"))
- {
- logger->log("Command", Log::INFO, "Switching to HDMI as Connection=%s", config);
- video->setConnection(Video::HDMI);
- } else if (!STRCASECMP(config, "HDMI3D"))
- {
- logger->log("Command", Log::INFO, "Switching to HDMI3D as Connection=%s", config);
- video->setConnection(Video::HDMI3D);
- }
- else
- {
- logger->log("Command", Log::INFO, "Switching to RGB/Composite as Connection=%s", config);
- video->setConnection(Video::COMPOSITERGB);
- }
- delete[] config;
- }
- else
- {
- logger->log("Command", Log::INFO, "Config TV/S-Video not found");
- }
-
- // Set to shutdown VDR if config says
-
- config = vdr->configLoad("General", "VDR shutdown");
- if (config)
- {
- if (!STRCASECMP(config, "On"))
- {
- logger->log("Command", Log::INFO, "Shutdown VDR when shutting down vomp");
- vdr->setVDRShutdown(true);
- }
- else if (!STRCASECMP(config, "Off"))
- {
- logger->log("Command", Log::INFO, "Shutdown only vomp");
- vdr->setVDRShutdown(false);
- }
- }
- else
- {
- logger->log("Command", Log::INFO, "Default shutdown only vomp");
- vdr->setVDRShutdown(false); // Default
- }
-
- // Get TV aspect ratio
-
- config = vdr->configLoad("TV", "Aspect");
- if (config)
- {
- if (!STRCASECMP(config, "16:9"))
- {
- logger->log("Command", Log::INFO, "/// Switching to TV aspect 16:9");
- video->setTVsize(Video::ASPECT16X9);
- }
- else
- {
- logger->log("Command", Log::INFO, "/// Switching to TV aspect 4:3");
- video->setTVsize(Video::ASPECT4X3);
- }
- delete[] config;
- }
- else
- {
- logger->log("Command", Log::INFO, "Config TV/Aspect type not found, going 4:3");
- video->setTVsize(Video::ASPECT4X3);
- }
-
- config = vdr->configLoad("TV", "Widemode");
- if (config)
- {
- if (!STRCASECMP(config, "Letterbox"))
- {
- logger->log("Command", Log::INFO, "Setting letterbox mode");
- video->setMode(Video::LETTERBOX);
- }
- else
- {
- logger->log("Command", Log::INFO, "Setting chop-sides mode");
- video->setMode(Video::NORMAL);
- }
- delete[] config;
- }
- else
- {
-#ifdef __ANDROID__
- logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting letterbox mode");
- video->setMode(Video::LETTERBOX);
-#else
- logger->log("Command", Log::INFO, "Config TV/Widemode not found, Setting chop-sides mode");
- video->setMode(Video::NORMAL);
-#endif
- }
-
- config = vdr->configLoad("Advanced", "TCP receive window");
- if (config)
- {
- size_t newTCPsize = atoi(config);
- delete[] config;
-
- logger->log("Command", Log::INFO, "Setting TCP window size %i", newTCPsize);
- vdr->setReceiveWindow(newTCPsize);
- }
- else
- {
- logger->log("Command", Log::INFO, "TCP window size not found, setting 2048");
- if (DEFAULT_TCP_WINDOWSIZE) vdr->setReceiveWindow(2048); // Default
- }
-
- config = vdr->configLoad("Advanced", "Font Name");
- if (config)
- {
- Osd::getInstance()->setFont(config);
- logger->log("Command", Log::INFO, "Setting Font to %s", config);
- delete[] config;
-
- }
-
-
- // Set recording list type
-
-#ifdef ADVANCED_MENUES
- config = vdr->configLoad("Advanced", "Menu type");
-
- if (config)
- {
- if (!STRCASECMP(config, "Advanced"))
- {
- logger->log("Command", Log::INFO, "Switching to Advanced menu");
- advMenus = true;
- }
- else
- {
- logger->log("Command", Log::INFO, "Switching to Classic menu");
- advMenus = false;
- }
- delete[] config;
- }
- else
- {
- logger->log("Command", Log::INFO, "Config General/menu type not found");
- advMenus = true;
- }
-#endif
-
- config = vdr->configLoad("Advanced", "Disable WOL");
- if (config)
- {
- if (!STRCASECMP(config, "Yes"))
- {
- logger->log("Command", Log::INFO, "Config says disable WOL");
- Wol::getInstance()->setEnabled(false);
- }
- else
- {
- logger->log("Command", Log::INFO, "Config says enable WOL");
- Wol::getInstance()->setEnabled(true);
- }
-
- delete[] config;
- }
- else
- {
- logger->log("Command", Log::INFO, "By default, enable WOL");
- Wol::getInstance()->setEnabled(true);
- }
- /* device dependend config */
- audio->loadOptionsFromServer(vdr);
- video->loadOptionsFromServer(vdr);
- inputMan->loadOptionsFromServer(vdr);
-
- video->executePendingModeChanges();
- // config done
-
- // Save power state = on
-
- vdr->configSave("General", "Last Power State", "On");
-
- // Make sure connection didn't die
- if (!vdr->isConnected())
- {
- Command::getInstance()->connectionLost();
- }
- else
- {
- boxstack->remove(vi);
-
- VWelcome* vw = new VWelcome();
- vw->draw();
- boxstack->add(vw);
- boxstack->update(vw);
-
- // Enter pre-keys here
-// handleCommand(Input::OK);
-// handleCommand(Input::THREE);
-// handleCommand(Input::SIX);
-// handleCommand(Input::OK);
-// handleCommand(Input::UP);
-// handleCommand(Input::PLAY);
-// handleCommand(Input::DOWN);
-// handleCommand(Input::DOWN);
-// handleCommand(Input::DOWN);
-// handleCommand(Input::RIGHT);
-// handleCommand(Input::RED);
- }
-}
+++ /dev/null
-/*
- Copyright 2004-2020 Chris Tallon
-
- This file is part of VOMP.
-
- VOMP is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- VOMP is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with VOMP. If not, see <https://www.gnu.org/licenses/>.
-*/
-
-#ifndef COMMAND_H
-#define COMMAND_H
-
-#ifndef WIN32
-#include <unistd.h> // for reboot
-#include <linux/reboot.h>
-#include <sys/reboot.h>
-#endif
-
-#include <time.h>
-#ifndef WIN32
-#include <pthread.h> // why?
-#endif
-
-#include <string>
-#include <vector>
-
-#include "defines.h"
-#include "messagequeue.h"
-
-class VConnect;
-class Message;
-class InputMan;
-class Boxx;
-class BoxStack;
-class Log;
-class VInfo;
-class WJpeg;
-
-struct ASLPref
-{
- std::string langcode;
- int audiopref;
- int subtitlepref;
-};
-
-typedef std::vector<struct ASLPref> ASLPrefList;
-
-class Command : public MessageQueue
-{
- public:
- Command();
- ~Command();
- static Command* getInstance();
-
- int init(bool crashed = false);
- int shutdown();
- void run();
- void stop();
- void doReboot();
- void connectionLost();
-
- void setAdvMenus(bool adv) { advMenus = adv; };
- bool isAdvMenus() { return advMenus; };
- int getLangPref(bool subtitle,const char* langcode);
- void setSubDefault(int subon) { subdefault = subon; };
- int getSubDefault() { return subdefault; };
- ASLPrefList &getASLList() { return langcodes; };
-
- private:
- void handleCommand(int);
- void doStandby();
- void doPowerOn();
- void doPowerOff();
- void doJustConnected(VConnect* vconnect);
- void doWallpaper();
- void doFromTheTop(bool which); // true - show vinfo,wait. false - del vinfo,restart
- void buildCrashedBox();
-// void sig1();
- void clearMQInputEvents();
-
- static Command* instance;
-
- Log* logger;
- BoxStack* boxstack;
- InputMan* inputMan;
-
- bool initted{};
- bool irun{};
- bool isStandby{};
- bool firstBoot{true};
- Boxx* wallpaper{};
- WJpeg* wallpaper_pict{};
- VInfo* connLost{};
- bool crashed{};
-
- bool advMenus{};
- ASLPrefList langcodes;
- int subdefault;
-
- void processMessage(Message* m);
-};
-
-#endif
--- /dev/null
+/*
+ Copyright 2004-2020 Chris Tallon
+
+ This file is part of VOMP.
+
+ VOMP is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ VOMP is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with VOMP. If not, see <https://www.gnu.org/licenses/>.
+*/
+
+// FIXME rename to Control and move stuff from main to here
+
+
+#include "control.h"
+
+#ifdef WIN32
+#include "inputwin.h"
+#endif
+
+#ifdef __ANDROID__
+#include "inputandroid.h"
+#endif
+
+#include "led.h"
+#include "video.h"
+#include "audio.h"
+#include "vdr.h"
+#include "vvolume.h"
+#include "vserverselect.h"
+#include "vwelcome.h"
+#include "vmute.h"
+#include "colour.h"
+#include "osd.h"
+#include "i18n.h"
+#include "timers.h"
+#include "wol.h"
+#include "vconnect.h"
+#include "message.h"
+#include "inputman.h"
+#include "input.h"
+#include "vinfo.h"
+#include "boxx.h"
+#include "boxstack.h"
+#include "log.h"
+#include "vsleeptimer.h"
+#include "wjpeg.h"
+#include "osdvector.h"
+
+
+Control* Control::instance = NULL;
+
+Control::Control()
+{
+ if (instance) return;
+ instance = this;
+}
+
+Control::~Control()
+{
+ flushMessageQueue();
+ instance = NULL;
+}
+
+Control* Control::getInstance()
+{
+ return instance;
+}
+
+int Control::init(bool tcrashed)
+{
+ if (initted) return 0;
+ initted = true;
+ crashed = tcrashed;
+
+ logger = Log::getInstance();
+ boxstack = BoxStack::getInstance();
+ inputMan = InputMan::getInstance();
+
+ if (!logger || !boxstack || !inputMan)
+ {
+ initted = false;
+ return 0;
+ }
+
+ SkinFactory::InitSkin(0);
+
+ return 1;
+}
+
+int Control::shutdown()
+{
+ if (!initted) return 0;
+ initted = false;
+ return 1;
+}
+
+void Control::stop()
+{
+ logger->log("Control", Log::NOTICE, "Request stop");
+
+ Message* m = new Message(); // break master loop
+ m->message = Message::SHUTDOWN;
+ m->p_to = Message::CONTROL;
+ postMessage(m);
+}
+
+void Control::doWallpaper()
+{
+ Video* video = Video::getInstance();
+
+ // Blue background
+ Boxx* bbg = new Boxx();
+ bbg->setSize(video->getScreenWidth(), video->getScreenHeight());
+ bbg->createBuffer();
+ bbg->fillColour(DrawStyle::WALLPAPER);
+ boxstack->add(bbg);
+ boxstack->update(bbg);
+ boxstack->remove(bbg);
+
+ // Wallpaper
+ wallpaper = new Boxx();
+ wallpaper->setSize(video->getScreenWidth(), video->getScreenHeight());
+ wallpaper->createBuffer();
+ wallpaper->setBackgroundColour(DrawStyle::WALLPAPER);
+
+ wallpaper_pict = new WJpegTYPE();
+ wallpaper_pict->setSize(video->getScreenWidth(), video->getScreenHeight());
+
+ if (video->getFormat() == Video::PAL)
+ {
+ logger->log("Control", Log::DEBUG, "PAL wallpaper selected");
+#ifndef _MIPS_ARCH
+ wallpaper_pict->init("/wallpaperPAL.jpg");
+#else
+ wallpaper_pict->init("wallpaperPAL.jpg");
+#endif
+ }
+ else
+ {
+ logger->log("Control", Log::DEBUG, "NTSC wallpaper selected");
+ wallpaper_pict->init("/wallpaperNTSC.jpg");
+ }
+
+ if (DrawStyle::WALLPAPER.alpha)
+ wallpaper_pict->setVisible(true);
+ else
+ wallpaper_pict->setVisible(false);
+
+ wallpaper->add(wallpaper_pict);
+ wallpaper->draw();
+
+ boxstack->add(wallpaper);
+ boxstack->update(wallpaper);
+
+ OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
+ if (osdv) osdv->updateBackgroundColor(DrawStyle::WALLPAPER);
+}
+
+void Control::run()
+{
+ if (!initted) return;
+ irun = true;
+
+ // just in case
+ Video::getInstance()->signalOn();
+ Led::getInstance()->on();
+
+ doWallpaper();
+
+ if (crashed)
+ {
+ buildCrashedBox();
+ }
+ else
+ {
+ VConnect* vconnect = new VConnect();
+ boxstack->add(vconnect);
+ vconnect->run();
+ }
+
+
+ // FIXME Input::NA_SIGNAL is possibly obsolete now
+
+ std::unique_lock<std::mutex> lockWrapper(messageQueueMutex); // locks. unlocks on out-of-scope
+
+ inputMan->start();
+
+ while(irun)
+ {
+ messageQueueCond.wait(lockWrapper, [&] { return !irun || !messages.empty(); });
+ logger->log("Control", Log::DEBUG, "woke");
+
+ if (!irun) break;
+
+ while(!messages.empty())
+ {
+ Message* m = messages.front();
+ messages.pop_front();
+
+ lockWrapper.unlock();
+
+ processMessage(m);
+ delete m;
+
+ lockWrapper.lock();
+ }
+ }
+
+ inputMan->stop();
+
+ boxstack->removeAllExceptWallpaper();
+ boxstack->remove(wallpaper);
+ delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL;
+}
+
+void Control::processMessage(Message* m)
+{
+ // FIXME - a slight modification - how if messagereceivers were to register
+ // themselves as receivers to avoid the calling-a-deleted-object problem
+ // then only deliver/register/unregister would have to be protected
+
+ logger->log("Control", Log::DEBUG, "processing message %i", m->message);
+
+
+ if ((m->p_to == Message::CONTROL) || (m->to == this)) // Maybe don't check m->to here? Always use predefined?
+ {
+ switch(m->message)
+ {
+ case Message::SHUTDOWN:
+ {
+ irun = false;
+ break;
+ }
+ // << FIXME OBSELETE
+ case Message::STOP_PLAYBACK:
+ {
+ handleCommand(Input::STOP); // an odd way of doing it, but so simple
+ break;
+ }
+ // Also connection_lost comes from player - anywhere else?
+ // FIXME OBSELETE >>
+
+
+ case Message::VDR_CONNECTED:
+ {
+ doJustConnected(static_cast<VConnect*>(m->from));
+ break;
+ }
+ case Message::SCREENSHOT:
+ {
+ logger->log("Osd", Log::NOTICE, "Screenshot Message arrived");
+ Osd::getInstance()->screenShot("out.jpg");
+ break;
+ }
+ case Message::CONNECTION_LOST:
+ {
+ doFromTheTop(true);
+ break;
+ }
+ case Message::INPUT_EVENT:
+ {
+ logger->log("Control", Log::NOTICE, "INPUT_EVENT %i", m->parameter);
+
+ handleCommand(m->parameter);
+ break;
+ }
+ case Message::CHANGE_LANGUAGE:
+ {
+ boxstack->removeAllExceptWallpaper();
+ boxstack->update(wallpaper);
+ I18n::initialize();
+ if (!VDR::getInstance()->isConnected()) { connectionLost(); break; }
+ VWelcome* vw = new VWelcome();
+ vw->draw();
+ boxstack->add(vw);
+ boxstack->update(vw);
+ break;
+ }
+ case Message::LAST_VIEW_CLOSE:
+ {
+ // Shouldn't be done like this. Some generic message pass back from vinfo perhaps
+ if (crashed)
+ {
+ crashed = false;
+ doFromTheTop(false);
+ }
+
+// VWelcome* vw = new VWelcome();
+// vw->draw();
+// boxstack->add(vw);
+// boxstack->update(vw);
+
+ break;
+ }
+ case Message::NEW_PICTURE:
+ {
+ //Log::getInstance()->log("Control", Log::DEBUG, "TVMedia NEW_PICTURE");
+ OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
+ if (osdv) osdv->informPicture(m->tag, reinterpret_cast<ImageIndex>(m->data));
+ break;
+ }
+ case Message::NEW_PICTURE_STATIC:
+ {
+ //Log::getInstance()->log("Control", Log::DEBUG, "TVMedia NEW_PICTURE %x %x",m->tag,m->parameter);
+ OsdVector* osdv = dynamic_cast<OsdVector*>(Osd::getInstance());
+ if (osdv) osdv->informPicture(static_cast<unsigned long long>(m->tag) << 32LL, reinterpret_cast<ImageIndex>(m->data));
+ break;
+ }
+ }
+ }
+ else
+ {
+ /* FIXME
+
+ Instead of sending through the boxstack, implement a more generic MessageReceiver interface
+ and have potential receivers register with something
+ When a message needs to be delivered, check if the receiver is still registered, if so, deliver the message
+ This could all be done using the existing big control mutex to keep it simple
+ */
+
+ logger->log("Control", Log::DEBUG, "Sending message to boxstack");
+ boxstack->processMessage(m);
+ }
+}
+
+void Control::handleCommand(int button)
+{
+ if (isStandby && (button != Input::POWER)
+ && (button != Input::POWERON)
+ && (button != Input::POWEROFF)) return;
+
+ if (!connLost && boxstack->handleCommand(button)) return; // don't send to boxstack if connLost
+
+ // command was not handled
+
+ switch(button)
+ {
+ case Input::VOLUMEUP:
+ case Input::VOLUMEDOWN:
+ {
+ if (inputMan->handlesVolume()) // CEC volume handler?
+ {
+ if (button == Input::VOLUMEDOWN)
+ inputMan->volumeDown();
+ else
+ inputMan->volumeUp();
+ }
+ else
+ {
+ VVolume* v = new VVolume();
+ boxstack->add(v);
+ v->handleCommand(button); // this will draw+show
+ }
+ return;
+ }
+ case Input::MUTE:
+ {
+ if (inputMan->handlesVolume())
+ {
+ inputMan->volumeMute();
+ }
+ else
+ {
+ VMute* v = new VMute();
+ v->draw();
+ boxstack->add(v);
+ boxstack->update(v);
+ }
+ return;
+ }
+ case Input::POWER:
+ {
+ doStandby();
+ return;
+ }
+ case Input::POWERON:
+ {
+ doPowerOn();
+ return;
+ }
+ case Input::POWEROFF:
+ {
+ doPowerOff();
+ return;
+ }
+ case Input::OK:
+ {
+ // FIXME
+ if (!connLost) return; // if connLost, handle Input::OK
+ doFromTheTop(false);
+ return;
+ }
+ case Input::GO:
+ {
+ VSleeptimer* sleep = new VSleeptimer();
+ boxstack->add(sleep);
+ sleep->handleCommand(button); // this will draw+show
+ return;
+ }
+ }
+}
+
+/*
+void Control::sig1()
+{
+#ifdef DEV
+ Message* m = new Message(); // break into master mutex
+ m->message = Message::SCREENSHOT;
+ m->to = this;
+ postMessage(m);
+#endif
+}
+*/
+
+void Control::doStandby()
+{
+ if (isStandby)
+ {
+ doPowerOn();
+ }
+ else
+ {
+ doPowerOff();
+ }
+}
+
+
+void Control::doPowerOn()
+{
+ if (isStandby)
+ {
+ Video::getInstance()->signalOn();
+ Led::getInstance()->on();
+ InputMan::getInstance()->changePowerState(true);
+ isStandby = false;
+
+ VConnect* vconnect = new VConnect();
+ boxstack->add(vconnect);
+ vconnect->run();
+ }
+}
+
+void Control::doPowerOff()
+{
+ if (!isStandby)
+ {
+ VDR::getInstance()->shutdownVDR();
+ boxstack->removeAllExceptWallpaper();
+ Video::getInstance()->signalOff();
+ boxstack->update(wallpaper);
+
+ VDR::getInstance()->configSave("General", "Last Power State", "Off");
+ logger->unsetExternLogger();
+ VDR::getInstance()->disconnect();
+ Led::getInstance()->off();
+ InputMan::getInstance()->changePowerState(false);
+ isStandby = true;
+ Sleeptimer::getInstance()->shutdown();
+ }
+}
+
+void Control::doFromTheTop(bool which)
+{
+ if (isStandby) return;
+ if (which)
+ {
+ if (connLost)
+ {
+ logger->log("Control", Log::NOTICE, "Connection lost dialog already present");
+ return;
+ }
+
+ logger->log("Control", Log::NOTICE, "Doing connection lost dialog");
+ connLost = new VInfo();
+ connLost->setSize(360, 200);
+ connLost->createBuffer();
+ if (Video::getInstance()->getFormat() == Video::PAL)
+ connLost->setPosition(190, 170);
+ else
+ connLost->setPosition(180, 120);
+ connLost->setOneLiner(tr("Connection lost"));
+ connLost->setDropThrough();
+ connLost->setBorderOn(1);
+ connLost->setTitleBarColour(DrawStyle::DANGER);
+ connLost->okButton();
+ connLost->draw();
+ boxstack->add(connLost);
+ boxstack->update(connLost);
+
+ clearMQInputEvents();
+ }
+ else
+ {
+ logger->unsetExternLogger();
+ VDR::getInstance()->disconnect();
+ boxstack->removeAllExceptWallpaper();
+ boxstack->update(wallpaper);
+ connLost = NULL;
+
+ flushMessageQueue();
+
+ // at this point, everything should be reset to first-go
+
+ VConnect* vconnect = new VConnect();
+ boxstack->add(vconnect);
+ vconnect->run();
+ }
+}
+
+void Control::clearMQInputEvents()
+{
+ std::lock_guard<std::mutex> lg(messageQueueMutex); // Get the lock
+
+ MQueueI i = messages.begin();
+ while(i != messages.end())
+ {
+ Message* m = *i;
+ if (m->message == Message::INPUT_EVENT)
+ {
+ delete m;
+ i = messages.erase(i);
+ }
+ else
+ {
+ ++i;
+ }
+ }
+}
+
+void Control::doReboot()
+{
+
+ logger->unsetExternLogger();
+ VDR::getInstance()->disconnect();
+ // just kill it...
+ logger->log("Control", Log::NOTICE, "Reboot");
+#ifndef WIN32
+#ifndef VOMP_HAS_EXIT
+ // some plattforms, want a proper deinitialisation of their hardware before reboot
+ Osd::getInstance()->shutdown();
+ Audio::getInstance()->shutdown();
+ Video::getInstance()->shutdown();
+ InputMan::getInstance()->shutdown();
+
+ reboot(LINUX_REBOOT_CMD_RESTART);
+ // if reboot is not allowed -> stop
+ stop();
+
+
+#else
+ stop();
+
+#ifdef __ANDROID__
+ exit(0);
+#endif
+
+#endif
+#endif //Would we support this on windows?
+}
+
+void Control::connectionLost()
+{
+ logger->unsetExternLogger();
+ Message* m = new Message(); // break into master mutex
+ m->message = Message::CONNECTION_LOST;
+ m->p_to = Message::CONTROL;
+ postMessage(m);
+}
+
+void Control::buildCrashedBox()
+{
+ VInfo* crash = new VInfo();
+ crash->setSize(360, 250);
+ crash->createBuffer();
+ if (Video::getInstance()->getFormat() == Video::PAL)
+ crash->setPosition(190, 146);
+ else
+ crash->setPosition(180, 96);
+ crash->setMainText("Oops, vomp crashed.. :(\nPlease report this crash to the author, with as much detail as possible about what you were doing at the time that might have caused the crash.");
+ crash->setBorderOn(1);
+ crash->setTitleBarColour(DrawStyle::DANGER);
+ crash->okButton();
+ crash->setExitable();
+ crash->draw();
+ boxstack->add(crash);
+ boxstack->update(crash);
+}
+
+int Control::getLangPref(bool subtitle, const char* langcode)
+{
+ std::vector<struct ASLPref>::iterator itty=langcodes.begin();
+ char templangcode[4];
+ templangcode[0] = langcode[0];
+ templangcode[1] = langcode[1];
+ templangcode[2] = langcode[2];
+ templangcode[3] = '\0';
+ int langpos = 0;
+ while (itty != langcodes.end())
+ {
+ size_t pos = (*itty).langcode.find(templangcode);
+ if (pos != std::string::npos)
+ {
+ //vector<struct ASLPref>::iterator itty2=langcodes.begin();
+ for (unsigned int i = 0; i < langcodes.size(); i++)
+ {
+ int pref = 0;
+ if (subtitle)
+ pref = langcodes[i].subtitlepref;
+ else
+ pref = langcodes[i].audiopref;
+ if (pref < 0) break;
+
+ if (subtitle)
+ {
+ if (langcodes[i].subtitlepref==langpos) return i;
+ }
+ else
+ {
+ if (langcodes[i].audiopref==langpos) return i;
+ }
+ }
+ break;
+ }
+ itty++;
+ langpos++;
+ }
+ return langcodes.size(); //neutral
+}
+
+void Control::doJustConnected(VConnect* vconnect)
+{
+ I18n::initialize();
+ if (!VDR::getInstance()->isConnected()) { connectionLost(); return; }
+ logger->log("Control", Log::INFO, "Entering doJustConnected");
+
+ Video* video = Video::getInstance();
+ Audio* audio = Audio::getInstance();
+ boxstack->remove(vconnect);
+
+ VInfo* vi = new VInfo();
+ vi->setSize(400, 200);
+ vi->createBuffer();
+ if (video->getFormat() == Video::PAL)
+ vi->setPosition(170, 200);
+ else
+ vi->setPosition(160, 150);
+ vi->setOneLiner(tr("Connected, loading config"));
+ vi->draw();
+ boxstack->add(vi);
+ boxstack->update(vi);
+
+ // FIXME make config system
+
+ VDR* vdr = VDR::getInstance();
+ char* config;
+
+ // See if we're supposed to do network logging
+ config = vdr->configLoad("Advanced", "Network logging");
+ if (config && !STRCASECMP(config, "On"))
+ {
+ logger->log("Control", Log::INFO, "Turning on network logging");
+ logger->setExternLogger(vdr);
+ }
+ else
+ {
+ logger->unsetExternLogger();
+ logger->log("Control", Log::INFO, "Turned off network logging");
+ }
+ if (config) delete[] config;
+
+ config = vdr->configLoad("Advanced", "Skin Name");
+ if (config)
+ {
+ const char **skinnames=SkinFactory::getSkinNames();
+ for (int i=0;i<SkinFactory::getNumberofSkins();i++)
+ {
+ if (!STRCASECMP(config, skinnames[i]))
+ {
+ SkinFactory::InitSkin(i);
+ break;
+ }
+ }
+ delete[] config;
+
+ if (wallpaper && wallpaper_pict)
+ {
+ if (DrawStyle::WALLPAPER.alpha)
+ wallpaper_pict->setVisible(true);
+ else
+ wallpaper_pict->setVisible(false);
+
+ wallpaper->draw();
+ boxstack->update(wallpaper);
+ }
+ }
+ else
+ {
+ SkinFactory::InitSkin(0);
+ }
+
+ // See if config says to override video format (PAL/NTSC)
+ config = vdr->configLoad("General", "Override Video Format");
+ if (config)
+ {
+ logger->log("Control", Log::DEBUG, "Override Video Format is present");
+
+ if ( (!strcmp(config, "PAL") && (video->getFormat() != Video::PAL))
+ || (!strcmp(config, "NTSC") && (video->getFormat() != Video::NTSC))
+ || (!strcmp(config, "PAL_M") && (video->getFormat() != Video::PAL_M))
+ || (!strcmp(config, "NTSC_J") && (video->getFormat() != Video::NTSC_J))
+ )
+ {
+ // Oh sheesh, need to switch format. Bye bye TV...
+
+ // Take everything down
+ boxstack->removeAllExceptWallpaper();
+ boxstack->remove(wallpaper);
+ delete wallpaper_pict; wallpaper_pict = NULL; wallpaper = NULL;
+
+ Osd* osd = Osd::getInstance();
+#ifndef __ANDROID__
+ osd->shutdown();
+#endif
+ video->shutdown();
+
+ inputMan->shutdown(); // need on raspberry shut not do any harm, hopefully
+ inputMan->init(); // FIXME this breaks badly now
+
+ // Get video and osd back up with the new mode
+ if (!strcmp(config, "PAL"))
+ {
+ logger->log("Control", Log::DEBUG, "Switching to PAL");
+ video->init(Video::PAL);
+ }
+ else if (!strcmp(config, "NTSC"))
+ {
+ logger->log("Control", Log::DEBUG, "Switching to NTSC");
+ video->init(Video::NTSC);
+ } else if (!strcmp(config, "PAL_M"))
+ {
+ logger->log("Control", Log::DEBUG, "Switching to PAL_M");
+ video->init(Video::PAL_M);
+ } else if (!strcmp(config, "NTSC_J"))
+ {
+ logger->log("Control", Log::DEBUG, "Switching to NTSC_J");
+ video->init(Video::NTSC_J);
+ }
+ delete[] config;
+
+#ifndef __ANDROID__
+ //we do not init twice
+ osd->init();
+#endif
+
+ // Put the wallpaper back
+ doWallpaper();
+
+ // Re add the vinfo
+ vi = new VInfo();
+ vi->setSize(400, 200);
+ vi->createBuffer();
+ if (video->getFormat() == Video::PAL)
+ vi->setPosition(170, 200);
+ else
+ vi->setPosition(160, 150);
+
+ vi->setOneLiner(tr("Connected, loading config"));
+ vi->draw();
+ boxstack->add(vi);
+ boxstack->update(vi);
+ }
+ else
+ {
+ logger->log("Control", Log::DEBUG, "Already in requested mode, or request was not 'PAL' or 'NTSC'");
+ }
+ }
+ else
+ {
+ logger->log("Control", Log::DEBUG, "Phew, no dangerous on-the-fly mode switching to do!");
+ }
+
+ // Power off if first boot and config says so
+ if (firstBoot)
+ {
+ firstBoot = false;
+
+ logger->log("Control", Log::DEBUG, "Load power after boot");
+
+ config = vdr->configLoad("General", "Power After Boot");
+
+ if (config)
+ {
+ if (!STRCASECMP(config, "On"))
+ {
+ logger->log("Control", Log::INFO, "Config says Power After Boot = On");
+ }
+ else if (!STRCASECMP(config, "Off"))
+ {
+ logger->log("Control", Log::INFO, "Config says Power After Boot = Off");
+ doStandby();
+ delete[] config;
+ return; // quit here
+ }
+ else if (!STRCASECMP(config, "Last state"))
+ {
+ char* lastPowerState = vdr->configLoad("General", "Last Power State");
+ if (lastPowerState)
+ {
+ if (!STRCASECMP(lastPowerState, "On"))
+ {
+ logger->log("Control", Log::INFO, "Config says Last Power State = On");
+ }
+ else if (!STRCASECMP(lastPowerState, "Off"))
+ {
+ logger->log("Control", Log::INFO, "Config says Last Power State = Off");
+ doStandby();
+ delete[] config;
+ return; // quit here
+ }
+ else
+ {
+ logger->log("Control", Log::INFO, "Config General/Last Power State not understood");
+ }
+ }
+ else
+ {
+ logger->log("Control", Log::INFO, "Config General/Last Power State not found");
+ }
+ }
+ else
+ {
+ logger->log("Control", Log::INFO, "Config/Power After Boot not understood");
+ }
+ delete[] config;
+ }
+ else
+ {
+ logger->log("Control", Log::INFO, "Config General/Power After Boot not found");
+ }
+ }
+
+
+ // Go S-Video if config says so
+
+ config = vdr->configLoad("TV", "Connection");
+
+ if (config)
+ {
+ if (!STRCASECMP(config, "S-Video"))
+ {
+ logger->log("Control", Log::INFO, "Switching to S-Video as Connection=%s", config);
+ video->setConnection(Video::SVIDEO);
+ } else if (!STRCASECMP(config, "HDMI"))
+ {
+ logger->log("Control", Log::INFO, "Switching to HDMI as Connection=%s", config);
+ video->setConnection(Video::HDMI);
+ } else if (!STRCASECMP(config, "HDMI3D"))
+ {
+ logger->log("Control", Log::INFO, "Switching to HDMI3D as Connection=%s", config);
+ video->setConnection(Video::HDMI3D);
+ }
+ else
+ {
+ logger->log("Control", Log::INFO, "Switching to RGB/Composite as Connection=%s", config);
+ video->setConnection(Video::COMPOSITERGB);
+ }
+ delete[] config;
+ }
+ else
+ {
+ logger->log("Control", Log::INFO, "Config TV/S-Video not found");
+ }
+
+ // Set to shutdown VDR if config says
+
+ config = vdr->configLoad("General", "VDR shutdown");
+ if (config)
+ {
+ if (!STRCASECMP(config, "On"))
+ {
+ logger->log("Control", Log::INFO, "Shutdown VDR when shutting down vomp");
+ vdr->setVDRShutdown(true);
+ }
+ else if (!STRCASECMP(config, "Off"))
+ {
+ logger->log("Control", Log::INFO, "Shutdown only vomp");
+ vdr->setVDRShutdown(false);
+ }
+ }
+ else
+ {
+ logger->log("Control", Log::INFO, "Default shutdown only vomp");
+ vdr->setVDRShutdown(false); // Default
+ }
+
+ // Get TV aspect ratio
+
+ config = vdr->configLoad("TV", "Aspect");
+ if (config)
+ {
+ if (!STRCASECMP(config, "16:9"))
+ {
+ logger->log("Control", Log::INFO, "/// Switching to TV aspect 16:9");
+ video->setTVsize(Video::ASPECT16X9);
+ }
+ else
+ {
+ logger->log("Control", Log::INFO, "/// Switching to TV aspect 4:3");
+ video->setTVsize(Video::ASPECT4X3);
+ }
+ delete[] config;
+ }
+ else
+ {
+ logger->log("Control", Log::INFO, "Config TV/Aspect type not found, going 4:3");
+ video->setTVsize(Video::ASPECT4X3);
+ }
+
+ config = vdr->configLoad("TV", "Widemode");
+ if (config)
+ {
+ if (!STRCASECMP(config, "Letterbox"))
+ {
+ logger->log("Control", Log::INFO, "Setting letterbox mode");
+ video->setMode(Video::LETTERBOX);
+ }
+ else
+ {
+ logger->log("Control", Log::INFO, "Setting chop-sides mode");
+ video->setMode(Video::NORMAL);
+ }
+ delete[] config;
+ }
+ else
+ {
+#ifdef __ANDROID__
+ logger->log("Control", Log::INFO, "Config TV/Widemode not found, Setting letterbox mode");
+ video->setMode(Video::LETTERBOX);
+#else
+ logger->log("Control", Log::INFO, "Config TV/Widemode not found, Setting chop-sides mode");
+ video->setMode(Video::NORMAL);
+#endif
+ }
+
+ config = vdr->configLoad("Advanced", "TCP receive window");
+ if (config)
+ {
+ size_t newTCPsize = atoi(config);
+ delete[] config;
+
+ logger->log("Control", Log::INFO, "Setting TCP window size %i", newTCPsize);
+ vdr->setReceiveWindow(newTCPsize);
+ }
+ else
+ {
+ logger->log("Control", Log::INFO, "TCP window size not found, setting 2048");
+ if (DEFAULT_TCP_WINDOWSIZE) vdr->setReceiveWindow(2048); // Default
+ }
+
+ config = vdr->configLoad("Advanced", "Font Name");
+ if (config)
+ {
+ Osd::getInstance()->setFont(config);
+ logger->log("Control", Log::INFO, "Setting Font to %s", config);
+ delete[] config;
+
+ }
+
+
+ // Set recording list type
+
+#ifdef ADVANCED_MENUES
+ config = vdr->configLoad("Advanced", "Menu type");
+
+ if (config)
+ {
+ if (!STRCASECMP(config, "Advanced"))
+ {
+ logger->log("Control", Log::INFO, "Switching to Advanced menu");
+ advMenus = true;
+ }
+ else
+ {
+ logger->log("Control", Log::INFO, "Switching to Classic menu");
+ advMenus = false;
+ }
+ delete[] config;
+ }
+ else
+ {
+ logger->log("Control", Log::INFO, "Config General/menu type not found");
+ advMenus = true;
+ }
+#endif
+
+ config = vdr->configLoad("Advanced", "Disable WOL");
+ if (config)
+ {
+ if (!STRCASECMP(config, "Yes"))
+ {
+ logger->log("Control", Log::INFO, "Config says disable WOL");
+ Wol::getInstance()->setEnabled(false);
+ }
+ else
+ {
+ logger->log("Control", Log::INFO, "Config says enable WOL");
+ Wol::getInstance()->setEnabled(true);
+ }
+
+ delete[] config;
+ }
+ else
+ {
+ logger->log("Control", Log::INFO, "By default, enable WOL");
+ Wol::getInstance()->setEnabled(true);
+ }
+ /* device dependend config */
+ audio->loadOptionsFromServer(vdr);
+ video->loadOptionsFromServer(vdr);
+ inputMan->loadOptionsFromServer(vdr);
+
+ video->executePendingModeChanges();
+ // config done
+
+ // Save power state = on
+
+ vdr->configSave("General", "Last Power State", "On");
+
+ // Make sure connection didn't die
+ if (!vdr->isConnected())
+ {
+ Control::getInstance()->connectionLost();
+ }
+ else
+ {
+ boxstack->remove(vi);
+
+ VWelcome* vw = new VWelcome();
+ vw->draw();
+ boxstack->add(vw);
+ boxstack->update(vw);
+
+ // Enter pre-keys here
+// handleCommand(Input::OK);
+// handleCommand(Input::THREE);
+// handleCommand(Input::SIX);
+// handleCommand(Input::OK);
+// handleCommand(Input::UP);
+// handleCommand(Input::PLAY);
+// handleCommand(Input::DOWN);
+// handleCommand(Input::DOWN);
+// handleCommand(Input::DOWN);
+// handleCommand(Input::RIGHT);
+// handleCommand(Input::RED);
+ }
+}
--- /dev/null
+/*
+ Copyright 2004-2020 Chris Tallon
+
+ This file is part of VOMP.
+
+ VOMP is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ VOMP is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with VOMP. If not, see <https://www.gnu.org/licenses/>.
+*/
+
+#ifndef COMMAND_H
+#define COMMAND_H
+
+#ifndef WIN32
+#include <unistd.h> // for reboot
+#include <linux/reboot.h>
+#include <sys/reboot.h>
+#endif
+
+#include <time.h>
+#ifndef WIN32
+#include <pthread.h> // why?
+#endif
+
+#include <string>
+#include <vector>
+
+#include "defines.h"
+#include "messagequeue.h"
+
+class VConnect;
+class Message;
+class InputMan;
+class Boxx;
+class BoxStack;
+class Log;
+class VInfo;
+class WJpeg;
+
+struct ASLPref
+{
+ std::string langcode;
+ int audiopref;
+ int subtitlepref;
+};
+
+typedef std::vector<struct ASLPref> ASLPrefList;
+
+class Control : public MessageQueue
+{
+ public:
+ Control();
+ ~Control();
+ static Control* getInstance();
+
+ int init(bool crashed = false);
+ int shutdown();
+ void run();
+ void stop();
+ void doReboot();
+ void connectionLost();
+
+ void setAdvMenus(bool adv) { advMenus = adv; };
+ bool isAdvMenus() { return advMenus; };
+ int getLangPref(bool subtitle,const char* langcode);
+ void setSubDefault(int subon) { subdefault = subon; };
+ int getSubDefault() { return subdefault; };
+ ASLPrefList &getASLList() { return langcodes; };
+
+ private:
+ void handleCommand(int);
+ void doStandby();
+ void doPowerOn();
+ void doPowerOff();
+ void doJustConnected(VConnect* vconnect);
+ void doWallpaper();
+ void doFromTheTop(bool which); // true - show vinfo,wait. false - del vinfo,restart
+ void buildCrashedBox();
+// void sig1();
+ void clearMQInputEvents();
+
+ static Control* instance;
+
+ Log* logger;
+ BoxStack* boxstack;
+ InputMan* inputMan;
+
+ bool initted{};
+ bool irun{};
+ bool isStandby{};
+ bool firstBoot{true};
+ Boxx* wallpaper{};
+ WJpeg* wallpaper_pict{};
+ VInfo* connLost{};
+ bool crashed{};
+
+ bool advMenus{};
+ ASLPrefList langcodes;
+ int subdefault;
+
+ void processMessage(Message* m);
+};
+
+#endif
bool dolby=false;
int selected=-1;
int prefered=-1;
- Command* command = Command::getInstance();
+ Control* control = Control::getInstance();
if (channelinfo.numDPids > 0 && Audio::getInstance()->maysupportAc3())
{
ULONG j = 0;
while (j < channelinfo.numDPids)
{
- int newpref = command->getLangPref(false, channelinfo.dpids[j].desc);
+ int newpref = control->getLangPref(false, channelinfo.dpids[j].desc);
if (Audio::getInstance()->streamTypeSupported(channelinfo.dpids[j].type)
&& (prefered < 0 || newpref < prefered))
{
ULONG j = 0;
while (j < channelinfo.numAPids)
{
- int newpref = command->getLangPref(false, channelinfo.apids[j].desc);
+ int newpref = control->getLangPref(false, channelinfo.apids[j].desc);
if (Audio::getInstance()->streamTypeSupported(channelinfo.apids[j].type)
&& (prefered < 0 || newpref < prefered))
{
ULONG j = 0;
while (j < channelinfo.numSPids)
{
- int newpref = command->getLangPref(true, channelinfo.spids[j].desc);
+ int newpref = control->getLangPref(true, channelinfo.spids[j].desc);
if ( (prefered < 0 || newpref < prefered))
{
selected = j;
#include "event.h"
#include "log.h"
-#include "command.h"
+#include "control.h"
#include "movieinfo.h"
#include "seriesinfo.h"
#include "vdr.h"
id, channelid, movieID, seriesID, episodeID);
}
- if (!vdr->isConnected()) Command::getInstance()->connectionLost();
+ if (!vdr->isConnected()) Control::getInstance()->connectionLost();
if (movieID != 0)
{
Log::getInstance()->log("Event", Log::DEBUG, "Got Scraper SeriesInfo");
}
- if (!vdr->isConnected()) Command::getInstance()->connectionLost();
+ if (!vdr->isConnected()) Control::getInstance()->connectionLost();
}
"Verbinding mislukt",
"55",
},
- // Command
+ // Control
{ "Connected, loading config",
"Verbunden, lade Einstellungen",
"Ansluten, laddar konfigurering",
#include "timers.h"
#include "vdr.h"
#include "boxstack.h"
-#include "command.h"
+#include "control.h"
#include "inputman.h"
#include "wol.h"
#include "vsleeptimer.h"
Osd* osd;
Timers* timers;
BoxStack* boxstack;
-Command* command;
+Control* control;
VDR* vdr;
Video* video;
Audio* audio;
video = new Video_TYPE();
boxstack = new BoxStack();
- command = new Command();
+ control = new Control();
wol = new Wol();
sleeptimer = new Sleeptimer();
- if (!logger || !timers || !inputMan || !led || !osd || !video || !audio || !boxstack || !command || !wol || !sleeptimer)
+ if (!logger || !timers || !inputMan || !led || !osd || !video || !audio || !boxstack || !control || !wol || !sleeptimer)
{
printf("Could not create objects. Memory problems?\n");
shutdown(1);
shutdown(1);
}
- success = command->init(crashed);
+ success = control->init(crashed);
if (success)
{
- logger->log("Core", Log::INFO, "Command module initialised");
+ logger->log("Core", Log::INFO, "Control module initialised");
}
else
{
- logger->log("Core", Log::EMERG, "Command module failed to initialise");
+ logger->log("Core", Log::EMERG, "Control module failed to initialise");
shutdown(1);
}
// Run main loop ---------------------------------------------------------------------------------------------------
// Ok, all major device components and other bits are loaded and ready
- command->run();
+ control->run();
// When that returns quit ------------------------------------------------------------------------------------------
shutdown(0);
logger->log("Core", Log::NOTICE, "Signal received: %i", sig);
- if ((sig == SIGINT) || (sig == SIGTERM)) command->stop();
+ if ((sig == SIGINT) || (sig == SIGTERM)) control->stop();
}
}
logger->log("Core", Log::NOTICE, "BoxStack module shut down");
}
- // FIXME, send a del all to boxstack first, then get rid of it after command?
- if (command) // shut down command here in case views have posted messages
+ // FIXME, send a del all to boxstack first, then get rid of it after control?
+ if (control) // shut down control here in case views have posted messages
{
- command->shutdown();
- delete command;
- command = NULL;
- logger->log("Core", Log::NOTICE, "Command module shut down");
+ control->shutdown();
+ delete control;
+ control = NULL;
+ logger->log("Core", Log::NOTICE, "Control module shut down");
}
if (vdr)
};
#endif
-
-// FIXME idea - instead of always having to specify a real pointer in the "to" variable (meaning clients may have to
-// run Command::getInstance() for e.g.), how about having some constant values for well known targets. Then
-// clients may not need the #include "command.h"
-OBJ_COMMON = command.o thread.o timers.o i18n.o udp4.o udp6.o vdpc.o tcp.o \
+OBJ_COMMON = control.o thread.o timers.o i18n.o udp4.o udp6.o vdpc.o tcp.o \
message.o messagequeue.o wol.o audio.o video.o log.o \
vdr.o recman.o recording.o recinfo.o channel.o rectimer.o event.o \
directory.o mark.o option.o vfeed.o afeed.o \
#include "videoomx.h"
#include "surfaceopengl.h"
#include "message.h"
-#include "command.h"
+#include "control.h"
#include "osdopengl.h"
#include "surfacevector.h"
#include "vdr.h"
#include "vdrresponsepacket.h"
-#include "command.h"
+#include "control.h"
#include "message.h"
// The next section is activated, if the magick++ PictureReader is provided, it should be available for many POSIX platforms
virtual void getScreenSize(int &width, int &height)=0;
virtual void getRealScreenSize(int &width, int &height)=0;
- // should be only called from command thread
+ // should be only called from control thread
void informPicture(LoadIndex index, ImageIndex i_index);
bool processReceivedPictures();
- // should be called from command thread
+ // should be called from control thread
void receivePicture(VDR_ResponsePacket *vresp);
void addStaticImage(unsigned int id);
#include "message.h"
-#include "command.h"
+#include "control.h"
m->message = Message::NEW_PICTURE_STATIC;
m->tag = pict_inf.lindex >> 32LL;
}
- MessageQueue::getInstance()->postMessage(m); // inform command about new picture
+ MessageQueue::getInstance()->postMessage(m); // inform control about new picture
} else {
pict_inf.decoder->freeReference(pict_inf.reference);
#include "channel.h"
#include "dvbsubtitles.h"
#include "osdreceiver.h"
-#include "command.h"
+#include "control.h"
#include "playervideolive.h"
int selected = -1;
int prefered = -1;
- Command* command = Command::getInstance();
+ Control* control = Control::getInstance();
if (chan->numDPids > 0 && audio->maysupportAc3())
{
ULONG j = 0;
while (j < chan->numDPids)
{
- int newpref = command->getLangPref(false, chan->dpids[j].desc);
+ int newpref = control->getLangPref(false, chan->dpids[j].desc);
if (Audio::getInstance()->streamTypeSupported(chan->dpids[j].type) && (prefered < 0 || newpref < prefered))
{
selected = j;
ULONG j = 0;
while (j < chan->numAPids)
{
- int newpref = command->getLangPref(false, chan->apids[j].desc);
+ int newpref = control->getLangPref(false, chan->apids[j].desc);
if (Audio::getInstance()->streamTypeSupported(chan->apids[j].type) && (prefered < 0 || newpref < prefered))
{
selected = j;
ULONG j = 0;
while (j < chan->numSPids)
{
- int newpref = command->getLangPref(true, chan->spids[j].desc);
+ int newpref = control->getLangPref(true, chan->spids[j].desc);
if ((prefered < 0 || newpref < prefered))
{
selected = j;
{
firstStart = false;
- if (command->getSubDefault())
+ if (control->getSubDefault())
turnSubtitlesOn(true);
else
turnSubtitlesOn(false);
video->blank();
audio->stop();
- if (Command::getInstance()->getSubDefault())
+ if (Control::getInstance()->getSubDefault())
turnSubtitlesOn(true);
else
turnSubtitlesOn(false);
#include "log.h"
#include "demuxer.h"
#include "demuxerts.h"
-#include "command.h"
+#include "control.h"
#include "seriesinfo.h"
#include "movieinfo.h"
recInfo = vdr->getRecInfo(fileName);
Log::getInstance()->log("Recording", Log::DEBUG, "Recording has loaded recInfo %p", recInfo);
- if (!vdr->isConnected()) Command::getInstance()->connectionLost();
+ if (!vdr->isConnected()) Control::getInstance()->connectionLost();
if (movieInfo) delete movieInfo;
if (seriesInfo) delete seriesInfo;
Log::getInstance()->log("Recording", Log::DEBUG, "Got Scraper EventType %d %d %d",
movieID, seriesID, episodeID);
- if (!vdr->isConnected()) Command::getInstance()->connectionLost();
+ if (!vdr->isConnected()) Control::getInstance()->connectionLost();
if (movieID != 0)
{
}
- if (!vdr->isConnected()) Command::getInstance()->connectionLost();
+ if (!vdr->isConnected()) Control::getInstance()->connectionLost();
}
void Recording::loadMarks()
{
markList = vdr->getMarks(fileName);
- if (!VDR::getInstance()->isConnected()) Command::getInstance()->connectionLost();
+ if (!VDR::getInstance()->isConnected()) Control::getInstance()->connectionLost();
}
bool Recording::isRadio(bool &h264)
free(buffer);
vdr->stopStreaming();
- if (!VDR::getInstance()->isConnected()) Command::getInstance()->connectionLost();
+ if (!VDR::getInstance()->isConnected()) Control::getInstance()->connectionLost();
Log::getInstance()->log("Recording", Log::DEBUG, "Recording has messed about and worked out radio = %u", !hasVideo);
#include "defines.h"
#include "video.h"
#include "colour.h"
-#include "command.h"
+#include "control.h"
#include "i18n.h"
#include "boxstack.h"
#include "message.h"
logger->log("VConnect", Log::DEBUG, "Connected ok, doing login");
unsigned int version_server_min, version_server_max, version_client;
int subtitles;
- success = vdr->doLogin(&version_server_min, &version_server_max, &version_client, Command::getInstance()->getASLList(), subtitles);
- Command::getInstance()->setSubDefault(subtitles);
+ success = vdr->doLogin(&version_server_min, &version_server_max, &version_client, Control::getInstance()->getASLList(), subtitles);
+ Control::getInstance()->setSubDefault(subtitles);
if (!success)
{
#include "wol.h"
#include "vdrrequestpacket.h"
#include "vdrresponsepacket.h"
-#include "command.h"
+#include "control.h"
#ifdef VOMP_MEDIAPLAYER
#include "media.h"
#include "mediaprovider.h"
}
}
edMutex.unlock();
- // Ok, all event receviers should be dealt with. just in case there weren't any, inform command
+ // Ok, all event receviers should be dealt with. just in case there weren't any, inform control
logger->log("VDR", Log::DEBUG, "edUnlock at end of connectionDied");
- Command::getInstance()->connectionLost();
+ Control::getInstance()->connectionLost();
}
bool VDR::ed_cb_find(EDReceiver* edr, void* userTag)
SerializeBuffer* vresp = doRequestResponse(vrp,request.command);
if (!vresp) {
- Command::getInstance()->connectionLost();
+ Control::getInstance()->connectionLost();
return NULL;
}
}
SerializeBuffer* vresp = doRequestResponse(vrp,request.command);
if (!vresp) {
- Command::getInstance()->connectionLost();
+ Control::getInstance()->connectionLost();
return -1;
}
ULONG flags=0;
}
SerializeBuffer* vresp = doRequestResponse(vrp,request.command);
if (!vresp) {
- Command::getInstance()->connectionLost();
+ Control::getInstance()->connectionLost();
return -1;
}
}
SerializeBuffer* vresp = doRequestResponse(vrp,request.command);
if (!vresp) {
- Command::getInstance()->connectionLost();
+ Control::getInstance()->connectionLost();
return -1;
}
}
SerializeBuffer* vresp = doRequestResponse(vrp,request.command);
if (!vresp) {
- Command::getInstance()->connectionLost();
+ Control::getInstance()->connectionLost();
return -1;
}
ULONG flags;
#include "eventdispatcher.h"
#include "i18n.h"
#include "log.h"
-#include "command.h"
+#include "control.h"
#include "tcp.h"
class RecInfo;
#include "log.h"
#include "vinfo.h"
#include "message.h"
-#include "command.h"
+#include "control.h"
#include "messagequeue.h"
#include "video.h"
#include "input.h"
if (!vdr->isConnected())
{
- Command::getInstance()->connectionLost();
+ Control::getInstance()->connectionLost();
}
if (ret == 0) logger->log("VEPGST", Log::DEBUG, "Success");
#include "colour.h"
#include "video.h"
#include "i18n.h"
-#include "command.h"
+#include "control.h"
#include "boxstack.h"
#include "event.h"
#include "channel.h"
#include "vinfo.h"
#include "i18n.h"
#include "message.h"
-#include "command.h"
+#include "control.h"
#include "mediaoptions.h"
#include "mediaplayer.h"
#include "log.h"
player->shutdown();
player=NULL;
}
- Command::getInstance()->connectionLost();
+ Control::getInstance()->connectionLost();
break;
}
}
#include "vdr.h"
#include "messagequeue.h"
#include "message.h"
-#include "command.h"
+#include "control.h"
#include "staticartwork.h"
#ifdef VOMP_PLATTFORM_MVP
if (options[i]->userSetChoice == 1)
{
Log::getInstance()->log("Options", Log::DEBUG, "Setting classic menu");
- Command::getInstance()->setAdvMenus(false);
+ Control::getInstance()->setAdvMenus(false);
}
else
{
Log::getInstance()->log("Options", Log::DEBUG, "Setting advanced menu");
- Command::getInstance()->setAdvMenus(true);
+ Control::getInstance()->setAdvMenus(true);
}
break;
}
along with VOMP. If not, see <https://www.gnu.org/licenses/>.
*/
-#include "command.h"
+#include "control.h"
#include "osd.h"
#include "wsymbol.h"
#include "recording.h"
startMargin = 0;
endMargin = 0;
- player = new PlayerRadioRec(Command::getInstance(), this);
+ player = new PlayerRadioRec(Control::getInstance(), this);
char* cstartMargin = vdr->configLoad("Timers", "Start margin");
char* cendMargin = vdr->configLoad("Timers", "End margin");
if (!vdr->isConnected())
{
- Command::getInstance()->connectionLost();
+ Control::getInstance()->connectionLost();
return;
}
{
case PlayerRadioRec::CONNECTION_LOST: // connection lost detected
{
- // I can't handle this, send it to command
+ // I can't handle this, send it to control
Message* m2 = new Message();
m2->p_to = Message::CONTROL;
m2->message = Message::CONNECTION_LOST;
playing = false;
- if (!vdr->isConnected()) { Command::getInstance()->connectionLost(); return; }
+ if (!vdr->isConnected()) { Control::getInstance()->connectionLost(); return; }
Log::getInstance()->log("VRadioRec", Log::DEBUG, "Post stopPlay");
}
#include "colour.h"
#include "video.h"
#include "i18n.h"
-#include "command.h"
+#include "control.h"
#include "vinfo.h"
#include "log.h"
int success = recman->deleteRecording(toDelete);
if (!VDR::getInstance()->isConnected())
{
- Command::getInstance()->connectionLost();
+ Control::getInstance()->connectionLost();
return;
}
int success = recman->moveRecording(toMove, toDir);
if (!VDR::getInstance()->isConnected())
{
- Command::getInstance()->connectionLost();
+ Control::getInstance()->connectionLost();
return;
}
#include "colour.h"
#include "video.h"
#include "i18n.h"
-#include "command.h"
+#include "control.h"
#include "vinfo.h"
#include "log.h"
#include "movieinfo.h"
#include "colour.h"
#include "video.h"
#include "i18n.h"
-#include "command.h"
+#include "control.h"
#include "vinfo.h"
#include "log.h"
#include "video.h"
#include "i18n.h"
#include "vtimeredit.h"
-#include "command.h"
+#include "control.h"
#include "boxstack.h"
#include "vinfo.h"
#include "log.h"
ULONG retval = VDR::getInstance()->deleteTimer(recTimer);
- if (!VDR::getInstance()->isConnected()) { Command::getInstance()->connectionLost(); return; }
+ if (!VDR::getInstance()->isConnected()) { Control::getInstance()->connectionLost(); return; }
Log::getInstance()->log("VTimerList", Log::DEBUG, "Got return fron delete timer: %lu", retval);
if (retval != 10)
#include "boxstack.h"
#include "colour.h"
#include "osd.h"
-#include "command.h"
+#include "control.h"
#include "i18n.h"
#include "wtextbox.h"
#include "input.h"
if ((*chanList)[currentChannelIndex]->type == VDR::VIDEO)
{
streamType = VDR::VIDEO;
- player = new PlayerVideoLive(Command::getInstance(), this, this, chanList);
+ player = new PlayerVideoLive(Control::getInstance(), this, this, chanList);
}
else
{
streamType = VDR::RADIO;
- player = new PlayerRadioLive(Command::getInstance(), this, chanList);
+ player = new PlayerRadioLive(Control::getInstance(), this, chanList);
}
player->init();
{
if (osd.getVisible()) clearScreen();
- if (!Command::getInstance()->isAdvMenus())
+ if (!Control::getInstance()->isAdvMenus())
{
VEpg* vepg = new VEpg(this, currentChannelIndex, chanList);
vepg->draw();
case PlayerVideoLive::CONNECTION_LOST: // connection lost detected
{
Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received connection lost from player");
- Command::getInstance()->connectionLost();
+ Control::getInstance()->connectionLost();
break;
}
{
case PlayerMedia::CONNECTION_LOST: // connection lost detected
{
- // I can't handle this, send it to command
+ // I can't handle this, send it to control
Message* m2 = new Message();
m2->p_to = Message::CONTROL;
m2->message = Message::CONNECTION_LOST;
#include <math.h>
-#include "command.h"
+#include "control.h"
#include "osd.h"
#include "wsymbol.h"
#include "audio.h"
video->seth264mode(ish264);
- player = new PlayerVideoRec(Command::getInstance(), this, this);
+ player = new PlayerVideoRec(Control::getInstance(), this, this);
player->init(myRec->IsPesRecording,myRec->recInfo->fps);
char* cstartMargin = vdr->configLoad("Timers", "Start margin");
if (!vdr->isConnected())
{
- Command::getInstance()->connectionLost();
+ Control::getInstance()->connectionLost();
return;
}
{
case PlayerVideoRec::CONNECTION_LOST: // connection lost detected
{
- // I can't handle this, send it to command
+ // I can't handle this, send it to control
Message* m2 = new Message();
m2->p_to = Message::CONTROL;
m2->message = Message::CONNECTION_LOST;
playing = false;
- if (!vdr->isConnected()) { Command::getInstance()->connectionLost(); return; }
+ if (!vdr->isConnected()) { Control::getInstance()->connectionLost(); return; }
Log::getInstance()->log("VVideoRec", Log::DEBUG, "Post stopPlay");
}
#include "vrecordinglistclassic.h"
#include "vrecordinglistadvanced.h"
#include "vtimerlist.h"
-#include "command.h"
+#include "control.h"
#include "message.h"
#include "colour.h"
#include "video.h"
}
case Input::SEVEN:
{
- Command::getInstance()->doReboot();
+ Control::getInstance()->doReboot();
return 2;
}
case Input::OK:
}
else if (option == 7)
{
- Command::getInstance()->doReboot();
+ Control::getInstance()->doReboot();
return 2;
}
return 2; // never gets here
}
else
{
- Command::getInstance()->connectionLost();
+ Control::getInstance()->connectionLost();
}
}
}
else
{
- Command::getInstance()->connectionLost();
+ Control::getInstance()->connectionLost();
}
}
void VWelcome::doRecordingsList()
{
VRecordingList* vrec;
- if (Command::getInstance()->isAdvMenus())
+ if (Control::getInstance()->isAdvMenus())
vrec = new VRecordingListAdvanced();
else
vrec = new VRecordingListClassic();
if (!vrec->load())
{
- Command::getInstance()->connectionLost();
+ Control::getInstance()->connectionLost();
}
}
if (!vtl->load())
{
delete vtl;
- Command::getInstance()->connectionLost();
+ Control::getInstance()->connectionLost();
return;
}
#include "osdwinvector.h"
#endif
#include "boxstack.h"
-#include "command.h"
+#include "control.h"
#include "wol.h"
#include "vsleeptimer.h"
#include "messagequeue.h"
Osd* osd;
Timers* timers;
BoxStack* boxstack;
-Command* command;
+Control* control;
VDR* vdr;
Video* video;
Audio* audio;
return 0;
}
-DWORD WINAPI commandthreadStart(void *arg)
+DWORD WINAPI controlthreadStart(void *arg)
{
- command->run();
+ control->run();
return 0;
}
video = new VideoWin();
audio = new AudioWin();
boxstack = new BoxStack();
- command = new Command();
+ control = new Control();
wol = new Wol();
sleeptimer = new Sleeptimer();
- if (!logger || !remote || !led || !osd || !video || !audio || !boxstack || !command || !sleeptimer)
+ if (!logger || !remote || !led || !osd || !video || !audio || !boxstack || !control || !sleeptimer)
{
ERROR_MSG("Could not create objects. Memory problems?\n");
shutdown(1);
return 0;
}
- messageQueue = command;
+ messageQueue = control;
// Get logging module started --------------------------------------------------------------------------------------
return 0;
}
- success = command->init();
+ success = control->init();
if (success)
{
- logger->log("Core", Log::INFO, "Command module initialised");
+ logger->log("Core", Log::INFO, "Control module initialised");
}
else
{
- logger->log("Core", Log::EMERG, "Command module failed to initialise");
+ logger->log("Core", Log::EMERG, "Control module failed to initialise");
shutdown(1);
WSACleanup();
return 0;
// Ok, all major device components and other bits are loaded and ready
lastmousemove=timeGetTime();
- HANDLE commandthread;
- commandthread= CreateThread(NULL, 0, commandthreadStart, NULL,0,
+ HANDLE controlthread;
+ controlthread= CreateThread(NULL, 0, controlthreadStart, NULL,0,
NULL);
MSG message;
message.message=WM_NULL;
bool run=true;
- while(run && WaitForSingleObject(commandthread,0)==WAIT_TIMEOUT) {
+ while(run && WaitForSingleObject(controlthread,0)==WAIT_TIMEOUT) {
if (PeekMessage(&message, NULL, 0,0,PM_REMOVE)!=0) {
if (TranslateAccelerator(win_main,acc,&message)==NULL) {
TranslateMessage(&message);
DispatchMessage(&message);
switch (message.message) {
case WM_QUIT:
- run=false; //TODO post exit to command Messages
+ run=false; //TODO post exit to control Messages
};
}
} else {
}
}
// When that returns quit ------------------------------------------------------------------------------------------
- WaitForSingleObject(commandthread,INFINITE);
+ WaitForSingleObject(controlthread,INFINITE);
shutdown(0);
WSACleanup();
if (user32dll) FreeModule(user32dll);
switch (msg) {
case WM_DESTROY: {
- //TODO: call command
+ //TODO: call control
logger->log("Core", Log::NOTICE, "Window closed, shutting down...");
- command->stop();
+ control->stop();
PostQuitMessage(0);
}break;
case WM_SIZING: {
logger->log("Core", Log::NOTICE, "BoxStack module shut down");
}
- if (command) // shut down command here in case views have posted messages
+ if (control) // shut down control here in case views have posted messages
{
- command->shutdown();
- delete command;
- logger->log("Core", Log::NOTICE, "Command module shut down");
+ control->shutdown();
+ delete control;
+ logger->log("Core", Log::NOTICE, "Control module shut down");
}
if (vdr)
m->message = Message::CHANGED_REMOTECONTROL;
m->to = parent;
m->parameter = 0;
- //Command::getInstance()->postMessage(m);
+ //Control::getInstance()->postMessage(m);
}
*/
m->message = Message::CLOSE_ME;
m->from = this;
m->to = viewman;
- //Command::getInstance()->postMessage(m);
+ //Control::getInstance()->postMessage(m);
return 2;
*/
}
m->message = Message::CHANGED_DEVICEOPTIONS;
m->to = parent;
m->parameter = 0;
- //Command::getInstance()->postMessage(m);
+ //Control::getInstance()->postMessage(m);
}*/
m->message = Message::CHANGED_DEVICEOPTIONS;
m->to = parent;
m->parameter = 0;
- //Command::getInstance()->postMessage(m);
+ //Control::getInstance()->postMessage(m);
}*/
m->message = Message::CHANGED_DEVICEOPTIONS;
m->to = parent;
m->parameter = 0;
- //Command::getInstance()->postMessage(m);
+ //Control::getInstance()->postMessage(m);
}*/
m->message = Message::CHANGED_DEVICEOPTIONS;
m->to = parent;
m->parameter = 0;
- //Command::getInstance()->postMessage(m);
+ //Control::getInstance()->postMessage(m);
}*/