home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / mac / SiteBldr / AMOVIE / SDK / _SETUP / COMMON.Z / inftee.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-17  |  6.4 KB  |  196 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 __TEE__
  13. #define __TEE__
  14.  
  15. // define a GUID for tee objects.
  16.  
  17. // {022B8142-0946-11cf-BCB1-444553540000}
  18. DEFINE_GUID (CLSID_Tee,
  19. 0x22b8142, 0x946, 0x11cf, 0xbc, 0xb1, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0);
  20.  
  21. //----------------------------------------------------------------------------
  22. // forward reference to classes defined later
  23. //----------------------------------------------------------------------------
  24.  
  25. class CTee ;
  26. class CTeeOutputPin ;
  27.  
  28. //----------------------------------------------------------------------------
  29. // CTeeInputPin. class for the Tee filter's Input pin.
  30. //----------------------------------------------------------------------------
  31. class CTeeInputPin : public CBaseInputPin
  32. {
  33.     friend class CTeeOutputPin ;
  34. public:
  35.  
  36.     // constructor and destructor
  37.     CTeeInputPin (TCHAR *pObjName, CTee *pTee, HRESULT *phr, LPCWSTR pPinName) ;
  38.     ~CTeeInputPin () ;
  39.  
  40.     // Used to check the input pin connection
  41.     HRESULT CheckMediaType (const CMediaType *pmt) ;
  42.     HRESULT SetMediaType (const CMediaType *pmt) ;
  43.     HRESULT BreakConnect () ;
  44.  
  45.     // reconnect outputs if necessary at end of completion
  46.     virtual HRESULT CompleteConnect(IPin *pReceivePin);
  47.  
  48.     STDMETHODIMP NotifyAllocator (IMemAllocator *pAllocator, BOOL bReadOnly);
  49.  
  50.     // pass throughs
  51.     STDMETHODIMP EndOfStream () ;
  52.     STDMETHODIMP BeginFlush () ;
  53.     STDMETHODIMP EndFlush () ;
  54.  
  55.     // handles the next block of data from the stream
  56.     STDMETHODIMP Receive (IMediaSample *pSample) ;
  57.  
  58.     // Persistent pin stuff
  59.     STDMETHODIMP QueryId(LPWSTR * Id)
  60.     {
  61.         *Id = (LPWSTR)CoTaskMemAlloc(8);
  62.         if (*Id==NULL) {
  63.            return E_OUTOFMEMORY;
  64.         }
  65.         lstrcpyW(*Id, L"0");
  66.         return NOERROR;
  67.     }
  68.  
  69. private:
  70.     CTee *m_pTee ;                  // ptr to the owner filter class
  71.     BOOL m_bInsideCheckMediaType ;  // re-entrancy control
  72. } ;
  73.  
  74.  
  75. //----------------------------------------------------------------------------
  76. // CTeeOutputPin. class for the Tee filter's Output pins.
  77. //----------------------------------------------------------------------------
  78. class CTeeOutputPin : public CBaseOutputPin
  79. {
  80.     friend class CTeeInputPin ;
  81.     friend class CTee ;
  82.  
  83. public:
  84.  
  85.     // constructor and destructor
  86.     CTeeOutputPin (TCHAR *pObjName, CTee *pTee, HRESULT *phr, LPCWSTR pPinName,
  87.                     INT PinNumber) ;
  88.     ~CTeeOutputPin () ;
  89.  
  90.     // Override to expose IMediaPosition
  91.     STDMETHODIMP NonDelegatingQueryInterface (REFIID riid, void **ppvoid) ;
  92.  
  93.     // Override since the life time of pins and filters are not the same.
  94.     STDMETHODIMP_(ULONG) NonDelegatingAddRef();
  95.     STDMETHODIMP_(ULONG) NonDelegatingRelease();
  96.  
  97.     // Override to enumerate media types.
  98.     STDMETHODIMP EnumMediaTypes (IEnumMediaTypes **ppEnum) ;
  99.  
  100.     // Check that we can support an output type
  101.     HRESULT CheckMediaType (const CMediaType *pmt) ;
  102.     HRESULT SetMediaType (const CMediaType *pmt) ;
  103.  
  104.     // Negotiation to use our input pins allocator
  105.     HRESULT DecideAllocator (IMemInputPin *pPin, IMemAllocator **ppAlloc) ;
  106.     HRESULT DecideBufferSize (IMemAllocator *pMemAllocator,
  107.                               ALLOCATOR_PROPERTIES * ppropInputRequest);
  108.  
  109.     // Used to create output queue objects
  110.     HRESULT Active () ;
  111.     HRESULT Inactive () ;
  112.  
  113.     // overriden to create and destroy output pins
  114.     HRESULT CompleteConnect(IPin *pReceivePin);
  115.  
  116.     // overriden to pass data to the output queues
  117.     HRESULT Deliver (IMediaSample *pMediaSample) ;
  118.     HRESULT DeliverEndOfStream () ;
  119.     HRESULT DeliverBeginFlush () ;
  120.     HRESULT DeliverEndFlush () ;
  121.  
  122.     // overriden to handle quality messages
  123.     STDMETHODIMP Notify (IFilter *pSender, Quality q) ;
  124.  
  125.     // Persistent pin id
  126.     STDMETHODIMP QueryId(LPWSTR * Id);
  127.  
  128. private:
  129.  
  130.     CTee *m_pTee ;                  // ptr to the owner filter class
  131.     CPosPassThru *m_pPosition ;     // pass seek calls upstream
  132.     BOOL m_bHoldsSeek ;             // is this the one seekable stream
  133.     COutputQueue *m_pOutputQueue ;  // streams data to the peer pin
  134.     BOOL m_bInsideCheckMediaType ;  // re-entrancy control
  135.     LONG m_cOurRef ;                // we maintain reference couting
  136. };
  137.  
  138. //----------------------------------------------------------------------------
  139. // CTee. class for the Tee filter
  140. //----------------------------------------------------------------------------
  141.  
  142. class CTee: public CCritSec, public CBaseFilter
  143. {
  144.     // let the pins access our internal state.
  145.     friend class CTeeInputPin ;
  146.     friend class CTeeOutputPin ;
  147.  
  148. public:
  149.     CTee (TCHAR *pName, LPUNKNOWN pUnk, HRESULT *hr) ; // constructore
  150.     ~CTee () ;                                         // destructor
  151.     CBasePin *GetPin (int n) ;                         // gets a pin ptr
  152.     int GetPinCount () ;                               // rets # pins.
  153.  
  154.     // Persistent pin id support
  155.     STDMETHODIMP FindPin(LPCWSTR pwszPinId, IPin **ppPin);
  156.  
  157.     // function needed for the class factory
  158.     static CUnknown *CreateInstance (LPUNKNOWN pUnk, HRESULT *phr) ;
  159.  
  160.     // setup helper
  161.     LPAMOVIESETUP_FILTER GetSetupData();
  162.  
  163. protected:
  164.  
  165.     // The following manage the list of output pins, their creation and
  166.     // deletions.
  167.  
  168.     void InitOutputPinsList () ;
  169.     CTeeOutputPin *GetPinNFromList (int n) ;
  170.     CTeeOutputPin *CreateNextOutputPin (CTee *pTee) ;
  171.     void DeleteOutputPin (CTeeOutputPin *pPin) ;
  172.     int GetNumFreePins () ;
  173.  
  174. private:
  175.  
  176.     // declare a input pin.
  177.  
  178.     CTeeInputPin m_Input ;
  179.  
  180.     // declare a list to keep a list of all the output pins.
  181.  
  182.     INT m_NumOutputPins ;
  183.     typedef CGenericList <CTeeOutputPin> COutputList ;
  184.     COutputList m_OutputPinsList ;
  185.     INT m_NextOutputPinNumber ;     // increases monotonically.
  186.  
  187.  
  188.     // other assorted data members.
  189.  
  190.     LONG m_lCanSeek ;               // seekable output pin (only one is..)
  191.     IMemAllocator *m_pAllocator ;   // Allocator from our input pin
  192.  
  193. } ;
  194.  
  195. #endif // __TEE__
  196.