From 733bbf188dddaf2de6dfb465ee5cf6c792847d60 Mon Sep 17 00:00:00 2001 From: Kai Sommerfeld Date: Sat, 9 Jun 2018 15:28:38 +0200 Subject: [PATCH] [PVR][VideoPlayer] Rework and simplify DVDInputStreamPVRManager. --- .../DVDDemuxers/DVDFactoryDemuxer.cpp | 4 - .../DVDInputStreams/CMakeLists.txt | 12 +- .../DVDInputStreams/DVDFactoryInputStream.cpp | 9 +- .../DVDInputStreamPVRManager.cpp | 482 ------------------ .../DVDInputStreams/InputStreamPVRBase.cpp | 359 +++++++++++++ ...treamPVRManager.h => InputStreamPVRBase.h} | 59 +-- .../DVDInputStreams/InputStreamPVRChannel.cpp | 121 +++++ .../DVDInputStreams/InputStreamPVRChannel.h | 45 ++ .../InputStreamPVRRecording.cpp | 97 ++++ .../DVDInputStreams/InputStreamPVRRecording.h | 40 ++ xbmc/cores/VideoPlayer/VideoPlayer.cpp | 7 +- xbmc/pvr/PVRGUIActions.cpp | 2 +- xbmc/pvr/PVRGUIInfo.cpp | 40 +- xbmc/pvr/PVRManager.cpp | 92 ++-- xbmc/pvr/PVRManager.h | 47 +- xbmc/pvr/addons/PVRClients.cpp | 251 --------- xbmc/pvr/addons/PVRClients.h | 132 +---- xbmc/pvr/epg/EpgInfoTag.cpp | 2 +- 18 files changed, 824 insertions(+), 977 deletions(-) delete mode 100644 xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamPVRManager.cpp create mode 100644 xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.cpp rename xbmc/cores/VideoPlayer/DVDInputStreams/{DVDInputStreamPVRManager.h => InputStreamPVRBase.h} (70%) create mode 100644 xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRChannel.cpp create mode 100644 xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRChannel.h create mode 100644 xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRRecording.cpp create mode 100644 xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRRecording.h diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDFactoryDemuxer.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDFactoryDemuxer.cpp index e88bd3b416991..50e29a096b074 100644 --- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDFactoryDemuxer.cpp +++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDFactoryDemuxer.cpp @@ -21,19 +21,15 @@ #include "DVDFactoryDemuxer.h" #include "DVDInputStreams/DVDInputStream.h" -#include "DVDInputStreams/DVDInputStreamPVRManager.h" #include "DVDDemuxFFmpeg.h" #include "DVDDemuxBXA.h" #include "DVDDemuxCDDA.h" #include "DVDDemuxClient.h" #include "DemuxMultiSource.h" -#include "pvr/PVRManager.h" #include "utils/log.h" #include "utils/URIUtils.h" -using namespace PVR; - CDVDDemux* CDVDFactoryDemuxer::CreateDemuxer(std::shared_ptr pInputStream, bool fileinfo) { if (!pInputStream) diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/CMakeLists.txt b/xbmc/cores/VideoPlayer/DVDInputStreams/CMakeLists.txt index 9385cb78f997f..5f60202bcb82d 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/CMakeLists.txt +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/CMakeLists.txt @@ -4,11 +4,13 @@ set(SOURCES DVDFactoryInputStream.cpp DVDInputStreamFile.cpp DVDInputStreamMemory.cpp DVDInputStreamNavigator.cpp - DVDInputStreamPVRManager.cpp DVDInputStreamStack.cpp DVDStateSerializer.cpp InputStreamAddon.cpp - InputStreamMultiSource.cpp) + InputStreamMultiSource.cpp + InputStreamPVRBase.cpp + InputStreamPVRChannel.cpp + InputStreamPVRRecording.cpp) set(HEADERS DVDFactoryInputStream.h DVDInputStream.h @@ -16,13 +18,15 @@ set(HEADERS DVDFactoryInputStream.h DVDInputStreamFile.h DVDInputStreamMemory.h DVDInputStreamNavigator.h - DVDInputStreamPVRManager.h DVDInputStreamStack.h DVDStateSerializer.h DllDvdNav.h InputStreamAddon.h InputStreamMultiStreams.h - InputStreamMultiSource.h) + InputStreamMultiSource.h + InputStreamPVRBase.h + InputStreamPVRChannel.h + InputStreamPVRRecording.h) if(BLURAY_FOUND) list(APPEND SOURCES DVDInputStreamBluray.cpp) diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDFactoryInputStream.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDFactoryInputStream.cpp index 5867da2101404..3cf945057c3b2 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDFactoryInputStream.cpp +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDFactoryInputStream.cpp @@ -23,9 +23,10 @@ #include "DVDInputStreamFile.h" #include "DVDInputStreamNavigator.h" #include "DVDInputStreamFFmpeg.h" -#include "DVDInputStreamPVRManager.h" #include "InputStreamAddon.h" #include "InputStreamMultiSource.h" +#include "InputStreamPVRChannel.h" +#include "InputStreamPVRRecording.h" #ifdef HAVE_LIBBLURAY #include "DVDInputStreamBluray.h" #endif @@ -96,8 +97,10 @@ std::shared_ptr CDVDFactoryInputStream::CreateInputStream(IVide if (fileitem.IsDVDFile(false, true)) return std::shared_ptr(new CDVDInputStreamNavigator(pPlayer, fileitem)); - else if(file.substr(0, 6) == "pvr://") - return std::shared_ptr(new CDVDInputStreamPVRManager(pPlayer, fileitem)); + else if (fileitem.IsPVRChannel() && file.substr(0, 6) == "pvr://") + return std::shared_ptr(new CInputStreamPVRChannel(pPlayer, fileitem)); + else if (fileitem.IsUsablePVRRecording() && file.substr(0, 6) == "pvr://") + return std::shared_ptr(new CInputStreamPVRRecording(pPlayer, fileitem)); #ifdef HAVE_LIBBLURAY else if (fileitem.IsType(".bdmv") || fileitem.IsType(".mpls") || file.substr(0, 7) == "bluray:") return std::shared_ptr(new CDVDInputStreamBluray(pPlayer, fileitem)); diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamPVRManager.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamPVRManager.cpp deleted file mode 100644 index 9d042d4368aed..0000000000000 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamPVRManager.cpp +++ /dev/null @@ -1,482 +0,0 @@ -/* - * Copyright (C) 2012-2013 Team XBMC - * http://kodi.tv - * - * This Program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * . - * - */ - -#include "DVDFactoryInputStream.h" -#include "DVDInputStreamPVRManager.h" -#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" -#include "ServiceBroker.h" -#include "URL.h" -#include "pvr/PVRManager.h" -#include "pvr/channels/PVRChannel.h" -#include "utils/log.h" -#include "utils/StringUtils.h" -#include "utils/URIUtils.h" -#include "pvr/addons/PVRClients.h" -#include "pvr/channels/PVRChannelGroupsContainer.h" -#include "pvr/recordings/PVRRecordingsPath.h" -#include "pvr/recordings/PVRRecordings.h" -#include "settings/Settings.h" -#include "cores/VideoPlayer/DVDDemuxers/DVDDemux.h" - -#include - -using namespace XFILE; -using namespace PVR; - -/************************************************************************ - * Description: Class constructor, initialize member variables - * public class is CDVDInputStream - */ -CDVDInputStreamPVRManager::CDVDInputStreamPVRManager(IVideoPlayer* pPlayer, const CFileItem& fileitem) - : CDVDInputStream(DVDSTREAM_TYPE_PVRMANAGER, fileitem) -{ - m_pPlayer = pPlayer; - m_eof = true; - m_ScanTimeout.Set(0); - m_demuxActive = false; - - m_StreamProps = new PVR_STREAM_PROPERTIES; -} - -/************************************************************************ - * Description: Class destructor - */ -CDVDInputStreamPVRManager::~CDVDInputStreamPVRManager() -{ - Close(); - - m_streamMap.clear(); - delete m_StreamProps; -} - -bool CDVDInputStreamPVRManager::IsEOF() -{ - // don't mark as eof while within the scan timeout - if (!m_ScanTimeout.IsTimePast()) - return false; - - return m_eof; -} - -bool CDVDInputStreamPVRManager::Open() -{ - if (!CDVDInputStream::Open()) - return false; - - CURL url(m_item.GetDynPath()); - - std::string strURL = url.Get(); - - if (StringUtils::StartsWith(strURL, "pvr://channels/tv/") || - StringUtils::StartsWith(strURL, "pvr://channels/radio/")) - { - CFileItemPtr tag = CServiceBroker::GetPVRManager().ChannelGroups()->GetByPath(strURL); - if (tag && tag->HasPVRChannelInfoTag()) - { - if (!CServiceBroker::GetPVRManager().OpenLiveStream(*tag)) - return false; - - m_isRecording = false; - CLog::Log(LOGDEBUG, "CDVDInputStreamPVRManager - %s - playback has started on filename %s", __FUNCTION__, strURL.c_str()); - } - else - { - CLog::Log(LOGERROR, "CDVDInputStreamPVRManager - %s - channel not found with filename %s", __FUNCTION__, strURL.c_str()); - return false; - } - } - else if (CPVRRecordingsPath(strURL).IsActive()) - { - CFileItemPtr tag = CServiceBroker::GetPVRManager().Recordings()->GetByPath(strURL); - if (tag && tag->HasPVRRecordingInfoTag()) - { - if (!CServiceBroker::GetPVRManager().OpenRecordedStream(tag->GetPVRRecordingInfoTag())) - return false; - - m_isRecording = true; - CLog::Log(LOGDEBUG, "%s - playback has started on recording %s (%s)", __FUNCTION__, strURL.c_str(), tag->GetPVRRecordingInfoTag()->m_strIconPath.c_str()); - } - else - { - CLog::Log(LOGERROR, "CDVDInputStreamPVRManager - Recording not found with filename %s", strURL.c_str()); - return false; - } - } - else if (CPVRRecordingsPath(strURL).IsDeleted()) - { - CLog::Log(LOGNOTICE, "CDVDInputStreamPVRManager - Playback of deleted recordings is not possible (%s)", strURL.c_str()); - return false; - } - else - { - CLog::Log(LOGERROR, "%s - invalid path specified %s", __FUNCTION__, strURL.c_str()); - return false; - } - - m_eof = false; - - if (URIUtils::IsPVRChannel(url.Get())) - { - std::shared_ptr client; - if (CServiceBroker::GetPVRManager().Clients()->GetPlayingClient(client) && - client->GetClientCapabilities().HandlesDemuxing()) - m_demuxActive = true; - } - - CLog::Log(LOGDEBUG, "CDVDInputStreamPVRManager::Open - stream opened: %s", CURL::GetRedacted(m_item.GetDynPath()).c_str()); - - m_StreamProps->iStreamCount = 0; - return true; -} - -// close file and reset everything -void CDVDInputStreamPVRManager::Close() -{ - CServiceBroker::GetPVRManager().CloseStream(); - - CDVDInputStream::Close(); - - m_eof = true; - - CLog::Log(LOGDEBUG, "CDVDInputStreamPVRManager::Close - stream closed"); -} - -int CDVDInputStreamPVRManager::Read(uint8_t* buf, int buf_size) -{ - int ret = CServiceBroker::GetPVRManager().Clients()->ReadStream(buf, buf_size); - if (ret < 0) - ret = -1; - - /* we currently don't support non completing reads */ - if( ret == 0 ) - m_eof = true; - - return ret; -} - -int64_t CDVDInputStreamPVRManager::Seek(int64_t offset, int whence) -{ - if (whence == SEEK_POSSIBLE) - { - if (CServiceBroker::GetPVRManager().Clients()->CanSeekStream()) - return 1; - else - return 0; - } - - int64_t ret = CServiceBroker::GetPVRManager().Clients()->SeekStream(offset, whence); - - // if we succeed, we are not eof anymore - if( ret >= 0 ) - m_eof = false; - - return ret; -} - -int64_t CDVDInputStreamPVRManager::GetLength() -{ - return CServiceBroker::GetPVRManager().Clients()->GetStreamLength(); -} - -int CDVDInputStreamPVRManager::GetBlockSize() -{ - return CServiceBroker::GetPVRManager().Clients()->GetStreamReadChunkSize(m_item); -} - -bool CDVDInputStreamPVRManager::GetTimes(Times ×) -{ - PVR_STREAM_TIMES streamTimes; - bool ret = CServiceBroker::GetPVRManager().Clients()->GetStreamTimes(&streamTimes); - if (ret) - { - times.startTime = streamTimes.startTime; - times.ptsStart = streamTimes.ptsStart; - times.ptsBegin = streamTimes.ptsBegin; - times.ptsEnd = streamTimes.ptsEnd; - } - - return ret; -} - -CPVRChannelPtr CDVDInputStreamPVRManager::GetSelectedChannel() -{ - return CServiceBroker::GetPVRManager().GetPlayingChannel(); -} - -CDVDInputStream::ENextStream CDVDInputStreamPVRManager::NextStream() -{ - m_eof = IsEOF(); - - if(!m_isRecording) - { - if (m_eof) - return NEXTSTREAM_OPEN; - else - return NEXTSTREAM_RETRY; - } - return NEXTSTREAM_NONE; -} - -bool CDVDInputStreamPVRManager::CanPause() -{ - return CServiceBroker::GetPVRManager().Clients()->CanPauseStream(); -} - -bool CDVDInputStreamPVRManager::CanSeek() -{ - return CServiceBroker::GetPVRManager().Clients()->CanSeekStream(); -} - -void CDVDInputStreamPVRManager::Pause(bool bPaused) -{ - CServiceBroker::GetPVRManager().Clients()->PauseStream(bPaused); -} - -bool CDVDInputStreamPVRManager::IsRealtime() -{ - return CServiceBroker::GetPVRManager().Clients()->IsRealTimeStream(); -} - -inline CDVDInputStream::IDemux* CDVDInputStreamPVRManager::GetIDemux() -{ - if (m_demuxActive) - return this; - else - return nullptr; -} - -bool CDVDInputStreamPVRManager::OpenDemux() -{ - CPVRClientPtr client; - if (!CServiceBroker::GetPVRManager().Clients()->GetPlayingClient(client)) - { - return false; - } - - client->GetStreamProperties(m_StreamProps); - UpdateStreamMap(); - return true; -} - -DemuxPacket* CDVDInputStreamPVRManager::ReadDemux() -{ - CPVRClientPtr client; - if (!CServiceBroker::GetPVRManager().Clients()->GetPlayingClient(client)) - { - return nullptr; - } - - DemuxPacket* pPacket = nullptr; - client->DemuxRead(pPacket); - if (!pPacket) - { - return nullptr; - } - else if (pPacket->iStreamId == DMX_SPECIALID_STREAMINFO) - { - client->GetStreamProperties(m_StreamProps); - return pPacket; - } - else if (pPacket->iStreamId == DMX_SPECIALID_STREAMCHANGE) - { - client->GetStreamProperties(m_StreamProps); - UpdateStreamMap(); - } - - return pPacket; -} - -CDemuxStream* CDVDInputStreamPVRManager::GetStream(int iStreamId) const -{ - auto stream = m_streamMap.find(iStreamId); - if (stream != m_streamMap.end()) - { - return stream->second.get(); - } - else - return nullptr; -} - -std::vector CDVDInputStreamPVRManager::GetStreams() const -{ - std::vector streams; - - for (auto& st : m_streamMap) - { - streams.push_back(st.second.get()); - } - - return streams; -} - -int CDVDInputStreamPVRManager::GetNrOfStreams() const -{ - return m_StreamProps->iStreamCount; -} - -void CDVDInputStreamPVRManager::SetSpeed(int Speed) -{ - CPVRClientPtr client; - if (CServiceBroker::GetPVRManager().Clients()->GetPlayingClient(client)) - { - client->SetSpeed(Speed); - } -} - -bool CDVDInputStreamPVRManager::SeekTime(double timems, bool backwards, double *startpts) -{ - CPVRClientPtr client; - if (CServiceBroker::GetPVRManager().Clients()->GetPlayingClient(client)) - { - return client->SeekTime(timems, backwards, startpts) == PVR_ERROR_NO_ERROR; - } - return false; -} - -void CDVDInputStreamPVRManager::AbortDemux() -{ - CPVRClientPtr client; - if (CServiceBroker::GetPVRManager().Clients()->GetPlayingClient(client)) - { - client->DemuxAbort(); - } -} - -void CDVDInputStreamPVRManager::FlushDemux() -{ - CPVRClientPtr client; - if (CServiceBroker::GetPVRManager().Clients()->GetPlayingClient(client)) - { - client->DemuxFlush(); - } -} - -std::shared_ptr CDVDInputStreamPVRManager::GetStreamInternal(int iStreamId) -{ - auto stream = m_streamMap.find(iStreamId); - if (stream != m_streamMap.end()) - { - return stream->second; - } - else - return nullptr; -} - -void CDVDInputStreamPVRManager::UpdateStreamMap() -{ - std::map> m_newStreamMap; - - int num = GetNrOfStreams(); - for (int i = 0; i < num; ++i) - { - PVR_STREAM_PROPERTIES::PVR_STREAM stream = m_StreamProps->stream[i]; - - std::shared_ptr dStream = GetStreamInternal(stream.iPID); - - if (stream.iCodecType == XBMC_CODEC_TYPE_AUDIO) - { - std::shared_ptr streamAudio; - - if (dStream) - streamAudio = std::dynamic_pointer_cast(dStream); - if (!streamAudio) - streamAudio = std::make_shared(); - - streamAudio->iChannels = stream.iChannels; - streamAudio->iSampleRate = stream.iSampleRate; - streamAudio->iBlockAlign = stream.iBlockAlign; - streamAudio->iBitRate = stream.iBitRate; - streamAudio->iBitsPerSample = stream.iBitsPerSample; - - dStream = streamAudio; - } - else if (stream.iCodecType == XBMC_CODEC_TYPE_VIDEO) - { - std::shared_ptr streamVideo; - - if (dStream) - streamVideo = std::dynamic_pointer_cast(dStream); - if (!streamVideo) - streamVideo = std::make_shared(); - - streamVideo->iFpsScale = stream.iFPSScale; - streamVideo->iFpsRate = stream.iFPSRate; - streamVideo->iHeight = stream.iHeight; - streamVideo->iWidth = stream.iWidth; - streamVideo->fAspect = stream.fAspect; - - dStream = streamVideo; - } - else if (stream.iCodecId == AV_CODEC_ID_DVB_TELETEXT) - { - std::shared_ptr streamTeletext; - - if (dStream) - streamTeletext = std::dynamic_pointer_cast(dStream); - if (!streamTeletext) - streamTeletext = std::make_shared(); - - dStream = streamTeletext; - } - else if (stream.iCodecType == XBMC_CODEC_TYPE_SUBTITLE) - { - std::shared_ptr streamSubtitle; - - if (dStream) - streamSubtitle = std::dynamic_pointer_cast(dStream); - if (!streamSubtitle) - streamSubtitle = std::make_shared(); - - if (stream.iSubtitleInfo) - { - streamSubtitle->ExtraData = new uint8_t[4]; - streamSubtitle->ExtraSize = 4; - streamSubtitle->ExtraData[0] = (stream.iSubtitleInfo >> 8) & 0xff; - streamSubtitle->ExtraData[1] = (stream.iSubtitleInfo >> 0) & 0xff; - streamSubtitle->ExtraData[2] = (stream.iSubtitleInfo >> 24) & 0xff; - streamSubtitle->ExtraData[3] = (stream.iSubtitleInfo >> 16) & 0xff; - } - dStream = streamSubtitle; - } - else if (stream.iCodecType == XBMC_CODEC_TYPE_RDS && - CServiceBroker::GetSettings().GetBool("pvrplayback.enableradiords")) - { - std::shared_ptr streamRadioRDS; - - if (dStream) - streamRadioRDS = std::dynamic_pointer_cast(dStream); - if (!streamRadioRDS) - streamRadioRDS = std::make_shared(); - - dStream = streamRadioRDS; - } - else - dStream = std::make_shared(); - - dStream->codec = (AVCodecID)stream.iCodecId; - dStream->uniqueId = stream.iPID; - dStream->language = stream.strLanguage; - dStream->realtime = true; - - m_newStreamMap[stream.iPID] = dStream; - } - - m_streamMap = m_newStreamMap; -} diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.cpp new file mode 100644 index 0000000000000..8c7fa18c41ed6 --- /dev/null +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.cpp @@ -0,0 +1,359 @@ +/* + * Copyright (C) 2012-2013 Team XBMC + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * . + * + */ + +#include "InputStreamPVRBase.h" + +#include "ServiceBroker.h" +#include "addons/PVRClient.h" +#include "cores/VideoPlayer/DVDDemuxers/DVDDemux.h" +#include "cores/VideoPlayer/Interface/Addon/DemuxPacket.h" +#include "pvr/PVRManager.h" +#include "settings/Settings.h" +#include "utils/log.h" + +CInputStreamPVRBase::CInputStreamPVRBase(IVideoPlayer* pPlayer, const CFileItem& fileitem) + : CDVDInputStream(DVDSTREAM_TYPE_PVRMANAGER, fileitem), + m_eof(true), + m_StreamProps(new PVR_STREAM_PROPERTIES()) +{ + if (!CServiceBroker::GetPVRManager().GetClient(fileitem, m_client) || !m_client) + CLog::Log(LOGERROR, "CInputStreamPVRBase - %s - unable to obtain pvr addon instance for item '%s'", __FUNCTION__, fileitem.GetPath().c_str()); +} + +CInputStreamPVRBase::~CInputStreamPVRBase() +{ + m_streamMap.clear(); +} + +bool CInputStreamPVRBase::IsEOF() +{ + return m_eof; +} + +bool CInputStreamPVRBase::Open() +{ + if (CDVDInputStream::Open() && OpenPVRStream()) + { + m_eof = false; + m_StreamProps->iStreamCount = 0; + return true; + } + else + { + return false; + } +} + +void CInputStreamPVRBase::Close() +{ + ClosePVRStream(); + CDVDInputStream::Close(); + m_eof = true; +} + +int CInputStreamPVRBase::Read(uint8_t* buf, int buf_size) +{ + int ret = ReadPVRStream(buf, buf_size); + + // we currently don't support non completing reads + if (ret == 0) + m_eof = true; + else if (ret < -1) + ret = -1; + + return ret; +} + +int64_t CInputStreamPVRBase::Seek(int64_t offset, int whence) +{ + if (whence == SEEK_POSSIBLE) + return CanSeek() ? 1 : 0; + + int64_t ret = SeekPVRStream(offset, whence); + + // if we succeed, we are not eof anymore + if (ret >= 0) + m_eof = false; + + return ret; +} + +int64_t CInputStreamPVRBase::GetLength() +{ + return GetPVRStreamLength(); +} + +int CInputStreamPVRBase::GetBlockSize() +{ + int ret = -1; + + if (m_client) + m_client->GetStreamReadChunkSize(ret); + + return ret; +} + +bool CInputStreamPVRBase::GetTimes(Times ×) +{ + PVR_STREAM_TIMES streamTimes; + if (m_client && m_client->GetStreamTimes(&streamTimes) == PVR_ERROR_NO_ERROR) + { + times.startTime = streamTimes.startTime; + times.ptsStart = streamTimes.ptsStart; + times.ptsBegin = streamTimes.ptsBegin; + times.ptsEnd = streamTimes.ptsEnd; + return true; + } + else + { + return false; + } +} + +CDVDInputStream::ENextStream CInputStreamPVRBase::NextStream() +{ + return NextPVRStream(); +} + +bool CInputStreamPVRBase::CanPause() +{ + return CanPausePVRStream(); +} + +bool CInputStreamPVRBase::CanSeek() +{ + return CanSeekPVRStream(); +} + +void CInputStreamPVRBase::Pause(bool bPaused) +{ + if (m_client) + m_client->PauseStream(bPaused); +} + +bool CInputStreamPVRBase::IsRealtime() +{ + bool ret = false; + + if (m_client) + m_client->IsRealTimeStream(ret); + + return ret; +} + +bool CInputStreamPVRBase::OpenDemux() +{ + if (m_client) + { + m_client->GetStreamProperties(m_StreamProps.get()); + UpdateStreamMap(); + return true; + } + else + { + return false; + } +} + +DemuxPacket* CInputStreamPVRBase::ReadDemux() +{ + if (!m_client) + return nullptr; + + DemuxPacket* pPacket = nullptr; + m_client->DemuxRead(pPacket); + if (!pPacket) + { + return nullptr; + } + else if (pPacket->iStreamId == DMX_SPECIALID_STREAMINFO) + { + m_client->GetStreamProperties(m_StreamProps.get()); + return pPacket; + } + else if (pPacket->iStreamId == DMX_SPECIALID_STREAMCHANGE) + { + m_client->GetStreamProperties(m_StreamProps.get()); + UpdateStreamMap(); + } + + return pPacket; +} + +CDemuxStream* CInputStreamPVRBase::GetStream(int iStreamId) const +{ + const auto stream = m_streamMap.find(iStreamId); + if (stream != m_streamMap.end()) + return stream->second.get(); + else + return nullptr; +} + +std::vector CInputStreamPVRBase::GetStreams() const +{ + std::vector streams; + + for (const auto& st : m_streamMap) + streams.emplace_back(st.second.get()); + + return streams; +} + +int CInputStreamPVRBase::GetNrOfStreams() const +{ + return m_StreamProps->iStreamCount; +} + +void CInputStreamPVRBase::SetSpeed(int Speed) +{ + if (m_client) + m_client->SetSpeed(Speed); +} + +bool CInputStreamPVRBase::SeekTime(double timems, bool backwards, double *startpts) +{ + if (m_client) + return m_client->SeekTime(timems, backwards, startpts) == PVR_ERROR_NO_ERROR; + else + return false; +} + +void CInputStreamPVRBase::AbortDemux() +{ + if (m_client) + m_client->DemuxAbort(); +} + +void CInputStreamPVRBase::FlushDemux() +{ + if (m_client) + m_client->DemuxFlush(); +} + +std::shared_ptr CInputStreamPVRBase::GetStreamInternal(int iStreamId) +{ + const auto stream = m_streamMap.find(iStreamId); + if (stream != m_streamMap.end()) + return stream->second; + else + return nullptr; +} + +void CInputStreamPVRBase::UpdateStreamMap() +{ + std::map> newStreamMap; + + int num = GetNrOfStreams(); + for (int i = 0; i < num; ++i) + { + PVR_STREAM_PROPERTIES::PVR_STREAM stream = m_StreamProps->stream[i]; + + std::shared_ptr dStream = GetStreamInternal(stream.iPID); + + if (stream.iCodecType == XBMC_CODEC_TYPE_AUDIO) + { + std::shared_ptr streamAudio; + + if (dStream) + streamAudio = std::dynamic_pointer_cast(dStream); + if (!streamAudio) + streamAudio = std::make_shared(); + + streamAudio->iChannels = stream.iChannels; + streamAudio->iSampleRate = stream.iSampleRate; + streamAudio->iBlockAlign = stream.iBlockAlign; + streamAudio->iBitRate = stream.iBitRate; + streamAudio->iBitsPerSample = stream.iBitsPerSample; + + dStream = streamAudio; + } + else if (stream.iCodecType == XBMC_CODEC_TYPE_VIDEO) + { + std::shared_ptr streamVideo; + + if (dStream) + streamVideo = std::dynamic_pointer_cast(dStream); + if (!streamVideo) + streamVideo = std::make_shared(); + + streamVideo->iFpsScale = stream.iFPSScale; + streamVideo->iFpsRate = stream.iFPSRate; + streamVideo->iHeight = stream.iHeight; + streamVideo->iWidth = stream.iWidth; + streamVideo->fAspect = stream.fAspect; + + dStream = streamVideo; + } + else if (stream.iCodecId == AV_CODEC_ID_DVB_TELETEXT) + { + std::shared_ptr streamTeletext; + + if (dStream) + streamTeletext = std::dynamic_pointer_cast(dStream); + if (!streamTeletext) + streamTeletext = std::make_shared(); + + dStream = streamTeletext; + } + else if (stream.iCodecType == XBMC_CODEC_TYPE_SUBTITLE) + { + std::shared_ptr streamSubtitle; + + if (dStream) + streamSubtitle = std::dynamic_pointer_cast(dStream); + if (!streamSubtitle) + streamSubtitle = std::make_shared(); + + if (stream.iSubtitleInfo) + { + streamSubtitle->ExtraData = new uint8_t[4]; + streamSubtitle->ExtraSize = 4; + streamSubtitle->ExtraData[0] = (stream.iSubtitleInfo >> 8) & 0xff; + streamSubtitle->ExtraData[1] = (stream.iSubtitleInfo >> 0) & 0xff; + streamSubtitle->ExtraData[2] = (stream.iSubtitleInfo >> 24) & 0xff; + streamSubtitle->ExtraData[3] = (stream.iSubtitleInfo >> 16) & 0xff; + } + dStream = streamSubtitle; + } + else if (stream.iCodecType == XBMC_CODEC_TYPE_RDS && + CServiceBroker::GetSettings().GetBool("pvrplayback.enableradiords")) + { + std::shared_ptr streamRadioRDS; + + if (dStream) + streamRadioRDS = std::dynamic_pointer_cast(dStream); + if (!streamRadioRDS) + streamRadioRDS = std::make_shared(); + + dStream = streamRadioRDS; + } + else + dStream = std::make_shared(); + + dStream->codec = (AVCodecID)stream.iCodecId; + dStream->uniqueId = stream.iPID; + dStream->language = stream.strLanguage; + dStream->realtime = true; + + newStreamMap[stream.iPID] = dStream; + } + + m_streamMap = newStreamMap; +} diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamPVRManager.h b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.h similarity index 70% rename from xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamPVRManager.h rename to xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.h index 5c1f4f7a39df8..d0c9e1a8ecb2a 100644 --- a/xbmc/cores/VideoPlayer/DVDInputStreams/DVDInputStreamPVRManager.h +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRBase.h @@ -20,32 +20,29 @@ * */ -/* -* for DESCRIPTION see 'DVDInputStreamPVRManager.cpp' -*/ - +#include +#include #include #include "DVDInputStream.h" -#include "FileItem.h" -#include "threads/SystemClock.h" +class CFileItem; +class IDemux; class IVideoPlayer; struct PVR_STREAM_PROPERTIES; -class CDemuxStreamAudio; -class CDemuxStreamVideo; -class CDemuxStreamSubtitle; -class CDemuxStreamTeletext; -class CDemuxStreamRadioRDS; -class IDemux; -class CDVDInputStreamPVRManager +namespace PVR +{ + class CPVRClient; +} + +class CInputStreamPVRBase : public CDVDInputStream , public CDVDInputStream::ITimes , public CDVDInputStream::IDemux { public: - CDVDInputStreamPVRManager(IVideoPlayer* pPlayer, const CFileItem& fileitem); - ~CDVDInputStreamPVRManager() override; + CInputStreamPVRBase(IVideoPlayer* pPlayer, const CFileItem& fileitem); + ~CInputStreamPVRBase() override; bool Open() override; void Close() override; int Read(uint8_t* buf, int buf_size) override; @@ -58,8 +55,6 @@ class CDVDInputStreamPVRManager ENextStream NextStream() override; bool IsRealtime() override; - PVR::CPVRChannelPtr GetSelectedChannel(); - CDVDInputStream::ITimes* GetITimes() override { return this; } bool GetTimes(Times ×) override; @@ -67,11 +62,8 @@ class CDVDInputStreamPVRManager bool CanPause() override; void Pause(bool bPaused); - /* overloaded is streamtype to support m_pOtherStream */ - bool IsStreamType(DVDStreamType type) const; - // Demux interface - CDVDInputStream::IDemux* GetIDemux() override; + CDVDInputStream::IDemux* GetIDemux() override { return nullptr; }; bool OpenDemux() override; DemuxPacket* ReadDemux() override; CDemuxStream* GetStream(int iStreamId) const override; @@ -85,19 +77,18 @@ class CDVDInputStreamPVRManager protected: void UpdateStreamMap(); std::shared_ptr GetStreamInternal(int iStreamId); - IVideoPlayer* m_pPlayer; + + virtual bool OpenPVRStream() = 0; + virtual void ClosePVRStream() = 0; + virtual int ReadPVRStream(uint8_t* buf, int buf_size) = 0; + virtual int64_t SeekPVRStream(int64_t offset, int whence) = 0; + virtual int64_t GetPVRStreamLength() = 0; + virtual ENextStream NextPVRStream() = 0; + virtual bool CanPausePVRStream() = 0; + virtual bool CanSeekPVRStream() = 0; + bool m_eof; - bool m_demuxActive; - std::string m_strContent; - XbmcThreads::EndTime m_ScanTimeout; - PVR_STREAM_PROPERTIES *m_StreamProps; + std::shared_ptr m_StreamProps; std::map> m_streamMap; - bool m_isRecording; + std::shared_ptr m_client; }; - - -inline bool CDVDInputStreamPVRManager::IsStreamType(DVDStreamType type) const -{ - return m_streamType == type; -} - diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRChannel.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRChannel.cpp new file mode 100644 index 0000000000000..c1174b3c07b64 --- /dev/null +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRChannel.cpp @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2012-2013 Team XBMC + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * . + * + */ + +#include "InputStreamPVRChannel.h" + +#include "addons/PVRClient.h" +#include "utils/log.h" + +CInputStreamPVRChannel::CInputStreamPVRChannel(IVideoPlayer* pPlayer, const CFileItem& fileitem) + : CInputStreamPVRBase(pPlayer, fileitem), + m_bDemuxActive(false) +{ +} + +CInputStreamPVRChannel::~CInputStreamPVRChannel() +{ + Close(); +} + +CDVDInputStream::IDemux* CInputStreamPVRChannel::GetIDemux() +{ + if (m_bDemuxActive) + return this; + + return CInputStreamPVRBase::GetIDemux(); +} + +bool CInputStreamPVRChannel::OpenPVRStream() +{ + if (m_client && (m_client->OpenLiveStream(m_item.GetPVRChannelInfoTag()) == PVR_ERROR_NO_ERROR)) + { + m_bDemuxActive = m_client->GetClientCapabilities().HandlesDemuxing(); + CLog::Log(LOGDEBUG, "CInputStreamPVRChannel - %s - opened channel stream %s", __FUNCTION__, m_item.GetPath().c_str()); + return true; + } + return false; +} + +void CInputStreamPVRChannel::ClosePVRStream() +{ + if (m_client && (m_client->CloseLiveStream() == PVR_ERROR_NO_ERROR)) + { + m_bDemuxActive = false; + CLog::Log(LOGDEBUG, "CInputStreamPVRChannel - %s - closed channel stream %s", __FUNCTION__, m_item.GetPath().c_str()); + } +} + +int CInputStreamPVRChannel::ReadPVRStream(uint8_t* buf, int buf_size) +{ + int ret = -1; + + if (m_client) + m_client->ReadLiveStream(buf, buf_size, ret); + + return ret; +} + +int64_t CInputStreamPVRChannel::SeekPVRStream(int64_t offset, int whence) +{ + int64_t ret = -1; + + if (m_client) + m_client->SeekLiveStream(offset, whence, ret); + + return ret; +} + +int64_t CInputStreamPVRChannel::GetPVRStreamLength() +{ + int64_t ret = -1; + + if (m_client) + m_client->GetLiveStreamLength(ret); + + return ret; +} + +CDVDInputStream::ENextStream CInputStreamPVRChannel::NextPVRStream() +{ + if (m_eof) + return NEXTSTREAM_OPEN; + + return NEXTSTREAM_RETRY; +} + +bool CInputStreamPVRChannel::CanPausePVRStream() +{ + bool ret = false; + + if (m_client) + m_client->CanPauseStream(ret); + + return ret; +} + +bool CInputStreamPVRChannel::CanSeekPVRStream() +{ + bool ret = false; + + if (m_client) + m_client->CanSeekStream(ret); + + return ret; +} diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRChannel.h b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRChannel.h new file mode 100644 index 0000000000000..92cf0f6b91a46 --- /dev/null +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRChannel.h @@ -0,0 +1,45 @@ +#pragma once + +/* + * Copyright (C) 2012-2013 Team XBMC + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * . + * + */ + +#include "InputStreamPVRBase.h" + +class CInputStreamPVRChannel : public CInputStreamPVRBase +{ +public: + CInputStreamPVRChannel(IVideoPlayer* pPlayer, const CFileItem& fileitem); + ~CInputStreamPVRChannel() override; + + CDVDInputStream::IDemux* GetIDemux() override; + +protected: + bool OpenPVRStream() override; + void ClosePVRStream() override; + int ReadPVRStream(uint8_t* buf, int buf_size) override; + int64_t SeekPVRStream(int64_t offset, int whence) override; + int64_t GetPVRStreamLength() override; + ENextStream NextPVRStream() override; + bool CanPausePVRStream() override; + bool CanSeekPVRStream() override; + +private: + bool m_bDemuxActive; +}; diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRRecording.cpp b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRRecording.cpp new file mode 100644 index 0000000000000..221acff7987db --- /dev/null +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRRecording.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2012-2013 Team XBMC + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * . + * + */ + +#include "InputStreamPVRRecording.h" + +#include "addons/PVRClient.h" +#include "utils/log.h" + +CInputStreamPVRRecording::CInputStreamPVRRecording(IVideoPlayer* pPlayer, const CFileItem& fileitem) + : CInputStreamPVRBase(pPlayer, fileitem) +{ +} + +CInputStreamPVRRecording::~CInputStreamPVRRecording() +{ + Close(); +} + +bool CInputStreamPVRRecording::OpenPVRStream() +{ + if (m_client && (m_client->OpenRecordedStream(m_item.GetPVRRecordingInfoTag()) == PVR_ERROR_NO_ERROR)) + { + CLog::Log(LOGDEBUG, "CInputStreamPVRRecording - %s - opened recording stream %s", __FUNCTION__, m_item.GetPath().c_str()); + return true; + } + return false; +} + +void CInputStreamPVRRecording::ClosePVRStream() +{ + if (m_client && (m_client->CloseRecordedStream() == PVR_ERROR_NO_ERROR)) + { + CLog::Log(LOGDEBUG, "CInputStreamPVRRecording - %s - closed recording stream %s", __FUNCTION__, m_item.GetPath().c_str()); + } +} + +int CInputStreamPVRRecording::ReadPVRStream(uint8_t* buf, int buf_size) +{ + int iRead = -1; + + if (m_client) + m_client->ReadRecordedStream(buf, buf_size, iRead); + + return iRead; +} + +int64_t CInputStreamPVRRecording::SeekPVRStream(int64_t offset, int whence) +{ + int64_t ret = -1; + + if (m_client) + m_client->SeekRecordedStream(offset, whence, ret); + + return ret; +} + +int64_t CInputStreamPVRRecording::GetPVRStreamLength() +{ + int64_t ret = -1; + + if (m_client) + m_client->GetRecordedStreamLength(ret); + + return ret; +} + +CDVDInputStream::ENextStream CInputStreamPVRRecording::NextPVRStream() +{ + return NEXTSTREAM_NONE; +} + +bool CInputStreamPVRRecording::CanPausePVRStream() +{ + return true; +} + +bool CInputStreamPVRRecording::CanSeekPVRStream() +{ + return true; +} diff --git a/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRRecording.h b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRRecording.h new file mode 100644 index 0000000000000..871893ba85ec4 --- /dev/null +++ b/xbmc/cores/VideoPlayer/DVDInputStreams/InputStreamPVRRecording.h @@ -0,0 +1,40 @@ +#pragma once + +/* + * Copyright (C) 2012-2013 Team XBMC + * http://kodi.tv + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * . + * + */ + +#include "InputStreamPVRBase.h" + +class CInputStreamPVRRecording : public CInputStreamPVRBase +{ +public: + CInputStreamPVRRecording(IVideoPlayer* pPlayer, const CFileItem& fileitem); + ~CInputStreamPVRRecording() override; + +protected: + bool OpenPVRStream() override; + void ClosePVRStream() override; + int ReadPVRStream(uint8_t* buf, int buf_size) override; + int64_t SeekPVRStream(int64_t offset, int whence) override; + int64_t GetPVRStreamLength() override; + ENextStream NextPVRStream() override; + bool CanPausePVRStream() override; + bool CanSeekPVRStream() override; +}; diff --git a/xbmc/cores/VideoPlayer/VideoPlayer.cpp b/xbmc/cores/VideoPlayer/VideoPlayer.cpp index 6082602ae5b7f..c10da08c95950 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayer.cpp +++ b/xbmc/cores/VideoPlayer/VideoPlayer.cpp @@ -28,7 +28,7 @@ #if defined(HAVE_LIBBLURAY) #include "DVDInputStreams/DVDInputStreamBluray.h" #endif -#include "DVDInputStreams/DVDInputStreamPVRManager.h" +#include "DVDInputStreams/InputStreamPVRBase.h" #include "DVDDemuxers/DVDDemux.h" #include "DVDDemuxers/DVDDemuxUtils.h" @@ -87,7 +87,6 @@ #include -using namespace PVR; using namespace KODI::MESSAGING; //------------------------------------------------------------------------------ @@ -2884,8 +2883,8 @@ void CVideoPlayer::HandleMessages() if (m_pInputStream->IsStreamType(DVDSTREAM_TYPE_PVRMANAGER) && speed != m_playSpeed) { - std::shared_ptr pvrinputstream = std::static_pointer_cast(m_pInputStream); - pvrinputstream->Pause( speed == 0 ); + std::shared_ptr pvrinputstream = std::static_pointer_cast(m_pInputStream); + pvrinputstream->Pause(speed == 0); } // do a seek after rewind, clock is not in sync with current pts diff --git a/xbmc/pvr/PVRGUIActions.cpp b/xbmc/pvr/PVRGUIActions.cpp index c14238feb3ae6..9c5c2133aac04 100644 --- a/xbmc/pvr/PVRGUIActions.cpp +++ b/xbmc/pvr/PVRGUIActions.cpp @@ -1464,7 +1464,7 @@ namespace PVR } if (iClientID < 0) - iClientID = CServiceBroker::GetPVRManager().Clients()->GetPlayingClientID(); + iClientID = CServiceBroker::GetPVRManager().GetPlayingClientID(); CPVRClientPtr client; if (CServiceBroker::GetPVRManager().Clients()->GetCreatedClient(iClientID, client) && client->HasMenuHooks(menuCategory)) diff --git a/xbmc/pvr/PVRGUIInfo.cpp b/xbmc/pvr/PVRGUIInfo.cpp index eda15518ef875..7f14a2088429d 100644 --- a/xbmc/pvr/PVRGUIInfo.cpp +++ b/xbmc/pvr/PVRGUIInfo.cpp @@ -216,13 +216,19 @@ void CPVRGUIInfo::UpdateQualityData(void) PVR_SIGNAL_STATUS qualityInfo; ClearQualityInfo(qualityInfo); - CPVRClientPtr client; - bool bIsPlayingRecording = false; - if (CServiceBroker::GetSettings().GetBool(CSettings::SETTING_PVRPLAYBACK_SIGNALQUALITY) && - CServiceBroker::GetPVRManager().Clients()->GetPlayingClient(client, bIsPlayingRecording) && - client && !bIsPlayingRecording && - client->SignalQuality(qualityInfo) == PVR_ERROR_NO_ERROR) - m_qualityInfo = qualityInfo; + if (CServiceBroker::GetSettings().GetBool(CSettings::SETTING_PVRPLAYBACK_SIGNALQUALITY)) + { + bool bIsPlayingRecording = CServiceBroker::GetPVRManager().IsPlayingRecording(); + if (!bIsPlayingRecording) + { + CPVRClientPtr client; + CServiceBroker::GetPVRManager().Clients()->GetCreatedClient(CServiceBroker::GetPVRManager().GetPlayingClientID(), client); + if (client && client->SignalQuality(qualityInfo) == PVR_ERROR_NO_ERROR) + { + m_qualityInfo = qualityInfo; + } + } + } } void CPVRGUIInfo::UpdateDescrambleData(void) @@ -230,19 +236,23 @@ void CPVRGUIInfo::UpdateDescrambleData(void) PVR_DESCRAMBLE_INFO descrambleInfo; ClearDescrambleInfo(descrambleInfo); - CPVRClientPtr client; - bool bIsPlayingRecording = false; - if (CServiceBroker::GetPVRManager().Clients()->GetPlayingClient(client, bIsPlayingRecording) && - client && !bIsPlayingRecording && - client->GetDescrambleInfo(descrambleInfo) == PVR_ERROR_NO_ERROR) - m_descrambleInfo = descrambleInfo; + bool bIsPlayingRecording = CServiceBroker::GetPVRManager().IsPlayingRecording(); + if (!bIsPlayingRecording) + { + CPVRClientPtr client; + CServiceBroker::GetPVRManager().Clients()->GetCreatedClient(CServiceBroker::GetPVRManager().GetPlayingClientID(), client); + if (client && client->GetDescrambleInfo(descrambleInfo) == PVR_ERROR_NO_ERROR) + { + m_descrambleInfo = descrambleInfo; + } + } } void CPVRGUIInfo::UpdateMisc(void) { bool bStarted = CServiceBroker::GetPVRManager().IsStarted(); /* safe to fetch these unlocked, since they're updated from the same thread as this one */ - std::string strPlayingClientName = bStarted ? CServiceBroker::GetPVRManager().Clients()->GetPlayingClientName() : ""; + std::string strPlayingClientName = bStarted ? CServiceBroker::GetPVRManager().GetPlayingClientName() : ""; bool bHasTVRecordings = bStarted && CServiceBroker::GetPVRManager().Recordings()->GetNumTVRecordings() > 0; bool bHasRadioRecordings = bStarted && CServiceBroker::GetPVRManager().Recordings()->GetNumRadioRecordings() > 0; bool bIsPlayingTV = bStarted && CServiceBroker::GetPVRManager().IsPlayingTV(); @@ -294,7 +304,7 @@ void CPVRGUIInfo::UpdateTimeshift(void) return; } - bool bIsTimeshifting = CServiceBroker::GetPVRManager().Clients()->IsTimeshifting(); + bool bIsTimeshifting = CServiceBroker::GetPVRManager().IsTimeshifting(); time_t now = std::time(nullptr); time_t iStartTime = CServiceBroker::GetDataCacheCore().GetStartTime(); time_t iPlayTime = CServiceBroker::GetDataCacheCore().GetPlayTime() / 1000; diff --git a/xbmc/pvr/PVRManager.cpp b/xbmc/pvr/PVRManager.cpp index a5821c6cad2d1..eddc3808b46b4 100644 --- a/xbmc/pvr/PVRManager.cpp +++ b/xbmc/pvr/PVRManager.cpp @@ -147,7 +147,8 @@ CPVRManager::CPVRManager(void) : CSettings::SETTING_PVRPOWERMANAGEMENT_SETWAKEUPCMD, CSettings::SETTING_PVRPARENTAL_ENABLED, CSettings::SETTING_PVRPARENTAL_DURATION - }) + }), + m_playingClientId(-1) { CAnnouncementManager::GetInstance().AddAnnouncer(this); } @@ -205,6 +206,21 @@ CPVRClientsPtr CPVRManager::Clients(void) const return m_addons; } +bool CPVRManager::GetClient(const CFileItem &item, CPVRClientPtr &client) const +{ + int iClientID = PVR_INVALID_CLIENT_ID; + + if (item.HasPVRChannelInfoTag()) + iClientID = item.GetPVRChannelInfoTag()->ClientID(); + else if (item.HasPVRRecordingInfoTag()) + iClientID = item.GetPVRRecordingInfoTag()->m_iClientId; + + if (iClientID != PVR_INVALID_CLIENT_ID) + return m_addons->GetCreatedClient(iClientID, client); + + return false; +} + CPVRGUIActionsPtr CPVRManager::GUIActions(void) const { // note: m_guiActions is const (only set/reset in ctor/dtor). no need for a lock here. @@ -642,12 +658,34 @@ CPVREpgInfoTagPtr CPVRManager::GetPlayingEpgTag(void) const return m_playingEpgTag; } +std::string CPVRManager::GetPlayingClientName(void) const +{ + return m_strPlayingClientName; +} + +int CPVRManager::GetPlayingClientID(void) const +{ + return m_playingClientId; +} + bool CPVRManager::IsRecordingOnPlayingChannel(void) const { const CPVRChannelPtr currentChannel = GetPlayingChannel(); return currentChannel && currentChannel->IsRecording(); } +bool CPVRManager::IsTimeshifting(void) const +{ + bool bTimeshifting = false; + if (m_playingChannel) + { + CPVRClientPtr client; + if (m_addons->GetCreatedClient(m_playingChannel->ClientID(), client) && client) + client->IsTimeshifting(bTimeshifting); + } + return bTimeshifting; +} + bool CPVRManager::CanRecordOnPlayingChannel(void) const { const CPVRChannelPtr currentChannel = GetPlayingChannel(); @@ -718,55 +756,45 @@ CPVRChannelGroupPtr CPVRManager::GetPlayingGroup(bool bRadio /* = false */) return CPVRChannelGroupPtr(); } -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 - const CPVRChannelPtr channel = fileItem.GetPVRChannelInfoTag(); - if (!IsParentalLocked(channel)) - bReturn = m_addons->OpenStream(channel); - - return bReturn; -} - -bool CPVRManager::OpenRecordedStream(const CPVRRecordingPtr &recording) -{ - return m_addons->OpenStream(recording); -} - -void CPVRManager::CloseStream(void) -{ - m_addons->CloseStream(); -} - void CPVRManager::OnPlaybackStarted(const CFileItemPtr item) { m_playingChannel.reset(); m_playingRecording.reset(); m_playingEpgTag.reset(); + m_playingClientId = -1; + m_strPlayingClientName.clear(); if (item->HasPVRChannelInfoTag()) { const CPVRChannelPtr channel(item->GetPVRChannelInfoTag()); m_playingChannel = channel; + m_playingClientId = m_playingChannel->ClientID(); + + CPVRClientPtr client; + if (m_addons->GetCreatedClient(m_playingClientId, client) && client) + m_strPlayingClientName = client->GetFriendlyName(); + SetPlayingGroup(channel); UpdateLastWatched(channel); } else if (item->HasPVRRecordingInfoTag()) { m_playingRecording = item->GetPVRRecordingInfoTag(); + m_playingClientId = m_playingRecording->m_iClientId; + + CPVRClientPtr client; + if (m_addons->GetCreatedClient(m_playingClientId, client) && client) + m_strPlayingClientName = client->GetFriendlyName(); } else if (item->HasEPGInfoTag()) { m_playingEpgTag = item->GetEPGInfoTag(); + m_playingClientId = m_playingEpgTag->ClientID(); + + CPVRClientPtr client; + if (m_addons->GetCreatedClient(m_playingClientId, client) && client) + m_strPlayingClientName = client->GetFriendlyName(); } m_guiActions->OnPlaybackStarted(item); @@ -780,14 +808,20 @@ void CPVRManager::OnPlaybackStopped(const CFileItemPtr item) { UpdateLastWatched(item->GetPVRChannelInfoTag()); m_playingChannel.reset(); + m_playingClientId = -1; + m_strPlayingClientName.clear(); } else if (item->HasPVRRecordingInfoTag() && item->GetPVRRecordingInfoTag() == m_playingRecording) { m_playingRecording.reset(); + m_playingClientId = -1; + m_strPlayingClientName.clear(); } else if (item->HasEPGInfoTag() && item->GetEPGInfoTag() == m_playingEpgTag) { m_playingEpgTag.reset(); + m_playingClientId = -1; + m_strPlayingClientName.clear(); } m_guiActions->OnPlaybackStopped(item); diff --git a/xbmc/pvr/PVRManager.h b/xbmc/pvr/PVRManager.h index ba89c99b60d81..8c7fb87deb948 100644 --- a/xbmc/pvr/PVRManager.h +++ b/xbmc/pvr/PVRManager.h @@ -108,6 +108,14 @@ namespace PVR */ CPVRClientsPtr Clients(void) const; + /*! + * @brief Get the instance of a client that matches the given item. + * @param item The item containing a PVR recording or a PVR channel. + * @param client will be filled with requested client on success, null otherwise. + * @return True on success, false otherwise. + */ + bool GetClient(const CFileItem &item, std::shared_ptr &client) const; + /*! * @brief Get access to the pvr gui actions. * @return The gui actions. @@ -188,6 +196,12 @@ namespace PVR */ bool IsPlayingEpgTag(const CPVREpgInfoTagPtr &epgTag) const; + /*! + * @brief Check whether the currently playing livetv stream is timeshifted. + * @return True if there is a playing stream and if it is timeshifted, false otherwise. + */ + bool IsTimeshifting() const; + /*! * @return True while the PVRManager is initialising. */ @@ -241,6 +255,18 @@ namespace PVR */ CPVREpgInfoTagPtr GetPlayingEpgTag(void) const; + /*! + * @brief Get the name of the playing client, if there is one. + * @return The name of the client or an empty string if nothing is playing. + */ + std::string GetPlayingClientName(void) const; + + /*! + * @brief Get the ID of the playing client, if there is one. + * @return The ID or -1 if no client is playing. + */ + int GetPlayingClientID(void) const; + /*! * @brief Check whether there is an active recording on the currenlyt playing channel. * @return True if there is a playing channel and there is an active recording on that channel, false otherwise. @@ -282,25 +308,6 @@ namespace PVR */ void OnPlaybackEnded(const CFileItemPtr item); - /*! - * @brief Close an open PVR stream. - */ - void CloseStream(void); - - /*! - * @brief Open a stream from the given channel. - * @param fileItem The file item with the channel to open. - * @return True if the stream was opened, false otherwise. - */ - bool OpenLiveStream(const CFileItem &fileItem); - - /*! - * @brief Open a stream from the given recording. - * @param tag The recording to open. - * @return True if the stream was opened, false otherwise. - */ - bool OpenRecordedStream(const CPVRRecordingPtr &tag); - /*! * @brief Check whether there are active recordings. * @return True if there are active recordings, false otherwise. @@ -536,5 +543,7 @@ namespace PVR CPVRChannelPtr m_playingChannel; CPVRRecordingPtr m_playingRecording; CPVREpgInfoTagPtr m_playingEpgTag; + std::string m_strPlayingClientName; + int m_playingClientId; }; } diff --git a/xbmc/pvr/addons/PVRClients.cpp b/xbmc/pvr/addons/PVRClients.cpp index 76e1d5da4ca38..1f314543c6268 100644 --- a/xbmc/pvr/addons/PVRClients.cpp +++ b/xbmc/pvr/addons/PVRClients.cpp @@ -56,8 +56,6 @@ namespace } // unnamed namespace CPVRClients::CPVRClients(void) -: m_playingClientId(-EINVAL), - m_bIsPlayingRecording(false) { CServiceBroker::GetAddonMgr().RegisterAddonMgrCallback(ADDON_PVRDLL, this); CServiceBroker::GetAddonMgr().Events().Subscribe(this, &CPVRClients::OnAddonEvent); @@ -217,10 +215,6 @@ bool CPVRClients::RequestRestart(AddonPtr addon, bool bDataChanged) bool CPVRClients::StopClient(const AddonPtr &addon, bool bRestart) { - /* stop playback if needed */ - if (IsPlaying()) - CApplicationMessenger::GetInstance().SendMsg(TMSG_MEDIA_STOP); - CSingleLock lock(m_critSection); int iId = GetClientId(addon->ID()); @@ -468,40 +462,6 @@ std::string CPVRClients::GetClientAddonId(int iClientId) const return GetClient(iClientId, client) ? client->ID() : ""; } -//////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// playing client access -//////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -bool CPVRClients::IsPlaying(void) const -{ - CSingleLock lock(m_critSection); - return m_playingClientId != -EINVAL; -} - -bool CPVRClients::GetPlayingClient(CPVRClientPtr &client) const -{ - return GetCreatedClient(m_playingClientId, client); -} - -bool CPVRClients::GetPlayingClient(CPVRClientPtr &client, bool &bPlayingRecording) const -{ - CSingleLock lock(m_critSection); - bPlayingRecording = m_bIsPlayingRecording; - return GetCreatedClient(m_playingClientId, client); -} - -int CPVRClients::GetPlayingClientID(void) const -{ - CSingleLock lock(m_critSection); - return m_playingClientId; -} - -const std::string CPVRClients::GetPlayingClientName(void) const -{ - CSingleLock lock(m_critSection); - return m_strPlayingClientName; -} - //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // client API calls //////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -559,170 +519,6 @@ std::string CPVRClients::GetBackendHostnameByClientId(int iClientId) const return name; } -int CPVRClients::GetStreamReadChunkSize(const CFileItem &item) -{ - int iChunkSize = 0; - int iClientID = PVR_INVALID_CLIENT_ID; - - if (item.HasPVRChannelInfoTag()) - iClientID = item.GetPVRChannelInfoTag()->ClientID(); - else if (item.HasPVRRecordingInfoTag()) - iClientID = item.GetPVRRecordingInfoTag()->m_iClientId; - - if (iClientID != PVR_INVALID_CLIENT_ID) - { - ForCreatedClient(__FUNCTION__, iClientID, [&iChunkSize](const CPVRClientPtr &client) { - return client->GetStreamReadChunkSize(iChunkSize); - }); - } - - return iChunkSize; -} - -bool CPVRClients::OpenStream(const CPVRChannelPtr &channel) -{ - CloseStream(); - - /* try to open the stream on the client */ - PVR_ERROR error = ForCreatedClient(__FUNCTION__, channel->ClientID(), [&channel](const CPVRClientPtr &client) { - return client->OpenLiveStream(channel); - }); - - if (error == PVR_ERROR_NO_ERROR) - { - CSingleLock lock(m_critSection); - m_playingClientId = channel->ClientID(); - m_bIsPlayingRecording = false; - - CPVRClientPtr client; - if (GetCreatedClient(channel->ClientID(), client)) - m_strPlayingClientName = client->GetFriendlyName(); - - return true; - } - - return false; -} - -bool CPVRClients::OpenStream(const CPVRRecordingPtr &recording) -{ - CloseStream(); - - /* try to open the recording stream on the client */ - PVR_ERROR error = ForCreatedClient(__FUNCTION__, recording->ClientID(), [&recording](const CPVRClientPtr &client) { - return client->OpenRecordedStream(recording); - }); - - if (error == PVR_ERROR_NO_ERROR) - { - CSingleLock lock(m_critSection); - m_playingClientId = recording->ClientID(); - m_bIsPlayingRecording = true; - - CPVRClientPtr client; - if (GetCreatedClient(recording->ClientID(), client)) - m_strPlayingClientName = client->GetFriendlyName(); - - return true; -} - - return false; -} - -void CPVRClients::CloseStream(void) -{ - PVR_ERROR error = ForPlayingClient(__FUNCTION__, [this](const CPVRClientPtr &client) { - if (m_bIsPlayingRecording) - return client->CloseRecordedStream(); - else - return client->CloseLiveStream(); - }); - - if (error == PVR_ERROR_NO_ERROR) - { - CSingleLock lock(m_critSection); - m_playingClientId = -EINVAL; - m_bIsPlayingRecording = false; - } -} - -int CPVRClients::ReadStream(void* lpBuf, int64_t uiBufSize) -{ - int iRead = -EINVAL; - ForPlayingClient(__FUNCTION__, [this, &lpBuf, uiBufSize, &iRead](const CPVRClientPtr &client) { - if (m_bIsPlayingRecording) - return client->ReadRecordedStream(lpBuf, uiBufSize, iRead); - else - return client->ReadLiveStream(lpBuf, uiBufSize, iRead); - }); - return iRead; -} - -int64_t CPVRClients::GetStreamLength(void) -{ - int64_t iLength = -EINVAL; - ForPlayingClient(__FUNCTION__, [this, &iLength](const CPVRClientPtr &client) { - if (m_bIsPlayingRecording) - return client->GetRecordedStreamLength(iLength); - else - return client->GetLiveStreamLength(iLength); - }); - return iLength; -} - -bool CPVRClients::CanSeekStream(void) const -{ - bool bCanSeek; - { - CSingleLock lock(m_critSection); - bCanSeek = m_bIsPlayingRecording; - } - - if (!bCanSeek) - { - ForPlayingClient(__FUNCTION__, [&bCanSeek](const CPVRClientPtr &client) { - return client->CanSeekStream(bCanSeek); - }); - } - return bCanSeek; -} - -int64_t CPVRClients::SeekStream(int64_t iFilePosition, int iWhence/* = SEEK_SET*/) -{ - int64_t iPos = -EINVAL; - ForPlayingClient(__FUNCTION__, [this, iFilePosition, iWhence, &iPos](const CPVRClientPtr &client) { - if (m_bIsPlayingRecording) - return client->SeekRecordedStream(iFilePosition, iWhence, iPos); - else - return client->SeekLiveStream(iFilePosition, iWhence, iPos); - }); - return iPos; -} - -bool CPVRClients::CanPauseStream(void) const -{ - bool bCanPause; - { - CSingleLock lock(m_critSection); - bCanPause = m_bIsPlayingRecording; - } - - if (!bCanPause) - { - ForPlayingClient(__FUNCTION__, [&bCanPause](const CPVRClientPtr &client) { - return client->CanPauseStream(bCanPause); - }); - } - return bCanPause; -} - -void CPVRClients::PauseStream(bool bPaused) -{ - ForPlayingClient(__FUNCTION__, [bPaused](const CPVRClientPtr &client) { - return client->PauseStream(bPaused); - }); -} - bool CPVRClients::FillChannelStreamFileItem(CFileItem &fileItem) { return ForCreatedClient(__FUNCTION__, fileItem.GetPVRChannelInfoTag()->ClientID(), [&fileItem](const CPVRClientPtr &client) { @@ -744,31 +540,6 @@ bool CPVRClients::FillEpgTagStreamFileItem(CFileItem &fileItem) }) == PVR_ERROR_NO_ERROR; } -bool CPVRClients::IsTimeshifting(void) const -{ - bool bTimeshifting = false; - ForPlayingClient(__FUNCTION__, [&bTimeshifting](const CPVRClientPtr &client) { - return client->IsTimeshifting(bTimeshifting); - }); - return bTimeshifting; -} - -bool CPVRClients::GetStreamTimes(PVR_STREAM_TIMES *times) const -{ - return ForPlayingClient(__FUNCTION__, [×](const CPVRClientPtr &client) { - return client->GetStreamTimes(times); - }) == PVR_ERROR_NO_ERROR; -} - -bool CPVRClients::IsRealTimeStream(void) const -{ - bool bRealTime = false; - ForPlayingClient(__FUNCTION__, [&bRealTime](const CPVRClientPtr &client) { - return client->IsRealTimeStream(bRealTime); - }); - return bRealTime; -} - bool CPVRClients::SupportsTimers() const { bool bReturn = false; @@ -1014,9 +785,6 @@ PVR_ERROR CPVRClients::OpenDialogChannelSettings(const CPVRChannelPtr &channel) bool CPVRClients::HasMenuHooks(int iClientID, PVR_MENUHOOK_CAT cat) { - if (iClientID < 0) - iClientID = GetPlayingClientID(); - bool bHasMenuHooks = false; ForCreatedClient(__FUNCTION__, iClientID, [cat, &bHasMenuHooks](const CPVRClientPtr &client) { bHasMenuHooks = client->HasMenuHooks(cat); @@ -1178,22 +946,3 @@ PVR_ERROR CPVRClients::ForCreatedClient(const char* strFunctionName, int iClient } return error; } - -PVR_ERROR CPVRClients::ForPlayingClient(const char* strFunctionName, PVRClientFunction function) const -{ - PVR_ERROR error = PVR_ERROR_UNKNOWN; - - if (!IsPlaying()) - return PVR_ERROR_REJECTED; - - CPVRClientPtr client; - if (GetPlayingClient(client)) - { - error = function(client); - - if (error != PVR_ERROR_NO_ERROR && error != PVR_ERROR_NOT_IMPLEMENTED) - CLog::Log(LOGERROR, "CPVRClients - %s - playing client '%s' returned an error: %s", - strFunctionName, client->GetFriendlyName().c_str(), CPVRClient::ToString(error)); - } - return error; -} diff --git a/xbmc/pvr/addons/PVRClients.h b/xbmc/pvr/addons/PVRClients.h index debba3204bf91..c7e349e454803 100644 --- a/xbmc/pvr/addons/PVRClients.h +++ b/xbmc/pvr/addons/PVRClients.h @@ -200,33 +200,6 @@ namespace PVR */ std::string GetClientAddonId(int iClientId) const; - /*! - * @brief Get the instance of the playing client, if there is one. - * @param client Will be filled with requested client on success, null otherwise. - * @return True on success, false otherwise. - */ - bool GetPlayingClient(CPVRClientPtr &client) const; - - /*! - * @brief Get the instance of the playing client, if there is one. - * @param client Will be filled with requested client on success, null otherwise. - * @param bPlayingRecording is set to true if the client is currently playing a recording, false otherwise. - * @return True on success, false otherwise. - */ - bool GetPlayingClient(CPVRClientPtr &client, bool &bPlayingRecording) const; - - /*! - * @brief Get the ID of the playing client, if there is one. - * @return The ID or -1 if no client is playing. - */ - int GetPlayingClientID(void) const; - - /*! - * @brief Get the name of the playing client, if there is one. - * @return The name of the client or an empty string if nothing is playing. - */ - const std::string GetPlayingClientName(void) const; - /*! @name general methods */ //@{ @@ -254,71 +227,6 @@ namespace PVR /*! @name stream methods */ //@{ - /*! - * @brief Open a stream on the given channel. - * @param channel The channel to start playing. - * @return True if the stream was opened successfully, false otherwise. - */ - bool OpenStream(const CPVRChannelPtr &channel); - - /*! - * @brief Open a stream from the given recording. - * @param recording The recording to start playing. - * @return True if the stream was opened successfully, false otherwise. - */ - bool OpenStream(const CPVRRecordingPtr &recording); - - /*! - * @brief Close the stream on the currently playing client, if any. - */ - void CloseStream(void); - - /*! - * @brief Return the read chunk size to use when playing a stream. - * @param item The item providing the stream (channel or recording). - * @return The chunk size in bytes or 0 in case of an error. - */ - int GetStreamReadChunkSize(const CFileItem &item); - - /*! - * @brief Read from an open stream. - * @param lpBuf Target buffer. - * @param uiBufSize The size of the buffer. - * @return The amount of bytes that was added or -1 in case of an error. - */ - int ReadStream(void* lpBuf, int64_t uiBufSize); - - /*! - * @brief Return the filesize of the currently playing stream. - * @return The size of the stream or -1 in case of an error. - */ - int64_t GetStreamLength(void); - - /*! - * @brief Check whether it is possible to seek the currently playing livetv or recording stream - */ - bool CanSeekStream(void) const; - - /*! - * @brief Seek to a position in a stream. - * @param iFilePosition The position to seek to. - * @param iWhence Specify how to seek ("new position=pos", "new position=pos+actual position" or "new position=filesize-pos") - * @return The new stream position or -1 in case of an error. - */ - int64_t SeekStream(int64_t iFilePosition, int iWhence = SEEK_SET); - - /*! - * @brief Check whether it is possible to pause the currently playing livetv or recording stream - * @return True if there is a playing channel and if it can be paused, false otherwise. - */ - bool CanPauseStream(void) const; - - /*! - * @brief Pause/Continue a stream. - * @param bPaused If true, pause the stream, unpause otherwise. - */ - void PauseStream(bool bPaused); - /*! * @brief Fill the file item for a channel with the properties required for playback. Values are obtained from the PVR backend. * @param fileItem The file item to be filled. @@ -333,25 +241,6 @@ namespace PVR */ bool FillRecordingStreamFileItem(CFileItem &fileItem); - /*! - * @brief Check whether the currently playing livetv stream is timeshifted. - * @return True if there is a playing stream and if it is timeshifted, false otherwise. - */ - bool IsTimeshifting() const; - - /*! - * @brief Get timing data for the currently playing stream. - * @param times The struct the client has to fill with data. - * @return True, if the data were fetched successfully, false itherwise. - */ - bool GetStreamTimes(PVR_STREAM_TIMES *times) const; - - /*! - * @brief Check if the currently playing stream is a realtime stream. - * @return True if there is a playing stream and if it is realtime, false otherwise. - */ - bool IsRealTimeStream() const; - //@} /*! @name Timer methods */ @@ -719,24 +608,7 @@ namespace PVR */ PVR_ERROR ForCreatedClient(const char* strFunctionName, int iClientId, PVRClientFunction function) const; - /*! - * @brief Wraps a call to the playing client, if any, in order to do common pre and post function invocation actions. - * @param strFunctionName The function name, for logging purposes. - * @param function The function to wrap. It has to have return type PVR_ERROR and must take a const reference to a CPVRClientPtr as parameter. - * @return PVR_ERROR_NO_ERROR on success, PVR_ERROR_REJECTED if there is no playing client, any other PVR_ERROR_* value otherwise. - */ - PVR_ERROR ForPlayingClient(const char* strFunctionName, PVRClientFunction function) const; - - /*! - * @brief Check if a client is currently playing a stream. - * @return True if a stream (TV/radio channel, recording) is playing, false otherwise. - */ - bool IsPlaying(void) const; - - int m_playingClientId; /*!< the ID of the client that is currently playing */ - bool m_bIsPlayingRecording; - std::string m_strPlayingClientName; /*!< the name client that is currently playing a stream or an empty string if nothing is playing */ - CPVRClientMap m_clientMap; /*!< a map of all known clients */ - CCriticalSection m_critSection; + CCriticalSection m_critSection; + CPVRClientMap m_clientMap; }; } diff --git a/xbmc/pvr/epg/EpgInfoTag.cpp b/xbmc/pvr/epg/EpgInfoTag.cpp index 7f4cd8da0b285..67e4934572de2 100644 --- a/xbmc/pvr/epg/EpgInfoTag.cpp +++ b/xbmc/pvr/epg/EpgInfoTag.cpp @@ -223,7 +223,7 @@ void CPVREpgInfoTag::Serialize(CVariant &value) const CDateTime CPVREpgInfoTag::GetCurrentPlayingTime() const { if (CServiceBroker::GetPVRManager().GetPlayingChannel() == Channel() && - CServiceBroker::GetPVRManager().Clients()->IsTimeshifting()) + CServiceBroker::GetPVRManager().IsTimeshifting()) { // timeshifting; start time valid? time_t startTime = CServiceBroker::GetDataCacheCore().GetStartTime();