summaryrefslogtreecommitdiff
path: root/ARMFCaptureD3D/preview.h
diff options
context:
space:
mode:
authorfcolin2011-11-18 12:14:12 +0000
committerfcolin2011-11-18 12:14:12 +0000
commit6bcf419d2e8f739b432d4790d1ba9d48ab65365b (patch)
tree92815e16f189c8e328dff4fcfa38ebe1d0217fdd /ARMFCaptureD3D/preview.h
parent487e963b081d7ffe2ddf489e11d927982c9101a6 (diff)
downloadamilis-master.zip
amilis-master.tar.gz
amilis-master.tar.bz2
amilis-master.tar.xz
Diffstat (limited to 'ARMFCaptureD3D/preview.h')
-rw-r--r--ARMFCaptureD3D/preview.h97
1 files changed, 97 insertions, 0 deletions
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 <cstdio>
+
+
+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