Skip to content

Commit

Permalink
Merge branch 'master' into pvr-ppa
Browse files Browse the repository at this point in the history
  • Loading branch information
opdenkamp committed Apr 14, 2011
2 parents ab82e45 + 26ec15a commit 248d3f1
Show file tree
Hide file tree
Showing 47 changed files with 943 additions and 5,221 deletions.
2 changes: 1 addition & 1 deletion addons/pvr.hts/resources/language/Dutch/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<string id="30002">HTSP poort</string>
<string id="30003">Gebruikersnaam</string>
<string id="30004">Wachtwoord</string>
<string id="30005">Sla eerste I-frames over</string>
<string id="30006">Verbinding timeout in seconden</string>
<string id="30007">Antwoord timeout in seconden</string>
<string id="30008">Toon een melding bij timer updates</string>
</strings>
2 changes: 1 addition & 1 deletion addons/pvr.hts/resources/language/English/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<string id="30002">HTSP port</string>
<string id="30003">Username</string>
<string id="30004">Password</string>
<string id="30005">Skip first I-frames</string>
<string id="30006">Connect timeout in seconds</string>
<string id="30007">Response timeout in seconds</string>
<string id="30008">Display a notification on timer updates</string>
</strings>
1 change: 0 additions & 1 deletion addons/pvr.hts/resources/language/Finnish/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
<string id="30002">HTSP-portti</string>
<string id="30003">Käyttäjänimi</string>
<string id="30004">Salasana</string>
<string id="30005">Ohita ensimmäinen I-frame</string>
</strings>
2 changes: 1 addition & 1 deletion addons/pvr.hts/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<setting id="htsp_port" type="integer" label="30002" default="9982" />
<setting id="user" type="text" label="30003" default="" />
<setting id="pass" type="text" label="30004" option="hidden" default="" />
<setting id="skip_I_frame_count" type="enum" label="30005" values="0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15" default="0" />
<setting id="connect_timeout" type="enum" label="30006" values="1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60" default="29" />
<setting id="response_timeout" type="enum" label="30007" values="1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60" default="1" />
<setting id="notifications_timers" type="bool" label="30008" default="true" />
</settings>
4 changes: 2 additions & 2 deletions addons/skin.confluence/720p/DialogPVRGuideOSD.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
<width>20</width>
<height>20</height>
<texture>PVR-HasTimer.png</texture>
<visible>ListItem.HasTimer</visible>
<visible>ListItem.HasTimer + !ListItem.IsRecording</visible>
</control>
</itemlayout>
<focusedlayout height="60" width="500">
Expand Down Expand Up @@ -225,7 +225,7 @@
<posy>30</posy>
<width>20</width>
<height>20</height>
<texture>PVR-HasTimer.png</texture>
<texture>PVR-HasTimer.png + !ListItem.IsRecording</texture>
<visible>ListItem.HasTimer</visible>
</control>
</focusedlayout>
Expand Down
16 changes: 8 additions & 8 deletions addons/skin.confluence/720p/ViewsPVR.xml
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@
<width>20</width>
<height>20</height>
<texture>PVR-HasTimer.png</texture>
<visible>ListItem.HasTimer</visible>
<visible>ListItem.HasTimer + !ListItem.IsRecording</visible>
</control>
</itemlayout>
<focusedlayout height="52" width="40">
Expand Down Expand Up @@ -821,7 +821,7 @@
<width>20</width>
<height>20</height>
<texture>PVR-HasTimer.png</texture>
<visible>ListItem.HasTimer</visible>
<visible>ListItem.HasTimer + !ListItem.IsRecording</visible>
</control>
</focusedlayout>
</control>
Expand Down Expand Up @@ -1262,7 +1262,7 @@
<width>20</width>
<height>20</height>
<texture>PVR-HasTimer.png</texture>
<visible>ListItem.HasTimer</visible>
<visible>ListItem.HasTimer + !ListItem.IsRecording</visible>
</control>
<control type="label">
<posx>1000</posx>
Expand Down Expand Up @@ -1392,7 +1392,7 @@
<width>20</width>
<height>20</height>
<texture>PVR-HasTimer.png</texture>
<visible>ListItem.HasTimer</visible>
<visible>ListItem.HasTimer + !ListItem.IsRecording</visible>
</control>
<control type="label">
<posx>1000</posx>
Expand Down Expand Up @@ -1583,7 +1583,7 @@
<width>20</width>
<height>20</height>
<texture>PVR-HasTimer.png</texture>
<visible>ListItem.HasTimer</visible>
<visible>ListItem.HasTimer + !ListItem.IsRecording</visible>
</control>
<control type="label">
<posx>1000</posx>
Expand Down Expand Up @@ -1715,7 +1715,7 @@
<width>20</width>
<height>20</height>
<texture>PVR-HasTimer.png</texture>
<visible>ListItem.HasTimer</visible>
<visible>ListItem.HasTimer + !ListItem.IsRecording</visible>
</control>
<control type="label">
<posx>1000</posx>
Expand Down Expand Up @@ -1938,7 +1938,7 @@
<width>20</width>
<height>20</height>
<texture>PVR-HasTimer.png</texture>
<visible>ListItem.HasTimer</visible>
<visible>ListItem.HasTimer + !ListItem.IsRecording</visible>
</control>
<control type="label">
<posx>1000</posx>
Expand Down Expand Up @@ -2089,7 +2089,7 @@
<width>20</width>
<height>20</height>
<texture>PVR-HasTimer.png</texture>
<visible>ListItem.HasTimer</visible>
<visible>ListItem.HasTimer + !ListItem.IsRecording</visible>
</control>
<control type="label">
<posx>1000</posx>
Expand Down
1 change: 1 addition & 0 deletions language/English/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,7 @@
<string id="19220">Channels in</string>
<string id="19221">Synchronise channel groups with backends</string>
<string id="19222">EPG</string>
<string id="19223">No PVR add-on could be enabled. Check your settings or the log for more info.</string>

<string id="19499">Other/Unknown</string>
<string id="19500">Movie/Drama</string>
Expand Down
8 changes: 4 additions & 4 deletions xbmc/addons/AddonCallbacksPVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ void CAddonCallbacksPVR::PVRTransferTimerEntry(void *addonData, const PVR_HANDLE
return;
}

CPVRTimers *xbmcTimers = (CPVRTimers*) handle->dataAddress;
CPVRClient* client = (CPVRClient*) handle->callerAddress;
const CPVRChannel *channel = CPVRManager::GetChannelGroups()->GetByUniqueID(timer->iClientChannelUid, client->GetClientID());
CPVRTimers *xbmcTimers = (CPVRTimers*) handle->dataAddress;
CPVRClient* client = (CPVRClient*) handle->callerAddress;
CPVRChannel *channel = (CPVRChannel *) CPVRManager::GetChannelGroups()->GetByUniqueID(timer->iClientChannelUid, client->GetClientID());

if (channel == NULL)
{
Expand All @@ -184,7 +184,7 @@ void CAddonCallbacksPVR::PVRTransferTimerEntry(void *addonData, const PVR_HANDLE
return;
}

CPVRTimerInfoTag tag(*timer, client->GetClientID());
CPVRTimerInfoTag tag(*timer, channel, client->GetClientID());

/* transfer this entry to the timers container */
xbmcTimers->UpdateFromClient(tag);
Expand Down
26 changes: 13 additions & 13 deletions xbmc/addons/include/xbmc_pvr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +135,22 @@ extern "C" {
} PVR_EVENT;

/*!
* @brief PVR add-on capabilities.
* @brief PVR add-on capabilities. All capabilities are set to "false" as default.
*/
typedef struct PVR_ADDON_CAPABILITIES
{
bool bSupportsChannelLogo; /*!< @brief (required) true if this add-on supports channel logos */
bool bSupportsChannelSettings; /*!< @brief (required) true if this add-on supports changing channel settings on the backend */
bool bSupportsTimeshift; /*!< @brief (required) true if the backend will handle timeshift. false if XBMC should handle it. */
bool bSupportsEPG; /*!< @brief (required) true if the add-on provides EPG information */
bool bSupportsTV; /*!< @brief (required) true if this add-on provides TV channels */
bool bSupportsRadio; /*!< @brief (required) true if this add-on supports radio channels */
bool bSupportsRecordings; /*!< @brief (required) true if this add-on supports playback of recordings stored on the backend */
bool bSupportsTimers; /*!< @brief (required) true if this add-on supports the creation and editing of timers */
bool bSupportsChannelGroups; /*!< @brief (required) true if this add-on supports channel groups */
bool bSupportsChannelScan; /*!< @brief (required) true if this add-on support scanning for new channels on the backend */
bool bHandlesInputStream; /*!< @brief (required) true if this add-on provides an input stream. false if XBMC handles the stream. */
bool bHandlesDemuxing; /*!< @brief (required) true if this add-on demultiplexes packets. */
bool bSupportsChannelLogo; /*!< @brief (optional) true if this add-on supports channel logos */
bool bSupportsChannelSettings; /*!< @brief (optional) true if this add-on supports changing channel settings on the backend */
bool bSupportsTimeshift; /*!< @brief (optional) true if the backend will handle timeshift. false if XBMC should handle it. */
bool bSupportsEPG; /*!< @brief (optional) true if the add-on provides EPG information */
bool bSupportsTV; /*!< @brief (optional) true if this add-on provides TV channels */
bool bSupportsRadio; /*!< @brief (optional) true if this add-on supports radio channels */
bool bSupportsRecordings; /*!< @brief (optional) true if this add-on supports playback of recordings stored on the backend */
bool bSupportsTimers; /*!< @brief (optional) true if this add-on supports the creation and editing of timers */
bool bSupportsChannelGroups; /*!< @brief (optional) true if this add-on supports channel groups */
bool bSupportsChannelScan; /*!< @brief (optional) true if this add-on support scanning for new channels on the backend */
bool bHandlesInputStream; /*!< @brief (optional) true if this add-on provides an input stream. false if XBMC handles the stream. */
bool bHandlesDemuxing; /*!< @brief (optional) true if this add-on demultiplexes packets. */
} ATTRIBUTE_PACKED PVR_ADDON_CAPABILITIES;

/*!
Expand Down
6 changes: 4 additions & 2 deletions xbmc/epg/Epg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ void CEpg::Clear(void)

void CEpg::Cleanup(void)
{
Cleanup(CDateTime::GetCurrentDateTime());
Cleanup(CDateTime::GetCurrentDateTime().GetAsUTCDateTime());
}

void CEpg::Cleanup(const CDateTime &Time)
{
CSingleLock lock(m_critSection);

CDateTime firstDate = Time.GetAsUTCDateTime() - CDateTimeSpan(0, g_advancedSettings.m_iEpgLingerTime / 60, g_advancedSettings.m_iEpgLingerTime % 60, 0);
CDateTime firstDate = Time - CDateTimeSpan(0, g_advancedSettings.m_iEpgLingerTime / 60, g_advancedSettings.m_iEpgLingerTime % 60, 0);
CDateTime dummy; dummy.SetValid(false);

RemoveTagsBetween(dummy, firstDate);
Expand Down Expand Up @@ -245,6 +245,8 @@ const CEpgInfoTag *CEpg::InfoTagNow(void) const

const CEpgInfoTag *CEpg::InfoTagNext(void) const
{
CSingleLock lock(m_critSection);

const CEpgInfoTag *nowTag = InfoTagNow();

return nowTag ? nowTag->GetNextEvent() : NULL;
Expand Down
2 changes: 1 addition & 1 deletion xbmc/epg/Epg.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class CEpg : public std::vector<CEpgInfoTag*>
/*!
* @brief Remove all entries from this EPG that finished before the given time
* and that have no timers set.
* @param Time Delete entries with an end time before this time.
* @param Time Delete entries with an end time before this time in UTC.
*/
virtual void Cleanup(const CDateTime &Time);

Expand Down
88 changes: 58 additions & 30 deletions xbmc/epg/EpgContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,14 @@ void CEpgContainer::Process(void)

AutoCreateTablesHook();

bool bInitialLoadSucess = UpdateEPG(true);

while (!m_bStop)
{
CDateTime::GetCurrentDateTime().GetAsTime(iNow);

/* load or update the EPG */
if (!m_bStop && (iNow > m_iLastEpgUpdate + g_advancedSettings.m_iEpgUpdateCheckInterval || !m_bDatabaseLoaded))
{
UpdateEPG(!bInitialLoadSucess);
bInitialLoadSucess = true;
UpdateEPG(!m_bDatabaseLoaded);
}

/* clean up old entries */
Expand Down Expand Up @@ -299,12 +296,54 @@ bool CEpgContainer::DeleteEpg(const CEpg &epg, bool bDeleteFromDatabase /* = fal
return bReturn;
}

bool CEpgContainer::UpdateSingleTable(CEpg *epg, const time_t start, const time_t end)
{
bool bReturn(false);

if (!epg)
return bReturn;

if (m_bDatabaseLoaded)
epg->Cleanup();

bReturn = m_bDatabaseLoaded || m_bIgnoreDbForClient ?
epg->Update(start, end, m_iUpdateTime) :
epg->Load();

/* try to update the table from clients if nothing was loaded from the db */
if (!m_bDatabaseLoaded && !m_bIgnoreDbForClient && !bReturn)
bReturn = epg->Update(start, end, m_iUpdateTime);

if (!bReturn && m_bDatabaseLoaded)
{
CLog::Log(LOGERROR, "EpgContainer - %s - failed to update table '%s'",
__FUNCTION__, epg->Name().c_str());
}

return bReturn;
}

bool CEpgContainer::InterruptUpdate(void) const
{
if (m_bStop || (CPVRManager::Get()->IsStarted() && CPVRManager::GetClients()->IsPlaying()))
{
CLog::Log(LOGNOTICE, "EpgContainer - %s - EPG load/update interrupted", __FUNCTION__);
return true;
}

return false;
}

bool CEpgContainer::UpdateEPG(bool bShowProgress /* = false */)
{
CSingleLock lock(m_critSection);
unsigned int iEpgCount = size();

if (InterruptUpdate())
return false;
lock.Leave();

bool bInterrupted(false);
long iStartTime = CTimeUtils::GetTimeMS();
bool bUpdateSuccess = true;
CGUIDialogExtendedProgressBar *progress = NULL;
Expand All @@ -319,7 +358,7 @@ bool CEpgContainer::UpdateEPG(bool bShowProgress /* = false */)
/* set start and end time */
time_t start;
time_t end;
CDateTime::GetCurrentDateTime().GetAsTime(start); // NOTE: XBMC stores the EPG times as local time
CDateTime::GetCurrentDateTime().GetAsUTCDateTime().GetAsTime(start);
end = start;
start -= g_advancedSettings.m_iEpgLingerTime * 60;
end += m_iDisplayTime;
Expand All @@ -344,32 +383,17 @@ bool CEpgContainer::UpdateEPG(bool bShowProgress /* = false */)
/* load or update all EPG tables */
for (unsigned int iEpgPtr = 0; iEpgPtr < iEpgCount; iEpgPtr++)
{
/* interrupt the update on exit or when livetv is playing */
if (m_bStop || (CPVRManager::Get()->IsStarted() && CPVRManager::GetClients()->IsPlaying()))
if (InterruptUpdate())
{
CLog::Log(LOGNOTICE, "EpgContainer - %s - EPG load/update interrupted", __FUNCTION__);
bUpdateSuccess = false;
bInterrupted = true;
break;
}

CEpg *epg = GetByIndex(iEpgPtr);
if (!epg)
continue;

if (m_bDatabaseLoaded)
at(iEpgPtr)->Cleanup();

bool bCurrent = m_bDatabaseLoaded || m_bIgnoreDbForClient ?
at(iEpgPtr)->Update(start, end, m_iUpdateTime) :
at(iEpgPtr)->Load() && bUpdateSuccess;

/* try to update the table from clients if nothing was loaded from the db */
if (!m_bDatabaseLoaded && !m_bIgnoreDbForClient && !bCurrent)
bCurrent = at(iEpgPtr)->Update(start, end, m_iUpdateTime);

if (!bCurrent && m_bDatabaseLoaded)
CLog::Log(LOGERROR, "EpgContainer - %s - failed to update table '%s'",
__FUNCTION__, at(iEpgPtr)->Name().c_str());
bool bCurrent = UpdateSingleTable(epg, start, end);

bUpdateSuccess = bCurrent && bUpdateSuccess;
if (bCurrent)
Expand All @@ -387,10 +411,17 @@ bool CEpgContainer::UpdateEPG(bool bShowProgress /* = false */)
Sleep(50); /* give other threads a chance to get a lock on tables */
}

CDateTime::GetCurrentDateTime().GetAsTime(m_iLastEpgUpdate);
/* update the last scan time if we did a full update */
if (bUpdateSuccess && m_bDatabaseLoaded && !m_bIgnoreDbForClient)
m_database.PersistLastEpgScanTime(0);
if (!bInterrupted)
{
/* only try to load the database once */
m_bDatabaseLoaded = true;

CDateTime::GetCurrentDateTime().GetAsTime(m_iLastEpgUpdate);
/* update the last scan time if we did a full update */
if (bUpdateSuccess && m_bDatabaseLoaded && !m_bIgnoreDbForClient)
m_database.PersistLastEpgScanTime(0);
}

m_database.Close();

if (bShowProgress)
Expand All @@ -400,9 +431,6 @@ bool CEpgContainer::UpdateEPG(bool bShowProgress /* = false */)
CLog::Log(LOGINFO, "EpgContainer - %s - finished %s %d EPG tables after %li.%li seconds",
__FUNCTION__, m_bDatabaseLoaded ? "updating" : "loading", iEpgCount, lUpdateTime / 1000, lUpdateTime % 1000);

/* only try to load the database once */
m_bDatabaseLoaded = true;

/* notify observers */
if (iUpdatedTables > 0)
{
Expand Down
14 changes: 14 additions & 0 deletions xbmc/epg/EpgContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ class CEpgContainer : public std::vector<CEpg *>,
*/
virtual bool UpdateEPG(bool bShowProgress = false);

/*!
* @return True if a running update should be interrupted, false otherwise.
*/
virtual bool InterruptUpdate(void) const;

/*!
* @brief Load or update a single table.
* @param epg The table to update.
* @param start The start time to use.
* @param end The end time to use.
* @return True if the load or update was successful, false otherwise.
*/
virtual bool UpdateSingleTable(CEpg *epg, const time_t start, const time_t end);

/*!
* @brief A hook that will be called on every update thread iteration.
*/
Expand Down
Loading

0 comments on commit 248d3f1

Please sign in to comment.