From b62773872c3a71cf3afaa5577ce5077df4ae7886 Mon Sep 17 00:00:00 2001 From: ksooo <3226626+ksooo@users.noreply.github.com> Date: Wed, 6 Nov 2024 15:44:13 +0100 Subject: [PATCH] Add support for Autorec and Timerec properties "Start after" and "Start before" --- pvr.hts/addon.xml.in | 2 +- pvr.hts/changelog.txt | 3 + pvr.hts/resources/instance-settings.xml | 24 ----- .../resource.language.en_gb/strings.po | 24 ++--- src/Tvheadend.cpp | 19 +--- src/tvheadend/AutoRecordings.cpp | 81 +-------------- src/tvheadend/CustomTimerProperties.cpp | 98 +++++++++++++++++++ src/tvheadend/CustomTimerProperties.h | 10 ++ src/tvheadend/InstanceSettings.cpp | 15 --- src/tvheadend/InstanceSettings.h | 6 -- src/tvheadend/TimeRecordings.cpp | 12 +-- src/tvheadend/entity/AutoRecording.cpp | 64 +----------- src/tvheadend/entity/AutoRecording.h | 15 --- src/tvheadend/entity/SeriesRecordingBase.cpp | 18 ---- src/tvheadend/entity/SeriesRecordingBase.h | 17 +++- src/tvheadend/entity/TimeRecording.cpp | 29 +----- src/tvheadend/entity/TimeRecording.h | 12 --- 17 files changed, 144 insertions(+), 305 deletions(-) diff --git a/pvr.hts/addon.xml.in b/pvr.hts/addon.xml.in index 40f1e04f..fe75471b 100644 --- a/pvr.hts/addon.xml.in +++ b/pvr.hts/addon.xml.in @@ -1,7 +1,7 @@ @ADDON_DEPENDS@ diff --git a/pvr.hts/changelog.txt b/pvr.hts/changelog.txt index f6aaf04f..125fb8c1 100644 --- a/pvr.hts/changelog.txt +++ b/pvr.hts/changelog.txt @@ -1,3 +1,6 @@ +v22.6.0 +- Add support for Autorec and Timerec properties "Start after" and "Start before" + v22.5.0 - PVR Add-on API v9.2.0 - Add support for multiple recorded streams at a time (used by Kodi for thumbnail extraction) diff --git a/pvr.hts/resources/instance-settings.xml b/pvr.hts/resources/instance-settings.xml index 68159c5c..5e954211 100644 --- a/pvr.hts/resources/instance-settings.xml +++ b/pvr.hts/resources/instance-settings.xml @@ -166,30 +166,6 @@ - - 0 - 0 - - - - - - - - - - 0 - 15 - - 0 - 5 - 120 - - - 1 - - - 0 false diff --git a/pvr.hts/resources/language/resource.language.en_gb/strings.po b/pvr.hts/resources/language/resource.language.en_gb/strings.po index a2face4a..2c0ee386 100644 --- a/pvr.hts/resources/language/resource.language.en_gb/strings.po +++ b/pvr.hts/resources/language/resource.language.en_gb/strings.po @@ -88,22 +88,6 @@ msgctxt "#30050" msgid "Auto recordings" msgstr "" -msgctxt "#30051" -msgid "Start time window calculation" -msgstr "" - -msgctxt "#30052" -msgid "Strict (start time + end time)" -msgstr "" - -msgctxt "#30053" -msgid "Relaxed (start time +/- margin)" -msgstr "" - -msgctxt "#30054" -msgid "Maximum start time margin (minutes)" -msgstr "" - msgctxt "#30055" msgid "Default priority" msgstr "" @@ -516,3 +500,11 @@ msgstr "" msgctxt "#30605" msgid "(Default profile)" msgstr "" + +msgctxt "#30606" +msgid "Start after" +msgstr "" + +msgctxt "#30607" +msgid "Start before" +msgstr "" diff --git a/src/Tvheadend.cpp b/src/Tvheadend.cpp index 6f648f76..7e384153 100644 --- a/src/Tvheadend.cpp +++ b/src/Tvheadend.cpp @@ -1093,7 +1093,6 @@ PVR_ERROR CTvheadend::GetTimerTypes(std::vector& type /* Attributes. */ PVR_TIMER_TYPE_IS_MANUAL | PVR_TIMER_TYPE_IS_REPEATING | PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE | PVR_TIMER_TYPE_SUPPORTS_CHANNELS | - PVR_TIMER_TYPE_SUPPORTS_START_TIME | PVR_TIMER_TYPE_SUPPORTS_END_TIME | PVR_TIMER_TYPE_SUPPORTS_WEEKDAYS | PVR_TIMER_TYPE_SUPPORTS_PRIORITY | PVR_TIMER_TYPE_SUPPORTS_LIFETIME | PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS, /* Let Kodi generate the description. */ @@ -1113,19 +1112,11 @@ PVR_ERROR CTvheadend::GetTimerTypes(std::vector& type { unsigned int TIMER_REPEATING_SERIESLINK_ATTRIBS = PVR_TIMER_TYPE_IS_REPEATING | PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE | - PVR_TIMER_TYPE_SUPPORTS_CHANNELS | PVR_TIMER_TYPE_SUPPORTS_START_TIME | - PVR_TIMER_TYPE_SUPPORTS_START_ANYTIME | PVR_TIMER_TYPE_SUPPORTS_WEEKDAYS | + PVR_TIMER_TYPE_SUPPORTS_CHANNELS | PVR_TIMER_TYPE_SUPPORTS_WEEKDAYS | PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN | PVR_TIMER_TYPE_SUPPORTS_PRIORITY | PVR_TIMER_TYPE_SUPPORTS_LIFETIME | PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS | PVR_TIMER_TYPE_SUPPORTS_ANY_CHANNEL | PVR_TIMER_TYPE_REQUIRES_EPG_SERIESLINK_ON_CREATE; - if (!m_settings->GetAutorecApproxTime()) - { - /* We need the end time to represent the end of the tvh starting window */ - TIMER_REPEATING_SERIESLINK_ATTRIBS |= PVR_TIMER_TYPE_SUPPORTS_END_TIME; - TIMER_REPEATING_SERIESLINK_ATTRIBS |= PVR_TIMER_TYPE_SUPPORTS_END_ANYTIME; - } - /* Repeating epg based - series link autorec */ types.emplace_back(TimerType( /* Settings */ @@ -1147,19 +1138,11 @@ PVR_ERROR CTvheadend::GetTimerTypes(std::vector& type unsigned int TIMER_REPEATING_EPG_ATTRIBS = PVR_TIMER_TYPE_IS_REPEATING | PVR_TIMER_TYPE_SUPPORTS_ENABLE_DISABLE | PVR_TIMER_TYPE_SUPPORTS_TITLE_EPG_MATCH | PVR_TIMER_TYPE_SUPPORTS_CHANNELS | - PVR_TIMER_TYPE_SUPPORTS_START_TIME | PVR_TIMER_TYPE_SUPPORTS_START_ANYTIME | PVR_TIMER_TYPE_SUPPORTS_WEEKDAYS | PVR_TIMER_TYPE_SUPPORTS_START_END_MARGIN | PVR_TIMER_TYPE_SUPPORTS_PRIORITY | PVR_TIMER_TYPE_SUPPORTS_LIFETIME | PVR_TIMER_TYPE_SUPPORTS_RECORDING_FOLDERS | PVR_TIMER_TYPE_SUPPORTS_ANY_CHANNEL | PVR_TIMER_TYPE_SUPPORTS_FULLTEXT_EPG_MATCH | PVR_TIMER_TYPE_SUPPORTS_RECORD_ONLY_NEW_EPISODES; - if (!m_settings->GetAutorecApproxTime()) - { - /* We need the end time to represent the end of the tvh starting window */ - TIMER_REPEATING_EPG_ATTRIBS |= PVR_TIMER_TYPE_SUPPORTS_END_TIME; - TIMER_REPEATING_EPG_ATTRIBS |= PVR_TIMER_TYPE_SUPPORTS_END_ANYTIME; - } - /* Repeating epg based - autorec */ types.emplace_back(TimerType( /* Settings */ diff --git a/src/tvheadend/AutoRecordings.cpp b/src/tvheadend/AutoRecordings.cpp index 3af42147..a3ceccef 100644 --- a/src/tvheadend/AutoRecordings.cpp +++ b/src/tvheadend/AutoRecordings.cpp @@ -28,7 +28,8 @@ AutoRecordings::AutoRecordings(const std::shared_ptr& settings Profiles& dvrConfigs) : m_settings(settings), m_conn(conn), - m_customTimerProps({CUSTOM_PROP_ID_DVR_CONFIGURATION, CUSTOM_PROP_ID_AUTOREC_BROADCASTTYPE, + m_customTimerProps({CUSTOM_PROP_ID_SERIESREC_START, CUSTOM_PROP_ID_SERIESREC_STARTWINDOW, + CUSTOM_PROP_ID_AUTOREC_BROADCASTTYPE, CUSTOM_PROP_ID_DVR_CONFIGURATION, CUSTOM_PROP_ID_DVR_COMMENT}, conn, dvrConfigs) @@ -69,23 +70,6 @@ void AutoRecordings::GetAutorecTimers(std::vector& timers tmr.SetClientIndex(rec.second.GetId()); tmr.SetClientChannelUid((rec.second.GetChannel() > 0) ? rec.second.GetChannel() : PVR_TIMER_ANY_CHANNEL); - tmr.SetStartTime(rec.second.GetStart()); - tmr.SetEndTime(rec.second.GetStop()); - if (tmr.GetStartTime() == 0) - tmr.SetStartAnyTime(true); - if (tmr.GetEndTime() == 0) - tmr.SetEndAnyTime(true); - - if (!tmr.GetStartAnyTime() && tmr.GetEndAnyTime()) - tmr.SetEndTime(tmr.GetStartTime() + 60 * 60); // Nominal 1 hour duration - if (tmr.GetStartAnyTime() && !tmr.GetEndAnyTime()) - tmr.SetStartTime(tmr.GetEndTime() - 60 * 60); // Nominal 1 hour duration - if (tmr.GetStartAnyTime() && tmr.GetEndAnyTime()) - { - tmr.SetStartTime(std::time(nullptr)); // now - tmr.SetEndTime(tmr.GetStartTime() + 60 * 60); // Nominal 1 hour duration - } - if (rec.second.GetName().empty()) // timers created on backend may not contain a name tmr.SetTitle(rec.second.GetTitle()); else @@ -211,66 +195,6 @@ PVR_ERROR AutoRecordings::SendAutorecAddOrUpdate(const kodi::addon::PVRTimer& ti if (timer.GetDirectory() != "/") htsmsg_add_str(m, "directory", timer.GetDirectory().c_str()); - - /* bAutorecApproxTime enabled: => start time in kodi = approximate start time in tvh */ - /* => 'approximate' = starting window / 2 */ - /* */ - /* bAutorecApproxTime disabled: => start time in kodi = begin of starting window in tvh */ - /* => end time in kodi = end of starting window in tvh */ - if (m_settings->GetAutorecApproxTime()) - { - /* Not sending causes server to set start and startWindow to any time */ - if (timer.GetStartTime() > 0 && !timer.GetStartAnyTime()) - { - time_t startTime = timer.GetStartTime(); - struct tm* tm_start = std::localtime(&startTime); - int32_t startWindowBegin = - tm_start->tm_hour * 60 + tm_start->tm_min - m_settings->GetAutorecMaxDiff(); - int32_t startWindowEnd = - tm_start->tm_hour * 60 + tm_start->tm_min + m_settings->GetAutorecMaxDiff(); - - /* Past midnight correction */ - if (startWindowBegin < 0) - startWindowBegin += (24 * 60); - if (startWindowEnd > (24 * 60)) - startWindowEnd -= (24 * 60); - - htsmsg_add_s32(m, "start", startWindowBegin); - htsmsg_add_s32(m, "startWindow", startWindowEnd); - } - else - { - htsmsg_add_s32(m, "start", -1); - htsmsg_add_s32(m, "startWindow", -1); - } - } - else - { - if (timer.GetStartTime() > 0 && !timer.GetStartAnyTime()) - { - /* Exact start time (minutes from midnight). */ - time_t startTime = timer.GetStartTime(); - struct tm* tm_start = std::localtime(&startTime); - htsmsg_add_s32(m, "start", tm_start->tm_hour * 60 + tm_start->tm_min); - } - else - htsmsg_add_s32( - m, "start", - 25 * 60); // -1 or not sending causes server to set start and startWindow to any time - - if (timer.GetEndTime() > 0 && !timer.GetEndAnyTime()) - { - /* Exact stop time (minutes from midnight). */ - time_t endTime = timer.GetEndTime(); - struct tm* tm_stop = std::localtime(&endTime); - htsmsg_add_s32(m, "startWindow", tm_stop->tm_hour * 60 + tm_stop->tm_min); - } - else - htsmsg_add_s32( - m, "startWindow", - 25 * 60); // -1 or not sending causes server to set start and startWindow to any time - } - /* series link */ if (timer.GetTimerType() == TIMER_REPEATING_SERIESLINK) htsmsg_add_str(m, "serieslinkUri", timer.GetSeriesLink().c_str()); @@ -341,7 +265,6 @@ bool AutoRecordings::ParseAutorecAddOrUpdate(htsmsg_t* msg, bool bAdd) /* Locate/create entry */ AutoRecording& rec = m_autoRecordings[std::string(str)]; - rec.SetSettings(m_settings); rec.SetStringId(std::string(str)); rec.SetDirty(false); diff --git a/src/tvheadend/CustomTimerProperties.cpp b/src/tvheadend/CustomTimerProperties.cpp index ee68e7f9..d16a8872 100644 --- a/src/tvheadend/CustomTimerProperties.cpp +++ b/src/tvheadend/CustomTimerProperties.cpp @@ -37,11 +37,22 @@ std::vector CustomTimerProperties::GetPrope return customProps; } +std::vector CustomTimerProperties::GetProperties( + const tvheadend::entity::TimeRecording& timerec) const +{ + std::vector customProps; + GetCommonProperties(customProps, timerec); + GetSeriesCommonProperties(customProps, timerec); + + return customProps; +} + std::vector CustomTimerProperties::GetProperties( const tvheadend::entity::AutoRecording& autorec) const { std::vector customProps; GetCommonProperties(customProps, autorec); + GetSeriesCommonProperties(customProps, autorec); for (unsigned int propId : m_propIds) { @@ -96,6 +107,32 @@ void CustomTimerProperties::GetCommonProperties( } } +void CustomTimerProperties::GetSeriesCommonProperties( + std::vector& props, + const tvheadend::entity::SeriesRecordingBase& seriesrec) const +{ + for (unsigned int propId : m_propIds) + { + switch (propId) + { + case CUSTOM_PROP_ID_SERIESREC_START: + { + // Start + props.emplace_back(CUSTOM_PROP_ID_SERIESREC_START, seriesrec.GetStartWindowBegin()); + break; + } + case CUSTOM_PROP_ID_SERIESREC_STARTWINDOW: + { + // Start window + props.emplace_back(CUSTOM_PROP_ID_SERIESREC_STARTWINDOW, seriesrec.GetStartWindowEnd()); + break; + } + default: + break; + } + } +} + const std::vector CustomTimerProperties::GetSettingDefinitions() const { @@ -105,6 +142,28 @@ const std::vector CustomTimerProperties::GetS { switch (propId) { + case CUSTOM_PROP_ID_SERIESREC_START: + { + int defaultValue{SERIESREC_START_ANYTIME}; + const std::vector startValues{ + GetPossibleValues(CUSTOM_PROP_ID_SERIESREC_START, defaultValue)}; + ret.emplace_back(CreateSettingDefinition(CUSTOM_PROP_ID_SERIESREC_START, + 30606, // Start after + startValues, defaultValue, + PVR_SETTING_READONLY_CONDITION_NONE)); + break; + } + case CUSTOM_PROP_ID_SERIESREC_STARTWINDOW: + { + int defaultValue{SERIESREC_START_ANYTIME}; + const std::vector startWindowValues{ + GetPossibleValues(CUSTOM_PROP_ID_SERIESREC_STARTWINDOW, defaultValue)}; + ret.emplace_back(CreateSettingDefinition(CUSTOM_PROP_ID_SERIESREC_STARTWINDOW, + 30607, // Start before + startWindowValues, defaultValue, + PVR_SETTING_READONLY_CONDITION_NONE)); + break; + } case CUSTOM_PROP_ID_AUTOREC_BROADCASTTYPE: { // Broadcast type @@ -166,6 +225,33 @@ const std::vector CustomTimerProperties::GetPossib { switch (propId) { + case CUSTOM_PROP_ID_SERIESREC_START: + case CUSTOM_PROP_ID_SERIESREC_STARTWINDOW: + { + // Start, Start window + + // Any : SERIESREC_START_ANYTIME (-1) + // 0:00 : 0 + // 0:10 : 0 * 60 + 10 + // ... + // 23:50 : 23 * 60 + 50 + static std::vector startValues{}; + if (startValues.empty()) + { + startValues.reserve(24 * 60 / 10 + 1); + startValues.emplace_back( + kodi::addon::PVRTypeIntValue(SERIESREC_START_ANYTIME, + kodi::addon::GetLocalizedString(30601))); // Any + for (int i = 0; i < 24 * 60; i += 10) + { + const std::string hours{std::to_string(i / 60)}; + const std::string minutes{(i % 60) == 0 ? "00" : std::to_string(i % 60)}; + startValues.emplace_back(kodi::addon::PVRTypeIntValue(i, hours + ":" + minutes)); + } + } + defaultValue = SERIESREC_START_ANYTIME; // Any + return startValues; + } case CUSTOM_PROP_ID_AUTOREC_BROADCASTTYPE: { // Broadcast type @@ -241,6 +327,18 @@ void CustomTimerProperties::AppendPropertiesToHTSPMessage( { switch (prop.GetKey()) { + case CUSTOM_PROP_ID_SERIESREC_START: + { + // Start + htsmsg_add_s32(msg, "start", prop.GetIntValue()); + break; + } + case CUSTOM_PROP_ID_SERIESREC_STARTWINDOW: + { + // Start window + htsmsg_add_s32(msg, "startWindow", prop.GetIntValue()); + break; + } case CUSTOM_PROP_ID_AUTOREC_BROADCASTTYPE: { // Broadcast type diff --git a/src/tvheadend/CustomTimerProperties.h b/src/tvheadend/CustomTimerProperties.h index ef6bbcc9..87635b47 100644 --- a/src/tvheadend/CustomTimerProperties.h +++ b/src/tvheadend/CustomTimerProperties.h @@ -32,12 +32,16 @@ namespace entity { class AutoRecording; class RecordingBase; +class SeriesRecordingBase; +class TimeRecording; } // namespace entity // custom property ids constexpr unsigned int CUSTOM_PROP_ID_AUTOREC_BROADCASTTYPE{1}; constexpr unsigned int CUSTOM_PROP_ID_DVR_CONFIGURATION{2}; constexpr unsigned int CUSTOM_PROP_ID_DVR_COMMENT{3}; +constexpr unsigned int CUSTOM_PROP_ID_SERIESREC_START{4}; +constexpr unsigned int CUSTOM_PROP_ID_SERIESREC_STARTWINDOW{5}; class CustomTimerProperties { @@ -55,6 +59,10 @@ class CustomTimerProperties std::vector GetProperties( const tvheadend::entity::AutoRecording& autorec) const; + // Get custom props for Timerecs, inlcuding props for all timers + std::vector GetProperties( + const tvheadend::entity::TimeRecording& timerec) const; + // Get setting definitions const std::vector GetSettingDefinitions() const; @@ -83,6 +91,8 @@ class CustomTimerProperties int GetDvrConfigurationId(const std::string& uuid) const; void GetCommonProperties(std::vector& props, const tvheadend::entity::RecordingBase& rec) const; + void GetSeriesCommonProperties(std::vector& props, + const tvheadend::entity::SeriesRecordingBase& seriesrec) const; const std::vector m_propIds; const HTSPConnection& m_conn; diff --git a/src/tvheadend/InstanceSettings.cpp b/src/tvheadend/InstanceSettings.cpp index 300e3620..1887a09d 100644 --- a/src/tvheadend/InstanceSettings.cpp +++ b/src/tvheadend/InstanceSettings.cpp @@ -30,11 +30,7 @@ const bool DEFAULT_ASYNC_EPG = true; const bool DEFAULT_PRETUNER_ENABLED = false; const int DEFAULT_TOTAL_TUNERS = 1; // total tuners > 1 => predictive tuning active const int DEFAULT_PRETUNER_CLOSEDELAY = 10; // secs -const int DEFAULT_AUTOREC_MAXDIFF = - 15; // mins. Maximum difference between real and approximate start time for auto recordings const bool DEFAULT_AUTOREC_USE_REGEX = false; -const int DEFAULT_APPROX_TIME = - 0; // don't use an approximate start time, use a fixed time instead for auto recordings const std::string DEFAULT_STREAMING_PROFILE = ""; const bool DEFAULT_STREAMING_HTTP = false; const int DEFAULT_DVR_PRIO = DVR_PRIO_NORMAL; @@ -62,8 +58,6 @@ InstanceSettings::InstanceSettings(kodi::addon::IAddonInstance& instance) m_bPretunerEnabled(DEFAULT_PRETUNER_ENABLED), m_iTotalTuners(DEFAULT_TOTAL_TUNERS), m_iPreTunerCloseDelay(DEFAULT_PRETUNER_CLOSEDELAY), - m_iAutorecApproxTime(DEFAULT_APPROX_TIME), - m_iAutorecMaxDiff(DEFAULT_AUTOREC_MAXDIFF), m_bAutorecUseRegEx(DEFAULT_AUTOREC_USE_REGEX), m_strStreamingProfile(DEFAULT_STREAMING_PROFILE), m_bUseHTTPStreaming(DEFAULT_STREAMING_HTTP), @@ -103,8 +97,6 @@ void InstanceSettings::ReadSettings() m_bPretunerEnabled ? ReadIntSetting("pretuner_closedelay", DEFAULT_PRETUNER_CLOSEDELAY) : 0); /* Auto recordings */ - SetAutorecApproxTime(ReadIntSetting("autorec_approxtime", DEFAULT_APPROX_TIME)); - SetAutorecMaxDiff(ReadIntSetting("autorec_maxdiff", DEFAULT_AUTOREC_MAXDIFF)); SetAutorecUseRegEx(ReadBoolSetting("autorec_use_regex", DEFAULT_AUTOREC_USE_REGEX)); /* Streaming */ @@ -176,13 +168,6 @@ ADDON_STATUS InstanceSettings::SetSetting(const std::string& key, return ADDON_STATUS_OK; } /* Auto recordings */ - else if (key == "autorec_approxtime") - return SetIntSetting(GetAutorecApproxTime(), value); - else if (key == "autorec_maxdiff") - { - SetAutorecMaxDiff(value.GetInt()); - return ADDON_STATUS_OK; - } else if (key == "autorec_use_regex") { SetAutorecUseRegEx(value.GetBoolean()); diff --git a/src/tvheadend/InstanceSettings.h b/src/tvheadend/InstanceSettings.h index 418931e1..a226908f 100644 --- a/src/tvheadend/InstanceSettings.h +++ b/src/tvheadend/InstanceSettings.h @@ -42,8 +42,6 @@ class InstanceSettings bool GetAsyncEpg() const { return m_bAsyncEpg; } int GetTotalTuners() const { return m_iTotalTuners; } int GetPreTunerCloseDelay() const { return m_iPreTunerCloseDelay; } - int GetAutorecApproxTime() const { return m_iAutorecApproxTime; } - int GetAutorecMaxDiff() const { return m_iAutorecMaxDiff; } bool GetAutorecUseRegEx() const { return m_bAutorecUseRegEx; } std::string GetStreamingProfile() const { return m_strStreamingProfile; } bool GetStreamingHTTP() const { return m_bUseHTTPStreaming; } @@ -79,8 +77,6 @@ class InstanceSettings void SetAsyncEpg(bool value) { m_bAsyncEpg = value; } void SetTotalTuners(int value) { m_iTotalTuners = value; } void SetPreTunerCloseDelay(int value) { m_iPreTunerCloseDelay = value; } - void SetAutorecApproxTime(int value) { m_iAutorecApproxTime = value; } - void SetAutorecMaxDiff(int value) { m_iAutorecMaxDiff = value; } void SetAutorecUseRegEx(bool value) { m_bAutorecUseRegEx = value; } void SetStreamingProfile(const std::string& value) { m_strStreamingProfile = value; } void SetStreamingHTTP(bool value) { m_bUseHTTPStreaming = value; } @@ -120,8 +116,6 @@ class InstanceSettings bool m_bPretunerEnabled; int m_iTotalTuners; int m_iPreTunerCloseDelay; - bool m_iAutorecApproxTime; - int m_iAutorecMaxDiff; bool m_bAutorecUseRegEx; std::string m_strStreamingProfile; bool m_bUseHTTPStreaming; diff --git a/src/tvheadend/TimeRecordings.cpp b/src/tvheadend/TimeRecordings.cpp index 719a026e..4fd43f63 100644 --- a/src/tvheadend/TimeRecordings.cpp +++ b/src/tvheadend/TimeRecordings.cpp @@ -23,8 +23,10 @@ using namespace tvheadend::utilities; TimeRecordings::TimeRecordings(HTSPConnection& conn, Profiles& dvrConfigs) : m_conn(conn), - m_customTimerProps( - {CUSTOM_PROP_ID_DVR_CONFIGURATION, CUSTOM_PROP_ID_DVR_COMMENT}, conn, dvrConfigs) + m_customTimerProps({CUSTOM_PROP_ID_SERIESREC_START, CUSTOM_PROP_ID_SERIESREC_STARTWINDOW, + CUSTOM_PROP_ID_DVR_CONFIGURATION, CUSTOM_PROP_ID_DVR_COMMENT}, + conn, + dvrConfigs) { } @@ -62,8 +64,6 @@ void TimeRecordings::GetTimerecTimers(std::vector& timers tmr.SetClientIndex(rec.second.GetId()); tmr.SetClientChannelUid((rec.second.GetChannel() > 0) ? rec.second.GetChannel() : PVR_TIMER_ANY_CHANNEL); - tmr.SetStartTime(rec.second.GetStart()); - tmr.SetEndTime(rec.second.GetStop()); tmr.SetTitle(rec.second.GetName()); tmr.SetEPGSearchString(""); // n/a for manual timers tmr.SetDirectory(rec.second.GetDirectory()); @@ -292,7 +292,7 @@ bool TimeRecordings::ParseTimerecAddOrUpdate(htsmsg_t* msg, bool bAdd) int32_t s32 = 0; if (!htsmsg_get_s32(msg, "start", &s32)) { - rec.SetStart(s32); + rec.SetStartWindowBegin(s32); } else if (bAdd) { @@ -302,7 +302,7 @@ bool TimeRecordings::ParseTimerecAddOrUpdate(htsmsg_t* msg, bool bAdd) if (!htsmsg_get_s32(msg, "stop", &s32)) { - rec.SetStop(s32); + rec.SetStartWindowEnd(s32); } else if (bAdd) { diff --git a/src/tvheadend/entity/AutoRecording.cpp b/src/tvheadend/entity/AutoRecording.cpp index 76530288..de97efdc 100644 --- a/src/tvheadend/entity/AutoRecording.cpp +++ b/src/tvheadend/entity/AutoRecording.cpp @@ -7,8 +7,6 @@ #include "AutoRecording.h" -#include "../InstanceSettings.h" - using namespace tvheadend; using namespace tvheadend::entity; @@ -18,8 +16,7 @@ AutoRecording::AutoRecording(const std::string& id /*= ""*/) : SeriesRecordingBa bool AutoRecording::operator==(const AutoRecording& right) { - return SeriesRecordingBase::operator==(right) && m_startWindowBegin == right.m_startWindowBegin && - m_startWindowEnd == right.m_startWindowEnd && m_startExtra == right.m_startExtra && + return SeriesRecordingBase::operator==(right) && m_startExtra == right.m_startExtra && m_stopExtra == right.m_stopExtra && m_dupDetect == right.m_dupDetect && m_fulltext == right.m_fulltext && m_broadcastType == right.m_broadcastType && m_seriesLink == right.m_seriesLink; @@ -30,65 +27,6 @@ bool AutoRecording::operator!=(const AutoRecording& right) return !(*this == right); } -time_t AutoRecording::GetStart() const -{ - if (m_settings->GetAutorecApproxTime()) - { - /* Calculate the approximate start time from the starting window */ - if ((m_startWindowBegin == -1) || - (m_startWindowEnd == -1)) // no starting window set => "any time" - { - return 0; - } - else if (m_startWindowEnd < m_startWindowBegin) - { - /* End of start window is a day in the future */ - int32_t newEnd = m_startWindowEnd + (24 * 60); - int32_t newStart = m_startWindowBegin + (newEnd - m_startWindowBegin) / 2; - - if (newStart > (24 * 60)) - newStart -= (24 * 60); - - return LocaltimeToUTC(newStart); - } - else - return LocaltimeToUTC(m_startWindowBegin + (m_startWindowEnd - m_startWindowBegin) / 2); - } - else - { - if (m_startWindowBegin == -1) // "any time" - return 0; - - return LocaltimeToUTC(m_startWindowBegin); - } -} - -void AutoRecording::SetStartWindowBegin(int32_t start) -{ - m_startWindowBegin = start; -} - -time_t AutoRecording::GetStop() const -{ - if (m_settings->GetAutorecApproxTime()) - { - /* Tvh doesn't have an approximate stop time => "any time" */ - return 0; - } - else - { - if (m_startWindowEnd == -1) // "any time" - return 0; - - return LocaltimeToUTC(m_startWindowEnd); - } -} - -void AutoRecording::SetStartWindowEnd(int32_t end) -{ - m_startWindowEnd = end; -} - int64_t AutoRecording::GetMarginStart() const { return m_startExtra; diff --git a/src/tvheadend/entity/AutoRecording.h b/src/tvheadend/entity/AutoRecording.h index f56ccd9a..e75a5a1b 100644 --- a/src/tvheadend/entity/AutoRecording.h +++ b/src/tvheadend/entity/AutoRecording.h @@ -11,14 +11,11 @@ #include #include -#include #include #include namespace tvheadend { -class InstanceSettings; - namespace entity { @@ -30,14 +27,6 @@ class AutoRecording : public SeriesRecordingBase bool operator==(const AutoRecording& right); bool operator!=(const AutoRecording& right); - void SetSettings(const std::shared_ptr& settings) { m_settings = settings; } - - time_t GetStart() const; - void SetStartWindowBegin(int32_t begin); - - time_t GetStop() const; - void SetStartWindowEnd(int32_t end); - int64_t GetMarginStart() const; void SetMarginStart(int64_t startExtra); @@ -57,10 +46,6 @@ class AutoRecording : public SeriesRecordingBase void SetSeriesLink(const std::string& seriesLink); private: - std::shared_ptr m_settings; - - int32_t m_startWindowBegin{0}; // Begin of the starting window (minutes from midnight). - int32_t m_startWindowEnd{0}; // End of the starting window (minutes from midnight). int64_t m_startExtra{0}; // Extra start minutes (pre-time). int64_t m_stopExtra{0}; // Extra stop minutes (post-time). uint32_t m_dupDetect{0}; // duplicate episode detect (numeric values: see dvr_autorec_dedup_t). diff --git a/src/tvheadend/entity/SeriesRecordingBase.cpp b/src/tvheadend/entity/SeriesRecordingBase.cpp index c0451f14..c2e6a2d9 100644 --- a/src/tvheadend/entity/SeriesRecordingBase.cpp +++ b/src/tvheadend/entity/SeriesRecordingBase.cpp @@ -7,8 +7,6 @@ #include "SeriesRecordingBase.h" -#include - using namespace tvheadend::entity; SeriesRecordingBase::SeriesRecordingBase(const std::string& id /*= ""*/) : m_sid(id) @@ -16,22 +14,6 @@ SeriesRecordingBase::SeriesRecordingBase(const std::string& id /*= ""*/) : m_sid m_id = GetNextIntId(); } -// static -time_t SeriesRecordingBase::LocaltimeToUTC(int32_t lctime) -{ - /* Note: lctime contains minutes from midnight (up to 24*60) as local time. */ - - /* complete lctime with current year, month, day, ... */ - time_t t = std::time(nullptr); - struct tm* tm_time = std::localtime(&t); - - tm_time->tm_hour = lctime / 60; - tm_time->tm_min = lctime % 60; - tm_time->tm_sec = 0; - - return std::mktime(tm_time); -} - // static unsigned int SeriesRecordingBase::GetNextIntId() { diff --git a/src/tvheadend/entity/SeriesRecordingBase.h b/src/tvheadend/entity/SeriesRecordingBase.h index b5d9658d..38e7033b 100644 --- a/src/tvheadend/entity/SeriesRecordingBase.h +++ b/src/tvheadend/entity/SeriesRecordingBase.h @@ -10,12 +10,13 @@ #include "RecordingBase.h" #include -#include #include namespace tvheadend::entity { +static constexpr int SERIESREC_START_ANYTIME{-1}; + class SeriesRecordingBase : public RecordingBase { protected: @@ -26,7 +27,8 @@ class SeriesRecordingBase : public RecordingBase return RecordingBase::operator==(right) && m_sid == right.m_sid && m_daysOfWeek == right.m_daysOfWeek && m_name == right.m_name && m_directory == right.m_directory && m_owner == right.m_owner && - m_creator == right.m_creator; + m_creator == right.m_creator && m_startWindowBegin == right.m_startWindowBegin && + m_startWindowEnd == right.m_startWindowEnd; } bool operator!=(const SeriesRecordingBase& right) { return !(*this == right); } @@ -48,8 +50,11 @@ class SeriesRecordingBase : public RecordingBase void SetCreator(const std::string& creator) { m_creator = creator; } -protected: - static time_t LocaltimeToUTC(int32_t lctime); + int GetStartWindowBegin() const { return m_startWindowBegin; } + void SetStartWindowBegin(int32_t begin) { m_startWindowBegin = begin; } + + int GetStartWindowEnd() const { return m_startWindowEnd; } + void SetStartWindowEnd(int32_t end) { m_startWindowEnd = end; } private: static unsigned int GetNextIntId(); @@ -61,6 +66,10 @@ class SeriesRecordingBase : public RecordingBase std::string m_directory; // Directory for the recording files. std::string m_owner; // Owner. std::string m_creator; // Creator. + int32_t m_startWindowBegin{ + SERIESREC_START_ANYTIME}; // Minutes from midnight (up to 24*60) for the start of the time window (including). + int32_t m_startWindowEnd{ + SERIESREC_START_ANYTIME}; // Minutes from midnight (up to 24*60) for the end of the time window (including, cross-noon allowed) }; } // namespace tvheadend::entity diff --git a/src/tvheadend/entity/TimeRecording.cpp b/src/tvheadend/entity/TimeRecording.cpp index 71131d8b..939718db 100644 --- a/src/tvheadend/entity/TimeRecording.cpp +++ b/src/tvheadend/entity/TimeRecording.cpp @@ -15,37 +15,10 @@ TimeRecording::TimeRecording(const std::string& id /*= ""*/) : SeriesRecordingBa bool TimeRecording::operator==(const TimeRecording& right) { - return SeriesRecordingBase::operator==(right) && m_start == right.m_start && - m_stop == right.m_stop; + return SeriesRecordingBase::operator==(right); } bool TimeRecording::operator!=(const TimeRecording& right) { return !(*this == right); } - -time_t TimeRecording::GetStart() const -{ - if (m_start == int32_t(-1)) // "any time" - return 0; - - return LocaltimeToUTC(m_start); -} - -void TimeRecording::SetStart(int32_t start) -{ - m_start = start; -} - -time_t TimeRecording::GetStop() const -{ - if (m_stop == int32_t(-1)) // "any time" - return 0; - - return LocaltimeToUTC(m_stop); -} - -void TimeRecording::SetStop(int32_t stop) -{ - m_stop = stop; -} diff --git a/src/tvheadend/entity/TimeRecording.h b/src/tvheadend/entity/TimeRecording.h index 97989d3c..74beae88 100644 --- a/src/tvheadend/entity/TimeRecording.h +++ b/src/tvheadend/entity/TimeRecording.h @@ -9,8 +9,6 @@ #include "SeriesRecordingBase.h" -#include -#include #include #include @@ -24,16 +22,6 @@ class TimeRecording : public SeriesRecordingBase bool operator==(const TimeRecording& right); bool operator!=(const TimeRecording& right); - - time_t GetStart() const; - void SetStart(int32_t start); - - time_t GetStop() const; - void SetStop(int32_t stop); - -private: - int32_t m_start{0}; // Start time in minutes from midnight (up to 24*60). - int32_t m_stop{0}; // Stop time in minutes from midnight (up to 24*60). }; typedef std::map TimeRecordingsMap;