void CPVRGUIInfo::UpdatePlayingTag(void) { CPVRChannelPtr currentChannel; CPVRRecording recording; if (g_PVRManager.GetCurrentChannel(currentChannel)) { CEpgInfoTag epgTag; bool bHasEpgTag = GetPlayingTag(epgTag); CPVRChannelPtr channel; if (bHasEpgTag) channel = epgTag.ChannelTag(); if (!bHasEpgTag || !epgTag.IsActive() || !channel || *channel != *currentChannel) { CEpgInfoTag newTag; { CSingleLock lock(m_critSection); ResetPlayingTag(); if (currentChannel->GetEPGNow(newTag)) { m_playingEpgTag = new CEpgInfoTag(newTag); m_iDuration = m_playingEpgTag->GetDuration() * 1000; } } g_PVRManager.UpdateCurrentFile(); } } else if (g_PVRClients->GetPlayingRecording(recording)) { ResetPlayingTag(); m_iDuration = recording.GetDuration() * 1000; } }
CPVRTimerInfoTagPtr CPVRTimerInfoTag::CreateInstantTimerTag(const CPVRChannelPtr &channel) { if (!channel) { CLog::Log(LOGERROR, "%s - no channel set", __FUNCTION__); return CPVRTimerInfoTagPtr(); } CEpgInfoTagPtr epgTag(channel->GetEPGNow()); CPVRTimerInfoTagPtr newTimer; if (epgTag) newTimer = CreateFromEpg(epgTag); if (!newTimer) { newTimer.reset(new CPVRTimerInfoTag); newTimer->m_iClientIndex = PVR_TIMER_NO_CLIENT_INDEX; newTimer->m_iParentClientIndex = PVR_TIMER_NO_PARENT; newTimer->m_channel = channel; newTimer->m_strTitle = channel->ChannelName(); newTimer->m_iChannelNumber = channel->ChannelNumber(); newTimer->m_iClientChannelUid = channel->UniqueID(); newTimer->m_iClientId = channel->ClientID(); newTimer->m_bIsRadio = channel->IsRadio(); // timertype: manual one-shot timer for given client CPVRTimerTypePtr timerType(CPVRTimerType::CreateFromAttributes( PVR_TIMER_TYPE_IS_MANUAL, PVR_TIMER_TYPE_IS_REPEATING | PVR_TIMER_TYPE_FORBIDS_NEW_INSTANCES, channel->ClientID())); if (!timerType) { CLog::Log(LOGERROR, "%s - unable to create one shot manual timer type", __FUNCTION__); return CPVRTimerInfoTagPtr(); } newTimer->SetTimerType(timerType); } // no matter the timer was created from an epg tag, set special instant timer start and end times. CDateTime startTime(0); newTimer->SetStartFromUTC(startTime); newTimer->m_iMarginStart = 0; /* set the start margin to 0 for instant timers */ int iDuration = CSettings::GetInstance().GetInt(CSettings::SETTING_PVRRECORD_INSTANTRECORDTIME); CDateTime endTime = CDateTime::GetUTCDateTime() + CDateTimeSpan(0, 0, iDuration ? iDuration : 120, 0); newTimer->SetEndFromUTC(endTime); /* update summary string according to changed start/end time */ newTimer->UpdateSummary(); /* set epg tag at timer & timer at epg tag */ newTimer->UpdateEpgInfoTag(); /* unused only for reference */ newTimer->m_strFileNameAndPath = CPVRTimersPath::PATH_NEW; return newTimer; }
bool CGUIWindowPVRBase::AddTimer(CFileItem *item, bool bCreateRule, bool bShowTimerSettings) { CEpgInfoTagPtr epgTag; CPVRChannelPtr channel; if (item->IsEPG()) { epgTag = item->GetEPGInfoTag(); channel = epgTag->ChannelTag(); } else if (item->IsPVRChannel()) { channel = item->GetPVRChannelInfoTag(); epgTag = channel->GetEPGNow(); } if (!channel) { CLog::Log(LOGERROR, "CGUIWindowPVRBase - %s - no channel!", __FUNCTION__); return false; } if (!g_PVRManager.CheckParentalLock(channel)) return false; if (!epgTag && bCreateRule) { CLog::Log(LOGERROR, "CGUIWindowPVRBase - %s - no epg tag!", __FUNCTION__); return false; } CPVRTimerInfoTagPtr timer(bCreateRule || !epgTag ? nullptr : epgTag->Timer()); CPVRTimerInfoTagPtr rule (bCreateRule ? g_PVRTimers->GetTimerRule(timer) : nullptr); if (timer || rule) { CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19034}); // "Information", "There is already a timer set for this event" return false; } CPVRTimerInfoTagPtr newTimer(epgTag ? CPVRTimerInfoTag::CreateFromEpg(epgTag, bCreateRule) : CPVRTimerInfoTag::CreateInstantTimerTag(channel)); if (!newTimer) { CGUIDialogOK::ShowAndGetInput(CVariant{19033}, bCreateRule ? CVariant{19095} // "Information", "Timer rule creation failed. The PVR add-on does not support a suitable timer rule type." : CVariant{19094}); // "Information", "Timer creation failed. The PVR add-on does not support a suitable timer type." return false; } if (bShowTimerSettings) { if (!ShowTimerSettings(newTimer)) return false; } return g_PVRTimers->AddTimer(newTimer); }
EPG::CEpgInfoTagPtr CPlayerOperations::GetCurrentEpg() { if (!g_PVRManager.IsPlayingTV() && !g_PVRManager.IsPlayingRadio()) return EPG::CEpgInfoTagPtr(); CPVRChannelPtr currentChannel; if (!g_PVRManager.GetCurrentChannel(currentChannel)) return EPG::CEpgInfoTagPtr(); return currentChannel->GetEPGNow(); }
bool CPVRTimers::InstantTimer(const CPVRChannelPtr &channel) { assert(channel.get()); if (!g_PVRManager.CheckParentalLock(channel)) return false; CEpgInfoTagPtr epgTag(channel->GetEPGNow()); CPVRTimerInfoTagPtr newTimer; if (epgTag) newTimer = CPVRTimerInfoTag::CreateFromEpg(epgTag); if (!newTimer) { newTimer.reset(new CPVRTimerInfoTag); /* set the timer data */ newTimer->m_iClientIndex = -1; newTimer->m_strTitle = channel->ChannelName(); newTimer->m_strSummary = g_localizeStrings.Get(19056); newTimer->m_iChannelNumber = channel->ChannelNumber(); newTimer->m_iClientChannelUid = channel->UniqueID(); newTimer->m_iClientId = channel->ClientID(); newTimer->m_bIsRadio = channel->IsRadio(); /* generate summary string */ newTimer->m_strSummary = StringUtils::Format("%s %s %s %s %s", newTimer->StartAsLocalTime().GetAsLocalizedDate().c_str(), g_localizeStrings.Get(19159).c_str(), newTimer->StartAsLocalTime().GetAsLocalizedTime("", false).c_str(), g_localizeStrings.Get(19160).c_str(), newTimer->EndAsLocalTime().GetAsLocalizedTime("", false).c_str()); } CDateTime startTime(0); newTimer->SetStartFromUTC(startTime); newTimer->m_iMarginStart = 0; /* set the start margin to 0 for instant timers */ int iDuration = CSettings::GetInstance().GetInt(CSettings::SETTING_PVRRECORD_INSTANTRECORDTIME); CDateTime endTime = CDateTime::GetUTCDateTime() + CDateTimeSpan(0, 0, iDuration ? iDuration : 120, 0); newTimer->SetEndFromUTC(endTime); /* unused only for reference */ newTimer->m_strFileNameAndPath = CPVRTimersPath::PATH_NEW; bool bReturn = newTimer->AddToClient(); if (!bReturn) CLog::Log(LOGERROR, "PVRTimers - %s - unable to add an instant timer on the client", __FUNCTION__); return bReturn; }
bool CPlayerOperations::GetCurrentEpg(EPG::CEpgInfoTag &epg) { if (!g_PVRManager.IsPlayingTV() && !g_PVRManager.IsPlayingRadio()) return false; CPVRChannelPtr currentChannel; if (!g_PVRManager.GetCurrentChannel(currentChannel)) return false; if (!currentChannel->GetEPGNow(epg)) return false; return true; }
void CGUIWindowPVRBase::ShowEPGInfo(CFileItem *item) { CEpgInfoTagPtr epgTag; CPVRChannelPtr channel; if (item->IsEPG()) { epgTag = item->GetEPGInfoTag(); channel = epgTag->ChannelTag(); } else if (item->IsPVRChannel()) { channel = item->GetPVRChannelInfoTag(); epgTag = channel->GetEPGNow(); } else if (item->IsPVRTimer()) { epgTag = item->GetPVRTimerInfoTag()->GetEpgInfoTag(); if (epgTag && epgTag->HasPVRChannel()) channel = epgTag->ChannelTag(); } if (channel && !g_PVRManager.CheckParentalLock(channel)) return; if (!epgTag) { CLog::Log(LOGERROR, "CGUIWindowPVRBase - %s - no epg tag!", __FUNCTION__); return; } CGUIDialogPVRGuideInfo* pDlgInfo = (CGUIDialogPVRGuideInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_GUIDE_INFO); if (!pDlgInfo) { CLog::Log(LOGERROR, "CGUIWindowPVRBase - %s - unable to get WINDOW_DIALOG_PVR_GUIDE_INFO!", __FUNCTION__); return; } pDlgInfo->SetProgInfo(epgTag); pDlgInfo->Open(); }