generated from PepperDash/EssentialsPluginTemplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds speaker and presenter track messengers and instantiates on…
… codec if MC running.
- Loading branch information
Showing
5 changed files
with
153 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters