- Posts: 10
- Joined: Tue Nov 16, 2021 9:06 pm
- Real Name: Andrew Wallace
I'm working on an APP for basic ATEM controls
Its written in C++
The code is below (most of it), but the weird thing is the cut I send never occurs even though I get a success code back.
I can however get the ATEMs product name without issue.
So clearly the connection works, and as far as I can tell the code is the same as the switcher panel example which I got working just fine.
Any ideas?
Its written in C++
The code is below (most of it), but the weird thing is the cut I send never occurs even though I get a success code back.
I can however get the ATEMs product name without issue.
So clearly the connection works, and as far as I can tell the code is the same as the switcher panel example which I got working just fine.
Any ideas?
- Code: Select all
IBMDSwitcherDiscovery* mSwitcherDiscovery;
IBMDSwitcher* mSwitcher;
IBMDSwitcherMixEffectBlock* mMixEffectBlock;
IBMDSwitcherInputIterator* inputIterator = NULL;
std::list<InputMonitor*> mInputMonitors;
std::string productName;
BMDSwitcherConnectToFailure connectToFailReason;
HRESULT result;
IBMDSwitcherMixEffectBlockIterator* iterator = NULL;
// Initialize COM and Switcher related members
if (FAILED(CoInitialize(NULL)))
{
printf("CoInitialize failed.");
return -1;
}
SwitcherMonitor* mSwitcherMonitor = new SwitcherMonitor();
MixEffectBlockMonitor* mMixEffectBlockMonitor = new MixEffectBlockMonitor();
result = CoCreateInstance(CLSID_CBMDSwitcherDiscovery, NULL, CLSCTX_ALL, IID_IBMDSwitcherDiscovery, (void**)&mSwitcherDiscovery);
if (result != S_OK)
{
fprintf(stderr, "A Switcher Discovery instance could not be created. The Switcher drivers may not be installed.\n");
return -1;
}
// Connect to switcher with address provided by argv
const char* ipAddress = "192.168.1.53";
CComBSTR addressString = _com_util::ConvertStringToBSTR(ipAddress);
result = mSwitcherDiscovery->ConnectTo(addressString, &mSwitcher, &connectToFailReason);
if (result != S_OK)
{
std::string connectFailReasonStr = LookupString<BMDSwitcherConnectToFailure>(kConnectFailReasonCodes, connectToFailReason);
fprintf(stderr, "Failed to connect to switcher at address %s, reason = %s\n", ipAddress, connectFailReasonStr.c_str());
return -1;
}
::SysFreeString(addressString);
mSwitcher->AddCallback(mSwitcherMonitor);
// Create an InputMonitor for each input so we can catch any changes to input names
result = mSwitcher->CreateIterator(IID_IBMDSwitcherInputIterator, (void**)&inputIterator);
if (SUCCEEDED(result))
{
IBMDSwitcherInput* input = NULL;
// For every input, install a callback to monitor property changes on the input
while (S_OK == inputIterator->Next(&input))
{
InputMonitor* inputMonitor = new InputMonitor(input);
input->Release();
mInputMonitors.push_back(inputMonitor);
}
inputIterator->Release();
inputIterator = NULL;
}
// Print switcher product name
printf("Switcher found at %s\n", ipAddress);
productName = get_product_name(mSwitcher);
printf(" %-40s %s\n", "Product Name:", productName.c_str());
result = mSwitcher->CreateIterator(IID_IBMDSwitcherMixEffectBlockIterator, (void**)&iterator);
if (FAILED(result))
{
printf("Could not create IBMDSwitcherMixEffectBlockIterator iterator");
return -1;
}
// Use the first Mix Effect Block
if (S_OK != iterator->Next(&mMixEffectBlock))
{
printf("Could not get the first IBMDSwitcherMixEffectBlock");
return -1;
}
mMixEffectBlock->AddCallback(mMixEffectBlockMonitor);
if (S_OK != mMixEffectBlock->PerformCut())
{
printf("Cut failed");
}
std::cout << "Program Completed\n";
return 0;