Skip to content

Commit

Permalink
Merge pull request #15 from kjgriffin/PresentationActions
Browse files Browse the repository at this point in the history
Presentation actions
  • Loading branch information
kjgriffin authored Jan 10, 2021
2 parents 1ac4ae9 + 6351e20 commit bc40cf4
Show file tree
Hide file tree
Showing 57 changed files with 1,891 additions and 175 deletions.
48 changes: 29 additions & 19 deletions Integrated Presenter/AudioPlayer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,37 @@ private void ClickLoadAudio(object sender, RoutedEventArgs e)
if (ofd.ShowDialog() == true)
{
string filename = ofd.FileName;
try
{
tbFileName.Text = filename;
AudioSource = new Uri(filename);
audioplayer.Source = AudioSource;
}
catch (Exception)
{
}
Dispatcher.Invoke(() =>
{
StopAudio();
PlaybackTimer.Interval = 500;
PlaybackTimer.Start();
BtnPlayAudio.Style = Application.Current.FindResource("SwitcherButton") as Style;
BtnPauseAudio.Style = Application.Current.FindResource("SwitcherButton") as Style;
BtnStopAudio.Style = Application.Current.FindResource("SwitcherButton") as Style;
BtnRestartAudio.Style = Application.Current.FindResource("SwitcherButton") as Style;
});
openAudio(filename);
}
}

private void openAudio(string filename)
{
try
{
tbFileName.Text = filename;
AudioSource = new Uri(filename);
audioplayer.Source = AudioSource;
}
catch (Exception)
{
}
Dispatcher.Invoke(() =>
{
StopAudio();
PlaybackTimer.Interval = 500;
PlaybackTimer.Start();
BtnPlayAudio.Style = Application.Current.FindResource("SwitcherButton") as Style;
BtnPauseAudio.Style = Application.Current.FindResource("SwitcherButton") as Style;
BtnStopAudio.Style = Application.Current.FindResource("SwitcherButton") as Style;
BtnRestartAudio.Style = Application.Current.FindResource("SwitcherButton") as Style;
});

}

public void OpenAudio(string filename)
{
openAudio(filename);
}

private void ClickRestartAudio(object sender, RoutedEventArgs e)
Expand Down
23 changes: 23 additions & 0 deletions Integrated Presenter/BMDSwitcher/BMDSwitcherAuxMonitor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
using BMDSwitcherAPI;

namespace Integrated_Presenter.BMDSwitcher
{
class BMDSwitcherAuxMonitor : IBMDSwitcherInputAuxCallback
{
public event SwitcherEventHandler OnAuxInputChanged;
public void Notify(_BMDSwitcherInputAuxEventType eventType)
{
switch (eventType)
{
case _BMDSwitcherInputAuxEventType.bmdSwitcherInputAuxEventTypeInputSourceChanged:
OnAuxInputChanged?.Invoke(this, null);
break;
default:
break;
}
}
}
}
73 changes: 71 additions & 2 deletions Integrated Presenter/BMDSwitcher/BMDSwitcherManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class BMDSwitcherManager : IBMDSwitcherManager
private IBMDSwitcher _BMDSwitcher;

private IBMDSwitcherMixEffectBlock _BMDSwitcherMixEffectBlock1;
private IBMDSwitcherInputAux _BMDSwitcherAuxInput;
private IBMDSwitcherKey _BMDSwitcherUpstreamKey1;
private IBMDSwitcherDownstreamKey _BMDSwitcherDownstreamKey1;
private IBMDSwitcherDownstreamKey _BMDSwitcherDownstreamKey2;
Expand All @@ -37,6 +38,7 @@ public class BMDSwitcherManager : IBMDSwitcherManager

private SwitcherMonitor _switcherMonitor;
private MixEffectBlockMonitor _mixEffectBlockMonitor;
private BMDSwitcherAuxMonitor _auxMonitor;
private UpstreamKeyMonitor _upstreamKey1Monitor;
private DownstreamKeyMonitor _dsk1Monitor;
private DownstreamKeyMonitor _dsk2Monitor;
Expand Down Expand Up @@ -71,6 +73,9 @@ public BMDSwitcherManager(Window parent)
_mixEffectBlockMonitor.ProgramInputChanged += _mixEffectBlockMonitor_ProgramInputChanged;
_mixEffectBlockMonitor.FateToBlackFullyChanged += _mixEffectBlockMonitor_FateToBlackFullyChanged;

_auxMonitor = new BMDSwitcherAuxMonitor();
_auxMonitor.OnAuxInputChanged += _auxMonitor_OnAuxInputChanged;

_upstreamKey1Monitor = new UpstreamKeyMonitor();
_upstreamKey1Monitor.UpstreamKeyOnAirChanged += _upstreamKey1Monitor_UpstreamKeyOnAirChanged;
_upstreamKey1Monitor.UpstreamKeyFillChanged += _upstreamKey1Monitor_UpstreamKeyFillChanged;
Expand Down Expand Up @@ -98,6 +103,15 @@ public BMDSwitcherManager(Window parent)
SwitcherDisconnected();
}

private void _auxMonitor_OnAuxInputChanged(object sender, object args)
{
_parent.Dispatcher.Invoke(() =>
{
ForceStateUpdate();
SwitcherStateChanged?.Invoke(_state);
});
}

private void _upstreamKey1Monitor_UpstreamKeyTypeChanged(object sender, object args)
{
_parent.Dispatcher.Invoke(() =>
Expand Down Expand Up @@ -291,6 +305,33 @@ private bool InitializeInputSources()
return true;
}

private bool InitializeAuxInput()
{
// get all input sources
IBMDSwitcherInputIterator inputIterator = null;
IntPtr inputIteratorPtr;
Guid inputIteratorIID = typeof(IBMDSwitcherInputIterator).GUID;
_BMDSwitcher.CreateIterator(ref inputIteratorIID, out inputIteratorPtr);
if (inputIteratorPtr != null)
{
inputIterator = (IBMDSwitcherInputIterator)Marshal.GetObjectForIUnknown(inputIteratorPtr);
}
else
{
return false;
}
if (inputIterator != null)
{
IBMDSwitcherInput aux;
inputIterator.GetById((long)BMDSwitcherVideoSources.Auxillary1, out aux);
_BMDSwitcherAuxInput = (IBMDSwitcherInputAux)aux;
_BMDSwitcherAuxInput.AddCallback(_auxMonitor);
return true;
}

return false;
}

private bool InitializeMultiView()
{
IntPtr multiViewPtr;
Expand Down Expand Up @@ -443,12 +484,13 @@ private void SwitcherConnected()
bool downstreamkeyers = InitializeDownstreamKeyers();

bool inputsources = InitializeInputSources();
bool auxsource = InitializeAuxInput();
bool multiviewer = InitializeMultiView();

bool mediapool = InitializeMediaPool();
bool mediaplayers = InitializeMediaPlayers();

GoodConnection = mixeffects && downstreamkeyers && upstreamkeyers && inputsources && multiviewer && mediaplayers && mediapool;
GoodConnection = mixeffects && auxsource && downstreamkeyers && upstreamkeyers && inputsources && multiviewer && mediaplayers && mediapool;

MessageBox.Show("Connected to Switcher", "Connection Success");

Expand Down Expand Up @@ -490,6 +532,12 @@ private void SwitcherDisconnected()
_BMDSwitcherDownstreamKey2 = null;
}

if (_BMDSwitcherAuxInput != null)
{
_BMDSwitcherAuxInput.RemoveCallback(_auxMonitor);
_BMDSwitcherAuxInput = null;
}

if (_BMDSwitcher != null)
{
_BMDSwitcher.RemoveCallback(_switcherMonitor);
Expand Down Expand Up @@ -522,6 +570,7 @@ public BMDSwitcherState ForceStateUpdate()
// update state
ForceStateUpdate_ProgramInput();
ForceStateUpdate_PreviewInput();
ForceStateUpdate_AuxInput();
ForceStateUpdate_Transition();
ForceStateUpdate_USK1();
ForceStateUpdate_ChromaSettings();
Expand All @@ -533,7 +582,12 @@ public BMDSwitcherState ForceStateUpdate()
return _state;
}


private void ForceStateUpdate_AuxInput()
{
long source;
_BMDSwitcherAuxInput.GetInputSource(out source);
_state.AuxID = source;
}

private void ForceStateUpdate_USK1()
{
Expand Down Expand Up @@ -653,6 +707,7 @@ public void ConfigureSwitcher(BMDSwitcherConfigSettings config)
{
_config = config;
ConfigureMixEffectBlock();
ConfigureAux();
ConfigureCameraSources();
ConfigureDownstreamKeys();
ConfigureMultiviewer();
Expand All @@ -664,6 +719,11 @@ public void ConfigureSwitcher(BMDSwitcherConfigSettings config)
ForceStateUpdate();
}

private void ConfigureAux()
{
_BMDSwitcherAuxInput.SetInputSource(_config.DefaultAuxSource);
}

private void ConfigureMixEffectBlock()
{
_BMDSwitcherMixEffectBlock1.SetFadeToBlackRate((uint)_config.MixEffectSettings.FTBRate);
Expand Down Expand Up @@ -1249,5 +1309,14 @@ public void PerformSetKey1OffForNextTrans()
{

}

public void PerformAuxSelect(int sourceID)
{
_parent.Dispatcher.Invoke(() =>
{
_BMDSwitcherAuxInput?.SetInputSource(sourceID);
ForceStateUpdate();
});
}
}
}
3 changes: 3 additions & 0 deletions Integrated Presenter/BMDSwitcher/BMDSwitcherState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class BMDSwitcherState

public long PresetID { get; set; }
public long ProgramID { get; set; }
public long AuxID { get; set; }

public bool USK1OnAir { get; set; }
public long USK1FillSource { get; set; }
Expand Down Expand Up @@ -44,6 +45,7 @@ public void SetDefault()
{
PresetID = -1;
ProgramID = -1;
AuxID = -1;
DSK1OnAir = false;
USK1OnAir = false;
USK1KeyType = 1;
Expand Down Expand Up @@ -115,6 +117,7 @@ public BMDSwitcherState Copy()
{
PresetID = this.PresetID,
ProgramID = this.ProgramID,
AuxID = this.AuxID,
USK1OnAir = this.USK1OnAir,
USK1KeyType = this.USK1KeyType,
USK1FillSource = this.USK1FillSource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public enum BMDSwitcherVideoSources
DSK2Mask = 5020,
SuperSource = 6000,
CleanFeed1 = 7001,
CleenFeed2 = 7002,
CleanFeed2 = 7002,
Auxillary1 = 8001,
// Aux 800x
Auxillary6 = 8006,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class BMDSwitcherConfigSettings

public List<ButtonSourceMapping> Routing { get; set; } = new List<ButtonSourceMapping>();

public int DefaultAuxSource { get; set; }

public BMDDSKSettings DownstreamKey1Config { get; set; } = new BMDDSKSettings();

public BMDDSKSettings DownstreamKey2Config { get; set; } = new BMDDSKSettings();
Expand Down
1 change: 1 addition & 0 deletions Integrated Presenter/BMDSwitcher/IBMDSwitcherManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public interface IBMDSwitcherManager
void PerformCutTransition();
void PerformPresetSelect(int sourceID);
void PerformProgramSelect(int sourceID);
void PerformAuxSelect(int sourceID);
void PerformTakeAutoDSK1();
void PerformTakeAutoDSK2();
void PerformTieDSK1();
Expand Down
18 changes: 12 additions & 6 deletions Integrated Presenter/BMDSwitcher/Mock/MockBMDSwitcherManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public MockBMDSwitcherManager(MainWindow parent)
_state.SetDefault();
Dictionary<int, string> mapping = new Dictionary<int, string>()
{
[1] = "center",
[2] = "organ",
[3] = "cam3",
[1] = "cam1",
[2] = "pres",
[3] = "key",
[4] = "slide",
[5] = "left",
[5] = "organ",
[6] = "right",
[7] = "cam7",
[8] = "cam8"
[7] = "center",
[8] = "left"
};
mockMultiviewer = new MockMultiviewer(mapping, parent.Config);
parent.PresentationStateUpdated += Parent_PresentationStateUpdated;
Expand Down Expand Up @@ -372,5 +372,11 @@ public void PerformSetKey1OffForNextTrans()
mockMultiviewer.SetUSK1ForNextTrans(false, _state);
SwitcherStateChanged?.Invoke(_state);
}

public void PerformAuxSelect(int sourceID)
{
_state.AuxID = sourceID;
SwitcherStateChanged?.Invoke(_state);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<Image Name="ImgSlide" Grid.ColumnSpan="1" Source="/BMDSwitcher/Mock/Images/black.png"></Image>
</Border>
<Border Background="Black" Grid.Row="2" Grid.Column="1" BorderBrush="Gray" BorderThickness="2,2,2,2">
<Image Grid.ColumnSpan="1"></Image>
<Image Name="ImgKey" Grid.ColumnSpan="1"></Image>
</Border>
<Border Background="Black" Grid.Row="2" Grid.Column="2" BorderBrush="Gray" BorderThickness="2,2,2,2">
<Image Grid.ColumnSpan="1"></Image>
Expand Down
Loading

0 comments on commit bc40cf4

Please sign in to comment.