本文整理汇总了C++中XElement::NumElements方法的典型用法代码示例。如果您正苦于以下问题:C++ XElement::NumElements方法的具体用法?C++ XElement::NumElements怎么用?C++ XElement::NumElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XElement
的用法示例。
在下文中一共展示了XElement::NumElements方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleGetSceneList
json_t* OBSAPIMessageHandler::HandleGetSceneList(OBSAPIMessageHandler* handler, json_t* message)
{
OBSEnterSceneMutex();
json_t* ret = GetOkResponse();
XElement* xscenes = OBSGetSceneListElement();
XElement* currentScene = OBSGetSceneElement();
json_object_set_new(ret, "current-scene", json_string_wchar(currentScene->GetName()));
json_t* scenes = json_array();
if(scenes != NULL)
{
int numScenes = xscenes->NumElements();
for(int i = 0; i < numScenes; i++)
{
XElement* scene = xscenes->GetElementByID(i);
json_array_append_new(scenes, getSceneJson(scene));
}
}
json_object_set_new(ret,"scenes", scenes);
OBSLeaveSceneMutex();
return ret;
}
示例2: GetGlobalSourceNames
void OBS::GetGlobalSourceNames(List<CTSTR> &globalSourceNames)
{
globalSourceNames.Clear();
XElement *globals = scenesConfig.GetElement(TEXT("global sources"));
if(globals)
{
UINT numSources = globals->NumElements();
for(UINT i=0; i<numSources; i++)
{
XElement *sourceElement = globals->GetElementByID(i);
globalSourceNames << sourceElement->GetName();
}
}
}
示例3: make_pair
std::pair<std::unique_ptr<XConfig>, XElement*> LoadService(const ServiceIdentifier& sid, String *failReason)
{
auto fail = [&](CTSTR reason)
{
if (failReason)
*failReason = reason;
return make_pair(std::unique_ptr<XConfig>(), nullptr);
};
auto serverData = make_unique<XConfig>();
if (sid.file.IsEmpty())
{
if (!serverData->Open(FormattedString(L"%s\\services.xconfig", API->GetAppPath())))
return fail(L"Could not open services.xconfig");
XElement *services = serverData->GetElement(TEXT("services"));
if (!services)
return fail(L"Could not find any services in services.xconfig");
XElement *service = NULL;
auto numServices = services->NumElements();
for (decltype(numServices) i = 0; i < numServices; i++)
{
XElement *curService = services->GetElementByID(i);
if (!curService)
continue;
if (curService->GetInt(L"id") == sid.id)
return { move(serverData), curService };
}
}
else
{
if (serverData->Open(FormattedString(L"%s/services/%s", API->GetAppDataPath(), sid.file.Array())))
return { move(serverData), serverData->GetElementByID(sid.id) };
else
return fail(FormattedString(L"Could not open service file '%s'", sid.file.Array()));
}
return make_pair(std::unique_ptr<XConfig>(), nullptr);
}
示例4: SceneHotkey
void STDCALL SceneHotkey(DWORD hotkey, UPARAM param, bool bDown)
{
if(!bDown) return;
XElement *scenes = API->GetSceneListElement();
if(scenes)
{
UINT numScenes = scenes->NumElements();
for(UINT i=0; i<numScenes; i++)
{
XElement *scene = scenes->GetElementByID(i);
DWORD sceneHotkey = (DWORD)scene->GetInt(TEXT("hotkey"));
if(sceneHotkey == hotkey)
{
App->SetScene(scene->GetName());
return;
}
}
}
}
示例5: SourcesAddedOrRemoved
void WebSocketOBSTriggerHandler::SourcesAddedOrRemoved()
{
json_t* update = json_object();
json_object_set_new(update, "update-type", json_string("RepopulateSources"));
XElement* xsources = OBSGetSceneElement()->GetElement(TEXT("sources"));
json_t* sources = json_array();
for(UINT i = 0; i < xsources->NumElements(); i++)
{
XElement* source = xsources->GetElementByID(i);
json_array_append_new(sources, getSourceJson(source));
}
json_object_set_new(update, "sources", sources);
OSEnterMutex(this->updateQueueMutex);
this->updates.Add(update);
OSLeaveMutex(this->updateQueueMutex);
}
示例6: SourceOrderChanged
void WebSocketOBSTriggerHandler::SourceOrderChanged()
{
json_t* update = json_object();
json_object_set_new(update, "update-type", json_string("SourceOrderChanged"));
XElement* xsources = OBSGetSceneElement()->GetElement(TEXT("sources"));
json_t* sources = json_array();
for(UINT i = 0; i < xsources->NumElements(); i++)
{
XElement* source = xsources->GetElementByID(i);
json_array_append_new(sources, json_string_wchar(source->GetName()));
}
json_object_set_new(update, "sources", sources);
OSEnterMutex(this->updateQueueMutex);
this->updates.Add(update);
OSLeaveMutex(this->updateQueueMutex);
}
示例7: getSceneJson
json_t* getSceneJson(XElement* scene)
{
XElement* sources = scene->GetElement(TEXT("sources"));
json_t* ret = json_object();
json_t* scene_items = json_array();
json_object_set_new(ret, "name", json_string_wchar(scene->GetName()));
if(sources != NULL)
{
for(UINT i = 0; i < sources->NumElements(); i++)
{
XElement* source = sources->GetElementByID(i);
json_array_append(scene_items, getSourceJson(source));
}
}
json_object_set_new(ret, "sources", scene_items);
return ret;
}
示例8: LoadBuiltinServices
static inline void LoadBuiltinServices(vector<ServiceIdentifier> &services_)
{
XConfig serverData;
if (serverData.Open(FormattedString(L"%s\\services.xconfig", API->GetAppPath())))
{
XElement *services = serverData.GetElement(TEXT("services"));
if (services)
{
auto numServices = services->NumElements();
for (decltype(numServices) i = 0; i < numServices; i++)
{
auto service = services->GetElementByID(i);
if (!service)
continue;
services_.emplace_back(service->GetInt(L"id"), String());
}
}
}
}
示例9: SettingsPane
ServerPingSettings::ServerPingSettings() : SettingsPane()
{
// class privates
pingers = new List<Pinger *>();
InitializeCriticalSection(&pingerMutex);
// service
UINT serviceCount;
XConfig serverData;
if(serverData.Open(TEXT("services.xconfig")))
{
XElement *services = serverData.GetElement(TEXT("services"));
if(services) {
serviceCount = services->NumElements();
for(UINT i = 0; i < serviceCount; i++) {
XElement *service = services->GetElementByID(i);
if (service) {
XElement *servers = service->GetElement(TEXT("servers"));
if(servers) {
UINT numServers = servers->NumDataItems();
for(UINT i=0; i<numServers; i++) {
XDataItem *server = servers->GetDataItemByID(i);
if (server) {
pingers->Add(new Pinger(service, server));
}
}
}
}
}
}
}
serverData.Close();
hThread = 0;
}
示例10: HandleGetCurrentScene
json_t* OBSAPIMessageHandler::HandleGetCurrentScene(OBSAPIMessageHandler* handler, json_t* message)
{
OBSEnterSceneMutex();
json_t* ret = GetOkResponse();
XElement* scene = OBSGetSceneElement();
json_object_set_new(ret, "name", json_string_wchar(scene->GetName()));
XElement* sources = scene->GetElement(TEXT("sources"));
json_t* scene_items = json_array();
if(sources != NULL)
{
for(UINT i = 0; i < sources->NumElements(); i++)
{
XElement* source = sources->GetElementByID(i);
json_array_append_new(scene_items, getSourceJson(source));
}
}
json_object_set_new(ret, "sources", scene_items);
OBSLeaveSceneMutex();
return ret;
}
示例11: EnumerateBuiltinServices
static inline bool EnumerateBuiltinServices(function<bool(ServiceIdentifier, XElement*)> &func)
{
XConfig serverData;
if (serverData.Open(FormattedString(L"%s\\services.xconfig", API->GetAppPath())))
{
XElement *services = serverData.GetElement(TEXT("services"));
if (services)
{
auto numServices = services->NumElements();
for (decltype(numServices) i = 0; i < numServices; i++)
{
auto service = services->GetElementByID(i);
if (!service)
continue;
if (!func({ service->GetInt(L"id"), String() }, service))
return false;
}
}
}
return true;
}
示例12: 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;
}
if(bRunning)
{
Log(TEXT("++++++++++++++++++++++++++++++++++++++++++++++++++++++"));
Log(TEXT(" New Scene"));
}
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);
bChangingSources = true;
ListView_DeleteAllItems(hwndSources);
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);
bool render = sourceElement->GetInt(TEXT("render"), 1) > 0;
AddSourceItem((LPWSTR)sourceElement->GetName(), render, i);
if(bRunning && newScene)
newScene->AddImageSource(sourceElement);
}
}
bChangingSources = false;
SendMessage(hwndSources, WM_SETREDRAW, (WPARAM)TRUE, (LPARAM) 0);
RedrawWindow(hwndSources, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
//.........这里部分代码省略.........
示例13: 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)
//.........这里部分代码省略.........
示例14: 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.
//.........这里部分代码省略.........
示例15: 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;
}
}
}
}
//.........这里部分代码省略.........