Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ksooo committed Aug 27, 2024
1 parent ce9ba70 commit 02b0711
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 15 deletions.
30 changes: 29 additions & 1 deletion pvr.hts/resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,13 @@ msgctxt "#30372"
msgid "Record if unique episode according EPG/XMLTV"
msgstr ""

#empty strings from id 30373 to 30374
#. Prevent duplicate episodes representation
#: src/Tvheadend.cpp
msgctxt "#30373"
msgid "Use DVR configuration"
msgstr ""

#empty string with id 30374

#. Recording lifetime representation
#: src/Tvheadend.cpp
Expand Down Expand Up @@ -478,3 +484,25 @@ msgstr ""
msgctxt "#30511"
msgid "Server based play status"
msgstr ""

#empty strings from id 30512 to 30599

msgctxt "#30600"
msgid "Broadcast type"
msgstr ""

msgctxt "#30601"
msgid "Any"
msgstr ""

msgctxt "#30602"
msgid "New / premiere / unknown"
msgstr ""

msgctxt "#30603"
msgid "Repeated"
msgstr ""

msgctxt "#30604"
msgid "New / premiere"
msgstr ""
20 changes: 17 additions & 3 deletions src/Tvheadend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -845,14 +845,17 @@ struct TimerType : kodi::addon::PVRTimerType
const std::vector<kodi::addon::PVRTypeIntValue>& lifetimeValues =
std::vector<kodi::addon::PVRTypeIntValue>(),
const std::vector<kodi::addon::PVRTypeIntValue>& dupEpisodesValues =
std::vector<kodi::addon::PVRTypeIntValue>())
std::vector<kodi::addon::PVRTypeIntValue>(),
const std::vector<kodi::addon::PVRIntSetting>& customIntSettings =
std::vector<kodi::addon::PVRIntSetting>())
{
SetId(id);
SetAttributes(attributes);
SetDescription(description);
SetPriorities(priorityValues, settings->GetDvrPriority());
SetLifetimes(lifetimeValues, LifetimeMapper::TvhToKodi(settings->GetDvrLifetime()));
SetPreventDuplicateEpisodes(dupEpisodesValues, settings->GetDvrDupdetect());
SetCustomIntSettings(customIntSettings);
}
};

Expand Down Expand Up @@ -898,6 +901,7 @@ PVR_ERROR CTvheadend::GetTimerTypes(std::vector<kodi::addon::PVRTimerType>& type

/* PVR_Timer.iPreventDuplicateEpisodes values and presentation.*/
std::vector<kodi::addon::PVRTypeIntValue> deDupValues = {
{DVR_AUTOREC_RECORD_DVR_PROFILE, kodi::addon::GetLocalizedString(30373)},
{DVR_AUTOREC_RECORD_ALL, kodi::addon::GetLocalizedString(30356)},
{DVR_AUTOREC_RECORD_DIFFERENT_EPISODE_NUMBER, kodi::addon::GetLocalizedString(30357)},
{DVR_AUTOREC_RECORD_DIFFERENT_SUBTITLE, kodi::addon::GetLocalizedString(30358)},
Expand Down Expand Up @@ -1030,6 +1034,10 @@ PVR_ERROR CTvheadend::GetTimerTypes(std::vector<kodi::addon::PVRTimerType>& type
/* Values definitions for lifetime. */
lifetimeValues));

/* Custom Autorec integer settings */
const std::vector<kodi::addon::PVRIntSetting> customAutorecIntSettings{
m_autoRecordings.GetCustomAutorecIntSettings()};

if (m_conn->GetProtocol() >= 29)
{
unsigned int TIMER_REPEATING_SERIESLINK_ATTRIBS =
Expand Down Expand Up @@ -1060,7 +1068,11 @@ PVR_ERROR CTvheadend::GetTimerTypes(std::vector<kodi::addon::PVRTimerType>& type
/* Values definitions for priorities. */
priorityValues,
/* Values definitions for lifetime. */
lifetimeValues));
lifetimeValues,
/* Values definitions for prevent duplicate episodes. */
{},
/* Custom int settings definitions. */
customAutorecIntSettings));
}

unsigned int TIMER_REPEATING_EPG_ATTRIBS =
Expand Down Expand Up @@ -1094,7 +1106,9 @@ PVR_ERROR CTvheadend::GetTimerTypes(std::vector<kodi::addon::PVRTimerType>& type
/* Values definitions for lifetime. */
lifetimeValues,
/* Values definitions for prevent duplicate episodes. */
deDupValues));
deDupValues,
/* Custom int settings definitions. */
customAutorecIntSettings));

return PVR_ERROR_NO_ERROR;
}
Expand Down
50 changes: 46 additions & 4 deletions src/tvheadend/AutoRecordings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ void AutoRecordings::GetAutorecTimers(std::vector<kodi::addon::PVRTimer>& timers
tmr.SetFullTextEpgSearch(rec.second.GetFulltext());
tmr.SetParentClientIndex(0);

if (m_conn.GetProtocol() >= 39)
{
// Add custom properties
std::vector<kodi::addon::PVRIntKeyValuePair> customProps;
customProps.emplace_back(CUSTOM_PROP_ID_AUTOREC_BROADCASTTYPE, rec.second.GetBroadcastType());
tmr.SetCustomIntProperties(customProps);
}

timers.emplace_back(std::move(tmr));
}
}
Expand Down Expand Up @@ -133,6 +141,27 @@ const std::string AutoRecordings::GetTimerStringIdFromIntId(unsigned int intId)
return "";
}

const std::vector<kodi::addon::PVRIntSetting> AutoRecordings::GetCustomAutorecIntSettings() const
{
std::vector<kodi::addon::PVRIntSetting> ret;
if (m_conn.GetProtocol() >= 39)
{
static std::vector<kodi::addon::PVRTypeIntValue> broadcastTypeValues = {
{DVR_AUTOREC_BTYPE_ALL, kodi::addon::GetLocalizedString(30601)},
{DVR_AUTOREC_BTYPE_NEW_OR_UNKNOWN, kodi::addon::GetLocalizedString(30602)},
{DVR_AUTOREC_BTYPE_REPEAT, kodi::addon::GetLocalizedString(30603)},
{DVR_AUTOREC_BTYPE_NEW, kodi::addon::GetLocalizedString(30604)}};

kodi::addon::PVRIntSetting setting;
setting.SetId(CUSTOM_PROP_ID_AUTOREC_BROADCASTTYPE);
setting.SetName(kodi::addon::GetLocalizedString(30600));
setting.SetValues(broadcastTypeValues);
setting.SetDefaultValue(DVR_AUTOREC_BTYPE_ALL);
ret.emplace_back(std::move(setting));
}
return ret;
}

PVR_ERROR AutoRecordings::SendAutorecAdd(const kodi::addon::PVRTimer& timer)
{
return SendAutorecAddOrUpdate(timer, false);
Expand Down Expand Up @@ -259,6 +288,20 @@ PVR_ERROR AutoRecordings::SendAutorecAddOrUpdate(const kodi::addon::PVRTimer& ti
if (timer.GetTimerType() == TIMER_REPEATING_SERIESLINK)
htsmsg_add_str(m, "serieslinkUri", timer.GetSeriesLink().c_str());

/* broadcast type */
std::vector<kodi::addon::PVRIntKeyValuePair> customProps{timer.GetCustomIntProperties()};
if (!customProps.empty())
{
for (const auto& entry : customProps)
{
if (entry.GetKey() == CUSTOM_PROP_ID_AUTOREC_BROADCASTTYPE)
{
htsmsg_add_u32(m, "broadcastType", entry.GetValue());
break;
}
}
}

/* Send and Wait */
{
std::unique_lock<std::recursive_mutex> lock(m_conn.Mutex());
Expand Down Expand Up @@ -443,21 +486,20 @@ bool AutoRecordings::ParseAutorecAddOrUpdate(htsmsg_t* msg, bool bAdd)
rec.SetCreator(str);

if (!htsmsg_get_u32(msg, "channel", &u32))
{
rec.SetChannel(u32);
}
else
rec.SetChannel(PVR_TIMER_ANY_CHANNEL); // an empty channel field = any channel

if (!htsmsg_get_u32(msg, "fulltext", &u32))
{
rec.SetFulltext(u32);
}

str = htsmsg_get_str(msg, "serieslinkUri");
if (str)
rec.SetSeriesLink(str);

if (!htsmsg_get_u32(msg, "broadcastType", &u32))
rec.SetBroadcastType(u32);

return true;
}

Expand Down
1 change: 1 addition & 0 deletions src/tvheadend/AutoRecordings.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class AutoRecordings
int GetAutorecTimerCount() const;
void GetAutorecTimers(std::vector<kodi::addon::PVRTimer>& timers);
const unsigned int GetTimerIntIdFromStringId(const std::string& strId) const;
const std::vector<kodi::addon::PVRIntSetting> GetCustomAutorecIntSettings() const;

/* client to server messages */
PVR_ERROR SendAutorecAdd(const kodi::addon::PVRTimer& timer);
Expand Down
23 changes: 17 additions & 6 deletions src/tvheadend/HTSPTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ typedef enum
DVR_ACTION_TYPE_MUTE,
DVR_ACTION_TYPE_SCENE,
DVR_ACTION_TYPE_COMBREAK,

} dvr_action_type_t;

typedef enum
Expand All @@ -50,6 +49,7 @@ typedef enum
DVR_AUTOREC_RECORD_ONCE_PER_MONTH = 12,
DVR_AUTOREC_RECORD_ONCE_PER_WEEK = 4,
DVR_AUTOREC_RECORD_ONCE_PER_DAY = 5,
DVR_AUTOREC_RECORD_DVR_PROFILE = 15, // Use DVR configuration
DVR_AUTOREC_LRECORD_DIFFERENT_EPISODE_NUMBER = 6,
DVR_AUTOREC_LRECORD_DIFFERENT_TITLE = 7,
DVR_AUTOREC_LRECORD_DIFFERENT_SUBTITLE = 8,
Expand Down Expand Up @@ -80,11 +80,10 @@ typedef enum
DVR_RET_1YEAR = 366,
DVR_RET_2YEARS = 731,
DVR_RET_3YEARS = 1096,
DVR_RET_SPACE =
INT32_MAX -
1, // the server may delete this recording if space for a new recording is needed (removal only)
DVR_RET_FOREVER =
INT32_MAX // the server should never delete this recording or database entry, only the user can do this
// the server may delete this recording if space for a new recording is needed (removal only)
DVR_RET_SPACE = (INT32_MAX - 1),
// the server should never delete this recording or database entry, only the user can do this
DVR_RET_FOREVER = (INT32_MAX)
} dvr_retention_t;

typedef enum
Expand All @@ -94,6 +93,15 @@ typedef enum
CHANNEL_TYPE_RADIO = 2
} channel_type_t;

// Autorecs: Broadcast type
typedef enum
{
DVR_AUTOREC_BTYPE_ALL = 0, // "Any"
DVR_AUTOREC_BTYPE_NEW_OR_UNKNOWN = 1, // "New / premiere / unknown"
DVR_AUTOREC_BTYPE_REPEAT = 2, // "Repeated"
DVR_AUTOREC_BTYPE_NEW = 3, // "New / premiere"
} dvr_autorec_btype_t;

typedef enum
{
HTSP_DVR_PLAYCOUNT_RESET = 0,
Expand Down Expand Up @@ -137,4 +145,7 @@ struct SHTSPEvent

typedef std::vector<SHTSPEvent> SHTSPEventList;

// custom property ids
constexpr unsigned int CUSTOM_PROP_ID_AUTOREC_BROADCASTTYPE{1};

} // namespace tvheadend
12 changes: 11 additions & 1 deletion src/tvheadend/entity/AutoRecording.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ bool AutoRecording::operator==(const AutoRecording& right)
return RecordingBase::operator==(right) && m_startWindowBegin == right.m_startWindowBegin &&
m_startWindowEnd == right.m_startWindowEnd && m_startExtra == right.m_startExtra &&
m_stopExtra == right.m_stopExtra && m_dupDetect == right.m_dupDetect &&
m_fulltext == right.m_fulltext && m_seriesLink == right.m_seriesLink;
m_fulltext == right.m_fulltext && m_broadcastType == right.m_broadcastType &&
m_seriesLink == right.m_seriesLink;
}

bool AutoRecording::operator!=(const AutoRecording& right)
Expand Down Expand Up @@ -135,6 +136,15 @@ void AutoRecording::SetFulltext(uint32_t fulltext)
m_fulltext = fulltext;
}

uint32_t AutoRecording::GetBroadcastType() const
{
return m_broadcastType;
}
void AutoRecording::SetBroadcastType(uint32_t broadcastType)
{
m_broadcastType = broadcastType;
}

const std::string& AutoRecording::GetSeriesLink() const
{
return m_seriesLink;
Expand Down
4 changes: 4 additions & 0 deletions src/tvheadend/entity/AutoRecording.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class AutoRecording : public RecordingBase
bool GetFulltext() const;
void SetFulltext(uint32_t fulltext);

uint32_t GetBroadcastType() const;
void SetBroadcastType(uint32_t broadcastType);

const std::string& GetSeriesLink() const;
void SetSeriesLink(const std::string& seriesLink);

Expand All @@ -59,6 +62,7 @@ class AutoRecording : public RecordingBase
int64_t m_stopExtra; // Extra stop minutes (post-time).
uint32_t m_dupDetect; // duplicate episode detect (numeric values: see dvr_autorec_dedup_t).
uint32_t m_fulltext; // Fulltext epg search.
uint32_t m_broadcastType{0}; // Broadcast type (numeric values: see dvr_autorec_btype_t).
std::string m_seriesLink; // Series link.
};

Expand Down

0 comments on commit 02b0711

Please sign in to comment.