void CPVRGUIInfo::UpdateTimeshift(void) { bool bStarted = g_PVRManager.IsStarted(); bool bIsTimeshifting = bStarted && g_PVRClients->IsTimeshifting(); CDateTime tmp; time_t iTimeshiftStartTime = g_PVRClients->GetBufferTimeStart(); tmp.SetFromUTCDateTime(iTimeshiftStartTime); std::string strTimeshiftStartTime = tmp.GetAsLocalizedTime("", false); time_t iTimeshiftEndTime = g_PVRClients->GetBufferTimeEnd(); tmp.SetFromUTCDateTime(iTimeshiftEndTime); std::string strTimeshiftEndTime = tmp.GetAsLocalizedTime("", false); time_t iTimeshiftPlayTime = g_PVRClients->GetPlayingTime(); tmp.SetFromUTCDateTime(iTimeshiftPlayTime); std::string strTimeshiftPlayTime = tmp.GetAsLocalizedTime("", true); CSingleLock lock(m_critSection); m_bIsTimeshifting = bIsTimeshifting; m_iTimeshiftStartTime = iTimeshiftStartTime; m_iTimeshiftEndTime = iTimeshiftEndTime; m_iTimeshiftPlayTime = iTimeshiftPlayTime; m_strTimeshiftStartTime = strTimeshiftStartTime; m_strTimeshiftEndTime = strTimeshiftEndTime; m_strTimeshiftPlayTime = strTimeshiftPlayTime; }
const CDateTime &CPVRTimerInfoTag::EndAsLocalTime(void) const { static CDateTime tmp; tmp.SetFromUTCDateTime(m_StopTime); return tmp; }
const CDateTime &CEpgInfoTag::EndAsLocalTime(void) const { static CDateTime tmp; tmp.SetFromUTCDateTime(m_endTime); return tmp; }
const CDateTime &CEpgInfoTag::FirstAiredAsLocalTime(void) const { static CDateTime tmp; tmp.SetFromUTCDateTime(m_firstAired); return tmp; }
CDateTime CEpgInfoTag::FirstAiredAsLocalTime(void) const { CDateTime retVal; CSingleLock lock(m_critSection); retVal.SetFromUTCDateTime(m_firstAired); return retVal; }
CDateTime CEpgInfoTag::EndAsLocalTime(void) const { CDateTime retVal; CSingleLock lock(m_critSection); retVal.SetFromUTCDateTime(m_endTime); return retVal; }
const CDateTime &CPVRRecording::RecordingTimeAsLocalTime(void) const { static CDateTime tmp; tmp.SetFromUTCDateTime(m_recordingTime); return tmp; }
const CDateTime &CPVRTimerInfoTag::FirstDayAsLocalTime(void) const { static CDateTime tmp; tmp.SetFromUTCDateTime(m_FirstDay); return tmp; }
const CDateTime &CEpgInfoTag::StartAsLocalTime(void) const { static CDateTime tmp; tmp.SetFromUTCDateTime(m_startTime); return tmp; }
const CDateTime &CPVRTimerInfoTag::FirstDayAsLocalTime(void) const { static CDateTime tmp; CSingleLock lock(m_critSection); tmp.SetFromUTCDateTime(m_FirstDay); return tmp; }
void CGUIWindowPVRGuide::UpdateViewTimeline(void) { CPVRChannel CurrentChannel; bool bGotCurrentChannel = g_PVRManager.GetCurrentChannel(CurrentChannel); bool bRadio = bGotCurrentChannel ? CurrentChannel.IsRadio() : false; CDateTime gridStart = CDateTime::GetCurrentDateTime(); CDateTime firstDate; firstDate.SetFromUTCDateTime(g_EpgContainer.GetFirstEPGDate()); CDateTime lastDate; lastDate.SetFromUTCDateTime(g_EpgContainer.GetLastEPGDate()); m_parent->m_guideGrid = (CGUIEPGGridContainer*) m_parent->GetControl(CONTROL_LIST_TIMELINE); if (!m_parent->m_guideGrid) return; m_parent->SetLabel(m_iControlButton, g_localizeStrings.Get(19222) + ": " + g_localizeStrings.Get(19032)); m_parent->SetLabel(CONTROL_LABELGROUP, g_localizeStrings.Get(19032)); g_PVRManager.GetPlayingGroup(bRadio)->GetEPGAll(*m_parent->m_vecItems); m_parent->m_vecItems->RemoveDiscCache(m_parent->GetID()); m_parent->m_guideGrid->SetStartEnd(firstDate > gridStart ? firstDate : gridStart, lastDate); m_parent->m_viewControl.SetCurrentView(CONTROL_LIST_TIMELINE); SelectPlayingFile(); }
int CEpg::Get(CFileItemList &results) const { int iInitialSize = results.Size(); CSingleLock lock(m_critSection); for (map<CDateTime, CEpgInfoTag *>::const_iterator it = m_tags.begin(); it != m_tags.end(); it++) { CDateTime localStartTime; localStartTime.SetFromUTCDateTime(it->first); CFileItemPtr entry(new CFileItem(*it->second)); entry->SetLabel2(localStartTime.GetAsLocalizedDateTime(false, false)); results.Add(entry); } return results.Size() - iInitialSize; }
CDateTime CEpgInfoTag::FirstAiredAsLocalTime(void) const { CDateTime retVal; retVal.SetFromUTCDateTime(m_firstAired); return retVal; }
CDateTime CPVRRecording::EndTimeAsLocalTime() const { CDateTime ret; ret.SetFromUTCDateTime(EndTimeAsUTC()); return ret; }
CDateTime CEpgInfoTag::StartAsLocalTime(void) const { CDateTime retVal; retVal.SetFromUTCDateTime(m_startTime); return retVal; }
CDateTime CEpgInfoTag::EndAsLocalTime(void) const { CDateTime retVal; retVal.SetFromUTCDateTime(m_endTime); return retVal; }
void CGUIEPGGridContainerModel::Initialize(const std::unique_ptr<CFileItemList> &items, const CDateTime &gridStart, const CDateTime &gridEnd, int iRulerUnit, int iBlocksPerPage, float fBlockSize) { if (!m_channelItems.empty()) { CLog::LogF(LOGERROR, "Already initialized!"); return; } //////////////////////////////////////////////////////////////////////// // Create programme & channel items m_programmeItems.reserve(items->Size()); CFileItemPtr fileItem; int iLastChannelID = -1; ItemsPtr itemsPointer; itemsPointer.start = 0; CPVRChannelPtr channel; int j = 0; for (int i = 0; i < items->Size(); ++i) { fileItem = items->Get(i); if (!fileItem->HasEPGInfoTag() || !fileItem->GetEPGInfoTag()->HasChannel()) continue; m_programmeItems.emplace_back(fileItem); channel = fileItem->GetEPGInfoTag()->Channel(); if (!channel) continue; int iCurrentChannelID = channel->ChannelID(); if (iCurrentChannelID != iLastChannelID) { if (j > 0) { itemsPointer.stop = j - 1; m_epgItemsPtr.emplace_back(itemsPointer); itemsPointer.start = j; } iLastChannelID = iCurrentChannelID; m_channelItems.emplace_back(CFileItemPtr(new CFileItem(channel))); } ++j; } if (!m_programmeItems.empty()) { itemsPointer.stop = m_programmeItems.size() - 1; m_epgItemsPtr.emplace_back(itemsPointer); } /* check for invalid start and end time */ if (gridStart >= gridEnd) { // default to start "now minus GRID_START_PADDING minutes" and end "start plus one page". m_gridStart = CDateTime::GetUTCDateTime() - CDateTimeSpan(0, 0, GetGridStartPadding(), 0); m_gridEnd = m_gridStart + CDateTimeSpan(0, 0, iBlocksPerPage * MINSPERBLOCK, 0); } else if (gridStart > (CDateTime::GetUTCDateTime() - CDateTimeSpan(0, 0, GetGridStartPadding(), 0))) { // adjust to start "now minus GRID_START_PADDING minutes". m_gridStart = CDateTime::GetUTCDateTime() - CDateTimeSpan(0, 0, GetGridStartPadding(), 0); m_gridEnd = gridEnd; } else { m_gridStart = gridStart; m_gridEnd = gridEnd; } // roundup m_gridStart = CDateTime(m_gridStart.GetYear(), m_gridStart.GetMonth(), m_gridStart.GetDay(), m_gridStart.GetHour(), m_gridStart.GetMinute() >= 30 ? 30 : 0, 0); m_gridEnd = CDateTime(m_gridEnd.GetYear(), m_gridEnd.GetMonth(), m_gridEnd.GetDay(), m_gridEnd.GetHour(), m_gridEnd.GetMinute() >= 30 ? 30 : 0, 0); //////////////////////////////////////////////////////////////////////// // Create ruler items CDateTime ruler; ruler.SetFromUTCDateTime(m_gridStart); CDateTime rulerEnd; rulerEnd.SetFromUTCDateTime(m_gridEnd); CFileItemPtr rulerItem(new CFileItem(ruler.GetAsLocalizedDate(true))); rulerItem->SetProperty("DateLabel", true); m_rulerItems.emplace_back(rulerItem); const CDateTimeSpan unit(0, 0, iRulerUnit * MINSPERBLOCK, 0); for (; ruler < rulerEnd; ruler += unit) { rulerItem.reset(new CFileItem(ruler.GetAsLocalizedTime("", false))); rulerItem->SetLabel2(ruler.GetAsLocalizedDate(true)); m_rulerItems.emplace_back(rulerItem); } FreeItemsMemory(); //////////////////////////////////////////////////////////////////////// // Create epg grid const CDateTimeSpan blockDuration(0, 0, MINSPERBLOCK, 0); const CDateTimeSpan gridDuration(m_gridEnd - m_gridStart); m_blocks = (gridDuration.GetDays() * 24 * 60 + gridDuration.GetHours() * 60 + gridDuration.GetMinutes()) / MINSPERBLOCK; if (m_blocks >= MAXBLOCKS) m_blocks = MAXBLOCKS; else if (m_blocks < iBlocksPerPage) m_blocks = iBlocksPerPage; m_gridIndex.reserve(m_channelItems.size()); const std::vector<GridItem> blocks(m_blocks); for (size_t channel = 0; channel < m_channelItems.size(); ++channel) { m_gridIndex.emplace_back(blocks); CDateTime gridCursor(m_gridStart); //reset cursor for new channel unsigned long progIdx = m_epgItemsPtr[channel].start; unsigned long lastIdx = m_epgItemsPtr[channel].stop; int iEpgId = m_programmeItems[progIdx]->GetEPGInfoTag()->EpgID(); int itemSize = 1; // size of the programme in blocks int savedBlock = 0; CFileItemPtr item; CPVREpgInfoTagPtr tag; for (int block = 0; block < m_blocks; ++block) { while (progIdx <= lastIdx) { item = m_programmeItems[progIdx]; tag = item->GetEPGInfoTag(); // Note: Start block of an event is start-time-based calculated block + 1, // unless start times matches exactly the begin of a block. if (tag->EpgID() != iEpgId || gridCursor < tag->StartAsUTC() || m_gridEnd <= tag->StartAsUTC()) break; if (gridCursor < tag->EndAsUTC()) { m_gridIndex[channel][block].item = item; m_gridIndex[channel][block].progIndex = progIdx; break; } progIdx++; } gridCursor += blockDuration; if (block == 0) continue; const CFileItemPtr prevItem(m_gridIndex[channel][block - 1].item); const CFileItemPtr currItem(m_gridIndex[channel][block].item); if (block == m_blocks - 1 || prevItem != currItem) { // special handling for last block. int blockDelta = -1; int sizeDelta = 0; if (block == m_blocks - 1 && prevItem == currItem) { itemSize++; blockDelta = 0; sizeDelta = 1; } if (prevItem) { m_gridIndex[channel][savedBlock].item->SetProperty("GenreType", prevItem->GetEPGInfoTag()->GenreType()); } else { CPVREpgInfoTagPtr gapTag(CPVREpgInfoTag::CreateDefaultTag()); gapTag->SetChannel(m_channelItems[channel]->GetPVRChannelInfoTag()); CFileItemPtr gapItem(new CFileItem(gapTag)); for (int i = block + blockDelta; i >= block - itemSize + sizeDelta; --i) { m_gridIndex[channel][i].item = gapItem; } } float fItemWidth = itemSize * fBlockSize; m_gridIndex[channel][savedBlock].originWidth = fItemWidth; m_gridIndex[channel][savedBlock].width = fItemWidth; itemSize = 1; savedBlock = block; // special handling for last block. if (block == m_blocks - 1 && prevItem != currItem) { if (currItem) { m_gridIndex[channel][savedBlock].item->SetProperty("GenreType", currItem->GetEPGInfoTag()->GenreType()); } else { CPVREpgInfoTagPtr gapTag(CPVREpgInfoTag::CreateDefaultTag()); gapTag->SetChannel(m_channelItems[channel]->GetPVRChannelInfoTag()); CFileItemPtr gapItem(new CFileItem(gapTag)); m_gridIndex[channel][block].item = gapItem; } m_gridIndex[channel][savedBlock].originWidth = fBlockSize; // size always 1 block here m_gridIndex[channel][savedBlock].width = fBlockSize; } } else { itemSize++; } } } }
CDateTime CPVRTimerInfoTag::FirstDayAsLocalTime(void) const { CDateTime retVal; retVal.SetFromUTCDateTime(m_FirstDay); return retVal; }
CDateTime CPVRTimerInfoTag::EndAsLocalTime(void) const { CDateTime retVal; retVal.SetFromUTCDateTime(m_StopTime); return retVal; }