aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorace20022 <ace20022@ymail.com>2016-09-29 13:32:50 +0200
committerace20022 <ace20022@ymail.com>2016-09-29 17:18:26 +0200
commit3b3e36499d18088b7b22a22063b1cd37d8e7519b (patch)
tree2697a5f1f64c4cb754754d34ef7bbe8a6b28d0ca
parentf75cc2c48c5cecbe2820b1dd6a577bae9e2e1e51 (diff)
[videoplayer] Refactor CUtil::GetExternalStreamDetailsFromFilename.
- return an ExternalStreamInfo object instead of passing it by ref. - rename params - add doxygen
-rw-r--r--xbmc/Util.cpp20
-rw-r--r--xbmc/Util.h8
-rw-r--r--xbmc/cores/VideoPlayer/DVDDemuxers/DemuxMultiSource.cpp3
-rw-r--r--xbmc/cores/VideoPlayer/DVDFileInfo.cpp3
-rw-r--r--xbmc/cores/VideoPlayer/VideoPlayer.cpp6
-rw-r--r--xbmc/network/upnp/UPnPInternal.cpp3
6 files changed, 24 insertions, 19 deletions
diff --git a/xbmc/Util.cpp b/xbmc/Util.cpp
index 6ccb8a02b7..161304a597 100644
--- a/xbmc/Util.cpp
+++ b/xbmc/Util.cpp
@@ -2066,25 +2066,27 @@ void CUtil::ScanForExternalSubtitles(const std::string& strMovie, std::vector<st
CLog::Log(LOGDEBUG, "%s: END (total time: %i ms)", __FUNCTION__, (int)(XbmcThreads::SystemClockMillis() - startTimer));
}
-void CUtil::GetExternalStreamDetailsFromFilename(const std::string& strVideo, const std::string& strStream, ExternalStreamInfo& info)
+ExternalStreamInfo CUtil::GetExternalStreamDetailsFromFilename(const std::string& videoPath, const std::string& associatedFile)
{
- std::string videoBaseName = URIUtils::GetFileName(strVideo);
+ ExternalStreamInfo info;
+
+ std::string videoBaseName = URIUtils::GetFileName(videoPath);
URIUtils::RemoveExtension(videoBaseName);
- std::string toParse = URIUtils::GetFileName(strStream);
+ std::string toParse = URIUtils::GetFileName(associatedFile);
URIUtils::RemoveExtension(toParse);
// we check left part - if it's same as video base name - strip it
if (StringUtils::StartsWithNoCase(toParse, videoBaseName))
toParse = toParse.substr(videoBaseName.length());
- else if (URIUtils::GetExtension(strStream) == ".sub" && URIUtils::IsInArchive(strStream))
+ else if (URIUtils::GetExtension(associatedFile) == ".sub" && URIUtils::IsInArchive(associatedFile))
{
- // exclude parsing of vobsub file names that embedded in an archive
- CLog::Log(LOGDEBUG, "%s - skipping archived vobsub filename parsing: %s", __FUNCTION__, CURL::GetRedacted(strStream).c_str());
+ // exclude parsing of vobsub file names that are embedded in an archive
+ CLog::Log(LOGDEBUG, "%s - skipping archived vobsub filename parsing: %s", __FUNCTION__, CURL::GetRedacted(associatedFile).c_str());
toParse.clear();
}
- // trim any non-alphanumeric char in the begining
+ // trim any non-alphanumeric char in the beginning
std::string::iterator result = std::find_if(toParse.begin(), toParse.end(), StringUtils::isasciialphanum);
std::string name;
@@ -2139,7 +2141,9 @@ void CUtil::GetExternalStreamDetailsFromFilename(const std::string& strVideo, co
info.flag = CDemuxStream::FLAG_NONE;
CLog::Log(LOGDEBUG, "%s - Language = '%s' / Name = '%s' / Flag = '%u' from %s",
- __FUNCTION__, info.language.c_str(), info.name.c_str(), info.flag, CURL::GetRedacted(strStream).c_str());
+ __FUNCTION__, info.language.c_str(), info.name.c_str(), info.flag, CURL::GetRedacted(associatedFile).c_str());
+
+ return info;
}
/*! \brief in a vector of subtitles finds the corresponding .sub file for a given .idx file
diff --git a/xbmc/Util.h b/xbmc/Util.h
index a2e915d5fe..16836bca8f 100644
--- a/xbmc/Util.h
+++ b/xbmc/Util.h
@@ -83,7 +83,13 @@ public:
static void ClearSubtitles();
static void ScanForExternalSubtitles(const std::string& strMovie, std::vector<std::string>& vecSubtitles );
- static void GetExternalStreamDetailsFromFilename(const std::string& strMovie, const std::string& strSubtitles, ExternalStreamInfo& info);
+
+ /** \brief Retrieves stream info of external associated files, e.g., subtitles, for a given video.
+ * \param[in] videoPath The full path of the video file.
+ * \param[in] associatedFile A file that provides additional streams for the given video file.
+ * \return stream info for the given associatedFile
+ */
+ static ExternalStreamInfo GetExternalStreamDetailsFromFilename(const std::string& videoPath, const std::string& associatedFile);
static bool FindVobSubPair( const std::vector<std::string>& vecSubtitles, const std::string& strIdxPath, std::string& strSubPath );
static bool IsVobSub(const std::vector<std::string>& vecSubtitles, const std::string& strSubPath);
static std::string GetVobSubSubFromIdx(const std::string& vobSubIdx);
diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxMultiSource.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxMultiSource.cpp
index 24c9297ae7..9cfc1a884d 100644
--- a/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxMultiSource.cpp
+++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DemuxMultiSource.cpp
@@ -230,8 +230,7 @@ void CDemuxMultiSource::SetMissingStreamDetails(DemuxPtr demuxer)
std::string fileName = demuxer->GetFileName();
for (auto& stream : demuxer->GetStreams())
{
- ExternalStreamInfo info;
- CUtil::GetExternalStreamDetailsFromFilename(baseFileName, fileName, info);
+ ExternalStreamInfo info = CUtil::GetExternalStreamDetailsFromFilename(baseFileName, fileName);
if (stream->flags == CDemuxStream::FLAG_NONE)
{
diff --git a/xbmc/cores/VideoPlayer/DVDFileInfo.cpp b/xbmc/cores/VideoPlayer/DVDFileInfo.cpp
index 2e47e95056..8709bbf8a0 100644
--- a/xbmc/cores/VideoPlayer/DVDFileInfo.cpp
+++ b/xbmc/cores/VideoPlayer/DVDFileInfo.cpp
@@ -484,8 +484,7 @@ bool CDVDFileInfo::AddExternalSubtitleToDetails(const std::string &path, CStream
}
CStreamDetailSubtitle *dsub = new CStreamDetailSubtitle();
- ExternalStreamInfo info;
- CUtil::GetExternalStreamDetailsFromFilename(path, filename, info);
+ ExternalStreamInfo info = CUtil::GetExternalStreamDetailsFromFilename(path, filename);
dsub->m_strLanguage = g_LangCodeExpander.ConvertToISO6392T(info.language);
details.AddStream(dsub);
diff --git a/xbmc/cores/VideoPlayer/VideoPlayer.cpp b/xbmc/cores/VideoPlayer/VideoPlayer.cpp
index 31bcc8e680..5665dcc313 100644
--- a/xbmc/cores/VideoPlayer/VideoPlayer.cpp
+++ b/xbmc/cores/VideoPlayer/VideoPlayer.cpp
@@ -4725,8 +4725,7 @@ int CVideoPlayer::AddSubtitleFile(const std::string& filename, const std::string
return -1;
m_SelectionStreams.Update(NULL, &v, vobsubfile);
- ExternalStreamInfo info;
- CUtil::GetExternalStreamDetailsFromFilename(m_item.GetPath(), vobsubfile, info);
+ ExternalStreamInfo info = CUtil::GetExternalStreamDetailsFromFilename(m_item.GetPath(), vobsubfile);
for (auto sub : v.GetStreams())
{
@@ -4763,8 +4762,7 @@ int CVideoPlayer::AddSubtitleFile(const std::string& filename, const std::string
s.type = STREAM_SUBTITLE;
s.id = 0;
s.filename = filename;
- ExternalStreamInfo info;
- CUtil::GetExternalStreamDetailsFromFilename(m_item.GetPath(), filename, info);
+ ExternalStreamInfo info = CUtil::GetExternalStreamDetailsFromFilename(m_item.GetPath(), filename);
s.name = info.name;
s.language = info.language;
if (static_cast<CDemuxStream::EFlags>(info.flag) != CDemuxStream::FLAG_NONE)
diff --git a/xbmc/network/upnp/UPnPInternal.cpp b/xbmc/network/upnp/UPnPInternal.cpp
index 75ef283d33..26d1eb1030 100644
--- a/xbmc/network/upnp/UPnPInternal.cpp
+++ b/xbmc/network/upnp/UPnPInternal.cpp
@@ -655,8 +655,7 @@ BuildObject(CFileItem& item,
for (unsigned int i = 0; i < subtitles.size(); i++)
{
- ExternalStreamInfo info;
- CUtil::GetExternalStreamDetailsFromFilename(file_path.GetChars(), subtitles[i], info);
+ ExternalStreamInfo info = CUtil::GetExternalStreamDetailsFromFilename(file_path.GetChars(), subtitles[i]);
if (preferredLanguageCode == info.language)
{