Exemple #1
0
        /// <summary>
        /// Processes camera frame buffer using the set effect and provides
        /// media element with a filtered frame buffer.
        /// </summary>
        protected override void GetSampleAsync(MediaStreamType mediaStreamType)
        {
            var task = _cameraEffect.GetNewFrameAndApplyEffect(_frameBuffer.AsBuffer(), _frameSize);

            // When asynchronous call completes, proceed by reporting about the sample completion

            task.ContinueWith(action =>
            {
                if (_frameStream != null)
                {
                    _frameStream.Position = 0;
                    _currentTime         += _frameTime;
                    _frameCount++;

                    var sample = new MediaStreamSample(
                        _videoStreamDescription, _frameStream, _frameStreamOffset,
                        _frameBufferSize, _currentTime, _emptyAttributes);

                    ReportGetSampleCompleted(sample);
                }
            });
        }