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(AudioSinkInputPin_h_) michael@0: #define AudioSinkInputPin_h_ michael@0: michael@0: #include "BaseInputPin.h" michael@0: #include "DirectShowUtils.h" michael@0: #include "mozilla/RefPtr.h" michael@0: #include "nsAutoPtr.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: namespace media { michael@0: class MediaType; michael@0: } michael@0: michael@0: class AudioSinkFilter; michael@0: class SampleSink; michael@0: michael@0: michael@0: // Input pin for capturing audio output of a DirectShow filter graph. michael@0: // This is the input pin for the AudioSinkFilter. michael@0: class AudioSinkInputPin: public mozilla::media::BaseInputPin michael@0: { michael@0: public: michael@0: AudioSinkInputPin(wchar_t* aObjectName, michael@0: AudioSinkFilter* aFilter, michael@0: mozilla::CriticalSection* aLock, michael@0: HRESULT* aOutResult); michael@0: virtual ~AudioSinkInputPin(); michael@0: michael@0: HRESULT GetMediaType (IN int iPos, OUT mozilla::media::MediaType * pmt); michael@0: HRESULT CheckMediaType (IN const mozilla::media::MediaType * pmt); michael@0: STDMETHODIMP Receive (IN IMediaSample *); michael@0: STDMETHODIMP BeginFlush() MOZ_OVERRIDE; michael@0: STDMETHODIMP EndFlush() MOZ_OVERRIDE; michael@0: michael@0: // Called when we start decoding a new segment, that happens directly after michael@0: // a seek. This captures the segment's start time. Samples decoded by the michael@0: // MP3 decoder have their timestamps offset from the segment start time. michael@0: // Storing the segment start time enables us to set each sample's MediaTime michael@0: // as an offset in the stream relative to the start of the stream, rather michael@0: // than the start of the segment, i.e. its absolute time in the stream. michael@0: STDMETHODIMP NewSegment(REFERENCE_TIME tStart, michael@0: REFERENCE_TIME tStop, michael@0: double dRate) MOZ_OVERRIDE; michael@0: michael@0: STDMETHODIMP EndOfStream() MOZ_OVERRIDE; michael@0: michael@0: // Returns the IMediaSeeking interface of the connected output pin. michael@0: // We forward seeking requests upstream from the sink to the source michael@0: // filters. michael@0: TemporaryRef GetConnectedPinSeeking(); michael@0: michael@0: SampleSink* GetSampleSink(); michael@0: michael@0: private: michael@0: AudioSinkFilter* GetAudioSinkFilter(); michael@0: michael@0: // Sets the media time on the media sample, relative to the segment michael@0: // start time. michael@0: HRESULT SetAbsoluteMediaTime(IMediaSample* aSample); michael@0: michael@0: nsAutoPtr mSampleSink; michael@0: michael@0: // Synchronized by the filter lock; BaseInputPin::mLock. michael@0: REFERENCE_TIME mSegmentStartTime; michael@0: }; michael@0: michael@0: } // namespace mozilla michael@0: #endif // AudioSinkInputPin_h_