I need help: On the issue of C# WPF controlling OBS Studio, are there other apis that other programs can call from outside?

kaiS

New Member
C# WPF control OBS Studio can control the functions of OBS Studio, such as creating scene sets and switching scenes, after being connected through OBS-WebSocket. Currently, it needs to be controlled through the interface in OBs-frontend-api.dll
OBS Studio creates scene sets, switches scenes, and so on. Obs-frontend -api.dll has been viewed through Developer Command Prompt for Vs 2022
obs_frontend_get_scene_collections = obs_frontend_get_scene_collections
obs_frontend_get_scene_names = obs_frontend_get_scene_names
obs_frontend_get_scenes = obs_frontend_get_scenes
These interfaces are included
[DllImport("E:\\obs-studio\\bin\\64bit\\obs-frontend-api.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private static extern IntPtr obs_frontend_get_scene_collections();
private static extern void obs_frontend_set_current_scene_collection(string collection);

public static List<string> GetSceneCollectionsList()
{
var sceneCollections = new List<string>();
var ptr = obs_frontend_get_scene_collections();
if (ptr == IntPtr.Zero) return sceneCollections;

try
{
var currentPtr = ptr;
while (true)
{
var strPtr = Marshal.ReadIntPtr(currentPtr);
if (strPtr == IntPtr.Zero) break;
var str = Marshal.PtrToStringAnsi(strPtr);
sceneCollections.Add(str);
currentPtr += IntPtr.Size;
}
}
finally
{


}

return sceneCollections;
}
if (ptr == IntPtr.Zero) return sceneCollections; if (PTR == intptr.zero) return scenecollections; Will directly return sceneCollections;
[DllImport("E:\\obs-studio\\bin\\64bit\\obs-frontend-api.dll", CallingConvention = CallingConvention.Cdecl, CharSet = charset.ansi)] is the actual obs-studio installation directory address
Given that ptr == IntPtr.Zero currently exists a scene set, is there a code problem? Or does obs-frontend-api.dll not support such a call?
 
Top