bool CPVRManager::PlayMedia(const CFileItem& item) { if (!g_PVRManager.IsStarted()) { CLog::Log(LOGERROR, "CApplication - %s PVR manager not started to play file '%s'", __FUNCTION__, item.GetPath().c_str()); return false; } CFileItem pvrItem(item); if (URIUtils::IsPVRChannel(item.GetPath()) && !item.HasPVRChannelInfoTag()) pvrItem = *g_PVRChannelGroups->GetByPath(item.GetPath()); else if (URIUtils::IsPVRRecording(item.GetPath()) && !item.HasPVRRecordingInfoTag()) pvrItem = *g_PVRRecordings->GetByPath(item.GetPath()); if (!pvrItem.HasPVRChannelInfoTag() && !pvrItem.HasPVRRecordingInfoTag()) return false; // check parental lock if we want to play a channel if (pvrItem.IsPVRChannel() && !g_PVRManager.CheckParentalLock(*pvrItem.GetPVRChannelInfoTag())) return false; if (!g_application.IsCurrentThread()) { CApplicationMessenger::Get().MediaPlay(pvrItem); return true; } return g_application.PlayFile(pvrItem, false) == PLAYBACK_OK; }
bool CUPnPPlayer::QueueNextFile(const CFileItem& file) { CFileItem item(file); NPT_Reference<CThumbLoader> thumb_loader; NPT_Reference<PLT_MediaObject> obj; NPT_String path(file.GetPath().c_str()); NPT_String tmp; if (file.IsVideoDb()) thumb_loader = NPT_Reference<CThumbLoader>(new CVideoThumbLoader()); else if (item.IsMusicDb()) thumb_loader = NPT_Reference<CThumbLoader>(new CMusicThumbLoader()); obj = BuildObject(item, path, 0, thumb_loader, NULL, CUPnP::GetServer(), UPnPPlayer); if(!obj.IsNull()) { NPT_CHECK_LABEL_SEVERE(PLT_Didl::ToDidl(*obj, "", tmp), failed); tmp.Insert(didl_header, 0); tmp.Append(didl_footer); } NPT_CHECK_LABEL_WARNING(m_control->SetNextAVTransportURI(m_delegate->m_device , m_delegate->m_instance , file.GetPath().c_str() , (const char*)tmp , m_delegate), failed); if(!m_delegate->m_resevent.WaitMSec(10000)) goto failed; NPT_CHECK_LABEL_WARNING(m_delegate->m_resstatus, failed); return true; failed: CLog::Log(LOGERROR, "UPNP: CUPnPPlayer::QueueNextFile - unable to queue file %s", file.GetPath().c_str()); return false; }
std::string CFavouritesDirectory::GetExecutePath(const CFileItem &item, const std::string &contextWindow) { std::string execute; if (item.m_bIsFolder && (g_advancedSettings.m_playlistAsFolders || !(item.IsSmartPlayList() || item.IsPlayList()))) { if (!contextWindow.empty()) execute = StringUtils::Format("ActivateWindow(%s,%s,return)", contextWindow.c_str(), StringUtils::Paramify(item.GetPath()).c_str()); } /* TODO:STRING_CLEANUP */ else if (item.IsAndroidApp() && item.GetPath().size() > 26) // androidapp://sources/apps/<foo> execute = StringUtils::Format("StartAndroidActivity(%s)", StringUtils::Paramify(item.GetPath().substr(26)).c_str()); else // assume a media file { if (item.IsVideoDb() && item.HasVideoInfoTag()) execute = StringUtils::Format("PlayMedia(%s)", StringUtils::Paramify(item.GetVideoInfoTag()->m_strFileNameAndPath).c_str()); else if (item.IsMusicDb() && item.HasMusicInfoTag()) execute = StringUtils::Format("PlayMedia(%s)", StringUtils::Paramify(item.GetMusicInfoTag()->GetURL()).c_str()); else if (item.IsPicture()) execute = StringUtils::Format("ShowPicture(%s)", StringUtils::Paramify(item.GetPath()).c_str()); else execute = StringUtils::Format("PlayMedia(%s)", StringUtils::Paramify(item.GetPath()).c_str()); } return execute; }
bool CAudioDecoder::Init(const CFileItem& file, unsigned int filecache) { if (!Initialized()) return false; // for replaygain CTagLoaderTagLib tag; tag.Load(file.GetPath(), XFILE::CMusicFileDirectory::m_tag, NULL); int channels; int sampleRate; m_context = m_struct.toAddon.Init(file.GetPath().c_str(), filecache, &channels, &sampleRate, &m_bitsPerSample, &m_TotalTime, &m_bitRate, &m_format.m_dataFormat, &m_channel); m_format.m_sampleRate = sampleRate; if (m_channel) m_format.m_channelLayout = CAEChannelInfo(m_channel); else m_format.m_channelLayout = CAEUtil::GuessChLayout(channels); return (m_context != NULL); }
bool CPVRManager::PlayMedia(const CFileItem& item) { if (!g_PVRManager.IsStarted()) { CLog::Log(LOGERROR, "CApplication - %s PVR manager not started to play file '%s'", __FUNCTION__, item.GetPath().c_str()); return false; } CFileItem pvrItem(item); if (URIUtils::IsPVRChannel(item.GetPath()) && !item.HasPVRChannelInfoTag()) pvrItem = *g_PVRChannelGroups->GetByPath(item.GetPath()); else if (URIUtils::IsPVRRecording(item.GetPath()) && !item.HasPVRRecordingInfoTag()) pvrItem = *g_PVRRecordings->GetByPath(item.GetPath()); if (!pvrItem.HasPVRChannelInfoTag() && !pvrItem.HasPVRRecordingInfoTag()) return false; // check parental lock if we want to play a channel if (pvrItem.IsPVRChannel() && !g_PVRManager.CheckParentalLock(pvrItem.GetPVRChannelInfoTag())) return false; if (!g_application.IsCurrentThread()) { CFileItemList *l = new CFileItemList; //don't delete, l->Add(std::make_shared<CFileItem>(pvrItem)); CApplicationMessenger::GetInstance().PostMsg(TMSG_MEDIA_PLAY, -1, -1, static_cast<void*>(l)); return true; } return g_application.PlayFile(pvrItem, "videoplayer", false) == PLAYBACK_OK; }
CPVRClientPtr CPVRManager::GetClient(const CFileItem &item) const { int iClientID = PVR_INVALID_CLIENT_ID; if (item.HasPVRChannelInfoTag()) iClientID = item.GetPVRChannelInfoTag()->ClientID(); else if (item.HasPVRRecordingInfoTag()) iClientID = item.GetPVRRecordingInfoTag()->m_iClientId; else if (item.HasPVRTimerInfoTag()) iClientID = item.GetPVRTimerInfoTag()->m_iClientId; else if (item.HasEPGInfoTag()) iClientID = item.GetEPGInfoTag()->ClientID(); else if (URIUtils::IsPVRChannel(item.GetPath())) { const std::shared_ptr<CFileItem> channelItem = m_channelGroups->GetByPath(item.GetPath()); if (channelItem) iClientID = channelItem->GetPVRChannelInfoTag()->ClientID(); } else if (URIUtils::IsPVRRecording(item.GetPath())) { const std::shared_ptr<CFileItem> recordingItem = m_recordings->GetByPath(item.GetPath()); if (recordingItem) iClientID = recordingItem->GetPVRRecordingInfoTag()->ClientID(); } return GetClient(iClientID); }
void CPlayerSelectionRule::GetPlayers(const CFileItem& item, VECPLAYERCORES &vecCores) { CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: considering rule: %s", m_name.c_str()); if (m_bStreamDetails && !item.HasVideoInfoTag()) return; if (m_tAudio >= 0 && (m_tAudio > 0) != item.IsAudio()) return; if (m_tVideo >= 0 && (m_tVideo > 0) != item.IsVideo()) return; if (m_tInternetStream >= 0 && (m_tInternetStream > 0) != item.IsInternetStream()) return; if (m_tDVD >= 0 && (m_tDVD > 0) != item.IsDVD()) return; if (m_tDVDFile >= 0 && (m_tDVDFile > 0) != item.IsDVDFile()) return; if (m_tDVDImage >= 0 && (m_tDVDImage > 0) != item.IsDVDImage()) return; CRegExp regExp; if (m_bStreamDetails) { if (!item.GetVideoInfoTag()->HasStreamDetails()) { CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: cannot check rule: %s, no StreamDetails", m_name.c_str()); return; } CStreamDetails streamDetails = item.GetVideoInfoTag()->m_streamDetails; if (CompileRegExp(m_audioCodec, regExp) && !MatchesRegExp(streamDetails.GetAudioCodec(), regExp)) return; if (CompileRegExp(m_videoCodec, regExp) && !MatchesRegExp(streamDetails.GetVideoCodec(), regExp)) return; if (CompileRegExp(m_videoResolution, regExp) && !MatchesRegExp(CStreamDetails::VideoDimsToResolutionDescription(streamDetails.GetVideoWidth(), streamDetails.GetVideoHeight()), regExp)) return; if (CompileRegExp(m_videoAspect, regExp) && !MatchesRegExp(CStreamDetails::VideoAspectToAspectDescription(streamDetails.GetVideoAspect()), regExp)) return; } CURL url(item.GetPath()); if (CompileRegExp(m_fileTypes, regExp) && !MatchesRegExp(url.GetFileType(), regExp)) return; if (CompileRegExp(m_protocols, regExp) && !MatchesRegExp(url.GetProtocol(), regExp)) return; if (CompileRegExp(m_mimeTypes, regExp) && !MatchesRegExp(item.GetMimeType(), regExp)) return; if (CompileRegExp(m_fileName, regExp) && !MatchesRegExp(item.GetPath(), regExp)) return; CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: matches rule: %s", m_name.c_str()); for (unsigned int i = 0; i < vecSubRules.size(); i++) vecSubRules[i]->GetPlayers(item, vecCores); PLAYERCOREID playerCoreId = GetPlayerCore(); if (playerCoreId != EPC_NONE) { CLog::Log(LOGDEBUG, "CPlayerSelectionRule::GetPlayers: adding player: %s (%d) for rule: %s", m_playerName.c_str(), playerCoreId, m_name.c_str()); vecCores.push_back(GetPlayerCore()); } }
void CActiveAEDSPDatabase::SetActiveDSPSettings(const CFileItem &item, const CAudioSettings &setting) { try { if (NULL == m_pDB.get()) return ; if (NULL == m_pDS.get()) return ; string strPath, strFileName; URIUtils::Split(item.GetPath(), strPath, strFileName); string strSQL = StringUtils::Format("select * from settings WHERE settings.strPath='%s' and settings.strFileName='%s'", strPath.c_str() , strFileName.c_str()); m_pDS->query( strSQL.c_str() ); if (m_pDS->num_rows() > 0) { m_pDS->close(); // update the item strSQL=PrepareSQL( "update settings set " "MasterStreamTypeSel=%i," "MasterStreamType=%i," "MasterBaseType=%i," "MasterModeId=%i," "WHERE settings.strPath='%s' and settings.strFileName='%s'\n", setting.m_MasterStreamTypeSel, setting.m_MasterStreamType, setting.m_MasterStreamBase, setting.m_MasterModes[setting.m_MasterStreamType][setting.m_MasterStreamBase], strPath.c_str(), strFileName.c_str()); m_pDS->exec(strSQL.c_str()); return ; } else { // add the items m_pDS->close(); strSQL= "INSERT INTO settings (" "id, " "strPath," "strFileName," "MasterStreamTypeSel," "MasterStreamType," "MasterBaseType," "MasterModeId) " "VALUES "; strSQL += PrepareSQL("(NULL,'%s','%s',%i,%i,%i,%i)", strPath.c_str(), strFileName.c_str(), setting.m_MasterStreamTypeSel, setting.m_MasterStreamType, setting.m_MasterStreamBase, setting.m_MasterModes[setting.m_MasterStreamType][setting.m_MasterStreamBase]); m_pDS->exec(strSQL.c_str()); } } catch (...) { CLog::Log(LOGERROR, "%s (%s) failed", __FUNCTION__, item.GetPath().c_str()); } }
void CPlayerCoreFactory::GetPlayers(const CFileItem& item, std::vector<std::string>&players) const { CURL url(item.GetPath()); CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers(%s)", CURL::GetRedacted(item.GetPath()).c_str()); std::vector<std::string>validPlayers; GetPlayers(validPlayers); // Process rules for (auto rule: m_vecCoreSelectionRules) rule->GetPlayers(item, validPlayers, players); CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: matched {0} rules with players", players.size()); // Process defaults // Set video default player. Check whether it's video first (overrule audio and // game check). Also push these players in case it is NOT audio or game either. if (item.IsVideo() || (!item.IsAudio() && !item.IsGame())) { int idx = GetPlayerIndex("videodefaultplayer"); if (idx > -1) { std::string eVideoDefault = GetPlayerName(idx); CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: adding videodefaultplayer (%s)", eVideoDefault.c_str()); players.push_back(eVideoDefault); } GetPlayers(players, false, true); // Video-only players GetPlayers(players, true, true); // Audio & video players } // Set audio default player // Pushback all audio players in case we don't know the type if (item.IsAudio()) { int idx = GetPlayerIndex("audiodefaultplayer"); if (idx > -1) { std::string eAudioDefault = GetPlayerName(idx); CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: adding audiodefaultplayer (%s)", eAudioDefault.c_str()); players.push_back(eAudioDefault); } GetPlayers(players, true, false); // Audio-only players GetPlayers(players, true, true); // Audio & video players } if (item.IsGame()) { CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: adding retroplayer"); players.push_back("RetroPlayer"); } CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers: added {0} players", players.size()); }
bool CGameClient::OpenFile(const CFileItem& file, IGameAudioCallback* audio, IGameVideoCallback* video, IGameInputCallback *input) { if (audio == nullptr || video == nullptr) return false; // Check if we should open in standalone mode if (file.GetPath().empty()) return false; // Some cores "succeed" to load the file even if it doesn't exist if (!XFILE::CFile::Exists(file.GetPath())) { // Failed to play game // The required files can't be found. HELPERS::ShowOKDialogText(CVariant{ 35210 }, CVariant{ g_localizeStrings.Get(35219) }); return false; } // Resolve special:// URLs CURL translatedUrl(CSpecialProtocol::TranslatePath(file.GetPath())); // Remove file:// from URLs if add-on doesn't support VFS if (!m_bSupportsVFS) { if (translatedUrl.GetProtocol() == "file") translatedUrl.SetProtocol(""); } std::string path = translatedUrl.Get(); CLog::Log(LOGDEBUG, "GameClient: Loading %s", CURL::GetRedacted(path).c_str()); CSingleLock lock(m_critSection); if (!Initialized()) return false; CloseFile(); GAME_ERROR error = GAME_ERROR_FAILED; try { LogError(error = m_struct.toAddon.LoadGame(path.c_str()), "LoadGame()"); } catch (...) { LogException("LoadGame()"); } if (error != GAME_ERROR_NO_ERROR) { NotifyError(error); return false; } if (!InitializeGameplay(file.GetPath(), audio, video, input)) return false; return true; }
bool MarkWatched(const CFileItem& item, const bool watched) { if (watched) { CFileItem temp(item); temp.SetProperty("original_listitem_url", item.GetPath()); return SaveFileState(temp, CBookmark(), watched); } else { CLog::Log(LOGDEBUG, "UPNP: Marking video item %s as watched", item.GetPath().c_str()); return InvokeUpdateObject(item.GetPath().c_str(), "<upnp:playCount>1</upnp:playCount>", "<upnp:playCount>0</upnp:playCount>"); } }
bool PAPlayer::QueueNextFile(const CFileItem &file, bool checkCrossFading) { if (IsPaused()) Pause(); if (file.GetPath() == m_currentFile->GetPath() && file.m_lStartOffset > 0 && file.m_lStartOffset == m_currentFile->m_lEndOffset) { // continuing on a .cue sheet item - return true to say we'll handle the transistion *m_nextFile = file; return true; } // check if we can handle this file at all int decoder = 1 - m_currentDecoder; int64_t seekOffset = (file.m_lStartOffset * 1000) / 75; if (!m_decoder[decoder].Create(file, seekOffset, m_crossFading)) { m_bQueueFailed = true; return false; } // ok, we're good to go on queuing this one up CLog::Log(LOGINFO, "PAPlayer: Queuing next file %s", file.GetPath().c_str()); m_bQueueFailed = false; if (checkCrossFading) { UpdateCrossFadingTime(file); } unsigned int channels, samplerate, bitspersample; m_decoder[decoder].GetDataFormat(&channels, &samplerate, &bitspersample); // check the number of channels isn't changing (else we can't do crossfading) if (m_crossFading && m_decoder[m_currentDecoder].GetChannels() == channels) { // crossfading - need to create a new stream if (!CreateStream(1 - m_currentStream, channels, samplerate, bitspersample)) { m_decoder[decoder].Destroy(); CLog::Log(LOGERROR, "PAPlayer::Unable to create audio stream"); } } else { // no crossfading if nr of channels is not the same m_crossFading = 0; } *m_nextFile = file; return true; }
bool CGUIDialogPlayEject::ShowAndGetInput(const CFileItem & item, unsigned int uiAutoCloseTime /* = 0 */) { // Make sure we're actually dealing with a Disc Stub if (!item.IsDiscStub()) return false; // Create the dialog CGUIDialogPlayEject * pDialog = (CGUIDialogPlayEject *)g_windowManager. GetWindow(WINDOW_DIALOG_PLAY_EJECT); if (!pDialog) return false; // Figure out Line 1 of the dialog CStdString strLine1; if (item.GetVideoInfoTag()) { strLine1 = item.GetVideoInfoTag()->m_strTitle; } else { strLine1 = URIUtils::GetFileName(item.GetPath()); URIUtils::RemoveExtension(strLine1); } // Figure out Line 2 of the dialog CStdString strLine2; CXBMCTinyXML discStubXML; if (discStubXML.LoadFile(item.GetPath())) { TiXmlElement * pRootElement = discStubXML.RootElement(); if (!pRootElement || strcmpi(pRootElement->Value(), "discstub") != 0) CLog::Log(LOGERROR, "Error loading %s, no <discstub> node", item.GetPath().c_str()); else XMLUtils::GetString(pRootElement, "message", strLine2); } // Setup dialog parameters pDialog->SetHeading(219); pDialog->SetLine(0, 429); pDialog->SetLine(1, strLine1); pDialog->SetLine(2, strLine2); pDialog->SetChoice(ID_BUTTON_PLAY - 10, 208); pDialog->SetChoice(ID_BUTTON_EJECT - 10, 13391); if (uiAutoCloseTime) pDialog->SetAutoClose(uiAutoCloseTime); // Display the dialog pDialog->DoModal(); return pDialog->IsConfirmed(); }
CStdString CThumbnailCache::GetVideoThumb(const CFileItem &item) { if (item.IsStack()) return GetThumb(CStackDirectory::GetFirstStackedFile(item.GetPath()), g_settings.GetVideoThumbFolder(), true); else if (item.IsVideoDb() && item.HasVideoInfoTag()) { if (item.m_bIsFolder && !item.GetVideoInfoTag()->m_strPath.IsEmpty()) return GetThumb(item.GetVideoInfoTag()->m_strPath, g_settings.GetVideoThumbFolder(), true); else if (!item.GetVideoInfoTag()->m_strFileNameAndPath.IsEmpty()) return GetThumb(item.GetVideoInfoTag()->m_strFileNameAndPath, g_settings.GetVideoThumbFolder(), true); } return GetThumb(item.GetPath(), g_settings.GetVideoThumbFolder(), true); }
bool CInputStream::Supports(CFileItem &fileitem) { std::string extension = URIUtils::GetExtension(fileitem.GetPath()); bool match = false; for (auto &ext : m_extensionsList) { if (ext == extension) { match = true; break; } } if (!match) return false; if (!m_pStruct) return true; std::string pathList; try { pathList = m_pStruct->GetPathList(); } catch (std::exception &e) { return false; } m_pathList = StringUtils::Tokenize(pathList, "|"); for (auto &path : m_pathList) { StringUtils::Trim(path); } match = false; for (auto &path : m_pathList) { if (path.empty()) continue; if (fileitem.GetPath().compare(0, path.length(), path) == 0) { match = true; break; } } if (!match) return false; return true; }
bool CActiveAEDSPDatabase::GetActiveDSPSettings(const CFileItem &item, CAudioSettings &settings) { try { if (NULL == m_pDB.get()) return false; if (NULL == m_pDS.get()) return false; string strPath, strFileName; URIUtils::Split(item.GetPath(), strPath, strFileName); string strSQL=PrepareSQL("SELECT * FROM settings WHERE settings.strPath='%s' and settings.strFileName='%s'", strPath.c_str() , strFileName.c_str()); m_pDS->query( strSQL.c_str() ); if (m_pDS->num_rows() > 0) { // get the audio dsp settings info settings.m_MasterStreamTypeSel = m_pDS->fv("MasterStreamTypeSel").get_asInt(); int type = m_pDS->fv("MasterStreamType").get_asInt(); int base = m_pDS->fv("MasterBaseType").get_asInt(); settings.m_MasterStreamType = type; settings.m_MasterStreamBase = base; settings.m_MasterModes[type][base] = m_pDS->fv("MasterModeId").get_asInt(); /*! if auto mode is selected, copy the identifier of previous used processor to the auto mode entry */ settings.m_MasterModes[settings.m_MasterStreamTypeSel][base] = settings.m_MasterModes[type][base]; m_pDS->close(); return true; } m_pDS->close(); } catch (...) { CLog::Log(LOGERROR, "%s failed", __FUNCTION__); } return false; }
bool CGUIMultiImage::CMultiImageJob::DoWork() { // check to see if we have a single image or a folder of images CFileItem item(m_path, false); item.FillInMimeType(); if (item.IsPicture() || StringUtils::StartsWithNoCase(item.GetMimeType(), "image/")) { m_files.push_back(m_path); } else { // Load in images from the directory specified // m_path is relative (as are all skin paths) std::string realPath = CServiceBroker::GetGUI()->GetTextureManager().GetTexturePath(m_path, true); if (realPath.empty()) return true; URIUtils::AddSlashAtEnd(realPath); CFileItemList items; CDirectory::GetDirectory(realPath, items, CServiceBroker::GetFileExtensionProvider().GetPictureExtensions()+ "|.tbn|.dds", DIR_FLAG_NO_FILE_DIRS | DIR_FLAG_NO_FILE_INFO); for (int i=0; i < items.Size(); i++) { CFileItem* pItem = items[i].get(); if (pItem && (pItem->IsPicture() || StringUtils::StartsWithNoCase(pItem->GetMimeType(), "image/"))) m_files.push_back(pItem->GetPath()); } } return true; }
bool CPlayListFactory::IsPlaylist(const CFileItem& item) { CStdString strMimeType = item.GetMimeType(); strMimeType.ToLower(); /* These are abit uncertain if(strMimeType == "video/x-ms-asf" || strMimeType == "video/x-ms-asx" || strMimeType == "video/x-ms-wmv" || strMimeType == "video/x-ms-wma" || strMimeType == "video/x-ms-wfs" || strMimeType == "video/x-ms-wvx" || strMimeType == "video/x-ms-wax" || strMimeType == "video/x-ms-asf") return true; */ // online m3u8 files are hls:// -- do not treat as playlist if (item.IsInternetStream() && item.IsType(".m3u8")) return false; if(strMimeType == "audio/x-pn-realaudio" || strMimeType == "playlist" || strMimeType == "audio/x-mpegurl") return true; return IsPlaylist(item.GetPath()); }
void CVideoThumbLoader::DetectAndAddMissingItemData(CFileItem &item) { if (item.m_bIsFolder) return; std::string stereoMode; // detect stereomode for videos if (item.HasVideoInfoTag()) stereoMode = item.GetVideoInfoTag()->m_streamDetails.GetStereoMode(); if (stereoMode.empty()) { std::string path = item.GetPath(); if (item.IsVideoDb() && item.HasVideoInfoTag()) path = item.GetVideoInfoTag()->GetPath(); // check for custom stereomode setting in video settings CVideoSettings itemVideoSettings; m_videoDatabase->Open(); if (m_videoDatabase->GetVideoSettings(path, itemVideoSettings) && itemVideoSettings.m_StereoMode != RENDER_STEREO_MODE_OFF) stereoMode = CStereoscopicsManager::Get().ConvertGuiStereoModeToString( (RENDER_STEREO_MODE) itemVideoSettings.m_StereoMode ); m_videoDatabase->Close(); // still empty, try grabbing from filename // TODO: in case of too many false positives due to using the full path, extract the filename only using string utils if (stereoMode.empty()) stereoMode = CStereoscopicsManager::Get().DetectStereoModeByString( path ); } if (!stereoMode.empty()) item.SetProperty("stereomode", CStereoscopicsManager::Get().NormalizeStereoMode(stereoMode)); }
bool CVideoThumbLoader::FillThumb(CFileItem &item) { if (item.HasArt("thumb")) return true; std::string thumb = GetCachedImage(item, "thumb"); if (thumb.empty()) { thumb = GetLocalArt(item, "thumb"); if (!thumb.empty()) SetCachedImage(item, "thumb", thumb); } if (!thumb.empty()) item.SetArt("thumb", thumb); else { // If nothing was found, try embedded art if (item.HasVideoInfoTag() && !item.GetVideoInfoTag()->m_coverArt.empty()) { for (auto& it : item.GetVideoInfoTag()->m_coverArt) { if (it.m_type == "thumb") { thumb = CTextureUtils::GetWrappedImageURL(item.GetPath(), "video_" + it.m_type); item.SetArt(it.m_type, thumb); } } } } return !thumb.empty(); }
CStdString CThumbLoader::GetCachedImage(const CFileItem &item, const CStdString &type) { CTextureDatabase db; if (db.Open()) return db.GetTextureForPath(item.GetPath(), type); return ""; }
CStdString CProgramThumbLoader::GetLocalThumb(const CFileItem &item) { // look for the thumb if (item.IsShortCut()) { CShortcut shortcut; if ( shortcut.Create( item.GetPath() ) ) { // use the shortcut's thumb if (!shortcut.m_strThumb.IsEmpty()) return shortcut.m_strThumb; else { CFileItem cut(shortcut.m_strPath,false); if (FillThumb(cut)) return cut.GetThumbnailImage(); } } } else if (item.m_bIsFolder) { CStdString folderThumb = item.GetFolderThumb(); if (XFILE::CFile::Exists(folderThumb)) return folderThumb; } else { CStdString fileThumb(item.GetTBNFile()); if (CFile::Exists(fileThumb)) return fileThumb; } return ""; }
CStdString CThumbLoader::GetCachedThumb(const CFileItem &item) { CTextureDatabase db; if (db.Open()) return db.GetTextureForPath(item.GetPath()); return ""; }
std::string CVideoThumbLoader::GetLocalArt(const CFileItem &item, const std::string &type, bool checkFolder) { /* Cache directory for (sub) folders on streamed filesystems. We need to do this else entering (new) directories from the app thread becomes much slower. This is caused by the fact that Curl Stat/Exist() is really slow and that the thumbloader thread accesses the streamed filesystem at the same time as the App thread and the latter has to wait for it. */ if (item.m_bIsFolder && (item.IsInternetStream(true) || g_advancedSettings.m_networkBufferMode == 1)) { CFileItemList items; // Dummy list CDirectory::GetDirectory(item.GetPath(), items, "", DIR_FLAG_NO_FILE_DIRS | DIR_FLAG_READ_CACHE | DIR_FLAG_NO_FILE_INFO); } std::string art; if (!type.empty()) { art = item.FindLocalArt(type + ".jpg", checkFolder); if (art.empty()) art = item.FindLocalArt(type + ".png", checkFolder); } if (art.empty() && (type.empty() || type == "thumb")) { // backward compatibility art = item.FindLocalArt("", false); if (art.empty() && (checkFolder || (item.m_bIsFolder && !item.IsFileFolder()) || item.IsOpticalMediaFile())) { // try movie.tbn art = item.FindLocalArt("movie.tbn", true); if (art.empty()) // try folder.jpg art = item.FindLocalArt("folder.jpg", true); } } return art; }
CSong::CSong(CFileItem& item) { CMusicInfoTag& tag = *item.GetMusicInfoTag(); SYSTEMTIME stTime; tag.GetReleaseDate(stTime); strTitle = tag.GetTitle(); genre = tag.GetGenre(); artist = tag.GetArtist(); strAlbum = tag.GetAlbum(); albumArtist = tag.GetAlbumArtist(); strMusicBrainzTrackID = tag.GetMusicBrainzTrackID(); strComment = tag.GetComment(); rating = tag.GetRating(); iYear = stTime.wYear; iTrack = tag.GetTrackAndDiskNumber(); iDuration = tag.GetDuration(); bCompilation = tag.GetCompilation(); embeddedArt = tag.GetCoverArtInfo(); strFileName = tag.GetURL().IsEmpty() ? item.GetPath() : tag.GetURL(); strThumb = item.GetUserMusicThumb(true); iStartOffset = item.m_lStartOffset; iEndOffset = item.m_lEndOffset; idSong = -1; iTimesPlayed = 0; iKaraokeNumber = 0; iKaraokeDelay = 0; //! Karaoke song lyrics-music delay in 1/10 seconds. idAlbum = -1; }
bool CGUIMultiImage::CMultiImageJob::DoWork() { // check to see if we have a single image or a folder of images CFileItem item(m_path, false); item.FillInMimeType(); if (item.IsPicture() || item.GetMimeType().Left(6).Equals("image/")) { m_files.push_back(m_path); } else { // Load in images from the directory specified // m_path is relative (as are all skin paths) CStdString realPath = g_TextureManager.GetTexturePath(m_path, true); if (realPath.IsEmpty()) return true; URIUtils::AddSlashAtEnd(realPath); CFileItemList items; CDirectory::GetDirectory(realPath, items, g_advancedSettings.m_pictureExtensions + "|.tbn|.dds", DIR_FLAG_NO_FILE_DIRS | DIR_FLAG_NO_FILE_INFO); for (int i=0; i < items.Size(); i++) { CFileItem* pItem = items[i].get(); if (pItem && (pItem->IsPicture() || pItem->GetMimeType().Left(6).Equals("image/"))) m_files.push_back(pItem->GetPath()); } } return true; }
bool CInputStream::Supports(const CFileItem &fileitem) { // check if a specific inputstream addon is requested CVariant addon = fileitem.GetProperty("inputstreamaddon"); if (!addon.isNull()) { if (addon.asString() != ID()) return false; else return true; } // check paths CSingleLock lock(m_parentSection); bool match = false; for (auto &path : m_pathList) { if (path.empty()) continue; CRegExp r(true, CRegExp::asciiOnly, path.c_str()); if (r.RegFind(fileitem.GetPath().c_str()) == 0 && r.GetFindLen() > 5) { match = true; break; } } return match; }
bool CInputStream::Open(CFileItem &fileitem) { INPUTSTREAM props; std::map<std::string, std::string> propsMap; for (auto &key : m_fileItemProps) { if (fileitem.GetProperty(key).isNull()) continue; propsMap[key] = fileitem.GetProperty(key).asString(); } props.m_nCountInfoValues = 0; for (auto &pair : propsMap) { props.m_ListItemProperties[props.m_nCountInfoValues].m_strKey = pair.first.c_str(); props.m_ListItemProperties[props.m_nCountInfoValues].m_strValue = pair.second.c_str(); props.m_nCountInfoValues++; } props.m_strURL = fileitem.GetPath().c_str(); std::string libFolder = URIUtils::GetDirectory(m_parentLib); std::string profileFolder = CSpecialProtocol::TranslatePath(Profile()); props.m_libFolder = libFolder.c_str(); props.m_profileFolder = profileFolder.c_str(); bool ret = m_pStruct->Open(props); if (ret) m_caps = m_pStruct->GetCapabilities(); UpdateStreams(); return ret; }
bool CInputStream::Open(CFileItem &fileitem) { INPUTSTREAM props; props.m_nCountInfoValues = 0; std::vector<std::string> values; for (auto &key : m_fileItemProps) { if (fileitem.GetProperty(key).isNull()) continue; props.m_ListItemProperties[props.m_nCountInfoValues].m_strKey = key.c_str(); values.push_back(fileitem.GetProperty(key).asString()); props.m_ListItemProperties[props.m_nCountInfoValues].m_strValue = values.back().c_str(); props.m_nCountInfoValues++; } props.m_strURL = fileitem.GetPath().c_str(); bool ret = false; try { ret = m_pStruct->Open(props); if (ret) m_caps = m_pStruct->GetCapabilities(); } catch (std::exception &e) { CLog::Log(LOGERROR, "CInputStream::Open - could not open stream. Reason: %s", e.what()); return false; } UpdateStreams(); return ret; }
bool CGUIDialogSimpleMenu::ShowPlaySelection(CFileItem& item) { /* if asked to resume somewhere, we should not show anything */ if (item.m_lStartOffset || (item.HasVideoInfoTag() && item.GetVideoInfoTag()->m_iBookmarkId > 0)) return true; if (CSettings::GetInstance().GetInt(CSettings::SETTING_DISC_PLAYBACK) != BD_PLAYBACK_SIMPLE_MENU) return true; std::string path; if (item.IsVideoDb()) path = item.GetVideoInfoTag()->m_strFileNameAndPath; else path = item.GetPath(); if (item.IsBDFile()) { std::string root = URIUtils::GetParentPath(path); URIUtils::RemoveSlashAtEnd(root); if (URIUtils::GetFileName(root) == "BDMV") { CURL url("bluray://"); url.SetHostName(URIUtils::GetParentPath(root)); url.SetFileName("root"); return ShowPlaySelection(item, url.Get()); } } if (item.IsDiscImage()) { CURL url2("udf://"); url2.SetHostName(item.GetPath()); url2.SetFileName("BDMV/index.bdmv"); if (XFILE::CFile::Exists(url2.Get())) { url2.SetFileName(""); CURL url("bluray://"); url.SetHostName(url2.Get()); url.SetFileName("root"); return ShowPlaySelection(item, url.Get()); } } return true; }