From 6bcf419d2e8f739b432d4790d1ba9d48ab65365b Mon Sep 17 00:00:00 2001 From: fcolin Date: Fri, 18 Nov 2011 12:14:12 +0000 Subject: --- ARMFCaptureD3D/preview.h | 97 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 ARMFCaptureD3D/preview.h (limited to 'ARMFCaptureD3D/preview.h') diff --git a/ARMFCaptureD3D/preview.h b/ARMFCaptureD3D/preview.h new file mode 100644 index 0000000..968f1a9 --- /dev/null +++ b/ARMFCaptureD3D/preview.h @@ -0,0 +1,97 @@ +////////////////////////////////////////////////////////////////////////// +// +// preview.h: Manages video preview. +// +// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO +// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A +// PARTICULAR PURPOSE. +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +////////////////////////////////////////////////////////////////////////// + +#pragma once +#include + + +const UINT WM_APP_PREVIEW_ERROR = WM_APP + 1; // wparam = HRESULT + + +class CPreview : public IMFSourceReaderCallback +{ +public: + static HRESULT CreateInstance( + HWND hVideo, + HWND hEvent, + CPreview **ppPlayer + ); + + // IUnknown methods + STDMETHODIMP QueryInterface(REFIID iid, void** ppv); + STDMETHODIMP_(ULONG) AddRef(); + STDMETHODIMP_(ULONG) Release(); + + // IMFSourceReaderCallback methods + STDMETHODIMP OnReadSample( + HRESULT hrStatus, + DWORD dwStreamIndex, + DWORD dwStreamFlags, + LONGLONG llTimestamp, + IMFSample *pSample + ); + + STDMETHODIMP OnEvent(DWORD, IMFMediaEvent *) + { + return S_OK; + } + + STDMETHODIMP OnFlush(DWORD) + { + return S_OK; + } + + HRESULT SetDevice(IMFActivate *pActivate, int formatType); + HRESULT CloseDevice(); + HRESULT ResizeVideo(WORD width, WORD height); + HRESULT CheckDeviceLost(DEV_BROADCAST_HDR *pHdr, BOOL *pbDeviceLost); + HRESULT EnumerateCaptureFormats(IMFMediaType ***pppTypes, UINT32 *pcCount); + HRESULT SetFormat(IMFMediaType *pActivate); + + bool ToggleVideo(); + bool ToggleTransform(); + bool ToggleMoyen(); + + +protected: + + bool m_video; + bool m_transform; + bool m_moyen; + + // Constructor is private. Use static CreateInstance method to create. + CPreview(HWND hVideo, HWND hEvent); + + // Destructor is private. Caller should call Release. + virtual ~CPreview(); + + HRESULT Initialize(); + void NotifyError(HRESULT hr) { PostMessage(m_hwndEvent, WM_APP_PREVIEW_ERROR, (WPARAM)hr, 0L); } + HRESULT TryMediaType(IMFMediaType *pType); + + long m_nRefCount; // Reference count. + CRITICAL_SECTION m_critsec; + + HWND m_hwndVideo; // Video window. + HWND m_hwndEvent; // Application window to receive events. + + IMFSourceReader *m_pReader; + IMFMediaSource *m_pSource; + + DrawDevice m_draw; // Manages the Direct3D device. + + WCHAR *m_pwszSymbolicLink; + UINT32 m_cchSymbolicLink; + + +}; \ No newline at end of file -- cgit v1.1