void CDVDSubtitleTagSami::ConvertLine(CDVDOverlayText* pOverlay, const char* line, int len, const char* lang) { CStdStringA strUTF8; strUTF8.assign(line, len); StringUtils::Trim(strUTF8); int pos = 0; int del_start = 0; while ((pos=m_tags->RegFind(strUTF8.c_str(), pos)) >= 0) { // Parse Tags CStdString fullTag = m_tags->GetMatch(0); StringUtils::ToLower(fullTag); strUTF8.erase(pos, fullTag.length()); if (fullTag == "<b>" || fullTag == "{\\b1}") { m_flag[FLAG_BOLD] = true; strUTF8.insert(pos, "[B]"); pos += 3; } else if ((fullTag == "</b>" || fullTag == "{\\b0}") && m_flag[FLAG_BOLD]) { m_flag[FLAG_BOLD] = false; strUTF8.insert(pos, "[/B]"); pos += 4; } else if (fullTag == "<i>" || fullTag == "{\\i1}") { m_flag[FLAG_ITALIC] = true; strUTF8.insert(pos, "[I]"); pos += 3; } else if ((fullTag == "</i>" || fullTag == "{\\i0}") && m_flag[FLAG_ITALIC]) { m_flag[FLAG_ITALIC] = false; strUTF8.insert(pos, "[/I]"); pos += 4; } else if ((fullTag == "</font>" || fullTag == "{\\c}") && m_flag[FLAG_COLOR]) { m_flag[FLAG_COLOR] = false; strUTF8.insert(pos, "[/COLOR]"); pos += 8; } else if (StringUtils::StartsWith(fullTag, "{\\c&h") || StringUtils::StartsWith(fullTag, "{\\1c&h")) { m_flag[FLAG_COLOR] = true; CStdString tempColorTag = "[COLOR FF"; CStdString tagOptionValue; if (StringUtils::StartsWith(fullTag, "{\\c&h")) tagOptionValue = fullTag.substr(5,6); else tagOptionValue = fullTag.substr(6,6); tempColorTag += tagOptionValue.substr(4,2); tempColorTag += tagOptionValue.substr(2,2); tempColorTag += tagOptionValue.substr(0,2); tempColorTag += "]"; strUTF8.insert(pos, tempColorTag); pos += tempColorTag.length(); } else if (StringUtils::StartsWith(fullTag, "<font")) { int pos2 = 5; while ((pos2 = m_tagOptions->RegFind(fullTag.c_str(), pos2)) >= 0) { CStdString tagOptionName = m_tagOptions->GetMatch(1); CStdString tagOptionValue = m_tagOptions->GetMatch(2); pos2 += tagOptionName.length() + tagOptionValue.length(); if (tagOptionName == "color") { m_flag[FLAG_COLOR] = true; CStdString tempColorTag = "[COLOR "; if (tagOptionValue[0] == '#') { tagOptionValue.erase(0, 1); tempColorTag += "FF"; } else if( tagOptionValue.size() == 6 ) { bool bHex = true; for( int i=0 ; i<6 ; i++ ) { char temp = tagOptionValue[i]; if( !(('0' <= temp && temp <= '9') || ('a' <= temp && temp <= 'f') || ('A' <= temp && temp <= 'F') )) { bHex = false; break; } } if( bHex ) tempColorTag += "FF"; } tempColorTag += tagOptionValue; tempColorTag += "]"; strUTF8.insert(pos, tempColorTag); pos += tempColorTag.length(); } } } else if (lang && (StringUtils::StartsWith(fullTag, "<p "))) { int pos2 = 3; while ((pos2 = m_tagOptions->RegFind(fullTag.c_str(), pos2)) >= 0) { CStdString tagOptionName = m_tagOptions->GetMatch(1); CStdString tagOptionValue = m_tagOptions->GetMatch(2); pos2 += tagOptionName.length() + tagOptionValue.length(); if (tagOptionName == "class") { if (m_flag[FLAG_LANGUAGE]) { strUTF8.erase(del_start, pos - del_start); pos = del_start; } if (!tagOptionValue.compare(lang)) { m_flag[FLAG_LANGUAGE] = false; } else { m_flag[FLAG_LANGUAGE] = true; del_start = pos; } break; } } } else if (fullTag == "</p>" && m_flag[FLAG_LANGUAGE]) { strUTF8.erase(del_start, pos - del_start); pos = del_start; m_flag[FLAG_LANGUAGE] = false; } else if (fullTag == "<br>" && !strUTF8.empty()) { strUTF8.insert(pos, "\n"); pos += 1; } } if(m_flag[FLAG_LANGUAGE]) strUTF8.erase(del_start); if (strUTF8.empty()) return; if( strUTF8[strUTF8.size()-1] == '\n' ) strUTF8.erase(strUTF8.size()-1); // add a new text element to our container pOverlay->AddElement(new CDVDOverlayText::CElementText(strUTF8.c_str())); }
/** * Look for a thumbnail for pItem. If one does not exist, look for an autogenerated * thumbnail. If that does not exist, attempt to autogenerate one. Finally, check * for the existance of fanart and set properties accordingly. * @return: true if pItem has been modified */ bool CVideoThumbLoader::LoadItem(CFileItem* pItem) { if (pItem->m_bIsShareOrDrive || pItem->IsParentFolder()) return false; m_database->Open(); 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->HasArt("thumb")) { FillLibraryArt(*pItem); if (!pItem->GetVideoInfoTag()->m_type.empty() && pItem->GetVideoInfoTag()->m_type != "movie" && pItem->GetVideoInfoTag()->m_type != "tvshow" && pItem->GetVideoInfoTag()->m_type != "episode" && pItem->GetVideoInfoTag()->m_type != "musicvideo") { m_database->Close(); return true; // nothing else to be done } } // if we have no art, look for it all map<string, string> artwork = pItem->GetArt(); if (artwork.empty()) { vector<string> artTypes = GetArtTypes(pItem->HasVideoInfoTag() ? pItem->GetVideoInfoTag()->m_type : ""); if (find(artTypes.begin(), artTypes.end(), "thumb") == artTypes.end()) artTypes.push_back("thumb"); // always look for "thumb" art for files for (vector<string>::const_iterator i = artTypes.begin(); i != artTypes.end(); ++i) { std::string type = *i; std::string art = GetCachedImage(*pItem, type); if (art.empty()) { art = GetLocalArt(*pItem, type, type=="fanart"); if (!art.empty()) // cache it SetCachedImage(*pItem, type, art); } if (!art.empty()) { CTextureCache::Get().BackgroundCacheImage(art); artwork.insert(make_pair(type, art)); } } SetArt(*pItem, artwork); } // thumbnails are special-cased due to auto-generation if (!pItem->m_bIsFolder && pItem->IsVideo()) { // An auto-generated thumb may have been cached on a different device - check we have it here CStdString url = pItem->GetArt("thumb"); if (url.compare(0, 14, "image://video@") == 0 && !CTextureCache::Get().HasCachedImage(url)) pItem->SetArt("thumb", ""); if (!pItem->HasArt("thumb")) { // create unique thumb for auto generated thumbs CStdString thumbURL = GetEmbeddedThumbURL(*pItem); if (CTextureCache::Get().HasCachedImage(thumbURL)) { CTextureCache::Get().BackgroundCacheImage(thumbURL); pItem->SetProperty("HasAutoThumb", true); pItem->SetProperty("AutoThumbImage", thumbURL); pItem->SetArt("thumb", thumbURL); // Item has cached autogen image but no art entry. Save it to db. CVideoInfoTag* info = pItem->GetVideoInfoTag(); if (info->m_iDbId > 0 && !info->m_type.empty()) m_database->SetArtForItem(info->m_iDbId, info->m_type, "thumb", thumbURL); } else if (g_guiSettings.GetBool("myvideos.extractthumb") && g_guiSettings.GetBool("myvideos.extractflags")) { CFileItem item(*pItem); CStdString path(item.GetPath()); if (URIUtils::IsInRAR(item.GetPath())) SetupRarOptions(item,path); CThumbExtractor* extract = new CThumbExtractor(item, path, true, thumbURL); AddJob(extract); m_database->Close(); return true; } } } // flag extraction if (!pItem->m_bIsFolder && pItem->HasVideoInfoTag() && g_guiSettings.GetBool("myvideos.extractflags") && (!pItem->GetVideoInfoTag()->HasStreamDetails() || pItem->GetVideoInfoTag()->m_streamDetails.GetVideoDuration() <= 0)) { CFileItem item(*pItem); CStdString path(item.GetPath()); if (URIUtils::IsInRAR(item.GetPath())) SetupRarOptions(item,path); CThumbExtractor* extract = new CThumbExtractor(item,path,false); AddJob(extract); } m_database->Close(); return true; }
ADDON_STATUS ADDON_SetSetting(const char *settingName, const void *settingValue) { // SetSetting can occur when the addon is enabled, but TV support still // disabled. In that case the addon is not loaded, so we should not try // to change its settings. if (!XBMC) return ADDON_STATUS_OK; CStdString sname(settingName); if (sname == "host") { if (g_strHostname.compare((const char *)settingValue) != 0) return ADDON_STATUS_NEED_RESTART; } else if (sname == "user") { if (g_strUsername.compare((const char *)settingValue) != 0) return ADDON_STATUS_NEED_RESTART; } else if (sname == "pass") { if (g_strPassword.compare((const char *)settingValue) != 0) return ADDON_STATUS_NEED_RESTART; } else if (sname == "streamport") { if (g_iPortStream != *(int *)settingValue) return ADDON_STATUS_NEED_RESTART; } else if (sname == "webport") { if (g_iPortWeb != *(int *)settingValue) return ADDON_STATUS_NEED_RESTART; } else if (sname == "recordingport") { if (g_iPortRecording != *(int *)settingValue) return ADDON_STATUS_NEED_RESTART; } else if (sname == "usefavourites") { if (g_bUseFavourites != *(bool *)settingValue) return ADDON_STATUS_NEED_RESTART; } else if (sname == "favouritespath") { if (g_strFavouritesPath.compare((const char *)settingValue) != 0) return ADDON_STATUS_NEED_RESTART; } else if (sname == "usetimeshift") { bool newValue = *(bool *)settingValue; if (g_bUseTimeshift != newValue) { XBMC->Log(LOG_DEBUG, "%s - Changed Setting '%s' from '%u' to '%u'", __FUNCTION__, settingName, g_bUseTimeshift, newValue); g_bUseTimeshift = newValue; } } else if (sname == "timeshiftpath") { CStdString newValue = (const char *)settingValue; if (g_strTimeshiftBufferPath != newValue) { XBMC->Log(LOG_DEBUG, "%s - Changed Setting '%s' from '%s' to '%s'", __FUNCTION__, settingName, g_strTimeshiftBufferPath.c_str(), newValue.c_str()); g_strTimeshiftBufferPath = newValue; } } return ADDON_STATUS_OK; }
bool CVideoReferenceClock::SetupGLX() { int singleBufferAttributes[] = { GLX_RGBA, GLX_RED_SIZE, 0, GLX_GREEN_SIZE, 0, GLX_BLUE_SIZE, 0, None }; int ReturnV, SwaMask; unsigned int GlxTest; XSetWindowAttributes Swa; m_vInfo = NULL; m_Context = NULL; m_Window = 0; m_pixmap = None; m_glPixmap = None; CLog::Log(LOGDEBUG, "CVideoReferenceClock: Setting up GLX"); if (!m_Dpy) { m_Dpy = XOpenDisplay(NULL); if (!m_Dpy) { CLog::Log(LOGDEBUG, "CVideoReferenceClock: Unable to open display"); return false; } } if (!glXQueryExtension(m_Dpy, NULL, NULL)) { CLog::Log(LOGDEBUG, "CVideoReferenceClock: X server does not support GLX"); return false; } bool ExtensionFound = false; istringstream Extensions(glXQueryExtensionsString(m_Dpy, g_Windowing.GetCurrentScreen())); string ExtensionStr; while (!ExtensionFound) { Extensions >> ExtensionStr; if (Extensions.fail()) break; if (ExtensionStr == "GLX_SGI_video_sync") ExtensionFound = true; } if (!ExtensionFound) { CLog::Log(LOGDEBUG, "CVideoReferenceClock: X server does not support GLX_SGI_video_sync"); return false; } CStdString Vendor = g_Windowing.GetRenderVendor(); Vendor.ToLower(); if (Vendor.compare(0, 3, "ati") == 0) { CLog::Log(LOGDEBUG, "CVideoReferenceClock: GL_VENDOR: %s, using ati workaround", Vendor.c_str()); m_bIsATI = true; } m_vInfo = glXChooseVisual(m_Dpy, g_Windowing.GetCurrentScreen(), singleBufferAttributes); if (!m_vInfo) { CLog::Log(LOGDEBUG, "CVideoReferenceClock: glXChooseVisual returned NULL"); return false; } if (!m_bIsATI) { Swa.border_pixel = 0; Swa.event_mask = StructureNotifyMask; Swa.colormap = XCreateColormap(m_Dpy, g_Windowing.GetWindow(), m_vInfo->visual, AllocNone ); SwaMask = CWBorderPixel | CWColormap | CWEventMask; m_Window = XCreateWindow(m_Dpy, g_Windowing.GetWindow(), 0, 0, 256, 256, 0, m_vInfo->depth, InputOutput, m_vInfo->visual, SwaMask, &Swa); } else { Window window = g_Windowing.GetWindow(); m_pixmap = XCreatePixmap(m_Dpy, window, 256, 256, m_vInfo->depth); if (!m_pixmap) { CLog::Log(LOGDEBUG, "CVideoReferenceClock: unable to create pixmap"); return false; } m_glPixmap = glXCreateGLXPixmap(m_Dpy, m_vInfo, m_pixmap); } m_Context = glXCreateContext(m_Dpy, m_vInfo, NULL, True); if (!m_Context) { CLog::Log(LOGDEBUG, "CVideoReferenceClock: glXCreateContext returned NULL"); return false; } if (!m_bIsATI) ReturnV = glXMakeCurrent(m_Dpy, m_Window, m_Context); else ReturnV = glXMakeCurrent(m_Dpy, m_glPixmap, m_Context); if (ReturnV != True) { CLog::Log(LOGDEBUG, "CVideoReferenceClock: glXMakeCurrent returned %i", ReturnV); return false; } if (!m_bIsATI) { m_glXWaitVideoSyncSGI = (int (*)(int, int, unsigned int*))glXGetProcAddress((const GLubyte*)"glXWaitVideoSyncSGI"); if (!m_glXWaitVideoSyncSGI) { CLog::Log(LOGDEBUG, "CVideoReferenceClock: glXWaitVideoSyncSGI not found"); return false; } ReturnV = m_glXWaitVideoSyncSGI(2, 0, &GlxTest); if (ReturnV) { CLog::Log(LOGDEBUG, "CVideoReferenceClock: glXWaitVideoSyncSGI returned %i", ReturnV); return false; } } m_glXGetVideoSyncSGI = (int (*)(unsigned int*))glXGetProcAddress((const GLubyte*)"glXGetVideoSyncSGI"); if (!m_glXGetVideoSyncSGI) { CLog::Log(LOGDEBUG, "CVideoReferenceClock: glXGetVideoSyncSGI not found"); return false; } ReturnV = m_glXGetVideoSyncSGI(&GlxTest); if (ReturnV) { CLog::Log(LOGDEBUG, "CVideoReferenceClock: glXGetVideoSyncSGI returned %i", ReturnV); return false; } XRRSizes(m_Dpy, m_vInfo->screen, &ReturnV); if (ReturnV == 0) { CLog::Log(LOGDEBUG, "CVideoReferenceClock: RandR not supported"); return false; } UpdateRefreshrate(true); //forced refreshrate update m_MissedVblanks = 0; return true; }
void SetFieldExclusionGroup(const CStdString& group) { Workshare::OptionApi::SetBool(L"ExcludeFieldCodesAuthor", (0 == group.compare(L"ExcludeFieldCodesAuthor"))); Workshare::OptionApi::SetBool(L"ExcludeFieldCodesAutomation", (0 == group.compare(L"ExcludeFieldCodesAutomation"))); Workshare::OptionApi::SetBool(L"ExcludeFieldCodesDocument", (0 == group.compare(L"ExcludeFieldCodesDocument"))); Workshare::OptionApi::SetBool(L"ExcludeFieldCodesFormFields", (0 == group.compare(L"ExcludeFieldCodesFormFields"))); Workshare::OptionApi::SetBool(L"ExcludeFieldCodesFormulas", (0 == group.compare(L"ExcludeFieldCodesFormulas"))); Workshare::OptionApi::SetBool(L"ExcludeFieldCodesHyperlinks", (0 == group.compare(L"ExcludeFieldCodesHyperlinks"))); Workshare::OptionApi::SetBool(L"ExcludeFieldCodesIncludeFields", (0 == group.compare(L"ExcludeFieldCodesIncludeFields"))); Workshare::OptionApi::SetBool(L"ExcludeFieldCodesLinks", (0 == group.compare(L"ExcludeFieldCodesLinks"))); Workshare::OptionApi::SetBool(L"ExcludeFieldCodesNumbering", (0 == group.compare(L"ExcludeFieldCodesNumbering"))); Workshare::OptionApi::SetBool(L"ExcludeFieldCodesReferences", (0 == group.compare(L"ExcludeFieldCodesReferences"))); Workshare::OptionApi::SetBool(L"ExcludeFieldCodesTables", (0 == group.compare(L"ExcludeFieldCodesTables"))); }