/// <summary>
        /// Builds the raw depth frame.
        /// </summary>
        /// <param name="depthFormat">Depth image format.</param>
        /// <param name="rawFrames">The raw frames.</param>
        /// <returns>
        /// Standard ccr iterator
        /// </returns>
        private IEnumerator <ITask> BuildRawDepthFrame(DepthImageFormat depthFormat, RawKinectFrames rawFrames)
        {
            var depthCamResponse = this.depthCamPartner.Get();

            yield return(depthCamResponse.Choice());

            var depthCamSensorState = (DepthCamSensorState)depthCamResponse;

            if (depthCamSensorState == null)
            {
                yield break;
            }

            var frameInfo = new KinectFrameInfo
            {
                Timestamp     = depthCamSensorState.TimeStamp.Ticks,
                Width         = depthCamSensorState.DepthImageSize.Width,
                Height        = depthCamSensorState.DepthImageSize.Height,
                BytesPerPixel = 2
            };

            var target = new short[depthCamSensorState.DepthImage.Length];

            // Raw depth data includes 3 bits for player information
            for (int i = 0; i < target.Length; i++)
            {
                target[i] = (short)(depthCamSensorState.DepthImage[i] << 3);
            }

            rawFrames.RawDepthFrameData = target;

            rawFrames.RawDepthFrameInfo = frameInfo;
        }
        /// <summary>
        /// Builds the video based data.
        /// </summary>
        /// <param name="imageFormat">Image format.</param>
        /// <param name="rawFrames">The raw frames.</param>
        /// <returns>
        /// Standard ccr iterator
        /// </returns>
        private IEnumerator <ITask> BuildRawVideoFrame(ColorImageFormat imageFormat, RawKinectFrames rawFrames)
        {
            var webCamResponse = this.webCamPartner.Get();

            yield return(webCamResponse.Choice());

            var webCamSensorState = (WebCamSensorState)webCamResponse;

            if (webCamSensorState == null)
            {
                yield break;
            }

            var frameInfo = new KinectFrameInfo
            {
                Timestamp     = webCamSensorState.TimeStamp.Ticks,
                Width         = webCamSensorState.Width,
                Height        = webCamSensorState.Height,
                BytesPerPixel = 4
            };

            var source = webCamSensorState.Data;

            // Move from 24rgb to 32rgb
            var target = new byte[(source.Length * 4) / 3];

            for (int i = 0, j = 0; i < source.Length && j < target.Length; i += 3, j += 4)
            {
                target[j]     = source[i];
                target[j + 1] = source[i + 1];
                target[j + 2] = source[i + 2];
            }

            rawFrames.RawColorFrameData = target;

            rawFrames.RawColorFrameInfo = frameInfo;
        }