Path: blob/master/modules/videoio/src/cap_winrt/CaptureFrameGrabber.hpp
16348 views
// Copyright (c) Microsoft. All rights reserved.1//2// The MIT License (MIT)3//4// Permission is hereby granted, free of charge, to any person obtaining a copy5// of this software and associated documentation files(the "Software"), to deal6// in the Software without restriction, including without limitation the rights7// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell8// copies of the Software, and to permit persons to whom the Software is9// furnished to do so, subject to the following conditions :10//11// The above copyright notice and this permission notice shall be included in12// all copies or substantial portions of the Software.13//14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE17// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN20// THE SOFTWARE.2122#pragma once2324#include "MFIncludes.hpp"252627namespace Media {2829class MediaSink;3031enum class CaptureStreamType32{33Preview = 0,34Record35};3637ref class CaptureFrameGrabber sealed38{39public:4041// IClosable42virtual ~CaptureFrameGrabber();4344virtual void ShowCameraSettings();4546internal:4748static concurrency::task<CaptureFrameGrabber^> CreateAsync(_In_ WMC::MediaCapture^ capture, _In_ WMMp::VideoEncodingProperties^ props)49{50return CreateAsync(capture, props, CaptureStreamType::Preview);51}5253static concurrency::task<CaptureFrameGrabber^> CreateAsync(_In_ WMC::MediaCapture^ capture, _In_ WMMp::VideoEncodingProperties^ props, CaptureStreamType streamType);5455concurrency::task<MW::ComPtr<IMF2DBuffer2>> GetFrameAsync();56concurrency::task<void> FinishAsync();5758private:5960CaptureFrameGrabber(_In_ WMC::MediaCapture^ capture, _In_ WMMp::VideoEncodingProperties^ props, CaptureStreamType streamType);6162void ProcessSample(_In_ MediaSample^ sample);6364Platform::Agile<WMC::MediaCapture> _capture;65::Windows::Media::IMediaExtension^ _mediaExtension;6667MW::ComPtr<MediaSink> _mediaSink;6869CaptureStreamType _streamType;7071enum class State72{73Created,74Started,75Closing,76Closed77} _state;7879std::queue<concurrency::task_completion_event<MW::ComPtr<IMF2DBuffer2>>> _videoSampleRequestQueue;80AutoMF _mf;81MWW::SRWLock _lock;82};8384}8586