revisiting inheritance

This commit is contained in:
Andrew Welker
2020-07-13 13:41:44 -06:00
parent 9a3cde0a30
commit c31a2a09de
12 changed files with 492 additions and 238 deletions

View File

@@ -1,9 +1,5 @@
using System.Collections.Generic;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Core;
using Newtonsoft.Json;
using PepperDash.Essentials.Core.Config;
namespace PepperDash.Essentials.Core.Rooms.Config
{

View File

@@ -210,7 +210,6 @@ namespace PepperDash.Essentials.Core
/// </summary>
public event EventHandler<EventArgs> RoomOccupancyIsSet;
private void SetupRoomVacancyShutdown()
{
RoomVacancyShutdownTimer = new SecondsCountdownTimer(Key + "-vacancyOffTimer");

View File

@@ -4,27 +4,17 @@ using System.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Devices.AudioCodec;
using PepperDash.Essentials.Core.Devices.VideoCodec;
using PepperDash.Essentials.Core.Rooms;
using PepperDash.Essentials.Core.Rooms.Config;
using PepperDash_Essentials_Core.Devices;
namespace PepperDash.Essentials
{
public class EssentialsDualDisplayRoom : EssentialsRoomBase, IHasCurrentSourceInfoChange,
IPrivacy, IHasCurrentVolumeControls, IRunRouteAction, IRunDefaultCallRoute, IHasVideoCodec, IHasAudioCodec,
IHasDefaultDisplay, IHasInCallFeedback
public class EssentialsDualDisplayRoom : EssentialsHuddleVtc1Room
{
public const string DefaultDestinationListKey = "default";
private const string LeftDestinationKey = "leftDisplay";
private const string RightDestinationKey = "rightDisplay";
/// <summary>
/// "codecOsd"
/// </summary>
public const string DefaultCodecRouteString = "codecOsd";
private readonly EssentialsDualDisplayRoomPropertiesConfig _config;
private string _destinationListKey;
@@ -33,23 +23,6 @@ namespace PepperDash.Essentials
{
_config = config.Properties.ToObject<EssentialsDualDisplayRoomPropertiesConfig>();
DefaultDisplay = DeviceManager.GetDeviceForKey(_config.DefaultDisplayKey) as IRoutingSinkWithSwitching;
DefaultAudioDevice = DeviceManager.GetDeviceForKey(_config.DefaultAudioKey) as IRoutingSinkWithSwitching;
VideoCodec = DeviceManager.GetDeviceForKey(_config.VideoCodecKey) as VideoCodecBase;
if (VideoCodec == null)
{
throw new ArgumentNullException("codec cannot be null");
}
AudioCodec = DeviceManager.GetDeviceForKey(_config.AudioCodecKey) as AudioCodecBase;
if (AudioCodec == null)
{
Debug.Console(0, this, "No audio codec found");
}
Initialize();
}
@@ -63,109 +36,15 @@ namespace PepperDash.Essentials
public IRoutingSinkWithSwitching LeftDisplay { get; private set; }
public IRoutingSinkWithSwitching RightDisplay { get; private set; }
#region IHasAudioCodec Members
public AudioCodecBase AudioCodec { get; private set; }
#endregion
#region IHasVideoCodec Members
public BoolFeedback InCallFeedback { get; private set; }
public IntFeedback CallTypeFeedback { get; private set; }
public BoolFeedback IsSharingFeedback { get; private set; }
public VideoCodecBase VideoCodec { get; private set; }
#endregion
#region IPrivacy Members
public BoolFeedback PrivacyModeIsOnFeedback { get; private set; }
public void PrivacyModeOff()
{
VideoCodec.PrivacyModeOff();
}
public void PrivacyModeOn()
{
VideoCodec.PrivacyModeOn();
}
public void PrivacyModeToggle()
{
VideoCodec.PrivacyModeToggle();
}
#endregion
#region IRunDefaultCallRoute Members
/// <summary>
/// Sets up the room when started into call mode without presenting a source
/// </summary>
/// <returns></returns>
public bool RunDefaultCallRoute()
{
RunRouteAction(DefaultCodecRouteString);
return true;
}
#endregion
private void Initialize()
{
try
{
if (DefaultAudioDevice is IBasicVolumeControls)
{
DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls;
}
else if (DefaultAudioDevice is IHasVolumeDevice)
{
DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice;
}
CurrentVolumeControls = DefaultVolumeControls;
_destinationListKey = String.IsNullOrEmpty(_config.DestinationListKey)
? DefaultDestinationListKey
: _config.DestinationListKey;
SourceListKey = String.IsNullOrEmpty(_config.SourceListKey)
? DefaultSourceListKey
: _config.SourceListKey;
InitializeDestinations();
InCallFeedback = new BoolFeedback(() =>
{
var inAudioCall = AudioCodec != null && AudioCodec.IsInCall;
var inVideoCall = VideoCodec != null && VideoCodec.IsInCall;
return inAudioCall || inVideoCall;
});
MicrophonePrivacy = EssentialsRoomConfigHelper.GetMicrophonePrivacy(_config, this);
Emergency = EssentialsRoomConfigHelper.GetEmergency(_config, this);
VideoCodec.CallStatusChange += (o, a) => InCallFeedback.FireUpdate();
if (AudioCodec != null)
{
AudioCodec.CallStatusChange += (o, a) => InCallFeedback.FireUpdate();
}
IsSharingFeedback = new BoolFeedback(() => VideoCodec.SharingContentIsOnFeedback.BoolValue);
VideoCodec.SharingContentIsOnFeedback.OutputChange += (o, a) => IsSharingFeedback.FireUpdate();
PrivacyModeIsOnFeedback = new BoolFeedback(() => VideoCodec.PrivacyModeIsOnFeedback.BoolValue);
VideoCodec.PrivacyModeIsOnFeedback.OutputChange += (o, a) => PrivacyModeIsOnFeedback.FireUpdate();
CallTypeFeedback = new IntFeedback(() => 0);
}
catch (Exception e)
{

View File

@@ -21,15 +21,14 @@ namespace PepperDash.Essentials
/// </summary>
public const string DefaultCodecRouteString = "codecOsd";
public EssentialsHuddleVtc1PropertiesConfig PropertiesConfig { get; private set; }
public EssentialsHuddleVtc1PropertiesConfig PropertiesConfig { get; protected set; }
public EssentialsHuddleVtc1Room(DeviceConfig config)
: base(config)
{
try
{
PropertiesConfig = JsonConvert.DeserializeObject<EssentialsHuddleVtc1PropertiesConfig>
(config.Properties.ToString());
PropertiesConfig = config.Properties.ToObject<EssentialsHuddleVtc1PropertiesConfig>();
DefaultDisplay =
DeviceManager.GetDeviceForKey(PropertiesConfig.DefaultDisplayKey) as IRoutingSinkWithSwitching;
@@ -68,28 +67,28 @@ namespace PepperDash.Essentials
#region IHasAudioCodec Members
public AudioCodecBase AudioCodec { get; private set; }
public AudioCodecBase AudioCodec { get; protected set; }
#endregion
#region IHasVideoCodec Members
public BoolFeedback InCallFeedback { get; private set; }
public BoolFeedback InCallFeedback { get; protected set; }
/// <summary>
/// States: 0 for on hook, 1 for video, 2 for audio, 3 for telekenesis
/// </summary>
public IntFeedback CallTypeFeedback { get; private set; }
public IntFeedback CallTypeFeedback { get; protected set; }
/// <summary>
/// When something in the room is sharing with the far end or through other means
/// </summary>
public BoolFeedback IsSharingFeedback { get; private set; }
public BoolFeedback IsSharingFeedback { get; protected set; }
//************************
public VideoCodecBase VideoCodec { get; private set; }
public VideoCodecBase VideoCodec { get; protected set; }
#endregion
@@ -98,7 +97,7 @@ namespace PepperDash.Essentials
/// <summary>
///
/// </summary>
public BoolFeedback PrivacyModeIsOnFeedback { get; private set; }
public BoolFeedback PrivacyModeIsOnFeedback { get; protected set; }
public void PrivacyModeOff()
{
@@ -149,18 +148,8 @@ namespace PepperDash.Essentials
// Combines call feedback from both codecs if available
InCallFeedback = new BoolFeedback(() =>
{
var inAudioCall = false;
var inVideoCall = false;
if (AudioCodec != null)
{
inAudioCall = AudioCodec.IsInCall;
}
if (VideoCodec != null)
{
inVideoCall = VideoCodec.IsInCall;
}
var inAudioCall = AudioCodec != null && AudioCodec.IsInCall;
var inVideoCall = VideoCodec != null && VideoCodec.IsInCall;
return inAudioCall || inVideoCall;
});
@@ -192,7 +181,9 @@ namespace PepperDash.Essentials
CallTypeFeedback = new IntFeedback(() => 0);
SourceListKey = "default";
SourceListKey = String.IsNullOrEmpty(PropertiesConfig.SourceListKey)
? DefaultSourceListKey
: PropertiesConfig.SourceListKey;
EnablePowerOnToLastSource = true;
var disp = DefaultDisplay as DisplayBase;