本文整理汇总了C++中XElement::GetString方法的典型用法代码示例。如果您正苦于以下问题:C++ XElement::GetString方法的具体用法?C++ XElement::GetString怎么用?C++ XElement::GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XElement
的用法示例。
在下文中一共展示了XElement::GetString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetElementByItem
XElement* XElement::GetElementByItem(CTSTR lpName, CTSTR lpItemName, CTSTR lpItemValue) const
{
assert(lpItemName);
assert(lpItemValue);
if(lpName)
{
for(DWORD i=0; i<SubItems.Num(); i++)
{
if(!SubItems[i]->IsElement()) continue;
XElement *element = static_cast<XElement*>(SubItems[i]);
if(element->strName.CompareI(lpName))
{
if(scmpi(element->GetString(lpItemName), lpItemValue) == 0)
return element;
}
}
}
else
{
for(DWORD i=0; i<SubItems.Num(); i++)
{
if(!SubItems[i]->IsElement()) continue;
XElement *element = static_cast<XElement*>(SubItems[i]);
if(scmpi(element->GetString(lpItemName), lpItemValue) == 0)
return element;
}
}
return NULL;
}
示例2: ConfigureBitmapSource
bool STDCALL ConfigureBitmapSource(XElement *element, bool bCreating)
{
if(!element)
{
AppWarning(TEXT("ConfigureBitmapSource: NULL element"));
return false;
}
XElement *data = element->GetElement(TEXT("data"));
if(!data)
data = element->CreateElement(TEXT("data"));
ConfigBitmapInfo configInfo;
configInfo.data = data;
if(DialogBoxParam(hinstMain, MAKEINTRESOURCE(IDD_CONFIGUREBITMAPSOURCE), hwndMain, ConfigureBitmapProc, (LPARAM)&configInfo) == IDOK)
{
CTSTR lpBitmap = data->GetString(TEXT("path"));
D3DX10_IMAGE_INFO ii;
if(SUCCEEDED(D3DX10GetImageInfoFromFile(lpBitmap, NULL, &ii, NULL)))
{
element->SetInt(TEXT("cx"), ii.Width);
element->SetInt(TEXT("cy"), ii.Height);
}
else
AppWarning(TEXT("ConfigureBitmapSource: could not get image info for bitmap '%s'"), lpBitmap);
return true;
}
return false;
}
示例3: AddGlobalSourceToScene
ImageSource* OBS::AddGlobalSourceToScene(CTSTR lpName)
{
XElement *globals = scenesConfig.GetElement(TEXT("global sources"));
if(globals)
{
XElement *globalSourceElement = globals->GetElement(lpName);
if(globalSourceElement)
{
CTSTR lpClass = globalSourceElement->GetString(TEXT("class"));
if(lpClass)
{
ImageSource *newGlobalSource = CreateImageSource(lpClass, globalSourceElement->GetElement(TEXT("data")));
if(newGlobalSource)
{
App->EnterSceneMutex();
GlobalSourceInfo *info = globalSources.CreateNew();
info->strName = lpName;
info->element = globalSourceElement;
info->source = newGlobalSource;
info->source->BeginScene();
App->LeaveSceneMutex();
return newGlobalSource;
}
}
}
}
AppWarning(TEXT("OBS::AddGlobalSourceToScene: Could not find global source '%s'"), lpName);
return NULL;
}
示例4: ConfigGlobalSource
bool STDCALL OBS::ConfigGlobalSource(XElement *element, bool bCreating)
{
XElement *data = element->GetElement(TEXT("data"));
CTSTR lpGlobalSourceName = data->GetString(TEXT("name"));
XElement *globalSources = App->scenesConfig.GetElement(TEXT("global sources"));
if(!globalSources) //shouldn't happen
return false;
XElement *globalSourceElement = globalSources->GetElement(lpGlobalSourceName);
if(!globalSourceElement) //shouldn't happen
return false;
CTSTR lpClass = globalSourceElement->GetString(TEXT("class"));
ClassInfo *classInfo = App->GetImageSourceClass(lpClass);
if(!classInfo) //shouldn't happen
return false;
if(classInfo->configProc)
{
if(!classInfo->configProc(globalSourceElement, bCreating))
return false;
element->SetInt(TEXT("cx"), globalSourceElement->GetInt(TEXT("cx")));
element->SetInt(TEXT("cy"), globalSourceElement->GetInt(TEXT("cy")));
if(App->bRunning)
{
for(UINT i=0; i<App->globalSources.Num(); i++)
{
GlobalSourceInfo &info = App->globalSources[i];
if(info.strName.CompareI(lpGlobalSourceName) && info.source)
{
info.source->UpdateSettings();
break;
}
}
}
}
return true;
}
示例5: UpdateSettings
void UpdateSettings()
{
bitmapImage.SetPath(data->GetString(TEXT("path")));
bitmapImage.EnableFileMonitor(data->GetInt(TEXT("monitor"), 0) == 1);
bitmapImage.Init();
//------------------------------------
opacity = data->GetInt(TEXT("opacity"), 100);
color = data->GetInt(TEXT("color"), 0xFFFFFFFF);
if(opacity > 100)
opacity = 100;
bool bNewUseColorKey = data->GetInt(TEXT("useColorKey"), 0) != 0;
keyColor = data->GetInt(TEXT("keyColor"), 0xFFFFFFFF);
keySimilarity = data->GetInt(TEXT("keySimilarity"), 10);
keyBlend = data->GetInt(TEXT("keyBlend"), 0);
bUseColorKey = bNewUseColorKey;
}
示例6: ConfigureDialogProc
//.........这里部分代码省略.........
switch(LOWORD(wParam))
{
case IDC_CAPTUREMOUSE:
{
BOOL bCaptureMouse = SendMessage(GetDlgItem(hwnd, IDC_CAPTUREMOUSE), BM_GETCHECK, 0, 0) == BST_CHECKED;
EnableWindow(GetDlgItem(hwnd, IDC_INVERTMOUSEONCLICK), bCaptureMouse);
}
break;
case IDC_SELECTAPP:
case IDC_USEHOTKEY:
if (HIWORD(wParam) == BN_CLICKED)
{
bool bUseHotkey = LOWORD(wParam) == IDC_USEHOTKEY;
EnableWindow(GetDlgItem(hwnd, IDC_APPLIST), !bUseHotkey);
EnableWindow(GetDlgItem(hwnd, IDC_REFRESH), !bUseHotkey);
EnableWindow(GetDlgItem(hwnd, IDC_HOTKEY), bUseHotkey);
}
break;
case IDC_STRETCHTOSCREEN:
{
BOOL bStretchToScreen = SendMessage(GetDlgItem(hwnd, IDC_STRETCHTOSCREEN), BM_GETCHECK, 0, 0) == BST_CHECKED;
EnableWindow(GetDlgItem(hwnd, IDC_IGNOREASPECT), bStretchToScreen);
}
break;
case IDC_REFRESH:
{
ConfigDialogData *info = (ConfigDialogData*)GetWindowLongPtr(hwnd, DWLP_USER);
XElement *data = info->data;
CTSTR lpWindowName = data->GetString(TEXT("window"));
HWND hwndWindowList = GetDlgItem(hwnd, IDC_APPLIST);
RefreshWindowList(hwndWindowList, *info);
UINT windowID = 0;
if(lpWindowName)
windowID = (UINT)SendMessage(hwndWindowList, CB_FINDSTRINGEXACT, -1, (LPARAM)lpWindowName);
if(windowID != CB_ERR)
SendMessage(hwndWindowList, CB_SETCURSEL, windowID, 0);
else
SendMessage(hwndWindowList, CB_SETCURSEL, 0, 0);
String strInfoText;
if(info->adminWindows.Num())
{
strInfoText << Str("Sources.GameCaptureSource.RequiresAdmin") << TEXT("\r\n");
for(UINT i=0; i<info->adminWindows.Num(); i++)
strInfoText << info->adminWindows[i] << TEXT("\r\n");
}
SetWindowText(GetDlgItem(hwnd, IDC_INFO), strInfoText);
}
break;
case IDOK:
{
UINT windowID = (UINT)SendMessage(GetDlgItem(hwnd, IDC_APPLIST), CB_GETCURSEL, 0, 0);
if(windowID == CB_ERR) windowID = 0;
示例7: OptimizeSettings
void SettingsPublish::OptimizeSettings()
{
auto refresh_on_exit = GuardScope([&] { SetWarningInfo(); });
XConfig serverData;
if (!serverData.Open(L"services.xconfig"))
return;
XElement *services = serverData.GetElement(L"services");
if (!services)
return;
UINT numServices = services->NumElements();
int serviceID = (int)SendMessage(GetDlgItem(hwnd, IDC_SERVICE), CB_GETITEMDATA, SendMessage(GetDlgItem(hwnd, IDC_SERVICE), CB_GETCURSEL, 0, 0), 0);
XElement *r = nullptr;
for (UINT i = 0; i < numServices; i++)
{
XElement *service = services->GetElementByID(i);
if (service->GetInt(L"id") != serviceID)
continue;
//check to see if the service we're using has recommendations
if (!service->HasItem(L"recommended"))
return;
r = service->GetElement(L"recommended");
break;
}
if (!r)
return;
using optimizers_t = std::vector<std::function<void()>>;
optimizers_t optimizers;
String changes = Str("Settings.Publish.Optimize.Optimizations");
String currentAudioCodec = AppConfig->GetString(L"Audio Encoding", L"Codec", L"AAC");
int audioBitrate = AppConfig->GetInt(L"Audio Encoding", L"Bitrate", 96);
if (r->HasItem(L"ratecontrol"))
{
bool useCBR = AppConfig->GetInt(L"Video Encoding", L"UseCBR", 1) != 0;
CTSTR rc = r->GetString(L"ratecontrol");
if (!scmp(rc, L"cbr") && !useCBR)
{
optimizers.push_back([] { AppConfig->SetInt(L"Video Encoding", L"UseCBR", 1); });
changes << Str("Settings.Publish.Optimize.UseCBR");
}
}
if (r->HasItem(L"max bitrate"))
{
int maxBitrate = AppConfig->GetInt(L"Video Encoding", L"MaxBitrate", 1000);
int max_bitrate = r->GetInt(L"max bitrate");
if (maxBitrate > max_bitrate)
{
optimizers.push_back([max_bitrate] { AppConfig->SetInt(L"Video Encoding", L"MaxBitrate", max_bitrate); });
changes << FormattedString(Str("Settings.Publish.Optimize.Maxbitrate"), max_bitrate);
}
}
if (r->HasItem(L"supported audio codec"))
{
StringList codecs;
r->GetStringList(L"supported audio codec", codecs);
if (codecs.FindValueIndex(currentAudioCodec) == INVALID)
{
String codec = codecs[0];
optimizers.push_back([codec]
{
AppConfig->SetString(L"Audio Encoding", L"Codec", codec.Array());
AppConfig->SetInt(L"Audio Encoding", L"Format", codec.CompareI(L"AAC") ? 1 : 0); //set to 44.1 kHz in case of MP3, see SettingsEncoding.cpp
});
changes << FormattedString(Str("Settings.Publish.Optimize.UnsupportedAudioCodec"), codec.Array());
}
}
if (r->HasItem(L"max audio bitrate aac") && (!scmp(currentAudioCodec, L"AAC")))
{
int maxaudioaac = r->GetInt(L"max audio bitrate aac");
if (audioBitrate > maxaudioaac)
{
optimizers.push_back([maxaudioaac] { AppConfig->SetInt(L"Audio Encoding", L"Bitrate", maxaudioaac); });
changes << FormattedString(Str("Settings.Publish.Optimize.MaxAudiobitrate"), maxaudioaac);
}
}
if (r->HasItem(L"max audio bitrate mp3") && (!scmp(currentAudioCodec, L"MP3")))
{
int maxaudiomp3 = r->GetInt(L"max audio bitrate mp3");
if (audioBitrate > maxaudiomp3)
{
optimizers.push_back([maxaudiomp3] { AppConfig->SetInt(L"Audio Encoding", L"Bitrate", maxaudiomp3); });
changes << FormattedString(Str("Settings.Publish.Optimize.MaxAudiobitrate"), maxaudiomp3);
}
}
if (r->HasItem(L"profile"))
{
//.........这里部分代码省略.........
示例8: SetWarningInfo
void SettingsPublish::SetWarningInfo()
{
int serviceID = (int)SendMessage(GetDlgItem(hwnd, IDC_SERVICE), CB_GETITEMDATA, SendMessage(GetDlgItem(hwnd, IDC_SERVICE), CB_GETCURSEL, 0, 0), 0);
bool bUseCBR = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseCBR"), 1) != 0;
int maxBitRate = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("MaxBitrate"), 1000);
int keyframeInt = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("KeyframeInterval"), 0);
int audioBitRate = AppConfig->GetInt(TEXT("Audio Encoding"), TEXT("Bitrate"), 96);
String currentx264Profile = AppConfig->GetString(TEXT("Video Encoding"), TEXT("X264Profile"), L"high");
String currentAudioCodec = AppConfig->GetString(TEXT("Audio Encoding"), TEXT("Codec"), TEXT("AAC"));
float currentAspect = AppConfig->GetInt(L"Video", L"BaseWidth") / (float)max(1, AppConfig->GetInt(L"Video", L"BaseHeight"));
//ignore for non-livestreams
if (data.mode != 0)
{
SetDlgItemText(hwnd, IDC_WARNINGS, TEXT(""));
return;
}
bool hasErrors = false;
bool canOptimize = false;
String strWarnings;
XConfig serverData;
if(serverData.Open(TEXT("services.xconfig")))
{
XElement *services = serverData.GetElement(TEXT("services"));
if(services)
{
UINT numServices = services->NumElements();
for(UINT i=0; i<numServices; i++)
{
XElement *service = services->GetElementByID(i);
if (service->GetInt(TEXT("id")) == serviceID)
{
strWarnings = FormattedString(Str("Settings.Publish.Warning.BadSettings"), service->GetName());
//check to see if the service we're using has recommendations
if (!service->HasItem(TEXT("recommended")))
{
SetDlgItemText(hwnd, IDC_WARNINGS, TEXT(""));
return;
}
XElement *r = service->GetElement(TEXT("recommended"));
if (r->HasItem(TEXT("ratecontrol")))
{
CTSTR rc = r->GetString(TEXT("ratecontrol"));
if (!scmp (rc, TEXT("cbr")) && !bUseCBR)
{
hasErrors = true;
canOptimize = true;
strWarnings << Str("Settings.Publish.Warning.UseCBR");
}
}
if (r->HasItem(TEXT("max bitrate")))
{
int max_bitrate = r->GetInt(TEXT("max bitrate"));
if (maxBitRate > max_bitrate)
{
hasErrors = true;
canOptimize = true;
strWarnings << FormattedString(Str("Settings.Publish.Warning.Maxbitrate"), max_bitrate);
}
}
if (r->HasItem(L"supported audio codec"))
{
StringList codecs;
r->GetStringList(L"supported audio codec", codecs);
if (codecs.FindValueIndex(currentAudioCodec) == INVALID)
{
String msg = Str("Settings.Publish.Warning.UnsupportedAudioCodec"); //good thing OBS only supports MP3 (and AAC), otherwise I'd have to come up with a better translation solution
msg.FindReplace(L"$1", codecs[0].Array());
msg.FindReplace(L"$2", currentAudioCodec.Array());
hasErrors = true;
canOptimize = true;
strWarnings << msg;
}
}
if (r->HasItem(TEXT("max audio bitrate aac")) && (!scmp(currentAudioCodec, TEXT("AAC"))))
{
int maxaudioaac = r->GetInt(TEXT("max audio bitrate aac"));
if (audioBitRate > maxaudioaac)
{
hasErrors = true;
canOptimize = true;
strWarnings << FormattedString(Str("Settings.Publish.Warning.MaxAudiobitrate"), maxaudioaac);
}
}
if (r->HasItem(TEXT("max audio bitrate mp3")) && (!scmp(currentAudioCodec, TEXT("MP3"))))
{
int maxaudiomp3 = r->GetInt(TEXT("max audio bitrate mp3"));
if (audioBitRate > maxaudiomp3)
{
//.........这里部分代码省略.........
示例9: SetScene
bool OBS::SetScene(CTSTR lpScene)
{
if(bDisableSceneSwitching)
return false;
HWND hwndScenes = GetDlgItem(hwndMain, ID_SCENES);
UINT curSel = (UINT)SendMessage(hwndScenes, LB_GETCURSEL, 0, 0);
//-------------------------
if(curSel != LB_ERR)
{
UINT textLen = (UINT)SendMessage(hwndScenes, LB_GETTEXTLEN, curSel, 0);
String strLBName;
strLBName.SetLength(textLen);
SendMessage(hwndScenes, LB_GETTEXT, curSel, (LPARAM)strLBName.Array());
if(!strLBName.CompareI(lpScene))
{
UINT id = (UINT)SendMessage(hwndScenes, LB_FINDSTRINGEXACT, -1, (LPARAM)lpScene);
if(id == LB_ERR)
return false;
SendMessage(hwndScenes, LB_SETCURSEL, id, 0);
}
}
else
{
UINT id = (UINT)SendMessage(hwndScenes, LB_FINDSTRINGEXACT, -1, (LPARAM)lpScene);
if(id == LB_ERR)
return false;
SendMessage(hwndScenes, LB_SETCURSEL, id, 0);
}
//-------------------------
XElement *scenes = scenesConfig.GetElement(TEXT("scenes"));
XElement *newSceneElement = scenes->GetElement(lpScene);
if(!newSceneElement)
return false;
if(sceneElement == newSceneElement)
return true;
sceneElement = newSceneElement;
CTSTR lpClass = sceneElement->GetString(TEXT("class"));
if(!lpClass)
{
AppWarning(TEXT("OBS::SetScene: no class found for scene '%s'"), newSceneElement->GetName());
return false;
}
DWORD sceneChangeStartTime;
if(bRunning)
{
Log(TEXT("++++++++++++++++++++++++++++++++++++++++++++++++++++++"));
Log(TEXT(" New Scene"));
sceneChangeStartTime = OSGetTime();
}
XElement *sceneData = newSceneElement->GetElement(TEXT("data"));
//-------------------------
Scene *newScene = NULL;
if(bRunning)
newScene = CreateScene(lpClass, sceneData);
//-------------------------
HWND hwndSources = GetDlgItem(hwndMain, ID_SOURCES);
SendMessage(hwndSources, WM_SETREDRAW, (WPARAM)FALSE, (LPARAM) 0);
App->scaleItem = NULL;
bChangingSources = true;
ListView_DeleteAllItems(hwndSources);
bool bSkipTransition = false;
XElement *sources = sceneElement->GetElement(TEXT("sources"));
if(sources)
{
UINT numSources = sources->NumElements();
ListView_SetItemCount(hwndSources, numSources);
for(UINT i=0; i<numSources; i++)
{
XElement *sourceElement = sources->GetElementByID(i);
String className = sourceElement->GetString(TEXT("class"));
if(className == "DeviceCapture") {
// There's a capture device in the next scene that isn't a global source,
// so let's skip the transition since it won't work anyway.
//.........这里部分代码省略.........
示例10: ConfigureDialogProc
INT_PTR CALLBACK ConfigureDialogProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
{
ConfigDialogData *info = (ConfigDialogData*)lParam;
XElement *data = info->data;
SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
LocalizeWindow(hwnd);
//--------------------------------------------
SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_REFRESH, BN_CLICKED), (LPARAM)GetDlgItem(hwnd, IDC_APPLIST));
//--------------------------------------------
BOOL bCaptureMouse = data->GetInt(TEXT("captureMouse"), 1);
BOOL bStretchImage = data->GetInt(TEXT("stretchImage"));
SendMessage(GetDlgItem(hwnd, IDC_STRETCHTOSCREEN), BM_SETCHECK, bStretchImage ? BST_CHECKED : BST_UNCHECKED, 0);
SendMessage(GetDlgItem(hwnd, IDC_IGNOREASPECT), BM_SETCHECK, data->GetInt(TEXT("ignoreAspect")) ? BST_CHECKED : BST_UNCHECKED, 0);
SendMessage(GetDlgItem(hwnd, IDC_CAPTUREMOUSE), BM_SETCHECK, bCaptureMouse ? BST_CHECKED : BST_UNCHECKED, 0);
SendMessage(GetDlgItem(hwnd, IDC_INVERTMOUSEONCLICK), BM_SETCHECK, data->GetInt(TEXT("invertMouse")) ? BST_CHECKED : BST_UNCHECKED, 0);
EnableWindow(GetDlgItem(hwnd, IDC_INVERTMOUSEONCLICK), bCaptureMouse);
EnableWindow(GetDlgItem(hwnd, IDC_IGNOREASPECT), bStretchImage);
return TRUE;
}
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_CAPTUREMOUSE:
{
BOOL bCaptureMouse = SendMessage(GetDlgItem(hwnd, IDC_CAPTUREMOUSE), BM_GETCHECK, 0, 0) == BST_CHECKED;
EnableWindow(GetDlgItem(hwnd, IDC_INVERTMOUSEONCLICK), bCaptureMouse);
}
break;
case IDC_STRETCHTOSCREEN:
{
BOOL bStretchToScreen = SendMessage(GetDlgItem(hwnd, IDC_STRETCHTOSCREEN), BM_GETCHECK, 0, 0) == BST_CHECKED;
EnableWindow(GetDlgItem(hwnd, IDC_IGNOREASPECT), bStretchToScreen);
}
break;
case IDC_REFRESH:
{
ConfigDialogData *info = (ConfigDialogData*)GetWindowLongPtr(hwnd, DWLP_USER);
XElement *data = info->data;
CTSTR lpWindowName = data->GetString(TEXT("window"));
HWND hwndWindowList = GetDlgItem(hwnd, IDC_APPLIST);
RefreshWindowList(hwndWindowList, *info);
UINT windowID = 0;
if(lpWindowName)
windowID = (UINT)SendMessage(hwndWindowList, CB_FINDSTRINGEXACT, -1, (LPARAM)lpWindowName);
if(windowID != CB_ERR)
SendMessage(hwndWindowList, CB_SETCURSEL, windowID, 0);
else
SendMessage(hwndWindowList, CB_SETCURSEL, 0, 0);
String strInfoText;
//todo: remove later whem more stable
strInfoText << TEXT("Note: This plugin is currently experimental and may not be fully stable yet.\r\nIf using multiple scenes, I highly recommend using this as a global source to prevent stability issues.\r\n\r\n");
if(info->adminWindows.Num())
{
strInfoText << Str("Sources.GameCaptureSource.RequiresAdmin") << TEXT("\r\n");
for(UINT i=0; i<info->adminWindows.Num(); i++)
strInfoText << info->adminWindows[i] << TEXT("\r\n");
}
if(info->opposingBitWindows.Num())
{
#ifdef _WIN64
strInfoText << Str("Sources.GameCaptureSource.Requires32bit") << TEXT("\r\n");
#else
strInfoText << Str("Sources.GameCaptureSource.Requires64bit") << TEXT("\r\n");
#endif
for(UINT i=0; i<info->opposingBitWindows.Num(); i++)
strInfoText << TEXT(" * ") << info->opposingBitWindows[i] << TEXT("\r\n");
}
SetWindowText(GetDlgItem(hwnd, IDC_INFO), strInfoText);
}
break;
case IDOK:
{
UINT windowID = (UINT)SendMessage(GetDlgItem(hwnd, IDC_APPLIST), CB_GETCURSEL, 0, 0);
if(windowID == CB_ERR) windowID = 0;
//.........这里部分代码省略.........
示例11: SetWarningInfo
void SettingsPublish::SetWarningInfo()
{
int serviceID = (int)SendMessage(GetDlgItem(hwnd, IDC_SERVICE), CB_GETITEMDATA, SendMessage(GetDlgItem(hwnd, IDC_SERVICE), CB_GETCURSEL, 0, 0), 0);
bool bUseCBR = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseCBR"), 1) != 0;
int maxBitRate = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("MaxBitrate"), 1000);
int keyframeInt = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("KeyframeInterval"), 0);
int audioBitRate = AppConfig->GetInt(TEXT("Audio Encoding"), TEXT("Bitrate"), 96);
String currentAudioCodec = AppConfig->GetString(TEXT("Audio Encoding"), TEXT("Codec"), TEXT("AAC"));
//ignore for non-livestreams
if (data->mode != 0)
{
SetDlgItemText(hwnd, IDC_WARNINGS, TEXT(""));
return;
}
int errors = 0;
String strWarnings;
XConfig serverData;
if(serverData.Open(TEXT("services.xconfig")))
{
XElement *services = serverData.GetElement(TEXT("services"));
if(services)
{
UINT numServices = services->NumElements();
for(UINT i=0; i<numServices; i++)
{
XElement *service = services->GetElementByID(i);
if (service->GetInt(TEXT("id")) == serviceID)
{
strWarnings = FormattedString(Str("Settings.Publish.Warning.BadSettings"), service->GetName());
//check to see if the service we're using has recommendations
if (!service->HasItem(TEXT("recommended")))
{
SetDlgItemText(hwnd, IDC_WARNINGS, TEXT(""));
return;
}
XElement *r = service->GetElement(TEXT("recommended"));
if (r->HasItem(TEXT("ratecontrol")))
{
CTSTR rc = r->GetString(TEXT("ratecontrol"));
if (!scmp (rc, TEXT("cbr")) && !bUseCBR)
{
errors++;
strWarnings << Str("Settings.Publish.Warning.UseCBR");
}
}
if (r->HasItem(TEXT("max bitrate")))
{
int max_bitrate = r->GetInt(TEXT("max bitrate"));
if (maxBitRate > max_bitrate)
{
errors++;
strWarnings << FormattedString(Str("Settings.Publish.Warning.Maxbitrate"), max_bitrate);
}
}
if (r->HasItem(TEXT("max audio bitrate aac")) && (!scmp(currentAudioCodec, TEXT("AAC"))))
{
int maxaudioaac = r->GetInt(TEXT("max audio bitrate aac"));
if (audioBitRate > maxaudioaac)
{
errors++;
strWarnings << FormattedString(Str("Settings.Publish.Warning.MaxAudiobitrate"), maxaudioaac);
}
}
if (r->HasItem(TEXT("max audio bitrate mp3")) && (!scmp(currentAudioCodec, TEXT("MP3"))))
{
int maxaudiomp3 = r->GetInt(TEXT("max audio bitrate mp3"));
if (audioBitRate > maxaudiomp3)
{
errors++;
strWarnings << FormattedString(Str("Settings.Publish.Warning.MaxAudiobitrate"), maxaudiomp3);
}
}
if (r->HasItem(TEXT("keyint")))
{
int keyint = r->GetInt(TEXT("keyint"));
if (!keyframeInt || keyframeInt * 1000 > keyint)
{
errors++;
strWarnings << FormattedString(Str("Settings.Publish.Warning.Keyint"), keyint / 1000);
}
}
break;
}
}
}
}
//.........这里部分代码省略.........
示例12: SetWarningInfo
void SettingsPublish::SetWarningInfo()
{
int serviceID = (int)SendMessage(GetDlgItem(hwnd, IDC_SERVICE), CB_GETITEMDATA, SendMessage(GetDlgItem(hwnd, IDC_SERVICE), CB_GETCURSEL, 0, 0), 0);
bool bUseCBR = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseCBR"), 1) != 0;
int maxBitRate = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("MaxBitrate"), 1000);
int keyframeInt = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("KeyframeInterval"), 0);
int audioBitRate = AppConfig->GetInt(TEXT("Audio Encoding"), TEXT("Bitrate"), 96);
String currentx264Profile = AppConfig->GetString(TEXT("Video Encoding"), TEXT("X264Profile"), L"high");
String currentAudioCodec = AppConfig->GetString(TEXT("Audio Encoding"), TEXT("Codec"), TEXT("AAC"));
//ignore for non-livestreams
if (data->mode != 0)
{
SetDlgItemText(hwnd, IDC_WARNINGS, TEXT(""));
return;
}
int errors = 0;
String strWarnings;
XConfig serverData;
if(serverData.Open(TEXT("services.xconfig")))
{
XElement *services = serverData.GetElement(TEXT("services"));
if(services)
{
UINT numServices = services->NumElements();
for(UINT i=0; i<numServices; i++)
{
XElement *service = services->GetElementByID(i);
if (service->GetInt(TEXT("id")) == serviceID)
{
strWarnings = FormattedString(Str("Settings.Publish.Warning.BadSettings"), service->GetName());
//check to see if the service we're using has recommendations
if (!service->HasItem(TEXT("recommended")))
{
SetDlgItemText(hwnd, IDC_WARNINGS, TEXT(""));
return;
}
XElement *r = service->GetElement(TEXT("recommended"));
if (r->HasItem(TEXT("ratecontrol")))
{
CTSTR rc = r->GetString(TEXT("ratecontrol"));
if (!scmp (rc, TEXT("cbr")) && !bUseCBR)
{
errors++;
strWarnings << Str("Settings.Publish.Warning.UseCBR");
}
}
if (r->HasItem(TEXT("max bitrate")))
{
int max_bitrate = r->GetInt(TEXT("max bitrate"));
if (maxBitRate > max_bitrate)
{
errors++;
strWarnings << FormattedString(Str("Settings.Publish.Warning.Maxbitrate"), max_bitrate);
}
}
if (r->HasItem(TEXT("profile")))
{
String expectedProfile = r->GetString(TEXT("profile"));
if (!expectedProfile.CompareI(currentx264Profile))
{
errors++;
strWarnings << Str("Settings.Publish.Warning.RecommendMainProfile");
}
}
if (r->HasItem(TEXT("max audio bitrate aac")) && (!scmp(currentAudioCodec, TEXT("AAC"))))
{
int maxaudioaac = r->GetInt(TEXT("max audio bitrate aac"));
if (audioBitRate > maxaudioaac)
{
errors++;
strWarnings << FormattedString(Str("Settings.Publish.Warning.MaxAudiobitrate"), maxaudioaac);
}
}
if (r->HasItem(TEXT("max audio bitrate mp3")) && (!scmp(currentAudioCodec, TEXT("MP3"))))
{
int maxaudiomp3 = r->GetInt(TEXT("max audio bitrate mp3"));
if (audioBitRate > maxaudiomp3)
{
errors++;
strWarnings << FormattedString(Str("Settings.Publish.Warning.MaxAudiobitrate"), maxaudiomp3);
}
}
if (r->HasItem(TEXT("keyint")))
{
int keyint = r->GetInt(TEXT("keyint"));
if (!keyframeInt || keyframeInt * 1000 > keyint)
//.........这里部分代码省略.........
示例13: ParseUpdateManifest
BOOL ParseUpdateManifest (TCHAR *path, BOOL *updatesAvailable, String &description)
{
XConfig manifest;
XElement *root;
if (!manifest.Open(path))
return FALSE;
root = manifest.GetRootElement();
DWORD numPackages = root->NumElements();
DWORD totalUpdatableFiles = 0;
int priority, bestPriority = 999;
for (DWORD i = 0; i < numPackages; i++)
{
XElement *package;
package = root->GetElementByID(i);
CTSTR packageName = package->GetName();
//find out if this package is relevant to us
String platform = package->GetString(TEXT("platform"));
if (!platform)
continue;
if (scmp(platform, TEXT("all")))
{
#ifndef _WIN64
if (scmp(platform, TEXT("Win32")))
continue;
#else
if (scmp(platform, TEXT("Win64")))
continue;
#endif
}
//what is it?
String name = package->GetString(TEXT("name"));
String version = package->GetString(TEXT("version"));
//figure out where the files belong
XDataItem *pathElement = package->GetDataItem(TEXT("path"));
if (!pathElement)
continue;
CTSTR path = pathElement->GetData();
if (path == NULL)
path = TEXT("");
if (!IsSafePath(path))
continue;
priority = package->GetInt(TEXT("priority"), 999);
//get the file list for this package
XElement *files = package->GetElement(TEXT("files"));
if (!files)
continue;
DWORD numFiles = files->NumElements();
DWORD numUpdatableFiles = 0;
for (DWORD j = 0; j < numFiles; j++)
{
XElement *file = files->GetElementByID(j);
String hash = file->GetString(TEXT("hash"));
if (!hash || hash.Length() != 40)
continue;
String fileName = file->GetName();
if (!fileName)
continue;
if (!IsSafeFilename(fileName))
continue;
String filePath;
filePath << path;
filePath << fileName;
BYTE fileHash[20];
TCHAR fileHashString[41];
if (OSFileExists(filePath))
{
if (!CalculateFileHash(filePath, fileHash))
continue;
HashToString(fileHash, fileHashString);
if (!scmp(fileHashString, hash))
continue;
}
numUpdatableFiles++;
}
if (numUpdatableFiles)
//.........这里部分代码省略.........
示例14: UpdateSettings
void UpdateSettings()
{
String strName = data->GetString(TEXT("name"));
globalSource = App->GetGlobalSource(strName);
}
示例15: ConfigureDialogProc
INT_PTR CALLBACK ConfigureDialogProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
{
ConfigDialogData *info = (ConfigDialogData*)lParam;
XElement *data = info->data;
SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
LocalizeWindow(hwnd);
//--------------------------------------------
SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_REFRESH, BN_CLICKED), (LPARAM)GetDlgItem(hwnd, IDC_APPLIST));
//--------------------------------------------
BOOL bCaptureMouse = data->GetInt(TEXT("captureMouse"), 1);
SendMessage(GetDlgItem(hwnd, IDC_STRETCHTOSCREEN), BM_SETCHECK, data->GetInt(TEXT("stretchImage")) ? BST_CHECKED : BST_UNCHECKED, 0);
SendMessage(GetDlgItem(hwnd, IDC_CAPTUREMOUSE), BM_SETCHECK, bCaptureMouse ? BST_CHECKED : BST_UNCHECKED, 0);
SendMessage(GetDlgItem(hwnd, IDC_INVERTMOUSEONCLICK), BM_SETCHECK, data->GetInt(TEXT("invertMouse")) ? BST_CHECKED : BST_UNCHECKED, 0);
EnableWindow(GetDlgItem(hwnd, IDC_INVERTMOUSEONCLICK), bCaptureMouse);
return TRUE;
}
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_CAPTUREMOUSE:
{
BOOL bCaptureMouse = SendMessage(GetDlgItem(hwnd, IDC_CAPTUREMOUSE), BM_GETCHECK, 0, 0) == BST_CHECKED;
EnableWindow(GetDlgItem(hwnd, IDC_INVERTMOUSEONCLICK), bCaptureMouse);
}
break;
case IDC_REFRESH:
{
ConfigDialogData *info = (ConfigDialogData*)GetWindowLongPtr(hwnd, DWLP_USER);
XElement *data = info->data;
CTSTR lpWindowName = data->GetString(TEXT("window"));
HWND hwndWindowList = GetDlgItem(hwnd, IDC_APPLIST);
RefreshWindowList(hwndWindowList, *info);
UINT windowID = 0;
if(lpWindowName)
windowID = (UINT)SendMessage(hwndWindowList, CB_FINDSTRINGEXACT, -1, (LPARAM)lpWindowName);
if(windowID != CB_ERR)
SendMessage(hwndWindowList, CB_SETCURSEL, windowID, 0);
else
SendMessage(hwndWindowList, CB_SETCURSEL, 0, 0);
String strInfoText;
//todo: remove later whem more stable
strInfoText << TEXT("Note: This plugin is currently experimental and may not be fully stable yet.\r\n");
SetWindowText(GetDlgItem(hwnd, IDC_INFO), strInfoText);
}
break;
case IDOK:
{
UINT windowID = (UINT)SendMessage(GetDlgItem(hwnd, IDC_APPLIST), CB_GETCURSEL, 0, 0);
if(windowID == CB_ERR) windowID = 0;
ConfigDialogData *info = (ConfigDialogData*)GetWindowLongPtr(hwnd, DWLP_USER);
XElement *data = info->data;
if(!info->windowData.Num())
return 0;
String strWindow = GetCBText(GetDlgItem(hwnd, IDC_APPLIST), windowID);
data->SetString(TEXT("window"), strWindow);
data->SetString(TEXT("windowClass"), info->windowData[windowID].strClass);
data->SetInt(TEXT("stretchImage"), SendMessage(GetDlgItem(hwnd, IDC_STRETCHTOSCREEN), BM_GETCHECK, 0, 0) == BST_CHECKED);
data->SetInt(TEXT("captureMouse"), SendMessage(GetDlgItem(hwnd, IDC_CAPTUREMOUSE), BM_GETCHECK, 0, 0) == BST_CHECKED);
data->SetInt(TEXT("invertMouse"), SendMessage(GetDlgItem(hwnd, IDC_INVERTMOUSEONCLICK), BM_GETCHECK, 0, 0) == BST_CHECKED);
}
case IDCANCEL:
EndDialog(hwnd, LOWORD(wParam));
}
break;
case WM_CLOSE:
EndDialog(hwnd, IDCANCEL);
}
return 0;
}