home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / mac / SiteBldr / AMOVIE / SDK / _SETUP / COMMON.Z / fball.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-23  |  3.7 KB  |  116 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. // Bouncing Ball Source filter...
  13. //
  14.  
  15. // Uses CSource & CSourceStream to generate a movie on the fly of a
  16. // bouncing ball...
  17.  
  18. class CBallStream; // The class managing the output pin.
  19.  
  20. //
  21. // CBouncingBall
  22. //
  23. // CBouncingBall manages filter level stuff
  24. class CBouncingBall : public ISpecifyPropertyPages,
  25.               public CSource {
  26.  
  27. public:
  28.  
  29.     // The only allowed way to create Bouncing ball's!
  30.     static CUnknown *CreateInstance(LPUNKNOWN lpunk, HRESULT *phr);
  31.     ~CBouncingBall();
  32.  
  33.     DECLARE_IUNKNOWN;
  34.  
  35.     // override this to reveal our property interface
  36.     STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void ** ppv);
  37.  
  38.     // --- ISpecifyPropertyPages ---
  39.  
  40.     // return our property pages
  41.     STDMETHODIMP GetPages(CAUUID * pPages);
  42.  
  43.     // setup helper
  44.     LPAMOVIESETUP_FILTER GetSetupData();
  45.  
  46. private:
  47.  
  48.     // it is only allowed to to create these objects with CreateInstance
  49.     CBouncingBall(LPUNKNOWN lpunk, HRESULT *phr);
  50.  
  51. };
  52.  
  53.  
  54. //
  55. // CBallStream
  56. //
  57. // CBallStream manages the data flow from the output pin.
  58. class CBallStream : public CSourceStream {
  59.  
  60. public:
  61.  
  62.     CBallStream(HRESULT *phr, CBouncingBall *pParent, LPCWSTR pPinName);
  63.     ~CBallStream();
  64.  
  65.     // plots a ball into the supplied video frame.
  66.     HRESULT FillBuffer(IMediaSample *pms);
  67.  
  68.     // Ask for buffers of the size appropriate to the agreed media type.
  69.     HRESULT DecideBufferSize(IMemAllocator *pIMemAlloc,
  70.                              ALLOCATOR_PROPERTIES *pProperties);
  71.  
  72.     // Set the agreed media type, and set up the necessary ball
  73.     // parameters that depend on the media type, ie BallPixel[], iPixelSize, etc.
  74.     HRESULT SetMediaType(const CMediaType *pMediaType);
  75.  
  76.     // because we calculate the ball there is no reason why we can't calculate it in
  77.     // any one of a set of formats...
  78.     HRESULT CheckMediaType(const CMediaType *pMediaType);
  79.     HRESULT GetMediaType(int iPosition, CMediaType *pmt);
  80.  
  81.     // resets the stream time to zero.
  82.     HRESULT OnThreadCreate(void);
  83.  
  84.     // Quality control notifications sent to us
  85.     STDMETHODIMP Notify(IFilter * pSender, Quality q);
  86.  
  87. private:
  88.  
  89.     // Access to this state information should be serialized with the filters
  90.     // critical section (m_pFilter->pStateLock())
  91.  
  92.     int m_iImageHeight;    // the current image dimentions
  93.     int m_iImageWidth;    //
  94.     int m_iRepeatTime;  // Time in msec between frames
  95.     const int m_iDefaultRepeatTime; // Initial m_iRepeatTime
  96.  
  97.     enum Colour {Red, Blue, Green, Yellow};
  98.     HRESULT SetPaletteEntries(Colour colour);    // set up the palette appropriately
  99.  
  100.     BYTE    m_BallPixel[4];    // The byte array that represents one ball coloured pixel in the frame
  101.     int        m_iPixelSize;    // The pixel size in bytes - the number of valid entries in m_BallPixel
  102.     PALETTEENTRY    m_Palette[iPALETTE_COLORS];    // The optimal palette for the image.
  103.  
  104.  
  105.     CCritSec    m_cSharedState;    // use this to lock access to m_rtSampleTime and m_Ball which are
  106.                     // shared with the worker thread.
  107.  
  108.  
  109.     BOOL m_bZeroMemory;             // do we need to clear the output buffer
  110.  
  111.     CRefTime     m_rtSampleTime;    // The time to be stamped on each sample
  112.     CBall    *m_Ball;    // the current ball.
  113. };
  114.     
  115.  
  116.