Adds null check before running RunRouteAction event in Cisco Spark class.

Fixes spelling error and other minor cleanup.
This commit is contained in:
Jason Alborough
2020-08-18 10:00:53 -04:00
parent 4e2683f8fc
commit 67f0ae92ef
2 changed files with 26 additions and 20 deletions

View File

@@ -59,13 +59,8 @@ namespace PepperDash.Essentials
set set
{ {
_SourceListKey = value; _SourceListKey = value;
if(VideoCodec is IHasExternalSourceSwitching) SetCodecExternalSources();
{
if((VideoCodec as IHasExternalSourceSwitching).ExternalSourceListEnabled)
{
SetCodecExternalSources();
}
}
} }
} }
@@ -698,28 +693,35 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
private void SetCodecExternalSources() private void SetCodecExternalSources()
{ {
var videoCodecWithExternalSwitching = VideoCodec as IHasExternalSourceSwitching;
string codecTieLine = "";
codecTieLine = ConfigReader.ConfigObject.TieLines.SingleOrDefault(x => x.DestinationKey == VideoCodec.Key).DestinationPort; if (videoCodecWithExternalSwitching == null)
(VideoCodec as IHasExternalSourceSwitching).ClearExternalSources(); {
(VideoCodec as IHasExternalSourceSwitching).RunRouteAction = RunRouteAction; return;
var srcList = ConfigReader.ConfigObject.SourceLists.SingleOrDefault(x => x.Key == SourceListKey).Value.OrderBy(kv => kv.Value.Order);; }
else
{
string codecTieLine = "";
codecTieLine = ConfigReader.ConfigObject.TieLines.SingleOrDefault(x => x.DestinationKey == VideoCodec.Key).DestinationPort;
videoCodecWithExternalSwitching.ClearExternalSources();
videoCodecWithExternalSwitching.RunRouteAction = RunRouteAction;
var srcList = ConfigReader.ConfigObject.SourceLists.SingleOrDefault(x => x.Key == SourceListKey).Value.OrderBy(kv => kv.Value.Order); ;
foreach (var kvp in srcList) foreach (var kvp in srcList)
{ {
var srcConfig = kvp.Value; var srcConfig = kvp.Value;
if (kvp.Key != "codecOsd" && kvp.Key != "roomOff") if (kvp.Key != DefaultCodecRouteString && kvp.Key != "roomOff")
{ {
(VideoCodec as IHasExternalSourceSwitching).AddExternalSource(codecTieLine, kvp.Key, srcConfig.PreferredName, PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.eExternalSourceType.desktop); videoCodecWithExternalSwitching.AddExternalSource(codecTieLine, kvp.Key, srcConfig.PreferredName, PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.eExternalSourceType.desktop);
(VideoCodec as IHasExternalSourceSwitching).SetExternalSourceState(kvp.Key, PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.eExternalSourceMode.Ready); videoCodecWithExternalSwitching.SetExternalSourceState(kvp.Key, PepperDash.Essentials.Devices.Common.VideoCodec.Cisco.eExternalSourceMode.Ready);
} }
} }
} }
}
#region IPrivacy Members #region IPrivacy Members

View File

@@ -21,7 +21,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
{ {
enum eCommandType { SessionStart, SessionEnd, Command, GetStatus, GetConfiguration }; enum eCommandType { SessionStart, SessionEnd, Command, GetStatus, GetConfiguration };
public enum eExternalSourceType {camera, desktop, document_camera, mediaplayer, PC, whiteboard, other} public enum eExternalSourceType {camera, desktop, document_camera, mediaplayer, PC, whiteboard, other}
public enum eExternalSourceMode {Ready, NotReady, Hiddon, Error} public enum eExternalSourceMode {Ready, NotReady, Hidden, Error}
public class CiscoSparkCodec : VideoCodecBase, IHasCallHistory, IHasCallFavorites, IHasDirectory, public class CiscoSparkCodec : VideoCodecBase, IHasCallHistory, IHasCallFavorites, IHasDirectory,
IHasScheduleAwareness, IOccupancyStatusProvider, IHasCodecLayouts, IHasCodecSelfView, IHasScheduleAwareness, IOccupancyStatusProvider, IHasCodecLayouts, IHasCodecSelfView,
@@ -868,7 +868,11 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
CiscoCodecEvents.RootObject eventReceived = new CiscoCodecEvents.RootObject(); CiscoCodecEvents.RootObject eventReceived = new CiscoCodecEvents.RootObject();
JsonConvert.PopulateObject(response, eventReceived); JsonConvert.PopulateObject(response, eventReceived);
Debug.Console(2, this, "*** Got an External Source Selection {0} {1}", eventReceived, eventReceived.Event.UserInterface, eventReceived.Event.UserInterface.Presentation.ExternalSource.Selected.SourceIdentifier.Value); Debug.Console(2, this, "*** Got an External Source Selection {0} {1}", eventReceived, eventReceived.Event.UserInterface, eventReceived.Event.UserInterface.Presentation.ExternalSource.Selected.SourceIdentifier.Value);
RunRouteAction(eventReceived.Event.UserInterface.Presentation.ExternalSource.Selected.SourceIdentifier.Value, null);
if (RunRouteAction != null)
{
RunRouteAction(eventReceived.Event.UserInterface.Presentation.ExternalSource.Selected.SourceIdentifier.Value, null);
}
} }
} }
else if (response.IndexOf("\"CommandResponse\":{") > -1 || response.IndexOf("\"CommandResponse\": {") > -1) else if (response.IndexOf("\"CommandResponse\":{") > -1 || response.IndexOf("\"CommandResponse\": {") > -1)