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] Cleanup: Reduce cores/VideoPlayer/Edl.cpp PVR dependencies. #16709

Merged
merged 3 commits into from Oct 5, 2019
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
2 changes: 1 addition & 1 deletion xbmc/cores/Cut.h
Expand Up @@ -15,7 +15,7 @@ enum class Action
{
CUT = 0,
MUTE = 1,
// SCENE = 2,
SCENE = 2,
COMM_BREAK = 3
};

Expand Down
119 changes: 37 additions & 82 deletions xbmc/cores/VideoPlayer/Edl.cpp
Expand Up @@ -12,9 +12,7 @@
#include "ServiceBroker.h"
#include "cores/Cut.h"
#include "filesystem/File.h"
#include "pvr/PVRManager.h"
#include "pvr/epg/EpgInfoTag.h"
#include "pvr/recordings/PVRRecording.h"
#include "pvr/PVREdl.h"
#include "settings/AdvancedSettings.h"
#include "settings/SettingsComponent.h"
#include "utils/StringUtils.h"
Expand Down Expand Up @@ -75,22 +73,8 @@ bool CEdl::ReadEditDecisionLists(const CFileItem& fileItem, const float fFramesP
if (!bFound)
bFound = ReadBeyondTV(strMovie);
}

/*
* PVR Recordings
*/
else if (fileItem.IsPVRRecording())
else
{
CLog::Log(LOGDEBUG, "%s - Checking for edit decision list (EDL) for PVR recording: %s",
__FUNCTION__, CURL::GetRedacted(strMovie).c_str());

bFound = ReadPvr(fileItem);
}
else if (fileItem.IsEPG())
{
CLog::Log(LOGDEBUG, "%s - Checking for edit decision list (EDL) for EPG entry: %s",
__FUNCTION__, CURL::GetRedacted(strMovie).c_str());

bFound = ReadPvr(fileItem);
}

Expand Down Expand Up @@ -542,79 +526,48 @@ bool CEdl::ReadBeyondTV(const std::string& strMovie)

bool CEdl::ReadPvr(const CFileItem &fileItem)
{
const std::string strMovie = fileItem.GetDynPath();
if (!CServiceBroker::GetPVRManager().IsStarted())
{
CLog::Log(LOGERROR, "%s - PVR Manager not started, cannot read Edl for %s", __FUNCTION__, CURL::GetRedacted(strMovie).c_str());
return false;
}

std::vector<PVR_EDL_ENTRY> edl;

if (fileItem.HasPVRRecordingInfoTag())
const std::vector<Cut> cutlist = PVR::CPVREdl::GetCuts(fileItem);
for (const auto& cut : cutlist)
{
CLog::Log(LOGDEBUG, "%s - Reading Edl for recording: %s", __FUNCTION__, fileItem.GetPVRRecordingInfoTag()->m_strTitle.c_str());
edl = fileItem.GetPVRRecordingInfoTag()->GetEdl();
}
else if (fileItem.HasEPGInfoTag())
{
CLog::Log(LOGDEBUG, "%s - Reading Edl for EPG: %s", __FUNCTION__, fileItem.GetEPGInfoTag()->Title().c_str());
edl = fileItem.GetEPGInfoTag()->GetEdl();
}
else
{
CLog::Log(LOGERROR, "%s - Unknown file item type : %s", __FUNCTION__, CURL::GetRedacted(strMovie).c_str());
return false;
}

std::vector<PVR_EDL_ENTRY>::const_iterator it;
for (it = edl.begin(); it != edl.end(); ++it)
{
Cut cut;
cut.start = it->start;
cut.end = it->end;

switch (it->type)
switch (cut.action)
{
case PVR_EDL_TYPE_CUT:
cut.action = Action::CUT;
break;
case PVR_EDL_TYPE_MUTE:
cut.action = Action::MUTE;
break;
case PVR_EDL_TYPE_SCENE:
if (!AddSceneMarker(cut.end))
{
CLog::Log(LOGWARNING, "%s - Error adding scene marker for pvr recording", __FUNCTION__);
}
continue;
case PVR_EDL_TYPE_COMBREAK:
cut.action = Action::COMM_BREAK;
break;
default:
CLog::Log(LOGINFO, "%s - Ignoring entry of unknown type: %d", __FUNCTION__, it->type);
continue;
}
case Action::CUT:
case Action::MUTE:
case Action::COMM_BREAK:
if (AddCut(cut))
{
CLog::Log(LOGDEBUG, "%s - Added break [%s - %s] found in PVR item for: %s.",
__FUNCTION__, MillisecondsToTimeString(cut.start).c_str(),
MillisecondsToTimeString(cut.end).c_str(), CURL::GetRedacted(fileItem.GetDynPath()).c_str());
}
else
{
CLog::Log(LOGERROR, "%s - Invalid break [%s - %s] found in PVR item for: %s. Continuing anyway.",
__FUNCTION__, MillisecondsToTimeString(cut.start).c_str(),
MillisecondsToTimeString(cut.end).c_str(), CURL::GetRedacted(fileItem.GetDynPath()).c_str());
}
break;
Comment on lines +534 to +549
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception: Do not increase indentation after a switch statements.

https://github.com/xbmc/xbmc/blob/master/docs/CODE_GUIDELINES.md#32-indentation


if (AddCut(cut))
{
CLog::Log(LOGDEBUG, "%s - Added break [%s - %s] found in PVRRecording for: %s.",
__FUNCTION__, MillisecondsToTimeString(cut.start).c_str(),
MillisecondsToTimeString(cut.end).c_str(), CURL::GetRedacted(strMovie).c_str());
}
else
{
CLog::Log(LOGERROR, "%s - Invalid break [%s - %s] found in PVRRecording for: %s. Continuing anyway.",
__FUNCTION__, MillisecondsToTimeString(cut.start).c_str(),
MillisecondsToTimeString(cut.end).c_str(), CURL::GetRedacted(strMovie).c_str());
case Action::SCENE:
if (!AddSceneMarker(cut.end))
{
CLog::Log(LOGWARNING, "%s - Error adding scene marker for PVR item", __FUNCTION__);
}
break;

default:
CLog::Log(LOGINFO, "%s - Ignoring entry of unknown cut action: %d", __FUNCTION__, static_cast<int>(cut.action));
break;
Comment on lines +551 to +560
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception: Do not increase indentation after a switch statements.

https://github.com/xbmc/xbmc/blob/master/docs/CODE_GUIDELINES.md#32-indentation

}
}

return !edl.empty();
return !cutlist.empty();
}

bool CEdl::AddCut(Cut& cut)
bool CEdl::AddCut(const Cut& newCut)
{
Cut cut = newCut;

if (cut.action != Action::CUT && cut.action != Action::MUTE && cut.action != Action::COMM_BREAK)
{
CLog::Log(LOGERROR, "%s - Not an Action::CUT, Action::MUTE, or Action::COMM_BREAK! [%s - %s], %d", __FUNCTION__,
Expand Down Expand Up @@ -793,6 +746,8 @@ std::string CEdl::GetInfo() const
case Action::COMM_BREAK:
commBreakCount++;
break;
default:
break;
}
}
if (cutCount > 0)
Expand Down
2 changes: 1 addition & 1 deletion xbmc/cores/VideoPlayer/Edl.h
Expand Up @@ -57,7 +57,7 @@ class CEdl
bool ReadBeyondTV(const std::string& strMovie);
bool ReadPvr(const CFileItem& fileItem);

bool AddCut(EDL::Cut& NewCut);
bool AddCut(const EDL::Cut& newCut);
bool AddSceneMarker(const int sceneMarker);

void MergeShortCommBreaks();
Expand Down
2 changes: 2 additions & 0 deletions xbmc/pvr/CMakeLists.txt
@@ -1,6 +1,7 @@
set(SOURCES PVRChannelNumberInputHandler.cpp
PVRContextMenus.cpp
PVRDatabase.cpp
PVREdl.cpp
PVREventLogJob.cpp
PVRItem.cpp
PVRManager.cpp
Expand All @@ -11,6 +12,7 @@ set(SOURCES PVRChannelNumberInputHandler.cpp
set(HEADERS PVRChannelNumberInputHandler.h
PVRContextMenus.h
PVRDatabase.h
PVREdl.h
PVREventLogJob.h
PVRItem.h
PVRManager.h
Expand Down
73 changes: 73 additions & 0 deletions xbmc/pvr/PVREdl.cpp
@@ -0,0 +1,73 @@
/*
* Copyright (C) 2012-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/

#include "PVREdl.h"

#include "FileItem.h"
#include "URL.h"
#include "addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h"
#include "cores/Cut.h"
#include "pvr/epg/EpgInfoTag.h"
#include "pvr/recordings/PVRRecording.h"
#include "utils/log.h"

namespace PVR
{

std::vector<EDL::Cut> CPVREdl::GetCuts(const CFileItem& item)
{
std::vector<PVR_EDL_ENTRY> edl;

if (item.HasPVRRecordingInfoTag())
{
CLog::LogFC(LOGDEBUG, LOGPVR, "Reading EDL for recording: %s", item.GetPVRRecordingInfoTag()->m_strTitle.c_str());
edl = item.GetPVRRecordingInfoTag()->GetEdl();
}
else if (item.HasEPGInfoTag())
{
CLog::LogFC(LOGDEBUG, LOGPVR, "Reading EDL for EPG tag: %s", item.GetEPGInfoTag()->Title().c_str());
edl = item.GetEPGInfoTag()->GetEdl();
}
else
{
CLog::LogF(LOGERROR, "Unhandled file item: %s", CURL::GetRedacted(item.GetDynPath()).c_str());
return {};
}

std::vector<EDL::Cut> cutlist;
for (const auto& entry : edl)
{
EDL::Cut cut;
cut.start = entry.start;
cut.end = entry.end;

switch (entry.type)
{
case PVR_EDL_TYPE_CUT:
cut.action = EDL::Action::CUT;
break;
case PVR_EDL_TYPE_MUTE:
cut.action = EDL::Action::MUTE;
break;
case PVR_EDL_TYPE_SCENE:
cut.action = EDL::Action::SCENE;
break;
case PVR_EDL_TYPE_COMBREAK:
cut.action = EDL::Action::COMM_BREAK;
break;
default:
CLog::LogF(LOGWARNING, "Ignoring entry of unknown EDL type: %d", entry.type);
continue;
}

cutlist.emplace_back(cut);
}
return cutlist;
}

} // namespace PVR
34 changes: 34 additions & 0 deletions xbmc/pvr/PVREdl.h
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2012-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/

#pragma once

#include <vector>

class CFileItem;

namespace EDL
{
struct Cut;
}

namespace PVR
{

class CPVREdl
{
public:
/*!
* @brief Get the cuts for the given item.
* @param item The item.
* @return The EDL cuts or enpty vector if no cuts exist.
*/
static std::vector<EDL::Cut> GetCuts(const CFileItem& item);
};

} // namespace PVR
2 changes: 1 addition & 1 deletion xbmc/pvr/PVRThumbLoader.cpp
Expand Up @@ -13,8 +13,8 @@
#include "TextureCache.h"
#include "TextureCacheJob.h"
#include "pictures/Picture.h"
#include "pvr/filesystem/PVRGUIDirectory.h"
#include "pvr/PVRManager.h"
#include "pvr/filesystem/PVRGUIDirectory.h"
#include "settings/AdvancedSettings.h"
#include "settings/Settings.h"
#include "settings/SettingsComponent.h"
Expand Down