bool CPVRChannelGroupInternal::AddToGroup(CPVRChannel &channel, int iChannelNumber /* = 0 */) { CSingleLock lock(m_critSection); bool bReturn(false); /* get the actual channel since this is called from a fileitemlist copy */ CPVRChannelPtr realChannel = GetByChannelID(channel.ChannelID()); if (!realChannel) return bReturn; /* switch the hidden flag */ if (realChannel->IsHidden()) { realChannel->SetHidden(false); m_iHiddenChannels--; SortAndRenumber(); } /* move this channel and persist */ bReturn = (iChannelNumber > 0l) ? MoveChannel(realChannel->ChannelNumber(), iChannelNumber, true) : MoveChannel(realChannel->ChannelNumber(), m_members.size() - m_iHiddenChannels, true); if (m_bLoaded) realChannel->Persist(); return bReturn; }
int CPVREpgs::GetEPGAll(CFileItemList* results, bool bRadio /* = false */) { int iInitialSize = results->Size(); for (unsigned int iEpgPtr = 0; iEpgPtr < size(); iEpgPtr++) { CPVREpg *epg = at(iEpgPtr); CPVRChannel *channel = at(iEpgPtr)->Channel(); if (!channel || channel->IsRadio() != bRadio) continue; epg->Get(results); } return results->Size() - iInitialSize; }
bool CPVRTimers::ChannelHasTimers(const CPVRChannel &channel) { CSingleLock lock(m_critSection); for (map<CDateTime, vector<CPVRTimerInfoTag *>* >::iterator it = m_tags.begin(); it != m_tags.end(); it++) { for (unsigned int iTimerPtr = 0; iTimerPtr < it->second->size(); iTimerPtr++) { CPVRTimerInfoTag *timer = it->second->at(iTimerPtr); if (timer->ChannelNumber() == channel.ChannelNumber() && timer->m_bIsRadio == channel.IsRadio()) return true; } } return false; }
void CGUIDialogPVRGuideOSD::Update() { // lock our display, as this window is rendered from the player thread g_graphicsContext.Lock(); m_viewControl.SetCurrentView(DEFAULT_VIEW_LIST); // empty the list ready for population Clear(); CPVRChannel CurrentChannel; if (g_PVRManager.GetCurrentChannel(&CurrentChannel)) CurrentChannel.GetEPG(m_vecItems); m_viewControl.SetItems(*m_vecItems); g_graphicsContext.Unlock(); }
bool CPVRChannelGroup::ToggleChannelLocked(const CFileItem &item) { if (!item.HasPVRChannelInfoTag()) return false; CSingleLock lock(m_critSection); /* get the real channel from the group */ CPVRChannel *channel = GetByUniqueID(item.GetPVRChannelInfoTag()->UniqueID()); if (!channel) return false; channel->SetLocked(!channel->IsLocked()); return true; }
bool CPVRDatabase::DeleteChannelSettings(const CPVRChannel &channel) { bool bReturn(false); /* invalid channel */ if (channel.ChannelID() <= 0) { CLog::Log(LOGERROR, "PVR - %s - invalid channel id: %i", __FUNCTION__, channel.ChannelID()); return bReturn; } Filter filter; filter.AppendWhere(PrepareSQL("idChannel = %u", channel.ChannelID())); return DeleteValues("channelsettings", filter); }
bool CPVRClient::SwitchChannel(const CPVRChannel &channel) { bool bSwitched(false); if (IsPlayingLiveStream() && CanPlayChannel(channel)) { PVR_CHANNEL tag; WriteClientChannelInfo(channel, tag); try { bSwitched = m_pStruct->SwitchChannel(tag); } catch (std::exception &e) { LogException(e, __FUNCTION__); } } if (bSwitched) { CPVRChannelPtr currentChannel = g_PVRChannelGroups->GetByUniqueID(channel.UniqueID(), channel.ClientID()); CSingleLock lock(m_critSection); ResetQualityData(m_qualityInfo); m_playingChannel = currentChannel; } return bSwitched; }
void CGUIDialogPVRChannelsOSD::Update() { // lock our display, as this window is rendered from the player thread g_graphicsContext.Lock(); m_viewControl.SetCurrentView(DEFAULT_VIEW_LIST); // empty the list ready for population Clear(); CPVRChannel channel; CPVRManager::Get()->GetCurrentChannel(&channel); CPVRManager::Get()->GetPlayingGroup(channel.IsRadio())->GetMembers(m_vecItems); m_viewControl.SetItems(*m_vecItems); m_viewControl.SetSelectedItem(channel.ChannelNumber() - 1); g_graphicsContext.Unlock(); }
bool CPVRChannelGroupInternal::UpdateChannel(const CPVRChannel &channel) { CSingleLock lock(m_critSection); CPVRChannelPtr updateChannel = GetByUniqueID(channel.UniqueID()); if (!updateChannel) { updateChannel = CPVRChannelPtr(new CPVRChannel(channel.IsRadio())); PVRChannelGroupMember newMember = { updateChannel, 0 }; m_members.push_back(newMember); updateChannel->SetUniqueID(channel.UniqueID()); } updateChannel->UpdateFromClient(channel); return updateChannel->Persist(!m_bLoaded); }
bool CEpg::Update(const time_t start, const time_t end, int iUpdateTime, bool bForceUpdate /* = false */) { bool bGrabSuccess(true); bool bUpdate(false); /* load the entries from the db first */ if (!m_bLoaded && !g_EpgContainer.IgnoreDB()) Load(); /* clean up if needed */ if (m_bLoaded) Cleanup(); /* get the last update time from the database */ CDateTime lastScanTime = GetLastScanTime(); if (!bForceUpdate) { /* check if we have to update */ time_t iNow = 0; time_t iLastUpdate = 0; CDateTime::GetCurrentDateTime().GetAsUTCDateTime().GetAsTime(iNow); lastScanTime.GetAsTime(iLastUpdate); bUpdate = (iNow > iLastUpdate + iUpdateTime); } else bUpdate = true; if (bUpdate) bGrabSuccess = LoadFromClients(start, end); if (bGrabSuccess) { CPVRChannel channel; if (g_PVRManager.GetCurrentChannel(channel)) if (channel.EpgID() == m_iEpgID) g_PVRManager.ResetPlayingTag(); m_bLoaded = true; } else CLog::Log(LOGERROR, "EPG - %s - failed to update table '%s'", __FUNCTION__, Name().c_str()); CSingleLock lock(m_critSection); m_bUpdatePending = false; return bGrabSuccess; }
void CGUIWindowPVRGuide::UpdateViewTimeline(void) { CPVRChannel CurrentChannel; bool bGotCurrentChannel = CPVRManager::Get()->GetCurrentChannel(&CurrentChannel); bool bRadio = bGotCurrentChannel ? CurrentChannel.IsRadio() : false; m_parent->SetLabel(m_iControlButton, g_localizeStrings.Get(19222) + ": " + g_localizeStrings.Get(19032)); m_parent->SetLabel(CONTROL_LABELGROUP, g_localizeStrings.Get(19032)); CSingleLock lock(m_critSection); /* start observing the EPG for changes, so our cache becomes updated in the background */ if (!m_bObservingEpg) { CPVRManager::GetEpg()->AddObserver(this); m_bObservingEpg = true; } if (!m_bGotInitialEpg) InitializeEpgCache(bRadio); if (bRadio != m_bLastEpgView) { m_epgData->Clear(); CPVRManager::GetEpg()->GetEPGAll(m_epgData, bRadio); } m_bLastEpgView = bRadio; if (m_epgData->Size() <= 0) return; m_parent->m_guideGrid = (CGUIEPGGridContainer*) m_parent->GetControl(CONTROL_LIST_TIMELINE); if (m_parent->m_guideGrid) { CDateTime gridStart = CDateTime::GetCurrentDateTime(); CDateTime firstDate = CPVRManager::GetEpg()->GetFirstEPGDate(bRadio); CDateTime lastDate = CPVRManager::GetEpg()->GetLastEPGDate(bRadio); /* copy over the cached epg data */ for (int iEpgPtr = 0; iEpgPtr < m_epgData->Size(); iEpgPtr++) m_parent->m_vecItems->Add(m_epgData->Get(iEpgPtr)); m_parent->m_guideGrid->SetStartEnd(firstDate > gridStart ? firstDate : gridStart, lastDate); m_parent->m_viewControl.SetCurrentView(CONTROL_LIST_TIMELINE); } //m_viewControl.SetSelectedItem(m_iSelected_GUIDE); }
bool CGUIWindowPVRCommon::PlayFile(CFileItem *item, bool bPlayMinimized /* = false */) { if (item->GetPath() == g_application.CurrentFile()) { CGUIMessage msg(GUI_MSG_FULLSCREEN, 0, m_parent->GetID()); g_windowManager.SendMessage(msg); return true; } g_settings.m_bStartVideoWindowed = bPlayMinimized; if (item->GetPath().Left(17) == "pvr://recordings/") { return PlayRecording(item, bPlayMinimized); } else { bool bSwitchSuccessful(false); CPVRChannel *channel = item->HasPVRChannelInfoTag() ? item->GetPVRChannelInfoTag() : NULL; if (g_PVRManager.CheckParentalLock(*channel)) { /* try a fast switch */ if (channel && (g_PVRManager.IsPlayingTV() || g_PVRManager.IsPlayingRadio()) && (channel->IsRadio() == g_PVRManager.IsPlayingRadio()) && g_application.m_pPlayer) { if (channel->StreamURL().IsEmpty()) bSwitchSuccessful = g_application.m_pPlayer->SwitchChannel(*channel); } if (!bSwitchSuccessful) { CApplicationMessenger::Get().PlayFile(*item, false); return true; } } if (!bSwitchSuccessful) { CGUIDialogOK::ShowAndGetInput(19033,0,19035,0); return false; } } return true; }
bool CPVRTimers::IsRecordingOnChannel(const CPVRChannel &channel) const { CSingleLock lock(m_critSection); for (MapTags::const_iterator it = m_tags.begin(); it != m_tags.end(); ++it) { for (VecTimerInfoTag::const_iterator timerIt = it->second->begin(); timerIt != it->second->end(); ++timerIt) { if ((*timerIt)->IsRecording() && (*timerIt)->m_iClientChannelUid == channel.UniqueID() && (*timerIt)->m_iClientId == channel.ClientID()) return true; } } return false; }
void CPVRChannelGroup::RemoveInvalidChannels(void) { for (unsigned int ptr = 0; ptr < size(); ptr--) { CPVRChannel *channel = at(ptr).channel; if (channel->IsVirtual()) continue; if (at(ptr).channel->ClientChannelNumber() <= 0) { CLog::Log(LOGERROR, "PVRChannelGroup - %s - removing invalid channel '%s' from client '%i': no valid client channel number", __FUNCTION__, channel->ChannelName().c_str(), channel->ClientID()); erase(begin() + ptr); ptr--; m_bChanged = true; continue; } if (channel->UniqueID() <= 0) { CLog::Log(LOGERROR, "PVRChannelGroup - %s - removing invalid channel '%s' from client '%i': no valid unique ID", __FUNCTION__, channel->ChannelName().c_str(), channel->ClientID()); erase(begin() + ptr); ptr--; m_bChanged = true; continue; } } }
void CPVRChannels::MoveChannel(unsigned int iOldIndex, unsigned int iNewIndex) { if (iNewIndex == iOldIndex || iNewIndex == 0) return; CPVRDatabase *database = g_PVRManager.GetTVDatabase(); database->Open(); CPVRChannels tempChannels(m_bRadio); /* move the channel */ tempChannels.push_back(at(iOldIndex - 1)); erase(begin() + iOldIndex - 1); if (iNewIndex < size()) insert(begin() + iNewIndex - 1, tempChannels[0]); else push_back(tempChannels[0]); /* update the channel numbers */ for (unsigned int ptr = 0; ptr < size(); ptr++) { CPVRChannel *channel = at(ptr); if (channel->ChannelNumber() != (int) ptr + 1) { channel->SetChannelNumber(ptr + 1, true); } } CLog::Log(LOGNOTICE, "%s - %s channel '%d' moved to '%d'", __FUNCTION__, (m_bRadio ? "radio" : "tv"), iOldIndex, iNewIndex); database->Close(); /* update the timers with the new channel numbers */ for (unsigned int ptr = 0; ptr < PVRTimers.size(); ptr++) { CPVRTimerInfoTag timer = PVRTimers[ptr]; CPVRChannel *tag = GetByClient(timer.Number(), timer.ClientID()); if (tag) timer.SetNumber(tag->ChannelNumber()); } m_bIsSorted = false; }
CPVRTimerInfoTag *CPVRTimerInfoTag::CreateFromEpg(const CEpgInfoTag &tag) { /* create a new timer */ CPVRTimerInfoTag *newTag = new CPVRTimerInfoTag(); if (!newTag) { CLog::Log(LOGERROR, "%s - couldn't create new timer", __FUNCTION__); return NULL; } /* check if a valid channel is set */ CPVRChannel *channel = (CPVRChannel *) tag.ChannelTag(); if (channel == NULL) { CLog::Log(LOGERROR, "%s - no channel set", __FUNCTION__); return NULL; } /* check if the epg end date is in the future */ if (tag.EndAsLocalTime() < CDateTime::GetCurrentDateTime()) { CLog::Log(LOGERROR, "%s - end time is in the past", __FUNCTION__); return NULL; } /* set the timer data */ CDateTime newStart = tag.StartAsUTC(); CDateTime newEnd = tag.EndAsUTC(); newTag->m_iClientIndex = -1; newTag->m_strTitle = tag.Title().IsEmpty() ? channel->ChannelName() : tag.Title(); newTag->m_iChannelNumber = channel->ChannelNumber(); newTag->m_iClientChannelUid = channel->UniqueID(); newTag->m_iClientId = channel->ClientID(); newTag->m_bIsRadio = channel->IsRadio(); newTag->SetStartFromUTC(newStart); newTag->SetEndFromUTC(newEnd); if (tag.Plot().IsEmpty()) { newTag->m_strSummary.Format("%s %s %s %s %s", newTag->StartAsLocalTime().GetAsLocalizedDate(), g_localizeStrings.Get(19159), newTag->StartAsLocalTime().GetAsLocalizedTime("", false), g_localizeStrings.Get(19160), newTag->EndAsLocalTime().GetAsLocalizedTime("", false)); } else { newTag->m_strSummary = tag.Plot(); } /* we might have a copy of the tag here, so get the real one from the pvrmanager */ const CEpg *epgTable = channel->GetEPG(); newTag->m_epgInfo = epgTable ? epgTable->GetTag(tag.UniqueBroadcastID(), tag.StartAsUTC()) : NULL; /* unused only for reference */ newTag->m_strFileNameAndPath = "pvr://timers/new"; return newTag; }
bool CPVRDatabase::GetChannelSettings(const CPVRChannel &channel, CVideoSettings &settings) { bool bReturn = false; /* invalid channel */ if (channel.ChannelID() <= 0) { CLog::Log(LOGERROR, "PVRDB - %s - invalid channel id: %li", __FUNCTION__, channel.ChannelID()); return bReturn; } CStdString strQuery = FormatSQL("SELECT * FROM ChannelSettings WHERE ChannelId = %u\n", channel.ChannelID()); if (ResultQuery(strQuery)) { settings.m_AudioDelay = m_pDS->fv("AudioDelay").get_asFloat(); settings.m_AudioStream = m_pDS->fv("AudioStream").get_asInt(); settings.m_Brightness = m_pDS->fv("Brightness").get_asFloat(); settings.m_Contrast = m_pDS->fv("Contrast").get_asFloat(); settings.m_CustomPixelRatio = m_pDS->fv("PixelRatio").get_asFloat(); settings.m_NoiseReduction = m_pDS->fv("NoiseReduction").get_asFloat(); settings.m_Sharpness = m_pDS->fv("Sharpness").get_asFloat(); settings.m_CustomZoomAmount = m_pDS->fv("CustomZoomAmount").get_asFloat(); settings.m_Gamma = m_pDS->fv("Gamma").get_asFloat(); settings.m_SubtitleDelay = m_pDS->fv("SubtitleDelay").get_asFloat(); settings.m_SubtitleOn = m_pDS->fv("SubtitlesOn").get_asBool(); settings.m_SubtitleStream = m_pDS->fv("SubtitleStream").get_asInt(); settings.m_ViewMode = m_pDS->fv("ViewMode").get_asInt(); settings.m_Crop = m_pDS->fv("Crop").get_asBool(); settings.m_CropLeft = m_pDS->fv("CropLeft").get_asInt(); settings.m_CropRight = m_pDS->fv("CropRight").get_asInt(); settings.m_CropTop = m_pDS->fv("CropTop").get_asInt(); settings.m_CropBottom = m_pDS->fv("CropBottom").get_asInt(); settings.m_InterlaceMethod = (EINTERLACEMETHOD)m_pDS->fv("InterlaceMethod").get_asInt(); settings.m_VolumeAmplification = m_pDS->fv("VolumeAmplification").get_asFloat(); settings.m_OutputToAllSpeakers = m_pDS->fv("OutputToAllSpeakers").get_asBool(); settings.m_SubtitleCached = false; bReturn = true; } m_pDS->close(); return bReturn; }
/*! * @brief Copy over channel info from xbmcChannel to addonClient. * @param xbmcChannel The channel on XBMC's side. * @param addonChannel The channel on the addon's side. */ void CPVRClient::WriteClientChannelInfo(const CPVRChannel &xbmcChannel, PVR_CHANNEL &addonChannel) { memset(&addonChannel, 0, sizeof(addonChannel)); addonChannel.iUniqueId = xbmcChannel.UniqueID(); addonChannel.iChannelNumber = xbmcChannel.ClientChannelNumber(); strncpy(addonChannel.strChannelName, xbmcChannel.ClientChannelName().c_str(), sizeof(addonChannel.strChannelName) - 1); strncpy(addonChannel.strIconPath, xbmcChannel.IconPath().c_str(), sizeof(addonChannel.strIconPath) - 1); addonChannel.iEncryptionSystem = xbmcChannel.EncryptionSystem(); addonChannel.bIsRadio = xbmcChannel.IsRadio(); addonChannel.bIsHidden = xbmcChannel.IsHidden(); strncpy(addonChannel.strInputFormat, xbmcChannel.InputFormat().c_str(), sizeof(addonChannel.strInputFormat) - 1); strncpy(addonChannel.strStreamURL, xbmcChannel.StreamURL().c_str(), sizeof(addonChannel.strStreamURL) - 1); }
int CPVRManager::GetPreviousChannel(void) { //XXX this must be the craziest way to store the last channel int iReturn = -1; CPVRChannel channel; if (m_addons->GetPlayingChannel(channel)) { int iLastChannel = channel.ChannelNumber(); if ((m_PreviousChannel[m_PreviousChannelIndex ^ 1] == iLastChannel || iLastChannel != m_PreviousChannel[0]) && iLastChannel != m_PreviousChannel[1]) m_PreviousChannelIndex ^= 1; iReturn = m_PreviousChannel[m_PreviousChannelIndex ^= 1]; } return iReturn; }
void CPVRClients::UpdateCharInfoSignalStatus(void) { CPVRChannel currentChannel; boost::shared_ptr<CPVRClient> client; PVR_SIGNAL_STATUS qualityInfo; ResetQualityData(qualityInfo); if (GetPlayingChannel(currentChannel) && g_guiSettings.GetBool("pvrplayback.signalquality") && !currentChannel.IsVirtual() && GetConnectedClient(currentChannel.ClientID(), client)) { client->SignalQuality(qualityInfo); } CSingleLock lock(m_critSection); m_qualityInfo = qualityInfo; }
bool CPVRChannelGroupInternal::CreateChannelEpgs(bool bForce /* = false */) { CSingleLock lock(m_critSection); for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++) { CPVRChannel *channel = at(iChannelPtr).channel; if (!channel) continue; channel->CreateEPG(bForce); } lock.Leave(); if (HasChangedChannels()) return Persist(); return true; }
bool CPVRTimers::DeleteTimersOnChannel(const CPVRChannel &channel, bool bForce /* = false */) { bool bReturn = true; for (unsigned int ptr = 0; ptr < size(); ptr++) { CPVRTimerInfoTag timer = at(ptr); if (timer.ChannelNumber() == channel.ChannelNumber() && timer.IsRadio() == channel.IsRadio()) { bReturn = timer.DeleteFromClient(bForce) && bReturn; erase(begin() + ptr); ptr--; } } return bReturn; }
bool CPVRChannelGroupInternal::AddAndUpdateChannels(const CPVRChannelGroup &channels, bool bUseBackendChannelNumbers) { bool bReturn(false); CSingleLock lock(m_critSection); /* go through the channel list and check for updated or new channels */ for (unsigned int iChannelPtr = 0; iChannelPtr < channels.size(); iChannelPtr++) { PVRChannelGroupMember member = channels.at(iChannelPtr); if (!member.channel) continue; /* check whether this channel is present in this container */ CPVRChannel *existingChannel = (CPVRChannel *) GetByClient(member.channel->UniqueID(), member.channel->ClientID()); if (existingChannel) { /* if it's present, update the current tag */ if (existingChannel->UpdateFromClient(*member.channel)) { existingChannel->Persist(!m_bLoaded); bReturn = true; CLog::Log(LOGINFO,"PVRChannelGroupInternal - %s - updated %s channel '%s'", __FUNCTION__, m_bRadio ? "radio" : "TV", member.channel->ChannelName().c_str()); } } else { /* new channel */ CPVRChannel *newChannel = new CPVRChannel(*member.channel); /* insert the new channel in this group */ int iChannelNumber = bUseBackendChannelNumbers ? member.channel->ClientChannelNumber() : 0; InsertInGroup(*newChannel, iChannelNumber, false); bReturn = true; CLog::Log(LOGINFO,"PVRChannelGroupInternal - %s - added %s channel '%s' at position %d", __FUNCTION__, m_bRadio ? "radio" : "TV", member.channel->ChannelName().c_str(), iChannelNumber); } } return bReturn; }
void CPVRManager::UpdateLastWatched(CPVRChannel &channel) { time_t tNow; CDateTime::GetCurrentDateTime().GetAsTime(tNow); // update last watched timestamp for channel // NOTE: method could be called with a fileitem copy as argument so we need to obtain the right channel instance CPVRChannelPtr channelPtr = m_channelGroups->GetChannelById(channel.ChannelID()); channelPtr->SetLastWatched(tNow); channelPtr->Persist(); // update last watched timestamp for group CPVRChannelGroupPtr group = GetPlayingGroup(channel.IsRadio()); group->SetLastWatched(tNow); group->Persist(); /* update last played group */ m_channelGroups->SetLastPlayedGroup(group); }
void CPVRChannelGroupInternal::UpdateFromClient(const CPVRChannel &channel, unsigned int iChannelNumber /* = 0 */) { CSingleLock lock(m_critSection); CPVRChannelPtr realChannel = GetByClient(channel.UniqueID(), channel.ClientID()); if (realChannel) realChannel->UpdateFromClient(channel); else { PVRChannelGroupMember newMember = { CPVRChannelPtr(new CPVRChannel(channel)), iChannelNumber > 0 ? iChannelNumber : m_members.size() + 1 }; m_members.push_back(newMember); m_bChanged = true; if (m_bUsingBackendChannelOrder) SortByClientChannelNumber(); else SortByChannelNumber(); Renumber(); } }
int CPVREpgContainer::GetEPGAll(CFileItemList* results, bool bRadio /* = false */) { int iInitialSize = results->Size(); const CPVRChannelGroup *group = CPVRManager::GetChannelGroups()->GetGroupAll(bRadio); if (!group) return -1; CSingleLock lock(m_critSection); for (unsigned int iChannelPtr = 0; iChannelPtr < group->Size(); iChannelPtr++) { CPVRChannel *channel = (CPVRChannel *) group->GetByIndex(iChannelPtr); if (!channel) continue; channel->GetEPG(results); } return results->Size() - iInitialSize; }
int CPVRChannelGroupInternal::GetMembers(CFileItemList *results, bool bGroupMembers /* = true */) const { int iOrigSize = results->Size(); CSingleLock lock(m_critSection); for (unsigned int iChannelPtr = 0; iChannelPtr < size(); iChannelPtr++) { CPVRChannel *channel = at(iChannelPtr).channel; if (!channel) continue; if (bGroupMembers != channel->IsHidden()) { CFileItemPtr pFileItem(new CFileItem(*channel)); results->Add(pFileItem); } } return results->Size() - iOrigSize; }
CEpgPtr CEpgContainer::GetByChannel(const CPVRChannel &channel) const { CSingleLock lock(m_critSection); for (const auto &epgEntry : m_epgs) { if (channel.ChannelID() == epgEntry.second->ChannelID()) return epgEntry.second; } return NULL; }
void CPVRTimerInfoTag::UpdateEpgEvent(bool bClear /* = false */) { /* try to get the channel */ CPVRChannel *channel = (CPVRChannel *) CPVRManager::GetChannelGroups()->GetByUniqueID(m_iClientChannelUid, m_iClientID); if (!channel) return; /* try to get the EPG table */ CPVREpg *epg = channel->GetEPG(); if (!epg) return; /* try to set the timer on the epg tag that matches */ m_EpgInfo = (CPVREpgInfoTag *) epg->InfoTagBetween(m_StartTime, m_StopTime); if (!m_EpgInfo) m_EpgInfo = (CPVREpgInfoTag *) epg->InfoTagAround(m_StartTime); if (m_EpgInfo) m_EpgInfo->SetTimer(bClear ? NULL : this); }
void CPVRTimerInfoTag::UpdateEpgEvent(bool bClear /* = false */) { CSingleLock lock(m_critSection); if (bClear) { CEpgInfoTag *epgTag = GetEpgInfoTag(); if (epgTag) epgTag->OnTimerDeleted(); } else { /* already got an epg event set */ if (m_iEpgId != -1) return; /* try to get the channel */ CPVRChannel *channel = (CPVRChannel *) g_PVRChannelGroups->GetByUniqueID(m_iClientChannelUid, m_iClientId); if (!channel) return; /* try to get the EPG table */ CEpg *epg = channel->GetEPG(); if (!epg) return; /* try to set the timer on the epg tag that matches with a 2 minute margin */ CEpgInfoTag *epgTag = (CEpgInfoTag *) epg->GetTagBetween(StartAsUTC() - CDateTimeSpan(0, 0, 2, 0), EndAsUTC() + CDateTimeSpan(0, 0, 2, 0)); if (!epgTag) epgTag = (CEpgInfoTag *) epg->GetTagAround(StartAsUTC()); if (epgTag) { m_iEpgId = epgTag->m_iEpgId; m_epgStart = epgTag->StartAsUTC(); m_genre = epgTag->Genre(); m_iGenreType = epgTag->GenreType(); m_iGenreSubType = epgTag->GenreSubType(); epgTag->SetTimer(this); } } }