CPVRTimerInfoTag::CPVRTimerInfoTag(const PVR_TIMER &timer, const CPVRChannelPtr &channel, unsigned int iClientId) : m_strTitle(timer.strTitle), m_strDirectory(timer.strDirectory) { m_iClientId = iClientId; m_iClientIndex = timer.iClientIndex; m_iClientChannelUid = channel ? channel->UniqueID() : timer.iClientChannelUid; m_iChannelNumber = channel ? g_PVRChannelGroups->GetGroupAll(channel->IsRadio())->GetChannelNumber(channel) : 0; m_StartTime = timer.startTime + g_advancedSettings.m_iPVRTimeCorrection; m_StopTime = timer.endTime + g_advancedSettings.m_iPVRTimeCorrection; m_bIsRepeating = timer.bIsRepeating; m_FirstDay = timer.firstDay + g_advancedSettings.m_iPVRTimeCorrection; m_iWeekdays = timer.iWeekdays; m_iPriority = timer.iPriority; m_iLifetime = timer.iLifetime; m_iMarginStart = timer.iMarginStart; m_iMarginEnd = timer.iMarginEnd; m_genre = StringUtils::Split(CEpg::ConvertGenreIdToString(timer.iGenreType, timer.iGenreSubType), g_advancedSettings.m_videoItemSeparator); m_iGenreType = timer.iGenreType; m_iGenreSubType = timer.iGenreSubType; CEpgInfoTagPtr emptyTag; m_epgTag = emptyTag; m_channel = channel; m_bIsRadio = channel && channel->IsRadio(); m_state = timer.state; m_strFileNameAndPath = StringUtils::Format("pvr://client%i/timers/%i", m_iClientId, m_iClientIndex); m_iTimerId = 0; UpdateSummary(); }
void CGUIDialogPVRChannelsOSD::Update() { // lock our display, as this window is rendered from the player thread g_graphicsContext.Lock(); if (!IsObserving(g_infoManager)) g_infoManager.RegisterObserver(this); m_viewControl.SetCurrentView(DEFAULT_VIEW_LIST); // empty the list ready for population Clear(); CPVRChannelPtr channel; if (g_PVRManager.GetCurrentChannel(channel)) { CPVRChannelGroupPtr group = g_PVRManager.GetPlayingGroup(channel->IsRadio()); if (group) { group->GetMembers(*m_vecItems); m_viewControl.SetItems(*m_vecItems); if (!m_group) { m_group = group; m_viewControl.SetSelectedItem(CGUIWindowPVRBase::GetSelectedItemPath(channel->IsRadio())); SaveSelectedItemPath(group->GroupID()); } } } g_graphicsContext.Unlock(); }
bool CPVRClient::CanPlayChannel(const CPVRChannelPtr &channel) const { assert(channel.get()); return (m_bReadyToUse && ((m_addonCapabilities.bSupportsTV && !channel->IsRadio()) || (m_addonCapabilities.bSupportsRadio && channel->IsRadio()))); }
void CPVRManager::SetPlayingGroup(const CPVRChannelPtr &channel) { CPVRChannelGroupPtr group = m_channelGroups->GetSelectedGroup(channel->IsRadio()); if (!group || !group->IsGroupMember(channel)) { // The channel we'll switch to is not part of the current selected group. // Set the first group as the selected group where the channel is a member. CPVRChannelGroups *channelGroups = m_channelGroups->Get(channel->IsRadio()); std::vector<CPVRChannelGroupPtr> groups = channelGroups->GetGroupsByChannel(channel, true); if (!groups.empty()) channelGroups->SetSelectedGroup(groups.front()); } }
bool CPVRManager::OpenLiveStream(const CFileItem &fileItem) { bool bReturn(false); if (!fileItem.HasPVRChannelInfoTag()) return bReturn; CLog::Log(LOGDEBUG,"PVRManager - %s - opening live stream on channel '%s'", __FUNCTION__, fileItem.GetPVRChannelInfoTag()->ChannelName().c_str()); // check if we're allowed to play this file if (IsParentalLocked(fileItem.GetPVRChannelInfoTag())) return bReturn; if ((bReturn = m_addons->OpenStream(fileItem.GetPVRChannelInfoTag(), false)) != false) { CSingleLock lock(m_critSection); m_currentFile.reset(new CFileItem(fileItem)); } if (bReturn) { const CPVRChannelPtr channel(m_addons->GetPlayingChannel()); if (channel) { SetPlayingGroup(channel); UpdateLastWatched(channel); // set channel as selected item CGUIWindowPVRBase::SetSelectedItemPath(channel->IsRadio(), channel->Path()); } } return bReturn; }
void CGUIWindowPVRGuide::UpdateViewNext(bool bUpdateSelectedFile) { CPVRChannelPtr CurrentChannel; bool bGotCurrentChannel = g_PVRManager.GetCurrentChannel(CurrentChannel); bool bRadio = bGotCurrentChannel ? CurrentChannel->IsRadio() : false; m_parent->m_guideGrid = NULL; m_parent->m_viewControl.SetCurrentView(CONTROL_LIST_GUIDE_NOW_NEXT); m_parent->SetLabel(m_iControlButton, g_localizeStrings.Get(19222) + ": " + g_localizeStrings.Get(19031)); m_parent->SetLabel(CONTROL_LABELGROUP, g_localizeStrings.Get(19031)); int iEpgItems = g_PVRManager.GetPlayingGroup(bRadio)->GetEPGNext(*m_parent->m_vecItems); if (iEpgItems == 0 && bRadio) // if we didn't get any events for radio, get tv instead iEpgItems = g_PVRManager.GetPlayingGroup(false)->GetEPGNext(*m_parent->m_vecItems); if (iEpgItems) { CFileItemPtr item; item.reset(new CFileItem("pvr://guide/next/empty.epg", false)); item->SetLabel(g_localizeStrings.Get(19028)); item->SetLabelPreformated(true); m_parent->m_vecItems->Add(item); } m_parent->m_viewControl.SetItems(*m_parent->m_vecItems); }
CFileItemPtr CPVRTimers::GetMatch(const CEpgInfoTag *Epg) { 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); CPVRChannelPtr channel; if (Epg) channel = Epg->ChannelTag(); if (!channel) continue; if (timer->ChannelNumber() != channel->ChannelNumber() || timer->m_bIsRadio != channel->IsRadio()) continue; if (timer->StartAsUTC() > Epg->StartAsUTC() || timer->EndAsUTC() < Epg->EndAsUTC()) continue; CFileItemPtr fileItem(new CFileItem(*timer)); return fileItem; } } CFileItemPtr fileItem; return fileItem; }
CFileItemPtr CPVRTimers::GetTimerForEpgTag(const CFileItem *item) const { if (item && item->HasEPGInfoTag() && item->GetEPGInfoTag()->ChannelTag()) { const CEpgInfoTagPtr epgTag(item->GetEPGInfoTag()); const CPVRChannelPtr channel(epgTag->ChannelTag()); 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) { CPVRTimerInfoTagPtr timer = *timerIt; if (timer->GetEpgInfoTag() == epgTag || (timer->m_iClientChannelUid == channel->UniqueID() && timer->m_bIsRadio == channel->IsRadio() && timer->StartAsUTC() <= epgTag->StartAsUTC() && timer->EndAsUTC() >= epgTag->EndAsUTC())) { CFileItemPtr fileItem(new CFileItem(timer)); return fileItem; } } } } CFileItemPtr fileItem; return fileItem; }
void CAddonCallbacksPVR::PVRTransferChannelGroupMember(void *addonData, const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP_MEMBER *member) { if (!handle) { CLog::Log(LOGERROR, "PVR - %s - invalid handler data", __FUNCTION__); return; } CPVRClient *client = GetPVRClient(addonData); CPVRChannelGroup *group = static_cast<CPVRChannelGroup *>(handle->dataAddress); if (!member || !client || !group) { CLog::Log(LOGERROR, "PVR - %s - invalid handler data", __FUNCTION__); return; } CPVRChannelPtr channel = g_PVRChannelGroups->GetByUniqueID(member->iChannelUniqueId, client->GetID()); if (!channel) { CLog::Log(LOGERROR, "PVR - %s - cannot find group '%s' or channel '%d'", __FUNCTION__, member->strGroupName, member->iChannelUniqueId); } else if (group->IsRadio() == channel->IsRadio()) { /* transfer this entry to the group */ group->AddToGroup(channel, member->iChannelNumber); } }
bool CPVRGUIActions::HideChannel(const CFileItemPtr &item) const { const CPVRChannelPtr channel(item->GetPVRChannelInfoTag()); /* check if the channel tag is valid */ if (!channel || channel->ChannelNumber() <= 0) return false; if (!CGUIDialogYesNo::ShowAndGetInput(CVariant{19054}, // "Hide channel" CVariant{19039}, // "Are you sure you want to hide this channel?" CVariant{""}, CVariant{channel->ChannelName()})) return false; if (!g_PVRChannelGroups->GetGroupAll(channel->IsRadio())->RemoveFromGroup(channel)) return false; CGUIWindowPVRBase *pvrWindow = dynamic_cast<CGUIWindowPVRBase *>(g_windowManager.GetWindow(g_windowManager.GetActiveWindow())); if (pvrWindow) pvrWindow->DoRefresh(); else CLog::Log(LOGERROR, "CPVRGUIActions - %s - called on non-pvr window. no refresh possible.", __FUNCTION__); return true; }
void CPVRManager::CloseStream(void) { CPVRChannelPtr channel; bool bPersistChannel(false); { CSingleLock lock(m_critSection); if (m_addons->GetPlayingChannel(channel)) { /* store current time in iLastWatched */ time_t tNow; CDateTime::GetCurrentDateTime().GetAsTime(tNow); channel->SetLastWatched(tNow); bPersistChannel = true; m_channelGroups->SetLastPlayedGroup(GetPlayingGroup(channel->IsRadio())); } m_addons->CloseStream(); SAFE_DELETE(m_currentFile); } if (bPersistChannel) channel->Persist(); }
bool CPVRClients::SwitchChannel(const CPVRChannel &channel) { { CSingleLock lock(m_critSection); if (m_bIsSwitchingChannels) { CLog::Log(LOGDEBUG, "PVRClients - %s - can't switch to channel '%s'. waiting for the previous switch to complete", __FUNCTION__, channel.ChannelName().c_str()); return false; } m_bIsSwitchingChannels = true; } bool bSwitchSuccessful(false); CPVRChannelPtr currentChannel; if (// no channel is currently playing !GetPlayingChannel(currentChannel) || // different backend currentChannel->ClientID() != channel.ClientID() || // different type currentChannel->IsRadio() != channel.IsRadio() || // stream URL should always be opened as a new file !channel.StreamURL().IsEmpty() || !currentChannel->StreamURL().IsEmpty()) { if (channel.StreamURL().IsEmpty()) { CloseStream(); bSwitchSuccessful = OpenStream(channel, true); } else { CFileItem m_currentFile(channel); CApplicationMessenger::Get().PlayFile(m_currentFile, false); bSwitchSuccessful = true; } } // same channel else if (currentChannel.get() && *currentChannel == channel) { bSwitchSuccessful = true; } else { PVR_CLIENT client; if (GetConnectedClient(channel.ClientID(), client)) bSwitchSuccessful = client->SwitchChannel(channel); } { CSingleLock lock(m_critSection); m_bIsSwitchingChannels = false; if (bSwitchSuccessful) m_bIsValidChannelSettings = false; } if (!bSwitchSuccessful) CLog::Log(LOGERROR, "PVR - %s - cannot switch to channel '%s' on client '%d'",__FUNCTION__, channel.ChannelName().c_str(), channel.ClientID()); return bSwitchSuccessful; }
CPVRChannelGroupPtr CGUIDialogPVRChannelsOSD::GetPlayingGroup() { CPVRChannelPtr channel; if (g_PVRManager.GetCurrentChannel(channel)) return g_PVRManager.GetPlayingGroup(channel->IsRadio()); else return CPVRChannelGroupPtr(); }
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 CGUIDialogPVRChannelManager::OnContextButton(int itemNumber, CONTEXT_BUTTON button) { /* Check file item is in list range and get his pointer */ if (itemNumber < 0 || itemNumber >= (int)m_channelItems->Size()) return false; CFileItemPtr pItem = m_channelItems->Get(itemNumber); if (!pItem) return false; if (button == CONTEXT_BUTTON_MOVE) { m_bMovingMode = true; pItem->Select(true); } else if (button == CONTEXT_BUTTON_SETTINGS) { PVR_ERROR ret = CServiceBroker::GetPVRManager().Clients()->OpenDialogChannelSettings(pItem->GetPVRChannelInfoTag()); if (ret == PVR_ERROR_NOT_IMPLEMENTED) CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19038}); // "Information", "Not supported by the PVR backend." else if (ret != PVR_ERROR_NO_ERROR) CGUIDialogOK::ShowAndGetInput(CVariant{2103}, CVariant{16029}); // "Add-on error", "Check the log for more information about this message." } else if (button == CONTEXT_BUTTON_DELETE) { CGUIDialogYesNo* pDialog = g_windowManager.GetWindow<CGUIDialogYesNo>(WINDOW_DIALOG_YES_NO); if (!pDialog) return true; pDialog->SetHeading(CVariant{19211}); // Delete channel pDialog->SetText(CVariant{750}); // Are you sure? pDialog->Open(); if (pDialog->IsConfirmed()) { CPVRChannelPtr channel = pItem->GetPVRChannelInfoTag(); PVR_ERROR ret = CServiceBroker::GetPVRManager().Clients()->DeleteChannel(channel); if (ret == PVR_ERROR_NO_ERROR) { CServiceBroker::GetPVRManager().ChannelGroups()->GetGroupAll(channel->IsRadio())->RemoveFromGroup(channel); m_channelItems->Remove(m_iSelected); m_viewControl.SetItems(*m_channelItems); Renumber(); } else if (ret == PVR_ERROR_NOT_IMPLEMENTED) CGUIDialogOK::ShowAndGetInput(CVariant{19033}, CVariant{19038}); // "Information", "Not supported by the PVR backend." else CGUIDialogOK::ShowAndGetInput(CVariant{2103}, CVariant{16029}); // "Add-on error", "Check the log for more information about this message." } } else if (button == CONTEXT_BUTTON_EDIT_SOURCE) { std::string strURL = pItem->GetProperty("StreamURL").asString(); if (CGUIKeyboardFactory::ShowAndGetInput(strURL, CVariant{g_localizeStrings.Get(19214)}, false)) pItem->SetProperty("StreamURL", strURL); } return true; }
int CPVRManager::GetPreviousChannel(void) { CPVRChannelPtr currentChannel; if (GetCurrentChannel(currentChannel)) { CPVRChannelGroupPtr selectedGroup = GetPlayingGroup(currentChannel->IsRadio()); CFileItemPtr channel = selectedGroup->GetLastPlayedChannel(currentChannel->ChannelID()); if (channel && channel->HasPVRChannelInfoTag()) return channel->GetPVRChannelInfoTag()->ChannelNumber(); } return -1; }
bool CGUIDialogPVRChannelManager::OnContextButton(int itemNumber, CONTEXT_BUTTON button) { /* Check file item is in list range and get his pointer */ if (itemNumber < 0 || itemNumber >= (int)m_channelItems->Size()) return false; CFileItemPtr pItem = m_channelItems->Get(itemNumber); if (!pItem) return false; if (button == CONTEXT_BUTTON_MOVE) { m_bMovingMode = true; pItem->Select(true); } else if (button == CONTEXT_BUTTON_SETTINGS) { if (!g_PVRClients->OpenDialogChannelSettings(pItem->GetPVRChannelInfoTag())) CGUIDialogOK::ShowAndGetInput(2103, 0, 16029, 0); // Add-on error;Check the log file for details. } else if (button == CONTEXT_BUTTON_DELETE) { CGUIDialogYesNo* pDialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO); if (!pDialog) return true; pDialog->SetHeading(19211); // Delete channel pDialog->SetText(750); // Are you sure? pDialog->DoModal(); if (pDialog->IsConfirmed()) { CPVRChannelPtr channel = pItem->GetPVRChannelInfoTag(); if (g_PVRClients->DeleteChannel(channel)) { g_PVRChannelGroups->GetGroupAll(channel->IsRadio())->RemoveFromGroup(channel); m_channelItems->Remove(m_iSelected); m_viewControl.SetItems(*m_channelItems); Renumber(); } else CGUIDialogOK::ShowAndGetInput(2103, 0, 16029, 0); // Add-on error;Check the log file for details. } } else if (button == CONTEXT_BUTTON_EDIT_SOURCE) { std::string strURL = pItem->GetProperty("StreamURL").asString(); if (CGUIKeyboardFactory::ShowAndGetInput(strURL, g_localizeStrings.Get(19214), false)) pItem->SetProperty("StreamURL", strURL); } return true; }
void CPVRManager::UpdateLastWatched(const CPVRChannelPtr &channel) { time_t tNow; CDateTime::GetCurrentDateTime().GetAsTime(tNow); channel->SetLastWatched(tNow); // update last watched timestamp for group CPVRChannelGroupPtr group(GetPlayingGroup(channel->IsRadio())); group->SetLastWatched(tNow); /* update last played group */ m_channelGroups->SetLastPlayedGroup(group); }
bool CPVRManager::OpenLiveStream(const CFileItem &channel) { bool bReturn(false); if (!channel.HasPVRChannelInfoTag()) return bReturn; CLog::Log(LOGDEBUG,"PVRManager - %s - opening live stream on channel '%s'", __FUNCTION__, channel.GetPVRChannelInfoTag()->ChannelName().c_str()); // check if we're allowed to play this file if (IsParentalLocked(*channel.GetPVRChannelInfoTag())) return bReturn; CPVRChannelPtr playingChannel; CPVRChannelGroupPtr group; bool bPersistChanges(false); if ((bReturn = m_addons->OpenStream(*channel.GetPVRChannelInfoTag(), false)) != false) { CSingleLock lock(m_critSection); if(m_currentFile) delete m_currentFile; m_currentFile = new CFileItem(channel); if (m_addons->GetPlayingChannel(playingChannel)) { time_t tNow; CDateTime::GetCurrentDateTime().GetAsTime(tNow); /* update last watched timestamp for channel */ playingChannel->SetLastWatched(tNow); /* update last watched timestamp for group */ group = g_PVRManager.GetPlayingGroup(playingChannel->IsRadio()); group->SetLastWatched(tNow); /* update last played group */ m_channelGroups->SetLastPlayedGroup(group); bPersistChanges = true; } } if (bPersistChanges) { playingChannel->Persist(); group->Persist(); } return bReturn; }
void CPVRManager::UpdateLastWatched(const CPVRChannelPtr &channel, const CDateTime& time) { time_t iTime; time.GetAsTime(iTime); channel->SetLastWatched(iTime); // update last watched timestamp for group CPVRChannelGroupPtr group(GetPlayingGroup(channel->IsRadio())); group->SetLastWatched(iTime); /* update last played group */ m_channelGroups->SetLastPlayedGroup(group); }
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 CDVDInputStreamPVRManager::PrevChannel(bool preview/* = false*/) { PVR_CLIENT client; if (!preview && !SupportsChannelSwitch()) { CPVRChannelPtr channel; g_PVRManager.GetCurrentChannel(channel); CFileItemPtr item = g_PVRChannelGroups->Get(channel->IsRadio())->GetSelectedGroup()->GetByChannelDown(*channel); if (item.get()) return CloseAndOpen(item->GetPath().c_str()); } else if (m_pLiveTV) return m_pLiveTV->PrevChannel(preview); return false; }
bool CDVDInputStreamPVRManager::SelectChannelByNumber(unsigned int iChannelNumber) { PVR_CLIENT client; if (!SupportsChannelSwitch()) { CPVRChannelPtr channel; g_PVRManager.GetCurrentChannel(channel); CFileItemPtr item = g_PVRChannelGroups->Get(channel->IsRadio())->GetSelectedGroup()->GetByChannelNumber(iChannelNumber); if (item.get()) return CloseAndOpen(item->GetPath().c_str()); } else if (m_pLiveTV) return m_pLiveTV->SelectChannel(iChannelNumber); return false; }
/*! * @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 CPVRChannelPtr &xbmcChannel, PVR_CHANNEL &addonChannel) { assert(xbmcChannel.get()); memset(&addonChannel, 0, sizeof(addonChannel)); addonChannel.iUniqueId = xbmcChannel->UniqueID(); addonChannel.iChannelNumber = xbmcChannel->ClientChannelNumber(); addonChannel.iSubChannelNumber = xbmcChannel->ClientSubChannelNumber(); 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); }
bool CPVRItem::IsRadio() const { if (m_item->IsPVRChannel()) { return m_item->GetPVRChannelInfoTag()->IsRadio(); } else if (m_item->IsEPG()) { const CPVRChannelPtr channel(m_item->GetEPGInfoTag()->ChannelTag()); return (channel && channel->IsRadio()); } else if (m_item->IsPVRRecording()) { return m_item->GetPVRRecordingInfoTag()->IsRadio(); } else { CLog::Log(LOGERROR, "CPVRItem - %s - unsupported item type!", __FUNCTION__); } return false; }
void CPVRManager::CloseStream(void) { CPVRChannelPtr channel; CPVRChannelGroupPtr group; bool bPersistChanges(false); { CSingleLock lock(m_critSection); if (m_addons->GetPlayingChannel(channel)) { time_t tNow; CDateTime::GetCurrentDateTime().GetAsTime(tNow); /* update last watched timestamp for channel */ channel->SetLastWatched(tNow); /* update last watched timestamp for group */ group = g_PVRManager.GetPlayingGroup(channel->IsRadio()); group->SetLastWatched(tNow); /* update last played group */ m_channelGroups->SetLastPlayedGroup(group); bPersistChanges = true; // store channel settings g_application.SaveFileState(); } m_addons->CloseStream(); SAFE_DELETE(m_currentFile); } if (bPersistChanges) { channel->Persist(); group->Persist(); } }
void CGUIWindowPVRGuide::UpdateViewTimeline(bool bUpdateSelectedFile) { m_parent->m_guideGrid = (CGUIEPGGridContainer*) m_parent->GetControl(CONTROL_LIST_TIMELINE); if (!m_parent->m_guideGrid) return; CPVRChannelPtr CurrentChannel; bool bGotCurrentChannel = g_PVRManager.GetCurrentChannel(CurrentChannel); bool bRadio = bGotCurrentChannel ? CurrentChannel->IsRadio() : false; if (m_bUpdateRequired || m_cachedTimeline->IsEmpty() || *m_cachedChannelGroup != *g_PVRManager.GetPlayingGroup(bRadio)) { m_bUpdateRequired = false; m_cachedTimeline->Clear(); m_cachedChannelGroup = g_PVRManager.GetPlayingGroup(bRadio); if (m_cachedChannelGroup->GetEPGAll(*m_cachedTimeline) == 0 && bRadio) { // if we didn't get any events for radio, get tv instead m_cachedChannelGroup = g_PVRManager.GetPlayingGroup(false); m_cachedChannelGroup->GetEPGAll(*m_cachedTimeline); } } m_parent->m_vecItems->RemoveDiscCache(m_parent->GetID()); m_parent->m_vecItems->Assign(*m_cachedTimeline, false); CDateTime gridStart = CDateTime::GetCurrentDateTime().GetAsUTCDateTime(); CDateTime firstDate(g_EpgContainer.GetFirstEPGDate()); CDateTime lastDate(g_EpgContainer.GetLastEPGDate()); m_parent->m_guideGrid->SetStartEnd(firstDate > gridStart ? firstDate : gridStart, lastDate); m_parent->SetLabel(m_iControlButton, g_localizeStrings.Get(19222) + ": " + g_localizeStrings.Get(19032)); m_parent->SetLabel(CONTROL_LABELGROUP, g_localizeStrings.Get(19032)); m_parent->m_viewControl.SetCurrentView(CONTROL_LIST_TIMELINE, true); if (bUpdateSelectedFile) SelectPlayingFile(); }
CPVRTimerInfoTagPtr CPVRTimers::GetTimerForEpgTag(const CEpgInfoTagPtr &epgTag) const { if (epgTag) { // already a timer assigned to tag? CPVRTimerInfoTagPtr timer(epgTag->Timer()); if (timer) return timer; // try to find a matching timer for the tag. if (epgTag->ChannelTag()) { const CPVRChannelPtr channel(epgTag->ChannelTag()); 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) { timer = *timerIt; if (!timer->IsRepeating() && (timer->GetEpgInfoTag(false) == epgTag || (timer->m_iEpgUid != EPG_TAG_INVALID_UID && timer->m_iEpgUid == epgTag->UniqueBroadcastID()) || (timer->m_iClientChannelUid == channel->UniqueID() && timer->m_bIsRadio == channel->IsRadio() && timer->StartAsUTC() <= epgTag->StartAsUTC() && timer->EndAsUTC() >= epgTag->EndAsUTC()))) { return timer; } } } } } return CPVRTimerInfoTagPtr(); }
bool CGUIDialogPVRGuideInfo::OnClickButtonPlay(CGUIMessage &message) { bool bReturn = false; if (message.GetSenderId() == CONTROL_BTN_SWITCH || message.GetSenderId() == CONTROL_BTN_PLAY_RECORDING) { Close(); PlayBackRet ret = PLAYBACK_CANCELED; CEpgInfoTagPtr epgTag(m_progItem->GetEPGInfoTag()); if (epgTag) { if (message.GetSenderId() == CONTROL_BTN_PLAY_RECORDING && epgTag->HasRecording()) ret = g_application.PlayFile(CFileItem(epgTag->Recording()), "videoplayer"); else if (epgTag->HasPVRChannel()) { CPVRChannelPtr channel = epgTag->ChannelTag(); // try a fast switch bool bSwitchSuccessful = false; if ((g_PVRManager.IsPlayingTV() || g_PVRManager.IsPlayingRadio()) && (channel->IsRadio() == g_PVRManager.IsPlayingRadio())) { if (channel->StreamURL().empty()) bSwitchSuccessful = g_application.m_pPlayer->SwitchChannel(channel); } if (!bSwitchSuccessful) { CApplicationMessenger::GetInstance().PostMsg(TMSG_MEDIA_PLAY, 0, 0, static_cast<void*>(new CFileItem(channel)), "videoplayer"); } } } bReturn = true; } return bReturn; }
bool CGUIWindowFullScreen::OnMessage(CGUIMessage& message) { switch (message.GetMessage()) { case GUI_MSG_WINDOW_INIT: { // check whether we've come back here from a window during which time we've actually // stopped playing videos if (message.GetParam1() == WINDOW_INVALID && !g_application.IsPlayingVideo()) { // why are we here if nothing is playing??? g_windowManager.PreviousWindow(); return true; } g_infoManager.SetShowInfo(false); g_infoManager.SetShowCodec(false); m_bShowCurrentTime = false; m_bGroupSelectShow = false; g_infoManager.SetDisplayAfterSeek(0); // Make sure display after seek is off. // switch resolution g_graphicsContext.SetFullScreenVideo(true); #ifdef HAS_VIDEO_PLAYBACK // make sure renderer is uptospeed g_renderManager.Update(false); #endif // now call the base class to load our windows CGUIWindow::OnMessage(message); m_bShowViewModeInfo = false; if (CUtil::IsUsingTTFSubtitles()) { CSingleLock lock (m_fontLock); CStdString fontPath = "special://xbmc/media/Fonts/"; fontPath += g_guiSettings.GetString("subtitles.font"); // We scale based on PAL4x3 - this at least ensures all sizing is constant across resolutions. RESOLUTION_INFO pal(720, 576, 0); CGUIFont *subFont = g_fontManager.LoadTTF("__subtitle__", fontPath, color[g_guiSettings.GetInt("subtitles.color")], 0, g_guiSettings.GetInt("subtitles.height"), g_guiSettings.GetInt("subtitles.style"), false, 1.0f, 1.0f, &pal, true); CGUIFont *borderFont = g_fontManager.LoadTTF("__subtitleborder__", fontPath, 0xFF000000, 0, g_guiSettings.GetInt("subtitles.height"), g_guiSettings.GetInt("subtitles.style"), true, 1.0f, 1.0f, &pal, true); if (!subFont || !borderFont) CLog::Log(LOGERROR, "CGUIWindowFullScreen::OnMessage(WINDOW_INIT) - Unable to load subtitle font"); else m_subsLayout = new CGUITextLayout(subFont, true, 0, borderFont); } else m_subsLayout = NULL; return true; } case GUI_MSG_WINDOW_DEINIT: { CGUIWindow::OnMessage(message); CGUIDialog *pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_OSD_TELETEXT); if (pDialog) pDialog->Close(true); CGUIDialogSlider *slider = (CGUIDialogSlider *)g_windowManager.GetWindow(WINDOW_DIALOG_SLIDER); if (slider) slider->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_OSD); if (pDialog) pDialog->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_FULLSCREEN_INFO); if (pDialog) pDialog->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_OSD_CHANNELS); if (pDialog) pDialog->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_OSD_GUIDE); if (pDialog) pDialog->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_OSD_DIRECTOR); if (pDialog) pDialog->Close(true); pDialog = (CGUIDialog *)g_windowManager.GetWindow(WINDOW_DIALOG_PVR_OSD_CUTTER); if (pDialog) pDialog->Close(true); FreeResources(true); CSingleLock lock (g_graphicsContext); g_graphicsContext.SetFullScreenVideo(false); lock.Leave(); #ifdef HAS_VIDEO_PLAYBACK // make sure renderer is uptospeed g_renderManager.Update(false); #endif CSingleLock lockFont(m_fontLock); if (m_subsLayout) { g_fontManager.Unload("__subtitle__"); g_fontManager.Unload("__subtitleborder__"); delete m_subsLayout; m_subsLayout = NULL; } return true; } case GUI_MSG_CLICKED: { unsigned int iControl = message.GetSenderId(); if (iControl == CONTROL_GROUP_CHOOSER && g_PVRManager.IsStarted()) { // Get the currently selected label of the Select button CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControl); OnMessage(msg); CStdString strLabel = msg.GetLabel(); CPVRChannelPtr playingChannel; if (g_PVRManager.GetCurrentChannel(playingChannel)) { CPVRChannelGroupPtr selectedGroup = g_PVRChannelGroups->Get(playingChannel->IsRadio())->GetByName(strLabel); if (selectedGroup) { g_PVRManager.SetPlayingGroup(selectedGroup); CLog::Log(LOGDEBUG, "%s - switched to group '%s'", __FUNCTION__, selectedGroup->GroupName().c_str()); if (!selectedGroup->IsGroupMember(*playingChannel)) { CLog::Log(LOGDEBUG, "%s - channel '%s' is not a member of '%s', switching to channel 1 of the new group", __FUNCTION__, playingChannel->ChannelName().c_str(), selectedGroup->GroupName().c_str()); CFileItemPtr switchChannel = selectedGroup->GetByChannelNumber(1); if (switchChannel && switchChannel->HasPVRChannelInfoTag()) OnAction(CAction(ACTION_CHANNEL_SWITCH, (float) switchChannel->GetPVRChannelInfoTag()->ChannelNumber())); else { CLog::Log(LOGERROR, "%s - cannot find channel '1' in group %s", __FUNCTION__, selectedGroup->GroupName().c_str()); CApplicationMessenger::Get().MediaStop(false); } } } else { CLog::Log(LOGERROR, "%s - could not switch to group '%s'", __FUNCTION__, selectedGroup->GroupName().c_str()); CApplicationMessenger::Get().MediaStop(false); } } else { CLog::Log(LOGERROR, "%s - cannot find the current channel", __FUNCTION__); CApplicationMessenger::Get().MediaStop(false); } // hide the control and reset focus m_bGroupSelectShow = false; SET_CONTROL_HIDDEN(CONTROL_GROUP_CHOOSER); // SET_CONTROL_FOCUS(0, 0); return true; } break; } case GUI_MSG_SETFOCUS: case GUI_MSG_LOSTFOCUS: if (message.GetSenderId() != WINDOW_FULLSCREEN_VIDEO) return true; break; } return CGUIWindow::OnMessage(message); }