Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to PVR addon API v4.0.0 #96

Merged
merged 1 commit into from
Sep 14, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pvr.hts/addon.xml.in
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="pvr.hts"
version="2.2.6"
version="2.2.7"
name="Tvheadend HTSP Client"
provider-name="Adam Sutton, Sam Stenvall, Lars Op den Kamp, Kai Sommerfeld">
<requires>
<c-pluff version="0.1"/>
<import addon="xbmc.pvr" version="3.0.0"/>
<import addon="xbmc.pvr" version="4.0.0"/>
<import addon="xbmc.codec" version="1.0.1"/>
</requires>
<extension
Expand Down
5 changes: 4 additions & 1 deletion pvr.hts/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
2.2.7
- Updated to PVR API v4.0.0

2.2.6
- Minimal support for PVR API 3.0.0 incl. Repeating EPG Timer AnyTime Bool Change
- Minimal support for PVR API v3.0.0 incl. Repeating EPG Timer AnyTime Bool Change

2.2.5
- dropped CStdString usage
Expand Down
15 changes: 8 additions & 7 deletions src/AutoRecordings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,28 @@ void AutoRecordings::GetAutorecTimers(std::vector<PVR_TIMER> &timers)
strncpy(tmr.strDirectory,
tit->second.GetDirectory().c_str(), sizeof(tmr.strDirectory) - 1);
strncpy(tmr.strSummary,
"", sizeof(tmr.strSummary) - 1); // n/a for repeating timers
"", sizeof(tmr.strSummary) - 1); // n/a for repeating timers
tmr.state = tit->second.IsEnabled()
? PVR_TIMER_STATE_SCHEDULED
: PVR_TIMER_STATE_DISABLED;
tmr.iTimerType = TIMER_REPEATING_EPG;
tmr.iPriority = tit->second.GetPriority();
tmr.iLifetime = tit->second.GetRetention();
tmr.iRecordingGroup = 0; // not supported by tvh
tmr.iMaxRecordings = 0; // not supported by tvh
tmr.iRecordingGroup = 0; // not supported by tvh

if (m_conn.GetProtocol() >= 20)
tmr.iPreventDuplicateEpisodes = tit->second.GetDupDetect();
else
tmr.iPreventDuplicateEpisodes = 0; // not supported by tvh
tmr.iPreventDuplicateEpisodes = 0; // not supported by tvh

tmr.firstDay = 0; // not supported by tvh
tmr.firstDay = 0; // not supported by tvh
tmr.iWeekdays = tit->second.GetDaysOfWeek();
tmr.iEpgUid = -1; // n/a for repeating timers
tmr.iEpgUid = PVR_TIMER_NO_EPG_UID; // n/a for repeating timers
tmr.iMarginStart = tit->second.GetMarginStart();
tmr.iMarginEnd = tit->second.GetMarginEnd();
tmr.iGenreType = 0; // not supported by tvh?
tmr.iGenreSubType = 0; // not supported by tvh?
tmr.iGenreType = 0; // not supported by tvh?
tmr.iGenreSubType = 0; // not supported by tvh?
tmr.bFullTextEpgSearch = tit->second.GetFulltext();
tmr.iParentClientIndex = 0;

Expand Down
19 changes: 10 additions & 9 deletions src/TimeRecordings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,17 @@ void TimeRecordings::GetTimerecTimers(std::vector<PVR_TIMER> &timers)
tmr.iTimerType = TIMER_REPEATING_MANUAL;
tmr.iPriority = tit->second.GetPriority();
tmr.iLifetime = tit->second.GetRetention();
tmr.iRecordingGroup = 0; // not supported by tvh
tmr.iPreventDuplicateEpisodes = 0; // n/a for manual timers
tmr.firstDay = 0; // not supported by tvh
tmr.iMaxRecordings = 0; // not supported by tvh
tmr.iRecordingGroup = 0; // not supported by tvh
tmr.iPreventDuplicateEpisodes = 0; // n/a for manual timers
tmr.firstDay = 0; // not supported by tvh
tmr.iWeekdays = tit->second.GetDaysOfWeek();
tmr.iEpgUid = -1; // n/a for manual timers
tmr.iMarginStart = 0; // n/a for manual timers
tmr.iMarginEnd = 0; // n/a for manual timers
tmr.iGenreType = 0; // not supported by tvh?
tmr.iGenreSubType = 0; // not supported by tvh?
tmr.bFullTextEpgSearch = false; // n/a for manual timers
tmr.iEpgUid = PVR_TIMER_NO_EPG_UID; // n/a for manual timers
tmr.iMarginStart = 0; // n/a for manual timers
tmr.iMarginEnd = 0; // n/a for manual timers
tmr.iGenreType = 0; // not supported by tvh?
tmr.iGenreSubType = 0; // not supported by tvh?
tmr.bFullTextEpgSearch = false; // n/a for manual timers
tmr.iParentClientIndex = 0;

timers.push_back(tmr);
Expand Down
75 changes: 6 additions & 69 deletions src/Tvheadend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,11 +777,12 @@ bool CTvheadend::CreateTimer ( const SRecording &tvhTmr, PVR_TIMER &tmr )
: TIMER_ONCE_MANUAL;
tmr.iPriority = tvhTmr.priority;
tmr.iLifetime = tvhTmr.retention;
tmr.iMaxRecordings = 0; // not supported by tvh
tmr.iRecordingGroup = 0; // not supported by tvh
tmr.iPreventDuplicateEpisodes = 0; // n/a for one-shot timers
tmr.firstDay = 0; // not supported by tvh
tmr.iWeekdays = PVR_WEEKDAY_NONE; // n/a for one-shot timers
tmr.iEpgUid = (tvhTmr.eventId > 0) ? tvhTmr.eventId : -1;
tmr.iEpgUid = tvhTmr.eventId;
tmr.iMarginStart = tvhTmr.startExtra;
tmr.iMarginEnd = tvhTmr.stopExtra;
tmr.iGenreType = 0; // not supported by tvh?
Expand Down Expand Up @@ -848,7 +849,7 @@ PVR_ERROR CTvheadend::AddTimer ( const PVR_TIMER &timer )

/* Build message */
htsmsg_t *m = htsmsg_create_map();
if (timer.iEpgUid > 0 && timer.iTimerType == TIMER_ONCE_EPG)
if (timer.iEpgUid > PVR_TIMER_NO_EPG_UID && timer.iTimerType == TIMER_ONCE_EPG)
{
/* EPG-based timer */
htsmsg_add_u32(m, "eventId", timer.iEpgUid);
Expand Down Expand Up @@ -913,71 +914,7 @@ PVR_ERROR CTvheadend::AddTimer ( const PVR_TIMER &timer )
}
}

PVR_ERROR CTvheadend::DeleteRepeatingTimer
( const PVR_TIMER &timer, bool deleteScheduled, bool timerec )
{
if (deleteScheduled)
{
if (timerec)
return m_timeRecordings.SendTimerecDelete(timer);
else
return m_autoRecordings.SendAutorecDelete(timer);
}

/* Deleting repeating timer's scheduled timers is tvh standard behavior. */
/* Thus, clone the scheduled timers before deleting the repeating timer, */
/* add them after deleting the repeating timer (adding clones before */
/* deleting the repeating timer will not work due to tvheadend internal */
/* check for duplicates) */

/* obtain the children of the timer, if any. */
std::string id = timerec
? m_timeRecordings.GetTimerStringIdFromIntId(timer.iClientIndex)
: m_autoRecordings.GetTimerStringIdFromIntId(timer.iClientIndex);

if (id.empty())
{
tvherror("unable to obtain string id from int id");
return PVR_ERROR_FAILED;
}

std::vector<PVR_TIMER> clones;
for (auto rit = m_recordings.begin(); rit != m_recordings.end(); ++rit)
{
if (!rit->second.IsTimer())
continue;

if ((timerec && (rit->second.timerecId) == id) || (rit->second.autorecId == id))
{
PVR_TIMER tmr;
if (!CreateTimer(rit->second, tmr))
{
clones.clear();
return PVR_ERROR_FAILED;
}

/* adjust timer type. */
tmr.iTimerType = (rit->second.eventId > 0) ? TIMER_ONCE_EPG : TIMER_ONCE_MANUAL;

clones.push_back(tmr);
}
}

PVR_ERROR error = timerec
? m_timeRecordings.SendTimerecDelete(timer)
: m_autoRecordings.SendAutorecDelete(timer);

if (error == PVR_ERROR_NO_ERROR)
{
for (auto it = clones.begin(); it != clones.end(); ++it)
AddTimer(*it); // TODO ksooo: error handling
}

return error;
}

PVR_ERROR CTvheadend::DeleteTimer
( const PVR_TIMER &timer, bool _unused(force), bool deleteScheduled )
PVR_ERROR CTvheadend::DeleteTimer ( const PVR_TIMER &timer, bool _unused(force) )
{
if ((timer.iTimerType == TIMER_ONCE_MANUAL) ||
(timer.iTimerType == TIMER_ONCE_EPG))
Expand All @@ -988,12 +925,12 @@ PVR_ERROR CTvheadend::DeleteTimer
else if (timer.iTimerType == TIMER_REPEATING_MANUAL)
{
/* time-based repeating timer */
return DeleteRepeatingTimer(timer, deleteScheduled, true);
return m_timeRecordings.SendTimerecDelete(timer);
}
else if (timer.iTimerType == TIMER_REPEATING_EPG)
{
/* EPG-query-based repeating timer */
return DeleteRepeatingTimer(timer, deleteScheduled, false);
return m_autoRecordings.SendAutorecDelete(timer);
}
else
{
Expand Down
7 changes: 2 additions & 5 deletions src/Tvheadend.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,17 +416,14 @@ class CTvheadend
int GetTimerCount ( void );
PVR_ERROR GetTimers ( ADDON_HANDLE handle );
PVR_ERROR AddTimer ( const PVR_TIMER &tmr );
PVR_ERROR DeleteTimer ( const PVR_TIMER &tmr, bool force,
bool deleteScheduled );
PVR_ERROR DeleteTimer ( const PVR_TIMER &tmr, bool force );
PVR_ERROR UpdateTimer ( const PVR_TIMER &tmr );

PVR_ERROR GetEpg ( ADDON_HANDLE handle, const PVR_CHANNEL &chn,
time_t start, time_t end );

private:
bool CreateTimer ( const SRecording &tvhTmr, PVR_TIMER &tmr );
PVR_ERROR DeleteRepeatingTimer ( const PVR_TIMER &timer,
bool deleteScheduled, bool timerec );
bool CreateTimer ( const SRecording &tvhTmr, PVR_TIMER &tmr );

uint32_t GetNextUnnumberedChannelNumber ( void );
std::string GetImageURL ( const char *str );
Expand Down
4 changes: 2 additions & 2 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,9 @@ PVR_ERROR AddTimer(const PVR_TIMER &timer)
return tvh->AddTimer(timer);
}

PVR_ERROR DeleteTimer(const PVR_TIMER &timer, bool bForceDelete, bool bDeleteScheduled)
PVR_ERROR DeleteTimer(const PVR_TIMER &timer, bool bForceDelete)
{
return tvh->DeleteTimer(timer, bForceDelete, bDeleteScheduled);
return tvh->DeleteTimer(timer, bForceDelete);
}

PVR_ERROR UpdateTimer(const PVR_TIMER &timer)
Expand Down