/// <summary> /// Initializes a new instance of the <see cref="InteractionStreamHandler"/> class /// and associates it with a context that allows it to communicate with its owner. /// </summary> /// <param name="ownerContext"> /// An instance of <see cref="SensorStreamHandlerContext"/> class. /// </param> internal InteractionStreamHandler(SensorStreamHandlerContext ownerContext) { this.userViewerDefaultUserColor = GetRgbaColorInt(UserViewerDefaultDefaultUserColor); this.userViewerUserColors[DefaultUserStateManager.TrackedStateName] = GetRgbaColorInt(UserViewerDefaultTrackedUserColor); this.userViewerUserColors[DefaultUserStateManager.EngagedStateName] = GetRgbaColorInt(UserViewerDefaultEngagedUserColor); this.ownerContext = ownerContext; this.userStateManager.UserStateChanged += this.OnUserStateChanged; this.AddStreamConfiguration(InteractionStreamName, new StreamConfiguration(this.GetInteractionStreamProperties, this.SetInteractionStreamProperty)); this.AddStreamConfiguration(UserViewerStreamName, new StreamConfiguration(this.GetUserViewerStreamProperties, this.SetUserViewerStreamProperty)); }
/// <summary> /// Initializes a new instance of the KinectRequestHandler class. /// </summary> /// <param name="sensorChooser"> /// Sensor chooser that will be used to obtain a KinectSensor. /// </param> /// <param name="streamHandlerFactories"> /// Collection of stream handler factories to be used to process kinect data and deliver /// data streams ready for web consumption. /// </param> internal KinectRequestHandler(KinectSensorChooser sensorChooser, Collection <ISensorStreamHandlerFactory> streamHandlerFactories) { this.sensorChooser = sensorChooser; this.streamHandlers = new ISensorStreamHandler[streamHandlerFactories.Count]; var streamHandlerContext = new SensorStreamHandlerContext(this.SendStreamMessageAsync, this.SendEventMessageAsync); var normalizedNameSet = new HashSet <string>(); // Associate each of the supported stream names with the corresponding handlers for (int i = 0; i < streamHandlerFactories.Count; ++i) { var handler = streamHandlerFactories[i].CreateHandler(streamHandlerContext); this.streamHandlers[i] = handler; var names = handler.GetSupportedStreamNames(); foreach (var name in names) { if (!name.Equals("skeleton")) { continue; } if (string.IsNullOrEmpty(name)) { throw new InvalidOperationException(@"Empty stream names are not supported"); } if (name.IndexOfAny(SharedConstants.UriPathComponentDelimiters) >= 0) { throw new InvalidOperationException(@"Stream names can't contain '/' character"); } var normalizedName = name.ToUpperInvariant(); if (ReservedNames.Contains(normalizedName)) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "'{0}' is a reserved stream name", normalizedName)); } if (normalizedNameSet.Contains(normalizedName)) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "'{0}' is a duplicate stream name", normalizedName)); } normalizedNameSet.Add(normalizedName); this.uriName2StreamNameMap.Add(normalizedName, name); this.streamHandlerMap.Add(name, handler); } } }
/// <summary> /// Creates a sensor stream handler object and associates it with a context that /// allows it to communicate with its owner. /// </summary> /// <param name="context"> /// An instance of <see cref="SensorStreamHandlerContext"/> class. /// </param> /// <returns> /// A new <see cref="ISensorStreamHandler"/> instance. /// </returns> public ISensorStreamHandler CreateHandler(SensorStreamHandlerContext context) { switch (streamType) { case StreamHandlerType.Skeleton: return new SkeletonStreamHandler(context); case StreamHandlerType.Interaction: return new InteractionStreamHandler(context); case StreamHandlerType.BackgroundRemoval: return new BackgroundRemovalStreamHandler(context); case StreamHandlerType.SensorStatus: return new SensorStatusStreamHandler(context); default: throw new NotSupportedException(Resources.UnsupportedStreamType); } }
/// <summary> /// Creates a sensor stream handler object and associates it with a context that /// allows it to communicate with its owner. /// </summary> /// <param name="context"> /// An instance of <see cref="SensorStreamHandlerContext"/> class. /// </param> /// <returns> /// A new <see cref="ISensorStreamHandler"/> instance. /// </returns> public ISensorStreamHandler CreateHandler(SensorStreamHandlerContext context) { switch (streamType) { case StreamHandlerType.Skeleton: return(new SkeletonStreamHandler(context)); case StreamHandlerType.Interaction: return(new InteractionStreamHandler(context)); case StreamHandlerType.BackgroundRemoval: return(new BackgroundRemovalStreamHandler(context)); case StreamHandlerType.SensorStatus: return(new SensorStatusStreamHandler(context)); default: throw new NotSupportedException(Resources.UnsupportedStreamType); } }
/// <summary> /// Initializes a new instance of the <see cref="SensorStatusStreamHandler"/> class /// and associates it with a context that allows it to communicate with its owner. /// </summary> /// <param name="ownerContext"> /// An instance of <see cref="SensorStreamHandlerContext"/> class. /// </param> internal SensorStatusStreamHandler(SensorStreamHandlerContext ownerContext) { this.ownerContext = ownerContext; this.AddStreamConfiguration(SensorStreamName, new StreamConfiguration(this.GetSensorStreamProperties, this.SetSensorStreamProperty)); }
/// <summary> /// Initializes a new instance of the <see cref="BackgroundRemovalStreamHandler"/> class /// and associates it with a context that allows it to communicate with its owner. /// </summary> /// <param name="ownerContext"> /// An instance of <see cref="SensorStreamHandlerContext"/> class. /// </param> internal BackgroundRemovalStreamHandler(SensorStreamHandlerContext ownerContext) { this.ownerContext = ownerContext; this.AddStreamConfiguration(BackgroundRemovalStreamName, new StreamConfiguration(this.GetProperties, this.SetProperty)); }
/// <summary> /// Initializes a new instance of the <see cref="InteractionStreamHandler"/> class /// and associates it with a context that allows it to communicate with its owner. /// </summary> /// <param name="ownerContext"> /// An instance of <see cref="SensorStreamHandlerContext"/> class. /// </param> internal InteractionStreamHandler(SensorStreamHandlerContext ownerContext) { this.userViewerDefaultUserColor = GetRgbaColorInt(UserViewerDefaultDefaultUserColor); this.userViewerUserColors[DefaultUserStateManager.TrackedStateName] = GetRgbaColorInt(UserViewerDefaultTrackedUserColor); this.userViewerUserColors[DefaultUserStateManager.EngagedStateName] = GetRgbaColorInt(UserViewerDefaultEngagedUserColor); this.ownerContext = ownerContext; this.userStateManager.UserStateChanged += this.OnUserStateChanged; this.AddStreamConfiguration(InteractionStreamName, new StreamConfiguration(this.GetInteractionStreamProperties, this.SetInteractionStreamProperty)); this.AddStreamConfiguration(UserViewerStreamName, new StreamConfiguration(this.GetUserViewerStreamProperties, this.SetUserViewerStreamProperty)); }
/// <summary> /// Initializes a new instance of the <see cref="SensorStatusStreamHandler"/> class /// and associates it with a context that allows it to communicate with its owner. /// </summary> /// <param name="ownerContext"> /// An instance of <see cref="SensorStreamHandlerContext"/> class. /// </param> internal SensorStatusStreamHandler(SensorStreamHandlerContext ownerContext) { this.ownerContext = ownerContext; this.AddStreamConfiguration(SensorStreamName, new StreamConfiguration(this.GetSensorStreamProperties, this.SetSensorStreamProperty)); }
/// <summary> /// Initializes a new instance of the KinectRequestHandler class. /// </summary> /// <param name="sensorChooser"> /// Sensor chooser that will be used to obtain a KinectSensor. /// </param> /// <param name="streamHandlerFactories"> /// Collection of stream handler factories to be used to process kinect data and deliver /// data streams ready for web consumption. /// </param> internal KinectRequestHandler(KinectSensorChooser sensorChooser, Collection<ISensorStreamHandlerFactory> streamHandlerFactories) { this.sensorChooser = sensorChooser; this.streamHandlers = new ISensorStreamHandler[streamHandlerFactories.Count]; var streamHandlerContext = new SensorStreamHandlerContext(this.SendStreamMessageAsync, this.SendEventMessageAsync); var normalizedNameSet = new HashSet<string>(); // Associate each of the supported stream names with the corresponding handlers for (int i = 0; i < streamHandlerFactories.Count; ++i) { var handler = streamHandlerFactories[i].CreateHandler(streamHandlerContext); this.streamHandlers[i] = handler; var names = handler.GetSupportedStreamNames(); foreach (var name in names) { if (string.IsNullOrEmpty(name)) { throw new InvalidOperationException(@"Empty stream names are not supported"); } if (name.IndexOfAny(SharedConstants.UriPathComponentDelimiters) >= 0) { throw new InvalidOperationException(@"Stream names can't contain '/' character"); } var normalizedName = name.ToUpperInvariant(); if (ReservedNames.Contains(normalizedName)) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "'{0}' is a reserved stream name", normalizedName)); } if (normalizedNameSet.Contains(normalizedName)) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "'{0}' is a duplicate stream name", normalizedName)); } normalizedNameSet.Add(normalizedName); this.uriName2StreamNameMap.Add(normalizedName, name); this.streamHandlerMap.Add(name, handler); } } }
/// <summary> /// Initializes a new instance of the <see cref="BackgroundRemovalStreamHandler"/> class /// and associates it with a context that allows it to communicate with its owner. /// </summary> /// <param name="ownerContext"> /// An instance of <see cref="SensorStreamHandlerContext"/> class. /// </param> internal BackgroundRemovalStreamHandler(SensorStreamHandlerContext ownerContext) { this.ownerContext = ownerContext; this.AddStreamConfiguration(BackgroundRemovalStreamName, new StreamConfiguration(this.GetProperties, this.SetProperty)); }