public static bool IsAvailable(this VideoSource src, DeviceProfile profile, params InternalPortType[] ignorePortTypes) { if (!src.IsValid()) { return(false); } VideoSourceTypeAttribute props = src.GetAttribute <VideoSource, VideoSourceTypeAttribute>(); if (ignorePortTypes.Contains(props.PortType)) { return(false); } switch (props.PortType) { case InternalPortType.Auxiliary: return(props.Me1Index <= profile.Auxiliaries); case InternalPortType.Black: case InternalPortType.ColorBars: return(true); case InternalPortType.ColorGenerator: return(props.Me1Index <= profile.ColorGenerators); case InternalPortType.External: return(props.Me1Index <= profile.Sources.Count); case InternalPortType.MEOutput: return(props.Me1Index <= profile.MixEffectBlocks); case InternalPortType.Mask: if (profile.MixEffectBlocks > 1) { return(props.Me2Index <= profile.UpstreamKeys); } return(props.Me1Index <= profile.UpstreamKeys); case InternalPortType.MediaPlayerFill: case InternalPortType.MediaPlayerKey: return(props.Me1Index <= profile.MediaPlayers); case InternalPortType.SuperSource: return(props.Me1Index <= profile.SuperSource); default: Debug.Fail(String.Format("Invalid source type:{0}", props.PortType)); return(false); } }
public static bool IsAvailable(this VideoSource src, DeviceProfile profile, params InternalPortType[] ignorePortTypes) { if (!src.IsValid()) { return(false); } VideoSourceTypeAttribute props = src.GetAttribute <VideoSource, VideoSourceTypeAttribute>(); if (ignorePortTypes.Contains(props.PortType)) { return(false); } switch (props.PortType) { case InternalPortType.Auxiliary: return(props.Me1Index <= profile.Auxiliaries); case InternalPortType.Black: case InternalPortType.ColorBars: return(true); case InternalPortType.ColorGenerator: return(props.Me1Index <= 2); // profile.ColorGenerators; TODO - should this be dynamic? case InternalPortType.External: return(props.Me1Index <= profile.Sources.Count); case InternalPortType.MEOutput: if (!(props.Me1Index <= profile.MixEffectBlocks)) { return(false); } // TODO - should cleanfeed be its own type? if (props.Me1Index == 0 && src >= VideoSource.CleanFeed1 && src < VideoSource.Auxilary1) { long cleanFeedId = src - VideoSource.CleanFeed1; return(cleanFeedId < profile.DownstreamKeys); } return(true); case InternalPortType.Mask: if (profile.MixEffectBlocks > 1) { return(props.Me2Index <= profile.UpstreamKeys); } return(props.Me1Index <= profile.UpstreamKeys); case InternalPortType.MediaPlayerFill: case InternalPortType.MediaPlayerKey: return(props.Me1Index <= profile.MediaPlayers); case InternalPortType.SuperSource: long id = src - VideoSource.SuperSource; return(props.Me1Index <= profile.SuperSource && id < profile.SuperSource); default: Debug.Fail(String.Format("Invalid source type:{0}", props.PortType)); return(false); } }