Blackmagic ATEM SDK not working as intended

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

_Remo_

  • Posts: 3
  • Joined: Tue Mar 03, 2020 7:53 am
  • Real Name: Remo Roethlisberger

Blackmagic ATEM SDK not working as intended

PostTue Mar 03, 2020 8:03 am

Hi all,
I am very much new to the ATEM suite and also the C++ SDK that is available for the switches. I am currently working on a small project that tries to integrate the Blackmagic Configuration with our own products. I got the first script to work - it compiles and runs just fine. However, it's not actually changing any settings on our Blackmagic ATEM Production Studio 4K. So I was wondering if someone could help me with debugging...

Code: Select all
#include "BMDSwitcherAPI.h"
#include <iostream>

// IP Address
static const CFStringRef ip_address = CFSTR("192.168.10.240");

int setMode0()
{
   HRESULT result;

   // Create discovery instance
   IBMDSwitcherDiscovery *discovery = CreateBMDSwitcherDiscoveryInstance();
   if (!discovery)
   {
      std::cerr << "Failed to create IBMDSwitcherDiscovery!" << std::endl;
      return 1;
   }

   // Use discovery instance to connect to switcher
   std::cout << "Connecting to switcher..." << std::endl;
   IBMDSwitcher *switcher;
   BMDSwitcherConnectToFailure connectToFailReason;
   result = discovery->ConnectTo(ip_address, &switcher, &connectToFailReason);
   discovery->Release();
   if (result != S_OK)
   {
      std::cerr << "Failed to connect to switcher!" << std::endl;
      return 1;
   }

   //Mix Effect input changer
   IBMDSwitcherMixEffectBlockIterator *mixIterator = NULL;
   result = switcher->CreateIterator(IID_IBMDSwitcherMixEffectBlockIterator, (void **)&mixIterator);
   IBMDSwitcherMixEffectBlock *mixEffect = NULL;

   if (SUCCEEDED(result))
   {
      while (S_OK == mixIterator->Next(&mixEffect))
      {
         // set the program input
         mixEffect->SetProgramInput(5);
      }
   }

   //Downstream Keyer
   IBMDSwitcherDownstreamKeyIterator *dskIterator = NULL;
   result = switcher->CreateIterator(IID_IBMDSwitcherDownstreamKeyIterator, (void **)&dskIterator);
   IBMDSwitcherDownstreamKey *downstreamKey = NULL;
   int i = 0;
   if (SUCCEEDED(result))
   {
      while (S_OK == dskIterator->Next(&downstreamKey))
      {
         if (i)
         {
            // this is the key - which should be media input key
            downstreamKey->SetInputCut(5);
            // this is the fill source which would be the computer output
            downstreamKey->SetInputFill(2);

            // mask the area we want
            downstreamKey->SetMasked(true);
            downstreamKey->SetMaskBottom(-12.0);
            downstreamKey->SetMaskLeft(-4.0);
            downstreamKey->SetMaskRight(9);
            downstreamKey->SetMaskTop(5.0);
            i = 0;
         }
         else
         {
            // this is the key - which should be media input key
            downstreamKey->SetInputCut(5);
            // this is the fill source which would be the computer output
            downstreamKey->SetInputFill(2);
            i = 1;
         }
      }
   }
   dskIterator->Release();
   dskIterator = NULL;

   switcher->Release();

   return 0;
}


When I call the above function, I can connect to the ATEM. But then nothing more happens! Is there some final send method that one needs to call? I couldn't find anything that would differ from the sample SDK/API snippets that Blackmagic Design provides...

Thanks a lot for your help,
Remo
Offline

_Remo_

  • Posts: 3
  • Joined: Tue Mar 03, 2020 7:53 am
  • Real Name: Remo Roethlisberger

Re: Blackmagic ATEM SDK not working as intended

PostTue Mar 03, 2020 4:03 pm

Just a short follow up: I was able to get it working once in like a 100 times. It seems to be an issue with open connections and occupied resources... I got the highest success rate by restarting the "Blackmagic ATEM Switchers" software, that was running on the same machine at the same time. Could it be the case that those two things interfere with each other? Or do I miss something in my script in order to close the connection and free up the resources, since if I run it a second time it won't work or only unreliably! I am using Mac OS X, running ATEM Software Control 8.1.1 and then my script that I provided in the first post.

I am happy for any input and suggestions.

Thanks a lot!
Remo
Offline

Cameron Nichols

Blackmagic Design

  • Posts: 278
  • Joined: Mon Sep 04, 2017 4:05 am

Re: Blackmagic ATEM SDK not working as intended

PostTue Mar 03, 2020 10:23 pm

Hi Remo,

I ran your program locally, I believe the issue is that your IBMDSwitcherDiscovery object is released too soon. Can you try moving
Code: Select all
discovery->Release();
to the end of setMode0 method.

Regards
Cameron
Offline

_Remo_

  • Posts: 3
  • Joined: Tue Mar 03, 2020 7:53 am
  • Real Name: Remo Roethlisberger

Re: Blackmagic ATEM SDK not working as intended

PostTue Mar 10, 2020 12:17 pm

Hi Cameron,

Thanks for your help. Unfortunately this didn't solve the problem. This part is also pretty much copy pasted from the SDK samples (especially the CameraFocus.cpp) that are provided by Blackmagic.
My error is still the same - the script executes and connects to the switch just fine, but somehow all my settings are not applied at the ATEM switch. So it is like nothing happened, only in like 1 of a hundred times it actually does what I want.

I am wondering whether I need to add some DLL library (or Mac OS equivalent) in order to make it work. As I get the best success rate whenever I restart the Blackmagic ATEM control software on my Mac.
I also didn't find a step-by-step guide on how to install the SDK. I just downloaded the library (all the .h files) and installed the Blackmagic ATEM Switchers software.

I am compiling my application with the following command:
Code: Select all
c++ -I server/blackmagic_api/mac_os/include/ -framework CoreFoundation server/blackmagic_api/mac_os/include/BMDSwitcherAPIDispatch.cpp server/blackmagic_api/App.cpp -o server/blackmagic_api/App.out

Thanks!

Highly appreciate your feedback.

Remo

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 5 guests