home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / mac / SiteBldr / AMOVIE / SDK / _SETUP / COMMON.Z / sampvid.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-21  |  6.1 KB  |  162 lines

  1. //==========================================================================;
  2. //
  3. //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. //  PURPOSE.
  7. //
  8. //  Copyright (c) 1992 - 1996  Microsoft Corporation.  All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------;
  11.  
  12. #ifndef __SAMPVID__
  13. #define __SAMPVID__
  14.  
  15. DEFINE_GUID(CLSID_SampleRenderer,
  16. 0x4d4b1600, 0x33ac, 0x11cf, 0xbf, 0x30, 0x00, 0xaa, 0x00, 0x55, 0x59, 0x5a);
  17.  
  18. DEFINE_GUID(CLSID_SampleQuality,
  19. 0xdb76d7f0, 0x97cc, 0x11cf, 0xa0, 0x96, 0x00, 0x80, 0x5f, 0x6c, 0xab, 0x82);
  20.  
  21. // Forward declarations
  22.  
  23. class CVideoRenderer;
  24. class CVideoInputPin;
  25. class CControlVideo;
  26. class CVideoText;
  27.  
  28. class CVideoText : public CBaseControlWindow, public CBaseControlVideo
  29. {
  30. protected:
  31.  
  32.     CVideoRenderer *m_pRenderer;        // Owning sample renderer object
  33.     SIZE m_Size;                        // Size of the masking bitmap
  34.  
  35. public:
  36.  
  37.     CVideoText(TCHAR *pName,                 // Object description
  38.                LPUNKNOWN pUnk,               // Normal COM ownership
  39.                HRESULT *phr,                 // OLE failure code
  40.                CCritSec *pInterfaceLock,     // Main critical section
  41.                CVideoRenderer *pRenderer);   // Delegates locking to
  42.  
  43.     virtual ~CVideoText();
  44.     STDMETHODIMP NonDelegatingQueryInterface(REFIID riid,void **ppv);
  45.  
  46.     // Pure virtual methods for the IBasicVideo interface
  47.  
  48.     HRESULT IsDefaultTargetRect();
  49.     HRESULT SetDefaultTargetRect();
  50.     HRESULT SetTargetRect(RECT *pTargetRect);
  51.     HRESULT GetTargetRect(RECT *pTargetRect);
  52.     HRESULT IsDefaultSourceRect();
  53.     HRESULT SetDefaultSourceRect();
  54.     HRESULT SetSourceRect(RECT *pSourceRect);
  55.     HRESULT GetSourceRect(RECT *pSourceRect);
  56.     HRESULT GetStaticImage(long *pBufferSize,long *pDIBImage);
  57.  
  58.     // Prepare the window with a text region
  59.  
  60.     void InitRenderer(TCHAR *pStringName);
  61.     HRESULT InitWindowRegion(TCHAR *pStringName);
  62.     HFONT CreateVideoFont();
  63.     RECT GetDefaultRect();
  64.     void GetVideoFormat(VIDEOINFO *pVideoInfo);
  65.  
  66.     // Overriden to return our window and class styles
  67.  
  68.     LPTSTR GetClassWindowStyles(DWORD *pClassStyles,
  69.                                 DWORD *pWindowStyles,
  70.                                 DWORD *pWindowStylesEx);
  71.  
  72.     // Method that gets all the window messages
  73.  
  74.     LRESULT OnReceiveMessage(HWND hwnd,          // Window handle
  75.                              UINT uMsg,          // Message ID
  76.                              WPARAM wParam,      // First parameter
  77.                              LPARAM lParam);     // Other parameter
  78. };
  79.  
  80. // This class supports the renderer input pin. We have to override the base
  81. // class input pin because we provide our own special allocator which hands
  82. // out buffers based on GDI DIBSECTIONs. We have an extra limitation which
  83. // is that we only connect to filters that agree to use our allocator. This
  84. // stops us from connecting to the tee for example. The extra work required
  85. // to use someone elses allocator and select the buffer into a bitmap and
  86. // that into the HDC is not great but would only really confuse this sample
  87.  
  88. class CVideoInputPin : public CRendererInputPin
  89. {
  90.     CVideoRenderer *m_pRenderer;        // The renderer that owns us
  91.     CCritSec *m_pInterfaceLock;         // Main filter critical section
  92.  
  93. public:
  94.  
  95.     // Constructor
  96.  
  97.     CVideoInputPin(
  98.         TCHAR *pObjectName,             // Object string description
  99.         CVideoRenderer *pRenderer,      // Used to delegate locking
  100.         CCritSec *pInterfaceLock,       // Main critical section
  101.         HRESULT *phr,                   // OLE failure return code
  102.         LPCWSTR pPinName);              // This pins identification
  103.  
  104.     // Manage our DIBSECTION video allocator
  105.     STDMETHODIMP GetAllocator(IMemAllocator **ppAllocator);
  106.     STDMETHODIMP NotifyAllocator(IMemAllocator *pAllocator,BOOL bReadOnly);
  107. };
  108.  
  109. // This is the COM object that represents a simple rendering filter. It
  110. // supports IFilter and IMediaFilter and has a single input stream (pin)
  111. // The classes that support these interfaces have nested scope NOTE the
  112. // nested class objects are passed a pointer to their owning renderer
  113. // when they are created but they should not use it during construction
  114.  
  115. class CVideoRenderer : public ISpecifyPropertyPages, public CBaseVideoRenderer
  116. {
  117. public:
  118.  
  119.     // Constructor and destructor
  120.  
  121.     static CUnknown *CreateInstance(LPUNKNOWN, HRESULT *);
  122.     CVideoRenderer(TCHAR *pName,LPUNKNOWN pUnk,HRESULT *phr);
  123.     ~CVideoRenderer();
  124.  
  125.     // Implement the ISpecifyPropertyPages interface
  126.  
  127.     DECLARE_IUNKNOWN
  128.     STDMETHODIMP NonDelegatingQueryInterface(REFIID, void **);
  129.     STDMETHODIMP GetPages(CAUUID *pPages);
  130.  
  131.     // setup helper
  132.     LPAMOVIESETUP_FILTER GetSetupData();
  133.  
  134.     CBasePin *GetPin(int n);
  135.  
  136.     // Override these from the filter and renderer classes
  137.  
  138.     HRESULT Active();
  139.     HRESULT BreakConnect();
  140.     HRESULT CompleteConnect(IPin *pReceivePin);
  141.     HRESULT SetMediaType(const CMediaType *pmt);
  142.     HRESULT CheckMediaType(const CMediaType *pmtIn);
  143.     HRESULT CheckVideoType(const VIDEOINFO *pDisplay,const VIDEOINFO *pInput);
  144.     HRESULT UpdateFormat(VIDEOINFO *pVideoInfo);
  145.     HRESULT DoRenderSample(IMediaSample *pMediaSample);
  146.     void PrepareRender();
  147.  
  148. public:
  149.  
  150.     CImageAllocator m_ImageAllocator;   // Our DIBSECTION allocator
  151.     CVideoInputPin m_InputPin;          // IPin based interfaces
  152.     CImageDisplay m_Display;            // Manages the video display type
  153.     CMediaType m_mtIn;                  // Source connection media type
  154.     CVideoText m_VideoText;             // Does the actual video rendering
  155.     CImagePalette m_ImagePalette;       // Looks after managing a palette
  156.     CDrawImage m_DrawImage;             // Does the actual image drawing
  157.     SIZE m_VideoSize;                   // Size of the current video stream
  158. };
  159.  
  160. #endif // __SAMPVID__
  161.  
  162.