// ----------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // ----------------------------------------------------------------------- namespace Microsoft.Samples.Kinect.Webserver.Sensor { using System.Collections.ObjectModel; using Microsoft.Kinect.Toolkit; using Microsoft.Samples.Kinect.Webserver; /// /// Implementation of IHttpRequestHandlerFactory used to create instances of /// objects. /// public class KinectRequestHandlerFactory : IHttpRequestHandlerFactory { /// /// Sensor chooser used to obtain a KinectSensor. /// private readonly KinectSensorChooser sensorChooser; /// /// Collection of sensor stream handler factories used to process kinect data and deliver /// a data streams ready for web consumption. /// private readonly Collection streamHandlerFactories; /// /// Initializes a new instance of the KinectRequestHandlerFactory class. /// /// /// Sensor chooser that will be used to obtain a KinectSensor. /// /// /// Default set of sensor stream handler factories will be used. /// public KinectRequestHandlerFactory(KinectSensorChooser sensorChooser) { this.sensorChooser = sensorChooser; this.streamHandlerFactories = CreateDefaultStreamHandlerFactories(); } /// /// Initializes a new instance of the KinectRequestHandlerFactory class. /// /// /// Sensor chooser that will be used to obtain a KinectSensor. /// /// /// Collection of stream handler factories to be used to process kinect data and deliver /// data streams ready for web consumption. /// public KinectRequestHandlerFactory(KinectSensorChooser sensorChooser, Collection streamHandlerFactories) { this.sensorChooser = sensorChooser; this.streamHandlerFactories = streamHandlerFactories; } /// /// Create collection of default stream handler factories. /// /// /// Collection containing default stream handler factories. /// public static Collection CreateDefaultStreamHandlerFactories() { var streamHandlerTypes = new[] { StreamHandlerType.Interaction, StreamHandlerType.Skeleton, StreamHandlerType.BackgroundRemoval, StreamHandlerType.SensorStatus }; var factoryCollection = new Collection(); foreach (var type in streamHandlerTypes) { factoryCollection.Add(new SensorStreamHandlerFactory(type)); } return factoryCollection; } /// /// Creates a request handler object. /// /// /// A new instance. /// public IHttpRequestHandler CreateHandler() { return new KinectRequestHandler(this.sensorChooser, this.streamHandlerFactories); } } }