diff --git a/modules/videoio/src/cap_msmf.cpp b/modules/videoio/src/cap_msmf.cpp index d4582d6f5e..eaca0e2cd9 100644 --- a/modules/videoio/src/cap_msmf.cpp +++ b/modules/videoio/src/cap_msmf.cpp @@ -86,36 +86,11 @@ #include -#ifdef WINRT - // for ComPtr usage -#include -#ifdef __cplusplus_winrt -#include -#include -#endif - -#include -#include -#include -#include -#include -#include -#ifdef HAVE_CONCURRENCY -#include -#ifndef __cplusplus_winrt -#include "wrl.h" -#endif -#include "ppltasks_winrt.hpp" -#endif -#else #include -#endif struct IMFMediaType; -#ifndef WINRT struct IMFActivate; struct IMFMediaSource; -#endif struct IMFAttributes; namespace @@ -252,43 +227,6 @@ private: ImageGrabberCallback& operator=(const ImageGrabberCallback&); // Declared to fix compilation warning. }; -#ifdef WINRT -extern const __declspec(selectany) WCHAR RuntimeClass_CV_ImageGrabberWinRT[] = L"cv.ImageGrabberWinRT"; - -class ImageGrabberWinRT : - public Microsoft::WRL::RuntimeClass< - Microsoft::WRL::RuntimeClassFlags< Microsoft::WRL::RuntimeClassType::WinRtClassicComMix>, - IMFSampleGrabberSinkCallback>, public ImageGrabberCallback -{ - InspectableClass(RuntimeClass_CV_ImageGrabberWinRT, BaseTrust) -public: - ImageGrabberWinRT(bool synchronous); - ~ImageGrabberWinRT(void); - - HRESULT initImageGrabber(MAKE_WRL_REF(_MediaCapture) pSource, - GUID VideoFormat); - HRESULT startGrabbing(MAKE_WRL_REF(_AsyncAction)* action); - HRESULT stopGrabbing(MAKE_WRL_REF(_AsyncAction)* action); - // IMFClockStateSink methods - STDMETHODIMP OnClockStart(MFTIME hnsSystemTime, LONGLONG llClockStartOffset) { return ImageGrabberCallback::OnClockStart(hnsSystemTime, llClockStartOffset); } - STDMETHODIMP OnClockStop(MFTIME hnsSystemTime) { return ImageGrabberCallback::OnClockStop(hnsSystemTime); } - STDMETHODIMP OnClockPause(MFTIME hnsSystemTime) { return ImageGrabberCallback::OnClockPause(hnsSystemTime); } - STDMETHODIMP OnClockRestart(MFTIME hnsSystemTime) { return ImageGrabberCallback::OnClockRestart(hnsSystemTime); } - STDMETHODIMP OnClockSetRate(MFTIME hnsSystemTime, float flRate) { return ImageGrabberCallback::OnClockSetRate(hnsSystemTime, flRate); } - // IMFSampleGrabberSinkCallback methods - STDMETHODIMP OnSetPresentationClock(IMFPresentationClock* pClock) { return ImageGrabberCallback::OnSetPresentationClock(pClock); } - STDMETHODIMP OnProcessSample(REFGUID guidMajorMediaType, DWORD dwSampleFlags, - LONGLONG llSampleTime, LONGLONG llSampleDuration, const BYTE * pSampleBuffer, - DWORD dwSampleSize) { return ImageGrabberCallback::OnProcessSample(guidMajorMediaType, dwSampleFlags, llSampleTime, llSampleDuration, pSampleBuffer, dwSampleSize); } - STDMETHODIMP OnShutdown() { return ImageGrabberCallback::OnShutdown(); } - // Function of creation of the instance of the class - static HRESULT CreateInstance(ImageGrabberWinRT **ppIG, bool synchronous = false); -private: - MAKE_WRL_AGILE_REF(_MediaCapture) ig_pMedCapSource; - MediaSink* ig_pMediaSink; -}; -#endif - // Class for grabbing image from video stream class ImageGrabber : public ImageGrabberCallback { @@ -395,20 +333,7 @@ public: CamParametrs getParametrs(); void setParametrs(CamParametrs parametrs); void setEmergencyStopEvent(void *userData, void(*func)(int, void *)); -#ifdef WINRT - long readInfoOfDevice(MAKE_WRL_REF(_IDeviceInformation) pDevice, unsigned int Num); - void waitForDevice() - { - if (vd_pAction) { -#ifdef HAVE_CONCURRENCY - CREATE_TASK DEFINE_RET_TYPE(void)(vd_pAction).wait(); -#endif - vd_pAction = nullptr; - } - } -#else long readInfoOfDevice(IMFActivate *pActivate, unsigned int Num); -#endif wchar_t *getName(); int getCountFormats(); unsigned int getWidth(); @@ -441,32 +366,14 @@ private: std::map vd_CaptureFormats; std::vector vd_CurrentFormats; IMFMediaSource *vd_pSource; -#ifdef WINRT - MAKE_WRL_AGILE_REF(_MediaCapture) vd_pMedCap; - EventRegistrationToken vd_cookie; - ImageGrabberWinRT *vd_pImGr; - MAKE_WRL_REF(_AsyncAction) vd_pAction; -#ifdef HAVE_CONCURRENCY - Concurrency::critical_section vd_lock; -#endif -#endif emergensyStopEventCallback vd_func; void *vd_userData; HRESULT enumerateCaptureFormats(IMFMediaSource *pSource); long setDeviceFormat(IMFMediaSource *pSource, unsigned long dwFormatIndex); void buildLibraryofTypes(); int findType(unsigned int size, unsigned int frameRate = 0); -#ifdef WINRT - HRESULT enumerateCaptureFormats(MAKE_WRL_REF(_MediaCapture) pSource); - long setDeviceFormat(MAKE_WRL_REF(_MediaCapture) pSource, unsigned long dwFormatIndex, MAKE_WRL_REF(_AsyncAction)* pAction); - long resetDevice(MAKE_WRL_REF(_IDeviceInformation) pDevice); -#ifdef HAVE_CONCURRENCY - long checkDevice(_DeviceClass devClass, DEFINE_TASK* pTask, MAKE_WRL_REF(_IDeviceInformation)* ppDevice); -#endif -#else long resetDevice(IMFActivate *pActivate); long checkDevice(IMFAttributes *pAttributes, IMFActivate **pDevice); -#endif long initDevice(); }; @@ -475,28 +382,13 @@ class videoDevices { public: ~videoDevices(void); -#ifdef WINRT - long initDevices(_DeviceClass devClass); - void waitInit() { - if (vds_enumTask) { -#ifdef HAVE_CONCURRENCY - CREATE_TASK DEFINE_RET_TYPE(void)(vds_enumTask).wait(); -#endif - vds_enumTask = nullptr; - } - } -#else long initDevices(IMFAttributes *pAttributes); -#endif static videoDevices& getInstance(); videoDevice *getDevice(unsigned int i); unsigned int getCount(); void clearDevices(); private: UINT32 count; -#ifdef WINRT - MAKE_WRL_REF(_AsyncAction) vds_enumTask; -#endif std::vector vds_Devices; videoDevices(void); }; @@ -566,9 +458,6 @@ public: bool setupDevice(int deviceID, unsigned int w, unsigned int h, unsigned int idealFramerate = 30); // Checking of recivig of new frame from video device with deviceID bool isFrameNew(int deviceID); -#ifdef WINRT - void waitForDevice(int deviceID); -#endif // Writing of Raw Data pixels from video device with deviceID with correction of RedAndBlue flipping flipRedAndBlue and vertical flipping flipImage bool getPixels(int deviceID, unsigned char * pixels, bool flipRedAndBlue = false, bool flipImage = false); static void processPixels(unsigned char * src, unsigned char * dst, unsigned int width, unsigned int height, unsigned int bpp, bool bRGB, bool bFlip); @@ -1089,156 +978,6 @@ ImageGrabber::~ImageGrabber(void) DebugPrintOut(L"IMAGEGRABBER VIDEODEVICE %i: Destroying instance of the ImageGrabber class\n", ig_DeviceID); } -#ifdef WINRT - -ImageGrabberWinRT::ImageGrabberWinRT(bool synchronous): - ImageGrabberCallback(synchronous), - ig_pMediaSink(NULL) -{ - ig_pMedCapSource = nullptr; -} - -ImageGrabberWinRT::~ImageGrabberWinRT(void) -{ - //stop must already be performed and complete by object owner - if (ig_pMediaSink != NULL) { - ((IMFMediaSink*)ig_pMediaSink)->Shutdown(); - } - SafeRelease(&ig_pMediaSink); - RELEASE_AGILE_WRL(ig_pMedCapSource) - - CloseHandle(ig_hFinish); - - if (ig_Synchronous) - { - CloseHandle(ig_hFrameReady); - CloseHandle(ig_hFrameGrabbed); - } - - DebugPrintOut(L"IMAGEGRABBER VIDEODEVICE: Destroying instance of the ImageGrabberWinRT class\n"); -} - -HRESULT ImageGrabberWinRT::initImageGrabber(MAKE_WRL_REF(_MediaCapture) pSource, - GUID VideoFormat) -{ - HRESULT hr; - MAKE_WRL_OBJ(_VideoDeviceController) pDevCont; - WRL_PROP_GET(pSource, VideoDeviceController, pDevCont, hr) - if (FAILED(hr)) return hr; - GET_WRL_OBJ_FROM_OBJ(_MediaDeviceController, pMedDevCont, pDevCont, hr) - if (FAILED(hr)) return hr; - MAKE_WRL_OBJ(_MediaEncodingProperties) pMedEncProps; - WRL_METHOD(pMedDevCont, GetMediaStreamProperties, pMedEncProps, hr, WRL_ENUM_GET(_MediaStreamType, MediaStreamType, VideoPreview)) - if (FAILED(hr)) return hr; - GET_WRL_OBJ_FROM_OBJ(_VideoEncodingProperties, pVidProps, pMedEncProps, hr); - if (FAILED(hr)) return hr; - _ComPtr pType = NULL; - hr = MediaSink::ConvertPropertiesToMediaType(DEREF_AS_NATIVE_WRL_OBJ(ABI::Windows::Media::MediaProperties::IMediaEncodingProperties, pMedEncProps), &pType); - if (FAILED(hr)) return hr; - MediaType MT = FormatReader::Read(pType.Get()); - unsigned int sizeRawImage = 0; - if(VideoFormat == MFVideoFormat_RGB24) - { - sizeRawImage = MT.MF_MT_FRAME_SIZE * 3; - } - else if(VideoFormat == MFVideoFormat_RGB32) - { - sizeRawImage = MT.MF_MT_FRAME_SIZE * 4; - } - sizeRawImage = MT.MF_MT_SAMPLE_SIZE; - CHECK_HR(hr = RawImage::CreateInstance(&ig_RIFirst, sizeRawImage)); - CHECK_HR(hr = RawImage::CreateInstance(&ig_RISecond, sizeRawImage)); - ig_RIOut = ig_RISecond; - ig_pMedCapSource = pSource; -done: - return hr; -} - -HRESULT ImageGrabberWinRT::stopGrabbing(MAKE_WRL_REF(_AsyncAction)* action) -{ - HRESULT hr = S_OK; - if (ig_pMedCapSource != nullptr) { - GET_WRL_OBJ_FROM_REF(_MediaCaptureVideoPreview, imedPrevCap, DEREF_AGILE_WRL_OBJ(ig_pMedCapSource), hr) - if (FAILED(hr)) return hr; - MAKE_WRL_REF(_AsyncAction) pAction; - WRL_METHOD_BASE(imedPrevCap, StopPreviewAsync, pAction, hr) - if (SUCCEEDED(hr)) { -#ifdef HAVE_CONCURRENCY - DEFINE_TASK _task = CREATE_TASK DEFINE_RET_TYPE(void)(pAction); - *action = reinterpret_cast(BEGIN_CREATE_ASYNC(void, _task, this) - HRESULT hr = S_OK; - _task.wait(); - SafeRelease(&ig_pMediaSink); - SetEvent(ig_hFinish); - END_CREATE_ASYNC(hr)); -#else - *action = nullptr; -#endif - } - } - return hr; -} - -HRESULT ImageGrabberWinRT::startGrabbing(MAKE_WRL_REF(_AsyncAction)* action) -{ - HRESULT hr = S_OK; - GET_WRL_OBJ_FROM_REF(_MediaCaptureVideoPreview, imedPrevCap, DEREF_AGILE_WRL_OBJ(ig_pMedCapSource), hr) - if (FAILED(hr)) return hr; - ACTIVATE_OBJ(RuntimeClass_Windows_Foundation_Collections_PropertySet, _PropertySet, pSet, hr) - if (FAILED(hr)) return hr; - GET_WRL_OBJ_FROM_OBJ(_Map, spSetting, pSet, hr) - if (FAILED(hr)) return hr; - ACTIVATE_STATIC_OBJ(RuntimeClass_Windows_Foundation_PropertyValue, MAKE_WRL_OBJ(_PropertyValueStatics), spPropVal, hr) - if (FAILED(hr)) return hr; - _ObjectObj pVal; - boolean bReplaced; - WRL_METHOD(spPropVal, CreateUInt32, pVal, hr, (unsigned int)WRL_ENUM_GET(_MediaStreamType, MediaStreamType, VideoPreview)) - if (FAILED(hr)) return hr; - WRL_METHOD(spSetting, Insert, bReplaced, hr, DEREF_WRL_OBJ(_StringReference(MF_PROP_VIDTYPE)), DEREF_WRL_OBJ(pVal)) - if (FAILED(hr)) return hr; - WRL_METHOD(spSetting, Insert, bReplaced, hr, DEREF_WRL_OBJ(_StringReference(MF_PROP_SAMPLEGRABBERCALLBACK)), reinterpret_cast<_Object>(this)) - if (FAILED(hr)) return hr; - MAKE_WRL_OBJ(_VideoDeviceController) pDevCont; - WRL_PROP_GET(ig_pMedCapSource, VideoDeviceController, pDevCont, hr) - if (FAILED(hr)) return hr; - GET_WRL_OBJ_FROM_OBJ(_MediaDeviceController, pMedDevCont, pDevCont, hr) - if (FAILED(hr)) return hr; - MAKE_WRL_OBJ(_MediaEncodingProperties) pMedEncProps; - WRL_METHOD(pMedDevCont, GetMediaStreamProperties, pMedEncProps, hr, WRL_ENUM_GET(_MediaStreamType, MediaStreamType, VideoPreview)) - if (FAILED(hr)) return hr; - GET_WRL_OBJ_FROM_OBJ(_VideoEncodingProperties, pVidProps, pMedEncProps, hr); - if (FAILED(hr)) return hr; - ACTIVATE_OBJ(RuntimeClass_Windows_Media_MediaProperties_MediaEncodingProfile, _MediaEncodingProfile, pEncProps, hr) - if (FAILED(hr)) return hr; - WRL_PROP_PUT(pEncProps, Video, DEREF_WRL_OBJ(pVidProps), hr) - if (FAILED(hr)) return hr; - WRL_METHOD(spSetting, Insert, bReplaced, hr, DEREF_WRL_OBJ(_StringReference(MF_PROP_VIDENCPROPS)), DEREF_WRL_OBJ(pVidProps)) - if (SUCCEEDED(hr)) { - //can start/stop multiple times with same MediaCapture object if using activatable class - WRL_METHOD(imedPrevCap, _StartPreviewToCustomSinkIdAsync, *action, hr, DEREF_WRL_OBJ(pEncProps), DEREF_WRL_OBJ(_StringReference(RuntimeClass_CV_MediaSink)), DEREF_WRL_OBJ(pSet)) - if (FAILED(hr) && hr == REGDB_E_CLASSNOTREG) { - hr = Microsoft::WRL::Make().CopyTo(&ig_pMediaSink); - if (FAILED(hr)) return hr; - hr = ((ABI::Windows::Media::IMediaExtension*)ig_pMediaSink)->SetProperties(DEREF_AS_NATIVE_WRL_OBJ(ABI::Windows::Foundation::Collections::IPropertySet, pSet)); - if (FAILED(hr)) return hr; - WRL_METHOD(imedPrevCap, StartPreviewToCustomSinkAsync, *action, hr, DEREF_WRL_OBJ(pEncProps), reinterpret_cast(ig_pMediaSink)) - } - } - return hr; -} - -HRESULT ImageGrabberWinRT::CreateInstance(ImageGrabberWinRT **ppIG, bool synchronous) -{ - *ppIG = Microsoft::WRL::Make(synchronous).Detach(); - if (ppIG == NULL) - { - return E_OUTOFMEMORY; - } - DebugPrintOut(L"IMAGEGRABBER VIDEODEVICE: Creating instance of ImageGrabberWinRT\n"); - return S_OK; -} -#endif - HRESULT ImageGrabber::initImageGrabber(IMFMediaSource *pSource) { // Clean up. @@ -1811,12 +1550,6 @@ unsigned char * RawImage::getpPixels() videoDevice::videoDevice(void): vd_IsSetuped(false), vd_LockOut(OpenLock), vd_pFriendlyName(NULL), vd_Width(0), vd_Height(0), vd_FrameRate(0), vd_pSource(NULL), vd_pImGrTh(NULL), vd_func(NULL), vd_userData(NULL) { -#ifdef WINRT - vd_pMedCap = nullptr; - vd_cookie.value = 0; - vd_pImGr = NULL; - vd_pAction = nullptr; -#endif } void videoDevice::setParametrs(CamParametrs parametrs) @@ -1899,63 +1632,13 @@ CamParametrs videoDevice::getParametrs() return out; } -#ifdef WINRT -long videoDevice::resetDevice(MAKE_WRL_REF(_IDeviceInformation) pDevice) -#else long videoDevice::resetDevice(IMFActivate *pActivate) -#endif { HRESULT hr = E_FAIL; vd_CurrentFormats.clear(); if(vd_pFriendlyName) CoTaskMemFree(vd_pFriendlyName); vd_pFriendlyName = NULL; -#ifdef WINRT - if (pDevice) - { - ACTIVATE_OBJ(RuntimeClass_Windows_Media_Capture_MediaCapture, _MediaCapture, pIMedCap, hr) - if (FAILED(hr)) return hr; - ACTIVATE_OBJ(RuntimeClass_Windows_Media_Capture_MediaCaptureInitializationSettings, _MediaCaptureInitializationSettings, pCapInitSet, hr) - if (FAILED(hr)) return hr; - _StringObj str; - WRL_PROP_GET(pDevice, Name, *REF_WRL_OBJ(str), hr) - if (FAILED(hr)) return hr; - unsigned int length = 0; - PCWSTR wstr = WindowsGetStringRawBuffer(reinterpret_cast(DEREF_WRL_OBJ(str)), &length); - vd_pFriendlyName = (wchar_t*)CoTaskMemAlloc((length + 1) * sizeof(wchar_t)); - wcscpy(vd_pFriendlyName, wstr); - WRL_PROP_GET(pDevice, Id, *REF_WRL_OBJ(str), hr) - if (FAILED(hr)) return hr; - WRL_PROP_PUT(pCapInitSet, VideoDeviceId, DEREF_WRL_OBJ(str), hr) - if (FAILED(hr)) return hr; - WRL_PROP_PUT(pCapInitSet, StreamingCaptureMode, WRL_ENUM_GET(_StreamingCaptureMode, StreamingCaptureMode, Video), hr) - if (FAILED(hr)) return hr; - MAKE_WRL_REF(_AsyncAction) pAction; - WRL_METHOD(DEREF_WRL_OBJ(pIMedCap), _InitializeWithSettingsAsync, pAction, hr, DEREF_WRL_OBJ(pCapInitSet)) -#ifdef HAVE_CONCURRENCY - DEFINE_TASK _task = CREATE_TASK DEFINE_RET_TYPE(void)(pAction); - if (FAILED(hr)) return hr; - MAKE_WRL_AGILE_REF(_MediaCapture) pAgileMedCap; - pAgileMedCap = PREPARE_TRANSFER_WRL_OBJ(pIMedCap); - Concurrency::critical_section::scoped_lock _LockHolder(vd_lock); - MAKE_WRL_REF(_AsyncAction) pOldAction = vd_pAction; - SAVE_CURRENT_CONTEXT(context); - vd_pAction = reinterpret_cast(BEGIN_CREATE_ASYNC(void, _task, pOldAction, context, &pAgileMedCap, this) - HRESULT hr = S_OK; - if (pOldAction) CREATE_TASK DEFINE_RET_TYPE(void)(pOldAction).wait(); - _task.wait(); - if (SUCCEEDED(hr)) { - //all camera capture calls only in original context - BEGIN_CALL_IN_CONTEXT(hr, context, pAgileMedCap, this) - enumerateCaptureFormats(DEREF_AGILE_WRL_OBJ(pAgileMedCap)); - END_CALL_IN_CONTEXT_BASE - } - buildLibraryofTypes(); - RELEASE_AGILE_WRL(pAgileMedCap) - END_CREATE_ASYNC(hr)); -#endif - } -#else if(pActivate) { IMFMediaSource *pSource = NULL; @@ -1981,64 +1664,15 @@ long videoDevice::resetDevice(IMFActivate *pActivate) DebugPrintOut(L"VIDEODEVICE %i: IMFMediaSource interface cannot be created \n", vd_CurrentNumber); } } -#endif return hr; } -#ifdef WINRT -long videoDevice::readInfoOfDevice(MAKE_WRL_REF(_IDeviceInformation) pDevice, unsigned int Num) -{ - HRESULT hr = -1; - vd_CurrentNumber = Num; - hr = resetDevice(pDevice); - return hr; -} -#else long videoDevice::readInfoOfDevice(IMFActivate *pActivate, unsigned int Num) { vd_CurrentNumber = Num; return resetDevice(pActivate); } -#endif -#ifdef WINRT -#ifdef HAVE_CONCURRENCY -long videoDevice::checkDevice(_DeviceClass devClass, DEFINE_TASK* pTask, MAKE_WRL_REF(_IDeviceInformation)* ppDevice) -{ - HRESULT hr = S_OK; - ACTIVATE_STATIC_OBJ(RuntimeClass_Windows_Devices_Enumeration_DeviceInformation, MAKE_WRL_OBJ(_DeviceInformationStatics), pDevStat, hr) - if (FAILED(hr)) return hr; - MAKE_WRL_REF(_AsyncOperation) pAction; - WRL_METHOD(pDevStat, _FindAllAsyncDeviceClass, pAction, hr, devClass) - if (SUCCEEDED(hr)) { - *pTask = CREATE_TASK DEFINE_RET_TYPE(void)([pAction, &ppDevice, this]() -> DEFINE_RET_FORMAL(void) { - HRESULT hr = S_OK; - MAKE_WRL_OBJ(_VectorView) pVector = - CREATE_TASK DEFINE_RET_TYPE(MAKE_WRL_REF(_VectorView))(pAction).get(); - UINT32 count = 0; - if (SUCCEEDED(hr)) WRL_PROP_GET(pVector, Size, count, hr) - if (SUCCEEDED(hr) && count > 0) { - for (UINT32 i = 0; i < count; i++) { - MAKE_WRL_OBJ(_IDeviceInformation) pDevice; - WRL_METHOD(pVector, GetAt, pDevice, hr, i) - if (SUCCEEDED(hr)) { - _StringObj str; - unsigned int length = 0; - WRL_PROP_GET(pDevice, Name, *REF_WRL_OBJ(str), hr) - PCWSTR wstr = WindowsGetStringRawBuffer(reinterpret_cast(DEREF_WRL_OBJ(str)), &length); - if (wcscmp(wstr, vd_pFriendlyName) == 0) { - *ppDevice = PREPARE_TRANSFER_WRL_OBJ(pDevice); - } - } - } - } - RET_VAL_BASE; - }); - } - return hr; -} -#endif -#else long videoDevice::checkDevice(IMFAttributes *pAttributes, IMFActivate **pDevice) { IMFActivate **ppDevices = NULL; @@ -2095,59 +1729,11 @@ long videoDevice::checkDevice(IMFAttributes *pAttributes, IMFActivate **pDevice) } return hr; } -#endif long videoDevice::initDevice() { HRESULT hr = S_OK; CoInitialize(NULL); -#ifdef WINRT -#ifdef HAVE_CONCURRENCY - Concurrency::critical_section::scoped_lock _LockHolder(vd_lock); - MAKE_WRL_REF(_AsyncAction) pOldAction = vd_pAction; - SAVE_CURRENT_CONTEXT(context); - vd_pAction = reinterpret_cast(BEGIN_CREATE_ASYNC(void, pOldAction, context, this) - HRESULT hr; - if (pOldAction) CREATE_TASK DEFINE_RET_TYPE(void)(pOldAction).wait(); - DEFINE_TASK pTask; - MAKE_WRL_OBJ(_IDeviceInformation) pDevInfo; - hr = checkDevice(WRL_ENUM_GET(_DeviceClass, DeviceClass, VideoCapture), &pTask, REF_WRL_OBJ(pDevInfo)); - if (SUCCEEDED(hr)) pTask.wait(); - if (SUCCEEDED(hr)) { - DEFINE_TASK _task; - BEGIN_CALL_IN_CONTEXT(hr, context, pDevInfo, &_task, context, this) - HRESULT hr; - ACTIVATE_OBJ(RuntimeClass_Windows_Media_Capture_MediaCapture, _MediaCapture, pIMedCap, hr) - if (SUCCEEDED(hr)) { - RELEASE_WRL(vd_pMedCap); - vd_pMedCap = PREPARE_TRANSFER_WRL_OBJ(pIMedCap); - ACTIVATE_OBJ(RuntimeClass_Windows_Media_Capture_MediaCaptureInitializationSettings, _MediaCaptureInitializationSettings, pCapInitSet, hr) - _StringObj str; - if (SUCCEEDED(hr)) { - WRL_PROP_GET(pDevInfo, Id, *REF_WRL_OBJ(str), hr) - if (SUCCEEDED(hr)) { - WRL_PROP_PUT(pCapInitSet, VideoDeviceId, DEREF_WRL_OBJ(str), hr) - } - } - if (SUCCEEDED(hr)) - WRL_PROP_PUT(pCapInitSet, StreamingCaptureMode, WRL_ENUM_GET(_StreamingCaptureMode, StreamingCaptureMode, Video), hr) - if (SUCCEEDED(hr)) reinterpret_cast(DEREF_AGILE_WRL_OBJ(vd_pMedCap))->add_Failed(Microsoft::WRL::Callback([this, context](ABI::Windows::Media::Capture::IMediaCapture*, ABI::Windows::Media::Capture::IMediaCaptureFailedEventArgs*) -> HRESULT { - HRESULT hr; - BEGIN_CALL_IN_CONTEXT(hr, context, this) - closeDevice(); - END_CALL_IN_CONTEXT_BASE - return hr; - }).Get(), &vd_cookie); - MAKE_WRL_OBJ(_AsyncAction) pAction; - if (SUCCEEDED(hr)) WRL_METHOD(vd_pMedCap, _InitializeWithSettingsAsync, *REF_WRL_OBJ(pAction), hr, DEREF_WRL_OBJ(pCapInitSet)) - if (SUCCEEDED(hr)) _task = CREATE_TASK DEFINE_RET_TYPE(void)(DEREF_WRL_OBJ(pAction)); - } - END_CALL_IN_CONTEXT(hr) - _task.wait(); - } - END_CREATE_ASYNC(hr)); -#endif -#else _ComPtr pAttributes = NULL; IMFActivate *vd_pActivate = NULL; hr = MFCreateAttributes(pAttributes.GetAddressOf(), 1); @@ -2182,7 +1768,6 @@ long videoDevice::initDevice() { DebugPrintOut(L"VIDEODEVICE %i: The attribute of video cameras cannot be getting \n", vd_CurrentNumber); } -#endif return hr; } @@ -2209,31 +1794,6 @@ void videoDevice::closeDevice() { vd_IsSetuped = false; -#ifdef WINRT -#ifdef HAVE_CONCURRENCY - if (DEREF_AGILE_WRL_OBJ(vd_pMedCap)) { - MAKE_WRL_REF(_AsyncAction) action; - Concurrency::critical_section::scoped_lock _LockHolder(vd_lock); - MAKE_WRL_REF(_AsyncAction) pOldAction = vd_pAction; - vd_pImGr->stopGrabbing(&action); - reinterpret_cast(DEREF_AGILE_WRL_OBJ(vd_pMedCap))->remove_Failed(vd_cookie); - vd_cookie.value = 0; - vd_pAction = reinterpret_cast(BEGIN_CREATE_ASYNC(void, action, pOldAction, this) - HRESULT hr = S_OK; - if (pOldAction) CREATE_TASK DEFINE_RET_TYPE(void)(pOldAction).wait(); - CREATE_TASK DEFINE_RET_TYPE(void)(action).wait(); - RELEASE_WRL(vd_pMedCap) - if(vd_LockOut == RawDataLock) { - delete vd_pImGr; - } - vd_pImGr = NULL; - vd_LockOut = OpenLock; - END_CREATE_ASYNC(hr)); - return; - } -#endif -#endif - vd_pSource->Shutdown(); SafeRelease(&vd_pSource); if(vd_LockOut == RawDataLock) @@ -2363,26 +1923,6 @@ void videoDevice::buildLibraryofTypes() } } -#ifdef WINRT -long videoDevice::setDeviceFormat(MAKE_WRL_REF(_MediaCapture) pSource, unsigned long dwFormatIndex, MAKE_WRL_REF(_AsyncAction)* pAction) -{ - HRESULT hr; - MAKE_WRL_OBJ(_VideoDeviceController) pDevCont; - WRL_PROP_GET(pSource, VideoDeviceController, pDevCont, hr) - if (FAILED(hr)) return hr; - GET_WRL_OBJ_FROM_OBJ(_MediaDeviceController, pMedDevCont, pDevCont, hr) - if (FAILED(hr)) return hr; - MAKE_WRL_OBJ(_VectorView) pVector; - WRL_METHOD(pMedDevCont, GetAvailableMediaStreamProperties, pVector, hr, WRL_ENUM_GET(_MediaStreamType, MediaStreamType, VideoPreview)) - if (FAILED(hr)) return hr; - MAKE_WRL_OBJ(_MediaEncodingProperties) pMedEncProps; - WRL_METHOD(pVector, GetAt, pMedEncProps, hr, dwFormatIndex) - if (FAILED(hr)) return hr; - WRL_METHOD(pMedDevCont, SetMediaStreamPropertiesAsync, *pAction, hr, WRL_ENUM_GET(_MediaStreamType, MediaStreamType, VideoPreview), DEREF_WRL_OBJ(pMedEncProps)) - return hr; -} -#endif - long videoDevice::setDeviceFormat(IMFMediaSource *pSource, unsigned long dwFormatIndex) { _ComPtr pPD = NULL; @@ -2424,9 +1964,6 @@ bool videoDevice::isDeviceSetup() RawImage * videoDevice::getRawImageOut() { if(!vd_IsSetuped) return NULL; -#ifdef WINRT - if(vd_pImGr) return vd_pImGr->getRawImage(); -#endif if(vd_pImGrTh) return vd_pImGrTh->getImageGrabber()->getRawImage(); else @@ -2446,27 +1983,6 @@ bool videoDevice::isFrameNew() vd_LockOut = RawDataLock; //must already be closed -#ifdef WINRT - if (DEREF_AGILE_WRL_OBJ(vd_pMedCap)) { - MAKE_WRL_REF(_AsyncAction) action; - if (FAILED(ImageGrabberWinRT::CreateInstance(&vd_pImGr))) return false; - if (FAILED(vd_pImGr->initImageGrabber(DEREF_AGILE_WRL_OBJ(vd_pMedCap), MFVideoFormat_RGB24)) || FAILED(vd_pImGr->startGrabbing(&action))) { - delete vd_pImGr; - return false; - } -#ifdef HAVE_CONCURRENCY - Concurrency::critical_section::scoped_lock _LockHolder(vd_lock); - MAKE_WRL_REF(_AsyncAction) pOldAction = vd_pAction; - DEFINE_TASK _task = CREATE_TASK DEFINE_RET_TYPE(void)(action); - vd_pAction = reinterpret_cast(BEGIN_CREATE_ASYNC(void, _task, pOldAction, this) - HRESULT hr = S_OK; - if (pOldAction) CREATE_TASK DEFINE_RET_TYPE(void)(pOldAction).wait(); - _task.wait(); - END_CREATE_ASYNC(hr)); -#endif - return true; - } -#endif HRESULT hr = ImageGrabberThread::CreateInstance(&vd_pImGrTh, vd_pSource, vd_CurrentNumber); if(FAILED(hr)) { @@ -2477,10 +1993,6 @@ bool videoDevice::isFrameNew() vd_pImGrTh->start(); return true; } -#ifdef WINRT - if(vd_pImGr) - return vd_pImGr->getRawImage()->isNew(); -#endif if(vd_pImGrTh) return vd_pImGrTh->getImageGrabber()->getRawImage()->isNew(); } @@ -2506,46 +2018,16 @@ bool videoDevice::setupDevice(unsigned int id) HRESULT hr = initDevice(); if(SUCCEEDED(hr)) { -#ifdef WINRT -#ifdef HAVE_CONCURRENCY - Concurrency::critical_section::scoped_lock _LockHolder(vd_lock); - MAKE_WRL_REF(_AsyncAction) pOldAction = vd_pAction; - SAVE_CURRENT_CONTEXT(context); - vd_pAction = reinterpret_cast(BEGIN_CREATE_ASYNC(void, pOldAction, context, id, this) - HRESULT hr; - if (pOldAction) CREATE_TASK DEFINE_RET_TYPE(void)(pOldAction).wait(); -#endif -#endif vd_Width = vd_CurrentFormats[id].width; vd_Height = vd_CurrentFormats[id].height; vd_FrameRate = vd_CurrentFormats[id].MF_MT_FRAME_RATE_NUMERATOR / vd_CurrentFormats[id].MF_MT_FRAME_RATE_DENOMINATOR; -#ifdef WINRT -#ifdef HAVE_CONCURRENCY - if (DEREF_AGILE_WRL_OBJ(vd_pMedCap)) { - DEFINE_TASK _task; - BEGIN_CALL_IN_CONTEXT(hr, context, id, &_task, this) - MAKE_WRL_REF(_AsyncAction) pAction; - HRESULT hr = setDeviceFormat(DEREF_AGILE_WRL_OBJ(vd_pMedCap), (DWORD) id, &pAction); - if (SUCCEEDED(hr)) _task = CREATE_TASK DEFINE_RET_TYPE(void)(pAction); - END_CALL_IN_CONTEXT(hr) - if (SUCCEEDED(hr)) _task.wait(); - } else -#endif -#endif hr = setDeviceFormat(vd_pSource, (DWORD) id); vd_IsSetuped = (SUCCEEDED(hr)); if(vd_IsSetuped) DebugPrintOut(L"\n\nVIDEODEVICE %i: Device is setuped \n", vd_CurrentNumber); vd_PrevParametrs = getParametrs(); -#ifdef WINRT -#ifdef HAVE_CONCURRENCY - END_CREATE_ASYNC(hr)); -#endif - return true; -#else return vd_IsSetuped; -#endif } else { @@ -2577,43 +2059,11 @@ wchar_t *videoDevice::getName() videoDevice::~videoDevice(void) { closeDevice(); -#ifdef WINRT - RELEASE_WRL(vd_pMedCap) -#endif SafeRelease(&vd_pSource); if(vd_pFriendlyName) CoTaskMemFree(vd_pFriendlyName); } -#ifdef WINRT -HRESULT videoDevice::enumerateCaptureFormats(MAKE_WRL_REF(_MediaCapture) pSource) -{ - HRESULT hr; - MAKE_WRL_OBJ(_VideoDeviceController) pDevCont; - WRL_PROP_GET(pSource, VideoDeviceController, pDevCont, hr) - if (FAILED(hr)) return hr; - GET_WRL_OBJ_FROM_OBJ(_MediaDeviceController, pMedDevCont, pDevCont, hr) - if (FAILED(hr)) return hr; - MAKE_WRL_OBJ(_VectorView) pVector; - WRL_METHOD(pMedDevCont, GetAvailableMediaStreamProperties, pVector, hr, WRL_ENUM_GET(_MediaStreamType, MediaStreamType, VideoPreview)) - if (FAILED(hr)) return hr; - UINT32 count; - WRL_PROP_GET(pVector, Size, count, hr) - if (FAILED(hr)) return hr; - for (UINT32 i = 0; i < count; i++) { - MAKE_WRL_OBJ(_MediaEncodingProperties) pMedEncProps; - WRL_METHOD(pVector, GetAt, pMedEncProps, hr, i) - if (FAILED(hr)) return hr; - _ComPtr pType = NULL; - hr = MediaSink::ConvertPropertiesToMediaType(DEREF_AS_NATIVE_WRL_OBJ(ABI::Windows::Media::MediaProperties::IMediaEncodingProperties, pMedEncProps), &pType); - if (FAILED(hr)) return hr; - MediaType MT = FormatReader::Read(pType.Get()); - vd_CurrentFormats.push_back(MT); - } - return hr; -} -#endif - HRESULT videoDevice::enumerateCaptureFormats(IMFMediaSource *pSource) { HRESULT hr = S_OK; @@ -2668,9 +2118,6 @@ done: videoDevices::videoDevices(void): count(0) { -#ifdef WINRT - vds_enumTask = nullptr; -#endif } void videoDevices::clearDevices() @@ -2699,41 +2146,6 @@ videoDevice * videoDevices::getDevice(unsigned int i) return vds_Devices[i]; } -#ifdef WINRT -long videoDevices::initDevices(_DeviceClass devClass) -{ - HRESULT hr = S_OK; - ACTIVATE_STATIC_OBJ(RuntimeClass_Windows_Devices_Enumeration_DeviceInformation, MAKE_WRL_OBJ(_DeviceInformationStatics), pDevStat, hr) - if (FAILED(hr)) return hr; - MAKE_WRL_REF(_AsyncOperation) pAction; - WRL_METHOD(pDevStat, _FindAllAsyncDeviceClass, pAction, hr, devClass) - if (SUCCEEDED(hr)) { -#ifdef HAVE_CONCURRENCY - SAVE_CURRENT_CONTEXT(context); - vds_enumTask = reinterpret_cast(BEGIN_CREATE_ASYNC(void, pAction, context, this) - HRESULT hr = S_OK; - MAKE_WRL_OBJ(_VectorView) pVector = - CREATE_TASK DEFINE_RET_TYPE(MAKE_WRL_REF(_VectorView))(pAction).get(); - if (SUCCEEDED(hr)) WRL_PROP_GET(pVector, Size, count, hr) - if (SUCCEEDED(hr) && count > 0) { - for (UINT32 i = 0; i < count; i++) { - videoDevice *vd = new videoDevice; - MAKE_WRL_OBJ(_IDeviceInformation) pDevice; - WRL_METHOD(pVector, GetAt, pDevice, hr, i) - if (SUCCEEDED(hr)) { - BEGIN_CALL_IN_CONTEXT(hr, context, vd, pDevice, i) - vd->readInfoOfDevice(DEREF_WRL_OBJ(pDevice), i); - END_CALL_IN_CONTEXT_BASE - vds_Devices.push_back(vd); - } - } - } - END_CREATE_ASYNC(hr)); -#endif - } - return hr; -} -#else long videoDevices::initDevices(IMFAttributes *pAttributes) { clearDevices(); @@ -2761,7 +2173,6 @@ long videoDevices::initDevices(IMFAttributes *pAttributes) } return hr; } -#endif unsigned int videoDevices::getCount() { @@ -2836,10 +2247,6 @@ videoInput::videoInput(void): MF(Media_Foundation::getInstance()), accessToDevic void videoInput::updateListOfDevices() { HRESULT hr = S_OK; -#ifdef WINRT - videoDevices *vDs = &videoDevices::getInstance(); - hr = vDs->initDevices(WRL_ENUM_GET(_DeviceClass, DeviceClass, VideoCapture)); -#else _ComPtr pAttributes = NULL; CoInitialize(NULL); hr = MFCreateAttributes(pAttributes.GetAddressOf(), 1); @@ -2855,7 +2262,6 @@ void videoInput::updateListOfDevices() videoDevices *vDs = &videoDevices::getInstance(); hr = vDs->initDevices(pAttributes.Get()); } -#endif if (FAILED(hr)) { DebugPrintOut(L"MEDIA FOUNDATION: The access to the video cameras denied\n"); @@ -3059,36 +2465,6 @@ bool videoInput::isFrameNew(int deviceID) return false; } -#ifdef WINRT -void videoInput::waitForDevice(int deviceID) -{ - if (deviceID < 0) - { - DebugPrintOut(L"VIDEODEVICE %i: Invalid device ID\n", deviceID); - return; - } - if(accessToDevices) - { - if(!isDeviceSetup(deviceID)) - { - if(isDeviceMediaSource(deviceID)) - return; - } - videoDevices *VDS = &videoDevices::getInstance(); - videoDevice * VD = VDS->getDevice(deviceID); - if(VD) - { - VD->waitForDevice(); - } - } - else - { - DebugPrintOut(L"VIDEODEVICE(s): There is not any suitable video device\n"); - } - return; -} -#endif - unsigned int videoInput::getCountFormats(int deviceID) const { if (deviceID < 0) @@ -3268,9 +2644,6 @@ unsigned int videoInput::listDevices(bool silent) if(accessToDevices) { videoDevices *VDS = &videoDevices::getInstance(); -#ifdef WINRT - VDS->waitInit(); -#endif out = VDS->getCount(); if(!silent) DebugPrintOut(L"\nVIDEOINPUT SPY MODE!\n\n"); if(!silent) DebugPrintOut(L"SETUP: Looking For Capture Devices\n"); @@ -3458,12 +2831,6 @@ protected: int index, width, height, fourcc; IplImage* frame; videoInput VI; -#ifdef WINRT -#ifdef HAVE_CONCURRENCY - DEFINE_TASK openTask; - Concurrency::critical_section lock; -#endif -#endif }; #ifdef _DEBUG @@ -3506,12 +2873,6 @@ void CvCaptureCAM_MSMF::close() // Initialize camera input bool CvCaptureCAM_MSMF::open( int _index ) { -#ifdef WINRT -#ifdef HAVE_CONCURRENCY - SAVE_CURRENT_CONTEXT(context); - auto func = [_index, context, this](DEFINE_RET_VAL(bool)) -> DEFINE_RET_FORMAL(bool) { -#endif -#endif int try_index = _index; int devices = 0; close(); @@ -3519,37 +2880,10 @@ bool CvCaptureCAM_MSMF::open( int _index ) if (devices == 0) return false; try_index = try_index < 0 ? 0 : (try_index > devices-1 ? devices-1 : try_index); -#ifdef WINRT - HRESULT hr; -#ifdef HAVE_CONCURRENCY - BEGIN_CALL_IN_CONTEXT(hr, context, this, try_index) -#endif -#endif VI.setupDevice(try_index, 0, 0, 0); // With maximum frame size. -#ifdef WINRT -#ifdef HAVE_CONCURRENCY - END_CALL_IN_CONTEXT_BASE - VI.waitForDevice(try_index); - BEGIN_CALL_IN_CONTEXT(hr, context, this, try_index) - HRESULT hr = S_OK; -#endif -#endif if( !VI.isFrameNew(try_index) ) -#ifdef WINRT - hr = E_FAIL; -#else return false; -#endif index = try_index; -#ifdef WINRT -#ifdef HAVE_CONCURRENCY - END_CALL_IN_CONTEXT_BASE - RET_VAL(true) - }; - Concurrency::critical_section::scoped_lock _LockHolder(lock); - CREATE_OR_CONTINUE_TASK(openTask, bool, func) -#endif -#endif return true; } diff --git a/modules/videoio/src/cap_msmf.hpp b/modules/videoio/src/cap_msmf.hpp index 2d48f86d94..04aa3b9806 100644 --- a/modules/videoio/src/cap_msmf.hpp +++ b/modules/videoio/src/cap_msmf.hpp @@ -1,9 +1,3 @@ -#ifdef WINRT -#define ICustomStreamSink StreamSink -#ifndef __cplusplus_winrt -#include "wrl.h" -#endif -#else EXTERN_C const IID IID_ICustomStreamSink; class DECLSPEC_UUID("4F8A1939-2FD3-46DB-AE70-DB7E0DD79B73") DECLSPEC_NOVTABLE ICustomStreamSink : public IUnknown @@ -16,7 +10,6 @@ public: virtual HRESULT Restart() = 0; virtual HRESULT Stop() = 0; }; -#endif #define MF_PROP_SAMPLEGRABBERCALLBACK L"samplegrabbercallback" #define MF_PROP_VIDTYPE L"vidtype" @@ -182,219 +175,6 @@ MAKE_ENUM(MFSTREAMSINK_MARKER_TYPE) StreamSinkMarkerTypePairs[] = { }; MAKE_MAP(MFSTREAMSINK_MARKER_TYPE) StreamSinkMarkerTypeMap(StreamSinkMarkerTypePairs, StreamSinkMarkerTypePairs + sizeof(StreamSinkMarkerTypePairs) / sizeof(StreamSinkMarkerTypePairs[0])); -#ifdef WINRT - -#ifdef __cplusplus_winrt -#define _ContextCallback Concurrency::details::_ContextCallback -#define BEGIN_CALL_IN_CONTEXT(hr, var, ...) hr = S_OK;\ - var._CallInContext([__VA_ARGS__]() { -#define END_CALL_IN_CONTEXT(hr) if (FAILED(hr)) throw Platform::Exception::CreateException(hr);\ -}); -#define END_CALL_IN_CONTEXT_BASE }); -#else -#define _ContextCallback Concurrency_winrt::details::_ContextCallback -#define BEGIN_CALL_IN_CONTEXT(hr, var, ...) hr = var._CallInContext([__VA_ARGS__]() -> HRESULT { -#define END_CALL_IN_CONTEXT(hr) return hr;\ -}); -#define END_CALL_IN_CONTEXT_BASE return S_OK;\ -}); -#endif -#define GET_CURRENT_CONTEXT _ContextCallback::_CaptureCurrent() -#define SAVE_CURRENT_CONTEXT(var) _ContextCallback var = GET_CURRENT_CONTEXT - -#define COMMA , - -#ifdef __cplusplus_winrt -#define _Object Platform::Object^ -#define _ObjectObj Platform::Object^ -#define _String Platform::String^ -#define _StringObj Platform::String^ -#define _StringReference ref new Platform::String -#define _StringReferenceObj Platform::String^ -#define _DeviceInformationCollection Windows::Devices::Enumeration::DeviceInformationCollection -#define _MediaCapture Windows::Media::Capture::MediaCapture -#define _MediaCaptureVideoPreview Windows::Media::Capture::MediaCapture -#define _MediaCaptureInitializationSettings Windows::Media::Capture::MediaCaptureInitializationSettings -#define _VideoDeviceController Windows::Media::Devices::VideoDeviceController -#define _MediaDeviceController Windows::Media::Devices::VideoDeviceController -#define _MediaEncodingProperties Windows::Media::MediaProperties::IMediaEncodingProperties -#define _VideoEncodingProperties Windows::Media::MediaProperties::VideoEncodingProperties -#define _MediaStreamType Windows::Media::Capture::MediaStreamType -#define _AsyncInfo Windows::Foundation::IAsyncInfo -#define _AsyncAction Windows::Foundation::IAsyncAction -#define _AsyncOperation Windows::Foundation::IAsyncOperation -#define _DeviceClass Windows::Devices::Enumeration::DeviceClass -#define _IDeviceInformation Windows::Devices::Enumeration::DeviceInformation -#define _DeviceInformation Windows::Devices::Enumeration::DeviceInformation -#define _DeviceInformationStatics Windows::Devices::Enumeration::DeviceInformation -#define _MediaEncodingProfile Windows::Media::MediaProperties::MediaEncodingProfile -#define _StreamingCaptureMode Windows::Media::Capture::StreamingCaptureMode -#define _PropertySet Windows::Foundation::Collections::PropertySet -#define _Map Windows::Foundation::Collections::PropertySet -#define _PropertyValueStatics Windows::Foundation::PropertyValue -#define _VectorView Windows::Foundation::Collections::IVectorView -#define _StartPreviewToCustomSinkIdAsync StartPreviewToCustomSinkAsync -#define _InitializeWithSettingsAsync InitializeAsync -#define _FindAllAsyncDeviceClass FindAllAsync -#define _MediaExtension Windows::Media::IMediaExtension -#define BEGIN_CREATE_ASYNC(type, ...) (Concurrency::create_async([__VA_ARGS__]() { -#define END_CREATE_ASYNC(hr) if (FAILED(hr)) throw Platform::Exception::CreateException(hr);\ -})) -#define DEFINE_TASK Concurrency::task -#define CREATE_TASK Concurrency::create_task -#define CREATE_OR_CONTINUE_TASK(_task, rettype, func) _task = (_task == Concurrency::task()) ? Concurrency::create_task(func) : _task.then([func](rettype) -> rettype { return func(); }); -#define DEFINE_RET_VAL(x) -#define DEFINE_RET_TYPE(x) -#define DEFINE_RET_FORMAL(x) x -#define RET_VAL(x) return x; -#define RET_VAL_BASE -#define MAKE_STRING(str) str -#define GET_STL_STRING(str) std::wstring(str->Data()) -#define GET_STL_STRING_RAW(str) std::wstring(str->Data()) -#define MAKE_WRL_OBJ(x) x^ -#define MAKE_WRL_REF(x) x^ -#define MAKE_OBJ_REF(x) x^ -#define MAKE_WRL_AGILE_REF(x) Platform::Agile -#define MAKE_PROPERTY_BACKING(Type, PropName) property Type PropName; -#define MAKE_PROPERTY(Type, PropName, PropValue) -#define MAKE_PROPERTY_STRING(Type, PropName, PropValue) -#define MAKE_READONLY_PROPERTY(Type, PropName, PropValue) property Type PropName\ -{\ - Type get() { return PropValue; }\ -} -#define THROW_INVALID_ARG throw ref new Platform::InvalidArgumentException(); -#define RELEASE_AGILE_WRL(x) x = nullptr; -#define RELEASE_WRL(x) x = nullptr; -#define GET_WRL_OBJ_FROM_REF(objtype, obj, orig, hr) objtype^ obj = orig;\ -hr = S_OK; -#define GET_WRL_OBJ_FROM_OBJ(objtype, obj, orig, hr) objtype^ obj = safe_cast(orig);\ -hr = S_OK; -#define WRL_ENUM_GET(obj, prefix, prop) obj::##prop -#define WRL_PROP_GET(obj, prop, arg, hr) arg = obj->##prop;\ -hr = S_OK; -#define WRL_PROP_PUT(obj, prop, arg, hr) obj->##prop = arg;\ -hr = S_OK; -#define WRL_METHOD_BASE(obj, method, ret, hr) ret = obj->##method();\ -hr = S_OK; -#define WRL_METHOD(obj, method, ret, hr, ...) ret = obj->##method(__VA_ARGS__);\ -hr = S_OK; -#define WRL_METHOD_NORET_BASE(obj, method, hr) obj->##method();\ - hr = S_OK; -#define WRL_METHOD_NORET(obj, method, hr, ...) obj->##method(__VA_ARGS__);\ - hr = S_OK; -#define REF_WRL_OBJ(obj) &obj -#define DEREF_WRL_OBJ(obj) obj -#define DEREF_AGILE_WRL_OBJ(obj) obj.Get() -#define DEREF_AS_NATIVE_WRL_OBJ(type, obj) reinterpret_cast(obj) -#define PREPARE_TRANSFER_WRL_OBJ(obj) obj -#define ACTIVATE_LOCAL_OBJ_BASE(objtype) ref new objtype() -#define ACTIVATE_LOCAL_OBJ(objtype, ...) ref new objtype(__VA_ARGS__) -#define ACTIVATE_EVENT_HANDLER(objtype, ...) ref new objtype(__VA_ARGS__) -#define ACTIVATE_OBJ(rtclass, objtype, obj, hr) MAKE_WRL_OBJ(objtype) obj = ref new objtype();\ -hr = S_OK; -#define ACTIVATE_STATIC_OBJ(rtclass, objtype, obj, hr) objtype obj;\ -hr = S_OK; -#else -#define _Object IInspectable* -#define _ObjectObj Microsoft::WRL::ComPtr -#define _String HSTRING -#define _StringObj Microsoft::WRL::Wrappers::HString -#define _StringReference Microsoft::WRL::Wrappers::HStringReference -#define _StringReferenceObj Microsoft::WRL::Wrappers::HStringReference -#define _DeviceInformationCollection ABI::Windows::Devices::Enumeration::DeviceInformationCollection -#define _MediaCapture ABI::Windows::Media::Capture::IMediaCapture -#define _MediaCaptureVideoPreview ABI::Windows::Media::Capture::IMediaCaptureVideoPreview -#define _MediaCaptureInitializationSettings ABI::Windows::Media::Capture::IMediaCaptureInitializationSettings -#define _VideoDeviceController ABI::Windows::Media::Devices::IVideoDeviceController -#define _MediaDeviceController ABI::Windows::Media::Devices::IMediaDeviceController -#define _MediaEncodingProperties ABI::Windows::Media::MediaProperties::IMediaEncodingProperties -#define _VideoEncodingProperties ABI::Windows::Media::MediaProperties::IVideoEncodingProperties -#define _MediaStreamType ABI::Windows::Media::Capture::MediaStreamType -#define _AsyncInfo ABI::Windows::Foundation::IAsyncInfo -#define _AsyncAction ABI::Windows::Foundation::IAsyncAction -#define _AsyncOperation ABI::Windows::Foundation::IAsyncOperation -#define _DeviceClass ABI::Windows::Devices::Enumeration::DeviceClass -#define _IDeviceInformation ABI::Windows::Devices::Enumeration::IDeviceInformation -#define _DeviceInformation ABI::Windows::Devices::Enumeration::DeviceInformation -#define _DeviceInformationStatics ABI::Windows::Devices::Enumeration::IDeviceInformationStatics -#define _MediaEncodingProfile ABI::Windows::Media::MediaProperties::IMediaEncodingProfile -#define _StreamingCaptureMode ABI::Windows::Media::Capture::StreamingCaptureMode -#define _PropertySet ABI::Windows::Foundation::Collections::IPropertySet -#define _Map ABI::Windows::Foundation::Collections::IMap -#define _PropertyValueStatics ABI::Windows::Foundation::IPropertyValueStatics -#define _VectorView ABI::Windows::Foundation::Collections::IVectorView -#define _StartPreviewToCustomSinkIdAsync StartPreviewToCustomSinkIdAsync -#define _InitializeWithSettingsAsync InitializeWithSettingsAsync -#define _FindAllAsyncDeviceClass FindAllAsyncDeviceClass -#define _MediaExtension ABI::Windows::Media::IMediaExtension -#define BEGIN_CREATE_ASYNC(type, ...) Concurrency_winrt::create_async([__VA_ARGS__]() -> HRESULT { -#define END_CREATE_ASYNC(hr) return hr;\ -}) -#define DEFINE_TASK Concurrency_winrt::task -#define CREATE_TASK Concurrency_winrt::create_task -#define CREATE_OR_CONTINUE_TASK(_task, rettype, func) _task = (_task == Concurrency_winrt::task()) ? Concurrency_winrt::create_task(func) : _task.then([func](rettype, rettype* retVal) -> HRESULT { return func(retVal); }); -#define DEFINE_RET_VAL(x) x* retVal -#define DEFINE_RET_TYPE(x) -#define DEFINE_RET_FORMAL(x) HRESULT -#define RET_VAL(x) *retVal = x;\ -return S_OK; -#define RET_VAL_BASE return S_OK; -#define MAKE_STRING(str) Microsoft::WRL::Wrappers::HStringReference(L##str) -#define GET_STL_STRING(str) std::wstring(str.GetRawBuffer(NULL)) -#define GET_STL_STRING_RAW(str) WindowsGetStringRawBuffer(str, NULL) -#define MAKE_WRL_OBJ(x) Microsoft::WRL::ComPtr -#define MAKE_WRL_REF(x) x* -#define MAKE_OBJ_REF(x) x -#define MAKE_WRL_AGILE_REF(x) x* -#define MAKE_PROPERTY_BACKING(Type, PropName) Type PropName; -#define MAKE_PROPERTY(Type, PropName, PropValue) STDMETHODIMP get_##PropName(Type* pVal) { if (pVal) { *pVal = PropValue; } else { return E_INVALIDARG; } return S_OK; }\ - STDMETHODIMP put_##PropName(Type Val) { PropValue = Val; return S_OK; } -#define MAKE_PROPERTY_STRING(Type, PropName, PropValue) STDMETHODIMP get_##PropName(Type* pVal) { if (pVal) { return ::WindowsDuplicateString(PropValue.Get(), pVal); } else { return E_INVALIDARG; } }\ - STDMETHODIMP put_##PropName(Type Val) { return PropValue.Set(Val); } -#define MAKE_READONLY_PROPERTY(Type, PropName, PropValue) STDMETHODIMP get_##PropName(Type* pVal) { if (pVal) { *pVal = PropValue; } else { return E_INVALIDARG; } return S_OK; } -#define THROW_INVALID_ARG RoOriginateError(E_INVALIDARG, nullptr); -#define RELEASE_AGILE_WRL(x) if (x) { (x)->Release(); x = nullptr; } -#define RELEASE_WRL(x) if (x) { (x)->Release(); x = nullptr; } -#define GET_WRL_OBJ_FROM_REF(objtype, obj, orig, hr) Microsoft::WRL::ComPtr obj;\ -hr = orig->QueryInterface(__uuidof(objtype), &obj); -#define GET_WRL_OBJ_FROM_OBJ(objtype, obj, orig, hr) Microsoft::WRL::ComPtr obj;\ -hr = orig.As(&obj); -#define WRL_ENUM_GET(obj, prefix, prop) obj::prefix##_##prop -#define WRL_PROP_GET(obj, prop, arg, hr) hr = obj->get_##prop(&arg); -#define WRL_PROP_PUT(obj, prop, arg, hr) hr = obj->put_##prop(arg); -#define WRL_METHOD_BASE(obj, method, ret, hr) hr = obj->##method(&ret); -#define WRL_METHOD(obj, method, ret, hr, ...) hr = obj->##method(__VA_ARGS__, &ret); -#define WRL_METHOD_NORET_BASE(obj, method, hr) hr = obj->##method(); -#define REF_WRL_OBJ(obj) obj.GetAddressOf() -#define DEREF_WRL_OBJ(obj) obj.Get() -#define DEREF_AGILE_WRL_OBJ(obj) obj -#define DEREF_AS_NATIVE_WRL_OBJ(type, obj) obj.Get() -#define PREPARE_TRANSFER_WRL_OBJ(obj) obj.Detach() -#define ACTIVATE_LOCAL_OBJ_BASE(objtype) Microsoft::WRL::Make() -#define ACTIVATE_LOCAL_OBJ(objtype, ...) Microsoft::WRL::Make(__VA_ARGS__) -#define ACTIVATE_EVENT_HANDLER(objtype, ...) Microsoft::WRL::Callback(__VA_ARGS__).Get() -#define ACTIVATE_OBJ(rtclass, objtype, obj, hr) MAKE_WRL_OBJ(objtype) obj;\ -{\ - Microsoft::WRL::ComPtr objFactory;\ - hr = Windows::Foundation::GetActivationFactory(Microsoft::WRL::Wrappers::HStringReference(rtclass).Get(), objFactory.ReleaseAndGetAddressOf());\ - if (SUCCEEDED(hr)) {\ - Microsoft::WRL::ComPtr pInsp;\ - hr = objFactory->ActivateInstance(pInsp.GetAddressOf());\ - if (SUCCEEDED(hr)) hr = pInsp.As(&obj);\ - }\ -} -#define ACTIVATE_STATIC_OBJ(rtclass, objtype, obj, hr) objtype obj;\ -{\ - Microsoft::WRL::ComPtr objFactory;\ - hr = Windows::Foundation::GetActivationFactory(Microsoft::WRL::Wrappers::HStringReference(rtclass).Get(), objFactory.ReleaseAndGetAddressOf());\ - if (SUCCEEDED(hr)) {\ - if (SUCCEEDED(hr)) hr = objFactory.As(&obj);\ - }\ -} -#endif - -#define _ComPtr Microsoft::WRL::ComPtr -#else #define _COM_SMARTPTR_DECLARE(T,var) T ## Ptr var @@ -509,7 +289,6 @@ private: }; #define _ComPtr ComPtr -#endif template class CBaseAttributes : public TBase @@ -860,19 +639,10 @@ protected: }; class StreamSink : -#ifdef WINRT - public Microsoft::WRL::RuntimeClass< - Microsoft::WRL::RuntimeClassFlags< Microsoft::WRL::RuntimeClassType::ClassicCom>, - IMFStreamSink, - IMFMediaEventGenerator, - IMFMediaTypeHandler, - CBaseAttributes<> > -#else public IMFStreamSink, public IMFMediaTypeHandler, public CBaseAttributes<>, public ICustomStreamSink -#endif { public: // IUnknown methods @@ -890,9 +660,6 @@ public: if (riid == IID_IMarshal) { return MarshalQI(riid, ppv); } else { -#ifdef WINRT - hr = RuntimeClassT::QueryInterface(riid, ppv); -#else if (riid == IID_IUnknown || riid == IID_IMFStreamSink) { *ppv = static_cast(this); AddRef(); @@ -910,15 +677,11 @@ public: AddRef(); } else hr = E_NOINTERFACE; -#endif } return hr; } -#ifdef WINRT - STDMETHOD(RuntimeClassInitialize)() { return S_OK; } -#else ULONG STDMETHODCALLTYPE AddRef() { return InterlockedIncrement(&m_cRef); @@ -932,7 +695,6 @@ public: } return cRef; } -#endif HRESULT MarshalQI(REFIID riid, LPVOID* ppv) { HRESULT hr = S_OK; @@ -967,11 +729,7 @@ public: m_StartTime(0), m_fGetStartTimeFromSample(false), m_fWaitingForFirstSample(false), m_state(State_TypeNotSet), m_pParent(nullptr), m_imageWidthInPixels(0), m_imageHeightInPixels(0) { -#ifdef WINRT - m_token.value = 0; -#else m_bConnected = false; -#endif InitializeCriticalSectionEx(&m_critSec, 3000, 0); ZeroMemory(&m_guiCurrentSubtype, sizeof(m_guiCurrentSubtype)); CBaseAttributes::Initialize(0U); @@ -1646,17 +1404,11 @@ public: return hr; } private: -#ifdef WINRT - EventRegistrationToken m_token; -#else bool m_bConnected; -#endif bool m_IsShutdown; // Flag to indicate if Shutdown() method was called. CRITICAL_SECTION m_critSec; -#ifndef WINRT long m_cRef; -#endif IMFAttributes* m_pParent; _ComPtr m_spCurrentType; _ComPtr m_spEventQueue; // Event queue @@ -2174,37 +1926,11 @@ protected: } }; -/* Be sure to declare webcam device capability in manifest - For better media capture support, add the following snippet with correct module name to the project manifest - (videoio needs DLL activation class factoryentry points): - - - - modulename - - - - */ - extern const __declspec(selectany) WCHAR RuntimeClass_CV_MediaSink[] = L"cv.MediaSink"; class MediaSink : -#ifdef WINRT - public Microsoft::WRL::RuntimeClass< - Microsoft::WRL::RuntimeClassFlags< Microsoft::WRL::RuntimeClassType::WinRtClassicComMix >, - Microsoft::WRL::Implements, - IMFMediaSink, - IMFClockStateSink, - Microsoft::WRL::FtmBase, - CBaseAttributes<>> -#else public IMFMediaSink, public IMFClockStateSink, public CBaseAttributes<> -#endif { -#ifdef WINRT - InspectableClass(RuntimeClass_CV_MediaSink, BaseTrust) -public: -#else public: ULONG STDMETHODCALLTYPE AddRef() { @@ -2246,7 +1972,6 @@ public: return hr; } -#endif MediaSink() : m_IsShutdown(false), m_llStartTime(0) { CBaseAttributes<>::Initialize(0U); InitializeCriticalSectionEx(&m_critSec, 3000, 0); @@ -2269,308 +1994,6 @@ public: return S_OK; } } -#ifdef WINRT - STDMETHODIMP SetProperties(ABI::Windows::Foundation::Collections::IPropertySet *pConfiguration) - { - HRESULT hr = S_OK; - if (pConfiguration) { - Microsoft::WRL::ComPtr spInsp; - Microsoft::WRL::ComPtr> spSetting; - Microsoft::WRL::ComPtr spPropVal; - Microsoft::WRL::ComPtr pMedEncProps; - UINT32 uiType = ABI::Windows::Media::Capture::MediaStreamType_VideoPreview; - - hr = pConfiguration->QueryInterface(IID_PPV_ARGS(&spSetting)); - if (FAILED(hr)) { - hr = E_FAIL; - } - - if (SUCCEEDED(hr)) { - hr = spSetting->Lookup(Microsoft::WRL::Wrappers::HStringReference(MF_PROP_SAMPLEGRABBERCALLBACK).Get(), spInsp.ReleaseAndGetAddressOf()); - if (FAILED(hr)) { - hr = E_INVALIDARG; - } - if (SUCCEEDED(hr)) { - hr = SetUnknown(MF_MEDIASINK_SAMPLEGRABBERCALLBACK, spInsp.Get()); - } - } - if (SUCCEEDED(hr)) { - hr = spSetting->Lookup(Microsoft::WRL::Wrappers::HStringReference(MF_PROP_VIDTYPE).Get(), spInsp.ReleaseAndGetAddressOf()); - if (FAILED(hr)) { - hr = E_INVALIDARG; - } - if (SUCCEEDED(hr)) { - if (SUCCEEDED(hr = spInsp.As(&spPropVal))) { - hr = spPropVal->GetUInt32(&uiType); - } - } - } - if (SUCCEEDED(hr)) { - hr = spSetting->Lookup(Microsoft::WRL::Wrappers::HStringReference(MF_PROP_VIDENCPROPS).Get(), spInsp.ReleaseAndGetAddressOf()); - if (FAILED(hr)) { - hr = E_INVALIDARG; - } - if (SUCCEEDED(hr)) { - hr = spInsp.As(&pMedEncProps); - } - } - if (SUCCEEDED(hr)) { - hr = SetMediaStreamProperties((ABI::Windows::Media::Capture::MediaStreamType)uiType, pMedEncProps.Get()); - } - } - - return hr; - } - static DWORD GetStreamId(ABI::Windows::Media::Capture::MediaStreamType mediaStreamType) - { - return 3 - mediaStreamType; - } - static HRESULT AddAttribute(_In_ GUID guidKey, _In_ ABI::Windows::Foundation::IPropertyValue *pValue, _In_ IMFAttributes* pAttr) - { - HRESULT hr = S_OK; - PROPVARIANT var; - ABI::Windows::Foundation::PropertyType type; - hr = pValue->get_Type(&type); - ZeroMemory(&var, sizeof(var)); - - if (SUCCEEDED(hr)) - { - switch (type) - { - case ABI::Windows::Foundation::PropertyType_UInt8Array: - { - UINT32 cbBlob; - BYTE *pbBlog = nullptr; - hr = pValue->GetUInt8Array(&cbBlob, &pbBlog); - if (SUCCEEDED(hr)) - { - if (pbBlog == nullptr) - { - hr = E_INVALIDARG; - } - else - { - hr = pAttr->SetBlob(guidKey, pbBlog, cbBlob); - } - } - CoTaskMemFree(pbBlog); - } - break; - - case ABI::Windows::Foundation::PropertyType_Double: - { - DOUBLE value; - hr = pValue->GetDouble(&value); - if (SUCCEEDED(hr)) - { - hr = pAttr->SetDouble(guidKey, value); - } - } - break; - - case ABI::Windows::Foundation::PropertyType_Guid: - { - GUID value; - hr = pValue->GetGuid(&value); - if (SUCCEEDED(hr)) - { - hr = pAttr->SetGUID(guidKey, value); - } - } - break; - - case ABI::Windows::Foundation::PropertyType_String: - { - Microsoft::WRL::Wrappers::HString value; - hr = pValue->GetString(value.GetAddressOf()); - if (SUCCEEDED(hr)) - { - UINT32 len = 0; - LPCWSTR szValue = WindowsGetStringRawBuffer(value.Get(), &len); - hr = pAttr->SetString(guidKey, szValue); - } - } - break; - - case ABI::Windows::Foundation::PropertyType_UInt32: - { - UINT32 value; - hr = pValue->GetUInt32(&value); - if (SUCCEEDED(hr)) - { - pAttr->SetUINT32(guidKey, value); - } - } - break; - - case ABI::Windows::Foundation::PropertyType_UInt64: - { - UINT64 value; - hr = pValue->GetUInt64(&value); - if (SUCCEEDED(hr)) - { - hr = pAttr->SetUINT64(guidKey, value); - } - } - break; - - case ABI::Windows::Foundation::PropertyType_Inspectable: - { - Microsoft::WRL::ComPtr value; - hr = TYPE_E_TYPEMISMATCH; - if (SUCCEEDED(hr)) - { - pAttr->SetUnknown(guidKey, value.Get()); - } - } - break; - - // ignore unknown values - } - } - - return hr; - } - static HRESULT ConvertPropertiesToMediaType(_In_ ABI::Windows::Media::MediaProperties::IMediaEncodingProperties *pMEP, _Outptr_ IMFMediaType **ppMT) - { - HRESULT hr = S_OK; - _ComPtr spMT; - Microsoft::WRL::ComPtr> spMap; - Microsoft::WRL::ComPtr*>> spIterable; - Microsoft::WRL::ComPtr*>> spIterator; - - if (pMEP == nullptr || ppMT == nullptr) - { - return E_INVALIDARG; - } - *ppMT = nullptr; - - hr = pMEP->get_Properties(spMap.GetAddressOf()); - - if (SUCCEEDED(hr)) - { - hr = spMap.As(&spIterable); - } - if (SUCCEEDED(hr)) - { - hr = spIterable->First(&spIterator); - } - if (SUCCEEDED(hr)) - { - MFCreateMediaType(spMT.ReleaseAndGetAddressOf()); - } - - boolean hasCurrent = false; - if (SUCCEEDED(hr)) - { - hr = spIterator->get_HasCurrent(&hasCurrent); - } - - while (hasCurrent) - { - Microsoft::WRL::ComPtr > spKeyValuePair; - Microsoft::WRL::ComPtr spValue; - Microsoft::WRL::ComPtr spPropValue; - GUID guidKey; - - hr = spIterator->get_Current(&spKeyValuePair); - if (FAILED(hr)) - { - break; - } - hr = spKeyValuePair->get_Key(&guidKey); - if (FAILED(hr)) - { - break; - } - hr = spKeyValuePair->get_Value(&spValue); - if (FAILED(hr)) - { - break; - } - hr = spValue.As(&spPropValue); - if (FAILED(hr)) - { - break; - } - hr = AddAttribute(guidKey, spPropValue.Get(), spMT.Get()); - if (FAILED(hr)) - { - break; - } - - hr = spIterator->MoveNext(&hasCurrent); - if (FAILED(hr)) - { - break; - } - } - - - if (SUCCEEDED(hr)) - { - Microsoft::WRL::ComPtr spValue; - Microsoft::WRL::ComPtr spPropValue; - GUID guiMajorType; - - hr = spMap->Lookup(MF_MT_MAJOR_TYPE, spValue.GetAddressOf()); - - if (SUCCEEDED(hr)) - { - hr = spValue.As(&spPropValue); - } - if (SUCCEEDED(hr)) - { - hr = spPropValue->GetGuid(&guiMajorType); - } - if (SUCCEEDED(hr)) - { - if (guiMajorType != MFMediaType_Video && guiMajorType != MFMediaType_Audio) - { - hr = E_UNEXPECTED; - } - } - } - - if (SUCCEEDED(hr)) - { - *ppMT = spMT.Detach(); - } - - return hr; - } - //this should be passed through SetProperties! - HRESULT SetMediaStreamProperties(ABI::Windows::Media::Capture::MediaStreamType MediaStreamType, - _In_opt_ ABI::Windows::Media::MediaProperties::IMediaEncodingProperties *mediaEncodingProperties) - { - HRESULT hr = S_OK; - _ComPtr spMediaType; - - if (MediaStreamType != ABI::Windows::Media::Capture::MediaStreamType_VideoPreview && - MediaStreamType != ABI::Windows::Media::Capture::MediaStreamType_VideoRecord && - MediaStreamType != ABI::Windows::Media::Capture::MediaStreamType_Audio) - { - return E_INVALIDARG; - } - - RemoveStreamSink(GetStreamId(MediaStreamType)); - - if (mediaEncodingProperties != nullptr) - { - _ComPtr spStreamSink; - hr = ConvertPropertiesToMediaType(mediaEncodingProperties, &spMediaType); - if (SUCCEEDED(hr)) - { - hr = AddStreamSink(GetStreamId(MediaStreamType), nullptr, spStreamSink.GetAddressOf()); - } - if (SUCCEEDED(hr)) { - hr = SetUnknown(MF_MEDIASINK_PREFERREDTYPE, spMediaType.Detach()); - } - } - - return hr; - } -#endif //IMFMediaSink HRESULT STDMETHODCALLTYPE GetCharacteristics( /* [out] */ __RPC__out DWORD *pdwCharacteristics) { @@ -2609,14 +2032,6 @@ public: if (SUCCEEDED(hr)) { -#ifdef WINRT - pStream = Microsoft::WRL::Make(); - if (pStream == nullptr) { - hr = E_OUTOFMEMORY; - } - if (SUCCEEDED(hr)) - hr = pStream.As(&spMFStream); -#else StreamSink* pSink = new StreamSink(); if (pSink) { hr = pSink->QueryInterface(IID_IMFStreamSink, (void**)spMFStream.GetAddressOf()); @@ -2625,7 +2040,6 @@ public: } if (FAILED(hr)) delete pSink; } -#endif } // Initialize the stream. @@ -2721,12 +2135,7 @@ public: { hr = m_streams.Remove(pos, nullptr); _ComPtr spCustomSink; -#ifdef WINRT - spCustomSink = static_cast(spStream.Get()); - hr = S_OK; -#else hr = spStream.As(&spCustomSink); -#endif if (SUCCEEDED(hr)) hr = spCustomSink->Shutdown(); } @@ -2945,12 +2354,8 @@ public: { _ComPtr spCustomSink; HRESULT hr; -#ifdef WINRT - spCustomSink = static_cast(pStream); -#else hr = pStream->QueryInterface(IID_PPV_ARGS(spCustomSink.GetAddressOf())); if (FAILED(hr)) return hr; -#endif hr = spCustomSink->Shutdown(); return hr; } @@ -2968,12 +2373,8 @@ public: { _ComPtr spCustomSink; HRESULT hr; -#ifdef WINRT - spCustomSink = static_cast(pStream); -#else hr = pStream->QueryInterface(IID_PPV_ARGS(spCustomSink.GetAddressOf())); if (FAILED(hr)) return hr; -#endif hr = spCustomSink->Start(_llStartTime); return hr; } @@ -2988,12 +2389,8 @@ public: { _ComPtr spCustomSink; HRESULT hr; -#ifdef WINRT - spCustomSink = static_cast(pStream); -#else hr = pStream->QueryInterface(IID_PPV_ARGS(spCustomSink.GetAddressOf())); if (FAILED(hr)) return hr; -#endif hr = spCustomSink->Stop(); return hr; } @@ -3098,16 +2495,10 @@ public: return hr; } private: -#ifndef WINRT long m_cRef; -#endif CRITICAL_SECTION m_critSec; bool m_IsShutdown; ComPtrList m_streams; _ComPtr m_spClock; LONGLONG m_llStartTime; }; - -#ifdef WINRT -ActivatableClass(MediaSink); -#endif