Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PVR] Separate TV and Radio recordings #9319

Merged
merged 2 commits into from Mar 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 20 additions & 6 deletions xbmc/dialogs/GUIDialogMediaSource.cpp
Expand Up @@ -253,6 +253,20 @@ void CGUIDialogMediaSource::OnPathBrowse(int item)
share1.m_ignore = true;
extraShares.push_back(share1);

// add the recordings dir as needed
if (CPVRDirectory::HasRadioRecordings())
{
share1.strPath = PVR::CPVRRecordingsPath::PATH_ACTIVE_RADIO_RECORDINGS;
share1.strName = g_localizeStrings.Get(19017); // Recordings
extraShares.push_back(share1);
}
if (CPVRDirectory::HasDeletedRadioRecordings())
{
share1.strPath = PVR::CPVRRecordingsPath::PATH_DELETED_RADIO_RECORDINGS;
share1.strName = g_localizeStrings.Get(19184); // Deleted recordings
extraShares.push_back(share1);
}

if (CSettings::GetInstance().GetString(CSettings::SETTING_AUDIOCDS_RECORDINGPATH) != "")
{
share1.strPath = "special://recordings/";
Expand Down Expand Up @@ -282,16 +296,16 @@ void CGUIDialogMediaSource::OnPathBrowse(int item)
extraShares.push_back(share1);

// add the recordings dir as needed
if (CPVRDirectory::HasRecordings())
if (CPVRDirectory::HasTVRecordings())
{
share1.strPath = PVR::CPVRRecordingsPath::PATH_ACTIVE_RECORDINGS;
share1.strName = g_localizeStrings.Get(19017); // TV Recordings
share1.strPath = PVR::CPVRRecordingsPath::PATH_ACTIVE_TV_RECORDINGS;
share1.strName = g_localizeStrings.Get(19017); // Recordings
extraShares.push_back(share1);
}
if (CPVRDirectory::HasDeletedRecordings())
if (CPVRDirectory::HasDeletedTVRecordings())
{
share1.strPath = PVR::CPVRRecordingsPath::PATH_DELETED_RECORDINGS;
share1.strName = g_localizeStrings.Get(19108); // Deleted TV Recordings
share1.strPath = PVR::CPVRRecordingsPath::PATH_DELETED_TV_RECORDINGS;
share1.strName = g_localizeStrings.Get(19184); // Deleted recordings
extraShares.push_back(share1);
}
}
Expand Down
22 changes: 17 additions & 5 deletions xbmc/filesystem/PVRDirectory.cpp
Expand Up @@ -122,14 +122,26 @@ bool CPVRDirectory::IsLiveTV(const std::string& strPath)
return URIUtils::IsLiveTV(filename);
}

bool CPVRDirectory::HasRecordings()
bool CPVRDirectory::HasTVRecordings()
{
return g_PVRManager.IsStarted() ?
g_PVRRecordings->GetNumRecordings() > 0 : false;
return g_PVRManager.IsStarted() ?
g_PVRRecordings->GetNumTVRecordings() > 0 : false;
}

bool CPVRDirectory::HasDeletedTVRecordings()
{
return g_PVRManager.IsStarted() ?
g_PVRRecordings->HasDeletedTVRecordings() : false;
}

bool CPVRDirectory::HasRadioRecordings()
{
return g_PVRManager.IsStarted() ?
g_PVRRecordings->GetNumRadioRecordings() > 0 : false;
}

bool CPVRDirectory::HasDeletedRecordings()
bool CPVRDirectory::HasDeletedRadioRecordings()
{
return g_PVRManager.IsStarted() ?
g_PVRRecordings->HasDeletedRecordings() : false;
g_PVRRecordings->HasDeletedRadioRecordings() : false;
}
6 changes: 4 additions & 2 deletions xbmc/filesystem/PVRDirectory.h
Expand Up @@ -37,8 +37,10 @@ class CPVRDirectory

static bool SupportsWriteFileOperations(const std::string& strPath);
static bool IsLiveTV(const std::string& strPath);
static bool HasRecordings();
static bool HasDeletedRecordings();
static bool HasTVRecordings();
static bool HasDeletedTVRecordings();
static bool HasRadioRecordings();
static bool HasDeletedRadioRecordings();

virtual bool Exists(const CURL& url);

Expand Down
9 changes: 6 additions & 3 deletions xbmc/pvr/PVRGUIInfo.cpp
Expand Up @@ -64,7 +64,8 @@ void CPVRGUIInfo::ResetProperties(void)
m_strNextRecordingChannelIcon .clear();
m_strNextRecordingTime .clear();
m_iTimerAmount = 0;
m_bHasRecordings = false;
m_bHasTVRecordings = false;
m_bHasRadioRecordings = false;
m_iRecordingTimerAmount = 0;
m_iCurrentActiveClient = 0;
m_strPlayingClientName .clear();
Expand Down Expand Up @@ -265,7 +266,8 @@ void CPVRGUIInfo::UpdateMisc(void)
{
bool bStarted = g_PVRManager.IsStarted();
std::string strPlayingClientName = bStarted ? g_PVRClients->GetPlayingClientName() : "";
bool bHasRecordings = bStarted && g_PVRRecordings->GetNumRecordings() > 0;
bool bHasTVRecordings = bStarted && g_PVRRecordings->GetNumTVRecordings() > 0;
bool bHasRadioRecordings = bStarted && g_PVRRecordings->GetNumRadioRecordings() > 0;
bool bIsPlayingTV = bStarted && g_PVRClients->IsPlayingTV();
bool bIsPlayingRadio = bStarted && g_PVRClients->IsPlayingRadio();
bool bIsPlayingRecording = bStarted && g_PVRClients->IsPlayingRecording();
Expand All @@ -279,7 +281,8 @@ void CPVRGUIInfo::UpdateMisc(void)

CSingleLock lock(m_critSection);
m_strPlayingClientName = strPlayingClientName;
m_bHasRecordings = bHasRecordings;
m_bHasTVRecordings = bHasTVRecordings;
m_bHasRadioRecordings = bHasRadioRecordings;
m_bHasNonRecordingTimers = bHasNonRecordingTimers;
m_bIsPlayingTV = bIsPlayingTV;
m_bIsPlayingRadio = bIsPlayingRadio;
Expand Down
3 changes: 2 additions & 1 deletion xbmc/pvr/PVRGUIInfo.h
Expand Up @@ -155,7 +155,8 @@ namespace PVR
std::string m_strNextRecordingChannelName;
std::string m_strNextRecordingChannelIcon;
std::string m_strNextRecordingTime;
bool m_bHasRecordings;
bool m_bHasTVRecordings;
bool m_bHasRadioRecordings;
unsigned int m_iTimerAmount;
unsigned int m_iRecordingTimerAmount;
unsigned int m_iCurrentActiveClient;
Expand Down
9 changes: 7 additions & 2 deletions xbmc/pvr/recordings/PVRRecording.cpp
Expand Up @@ -114,6 +114,7 @@ CPVRRecording::CPVRRecording(const PVR_RECORDING &recording, unsigned int iClien
m_bIsDeleted = recording.bIsDeleted;
m_iEpgEventId = recording.iEpgEventId;
m_iChannelUid = recording.iChannelUid;
m_bRadio = recording.channelType == PVR_RECORDING_CHANNEL_TYPE_RADIO; // everything else is considered TV
}

bool CPVRRecording::operator ==(const CPVRRecording& right) const
Expand Down Expand Up @@ -142,7 +143,8 @@ bool CPVRRecording::operator ==(const CPVRRecording& right) const
m_iRecordingId == right.m_iRecordingId &&
m_bIsDeleted == right.m_bIsDeleted &&
m_iEpgEventId == right.m_iEpgEventId &&
m_iChannelUid == right.m_iChannelUid);
m_iChannelUid == right.m_iChannelUid &&
m_bRadio == right.m_bRadio);
}

bool CPVRRecording::operator !=(const CPVRRecording& right) const
Expand All @@ -166,6 +168,7 @@ void CPVRRecording::Serialize(CVariant& value) const
value["deleted"] = m_bIsDeleted;
value["epgevent"] = m_iEpgEventId;
value["channeluid"] = m_iChannelUid;
value["radio"] = m_bRadio;

if (!value.isMember("art"))
value["art"] = CVariant(CVariant::VariantTypeObject);
Expand Down Expand Up @@ -195,6 +198,7 @@ void CPVRRecording::Reset(void)
m_iSeason = -1;
m_iEpisode = -1;
m_iChannelUid = PVR_CHANNEL_INVALID_UID;
m_bRadio = false;

m_recordingTime.Reset();
CVideoInfoTag::Reset();
Expand Down Expand Up @@ -374,6 +378,7 @@ void CPVRRecording::Update(const CPVRRecording &tag)
m_bIsDeleted = tag.m_bIsDeleted;
m_iEpgEventId = tag.m_iEpgEventId;
m_iChannelUid = tag.m_iChannelUid;
m_bRadio = tag.m_bRadio;

if (g_PVRClients->SupportsRecordingPlayCount(m_iClientId))
m_playCount = tag.m_playCount;
Expand Down Expand Up @@ -416,7 +421,7 @@ void CPVRRecording::UpdatePath(void)
else
{
m_strFileNameAndPath = CPVRRecordingsPath(
m_bIsDeleted, m_strDirectory, m_strTitle, m_iSeason, m_iEpisode, m_iYear, m_strShowTitle, m_strChannelName, m_recordingTime);
m_bIsDeleted, m_bRadio, m_strDirectory, m_strTitle, m_iSeason, m_iEpisode, m_iYear, m_strShowTitle, m_strChannelName, m_recordingTime);
}
}

Expand Down
7 changes: 7 additions & 0 deletions xbmc/pvr/recordings/PVRRecording.h
Expand Up @@ -202,6 +202,12 @@ namespace PVR
*/
bool IsDeleted() const { return m_bIsDeleted; }

/*!
* @brief Check whether this is a tv or radio recording
* @return true if this is a radio recording, false if this is a tv recording
*/
bool IsRadio() const { return m_bRadio; }

/*!
* @return Broadcast id of the EPG event associated with this recording or EPG_TAG_INVALID_UID
*/
Expand Down Expand Up @@ -236,6 +242,7 @@ namespace PVR
bool m_bIsDeleted; /*!< set if entry is a deleted recording which can be undelete */
unsigned int m_iEpgEventId; /*!< epg broadcast id associated with this recording */
int m_iChannelUid; /*!< channel uid associated with this recording */
bool m_bRadio; /*!< radio or tv recording */

void UpdatePath(void);
void DisplayError(PVR_ERROR err) const;
Expand Down
69 changes: 43 additions & 26 deletions xbmc/pvr/recordings/PVRRecordings.cpp
Expand Up @@ -39,7 +39,10 @@ CPVRRecordings::CPVRRecordings(void) :
m_bIsUpdating(false),
m_iLastId(0),
m_bGroupItems(true),
m_bHasDeleted(false)
m_bDeletedTVRecordings(false),
m_bDeletedRadioRecordings(false),
m_iTVRecordings(0),
m_iRadioRecordings(0)
{
m_database.Open();
}
Expand Down Expand Up @@ -86,13 +89,17 @@ void CPVRRecordings::GetSubDirectories(const CPVRRecordingsPath &recParentPath,
// Only active recordings are fetched to provide sub directories.
// Not applicable for deleted view which is supposed to be flattened.
std::set<CFileItemPtr> unwatchedFolders;
bool bRadio = recParentPath.IsRadio();

for (PVR_RECORDINGMAP_CITR it = m_recordings.begin(); it != m_recordings.end(); it++)
{
CPVRRecordingPtr current = it->second;
if (current->IsDeleted())
continue;

if (current->IsRadio() != bRadio)
continue;

const std::string strCurrent = recParentPath.GetSubDirectoryPath(current->m_strDirectory);
if (strCurrent.empty())
continue;
Expand All @@ -119,9 +126,9 @@ void CPVRRecordings::GetSubDirectories(const CPVRRecordingsPath &recParentPath,
}
else
{
pFileItem=results->Get(strFilePath);
pFileItem = results->Get(strFilePath);
if (pFileItem->m_dateTime<current->RecordingTimeAsLocalTime())
pFileItem->m_dateTime = current->RecordingTimeAsLocalTime();
pFileItem->m_dateTime = current->RecordingTimeAsLocalTime();
}

if (current->m_playCount == 0)
Expand Down Expand Up @@ -164,34 +171,28 @@ void CPVRRecordings::Update(void)
NotifyObservers(ObservableMessageRecordings);
}

int CPVRRecordings::GetNumRecordings()
int CPVRRecordings::GetNumTVRecordings() const
{
CSingleLock lock(m_critSection);
return m_recordings.size();
return m_iTVRecordings;
}

bool CPVRRecordings::HasDeletedRecordings()
bool CPVRRecordings::HasDeletedTVRecordings() const
{
CSingleLock lock(m_critSection);
return m_bHasDeleted;
return m_bDeletedTVRecordings;
}

int CPVRRecordings::GetRecordings(CFileItemList* results, bool bDeleted)
int CPVRRecordings::GetNumRadioRecordings() const
{
CSingleLock lock(m_critSection);
return m_iRadioRecordings;
}

int iRecCount = 0;
for (PVR_RECORDINGMAP_CITR it = m_recordings.begin(); it != m_recordings.end(); it++)
{
if (it->second->IsDeleted() != bDeleted)
continue;

CFileItemPtr pFileItem(new CFileItem(it->second));
results->Add(pFileItem);
iRecCount++;
}

return iRecCount;
bool CPVRRecordings::HasDeletedRadioRecordings() const
{
CSingleLock lock(m_critSection);
return m_bDeletedRadioRecordings;
}

bool CPVRRecordings::Delete(const CFileItem& item)
Expand Down Expand Up @@ -330,8 +331,10 @@ bool CPVRRecordings::GetDirectory(const std::string& strPath, CFileItemList &ite
{
CPVRRecordingPtr current = it->second;

// skip items that are not members of the target directory
if (!IsDirectoryMember(strDirectory, current->m_strDirectory) || current->IsDeleted() != recPath.IsDeleted())
// Omit recordings not matching criteria
if (!IsDirectoryMember(strDirectory, current->m_strDirectory) ||
current->IsDeleted() != recPath.IsDeleted() ||
current->IsRadio() != recPath.IsRadio())
continue;

if (m_database.IsOpen())
Expand Down Expand Up @@ -410,13 +413,15 @@ CFileItemPtr CPVRRecordings::GetByPath(const std::string &path)
CPVRRecordingsPath recPath(path);
if (recPath.IsValid())
{
// Check directory name is for deleted recordings
bool bDeleted = recPath.IsDeleted();
bool bRadio = recPath.IsRadio();

for (PVR_RECORDINGMAP_CITR it = m_recordings.begin(); it != m_recordings.end(); it++)
{
CPVRRecordingPtr current = it->second;
if (!URIUtils::PathEquals(path, current->m_strFileNameAndPath) || bDeleted != current->IsDeleted())
// Omit recordings not matching criteria
if (!URIUtils::PathEquals(path, current->m_strFileNameAndPath) ||
bDeleted != current->IsDeleted() || bRadio != current->IsRadio())
continue;

CFileItemPtr fileItem(new CFileItem(current));
Expand All @@ -442,7 +447,10 @@ CPVRRecordingPtr CPVRRecordings::GetById(int iClientId, const std::string &strRe
void CPVRRecordings::Clear()
{
CSingleLock lock(m_critSection);
m_bHasDeleted = false;
m_bDeletedTVRecordings = false;
m_bDeletedRadioRecordings = false;
m_iTVRecordings = 0;
m_iRadioRecordings = 0;
m_recordings.clear();
}

Expand All @@ -451,7 +459,12 @@ void CPVRRecordings::UpdateFromClient(const CPVRRecordingPtr &tag)
CSingleLock lock(m_critSection);

if (tag->IsDeleted())
m_bHasDeleted = true;
{
if (tag->IsRadio())
m_bDeletedRadioRecordings = true;
else
m_bDeletedTVRecordings = true;
}

CPVRRecordingPtr newTag = GetById(tag->m_iClientId, tag->m_strRecordingId);
if (newTag)
Expand All @@ -474,6 +487,10 @@ void CPVRRecordings::UpdateFromClient(const CPVRRecordingPtr &tag)
}
newTag->m_iRecordingId = ++m_iLastId;
m_recordings.insert(std::make_pair(CPVRRecordingUid(newTag->m_iClientId, newTag->m_strRecordingId), newTag));
if (newTag->IsRadio())
m_iRadioRecordings++;
else
m_iTVRecordings++;
}
}

Expand Down
12 changes: 8 additions & 4 deletions xbmc/pvr/recordings/PVRRecordings.h
Expand Up @@ -42,7 +42,10 @@ namespace PVR
unsigned int m_iLastId;
bool m_bGroupItems;
CVideoDatabase m_database;
bool m_bHasDeleted;
bool m_bDeletedTVRecordings;
bool m_bDeletedRadioRecordings;
unsigned int m_iTVRecordings;
unsigned int m_iRadioRecordings;

virtual void UpdateFromClients(void);
virtual std::string TrimSlashes(const std::string &strOrig) const;
Expand Down Expand Up @@ -72,9 +75,10 @@ namespace PVR
*/
void Update(void);

int GetNumRecordings();
bool HasDeletedRecordings();
int GetRecordings(CFileItemList* results, bool bDeleted = false);
int GetNumTVRecordings() const;
bool HasDeletedTVRecordings() const;
int GetNumRadioRecordings() const;
bool HasDeletedRadioRecordings() const;

/**
* Deletes the item in question, be it a directory or a file
Expand Down