Permalink
Browse files

move call to GetStreamDetails to CVideoThumbLoader

  • Loading branch information...
1 parent 5c10498 commit fcb6107c6e9d0261e7807f58ef566987a1bd0401 @Montellese committed Jun 18, 2012
Showing with 14 additions and 14 deletions.
  1. +7 −0 xbmc/ThumbLoader.cpp
  2. +4 −11 xbmc/video/VideoDatabase.cpp
  3. +3 −3 xbmc/video/VideoDatabase.h
View
7 xbmc/ThumbLoader.cpp
@@ -206,6 +206,13 @@ bool CVideoThumbLoader::LoadItem(CFileItem* pItem)
pItem->SetInvalid();
}
+ if (pItem->HasVideoInfoTag() && !pItem->GetVideoInfoTag()->HasStreamDetails() &&
+ (pItem->GetVideoInfoTag()->m_type == "movie" || pItem->GetVideoInfoTag()->m_type == "episode" || pItem->GetVideoInfoTag()->m_type == "musicvideo"))
+ {
+ if (m_database->GetStreamDetails(*pItem->GetVideoInfoTag()))
+ pItem->SetInvalid();
+ }
+
// video db items normally have info in the database
if (pItem->HasVideoInfoTag() && pItem->GetArt().empty())
{
View
15 xbmc/video/VideoDatabase.cpp
@@ -3018,12 +3018,12 @@ bool CVideoDatabase::GetResumePoint(CVideoInfoTag& tag)
return match;
}
-CVideoInfoTag CVideoDatabase::GetDetailsForMovie(auto_ptr<Dataset> &pDS, bool needsCast /* = false */, bool needsStreamDetails /* = true */)
+CVideoInfoTag CVideoDatabase::GetDetailsForMovie(auto_ptr<Dataset> &pDS, bool needsCast /* = false */)
{
- return GetDetailsForMovie(pDS->get_sql_record(), needsCast, needsStreamDetails);
+ return GetDetailsForMovie(pDS->get_sql_record(), needsCast);
}
-CVideoInfoTag CVideoDatabase::GetDetailsForMovie(const dbiplus::sql_record* const record, bool needsCast /* = false */, bool needsStreamDetails /* = true */)
+CVideoInfoTag CVideoDatabase::GetDetailsForMovie(const dbiplus::sql_record* const record, bool needsCast /* = false */)
{
CVideoInfoTag details;
@@ -3040,9 +3040,6 @@ CVideoInfoTag CVideoDatabase::GetDetailsForMovie(const dbiplus::sql_record* cons
GetCommonDetails(record, details);
movieTime += XbmcThreads::SystemClockMillis() - time; time = XbmcThreads::SystemClockMillis();
- if (needsStreamDetails)
- GetStreamDetails(details);
-
if (needsCast)
{
GetCast("movie", "idMovie", details.m_iDbId, details.m_cast);
@@ -3153,8 +3150,6 @@ CVideoInfoTag CVideoDatabase::GetDetailsForEpisode(const dbiplus::sql_record* co
movieTime += XbmcThreads::SystemClockMillis() - time; time = XbmcThreads::SystemClockMillis();
- GetStreamDetails(details);
-
if (needsCast)
{
GetCast("episode", "idEpisode", details.m_iDbId, details.m_cast);
@@ -3189,8 +3184,6 @@ CVideoInfoTag CVideoDatabase::GetDetailsForMusicVideo(const dbiplus::sql_record*
GetCommonDetails(record, details);
movieTime += XbmcThreads::SystemClockMillis() - time; time = XbmcThreads::SystemClockMillis();
- GetStreamDetails(details);
-
details.m_strPictureURL.Parse();
return details;
}
@@ -4425,7 +4418,7 @@ bool CVideoDatabase::GetSetsByWhere(const CStdString& strBaseDir, const Filter &
}
// add the movie's details to the set
- it->second.movies.push_back(GetDetailsForMovie(m_pDS, false, false));
+ it->second.movies.push_back(GetDetailsForMovie(m_pDS));
m_pDS->next();
}
View
6 xbmc/video/VideoDatabase.h
@@ -478,6 +478,7 @@ class CVideoDatabase : public CDatabase
void AddBookMarkForEpisode(const CVideoInfoTag& tag, const CBookmark& bookmark);
void DeleteBookMarkForEpisode(const CVideoInfoTag& tag);
bool GetResumePoint(CVideoInfoTag& tag);
+ bool GetStreamDetails(CVideoInfoTag& tag) const;
// scraper settings
void SetScraperForPath(const CStdString& filePath, const ADDON::ScraperPtr& info, const VIDEO::SScanSettings& settings);
@@ -739,8 +740,8 @@ class CVideoDatabase : public CDatabase
void DeleteStreamDetails(int idFile);
CVideoInfoTag GetDetailsByTypeAndId(VIDEODB_CONTENT_TYPE type, int id);
- CVideoInfoTag GetDetailsForMovie(std::auto_ptr<dbiplus::Dataset> &pDS, bool needsCast = false, bool needsStreamDetails = true);
- CVideoInfoTag GetDetailsForMovie(const dbiplus::sql_record* const record, bool needsCast = false, bool needsStreamDetails = true);
+ CVideoInfoTag GetDetailsForMovie(std::auto_ptr<dbiplus::Dataset> &pDS, bool needsCast = false);
+ CVideoInfoTag GetDetailsForMovie(const dbiplus::sql_record* const record, bool needsCast = false);
CVideoInfoTag GetDetailsForTvShow(std::auto_ptr<dbiplus::Dataset> &pDS, bool needsCast = false);
CVideoInfoTag GetDetailsForTvShow(const dbiplus::sql_record* const record, bool needsCast = false);
CVideoInfoTag GetDetailsForEpisode(std::auto_ptr<dbiplus::Dataset> &pDS, bool needsCast = false);
@@ -756,7 +757,6 @@ class CVideoDatabase : public CDatabase
void GetDetailsFromDB(std::auto_ptr<dbiplus::Dataset> &pDS, int min, int max, const SDbTableOffsets *offsets, CVideoInfoTag &details, int idxOffset = 2);
void GetDetailsFromDB(const dbiplus::sql_record* const record, int min, int max, const SDbTableOffsets *offsets, CVideoInfoTag &details, int idxOffset = 2);
CStdString GetValueString(const CVideoInfoTag &details, int min, int max, const SDbTableOffsets *offsets) const;
- bool GetStreamDetails(CVideoInfoTag& tag) const;
private:
virtual bool CreateTables();

5 comments on commit fcb6107

@koying

Hi,

It looks that between this and some later thumb loading optimizations, the streamdetails are actually never fetched, and thus streamdetails is always NULL from JSON.

Not sure how to best solve this...

@Montellese
Owner

We'll probably have to manually get the stream details for all the video items that JSON-RPC wants to return to the client (but only if streamdetails are requested by the client).

@koying

Another solution would be to keep the "GetStreamDetails" as they were, but adding a bool to CVideoInfoTag indicating whether the details were already fetched, to avoid duplicate db fetches (trying this now)

Or do both...

@Montellese
Owner

The reason why I moved the call to the thumbloader is that there are several calls to GetMoviesByWhere (and therefore GetDetailsForMovie) which fetch the streamdetails (which causes an additional query and therefore additional processing time) but don't need the streamdetails. The problem isn't knowing whether the streamdetails were already retrieved or not. We want to do as few SQL queries as possible. Making the necessary calls to GetStreamDetails from JSON-RPC will not increase the number of SQL queries compared to how it worked before this commit . There will still be the same amound of SQL queries per movie but they will be triggered from a different location.

@koying

Re as few SQL as possible, I understand that.
I meant to do:

bool CVideoDatabase::GetStreamDetails(CVideoInfoTag& tag) const
{
  if (tag.m_iFileId < 0)
    return false;

  if (tag.m_streamDetailsLoaded)
    return tag.m_streamDetails.HasItems();

But, obviously, only retrieving stream details when requested doesn't harm either ;)

Please sign in to comment.