Paladin
Paladin
CC#
Created by Paladin on 4/16/2024 in #help
Connecting to an ATEM Switcher via C# (Multiplatform)
So, I am trying to invoke some disconnection logic, in order to access COM ports. The SDK says it is possible to connect on other platforms but it seems to be proving difficult.
The SDK interface is modeled on Microsoft’s Component Object Model (COM). On Microsoft Windows platforms, it is provided as a native COM interface registered with the operating system. On other platforms application code is provided to allow the same COM style interface to be used.
The SDK interface is modeled on Microsoft’s Component Object Model (COM). On Microsoft Windows platforms, it is provided as a native COM interface registered with the operating system. On other platforms application code is provided to allow the same COM style interface to be used.
Here is the code I'm using atm from the ATEMConnect.cs file
[DllImport("BMDSwitcherAPI.dll")]
public static extern IntPtr ConnectToSwitcher(string ipAddress);

public void ConnectToAtemSwitcher(string ipAddress)
{
IntPtr switcherPtr = ConnectToSwitcher(ipAddress);

if (switcherPtr != IntPtr.Zero)
{
Console.WriteLine("Successfully connected to ATEM switcher at IP: " + ipAddress);
// Continue with your operations on the switcher
}
else
{
Console.WriteLine("Failed to connect to ATEM switcher at IP: " + ipAddress);
}
}

public void DisconnectFromAtemSwitcher(IntPtr switcherPtr)
{
IBMDSwitcher switcher = (IBMDSwitcher)Marshal.GetObjectForIUnknown(switcherPtr);

// Assuming Disconnect method exists in the switcher API

Console.WriteLine("Disconnected from ATEM switcher");
}
[DllImport("BMDSwitcherAPI.dll")]
public static extern IntPtr ConnectToSwitcher(string ipAddress);

public void ConnectToAtemSwitcher(string ipAddress)
{
IntPtr switcherPtr = ConnectToSwitcher(ipAddress);

if (switcherPtr != IntPtr.Zero)
{
Console.WriteLine("Successfully connected to ATEM switcher at IP: " + ipAddress);
// Continue with your operations on the switcher
}
else
{
Console.WriteLine("Failed to connect to ATEM switcher at IP: " + ipAddress);
}
}

public void DisconnectFromAtemSwitcher(IntPtr switcherPtr)
{
IBMDSwitcher switcher = (IBMDSwitcher)Marshal.GetObjectForIUnknown(switcherPtr);

// Assuming Disconnect method exists in the switcher API

Console.WriteLine("Disconnected from ATEM switcher");
}
Marshal.GetObjectForIUnknown(switcherPtr) is proving to be the problem as it says in the IDE it is Windows only, but I aren't sure what the equivalent is. I asked in #chat about P/Invoke but I'd still likely need to use something like that even with P/Invoke. I'm not sure how I can get this to access on Mac.
7 replies