Skip to content

Commit

Permalink
feat: adds speaker and presenter track messengers and instantiates on…
Browse files Browse the repository at this point in the history
… codec if MC running.
  • Loading branch information
ndorin committed Jun 28, 2024
1 parent a6b784b commit d41715a
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 31 deletions.
21 changes: 18 additions & 3 deletions src/CiscoRoomOsCodec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.Diagnostics;
using epi_videoCodec_ciscoExtended.Interfaces;
using epi_videoCodec_ciscoExtended.UserInterface.UserInterfaceExtensions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
Expand Down Expand Up @@ -87,7 +88,6 @@ public class CiscoCodec
IHasCodecLayoutsAvailable,
IHasCodecSelfView,
ICommunicationMonitor,
//IRouting,
IRoutingInputs,
IRoutingSource,
IHasCodecCameras,
Expand All @@ -104,7 +104,9 @@ public class CiscoCodec
IDeviceInfoProvider,
IHasPhoneDialing,
ICiscoCodecUiExtensionsController,
ICiscoCodecCameraConfig
ICiscoCodecCameraConfig,
ISpeakerTrack,
IPresenterTrack
{
public event EventHandler<AvailableLayoutsChangedEventArgs> AvailableLayoutsChanged;
public event EventHandler<CurrentLayoutChangedEventArgs> CurrentLayoutChanged;
Expand Down Expand Up @@ -1697,7 +1699,20 @@ public override bool CustomActivate()
CodecSchedule.MeetingsListHasChanged += (sender, args) => { };
CodecSchedule.MeetingEventChange += (sender, args) => { };

return base.CustomActivate();
var mc = DeviceManager.AllDevices.OfType<IMobileControl>().FirstOrDefault();

if (mc == null)
{
return base.CustomActivate();
}

var speakerTrackMessenger = new ISpeakerTrackMessenger($"speakerTrack-{Key}", $"/device/{Key}", this);
mc.AddDeviceMessenger(speakerTrackMessenger);

var presenterTrackMessenger = new IPresenterTrackMessenger($"presenterTrack-{Key}", $"/device/{Key}", this);
mc.AddDeviceMessenger(presenterTrackMessenger);

return base.CustomActivate();
}

private void CiscoCodec_CameraTrackingCapabilitiesChanged(
Expand Down
74 changes: 74 additions & 0 deletions src/Interfaces/IPresenterTrackMessenger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using PepperDash.Core;
using PepperDash.Essentials.AppServer.Messengers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace epi_videoCodec_ciscoExtended.Interfaces
{
internal class IPresenterTrackMessenger : MessengerBase
{
private readonly IPresenterTrack _presenterTrack;

public IPresenterTrackMessenger(string key, string messagePath, IPresenterTrack presenterTrack)
: base(key, messagePath, presenterTrack as Device)
{
_presenterTrack = presenterTrack;
}


protected override void RegisterActions()
{
if(_presenterTrack == null)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Error, $"{Key} does not implement IPresenterTrack", this, _presenterTrack.Key);
return;
}

AddAction("/fullStatus", (id, content) => SendFullStatus());

AddAction($"/presenterTrackOff", (id, context) => _presenterTrack.PresenterTrackOff());

AddAction($"/presenterTrackFollow", (id, context) => _presenterTrack.PresenterTrackFollow());

AddAction($"/presenterTrackBackground", (id, context) => _presenterTrack.PresenterTrackBackground());

AddAction($"/presenterTrackPersistent", (id, context) => _presenterTrack.PresenterTrackPersistent());

_presenterTrack.PresenterTrackAvailableFeedback.OutputChange += (o, a) => SendFullStatus();
_presenterTrack.PresenterTrackStatusOffFeedback.OutputChange += (o, a) => SendFullStatus();
_presenterTrack.PresenterTrackStatusFollowFeedback.OutputChange += (o, a) => SendFullStatus();
_presenterTrack.PresenterTrackStatusBackgroundFeedback.OutputChange += (o, a) => SendFullStatus();
_presenterTrack.PresenterTrackStatusPersistentFeedback.OutputChange += (o, a) => SendFullStatus();
}

private void SendFullStatus()
{
var message = new IPresenterTrackStateMessage
{
PresenterTrackAvailable = _presenterTrack.PresenterTrackAvailableFeedback.BoolValue,
PresenterTrackStatusOff = _presenterTrack.PresenterTrackStatusOffFeedback.BoolValue,
PresenterTrackStatusFollow = _presenterTrack.PresenterTrackStatusFollowFeedback.BoolValue,
PresenterTrackStatusBackground = _presenterTrack.PresenterTrackStatusBackgroundFeedback.BoolValue,
PresenterTrackStatusPersistent = _presenterTrack.PresenterTrackStatusPersistentFeedback.BoolValue
};

PostStatusMessage(message);
}
}

public class IPresenterTrackStateMessage : DeviceStateMessageBase
{
public bool? PresenterTrackAvailable { get; set; }

public bool? PresenterTrackStatusOff { get; set; }

public bool? PresenterTrackStatusFollow { get; set; }

public bool? PresenterTrackStatusBackground { get; set; }

public bool? PresenterTrackStatusPersistent { get; set; }
}
}
56 changes: 56 additions & 0 deletions src/Interfaces/ISpeakerTrackMessenger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.AppServer.Messengers;

namespace epi_videoCodec_ciscoExtended.Interfaces
{
public class ISpeakerTrackMessenger : MessengerBase
{
private readonly ISpeakerTrack _speakerTrack;

public ISpeakerTrackMessenger(string key, string messagePath, ISpeakerTrack device)
: base(key, messagePath, device as Device)
{
_speakerTrack = device ;
}

protected override void RegisterActions()
{
if(_speakerTrack == null)
{

Debug.LogMessage(Serilog.Events.LogEventLevel.Error, $"{Key} does not implement ISpeakerTrack", this, _speakerTrack.Key);
return;
}

AddAction("/fullStatus", (id, content) => SendFullStatus());

AddAction($"/speakerTrackOn", (id, context) => _speakerTrack.SpeakerTrackOn());

AddAction($"/speakerTrackOff", (id, context) => _speakerTrack.SpeakerTrackOff());

_speakerTrack.SpeakerTrackAvailableFeedback.OutputChange += (o, a) => SendFullStatus();
}

private void SendFullStatus()
{
var message = new ISpeakerTrackStateMessage
{
SpeakerTrackAvailability = _speakerTrack.SpeakerTrackAvailability,
SpeakerTrackStatus = _speakerTrack.SpeakerTrackStatus
};

PostStatusMessage(message);
}
}

public class ISpeakerTrackStateMessage: DeviceStateMessageBase
{
[JsonProperty("speakerTrackAvailability", NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public bool? SpeakerTrackAvailability { get; set; }

[JsonProperty("speakerTrackStatus", NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)]
public bool? SpeakerTrackStatus { get; set; }

}
}
13 changes: 4 additions & 9 deletions src/Interfaces/TrackingModes.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using PepperDash.Essentials.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using PepperDash.Core;
using PepperDash.Essentials.Core;
namespace epi_videoCodec_ciscoExtended.Interfaces
{
internal enum eCiscoCameraMode
Expand All @@ -17,7 +12,7 @@ internal enum eCiscoCameraMode
/// <summary>
/// Describes the available tracking modes for a Cisco codec
/// </summary>
internal interface ISpeakerTrack
public interface ISpeakerTrack : IKeyed
{
bool SpeakerTrackAvailability { get; }

Expand All @@ -29,7 +24,7 @@ internal interface ISpeakerTrack
void SpeakerTrackOn();
}

internal interface IPresenterTrack
public interface IPresenterTrack : IKeyed
{
bool PresenterTrackAvailability { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using PepperDash.Core;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using System.Security.Cryptography.X509Certificates;

namespace PepperDash.Essentials.Touchpanel
{
Expand All @@ -23,28 +24,9 @@ protected override void RegisterActions()
return;
}

// AddAction($"/fullStatus", (id, context) => SendFullStatus());

AddAction($"/closeWebViewController", (id, context) => _appControl.CloseWebViewController());

//_appControl.WebViewOpenFeedback.OutputChange += (s, a) =>
//{
// PostStatusMessage(JToken.FromObject(new
// {
// appOpen = a.BoolValue
// }));
//};
}

//private void SendFullStatus()
//{
// var message = new TswAppStateMessage
// {
// AppOpen = _appControl.AppOpenFeedback.BoolValue,
// };

// PostStatusMessage(message);
//}
}

//public class VideoCodecUserInterfaceAppStateMessage : DeviceStateMessageBase
Expand Down

0 comments on commit d41715a

Please sign in to comment.