Skip to content

Commit

Permalink
Adding UpstreamKeyerMonitor to catch USK On Air events, full support …
Browse files Browse the repository at this point in the history
…for BKGD (+ docs), bug fixes
  • Loading branch information
SteffeyDev committed Jul 1, 2018
1 parent 55a8ba9 commit 45e9351
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 21 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ Feedback: None

### Upstream Keyers

- **Set Tie BKGD** `/atem/usk/0/tie <0|1>`
- Send a value of 1 to enable tie, and 0 to disable
- **Toggle Tie BKGD** `/atem/usk/0/tie/toggle`
- **Set On-Air Upstream Keyer $i** `/atem/usk/$i/on-air <0|1>`
- Send a value of 1 to cut the USK on-air, and a value of 0 to cut it off-air
- **Cut Toggle On-Air Upstream Keyer $i** `/atem/usk/$i/on-air/toggle`
Expand Down
1 change: 1 addition & 0 deletions atemOSC/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
IBMDSwitcherKeyFlyParameters* mDVEControl;
SwitcherMonitor* mSwitcherMonitor;
DownstreamKeyerMonitor* mDownstreamKeyerMonitor;
UpstreamKeyerMonitor* mUpstreamKeyerMonitor;
TransitionParametersMonitor* mTransitionParametersMonitor;
MacroPoolMonitor* mMacroPoolMonitor;
std::vector<SendStatusInterface*> mMonitors;
Expand Down
4 changes: 4 additions & 0 deletions atemOSC/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
mMonitors.push_back(mSwitcherMonitor);
mDownstreamKeyerMonitor = new DownstreamKeyerMonitor(self);
mMonitors.push_back(mDownstreamKeyerMonitor);
mUpstreamKeyerMonitor = new UpstreamKeyerMonitor(self);
mMonitors.push_back(mUpstreamKeyerMonitor);
mTransitionParametersMonitor = new TransitionParametersMonitor(self);
mMonitors.push_back(mTransitionParametersMonitor);
mMixEffectBlockMonitor = new MixEffectBlockMonitor(self);
Expand Down Expand Up @@ -293,6 +295,7 @@ - (void)switcherConnected
while (S_OK == keyIterator->Next(&key))
{
keyers.push_back(key);
key->AddCallback(mUpstreamKeyerMonitor);
}
keyIterator->Release();
keyIterator = NULL;
Expand Down Expand Up @@ -480,6 +483,7 @@ - (void)cleanUpConnection
while (keyers.size())
{
keyers.back()->Release();
keyers.back()->RemoveCallback(mUpstreamKeyerMonitor);
keyers.pop_back();
}

Expand Down
14 changes: 14 additions & 0 deletions atemOSC/FeedbackMonitors.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ class DownstreamKeyerMonitor : public GenericMonitor<IBMDSwitcherDownstreamKeyCa
void updateDSKTie() const;
};

class UpstreamKeyerMonitor : public GenericMonitor<IBMDSwitcherKeyCallback>, public SendStatusInterface
{
public:
UpstreamKeyerMonitor(void *delegate) : GenericMonitor(delegate) { }
HRESULT Notify (BMDSwitcherKeyEventType eventType);
float sendStatus() const;

protected:
virtual ~UpstreamKeyerMonitor() { }

private:
void updateUSKOnAir() const;
};

class TransitionParametersMonitor : public GenericMonitor<IBMDSwitcherTransitionParametersCallback>, public SendStatusInterface
{
public:
Expand Down
75 changes: 56 additions & 19 deletions atemOSC/FeedbackMonitors.mm
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,17 @@
{
bool isTied;
key->GetTie(&isTied);

// Deprecated
OSCMessage *oldMsg = [OSCMessage createWithAddress:[NSString stringWithFormat:@"/atem/dsk/set-tie/%d",i++]];
OSCMessage *oldMsg = [OSCMessage createWithAddress:[NSString stringWithFormat:@"/atem/dsk/set-tie/%d",i]];
[oldMsg addInt: isTied];
[static_cast<AppDelegate *>(appDel).outPort sendThisMessage:oldMsg];
OSCMessage *newMsg = [OSCMessage createWithAddress:[NSString stringWithFormat:@"/atem/dsk/%d/tie",i++]];

OSCMessage *newMsg = [OSCMessage createWithAddress:[NSString stringWithFormat:@"/atem/dsk/%d/tie",i]];
[newMsg addInt: isTied];
[static_cast<AppDelegate *>(appDel).outPort sendThisMessage:newMsg];

i++;
}
}

Expand All @@ -182,15 +184,17 @@
{
bool isOnAir;
key->GetOnAir(&isOnAir);

// Deprecated
OSCMessage *oldMsg = [OSCMessage createWithAddress:[NSString stringWithFormat:@"/atem/dsk/on-air/%d",i++]];
OSCMessage *oldMsg = [OSCMessage createWithAddress:[NSString stringWithFormat:@"/atem/dsk/on-air/%d",i]];
[oldMsg addInt: isOnAir];
[static_cast<AppDelegate *>(appDel).outPort sendThisMessage:oldMsg];
OSCMessage *newMsg = [OSCMessage createWithAddress:[NSString stringWithFormat:@"/atem/dsk/%d/on-air",i++]];

OSCMessage *newMsg = [OSCMessage createWithAddress:[NSString stringWithFormat:@"/atem/dsk/%d/on-air",i]];
[newMsg addInt: isOnAir];
[static_cast<AppDelegate *>(appDel).outPort sendThisMessage:newMsg];

i++;
}
}

Expand Down Expand Up @@ -225,6 +229,47 @@
return 0.1;
}

// Send OSC messages out when DSK On Air is changed on switcher
void UpstreamKeyerMonitor::updateUSKOnAir() const
{
int i = 1;
for(auto& key : [(AppDelegate *)appDel keyers])
{
bool isOnAir;
key->GetOnAir(&isOnAir);

OSCMessage *newMsg = [OSCMessage createWithAddress:[NSString stringWithFormat:@"/atem/usk/%d/on-air",i]];
[newMsg addInt: isOnAir];
[static_cast<AppDelegate *>(appDel).outPort sendThisMessage:newMsg];

i++;
}
}

HRESULT UpstreamKeyerMonitor::Notify(BMDSwitcherKeyEventType eventType)
{
switch (eventType)
{
case bmdSwitcherKeyEventTypeTypeChanged:
// Might want to do something with this down the road
break;
case bmdSwitcherKeyEventTypeOnAirChanged:
updateUSKOnAir();
break;
default:
// ignore other property changes not used for this app
break;
}
return S_OK;
}

float UpstreamKeyerMonitor::sendStatus() const
{
updateUSKOnAir();

return 0.1;
}

HRESULT TransitionParametersMonitor::Notify(BMDSwitcherTransitionParametersEventType eventType)
{

Expand All @@ -251,25 +296,17 @@
uint32_t currentTransitionSelection;
static_cast<AppDelegate *>(appDel).switcherTransitionParameters->GetNextTransitionSelection(&currentTransitionSelection);

for (int i = 0; i < ((int) reinterpret_cast<AppDelegate *>(appDel).keyers.size()); i++) {
for (int i = 0; i < ((int) reinterpret_cast<AppDelegate *>(appDel).keyers.size()) + 1; i++) {
uint32_t requestedTransitionSelection = transitionSelections[i];

// Deprecated
OSCMessage *oldMsg = [OSCMessage createWithAddress:[NSString stringWithFormat:@"/atem/nextusk/%d",i+1]];
OSCMessage *oldMsg = [OSCMessage createWithAddress:[NSString stringWithFormat:@"/atem/nextusk/%d",i]];
[oldMsg addInt: ((requestedTransitionSelection & currentTransitionSelection) == requestedTransitionSelection)];
[static_cast<AppDelegate *>(appDel).outPort sendThisMessage:oldMsg];

OSCMessage *newMsg = [OSCMessage createWithAddress:[NSString stringWithFormat:@"/atem/usk/%d/tie",i+1]];
OSCMessage *newMsg = [OSCMessage createWithAddress:[NSString stringWithFormat:@"/atem/usk/%d/tie",i]];
[newMsg addInt: ((requestedTransitionSelection & currentTransitionSelection) == requestedTransitionSelection)];
[static_cast<AppDelegate *>(appDel).outPort sendThisMessage:newMsg];

IBMDSwitcherKey* key = static_cast<AppDelegate *>(appDel).keyers[i];
bool onAir;
key->GetOnAir(&onAir);

OSCMessage *newMsg2 = [OSCMessage createWithAddress:[NSString stringWithFormat:@"/atem/usk/%d/on-air",i+1]];
[newMsg2 addInt: onAir];
[static_cast<AppDelegate *>(appDel).outPort sendThisMessage:newMsg2];
}
}

Expand Down
3 changes: 2 additions & 1 deletion atemOSC/OSCAddressPanel.mm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ - (void)setupWithDelegate:(AppDelegate *)appDel
[self addEntry:@"Set to DVE" forAddress:@"/atem/transition/set-type/dve" toString:helpString];

[self addHeader:@"Upstream Keyers" toString:helpString];
[self addEntry:@"BKGD" forAddress:@"/atem/usk/0/tie" toString:helpString];
[self addEntry:@"Set Tie BKGD" forAddress:@"/atem/usk/0/tie" toString:helpString];
[self addEntry:@"Toggle Tie BKGD" forAddress:@"/atem/usk/0/tie/toggle" toString:helpString];
for (int i = 0; i<[appDel keyers].size();i++)
{
[self addEntry:[NSString stringWithFormat:@"Set USK%d On Air",i+1] forAddress:[NSString stringWithFormat:@"/atem/usk/%d/on-air\t<0|1>",i+1] toString:helpString];
Expand Down
13 changes: 12 additions & 1 deletion atemOSC/OSCReceiver.mm
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,17 @@ - (void) receivedOSCMessage:(OSCMessage *)m
}
}

// Auto on-air
else if ([address count] == 6 && [[address objectAtIndex:5] isEqualToString:@"auto"])
{
if (IBMDSwitcherDownstreamKey* key = [self getDSK:t])
{
bool isTransitioning;
key->IsAutoTransitioning(&isTransitioning);
if (!isTransitioning) key->PerformAutoTransition();
}
}

// Set on-air
else if ([address count] == 5)
{
Expand All @@ -345,7 +356,7 @@ - (void) receivedOSCMessage:(OSCMessage *)m
}

else
[appDel logMessage:@"You must specify a dsk on-air command of 'toggle' or send a value to cut the usk on or off air"];
[appDel logMessage:@"You must specify a dsk on-air command of 'toggle' or send a value to cut the dsk on or off air"];
}

else
Expand Down
Binary file modified samples/Advanced Video Control.touchosc
Binary file not shown.

0 comments on commit 45e9351

Please sign in to comment.