Skip to content

Commit

Permalink
Merge pull request kodi-pvr#114 from linknetx/update-interval
Browse files Browse the repository at this point in the history
Add PVR addon update interval setting
  • Loading branch information
dvblogic authored Mar 5, 2019
2 parents b636726 + a100a28 commit 92dce25
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 9 deletions.
1 change: 1 addition & 0 deletions pvr.dvblink/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[B]Version 4.7.2[/B]
Added: PVR_RECORDING.iChannelUid and PVR_RECORDING.channelType support
Added: Setting to change the addon update interval

[B]Version 4.7.1[/B]
Added: Option to change default 'Prevent duplicate episodes' setting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,69 @@ msgctxt "#30112"
msgid "Timeshift buffer path"
msgstr ""

#empty strings from id 30113 to 30199
#empty strings from id 30113 to 30119

msgctxt "#30120"
msgid "1 min"
msgstr ""

msgctxt "#30121"
msgid "2 min"
msgstr ""

msgctxt "#30122"
msgid "3 min"
msgstr ""

msgctxt "#30123"
msgid "4 min"
msgstr ""

msgctxt "#30124"
msgid "5 min"
msgstr ""

msgctxt "#30125"
msgid "6 min"
msgstr ""

msgctxt "#30126"
msgid "7 min"
msgstr ""

msgctxt "#30127"
msgid "8 min"
msgstr ""

msgctxt "#30128"
msgid "9 min"
msgstr ""

msgctxt "#30129"
msgid "10 min"
msgstr ""

msgctxt "#30130"
msgid "20 min"
msgstr ""

msgctxt "#30131"
msgid "30 min"
msgstr ""

msgctxt "#30132"
msgid "40 min"
msgstr ""

msgctxt "#30133"
msgid "50 min"
msgstr ""

msgctxt "#30134"
msgid "60 min"
msgstr ""

#empty strings from id 30135 to 30199

msgctxt "#30200"
msgid "Advanced"
Expand Down
1 change: 1 addition & 0 deletions pvr.dvblink/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<setting id="add_rec_episode_info" type="bool" label="30203" default="true" />
<setting id="group_recordings_by_series" type="bool" label="30204" default="true" />
<setting id="no_group_for_single_record" visible="eq(-1,true)" type="bool" label="32025" default="false" />
<setting id="default_update_interval" label="19071" type="enum" lvalues="30120|30121|30122|30123|30124|30125|30126|30127|30128|30129|30130|30131|30132|30133|30134" default="4" />
<setting id="default_record_show_type" label="812" type="enum" lvalues="32035|32036" default="1" />
</category>
</settings>
63 changes: 57 additions & 6 deletions src/DVBLinkClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void DVBLinkClient::get_server_caps()

DVBLinkClient::DVBLinkClient(CHelper_libXBMC_addon* xbmc, CHelper_libXBMC_pvr* pvr, CHelper_libKODI_guilib* gui,
std::string clientname, std::string hostname, long port, bool showinfomsg, std::string username,
std::string password, bool add_episode_to_rec_title, bool group_recordings_by_series, bool no_group_single_rec, int default_rec_show_type) :
std::string password, bool add_episode_to_rec_title, bool group_recordings_by_series, bool no_group_single_rec, int default_update_interval, int default_rec_show_type) :
connection_props_(hostname, port, username, password, clientname)
{
PVR = pvr;
Expand All @@ -130,6 +130,58 @@ DVBLinkClient::DVBLinkClient(CHelper_libXBMC_addon* xbmc, CHelper_libXBMC_pvr* p
no_group_single_rec_ = no_group_single_rec;
default_rec_show_type_ = default_rec_show_type;
timer_idx_seed_ = PVR_TIMER_NO_CLIENT_INDEX + 10; //arbitrary seed number, greater than

switch (default_update_interval)
{
case 0:
default_update_interval_sec_ = UPDATE_INTERVAL_60_SEC;
break;
case 1:
default_update_interval_sec_ = UPDATE_INTERVAL_120_SEC;
break;
case 2:
default_update_interval_sec_ = UPDATE_INTERVAL_180_SEC;
break;
case 3:
default_update_interval_sec_ = UPDATE_INTERVAL_240_SEC;
break;
case 4:
default_update_interval_sec_ = UPDATE_INTERVAL_300_SEC;
break;
case 5:
default_update_interval_sec_ = UPDATE_INTERVAL_360_SEC;
break;
case 6:
default_update_interval_sec_ = UPDATE_INTERVAL_420_SEC;
break;
case 7:
default_update_interval_sec_ = UPDATE_INTERVAL_480_SEC;
break;
case 8:
default_update_interval_sec_ = UPDATE_INTERVAL_540_SEC;
break;
case 9:
default_update_interval_sec_ = UPDATE_INTERVAL_600_SEC;
break;
case 10:
default_update_interval_sec_ = UPDATE_INTERVAL_1200_SEC;
break;
case 11:
default_update_interval_sec_ = UPDATE_INTERVAL_1800_SEC;
break;
case 12:
default_update_interval_sec_ = UPDATE_INTERVAL_2400_SEC;
break;
case 13:
default_update_interval_sec_ = UPDATE_INTERVAL_3000_SEC;
break;
case 14:
default_update_interval_sec_ = UPDATE_INTERVAL_3600_SEC;
break;
default:
default_update_interval_sec_ = UPDATE_INTERVAL_300_SEC;
break;
}

get_server_caps();

Expand Down Expand Up @@ -210,13 +262,12 @@ void *DVBLinkClient::Process()
{
XBMC->Log(LOG_DEBUG, "DVBLinkUpdateProcess:: thread started");

time_t update_period_default_sec = 300;
time_t update_period_timers_sec = 5;
time_t update_period_recordings_sec = 1;
time_t now;
time(&now);
time_t next_update_time_timers = now + update_period_default_sec;
time_t next_update_time_recordings = now + update_period_default_sec;
time_t next_update_time_timers = now + default_update_interval_sec_;
time_t next_update_time_recordings = now + default_update_interval_sec_;

while (m_updating)
{
Expand All @@ -235,7 +286,7 @@ void *DVBLinkClient::Process()
if (now > next_update_time_timers)
{
PVR->TriggerTimerUpdate();
next_update_time_timers = now + update_period_default_sec;
next_update_time_timers = now + default_update_interval_sec_;
}

if (m_update_timers_repeat)
Expand All @@ -253,7 +304,7 @@ void *DVBLinkClient::Process()
if (now > next_update_time_recordings)
{
PVR->TriggerRecordingUpdate();
next_update_time_recordings = now + update_period_default_sec;
next_update_time_recordings = now + default_update_interval_sec_;
}

Sleep(100);
Expand Down
20 changes: 19 additions & 1 deletion src/DVBLinkClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,23 @@ enum dvblink_client_rec_showtype_e
dcrs_record_all = 0, dcrs_record_new_only = 1
};

/* dvblink update interval values */
const int UPDATE_INTERVAL_60_SEC = 60;
const int UPDATE_INTERVAL_120_SEC = 120;
const int UPDATE_INTERVAL_180_SEC = 180;
const int UPDATE_INTERVAL_240_SEC = 240;
const int UPDATE_INTERVAL_300_SEC = 300;
const int UPDATE_INTERVAL_360_SEC = 360;
const int UPDATE_INTERVAL_420_SEC = 420;
const int UPDATE_INTERVAL_480_SEC = 480;
const int UPDATE_INTERVAL_540_SEC = 540;
const int UPDATE_INTERVAL_600_SEC = 600;
const int UPDATE_INTERVAL_1200_SEC = 1200;
const int UPDATE_INTERVAL_1800_SEC = 1800;
const int UPDATE_INTERVAL_2400_SEC = 2400;
const int UPDATE_INTERVAL_3000_SEC = 3000;
const int UPDATE_INTERVAL_3600_SEC = 3600;

struct schedule_desc
{
schedule_desc(unsigned int idx, int type, int margin_before, int margin_after)
Expand Down Expand Up @@ -127,7 +144,7 @@ class DVBLinkClient: public P8PLATFORM::CThread
public:
DVBLinkClient(ADDON::CHelper_libXBMC_addon* xbmc, CHelper_libXBMC_pvr* pvr, CHelper_libKODI_guilib* gui,
std::string clientname, std::string hostname, long port, bool showinfomsg, std::string username,
std::string password, bool add_episode_to_rec_title, bool group_recordings_by_series, bool no_group_single_rec, int default_rec_show_type);
std::string password, bool add_episode_to_rec_title, bool group_recordings_by_series, bool no_group_single_rec, int default_update_interval, int default_rec_show_type);
~DVBLinkClient(void);
const char *GetBackendVersion();
void GetAddonCapabilities(PVR_ADDON_CAPABILITIES* pCapabilities);
Expand Down Expand Up @@ -210,6 +227,7 @@ class DVBLinkClient: public P8PLATFORM::CThread
dvblinkremote::ChannelFavorites channel_favorites_;
std::map<std::string, int> inverse_channel_map_;
bool no_group_single_rec_;
time_t default_update_interval_sec_;
int default_rec_show_type_;
std::map<std::string, schedule_desc> schedule_map_;
std::map<std::string, unsigned int> timer_idx_map_;
Expand Down
16 changes: 15 additions & 1 deletion src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ bool g_bShowInfoMSG = DEFAULT_SHOWINFOMSG; ///< Show i
int g_iHeight = DEFAULT_HEIGHT; ///< Height of stream when using transcoding (0: autodetect)
int g_iWidth = DEFAULT_WIDTH; ///< Width of stream when using transcoding (0: autodetect)
int g_iBitrate = DEFAULT_BITRATE; ///< Bitrate of stream when using transcoding
int g_iDefaultUpdateInterval = DEFAULT_UPDATE_INTERVAL; ///< Default update interval
int g_iDefaultRecShowType = DEFAULT_RECORD_SHOW_TYPE; ///< Default record show type
std::string g_szAudiotrack = DEFAULT_AUDIOTRACK; ///< Audiotrack to include in stream when using transcoding
bool g_bUseTimeshift = DEFAULT_USETIMESHIFT; ///< Use timeshift
Expand Down Expand Up @@ -270,6 +271,14 @@ ADDON_STATUS ADDON_Create(void* hdl, void* props)
g_szAudiotrack = DEFAULT_AUDIOTRACK;
}

/* Read setting "default_update_interval" from settings.xml */
if (!XBMC->GetSetting("default_update_interval", &g_iDefaultUpdateInterval))
{
/* If setting is unknown fallback to defaults */
XBMC->Log(LOG_ERROR, "Couldn't get 'default_update_interval' setting, falling back to '4' (5 minutes) as default");
g_iDefaultUpdateInterval = DEFAULT_UPDATE_INTERVAL;
}

/* Read setting "default_record_show_type" from settings.xml */
if (!XBMC->GetSetting("default_record_show_type", &g_iDefaultRecShowType))
{
Expand All @@ -283,7 +292,7 @@ ADDON_STATUS ADDON_Create(void* hdl, void* props)
g_lPort);

dvblinkclient = new DVBLinkClient(XBMC, PVR, GUI, g_szClientname, g_szHostname, g_lPort, g_bShowInfoMSG, g_szUsername,
g_szPassword, g_bAddRecEpisode2title, g_bGroupRecBySeries, g_bNoGroupSingleRec, g_iDefaultRecShowType);
g_szPassword, g_bAddRecEpisode2title, g_bGroupRecBySeries, g_bNoGroupSingleRec, g_iDefaultUpdateInterval, g_iDefaultRecShowType);

if (dvblinkclient->GetStatus())
m_CurStatus = ADDON_STATUS_OK;
Expand Down Expand Up @@ -408,6 +417,11 @@ ADDON_STATUS ADDON_SetSetting(const char *settingName, const void *settingValue)
if (tmp_sAudiotrack != g_szAudiotrack)
return ADDON_STATUS_NEED_RESTART;
}
else if (str == "default_update_interval")
{
XBMC->Log(LOG_INFO, "Changed Setting 'default_update_interval' from %u to %u", g_iDefaultUpdateInterval, *(int*) settingValue);
g_iDefaultUpdateInterval = *(int*) settingValue;
}
else if (str == "default_record_show_type")
{
XBMC->Log(LOG_INFO, "Changed Setting 'default_record_show_type' from %u to %u", g_iDefaultRecShowType, *(int*) settingValue);
Expand Down
1 change: 1 addition & 0 deletions src/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@
#define DEFAULT_ADDRECEPISODE2TITLE true
#define DEFAULT_GROUPRECBYSERIES true
#define DEFAULT_NOGROUP_SINGLE_REC false
#define DEFAULT_UPDATE_INTERVAL 4
#define DEFAULT_RECORD_SHOW_TYPE 1

0 comments on commit 92dce25

Please sign in to comment.