/// <summary> /// Setup the actions to take place on various incoming API calls /// </summary> void SetupFunctions() { Parent.AddAction(@"/room/room1/promptForCode", new Action(() => EISC.PulseBool(JoinMap.PromptForCode.JoinNumber))); Parent.AddAction(@"/room/room1/clientJoined", new Action(() => EISC.PulseBool(JoinMap.ClientJoined.JoinNumber))); Parent.AddAction(@"/room/room1/status", new Action(SendFullStatus)); Parent.AddAction(@"/room/room1/source", new Action <SourceSelectMessageContent>(c => { EISC.SetString(JoinMap.CurrentSourceKey.JoinNumber, c.SourceListItem); EISC.PulseBool(JoinMap.SourceHasChanged.JoinNumber); })); Parent.AddAction(@"/room/room1/defaultsource", new Action(() => EISC.PulseBool(JoinMap.ActivityShare.JoinNumber))); Parent.AddAction(@"/room/room1/activityPhone", new Action(() => EISC.PulseBool(JoinMap.ActivityPhoneCall.JoinNumber))); Parent.AddAction(@"/room/room1/activityVideo", new Action(() => EISC.PulseBool(JoinMap.ActivityVideoCall.JoinNumber))); Parent.AddAction(@"/room/room1/volumes/master/level", new Action <ushort>(u => EISC.SetUshort(JoinMap.MasterVolume.JoinNumber, u))); Parent.AddAction(@"/room/room1/volumes/master/muteToggle", new Action(() => EISC.PulseBool(JoinMap.MasterVolume.JoinNumber))); Parent.AddAction(@"/room/room1/volumes/master/privacyMuteToggle", new Action(() => EISC.PulseBool(JoinMap.PrivacyMute.JoinNumber))); // /xyzxyz/volumes/master/muteToggle ---> BoolInput[1] var volumeStart = JoinMap.VolumeJoinStart.JoinNumber; var volumeEnd = JoinMap.VolumeJoinStart.JoinNumber + JoinMap.VolumeJoinStart.JoinSpan; for (uint i = volumeStart; i <= volumeEnd; i++) { var index = i; Parent.AddAction(string.Format(@"/room/room1/volumes/level-{0}/level", index), new Action <ushort>(u => EISC.SetUshort(index, u))); Parent.AddAction(string.Format(@"/room/room1/volumes/level-{0}/muteToggle", index), new Action(() => EISC.PulseBool(index))); } Parent.AddAction(@"/room/room1/shutdownStart", new Action(() => EISC.PulseBool(JoinMap.ShutdownStart.JoinNumber))); Parent.AddAction(@"/room/room1/shutdownEnd", new Action(() => EISC.PulseBool(JoinMap.ShutdownEnd.JoinNumber))); Parent.AddAction(@"/room/room1/shutdownCancel", new Action(() => EISC.PulseBool(JoinMap.ShutdownCancel.JoinNumber))); }
/// <summary> /// Setup the actions to take place on various incoming API calls /// </summary> void SetupFunctions() { Parent.AddAction(@"/room/room1/promptForCode", new Action(() => EISC.PulseBool(BoolJoin.PromptForCode))); Parent.AddAction(@"/room/room1/clientJoined", new Action(() => EISC.PulseBool(BoolJoin.ClientJoined))); Parent.AddAction(@"/room/room1/status", new Action(SendFullStatus)); Parent.AddAction(@"/room/room1/source", new Action <SourceSelectMessageContent>(c => { EISC.SetString(StringJoin.SelectedSourceKey, c.SourceListItem); EISC.PulseBool(BoolJoin.SourceHasChanged); })); Parent.AddAction(@"/room/room1/defaultsource", new Action(() => EISC.PulseBool(BoolJoin.ActivityShare))); Parent.AddAction(@"/room/room1/activityPhone", new Action(() => EISC.PulseBool(BoolJoin.ActivityPhoneCall))); Parent.AddAction(@"/room/room1/activityVideo", new Action(() => EISC.PulseBool(BoolJoin.ActivityVideoCall))); Parent.AddAction(@"/room/room1/volumes/master/level", new Action <ushort>(u => EISC.SetUshort(UshortJoin.MasterVolumeLevel, u))); Parent.AddAction(@"/room/room1/volumes/master/muteToggle", new Action(() => EISC.PulseBool(BoolJoin.MasterVolumeIsMuted))); Parent.AddAction(@"/room/room1/volumes/master/privacyMuteToggle", new Action(() => EISC.PulseBool(BoolJoin.PrivacyMute))); // /xyzxyz/volumes/master/muteToggle ---> BoolInput[1] for (uint i = 2; i <= 7; i++) { var index = i; Parent.AddAction(string.Format(@"/room/room1/volumes/level-{0}/level", index), new Action <ushort>(u => EISC.SetUshort(index, u))); Parent.AddAction(string.Format(@"/room/room1/volumes/level-{0}/muteToggle", index), new Action(() => EISC.PulseBool(index))); } Parent.AddAction(@"/room/room1/shutdownStart", new Action(() => EISC.PulseBool(BoolJoin.ShutdownStart))); Parent.AddAction(@"/room/room1/shutdownEnd", new Action(() => EISC.PulseBool(BoolJoin.ShutdownEnd))); Parent.AddAction(@"/room/room1/shutdownCancel", new Action(() => EISC.PulseBool(BoolJoin.ShutdownCancel))); }
/// <summary> /// Reads in config values when the Simpl program is ready /// </summary> void LoadConfigValues() { Debug.Console(1, this, "Loading configuration from DDVC01 EISC bridge"); ConfigIsLoaded = false; var co = ConfigReader.ConfigObject; co.Info.RuntimeInfo.AppName = Assembly.GetExecutingAssembly().GetName().Name; var version = Assembly.GetExecutingAssembly().GetName().Version; co.Info.RuntimeInfo.AssemblyVersion = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build); //Room //if (co.Rooms == null) // always start fresh in case simpl changed co.Rooms = new List <DeviceConfig>(); var rm = new DeviceConfig(); if (co.Rooms.Count == 0) { Debug.Console(0, this, "Adding room to config"); co.Rooms.Add(rm); } else { Debug.Console(0, this, "Replacing Room[0] in config"); co.Rooms[0] = rm; } rm.Name = EISC.StringOutput[StringJoin.ConfigRoomName].StringValue; rm.Key = "room1"; rm.Type = "ddvc01"; DDVC01RoomPropertiesConfig rmProps; if (rm.Properties == null) { rmProps = new DDVC01RoomPropertiesConfig(); } else { rmProps = JsonConvert.DeserializeObject <DDVC01RoomPropertiesConfig>(rm.Properties.ToString()); } rmProps.Help = new EssentialsHelpPropertiesConfig(); rmProps.Help.CallButtonText = EISC.StringOutput[StringJoin.ConfigHelpNumber].StringValue; rmProps.Help.Message = EISC.StringOutput[StringJoin.ConfigHelpMessage].StringValue; rmProps.Environment = new EssentialsEnvironmentPropertiesConfig(); // enabled defaults to false rmProps.RoomPhoneNumber = EISC.StringOutput[StringJoin.ConfigRoomPhoneNumber].StringValue; rmProps.RoomURI = EISC.StringOutput[StringJoin.ConfigRoomURI].StringValue; rmProps.SpeedDials = new List <DDVC01SpeedDial>(); // This MAY need a check rmProps.AudioCodecKey = "audioCodec"; rmProps.VideoCodecKey = "videoCodec"; // volume control names var volCount = EISC.UShortOutput[UshortJoin.NumberOfAuxFaders].UShortValue; //// use Volumes object or? //rmProps.VolumeSliderNames = new List<string>(); //for(uint i = 701; i <= 700 + volCount; i++) //{ // rmProps.VolumeSliderNames.Add(EISC.StringInput[i].StringValue); //} // There should be Mobile Control devices in here, I think... if (co.Devices == null) { co.Devices = new List <DeviceConfig>(); } // clear out previous DDVC devices co.Devices.RemoveAll(d => d.Key.StartsWith("source-", StringComparison.OrdinalIgnoreCase) || d.Key.Equals("audioCodec", StringComparison.OrdinalIgnoreCase) || d.Key.Equals("videoCodec", StringComparison.OrdinalIgnoreCase)); rmProps.SourceListKey = "default"; rm.Properties = JToken.FromObject(rmProps); // Source list! This might be brutal!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! var groupMap = GetSourceGroupDictionary(); co.SourceLists = new Dictionary <string, Dictionary <string, SourceListItem> >(); var newSl = new Dictionary <string, SourceListItem>(); // add "none" source if VTC present if (!string.IsNullOrEmpty(rmProps.VideoCodecKey)) { var codecOsd = new SourceListItem() { Name = "None", IncludeInSourceList = true, Order = 1, Type = eSourceListItemType.Route, SourceKey = "" }; newSl.Add("Source-None", codecOsd); } // add sources... for (uint i = 0; i <= 19; i++) { var name = EISC.StringOutput[StringJoin.SourceNameJoinStart + i].StringValue; if (EISC.BooleanOutput[BoolJoin.UseSourceEnabled].BoolValue && !EISC.BooleanOutput[BoolJoin.SourceIsEnabledJoinStart + i].BoolValue) { continue; } else if (!EISC.BooleanOutput[BoolJoin.UseSourceEnabled].BoolValue && string.IsNullOrEmpty(name)) { break; } var icon = EISC.StringOutput[StringJoin.SourceIconJoinStart + i].StringValue; var key = EISC.StringOutput[StringJoin.SourceKeyJoinStart + i].StringValue; var type = EISC.StringOutput[StringJoin.SourceTypeJoinStart + i].StringValue; var disableShare = EISC.BooleanOutput[BoolJoin.SourceShareDisableJoinStart + i].BoolValue; Debug.Console(0, this, "Adding source {0} '{1}'", key, name); var newSLI = new SourceListItem { Icon = icon, Name = name, Order = (int)i + 10, SourceKey = key, Type = eSourceListItemType.Route, DisableCodecSharing = disableShare, }; newSl.Add(key, newSLI); string group = "genericsource"; if (groupMap.ContainsKey(type)) { group = groupMap[type]; } // add dev to devices list var devConf = new DeviceConfig { Group = group, Key = key, Name = name, Type = type }; co.Devices.Add(devConf); if (group.ToLower().StartsWith("settopbox")) // Add others here as needed { SetupSourceFunctions(key); } } co.SourceLists.Add("default", newSl); // Build "audioCodec" config if we need if (!string.IsNullOrEmpty(rmProps.AudioCodecKey)) { var acFavs = new List <PepperDash.Essentials.Devices.Common.Codec.CodecActiveCallItem>(); for (uint i = 0; i < 4; i++) { if (!EISC.GetBool(BoolJoin.SpeedDialVisibleStartJoin + i)) { break; } acFavs.Add(new PepperDash.Essentials.Devices.Common.Codec.CodecActiveCallItem() { Name = EISC.GetString(StringJoin.SpeedDialNameStartJoin + i), Number = EISC.GetString(StringJoin.SpeedDialNumberStartJoin + i), Type = PepperDash.Essentials.Devices.Common.Codec.eCodecCallType.Audio }); } var acProps = new { favorites = acFavs }; var acStr = "audioCodec"; var acConf = new DeviceConfig() { Group = acStr, Key = acStr, Name = acStr, Type = acStr, Properties = JToken.FromObject(acProps) }; co.Devices.Add(acConf); } // Build Video codec config if (!string.IsNullOrEmpty(rmProps.VideoCodecKey)) { // No favorites, for now? var favs = new List <PepperDash.Essentials.Devices.Common.Codec.CodecActiveCallItem>(); // cameras var camsProps = new List <object>(); for (uint i = 0; i < 9; i++) { var name = EISC.GetString(i + StringJoin.CameraNearNameStart); if (!string.IsNullOrEmpty(name)) { camsProps.Add(new { name = name, selector = "camera" + (i + 1), }); } } var farName = EISC.GetString(StringJoin.CameraFarName); if (!string.IsNullOrEmpty(farName)) { camsProps.Add(new { name = farName, selector = "cameraFar", }); } var props = new { favorites = favs, cameras = camsProps, }; var str = "videoCodec"; var conf = new DeviceConfig() { Group = str, Key = str, Name = str, Type = str, Properties = JToken.FromObject(props) }; co.Devices.Add(conf); } Debug.Console(0, this, "******* CONFIG FROM DDVC: \r{0}", JsonConvert.SerializeObject(ConfigReader.ConfigObject, Formatting.Indented)); var handler = ConfigurationIsReady; if (handler != null) { handler(this, new EventArgs()); } ConfigIsLoaded = true; }
/// <summary> /// Links feedbacks to whatever is gonna happen! /// </summary> void SetupFeedbacks() { // Power EISC.SetBoolSigAction(BoolJoin.RoomIsOn, b => PostStatusMessage(new { isOn = b })); // Source change things EISC.SetSigTrueAction(BoolJoin.SourceHasChanged, () => PostStatusMessage(new { selectedSourceKey = EISC.StringOutput[StringJoin.SelectedSourceKey].StringValue })); // Volume things EISC.SetUShortSigAction(UshortJoin.MasterVolumeLevel, u => PostStatusMessage(new { volumes = new { master = new { level = u } } })); // map MasterVolumeIsMuted join -> status/volumes/master/muted // EISC.SetBoolSigAction(BoolJoin.MasterVolumeIsMuted, b => PostStatusMessage(new { volumes = new { master = new { muted = b } } })); EISC.SetBoolSigAction(BoolJoin.PrivacyMute, b => PostStatusMessage(new { volumes = new { master = new { privacyMuted = b } } })); for (uint i = 2; i <= 7; i++) { var index = i; // local scope for lambdas EISC.SetUShortSigAction(index, u => // start at join 2 { // need a dict in order to create the level-n property on auxFaders var dict = new Dictionary <string, object>(); dict.Add("level-" + index, new { level = u }); PostStatusMessage(new { volumes = new { auxFaders = dict, } }); }); EISC.SetBoolSigAction(index, b => { // need a dict in order to create the level-n property on auxFaders var dict = new Dictionary <string, object>(); dict.Add("level-" + index, new { muted = b }); PostStatusMessage(new { volumes = new { auxFaders = dict, } }); }); } EISC.SetUShortSigAction(UshortJoin.NumberOfAuxFaders, u => PostStatusMessage(new { volumes = new { numberOfAuxFaders = u, } })); // shutdown things EISC.SetSigTrueAction(BoolJoin.ShutdownCancel, new Action(() => PostMessage("/room/shutdown/", new { state = "wasCancelled" }))); EISC.SetSigTrueAction(BoolJoin.ShutdownEnd, new Action(() => PostMessage("/room/shutdown/", new { state = "hasFinished" }))); EISC.SetSigTrueAction(BoolJoin.ShutdownStart, new Action(() => PostMessage("/room/shutdown/", new { state = "hasStarted", duration = EISC.UShortOutput[UshortJoin.ShutdownPromptDuration].UShortValue }))); // Config things EISC.SetSigTrueAction(BoolJoin.ConfigIsReady, LoadConfigValues); // Activity modes EISC.SetSigTrueAction(BoolJoin.ActivityShare, () => UpdateActivity(1)); EISC.SetSigTrueAction(BoolJoin.ActivityPhoneCall, () => UpdateActivity(2)); EISC.SetSigTrueAction(BoolJoin.ActivityVideoCall, () => UpdateActivity(3)); }
/// <summary> /// /// </summary> /// <param name="devKey"></param> void SetupSourceFunctions(string devKey) { SourceDeviceMapDictionary sourceJoinMap = new SourceDeviceMapDictionary(); var prefix = string.Format("/device/{0}/", devKey); foreach (var item in sourceJoinMap) { var join = item.Value; Parent.AddAction(string.Format("{0}{1}", prefix, item.Key), new PressAndHoldAction(b => EISC.SetBool(join, b))); } }