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

[EDL] Migrate to tinyxml2 #24185

Merged
merged 2 commits into from
Dec 5, 2023
Merged
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
36 changes: 18 additions & 18 deletions xbmc/cores/VideoPlayer/Edl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "settings/SettingsComponent.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include "utils/XBMCTinyXML.h"
#include "utils/XBMCTinyXML2.h"
#include "utils/log.h"

#include "PlatformDefs.h"
Expand Down Expand Up @@ -482,36 +482,36 @@ bool CEdl::ReadBeyondTV(const std::string& strMovie)
if (!CFile::Exists(beyondTVFilename))
return false;

CXBMCTinyXML xmlDoc;
CXBMCTinyXML2 xmlDoc;
if (!xmlDoc.LoadFile(beyondTVFilename))
{
CLog::Log(LOGERROR, "{} - Could not load Beyond TV file: {}. {}", __FUNCTION__,
CURL::GetRedacted(beyondTVFilename), xmlDoc.ErrorDesc());
CURL::GetRedacted(beyondTVFilename), xmlDoc.ErrorStr());
return false;
}

if (xmlDoc.Error())
{
CLog::Log(LOGERROR, "{} - Could not parse Beyond TV file: {}. {}", __FUNCTION__,
CURL::GetRedacted(beyondTVFilename), xmlDoc.ErrorDesc());
CURL::GetRedacted(beyondTVFilename), xmlDoc.ErrorStr());
return false;
}

TiXmlElement *pRoot = xmlDoc.RootElement();
if (!pRoot || strcmp(pRoot->Value(), "cutlist"))
const tinyxml2::XMLElement* root = xmlDoc.RootElement();
if (!root || strcmp(root->Value(), "cutlist"))
{
CLog::Log(LOGERROR, "{} - Invalid Beyond TV file: {}. Expected root node to be <cutlist>",
__FUNCTION__, CURL::GetRedacted(beyondTVFilename));
return false;
}

bool bValid = true;
TiXmlElement *pRegion = pRoot->FirstChildElement("Region");
while (bValid && pRegion)
bool valid = true;
const tinyxml2::XMLElement* region = root->FirstChildElement("Region");
while (valid && region)
{
TiXmlElement *pStart = pRegion->FirstChildElement("start");
TiXmlElement *pEnd = pRegion->FirstChildElement("end");
if (pStart && pEnd && pStart->FirstChild() && pEnd->FirstChild())
const tinyxml2::XMLElement* start = region->FirstChildElement("start");
const tinyxml2::XMLElement* end = region->FirstChildElement("end");
if (start && end && start->FirstChild() && end->FirstChild())
{
/*
* Need to divide the start and end times by a factor of 10,000 to get msec.
Expand All @@ -526,17 +526,17 @@ bool CEdl::ReadBeyondTV(const std::string& strMovie)
* atof() returns 0 if there were any problems and will subsequently be rejected in AddEdit().
*/
Edit edit;
edit.start = std::lround((std::atof(pStart->FirstChild()->Value()) / 10000));
edit.end = std::lround((std::atof(pEnd->FirstChild()->Value()) / 10000));
edit.start = std::lround((std::atof(start->FirstChild()->Value()) / 10000));
edit.end = std::lround((std::atof(end->FirstChild()->Value()) / 10000));
edit.action = Action::COMM_BREAK;
bValid = AddEdit(edit);
valid = AddEdit(edit);
}
else
bValid = false;
valid = false;

pRegion = pRegion->NextSiblingElement("Region");
region = region->NextSiblingElement("Region");
}
if (!bValid)
if (!valid)
{
CLog::Log(LOGERROR,
"{} - Invalid Beyond TV file: {}. Clearing any valid commercial breaks found.",
Expand Down