123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488 |
- //------------------------------------------------------------------------------
- // File: PushSource.H
- //
- // Desc: DirectShow sample code - In-memory push mode source filter
- //
- // Copyright (c) Microsoft Corporation. All rights reserved.
- //------------------------------------------------------------------------------
- #ifndef PLUGIN_DSHOW_DSPUSHSOURCE_H
- #define PLUGIN_DSHOW_DSPUSHSOURCE_H
- #include "plugin_dshow_config.h"
- #include <strsafe.h>
- // UNITS = 10 ^ 7
- // UNITS / 30 = 30 fps;
- // UNITS / 20 = 20 fps, etc
- const REFERENCE_TIME FPS_30 = UNITS / 30;
- const REFERENCE_TIME FPS_20 = UNITS / 20;
- const REFERENCE_TIME FPS_10 = UNITS / 10;
- const REFERENCE_TIME FPS_5 = UNITS / 5;
- const REFERENCE_TIME FPS_4 = UNITS / 4;
- const REFERENCE_TIME FPS_3 = UNITS / 3;
- const REFERENCE_TIME FPS_2 = UNITS / 2;
- const REFERENCE_TIME FPS_1 = UNITS / 1;
- const REFERENCE_TIME rtDefaultFrameLength = FPS_10;
- // Filter name strings
- #define g_wszPushBitmap L"PushSource Bitmap Filter"
- #define g_wszPushBitmapSet L"PushSource BitmapSet Filter"
- #define g_wszPushDesktop L"PushSource Desktop Filter"
- // Number of bitmap files to load in the CPushPinBitmapSet class
- #define NUM_FILES 5
- // {3FD3081A-A8C9-4958-9F75-07EC89690024}
- TDSHOW_DEFINE_GUID(CLSID_PushSourceDesktop,
- 0x3fd3081a, 0xa8c9, 0x4958, 0x9f, 0x75, 0x7, 0xec, 0x89, 0x69, 0x0, 0x24);
- /**********************************************
- *
- * Class declarations
- *
- **********************************************/
- class CPushPinBitmap : public CSourceStream
- {
- protected:
- int m_FramesWritten; // To track where we are in the file
- BOOL m_bZeroMemory; // Do we need to clear the buffer?
- CRefTime m_rtSampleTime; // The time stamp for each sample
- BITMAPINFO *m_pBmi; // Pointer to the bitmap header
- DWORD m_cbBitmapInfo; // Size of the bitmap header
- // File opening variables
- HANDLE m_hFile; // Handle returned from CreateFile
- BYTE * m_pFile; // Points to beginning of file buffer
- BYTE * m_pImage; // Points to pixel bits
- int m_iFrameNumber;
- const REFERENCE_TIME m_rtFrameLength;
- CCritSec m_cSharedState; // Protects our internal state
- CImageDisplay m_Display; // Figures out our media type for us
- public:
- CPushPinBitmap(HRESULT *phr, CSource *pFilter);
- ~CPushPinBitmap();
- // Override the version that offers exactly one media type
- HRESULT GetMediaType(CMediaType *pMediaType);
- HRESULT DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pRequest);
- HRESULT FillBuffer(IMediaSample *pSample);
- // Quality control
- // Not implemented because we aren't going in real time.
- // If the file-writing filter slows the graph down, we just do nothing, which means
- // wait until we're unblocked. No frames are ever dropped.
- STDMETHODIMP Notify(IBaseFilter *pSelf, Quality q) {
- return E_FAIL;
- }
- };
- class CPushPinBitmapSet : public CSourceStream
- {
- protected:
- int m_FramesWritten; // To track where we are in the file
- BOOL m_bZeroMemory; // Do we need to clear the buffer?
- CRefTime m_rtSampleTime; // The time stamp for each sample
- BITMAPINFO *m_pBmi[NUM_FILES]; // Pointer to the bitmap headers
- DWORD m_cbBitmapInfo[NUM_FILES]; // Size of the bitmap headers
- // File opening variables
- HANDLE m_hFile[NUM_FILES]; // Handles returned from CreateFile
- BYTE * m_pFile[NUM_FILES]; // Points to beginning of file buffers
- BYTE * m_pImage[NUM_FILES]; // Points to pixel bits
- BOOL m_bFilesLoaded;
- int m_iCurrentBitmap; // Which bitmap is being displayed
- int m_iFrameNumber; // How many frames have been displayed
- const REFERENCE_TIME m_rtFrameLength; // Duration of one frame
- CCritSec m_cSharedState; // Protects our internal state
- CImageDisplay m_Display; // Figures out our media type for us
- public:
- CPushPinBitmapSet(HRESULT *phr, CSource *pFilter);
- ~CPushPinBitmapSet();
- // Override the version that offers exactly one media type
- HRESULT GetMediaType(CMediaType *pMediaType);
- HRESULT DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pRequest);
- HRESULT FillBuffer(IMediaSample *pSample);
- // Quality control
- // Not implemented because we aren't going in real time.
- // If the file-writing filter slows the graph down, we just do nothing, which means
- // wait until we're unblocked. No frames are ever dropped.
- STDMETHODIMP Notify(IBaseFilter *pSelf, Quality q) {
- return E_FAIL;
- }
- };
- class CPushPinDesktop : public CSourceStream
- {
- protected:
- int m_FramesWritten; // To track where we are in the file
- BOOL m_bZeroMemory; // Do we need to clear the buffer?
- CRefTime m_rtSampleTime; // The time stamp for each sample
- int m_iFrameNumber;
- const REFERENCE_TIME m_rtFrameLength;
- RECT m_rScreen; // Rect containing entire screen coordinates
- int m_iImageHeight; // The current image height
- int m_iImageWidth; // And current image width
- int m_iRepeatTime; // Time in msec between frames
- int m_nCurrentBitDepth; // Screen bit depth
- CMediaType m_MediaType;
- CCritSec m_cSharedState; // Protects our internal state
- CImageDisplay m_Display; // Figures out our media type for us
- HWND m_hSrcHwnd; // Handle to the window to grab
- public:
- CPushPinDesktop(HRESULT *phr, CSource *pFilter);
- ~CPushPinDesktop();
- // Override the version that offers exactly one media type
- HRESULT DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pRequest);
- HRESULT FillBuffer(IMediaSample *pSample);
- // Set the agreed media type and set up the necessary parameters
- HRESULT SetMediaType(const CMediaType *pMediaType);
- // Support multiple display formats
- HRESULT CheckMediaType(const CMediaType *pMediaType);
- HRESULT GetMediaType(int iPosition, CMediaType *pmt);
- // Quality control
- // Not implemented because we aren't going in real time.
- // If the file-writing filter slows the graph down, we just do nothing, which means
- // wait until we're unblocked. No frames are ever dropped.
- STDMETHODIMP Notify(IBaseFilter *pSelf, Quality q) {
- return E_FAIL;
- }
- HRESULT SetSrcHwnd(HWND hWnd) {
- m_hSrcHwnd = hWnd;
- return S_OK;
- }
- };
- class CPushSourceBitmap : public CSource
- {
- private:
- // Constructor is private because you have to use CreateInstance
- CPushSourceBitmap(IUnknown *pUnk, HRESULT *phr);
- ~CPushSourceBitmap();
- CPushPinBitmap *m_pPin;
- public:
- static CUnknown * WINAPI CreateInstance(IUnknown *pUnk, HRESULT *phr);
- };
- class CPushSourceBitmapSet : public CSource
- {
- private:
- // Constructor is private because you have to use CreateInstance
- CPushSourceBitmapSet(IUnknown *pUnk, HRESULT *phr);
- ~CPushSourceBitmapSet();
- CPushPinBitmapSet *m_pPin;
- public:
- static CUnknown * WINAPI CreateInstance(IUnknown *pUnk, HRESULT *phr);
- };
- class CPushSourceDesktop : public CSource
- {
- private:
- // Constructor is private because you have to use CreateInstance
- CPushSourceDesktop(IUnknown *pUnk, HRESULT *phr);
- ~CPushSourceDesktop();
- CPushPinDesktop *m_pPin;
- public:
- static CUnknown * WINAPI CreateInstance(IUnknown *pUnk, HRESULT *phr);
- DECLARE_IUNKNOWN;
- HRESULT SetSrcHwnd(HWND hWnd);
- };
- #endif /* PLUGIN_DSHOW_DSPUSHSOURCE_H */
- //------------------------------------------------------------------------------
- // File: PushSource.H
- //
- // Desc: DirectShow sample code - In-memory push mode source filter
- //
- // Copyright (c) Microsoft Corporation. All rights reserved.
- //------------------------------------------------------------------------------
- #ifndef PLUGIN_DSHOW_DSPUSHSOURCE_H
- #define PLUGIN_DSHOW_DSPUSHSOURCE_H
- #include "plugin_dshow_config.h"
- #include <strsafe.h>
- // UNITS = 10 ^ 7
- // UNITS / 30 = 30 fps;
- // UNITS / 20 = 20 fps, etc
- const REFERENCE_TIME FPS_30 = UNITS / 30;
- const REFERENCE_TIME FPS_20 = UNITS / 20;
- const REFERENCE_TIME FPS_10 = UNITS / 10;
- const REFERENCE_TIME FPS_5 = UNITS / 5;
- const REFERENCE_TIME FPS_4 = UNITS / 4;
- const REFERENCE_TIME FPS_3 = UNITS / 3;
- const REFERENCE_TIME FPS_2 = UNITS / 2;
- const REFERENCE_TIME FPS_1 = UNITS / 1;
- const REFERENCE_TIME rtDefaultFrameLength = FPS_10;
- // Filter name strings
- #define g_wszPushBitmap L"PushSource Bitmap Filter"
- #define g_wszPushBitmapSet L"PushSource BitmapSet Filter"
- #define g_wszPushDesktop L"PushSource Desktop Filter"
- // Number of bitmap files to load in the CPushPinBitmapSet class
- #define NUM_FILES 5
- // {3FD3081A-A8C9-4958-9F75-07EC89690024}
- TDSHOW_DEFINE_GUID(CLSID_PushSourceDesktop,
- 0x3fd3081a, 0xa8c9, 0x4958, 0x9f, 0x75, 0x7, 0xec, 0x89, 0x69, 0x0, 0x24);
- /**********************************************
- *
- * Class declarations
- *
- **********************************************/
- class CPushPinBitmap : public CSourceStream
- {
- protected:
- int m_FramesWritten; // To track where we are in the file
- BOOL m_bZeroMemory; // Do we need to clear the buffer?
- CRefTime m_rtSampleTime; // The time stamp for each sample
- BITMAPINFO *m_pBmi; // Pointer to the bitmap header
- DWORD m_cbBitmapInfo; // Size of the bitmap header
- // File opening variables
- HANDLE m_hFile; // Handle returned from CreateFile
- BYTE * m_pFile; // Points to beginning of file buffer
- BYTE * m_pImage; // Points to pixel bits
- int m_iFrameNumber;
- const REFERENCE_TIME m_rtFrameLength;
- CCritSec m_cSharedState; // Protects our internal state
- CImageDisplay m_Display; // Figures out our media type for us
- public:
- CPushPinBitmap(HRESULT *phr, CSource *pFilter);
- ~CPushPinBitmap();
- // Override the version that offers exactly one media type
- HRESULT GetMediaType(CMediaType *pMediaType);
- HRESULT DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pRequest);
- HRESULT FillBuffer(IMediaSample *pSample);
- // Quality control
- // Not implemented because we aren't going in real time.
- // If the file-writing filter slows the graph down, we just do nothing, which means
- // wait until we're unblocked. No frames are ever dropped.
- STDMETHODIMP Notify(IBaseFilter *pSelf, Quality q) {
- return E_FAIL;
- }
- };
- class CPushPinBitmapSet : public CSourceStream
- {
- protected:
- int m_FramesWritten; // To track where we are in the file
- BOOL m_bZeroMemory; // Do we need to clear the buffer?
- CRefTime m_rtSampleTime; // The time stamp for each sample
- BITMAPINFO *m_pBmi[NUM_FILES]; // Pointer to the bitmap headers
- DWORD m_cbBitmapInfo[NUM_FILES]; // Size of the bitmap headers
- // File opening variables
- HANDLE m_hFile[NUM_FILES]; // Handles returned from CreateFile
- BYTE * m_pFile[NUM_FILES]; // Points to beginning of file buffers
- BYTE * m_pImage[NUM_FILES]; // Points to pixel bits
- BOOL m_bFilesLoaded;
- int m_iCurrentBitmap; // Which bitmap is being displayed
- int m_iFrameNumber; // How many frames have been displayed
- const REFERENCE_TIME m_rtFrameLength; // Duration of one frame
- CCritSec m_cSharedState; // Protects our internal state
- CImageDisplay m_Display; // Figures out our media type for us
- public:
- CPushPinBitmapSet(HRESULT *phr, CSource *pFilter);
- ~CPushPinBitmapSet();
- // Override the version that offers exactly one media type
- HRESULT GetMediaType(CMediaType *pMediaType);
- HRESULT DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pRequest);
- HRESULT FillBuffer(IMediaSample *pSample);
- // Quality control
- // Not implemented because we aren't going in real time.
- // If the file-writing filter slows the graph down, we just do nothing, which means
- // wait until we're unblocked. No frames are ever dropped.
- STDMETHODIMP Notify(IBaseFilter *pSelf, Quality q) {
- return E_FAIL;
- }
- };
- class CPushPinDesktop : public CSourceStream
- {
- protected:
- int m_FramesWritten; // To track where we are in the file
- BOOL m_bZeroMemory; // Do we need to clear the buffer?
- CRefTime m_rtSampleTime; // The time stamp for each sample
- int m_iFrameNumber;
- const REFERENCE_TIME m_rtFrameLength;
- RECT m_rScreen; // Rect containing entire screen coordinates
- int m_iImageHeight; // The current image height
- int m_iImageWidth; // And current image width
- int m_iRepeatTime; // Time in msec between frames
- int m_nCurrentBitDepth; // Screen bit depth
- CMediaType m_MediaType;
- CCritSec m_cSharedState; // Protects our internal state
- CImageDisplay m_Display; // Figures out our media type for us
- HWND m_hSrcHwnd; // Handle to the window to grab
- public:
- CPushPinDesktop(HRESULT *phr, CSource *pFilter);
- ~CPushPinDesktop();
- // Override the version that offers exactly one media type
- HRESULT DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pRequest);
- HRESULT FillBuffer(IMediaSample *pSample);
- // Set the agreed media type and set up the necessary parameters
- HRESULT SetMediaType(const CMediaType *pMediaType);
- // Support multiple display formats
- HRESULT CheckMediaType(const CMediaType *pMediaType);
- HRESULT GetMediaType(int iPosition, CMediaType *pmt);
- // Quality control
- // Not implemented because we aren't going in real time.
- // If the file-writing filter slows the graph down, we just do nothing, which means
- // wait until we're unblocked. No frames are ever dropped.
- STDMETHODIMP Notify(IBaseFilter *pSelf, Quality q) {
- return E_FAIL;
- }
- HRESULT SetSrcHwnd(HWND hWnd) {
- m_hSrcHwnd = hWnd;
- return S_OK;
- }
- };
- class CPushSourceBitmap : public CSource
- {
- private:
- // Constructor is private because you have to use CreateInstance
- CPushSourceBitmap(IUnknown *pUnk, HRESULT *phr);
- ~CPushSourceBitmap();
- CPushPinBitmap *m_pPin;
- public:
- static CUnknown * WINAPI CreateInstance(IUnknown *pUnk, HRESULT *phr);
- };
- class CPushSourceBitmapSet : public CSource
- {
- private:
- // Constructor is private because you have to use CreateInstance
- CPushSourceBitmapSet(IUnknown *pUnk, HRESULT *phr);
- ~CPushSourceBitmapSet();
- CPushPinBitmapSet *m_pPin;
- public:
- static CUnknown * WINAPI CreateInstance(IUnknown *pUnk, HRESULT *phr);
- };
- class CPushSourceDesktop : public CSource
- {
- private:
- // Constructor is private because you have to use CreateInstance
- CPushSourceDesktop(IUnknown *pUnk, HRESULT *phr);
- ~CPushSourceDesktop();
- CPushPinDesktop *m_pPin;
- public:
- static CUnknown * WINAPI CreateInstance(IUnknown *pUnk, HRESULT *phr);
- DECLARE_IUNKNOWN;
- HRESULT SetSrcHwnd(HWND hWnd);
- };
- #endif /* PLUGIN_DSHOW_DSPUSHSOURCE_H */
|