michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #if !defined(SampleSink_h_) michael@0: #define SampleSink_h_ michael@0: michael@0: #include "BaseFilter.h" michael@0: #include "DirectShowUtils.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "mozilla/RefPtr.h" michael@0: #include "mozilla/ReentrantMonitor.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: class SampleSink { michael@0: public: michael@0: SampleSink(); michael@0: virtual ~SampleSink(); michael@0: michael@0: // Sets the audio format of the incoming samples. The upstream filter michael@0: // calls this. This makes a copy. michael@0: void SetAudioFormat(const WAVEFORMATEX* aInFormat); michael@0: michael@0: // Copies the format of incoming audio samples into into *aOutFormat. michael@0: void GetAudioFormat(WAVEFORMATEX* aOutFormat); michael@0: michael@0: // Called when a sample is delivered by the DirectShow graph to the sink. michael@0: // The decode thread retrieves the sample by calling WaitForSample(). michael@0: // Blocks if there's already a sample waiting to be consumed by the decode michael@0: // thread. michael@0: HRESULT Receive(IMediaSample* aSample); michael@0: michael@0: // Retrieves a sample from the sample queue, blocking until one becomes michael@0: // available, or until an error occurs. Returns S_FALSE on EOS. michael@0: HRESULT Extract(RefPtr& aOutSample); michael@0: michael@0: // Unblocks any threads waiting in GetSample(). michael@0: // Clears mSample, which unblocks upstream stream. michael@0: void Flush(); michael@0: michael@0: // Opens up the sink to receive more samples in PutSample(). michael@0: // Clears EOS flag. michael@0: void Reset(); michael@0: michael@0: // Marks that we've reacehd the end of stream. michael@0: void SetEOS(); michael@0: michael@0: // Returns whether we're at end of stream. michael@0: bool AtEOS(); michael@0: michael@0: private: michael@0: // All data in this class is syncronized by mMonitor. michael@0: ReentrantMonitor mMonitor; michael@0: RefPtr mSample; michael@0: michael@0: // Format of the audio stream we're receiving. michael@0: WAVEFORMATEX mAudioFormat; michael@0: michael@0: bool mIsFlushing; michael@0: bool mAtEOS; michael@0: }; michael@0: michael@0: } // namespace mozilla michael@0: #endif // SampleSink_h_