public static FrameRecorder getInstance() { if (_instance == null) { _instance = new FrameRecorder(); } return(_instance); }
public ServerTask(HttpListenerContext clientContext, SkeletonEventDispatcher source, Boolean logging) { this.clientContext = clientContext; this.source = source; this.logging = logging; this.running = true; clientWriter = new System.IO.StreamWriter(clientContext.Response.OutputStream); if (clientContext.Request.QueryString["frames"] != null) { framesToGet = int.Parse(clientContext.Request.QueryString["frames"]); } else { framesToGet = 1; } framesGot = 0; if (clientContext.Request.QueryString["callback"] != null) { callbackfn = clientContext.Request.QueryString["callback"]; } else { callbackfn = null; } if (callbackfn != null) { clientWriter.Write(callbackfn + "("); } if (clientContext.Request.QueryString["recordState"] != null) { if (clientContext.Request.QueryString["recordState"].Equals("START")) { FrameRecorder frameRecorder = FrameRecorder.getInstance(); frameRecorder.Clear(); source.addSkeletonReceiver(frameRecorder); SendString("{'status':'success'}"); Disconnect(); } else if (clientContext.Request.QueryString["recordState"].Equals("STOP")) { FrameRecorder frameRecorder = FrameRecorder.getInstance(); LinkedList <KinectSkeletonFrame> frames = frameRecorder.GetFrames(); lock (frames) { IEnumerator <KinectSkeletonFrame> frameIter = frames.GetEnumerator(); SendString("["); //frameIter.Reset(); //frameIter.MoveNext(); for (int i = 0; i < frames.Count - 1; ++i) { Send(frameIter.Current); SendString(","); frameIter.MoveNext(); } Send(frameIter.Current); } SendString("]"); Disconnect(); } return; } if (framesToGet > 1) { clientWriter.Write("["); } source.addSkeletonReceiver(this); }
public static FrameRecorder getInstance() { if (_instance == null) _instance = new FrameRecorder(); return _instance; }