diff options
author | Ulrich Eckhardt <uli@uli-eckhardt.de> | 2018-05-27 16:04:17 +0200 |
---|---|---|
committer | Ulrich Eckhardt <uli@uli-eckhardt.de> | 2018-05-27 16:04:17 +0200 |
commit | ee182db644001cf1f1325bf7f858dce1e056b4a9 (patch) | |
tree | bc45ad46abf4e90dddb5316c56775928ae70528e | |
parent | 73144cec5a92ab7cee0f1de729b1e38ec11d9605 (diff) | |
download | vdr-plugin-radio-ee182db644001cf1f1325bf7f858dce1e056b4a9.tar.gz vdr-plugin-radio-ee182db644001cf1f1325bf7f858dce1e056b4a9.tar.bz2 |
Split radio.c
Move classes in file radio.c into separate files.
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | menusetupradio.c | 117 | ||||
-rw-r--r-- | menusetupradio.h | 49 | ||||
-rw-r--r-- | radio.c | 295 | ||||
-rw-r--r-- | radiocheck.c | 168 | ||||
-rw-r--r-- | radiocheck.h | 27 |
6 files changed, 365 insertions, 294 deletions
@@ -61,7 +61,8 @@ DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' \ ### The object files (add further files here): OBJS = $(PLUGIN).o radioaudio.o radioskin.o radiotools.o radioepg.o inforx.o \ - radiotextosd.o rtplusosd.o rtpluslist.o rdsreceiver.o radioimage.o + radiotextosd.o rtplusosd.o rtpluslist.o rdsreceiver.o radioimage.o \ + menusetupradio.o radiocheck.o ### The main target: diff --git a/menusetupradio.c b/menusetupradio.c new file mode 100644 index 0000000..243aa64 --- /dev/null +++ b/menusetupradio.c @@ -0,0 +1,117 @@ +#include <vdr/plugin.h> +#include <vdr/status.h> +#include <vdr/config.h> +#include <vdr/interface.h> +#include <vdr/transfer.h> +#include <string> +#include "getopt.h" +#include "radioaudio.h" +#include "radiotools.h" +#include "radioepg.h" +#include "inforx.h" +#include "service.h" +#include "menusetupradio.h" + +// --- cMenuSetupRadio ------------------------------------------------------- + +extern int S_Activate; +extern int S_ExtInfo; +extern int S_HMEntry; + +cMenuSetupRadio::cMenuSetupRadio(void) +{ + T_RtFunc[0] = tr("Off"); + T_RtFunc[1] = tr("only Text"); + T_RtFunc[2] = tr("Text+TagInfo"); + T_RtOsdTags[0] = tr("Off"); + T_RtOsdTags[1] = tr("only, if some"); + T_RtOsdTags[2] = tr("always"); + T_RtOsdPos[0] = tr("Top"); + T_RtOsdPos[1] = tr("Bottom"); + T_RtOsdLoop[0] = tr("latest at Top"); + T_RtOsdLoop[1] = tr("latest at Bottom"); + T_RtBgColor[0] = T_RtFgColor[0] = tr ("Black"); + T_RtBgColor[1] = T_RtFgColor[1] = tr ("White"); + T_RtBgColor[2] = T_RtFgColor[2] = tr ("Red"); + T_RtBgColor[3] = T_RtFgColor[3] = tr ("Green"); + T_RtBgColor[4] = T_RtFgColor[4] = tr ("Yellow"); + T_RtBgColor[5] = T_RtFgColor[5] = tr ("Magenta"); + T_RtBgColor[6] = T_RtFgColor[6] = tr ("Blue"); + T_RtBgColor[7] = T_RtFgColor[7] = tr ("Cyan"); + T_RtBgColor[8] = T_RtFgColor[8] = tr ("Transparent"); + T_RtDisplay[0] = tr("Off"); + T_RtDisplay[1] = tr("about MainMenu"); + T_RtDisplay[2] = tr("Automatic"); + T_RtMsgItems[0] = tr("Off"); + T_RtMsgItems[1] = tr("only Taginfo"); + T_RtMsgItems[2] = tr("only Text"); + T_RtMsgItems[3] = tr("Text+TagInfo"); + T_RassText[0] = tr("Off"); + T_RassText[1] = tr("Rass only"); + T_RassText[2] = tr("Rass+Text mixed"); + + newS_Activate = S_Activate; + newS_StillPic = S_StillPic; + newS_Activate = S_Activate; + newS_RtFunc = S_RtFunc; + newS_RtOsdTitle = S_RtOsdTitle; + newS_RtOsdTags = S_RtOsdTags; + newS_RtOsdPos = S_RtOsdPos; + newS_RtOsdRows = S_RtOsdRows; + newS_RtOsdLoop = S_RtOsdLoop; + newS_RtOsdTO = S_RtOsdTO; + newS_RtSkinColor = S_RtSkinColor; + newS_RtBgCol = S_RtBgCol; + newS_RtBgTra = S_RtBgTra; + newS_RtFgCol = S_RtFgCol; + newS_RtDispl = (S_RtDispl > 2 ? 2 : S_RtDispl); + newS_RtMsgItems = S_RtMsgItems; + //newS_RtpMemNo = S_RtpMemNo; + newS_RassText = S_RassText; + newS_ExtInfo = S_ExtInfo; + + Add(new cMenuEditBoolItem( tr("Activate"), &newS_Activate)); + Add(new cMenuEditBoolItem( tr("Use StillPicture-Function"), &newS_StillPic)); + Add(new cMenuEditBoolItem( tr("Hide MainMenuEntry"), &newS_HMEntry)); + Add(new cMenuEditStraItem( tr("RDSText Function"), &newS_RtFunc, 3, T_RtFunc)); + Add(new cMenuEditStraItem( tr("RDSText OSD-Position"), &newS_RtOsdPos, 2, T_RtOsdPos)); + Add(new cMenuEditBoolItem( tr("RDSText OSD-Titlerow"), &newS_RtOsdTitle)); + Add(new cMenuEditIntItem( tr("RDSText OSD-Rows (1-5)"), &newS_RtOsdRows, 1, 5)); + Add(new cMenuEditStraItem( tr("RDSText OSD-Scrollmode"), &newS_RtOsdLoop, 2, T_RtOsdLoop)); + Add(new cMenuEditStraItem( tr("RDSText OSD-Taginfo"), &newS_RtOsdTags, 3, T_RtOsdTags)); + Add(new cMenuEditBoolItem( tr("RDSText OSD-Skincolors used"), &newS_RtSkinColor)); + if (newS_RtSkinColor == 0) { + Add(new cMenuEditStraItem( tr("RDSText OSD-Backgr.Color"), &newS_RtBgCol, 9, T_RtBgColor)); + Add(new cMenuEditIntItem( tr("RDSText OSD-Backgr.Transp."), &newS_RtBgTra, 1, 255)); + Add(new cMenuEditStraItem( tr("RDSText OSD-Foregr.Color"), &newS_RtFgCol, 8, T_RtFgColor)); + } + Add(new cMenuEditIntItem( tr("RDSText OSD-Timeout (0-1440 min)"), &newS_RtOsdTO, 0, 1440)); + Add(new cMenuEditStraItem( tr("RDSText OSD-Display"), &newS_RtDispl, 3, T_RtDisplay)); + Add(new cMenuEditStraItem( tr("RDSText StatusMsg (lcdproc & co)"), &newS_RtMsgItems, 4, T_RtMsgItems)); + //Add(new cMenuEditIntItem( tr("RDSplus Memorynumber (10-99)"), &newS_RtpMemNo, 10, 99)); + Add(new cMenuEditStraItem( tr("RDSText Rass-Function"), &newS_RassText, 3, T_RassText)); + Add(new cMenuEditBoolItem( tr("External Info-Request"), &newS_ExtInfo)); +} + +void cMenuSetupRadio::Store(void) +{ + SetupStore("Activate", S_Activate = newS_Activate); + SetupStore("UseStillPic", S_StillPic = newS_StillPic); + SetupStore("HideMenuEntry", S_HMEntry = newS_HMEntry); + SetupStore("RDSText-Function", S_RtFunc = newS_RtFunc); + SetupStore("RDSText-OsdTitle", S_RtOsdTitle = newS_RtOsdTitle); + SetupStore("RDSText-OsdTags", S_RtOsdTags = newS_RtOsdTags); + SetupStore("RDSText-OsdPosition", S_RtOsdPos = newS_RtOsdPos); + SetupStore("RDSText-OsdRows", S_RtOsdRows = newS_RtOsdRows); + SetupStore("RDSText-OsdLooping", S_RtOsdLoop = newS_RtOsdLoop); + SetupStore("RDSText-OsdSkinColor", S_RtSkinColor = newS_RtSkinColor); + SetupStore("RDSText-OsdBackgrColor", S_RtBgCol = newS_RtBgCol); + SetupStore("RDSText-OsdBackgrTrans", S_RtBgTra = newS_RtBgTra); + SetupStore("RDSText-OsdForegrColor", S_RtFgCol = newS_RtFgCol); + SetupStore("RDSText-OsdTimeout", S_RtOsdTO = newS_RtOsdTO); + SetupStore("RDSText-Display", S_RtDispl = newS_RtDispl); + SetupStore("RDSText-MsgItems", S_RtMsgItems = newS_RtMsgItems); + //SetupStore("RDSplus-MemNumber", S_RtpMemNo = newS_RtpMemNo); + SetupStore("RDSText-Rass", S_RassText = newS_RassText); + SetupStore("ExtInfo-Req", S_ExtInfo = newS_ExtInfo); +} diff --git a/menusetupradio.h b/menusetupradio.h new file mode 100644 index 0000000..d6ac7ce --- /dev/null +++ b/menusetupradio.h @@ -0,0 +1,49 @@ +/* + * menusetupradio.h + * + * Created on: 27.05.2018 + * Author: uli + */ + +#ifndef MENUSETUPRADIO_H_ +#define MENUSETUPRADIO_H_ + +#include <vdr/plugin.h> + +class cMenuSetupRadio : public cMenuSetupPage { +private: + int newS_Activate; + int newS_StillPic; + int newS_HMEntry; + int newS_RtFunc; + int newS_RtOsdTitle; + int newS_RtOsdTags; + int newS_RtOsdPos; + int newS_RtOsdRows; + int newS_RtOsdLoop; + int newS_RtOsdTO; + int newS_RtSkinColor; + int newS_RtBgCol; + int newS_RtBgTra; + int newS_RtFgCol; + int newS_RtDispl; + int newS_RtMsgItems; + //int newS_RtpMemNo; + int newS_RassText; + int newS_ExtInfo; + const char *T_RtFunc[3]; + const char *T_RtOsdTags[3]; + const char *T_RtOsdPos[2]; + const char *T_RtOsdLoop[2]; + const char *T_RtBgColor[9]; + const char *T_RtFgColor[9]; + const char *T_RtDisplay[3]; + const char *T_RtMsgItems[4]; + const char *T_RassText[3]; +protected: + virtual void Store(void); +public: + cMenuSetupRadio(void); +}; + +#endif /* MENUSETUPRADIO_H_ */ @@ -17,6 +17,8 @@ #include "radioepg.h" #include "inforx.h" #include "service.h" +#include "menusetupradio.h" +#include "radiocheck.h" #if VDRVERSNUM < 10737 #error This version of radio-plugin requires vdr >= 1.7.37 @@ -73,299 +75,6 @@ int IsRadioOrReplay; bool DoInfoReq = false, InfoRequest = false; int InfoTimeout = 3; -// --- cRadioCheck ------------------------------------------------------- - -class cRadioCheck: public cThread { -private: - static cRadioCheck *RadioCheck; -protected: - virtual void Action(void); - void Stop(void); -public: - cRadioCheck(void); - virtual ~cRadioCheck(); - static void Init(void); - static void Exit(void); -}; - -cRadioCheck *cRadioCheck::RadioCheck = NULL; - -cRadioCheck::cRadioCheck(void) -: cThread("radiocheck") -{ - IsRadioOrReplay = 0; -} - -cRadioCheck::~cRadioCheck() { - if (Running()) { - Stop(); - } -} - -void cRadioCheck::Init(void) { - if (RadioCheck == NULL) { - RadioCheck = new cRadioCheck; - RadioCheck->Start(); - } -} - -void cRadioCheck::Exit(void) { - if (RadioCheck != NULL) { - RadioCheck->Stop(); - DELETENULL(RadioCheck); - } -} - -void cRadioCheck::Stop(void) { - Cancel(10); -} - -void cRadioCheck::Action(void) -{ - if ((S_Verbose & 0x0f) >= 2) { - printf("vdr-radio: background-checking starts\n"); - } - - while (Running()) { - cCondWait::SleepMs(2000); - - // check Live-Radio - if ((IsRadioOrReplay == 1) && (chan != NULL)) { - if (chan->Vpid()) { - isyslog("radio: channnel '%s' got Vpid= %d", chan->Name(), - chan->Vpid()); - IsRadioOrReplay = 0; -#if VDRVERSNUM >= 20300 - LOCK_CHANNELS_READ - Channels->SwitchTo(cDevice::CurrentChannel()); -#else - Channels.SwitchTo(cDevice::CurrentChannel()); -#endif - //cDevice::PrimaryDevice()->SwitchChannel(chan, true); - } else { - if ((InfoTimeout -= 2) <= 0) { - InfoTimeout = 20; - int chtid = chan->Tid(); - // Kanal-EPG PresentEvent - if (chan->Apid(0) > 0 - && (chtid == PREMIERERADIO_TID - || chtid == KDRADIO_TID - || chtid == UMRADIO_TID1 - || chtid == UMRADIO_TID2 - || chtid == UMRADIO_TID3 - || chtid == UMRADIO_TID4 - || chtid == UMRADIO_TID5)) { -#if VDRVERSNUM >= 20300 - LOCK_SCHEDULES_READ - static cStateKey SchedulesStateKey; - const cSchedules *scheds = cSchedules::GetSchedulesRead( - SchedulesStateKey); -#else - cSchedulesLock schedLock; - const cSchedules *scheds = cSchedules::Schedules(schedLock); -#endif - if (scheds != NULL) { - const cSchedule *sched = scheds->GetSchedule( - chan->GetChannelID()); - if (sched != NULL) { - const cEvent *present = - sched->GetPresentEvent(); - if (present != NULL) { - if (chtid == PREMIERERADIO_TID) { // Premiere - InfoTimeout = epg_premiere( - present->Title(), - present->Description(), - present->StartTime(), - present->EndTime()); - } - else if (chtid == KDRADIO_TID) {// Kabel Deutschland - InfoTimeout = epg_kdg( - present->Description(), - present->StartTime(), - present->EndTime()); - } - else { - // Unity Media Kabel - InfoTimeout = epg_unitymedia( - present->Description(), - present->StartTime(), - present->EndTime()); - } - InfoRequest = true; - } - else { - dsyslog("radio: no event.present (Tid= %d, Apid= %d)", - chtid, chan->Apid(0)); - } - } - else { - dsyslog("radio: no schedule (Tid= %d, Apid= %d)", - chtid, chan->Apid(0)); - } - } - } - // Artist/Title with external script? - else if (chan->Apid(0) > 0 && DoInfoReq) { - InfoTimeout = info_request(chtid, chan->Apid(0)); - InfoRequest = (InfoTimeout > 0); - } - } - } - } - - // temp. OSD-CloseTimeout - (RT_OsdTOTemp > 0) ? RT_OsdTOTemp -= 2 : RT_OsdTOTemp = 0; // in sec like this cycletime - - // Radiotext-Autodisplay - if ((S_RtDispl == 2) && (RT_Info >= 0) && !RT_OsdTO - && (RT_OsdTOTemp == 0) && RT_ReOpen && !Skins.IsOpen() - && !cOsd::IsOpen()) { - cRemote::CallPlugin("radio"); - } - } - - if ((S_Verbose & 0x0f) >= 2) { - printf("vdr-radio: background-checking ends\n"); - } -} - - -// --- cMenuSetupRadio ------------------------------------------------------- - -class cMenuSetupRadio : public cMenuSetupPage { -private: - int newS_Activate; - int newS_StillPic; - int newS_HMEntry; - int newS_RtFunc; - int newS_RtOsdTitle; - int newS_RtOsdTags; - int newS_RtOsdPos; - int newS_RtOsdRows; - int newS_RtOsdLoop; - int newS_RtOsdTO; - int newS_RtSkinColor; - int newS_RtBgCol; - int newS_RtBgTra; - int newS_RtFgCol; - int newS_RtDispl; - int newS_RtMsgItems; - //int newS_RtpMemNo; - int newS_RassText; - int newS_ExtInfo; - const char *T_RtFunc[3]; - const char *T_RtOsdTags[3]; - const char *T_RtOsdPos[2]; - const char *T_RtOsdLoop[2]; - const char *T_RtBgColor[9]; - const char *T_RtFgColor[9]; - const char *T_RtDisplay[3]; - const char *T_RtMsgItems[4]; - const char *T_RassText[3]; -protected: - virtual void Store(void); -public: - cMenuSetupRadio(void); -}; - -cMenuSetupRadio::cMenuSetupRadio(void) -{ - T_RtFunc[0] = tr("Off"); - T_RtFunc[1] = tr("only Text"); - T_RtFunc[2] = tr("Text+TagInfo"); - T_RtOsdTags[0] = tr("Off"); - T_RtOsdTags[1] = tr("only, if some"); - T_RtOsdTags[2] = tr("always"); - T_RtOsdPos[0] = tr("Top"); - T_RtOsdPos[1] = tr("Bottom"); - T_RtOsdLoop[0] = tr("latest at Top"); - T_RtOsdLoop[1] = tr("latest at Bottom"); - T_RtBgColor[0] = T_RtFgColor[0] = tr ("Black"); - T_RtBgColor[1] = T_RtFgColor[1] = tr ("White"); - T_RtBgColor[2] = T_RtFgColor[2] = tr ("Red"); - T_RtBgColor[3] = T_RtFgColor[3] = tr ("Green"); - T_RtBgColor[4] = T_RtFgColor[4] = tr ("Yellow"); - T_RtBgColor[5] = T_RtFgColor[5] = tr ("Magenta"); - T_RtBgColor[6] = T_RtFgColor[6] = tr ("Blue"); - T_RtBgColor[7] = T_RtFgColor[7] = tr ("Cyan"); - T_RtBgColor[8] = T_RtFgColor[8] = tr ("Transparent"); - T_RtDisplay[0] = tr("Off"); - T_RtDisplay[1] = tr("about MainMenu"); - T_RtDisplay[2] = tr("Automatic"); - T_RtMsgItems[0] = tr("Off"); - T_RtMsgItems[1] = tr("only Taginfo"); - T_RtMsgItems[2] = tr("only Text"); - T_RtMsgItems[3] = tr("Text+TagInfo"); - T_RassText[0] = tr("Off"); - T_RassText[1] = tr("Rass only"); - T_RassText[2] = tr("Rass+Text mixed"); - - newS_Activate = S_Activate; - newS_StillPic = S_StillPic; - newS_Activate = S_Activate; - newS_RtFunc = S_RtFunc; - newS_RtOsdTitle = S_RtOsdTitle; - newS_RtOsdTags = S_RtOsdTags; - newS_RtOsdPos = S_RtOsdPos; - newS_RtOsdRows = S_RtOsdRows; - newS_RtOsdLoop = S_RtOsdLoop; - newS_RtOsdTO = S_RtOsdTO; - newS_RtSkinColor = S_RtSkinColor; - newS_RtBgCol = S_RtBgCol; - newS_RtBgTra = S_RtBgTra; - newS_RtFgCol = S_RtFgCol; - newS_RtDispl = (S_RtDispl > 2 ? 2 : S_RtDispl); - newS_RtMsgItems = S_RtMsgItems; - //newS_RtpMemNo = S_RtpMemNo; - newS_RassText = S_RassText; - newS_ExtInfo = S_ExtInfo; - - Add(new cMenuEditBoolItem( tr("Activate"), &newS_Activate)); - Add(new cMenuEditBoolItem( tr("Use StillPicture-Function"), &newS_StillPic)); - Add(new cMenuEditBoolItem( tr("Hide MainMenuEntry"), &newS_HMEntry)); - Add(new cMenuEditStraItem( tr("RDSText Function"), &newS_RtFunc, 3, T_RtFunc)); - Add(new cMenuEditStraItem( tr("RDSText OSD-Position"), &newS_RtOsdPos, 2, T_RtOsdPos)); - Add(new cMenuEditBoolItem( tr("RDSText OSD-Titlerow"), &newS_RtOsdTitle)); - Add(new cMenuEditIntItem( tr("RDSText OSD-Rows (1-5)"), &newS_RtOsdRows, 1, 5)); - Add(new cMenuEditStraItem( tr("RDSText OSD-Scrollmode"), &newS_RtOsdLoop, 2, T_RtOsdLoop)); - Add(new cMenuEditStraItem( tr("RDSText OSD-Taginfo"), &newS_RtOsdTags, 3, T_RtOsdTags)); - Add(new cMenuEditBoolItem( tr("RDSText OSD-Skincolors used"), &newS_RtSkinColor)); - if (newS_RtSkinColor == 0) { - Add(new cMenuEditStraItem( tr("RDSText OSD-Backgr.Color"), &newS_RtBgCol, 9, T_RtBgColor)); - Add(new cMenuEditIntItem( tr("RDSText OSD-Backgr.Transp."), &newS_RtBgTra, 1, 255)); - Add(new cMenuEditStraItem( tr("RDSText OSD-Foregr.Color"), &newS_RtFgCol, 8, T_RtFgColor)); - } - Add(new cMenuEditIntItem( tr("RDSText OSD-Timeout (0-1440 min)"), &newS_RtOsdTO, 0, 1440)); - Add(new cMenuEditStraItem( tr("RDSText OSD-Display"), &newS_RtDispl, 3, T_RtDisplay)); - Add(new cMenuEditStraItem( tr("RDSText StatusMsg (lcdproc & co)"), &newS_RtMsgItems, 4, T_RtMsgItems)); - //Add(new cMenuEditIntItem( tr("RDSplus Memorynumber (10-99)"), &newS_RtpMemNo, 10, 99)); - Add(new cMenuEditStraItem( tr("RDSText Rass-Function"), &newS_RassText, 3, T_RassText)); - Add(new cMenuEditBoolItem( tr("External Info-Request"), &newS_ExtInfo)); -} - -void cMenuSetupRadio::Store(void) -{ - SetupStore("Activate", S_Activate = newS_Activate); - SetupStore("UseStillPic", S_StillPic = newS_StillPic); - SetupStore("HideMenuEntry", S_HMEntry = newS_HMEntry); - SetupStore("RDSText-Function", S_RtFunc = newS_RtFunc); - SetupStore("RDSText-OsdTitle", S_RtOsdTitle = newS_RtOsdTitle); - SetupStore("RDSText-OsdTags", S_RtOsdTags = newS_RtOsdTags); - SetupStore("RDSText-OsdPosition", S_RtOsdPos = newS_RtOsdPos); - SetupStore("RDSText-OsdRows", S_RtOsdRows = newS_RtOsdRows); - SetupStore("RDSText-OsdLooping", S_RtOsdLoop = newS_RtOsdLoop); - SetupStore("RDSText-OsdSkinColor", S_RtSkinColor = newS_RtSkinColor); - SetupStore("RDSText-OsdBackgrColor", S_RtBgCol = newS_RtBgCol); - SetupStore("RDSText-OsdBackgrTrans", S_RtBgTra = newS_RtBgTra); - SetupStore("RDSText-OsdForegrColor", S_RtFgCol = newS_RtFgCol); - SetupStore("RDSText-OsdTimeout", S_RtOsdTO = newS_RtOsdTO); - SetupStore("RDSText-Display", S_RtDispl = newS_RtDispl); - SetupStore("RDSText-MsgItems", S_RtMsgItems = newS_RtMsgItems); - //SetupStore("RDSplus-MemNumber", S_RtpMemNo = newS_RtpMemNo); - SetupStore("RDSText-Rass", S_RassText = newS_RassText); - SetupStore("ExtInfo-Req", S_ExtInfo = newS_ExtInfo); -} - // --- cPluginRadio ------------------------------------------------------- diff --git a/radiocheck.c b/radiocheck.c new file mode 100644 index 0000000..d0a8d2e --- /dev/null +++ b/radiocheck.c @@ -0,0 +1,168 @@ +/* + * radiocheck.c + * + * Created on: 27.05.2018 + * Author: uli + */ + +// --- cRadioCheck ------------------------------------------------------- + +#include <vdr/plugin.h> +#include <vdr/status.h> +#include <vdr/config.h> +#include <vdr/interface.h> +#include <vdr/transfer.h> +#include "radiocheck.h" +#include "radioepg.h" +#include "inforx.h" + +extern int IsRadioOrReplay; +extern int S_Verbose; +extern int InfoTimeout; + +extern bool DoInfoReq, InfoRequest; +extern const cChannel *chan; + +cRadioCheck *cRadioCheck::RadioCheck = NULL; + +cRadioCheck::cRadioCheck(void) +: cThread("radiocheck") +{ + IsRadioOrReplay = 0; +} + +cRadioCheck::~cRadioCheck() { + if (Running()) { + Stop(); + } +} + +void cRadioCheck::Init(void) { + if (RadioCheck == NULL) { + RadioCheck = new cRadioCheck; + RadioCheck->Start(); + } +} + +void cRadioCheck::Exit(void) { + if (RadioCheck != NULL) { + RadioCheck->Stop(); + DELETENULL(RadioCheck); + } +} + +void cRadioCheck::Stop(void) { + Cancel(10); +} + +void cRadioCheck::Action(void) +{ + if ((S_Verbose & 0x0f) >= 2) { + printf("vdr-radio: background-checking starts\n"); + } + + while (Running()) { + cCondWait::SleepMs(2000); + + // check Live-Radio + if ((IsRadioOrReplay == 1) && (chan != NULL)) { + if (chan->Vpid()) { + isyslog("radio: channnel '%s' got Vpid= %d", chan->Name(), + chan->Vpid()); + IsRadioOrReplay = 0; +#if VDRVERSNUM >= 20300 + LOCK_CHANNELS_READ + Channels->SwitchTo(cDevice::CurrentChannel()); +#else + Channels.SwitchTo(cDevice::CurrentChannel()); +#endif + //cDevice::PrimaryDevice()->SwitchChannel(chan, true); + } else { + if ((InfoTimeout -= 2) <= 0) { + InfoTimeout = 20; + int chtid = chan->Tid(); + // Kanal-EPG PresentEvent + if (chan->Apid(0) > 0 + && (chtid == PREMIERERADIO_TID + || chtid == KDRADIO_TID + || chtid == UMRADIO_TID1 + || chtid == UMRADIO_TID2 + || chtid == UMRADIO_TID3 + || chtid == UMRADIO_TID4 + || chtid == UMRADIO_TID5)) { +#if VDRVERSNUM >= 20300 + LOCK_SCHEDULES_READ + static cStateKey SchedulesStateKey; + const cSchedules *scheds = cSchedules::GetSchedulesRead( + SchedulesStateKey); +#else + cSchedulesLock schedLock; + const cSchedules *scheds = cSchedules::Schedules(schedLock); +#endif + if (scheds != NULL) { + const cSchedule *sched = scheds->GetSchedule( + chan->GetChannelID()); + if (sched != NULL) { + const cEvent *present = + sched->GetPresentEvent(); + if (present != NULL) { + if (chtid == PREMIERERADIO_TID) { // Premiere + InfoTimeout = epg_premiere( + present->Title(), + present->Description(), + present->StartTime(), + present->EndTime()); + } + else if (chtid == KDRADIO_TID) {// Kabel Deutschland + InfoTimeout = epg_kdg( + present->Description(), + present->StartTime(), + present->EndTime()); + } + else { + // Unity Media Kabel + InfoTimeout = epg_unitymedia( + present->Description(), + present->StartTime(), + present->EndTime()); + } + InfoRequest = true; + } + else { + dsyslog("radio: no event.present (Tid= %d, Apid= %d)", + chtid, chan->Apid(0)); + } + } + else { + dsyslog("radio: no schedule (Tid= %d, Apid= %d)", + chtid, chan->Apid(0)); + } + } + } + // Artist/Title with external script? + else if (chan->Apid(0) > 0 && DoInfoReq) { + InfoTimeout = info_request(chtid, chan->Apid(0)); + InfoRequest = (InfoTimeout > 0); + } + } + } + } + + // temp. OSD-CloseTimeout + (RT_OsdTOTemp > 0) ? RT_OsdTOTemp -= 2 : RT_OsdTOTemp = 0; // in sec like this cycletime + + // Radiotext-Autodisplay + if ((S_RtDispl == 2) && (RT_Info >= 0) && !RT_OsdTO + && (RT_OsdTOTemp == 0) && RT_ReOpen && !Skins.IsOpen() + && !cOsd::IsOpen()) { + cRemote::CallPlugin("radio"); + } + } + + if ((S_Verbose & 0x0f) >= 2) { + printf("vdr-radio: background-checking ends\n"); + } +} + + + diff --git a/radiocheck.h b/radiocheck.h new file mode 100644 index 0000000..5253842 --- /dev/null +++ b/radiocheck.h @@ -0,0 +1,27 @@ +/* + * radiocheck.h + * + * Created on: 27.05.2018 + * Author: uli + */ + +#ifndef RADIOCHECK_H_ +#define RADIOCHECK_H_ + +#include <vdr/plugin.h> + +class cRadioCheck: public cThread { +private: + static cRadioCheck *RadioCheck; +protected: + virtual void Action(void); + void Stop(void); +public: + cRadioCheck(void); + virtual ~cRadioCheck(); + static void Init(void); + static void Exit(void); +}; + + +#endif /* RADIOCHECK_H_ */ |