home *** CD-ROM | disk | FTP | other *** search
- //==========================================================================;
- //
- // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
- // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
- // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
- // PURPOSE.
- //
- // Copyright (c) 1992 - 1996 Microsoft Corporation. All Rights Reserved.
- //
- //--------------------------------------------------------------------------;
-
- #ifndef __VMBASE_H__
- #define __VMBASE_H__
-
- // We export this:
- class CBaseVideoMixer;
- class CBaseVideoMixerInputPin;
- class CBaseVideoMixerOutputPin;
-
- // ==================================================
- // Implements the input pins
- // ==================================================
-
- class CBaseVideoMixerInputPin : public CBaseInputPin
- {
- friend class CBaseVideoMixer;
-
- // owning video mixer
- protected:
- CBaseVideoMixer *m_pBaseVideoMixer;
-
- public:
- CBaseVideoMixerInputPin(
- TCHAR *pObjectName,
- CBaseFilter *pBaseFilter,
- CBaseVideoMixer *pTransformFilter,
- HRESULT * phr,
- LPCWSTR pName,
- int iPinNo);
-
- ~CBaseVideoMixerInputPin();
-
- // override connect to grab critsec
- STDMETHODIMP Disconnect();
-
- // Grab and release extra interfaces if required
- HRESULT CheckConnect(IPin *pPin);
- HRESULT BreakConnect();
-
- // check that we can support this output type
- HRESULT CheckMediaType(const CMediaType* mtIn);
-
- // set the connection media type
- HRESULT SetMediaType(const CMediaType* mt);
-
- // --- IMemInputPin -----
-
- // here's the next block of data from the stream.
- // AddRef it yourself if you need to hold it beyond the end
- // of this call.
- STDMETHODIMP Receive(IMediaSample * pSample);
-
- // provide EndOfStream that passes straight downstream
- // (there is no queued data)
- STDMETHODIMP EndOfStream(void);
-
- // passes it to CBaseVideoMixer::BeginFlush
- STDMETHODIMP BeginFlush(void);
-
- // passes it to CBaseVideoMixer::EndFlush
- STDMETHODIMP EndFlush(void);
-
- // Pass a Quality notification on to the appropriate sink
- HRESULT PassNotify(Quality q);
-
- HRESULT Active(void);
-
- // return an enumerator for this pins preferred media types
- STDMETHODIMP EnumMediaTypes(
- IEnumMediaTypes **ppEnum
- );
-
- // Sample queue
- protected:
- CGenericList<IMediaSample> m_SampleList;
- public:
- BOOL SampleReady( void );
- IMediaSample *GetHeadSample( void );
- void GetHeadStopTime( CRefTime *prt );
- void ReleaseHeadSample( void );
- void ReleaseAllBefore( CRefTime rtTime );
-
- // Media type
- public:
- CMediaType& CurrentMediaType() { return m_mt; };
- IPin * CurrentPeer() { return m_Connected; };
-
- // Attributes
- const int m_iPinNo;
- BOOL m_fEOSReceived;
- };
-
- // ==================================================
- // Implements the output pin
- // ==================================================
-
- class CBaseVideoMixerOutputPin : public CBaseOutputPin
- {
- const int m_iOutputPin; // CBaseVideoMixer's identifier
- friend class CBaseVideoMixer;
-
- // Owning video mixer
- protected:
- CBaseVideoMixer *m_pBaseVideoMixer;
-
- public:
-
- CBaseVideoMixerOutputPin(
- TCHAR *pObjectName,
- CBaseFilter *pBaseFilter,
- CBaseVideoMixer *pTransformFilter,
- HRESULT * phr,
- LPCWSTR pName);
-
- ~CBaseVideoMixerOutputPin();
-
- // override to expose IMediaPosition
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
-
- // --- CBaseOutputPin ------------
-
- // override connect to grab critsec
- STDMETHODIMP Disconnect();
-
- // Grab and release extra interfaces if required
-
- HRESULT CheckConnect(IPin *pPin);
- HRESULT BreakConnect();
-
- // return an enumerator for this pins preferred media types
- STDMETHODIMP EnumMediaTypes(
- IEnumMediaTypes **ppEnum
- );
-
- // check that we can support this output type
- HRESULT CheckMediaType(const CMediaType* mtOut);
-
- // set the connection media type
- HRESULT SetMediaType(const CMediaType *pmt);
-
- // called from CBaseOutputPin during connection to ask for
- // the count and size of buffers we need.
- HRESULT DecideBufferSize(
- IMemAllocator * pAlloc,
- ALLOCATOR_PROPERTIES * pProp);
-
- // inherited from IQualityControl via CBasePin
- STDMETHODIMP Notify(IFilter * pSender, Quality q);
-
- // Media type
- public:
- CMediaType& CurrentMediaType() { return m_mt; };
- IPin * CurrentPeer() { return m_Connected; };
- };
-
-
- /*
- * Define our base video mixer
- */
-
- class CBaseVideoMixer : public CBaseFilter
- , public IBaseVideoMixer
- {
-
- protected:
-
- public:
-
- // Have we connected all input and output pins
- virtual HRESULT CanChangeState();
-
- // map getpin/getpincount for base enum of pins to owner
- // override this to return more specialised pin objects
- virtual int GetPinCount();
- virtual CBasePin * GetPin(int n);
-
- // override state changes to allow derived transform filter
- // to control streaming start/stop
- STDMETHODIMP Stop();
- STDMETHODIMP Pause();
- STDMETHODIMP Run(REFERENCE_TIME tStart);
-
- // Construction / destruction
- public:
- CBaseVideoMixer(TCHAR *, LPUNKNOWN, CLSID clsid, HRESULT *, int iInitialPinCount);
- ~CBaseVideoMixer();
-
- // IBaseVideoMixer
- public:
- STDMETHODIMP SetLeadPin ( int iPin )
- { CAutoLock cal( &m_csFilter ); m_iLeadPin = iPin; return NOERROR; };
-
- STDMETHODIMP GetLeadPin ( int *piPin ) { *piPin = m_iLeadPin; return NOERROR; }
- STDMETHODIMP GetInputPinCount(int *piPinCount)
- {
- CheckPointer(piPinCount,E_INVALIDARG);
- ValidateReadWritePtr(piPinCount,sizeof(int));
- *piPinCount = m_iInputPinCount;
- return NOERROR;
- }
-
- STDMETHODIMP IsUsingClock ( int *pbValue )
- {
- CheckPointer(pbValue,E_INVALIDARG);
- ValidateReadWritePtr(pbValue,sizeof(int));
- *pbValue = m_bUsingClock;
- return NOERROR;
- }
-
- STDMETHODIMP SetUsingClock ( int bValue )
- { CAutoLock cal( &m_csFilter ); m_bUsingClock = bValue; return E_NOTIMPL; }
-
- STDMETHODIMP GetClockPeriod ( int *piValue )
- {
- CheckPointer(piValue,E_INVALIDARG);
- ValidateReadWritePtr(piValue,sizeof(int));
- *piValue = m_iClockPeriod;
- return NOERROR;
- }
-
- STDMETHODIMP SetClockPeriod ( int iValue )
- { CAutoLock cal( &m_csFilter ); m_iClockPeriod = iValue; return NOERROR; }
-
- // Definitions
- protected:
- // =================================================================
- // ----- override these bits ---------------------------------------
- // =================================================================
-
- // These must be supplied in a derived class
- virtual HRESULT MixSamples( IMediaSample *pSampleOut ) PURE;
-
- // check if you can support this format
- virtual HRESULT CanMixType(const CMediaType* mtIn) PURE;
-
- // override this if you want to supply your own pins
- virtual HRESULT CreatePins();
- // =================================================================
- // ----- End of video mixer supplied functions -----------------------
- // =================================================================
-
- // exploses ISpecifyPropertyPages & IBaseVideoMixer
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);
-
- // wraps the PURE MixSamples function
- virtual HRESULT MixAndOutputSamples( IMediaSample **ppOut );
-
- // you can also override these if you want to know about streaming
- virtual HRESULT StartStreaming();
- virtual HRESULT StopStreaming();
-
- // override this to know when the media type is actually set
- virtual HRESULT SetMediaType( int iPin, const CMediaType *pmt );
-
- // chance to grab extra interfaces on connection
- virtual HRESULT CheckConnect( int iPin, IPin *pPin );
- virtual HRESULT BreakConnect( int iPin );
-
- // chance to customize the mix process
- virtual HRESULT Receive( void );
-
- // check if you can support this format
- virtual HRESULT CheckMediaType(int iPin, const CMediaType* mtIn);
-
- // Stream flushing
- virtual HRESULT BeginFlush(void);
- virtual HRESULT EndFlush(void);
- virtual HRESULT ReleaseAllQueuedSamples( void );
-
- // called when leading stream transitioned out or at EndOfStream
- virtual HRESULT HandleLeadingPinStopping(void);
-
- // Critical sections
- protected:
- CCritSec m_csFilter; // filter wide lock
- CCritSec m_csMixLock; // mix lock
-
- // Pins
- protected:
- friend class CBaseVideoMixerInputPin;
- friend class CBaseVideoMixerOutputPin;
-
- int m_iInputPinCount; // number of input pins
- int m_iInputPinsConnected; // number connected
- CBaseVideoMixerInputPin **m_apInput;// Array of input pin pointers
- CBaseVideoMixerOutputPin *m_pOutput;// output pin
-
- CRefTime *m_pStreamOffset;
-
- // Method of operation (clock vs lead pin)
- protected:
- BOOL m_bUsingClock; // are we using the clock?
- int m_iClockPeriod; // period of the clock
- int m_iLeadPin; // Which pin triggers an output?
-
- CRefTime *m_apOffsets; // if non-NULL, allows various
- // input streams to be offset in time
- CRefTime *m_apLengths; // if non-NULL, allows various
- // input streams to be limited in time
-
- // Current frame that we are working on
- protected:
- CRefTime m_rtThisFrame; // when will we mix?
- CRefTime m_rtNextFrame; // this frame stop/next frame start
-
- // implement IMediaPosition by passing upstream
- protected:
- CMultiPinPosPassThru * m_pPosition;
-
- };
-
- BOOL AreEqualVideoTypes( const CMediaType *pmt1, const CMediaType *pmt2 );
-
-
- #endif /* __VMBASE_H__ */
-
-