int CPVRChannelGroup::GetEPGNowOrNext(CFileItemList &results, bool bGetNext) const { int iInitialSize = results.Size(); CEpgInfoTagPtr epgNext; CPVRChannelPtr channel; CSingleLock lock(m_critSection); for (PVR_CHANNEL_GROUP_SORTED_MEMBERS::const_iterator it = m_sortedMembers.begin(); it != m_sortedMembers.end(); ++it) { channel = (*it).channel; CEpgPtr epg = channel->GetEPG(); if (epg && !channel->IsHidden()) { epgNext = bGetNext ? epg->GetTagNext() : epg->GetTagNow(); if (epgNext) { CFileItemPtr entry(new CFileItem(epgNext)); entry->SetLabel2(epgNext->StartAsLocalTime().GetAsLocalizedTime("", false)); entry->SetPath(channel->Path()); entry->SetArt("thumb", channel->IconPath()); results.Add(entry); } } } return results.Size() - iInitialSize; }
int CPVRChannelGroup::GetEPGNext(CFileItemList &results) { int iInitialSize = results.Size(); CSingleLock lock(m_critSection); for (unsigned int iChannelPtr = 0; iChannelPtr < m_members.size(); iChannelPtr++) { CPVRChannelPtr channel = m_members.at(iChannelPtr).channel; CEpg *epg = channel->GetEPG(); if (!epg || !epg->HasValidEntries() || m_members.at(iChannelPtr).channel->IsHidden()) continue; CEpgInfoTag epgNow; if (!epg->InfoTagNext(epgNow)) continue; CFileItemPtr entry(new CFileItem(epgNow)); entry->SetLabel2(epgNow.StartAsLocalTime().GetAsLocalizedTime("", false)); entry->SetPath(channel->Path()); entry->SetArt("thumb", channel->IconPath()); results.Add(entry); } return results.Size() - iInitialSize; }
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; }
bool CPVRManager::PerformChannelSwitch(const CPVRChannelPtr &channel, bool bPreview) { assert(channel.get()); // check parental lock state if (IsParentalLocked(channel)) return false; // invalid channel if (channel->ClientID() < 0) return false; // check whether we're waiting for a previous switch to complete { CSingleLock lock(m_critSection); if (m_bIsSwitchingChannels) { CLog::Log(LOGDEBUG, "PVRManager - %s - can't switch to channel '%s'. waiting for the previous switch to complete", __FUNCTION__, channel->ChannelName().c_str()); return false; } // no need to do anything except switching m_currentFile if (bPreview) { delete m_currentFile; m_currentFile = new CFileItem(channel); return true; } m_bIsSwitchingChannels = true; } CLog::Log(LOGDEBUG, "PVRManager - %s - switching to channel '%s'", __FUNCTION__, channel->ChannelName().c_str()); // will be deleted by CPVRChannelSwitchJob::DoWork() CFileItem* previousFile = m_currentFile; m_currentFile = NULL; bool bSwitched(false); // switch channel if (!m_addons->SwitchChannel(channel)) { // switch failed CSingleLock lock(m_critSection); m_bIsSwitchingChannels = false; CLog::Log(LOGERROR, "PVRManager - %s - failed to switch to channel '%s'", __FUNCTION__, channel->ChannelName().c_str()); std::string msg = StringUtils::Format(g_localizeStrings.Get(19035).c_str(), channel->ChannelName().c_str()); // CHANNELNAME could not be played. Check the log for details. CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(19166), // PVR information msg); } else { // switch successful bSwitched = true; // save previous and load new channel's settings (view mode is updated in // the player) g_application.SaveFileState(); g_application.LoadVideoSettings(channel); // set channel as selected item CGUIWindowPVRBase::SetSelectedItemPath(channel->IsRadio(), channel->Path()); UpdateLastWatched(channel); CSingleLock lock(m_critSection); m_currentFile = new CFileItem(channel); m_bIsSwitchingChannels = false; CLog::Log(LOGNOTICE, "PVRManager - %s - switched to channel '%s'", __FUNCTION__, channel->ChannelName().c_str()); } // announce OnStop and OnPlay. yes, this ain't pretty { CSingleLock lock(m_critSectionTriggers); m_pendingUpdates.push_back(new CPVRChannelSwitchJob(previousFile, m_currentFile)); } m_triggerEvent.Set(); return bSwitched; }
bool CPVRManager::PerformChannelSwitch(const CPVRChannelPtr &channel, bool bPreview) { assert(channel.get()); // check parental lock state if (IsParentalLocked(channel)) return false; // invalid channel if (channel->ClientID() < 0) return false; // check whether we're waiting for a previous switch to complete CFileItemPtr previousFile; { CSingleLock lock(m_critSection); if (m_bIsSwitchingChannels) { CLog::Log(LOGDEBUG, "PVRManager - %s - can't switch to channel '%s'. waiting for the previous switch to complete", __FUNCTION__, channel->ChannelName().c_str()); return false; } if (bPreview) { if (!g_infoManager.GetShowInfo() && m_settings.GetIntValue(CSettings::SETTING_PVRPLAYBACK_CHANNELENTRYTIMEOUT) == 0) { // no need to do anything return true; } m_currentFile.reset(new CFileItem(channel)); if (IsPlayingChannel(channel)) m_isChannelPreview = false; else m_isChannelPreview = true; return true; } m_bIsSwitchingChannels = true; CLog::Log(LOGDEBUG, "PVRManager - %s - switching to channel '%s'", __FUNCTION__, channel->ChannelName().c_str()); previousFile = std::move(m_currentFile); } bool bSwitched(false); // switch channel if (!m_addons->SwitchChannel(channel)) { // switch failed CSingleLock lock(m_critSection); m_bIsSwitchingChannels = false; CLog::Log(LOGERROR, "PVRManager - %s - failed to switch to channel '%s'", __FUNCTION__, channel->ChannelName().c_str()); std::string msg = StringUtils::Format(g_localizeStrings.Get(19035).c_str(), channel->ChannelName().c_str()); // CHANNELNAME could not be played. Check the log for details. CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(19166), // PVR information msg); } else { // switch successful bSwitched = true; // save previous and load new channel's settings (view mode is updated in // the player) g_application.SaveFileState(); g_application.LoadVideoSettings(channel); // set channel as selected item CGUIWindowPVRBase::SetSelectedItemPath(channel->IsRadio(), channel->Path()); UpdateLastWatched(channel); CSingleLock lock(m_critSection); m_currentFile.reset(new CFileItem(channel)); m_bIsSwitchingChannels = false; CLog::Log(LOGNOTICE, "PVRManager - %s - switched to channel '%s'", __FUNCTION__, channel->ChannelName().c_str()); } // announce OnStop if (previousFile) { CVariant data(CVariant::VariantTypeObject); data["end"] = true; ANNOUNCEMENT::CAnnouncementManager::GetInstance().Announce(ANNOUNCEMENT::Player, "xbmc", "OnStop", previousFile, data); } // announce OnPlay if (m_currentFile) { CVariant param; param["player"]["speed"] = 1; param["player"]["playerid"] = CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist(); ANNOUNCEMENT::CAnnouncementManager::GetInstance().Announce(ANNOUNCEMENT::Player, "xbmc", "OnPlay", m_currentFile, param); } return bSwitched; }