⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winutil.h

📁 mediastreamer2是开源的网络传输媒体流的库
💻 H
📖 第 1 页 / 共 2 页
字号:
    void NotifyAllocator(BOOL bUsingImageAllocator);    void NotifyMediaType(CMediaType *pMediaType);    BOOL UsingImageAllocator();    // Called when we are about to draw an image    void NotifyStartDraw() {        MSR_START(m_perfidRenderTime);    };    // Called when we complete an image rendering    void NotifyEndDraw() {        MSR_STOP(m_perfidRenderTime);    };};// This is the structure used to keep information about each GDI DIB. All the// samples we create from our allocator will have a DIBSECTION allocated to// them. When we receive the sample we know we can BitBlt straight to an HDCtypedef struct tagDIBDATA {    LONG        PaletteVersion;     // Current palette version in use    DIBSECTION  DibSection;         // Details of DIB section allocated    HBITMAP     hBitmap;            // Handle to bitmap for drawing    HANDLE      hMapping;           // Handle to shared memory block    BYTE        *pBase;             // Pointer to base memory address} DIBDATA;// This class inherits from CMediaSample and uses all of it's methods but it// overrides the constructor to initialise itself with the DIBDATA structure// When we come to render an IMediaSample we will know if we are using our own// allocator, and if we are, we can cast the IMediaSample to a pointer to one// of these are retrieve the DIB section information and hence the HBITMAPclass CImageSample : public CMediaSample{protected:    DIBDATA m_DibData;      // Information about the DIBSECTION    BOOL m_bInit;           // Is the DIB information setuppublic:    // Constructor    CImageSample(CBaseAllocator *pAllocator,                 TCHAR *pName,                 HRESULT *phr,                 LPBYTE pBuffer,                 LONG length);    // Maintain the DIB/DirectDraw state    void SetDIBData(DIBDATA *pDibData);    DIBDATA *GetDIBData();};// This is an allocator based on the abstract CBaseAllocator base class that// allocates sample buffers in shared memory. The number and size of these// are determined when the output pin calls Prepare on us. The shared memory// blocks are used in subsequent calls to GDI CreateDIBSection, once that// has been done the output pin can fill the buffers with data which will// then be handed to GDI through BitBlt calls and thereby remove one copyclass CImageAllocator : public CBaseAllocator{protected:    CBaseFilter *m_pFilter;   // Delegate reference counts to    CMediaType *m_pMediaType;           // Pointer to the current format    // Used to create and delete samples    HRESULT Alloc();    void Free();    // Manage the shared DIBSECTION and DCI/DirectDraw buffers    HRESULT CreateDIB(LONG InSize,DIBDATA &DibData);    STDMETHODIMP CheckSizes(ALLOCATOR_PROPERTIES *pRequest);    virtual CImageSample *CreateImageSample(LPBYTE pData,LONG Length);public:    // Constructor and destructor    CImageAllocator(CBaseFilter *pFilter,TCHAR *pName,HRESULT *phr);#ifdef DEBUG    ~CImageAllocator();#endif    STDMETHODIMP_(ULONG) NonDelegatingAddRef();    STDMETHODIMP_(ULONG) NonDelegatingRelease();    void NotifyMediaType(CMediaType *pMediaType);    // Agree the number of buffers to be used and their size    STDMETHODIMP SetProperties(        ALLOCATOR_PROPERTIES *pRequest,        ALLOCATOR_PROPERTIES *pActual);};// This class is a fairly specialised helper class for image renderers that// have to create and manage palettes. The CBaseWindow class looks after// realising palettes once they have been installed. This class can be used// to create the palette handles from a media format (which must contain a// VIDEOINFO structure in the format block). We try to make the palette an// identity palette to maximise performance and also only change palettes// if actually required to (we compare palette colours before updating).// All the methods are virtual so that they can be overriden if so requiredclass CImagePalette{protected:    CBaseWindow *m_pBaseWindow;             // Window to realise palette in    CBaseFilter *m_pFilter;                 // Media filter to send events    CDrawImage *m_pDrawImage;               // Object who will be drawing    HPALETTE m_hPalette;                    // The palette handle we ownpublic:    CImagePalette(CBaseFilter *pBaseFilter,                  CBaseWindow *pBaseWindow,                  CDrawImage *pDrawImage);#ifdef DEBUG    virtual ~CImagePalette();#endif    static HPALETTE MakePalette(const VIDEOINFOHEADER *pVideoInfo, LPSTR szDevice);    HRESULT RemovePalette();    static HRESULT MakeIdentityPalette(PALETTEENTRY *pEntry,INT iColours, LPSTR szDevice);    HRESULT CopyPalette(const CMediaType *pSrc,CMediaType *pDest);    BOOL ShouldUpdate(const VIDEOINFOHEADER *pNewInfo,const VIDEOINFOHEADER *pOldInfo);    HRESULT PreparePalette(const CMediaType *pmtNew,const CMediaType *pmtOld,LPSTR szDevice);    BOOL DrawVideoImageHere(HDC hdc, IMediaSample *pMediaSample, LPRECT lprcSrc, LPRECT lprcDst)    {        return m_pDrawImage->DrawVideoImageHere(hdc, pMediaSample, lprcSrc,lprcDst);    }};// Another helper class really for video based renderers. Most such renderers// need to know what the display format is to some degree or another. This// class initialises itself with the display format. The format can be asked// for through GetDisplayFormat and various other accessor functions. If a// filter detects a display format change (perhaps it gets a WM_DEVMODECHANGE// message then it can call RefreshDisplayType to reset that format). Also// many video renderers will want to check formats as they are proposed by// source filters. This class provides methods to check formats and only// accept those video formats that can be efficiently drawn using GDI callsclass CImageDisplay : public CCritSec{protected:    // This holds the display format; biSize should not be too big, so we can    // safely use the VIDEOINFO structure    VIDEOINFO m_Display;    static DWORD CountSetBits(const DWORD Field);    static DWORD CountPrefixBits(const DWORD Field);    static BOOL CheckBitFields(const VIDEOINFO *pInput);public:    // Constructor and destructor    CImageDisplay();    // Used to manage BITMAPINFOHEADERs and the display format    const VIDEOINFO *GetDisplayFormat();    HRESULT RefreshDisplayType(LPSTR szDeviceName);    static BOOL CheckHeaderValidity(const VIDEOINFO *pInput);    static BOOL CheckPaletteHeader(const VIDEOINFO *pInput);    BOOL IsPalettised();    WORD GetDisplayDepth();    // Provide simple video format type checking    HRESULT CheckMediaType(const CMediaType *pmtIn);    HRESULT CheckVideoType(const VIDEOINFO *pInput);    HRESULT UpdateFormat(VIDEOINFO *pVideoInfo);    const DWORD *GetBitMasks(const VIDEOINFO *pVideoInfo);    BOOL GetColourMask(DWORD *pMaskRed,                       DWORD *pMaskGreen,                       DWORD *pMaskBlue);};//  Convert a FORMAT_VideoInfo to FORMAT_VideoInfo2STDAPI ConvertVideoInfoToVideoInfo2(AM_MEDIA_TYPE *pmt);#endif // __WINUTIL__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -