source: other-projects/playing-in-the-street/summer-2013/trunk/Playing-in-the-Street-WPF/Microsoft.Samples.Kinect.Webserver/Sensor/ISensorStreamHandler.cs@ 28897

Last change on this file since 28897 was 28897, checked in by davidb, 10 years ago

GUI front-end to server base plus web page content

File size: 6.7 KB
Line 
1// -----------------------------------------------------------------------
2// <copyright file="ISensorStreamHandler.cs" company="Microsoft">
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// </copyright>
5// -----------------------------------------------------------------------
6
7namespace Microsoft.Samples.Kinect.Webserver.Sensor
8{
9 using System.Collections.Generic;
10 using System.Net;
11 using System.Threading.Tasks;
12
13 using Microsoft.Kinect;
14
15 /// <summary>
16 /// Interface called upon to:
17 /// a) Process Kinect sensor data associated with a specific stream or set of streams.
18 /// b) Handle requests to deliver data associated with the same stream(s).
19 /// </summary>
20 /// <remarks>
21 /// <para>
22 /// Objects that implement this interface are not expected to be thread-safe but are expected
23 /// to support async operations, so instances should be created and instance methods should
24 /// always be called from a single thread that is associated with a SynchronizationContext
25 /// that provides single-threaded message dispatch
26 /// (e.g.: System.Windows.Threading.DispatcherSynchronizationContext).
27 /// </para>
28 /// <para>
29 /// This means that IHttpRequestHandlers still have to be aware of potential reentrancy
30 /// resulting from asynchronous operations, but they don't have to protect data access with
31 /// locks.
32 /// </para>
33 /// </remarks>
34 public interface ISensorStreamHandler
35 {
36 /// <summary>
37 /// Get the names of the stream(s) supported by this stream handler.
38 /// </summary>
39 /// <returns>
40 /// An array of stream names.
41 /// </returns>
42 /// <remarks>
43 /// These names will be used in JSON objects to refer to individual streams.
44 /// </remarks>
45 string[] GetSupportedStreamNames();
46
47 /// <summary>
48 /// Lets ISensorStreamHandler know that Kinect Sensor associated with this stream
49 /// handler has changed.
50 /// </summary>
51 /// <param name="newSensor">
52 /// New KinectSensor.
53 /// </param>
54 void OnSensorChanged(KinectSensor newSensor);
55
56 /// <summary>
57 /// Process data from one Kinect color frame.
58 /// </summary>
59 /// <param name="colorData">
60 /// Kinect color data.
61 /// </param>
62 /// <param name="colorFrame">
63 /// <see cref="ColorImageFrame"/> from which we obtained color data.
64 /// </param>
65 void ProcessColor(byte[] colorData, ColorImageFrame colorFrame);
66
67 /// <summary>
68 /// Process data from one Kinect depth frame.
69 /// </summary>
70 /// <param name="depthData">
71 /// Kinect depth data.
72 /// </param>
73 /// <param name="depthFrame">
74 /// <see cref="DepthImageFrame"/> from which we obtained depth data.
75 /// </param>
76 void ProcessDepth(DepthImagePixel[] depthData, DepthImageFrame depthFrame);
77
78 /// <summary>
79 /// Process data from one Kinect skeleton frame.
80 /// </summary>
81 /// <param name="skeletons">
82 /// Kinect skeleton data.
83 /// </param>
84 /// <param name="skeletonFrame">
85 /// <see cref="SkeletonFrame"/> from which we obtained skeleton data.
86 /// </param>
87 void ProcessSkeleton(Skeleton[] skeletons, SkeletonFrame skeletonFrame);
88
89 /// <summary>
90 /// Gets the state property values associated with the specified stream name.
91 /// </summary>
92 /// <param name="streamName">
93 /// Name of stream for which property values should be returned.
94 /// </param>
95 /// <returns>
96 /// Dictionary mapping property names to property values.
97 /// </returns>
98 IDictionary<string, object> GetState(string streamName);
99
100 /// <summary>
101 /// Attempts to set the specified state property values associated with the specified
102 /// stream name.
103 /// </summary>
104 /// <param name="streamName">
105 /// Name of stream for which property values should be set.
106 /// </param>
107 /// <param name="properties">
108 /// Dictionary mapping property names to property values that should be set.
109 /// Must not be null.
110 /// </param>
111 /// <param name="errors">
112 /// Dictionary meant to receive mappings between property names to errors encountered
113 /// while trying to set each property value.
114 /// May be null.
115 /// </param>
116 /// <returns>
117 /// true if there were no errors encountered while setting state. false otherwise.
118 /// </returns>
119 /// <remarks>
120 /// If <paramref name="errors"/> is non-null, it is expected that it will be empty
121 /// when method is called.
122 /// </remarks>
123 bool SetState(string streamName, IReadOnlyDictionary<string, object> properties, IDictionary<string, object> errors);
124
125 /// <summary>
126 /// Handle an http request.
127 /// </summary>
128 /// <param name="streamName">
129 /// Name of stream for which property values should be set.
130 /// </param>
131 /// <param name="requestContext">
132 /// Context containing HTTP request data, which will also contain associated
133 /// response upon return.
134 /// </param>
135 /// <param name="subpath">
136 /// Request URI path relative to the stream name associated with this sensor stream
137 /// handler in the stream handler owner.
138 /// </param>
139 /// <returns>
140 /// Await-able task.
141 /// </returns>
142 /// <remarks>
143 /// Return value should never be null. Implementations should use Task.FromResult(0)
144 /// if function is implemented synchronously so that callers can await without
145 /// needing to check for null.
146 /// </remarks>
147 Task HandleRequestAsync(string streamName, HttpListenerContext requestContext, string subpath);
148
149 /// <summary>
150 /// Cancel all pending operations
151 /// </summary>
152 void Cancel();
153
154 /// <summary>
155 /// Lets handler know that it should clean up resources associated with sensor stream
156 /// handling.
157 /// </summary>
158 /// <returns>
159 /// Await-able task.
160 /// </returns>
161 /// <remarks>
162 /// Return value should never be null. Implementations should use Task.FromResult(0)
163 /// if function is implemented synchronously so that callers can await without
164 /// needing to check for null.
165 /// </remarks>
166 Task UninitializeAsync();
167 }
168}
Note: See TracBrowser for help on using the repository browser.