Пример #1
0
void OBSBasic::on_tabAddSceneBtn_clicked()
{
	QString format{ QTStr("Basic.Main.DefaultSceneName.Text") };

	QString sceneName = format.arg(m_curNewSceneNameIndex++);

	{
		std::string name = QT_TO_UTF8(sceneName);
		obs_scene_t *scene = obs_scene_create(name.c_str());

		obs_source_t *source = obs_scene_get_source(scene);
		AddScene(source);
		SetCurrentScene(source);
		obs_scene_release(scene);
	}
}
Пример #2
0
void BiLiOBSMainWid::LoadScene()
{
	obs_data_t* sceneData = BiliConfigFile::LoadSceneData();
	if (sceneData)
	{
		BiliSceneConfig::Set(sceneData);
		obs_data_release(sceneData);
	}

	//如果加载进来的场景不够3个,就补到三个
	std::string firstAddedScene;
	int sceneCount = 0;
	for (OBSSource& src : OBSEnumSources())
	{
		if (strcmp(obs_source_get_id(src), "scene") == 0)
		{
			++sceneCount;
		}
	}

	int nextSceneIndex = 1;
	for (; sceneCount < 3; ++sceneCount)
	{
	restartByNewName:
		std::string sceneName = tr("Scene %1").arg(nextSceneIndex).toUtf8().data();

		obs_source_t* existedSource = obs_get_source_by_name(sceneName.c_str());
		if (existedSource != 0)
		{
			obs_source_release(existedSource);
			++nextSceneIndex;
			goto restartByNewName;
		}

		if (firstAddedScene.empty())
		{
			firstAddedScene = sceneName;
		}

		obs_scene_t* scene = obs_scene_create(sceneName.c_str());
		obs_source_t* sceneSource = obs_scene_get_source(scene);
		obs_add_source(sceneSource);
		obs_scene_release(scene);
	}

	obs_source_t* currentOutputSource = obs_get_output_source(0);
	if (!currentOutputSource)
	{
		if (!firstAddedScene.empty())
		{
			currentOutputSource = obs_get_source_by_name(firstAddedScene.c_str());
			if (currentOutputSource)
			{
				obs_set_output_source(0, currentOutputSource);
				obs_source_release(currentOutputSource);
			}
		}
	}
	else
	{
		obs_source_release(currentOutputSource);
	}

	//更新列表控件
	sceneListWidgetOperator->NotifyCurrentSceneChanged();
}
Пример #3
0
int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdLine,
		int numCmd)
{
	HWND hwnd = NULL;
	base_set_log_handler(do_log);

	try {
		hwnd = CreateTestWindow(instance);
		if (!hwnd)
			throw "Couldn't create main window";

		/* ------------------------------------------------------ */
		/* create OBS */
		CreateOBS(hwnd);

		/* ------------------------------------------------------ */
		/* load module */
		if (obs_load_module("test-input") != 0)
			throw "Couldn't load module";

		/* ------------------------------------------------------ */
		/* create source */
		SourceContext source = obs_source_create(SOURCE_INPUT,
				"random", "some randon source", NULL);
		if (!source)
			throw "Couldn't create random test source";

		/* ------------------------------------------------------ */
		/* create filter */
		SourceContext filter = obs_source_create(SOURCE_FILTER,
				"test", "a nice little green filter", NULL);
		if (!filter)
			throw "Couldn't create test filter";
		obs_source_filter_add(source, filter);

		/* ------------------------------------------------------ */
		/* create scene and add source to scene (twice) */
		SceneContext scene = obs_scene_create("test scene");
		if (!scene)
			throw "Couldn't create scene";

		AddTestItems(scene, source);

		/* ------------------------------------------------------ */
		/* set the scene as the primary draw source and go */
		obs_set_output_source(0, source);

		MSG msg;
		while (GetMessage(&msg, NULL, 0, 0)) {
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}

	} catch (char *error) {
		MessageBoxA(NULL, error, NULL, 0);
	}

	obs_shutdown();

	blog(LOG_INFO, "Number of memory leaks: %llu", bnum_allocs());
	DestroyWindow(hwnd);

	return 0;
}