Added scene collections API calls
parent
e0fce5bc27
commit
658800ee2e
|
@ -64,6 +64,14 @@ Scene* OBSGetScene() {return API->GetScene();}
|
|||
CTSTR OBSGetSceneName() {return API->GetSceneName();}
|
||||
XElement* OBSGetSceneElement() {return API->GetSceneElement();}
|
||||
|
||||
bool OBSSetSceneCollection(CTSTR lpCollection, CTSTR lpScene)
|
||||
{
|
||||
return API->SetSceneCollection(lpCollection, lpScene);
|
||||
}
|
||||
|
||||
CTSTR OBSGetSceneCollectionName() { return API->GetSceneCollectionName(); }
|
||||
void OBSGetSceneCollectionNames(StringList &list) { API->GetSceneCollectionNames(list); }
|
||||
|
||||
//low-order word is VK, high-order word is modifier. equivalent to the value given by hotkey controls
|
||||
UINT OBSCreateHotkey(DWORD hotkey, OBSHOTKEYPROC hotkeyProc, UPARAM param)
|
||||
{
|
||||
|
|
|
@ -193,6 +193,10 @@ public:
|
|||
virtual void StartStopRecordingReplayBuffer() = 0;
|
||||
virtual bool GetRecordingReplayBuffer() const=0;
|
||||
virtual void SaveReplayBuffer() = 0;
|
||||
|
||||
virtual bool SetSceneCollection(CTSTR lpCollection, CTSTR lpScene) = 0;
|
||||
virtual CTSTR GetSceneCollectionName() const = 0;
|
||||
virtual void GetSceneCollectionNames(StringList &list) const = 0;
|
||||
};
|
||||
|
||||
BASE_EXPORT extern APIInterface *API;
|
||||
|
@ -218,6 +222,10 @@ BASE_EXPORT Scene* OBSGetScene();
|
|||
BASE_EXPORT CTSTR OBSGetSceneName();
|
||||
BASE_EXPORT XElement* OBSGetSceneElement();
|
||||
|
||||
BASE_EXPORT bool OBSSetSceneCollection(CTSTR lpCollection, CTSTR lpScene);
|
||||
BASE_EXPORT CTSTR OBSGetSceneCollectionName();
|
||||
BASE_EXPORT void OBSGetSceneCollectionNames(StringList &list);
|
||||
|
||||
//low-order word is VK, high-order word is modifier. equivalent to the value given by hotkey controls
|
||||
BASE_EXPORT UINT OBSCreateHotkey(DWORD hotkey, OBSHOTKEYPROC hotkeyProc, UPARAM param);
|
||||
BASE_EXPORT void OBSDeleteHotkey(UINT hotkeyID);
|
||||
|
|
|
@ -399,6 +399,34 @@ bool OBS::SetScene(CTSTR lpScene)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool OBS::SetSceneCollection(CTSTR lpCollection) {
|
||||
if (bRunning)
|
||||
return false;
|
||||
|
||||
App->scenesConfig.Save();
|
||||
CTSTR collection = GetCurrentSceneCollection();
|
||||
String strSceneCollectionPath;
|
||||
strSceneCollectionPath = FormattedString(L"%s\\sceneCollection\\%s.xconfig", lpAppDataPath, collection);
|
||||
|
||||
if (!App->scenesConfig.Open(strSceneCollectionPath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
GlobalConfig->SetString(TEXT("General"), TEXT("SceneCollection"), lpCollection);
|
||||
App->scenesConfig.Close();
|
||||
App->ReloadSceneCollection();
|
||||
ResetSceneCollectionMenu();
|
||||
ResetApplicationName();
|
||||
App->UpdateNotificationAreaIcon();
|
||||
App->scenesConfig.SaveTo(String() << lpAppDataPath << "\\scenes.xconfig");
|
||||
|
||||
if (API != NULL)
|
||||
ReportSwitchSceneCollections(lpCollection);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
struct HotkeyInfo
|
||||
{
|
||||
DWORD hotkeyID;
|
||||
|
@ -633,6 +661,24 @@ public:
|
|||
virtual UINT GetFramesDropped() const {return App->curFramesDropped;}
|
||||
virtual UINT GetTotalStreamTime() const {return App->totalStreamTime;}
|
||||
virtual UINT GetBytesPerSec() const {return App->bytesPerSec;}
|
||||
|
||||
virtual bool SetSceneCollection(CTSTR lpCollection, CTSTR lpScene)
|
||||
{
|
||||
assert(lpCollection && *lpCollection);
|
||||
|
||||
if (!lpCollection || !*lpCollection)
|
||||
return false;
|
||||
|
||||
bool success = App->SetSceneCollection(lpCollection);
|
||||
if (lpScene != NULL && success)
|
||||
{
|
||||
SetScene(lpScene, true);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
virtual CTSTR GetSceneCollectionName() const { return App->GetCurrentSceneCollection(); }
|
||||
virtual void GetSceneCollectionNames(StringList &list) const { return App->GetSceneCollection(list); }
|
||||
};
|
||||
|
||||
APIInterface* CreateOBSApiInterface()
|
||||
|
|
|
@ -744,7 +744,9 @@ OBS::OBS()
|
|||
pluginInfo->statusCallback = (OBS_STATUS_CALLBACK)GetProcAddress(hPlugin, "OnOBSStatus");
|
||||
pluginInfo->streamStatusCallback = (OBS_STREAM_STATUS_CALLBACK)GetProcAddress(hPlugin, "OnStreamStatus");
|
||||
pluginInfo->sceneSwitchCallback = (OBS_SCENE_SWITCH_CALLBACK)GetProcAddress(hPlugin, "OnSceneSwitch");
|
||||
pluginInfo->sceneCollectionSwitchCallback = (OBS_SCENE_SWITCH_CALLBACK)GetProcAddress(hPlugin, "OnSceneCollectionSwitch");
|
||||
pluginInfo->scenesChangedCallback = (OBS_CALLBACK)GetProcAddress(hPlugin, "OnScenesChanged");
|
||||
pluginInfo->sceneCollectionsChangedCallback = (OBS_CALLBACK)GetProcAddress(hPlugin, "OnSceneCollectionsChanged");
|
||||
pluginInfo->sourceOrderChangedCallback = (OBS_CALLBACK)GetProcAddress(hPlugin, "OnSourceOrderChanged");
|
||||
pluginInfo->sourceChangedCallback = (OBS_SOURCE_CHANGED_CALLBACK)GetProcAddress(hPlugin, "OnSourceChanged");
|
||||
pluginInfo->sourcesAddedOrRemovedCallback = (OBS_CALLBACK)GetProcAddress(hPlugin, "OnSourcesAddedOrRemoved");
|
||||
|
|
12
Source/OBS.h
12
Source/OBS.h
|
@ -349,10 +349,16 @@ struct PluginInfo
|
|||
|
||||
/* called when scenes are switched */
|
||||
OBS_SCENE_SWITCH_CALLBACK sceneSwitchCallback;
|
||||
|
||||
|
||||
/* called when scene collections are switched */
|
||||
OBS_SCENE_SWITCH_CALLBACK sceneCollectionSwitchCallback;
|
||||
|
||||
/* called when a scene is renamed, added, removed, or moved */
|
||||
OBS_CALLBACK scenesChangedCallback;
|
||||
|
||||
/* called when a scene collection is renamed, added, removed, or moved */
|
||||
OBS_CALLBACK sceneCollectionsChangedCallback;
|
||||
|
||||
/* called when the source order is changed */
|
||||
OBS_CALLBACK sourceOrderChangedCallback;
|
||||
|
||||
|
@ -1238,6 +1244,8 @@ public:
|
|||
virtual bool SetScene(CTSTR lpScene);
|
||||
virtual void InsertSourceItem(UINT index, LPWSTR name, bool checked);
|
||||
|
||||
virtual bool SetSceneCollection(CTSTR lpCollection);
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// volume stuff
|
||||
virtual void SetDesktopVolume(float val, bool finalValue);
|
||||
|
@ -1269,7 +1277,9 @@ public:
|
|||
UINT totalStreamtime = 0, UINT numTotalFrames = 0,
|
||||
UINT numDroppedFrames = 0, UINT fps = 0);
|
||||
virtual void ReportSwitchScenes(CTSTR scene);
|
||||
virtual void ReportSwitchSceneCollections(CTSTR collection);
|
||||
virtual void ReportScenesChanged();
|
||||
virtual void ReportSceneCollectionsChanged();
|
||||
virtual void ReportSourceOrderChanged();
|
||||
virtual void ReportSourceChanged(CTSTR sourceName, XElement* source);
|
||||
virtual void ReportSourcesAddedOrRemoved();
|
||||
|
|
|
@ -183,6 +183,20 @@ void OBS::ReportSwitchScenes(CTSTR scene)
|
|||
}
|
||||
}
|
||||
|
||||
void OBS::ReportSwitchSceneCollections(CTSTR collection)
|
||||
{
|
||||
if (bShuttingDown)
|
||||
return;
|
||||
|
||||
for (UINT i = 0; i<plugins.Num(); i++)
|
||||
{
|
||||
OBS_SCENE_SWITCH_CALLBACK callback = plugins[i].sceneCollectionSwitchCallback;
|
||||
|
||||
if (callback)
|
||||
(*callback)(collection);
|
||||
}
|
||||
}
|
||||
|
||||
void OBS::ReportScenesChanged()
|
||||
{
|
||||
if (bShuttingDown)
|
||||
|
@ -197,6 +211,20 @@ void OBS::ReportScenesChanged()
|
|||
}
|
||||
}
|
||||
|
||||
void OBS::ReportSceneCollectionsChanged()
|
||||
{
|
||||
if (bShuttingDown)
|
||||
return;
|
||||
|
||||
for (UINT i = 0; i<plugins.Num(); i++)
|
||||
{
|
||||
OBS_CALLBACK callback = plugins[i].sceneCollectionsChangedCallback;
|
||||
|
||||
if (callback)
|
||||
(*callback)();
|
||||
}
|
||||
}
|
||||
|
||||
void OBS::ReportSourceOrderChanged()
|
||||
{
|
||||
if (bShuttingDown)
|
||||
|
|
|
@ -2733,6 +2733,7 @@ void OBS::AddSceneCollection(SceneCollectionAction action)
|
|||
App->ReloadSceneCollection();
|
||||
App->ResetSceneCollectionMenu();
|
||||
App->ResetApplicationName();
|
||||
App->ReportSceneCollectionsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2783,6 +2784,7 @@ void OBS::RemoveSceneCollection()
|
|||
|
||||
App->ReloadSceneCollection();
|
||||
App->ResetSceneCollectionMenu();
|
||||
App->ReportSceneCollectionsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2825,6 +2827,7 @@ void OBS::ImportSceneCollection()
|
|||
scenesConfig.Close();
|
||||
CopyFile(lpFile, strCurSceneCollectionFile, false);
|
||||
App->ReloadSceneCollection();
|
||||
App->ReportSceneCollectionsChanged();
|
||||
}
|
||||
|
||||
void OBS::ExportSceneCollection()
|
||||
|
@ -3698,24 +3701,11 @@ LRESULT CALLBACK OBS::OBSProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
|
||||
if (!strSceneCollection.CompareI(GetCurrentSceneCollection()))
|
||||
{
|
||||
App->scenesConfig.Save();
|
||||
CTSTR collection = GetCurrentSceneCollection();
|
||||
String strSceneCollectionPath;
|
||||
strSceneCollectionPath = FormattedString(L"%s\\sceneCollection\\%s.xconfig", lpAppDataPath, collection);
|
||||
|
||||
if (!App->scenesConfig.Open(strSceneCollectionPath))
|
||||
if (!App->SetSceneCollection(strSceneCollection))
|
||||
{
|
||||
OBSMessageBox(hwnd, TEXT("Error - unable to open xconfig file"), NULL, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
GlobalConfig->SetString(TEXT("General"), TEXT("SceneCollection"), strSceneCollection);
|
||||
App->scenesConfig.Close();
|
||||
App->ReloadSceneCollection();
|
||||
ResetSceneCollectionMenu();
|
||||
ResetApplicationName();
|
||||
App->UpdateNotificationAreaIcon();
|
||||
App->scenesConfig.SaveTo(String() << lpAppDataPath << "\\scenes.xconfig");
|
||||
}
|
||||
}
|
||||
else if (id >= ID_UPLOAD_LOG && id <= ID_UPLOAD_LOG_END)
|
||||
|
|
Loading…
Reference in New Issue