content/media/directshow/SampleSink.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #if !defined(SampleSink_h_)
michael@0 8 #define SampleSink_h_
michael@0 9
michael@0 10 #include "BaseFilter.h"
michael@0 11 #include "DirectShowUtils.h"
michael@0 12 #include "nsAutoPtr.h"
michael@0 13 #include "mozilla/RefPtr.h"
michael@0 14 #include "mozilla/ReentrantMonitor.h"
michael@0 15
michael@0 16 namespace mozilla {
michael@0 17
michael@0 18 class SampleSink {
michael@0 19 public:
michael@0 20 SampleSink();
michael@0 21 virtual ~SampleSink();
michael@0 22
michael@0 23 // Sets the audio format of the incoming samples. The upstream filter
michael@0 24 // calls this. This makes a copy.
michael@0 25 void SetAudioFormat(const WAVEFORMATEX* aInFormat);
michael@0 26
michael@0 27 // Copies the format of incoming audio samples into into *aOutFormat.
michael@0 28 void GetAudioFormat(WAVEFORMATEX* aOutFormat);
michael@0 29
michael@0 30 // Called when a sample is delivered by the DirectShow graph to the sink.
michael@0 31 // The decode thread retrieves the sample by calling WaitForSample().
michael@0 32 // Blocks if there's already a sample waiting to be consumed by the decode
michael@0 33 // thread.
michael@0 34 HRESULT Receive(IMediaSample* aSample);
michael@0 35
michael@0 36 // Retrieves a sample from the sample queue, blocking until one becomes
michael@0 37 // available, or until an error occurs. Returns S_FALSE on EOS.
michael@0 38 HRESULT Extract(RefPtr<IMediaSample>& aOutSample);
michael@0 39
michael@0 40 // Unblocks any threads waiting in GetSample().
michael@0 41 // Clears mSample, which unblocks upstream stream.
michael@0 42 void Flush();
michael@0 43
michael@0 44 // Opens up the sink to receive more samples in PutSample().
michael@0 45 // Clears EOS flag.
michael@0 46 void Reset();
michael@0 47
michael@0 48 // Marks that we've reacehd the end of stream.
michael@0 49 void SetEOS();
michael@0 50
michael@0 51 // Returns whether we're at end of stream.
michael@0 52 bool AtEOS();
michael@0 53
michael@0 54 private:
michael@0 55 // All data in this class is syncronized by mMonitor.
michael@0 56 ReentrantMonitor mMonitor;
michael@0 57 RefPtr<IMediaSample> mSample;
michael@0 58
michael@0 59 // Format of the audio stream we're receiving.
michael@0 60 WAVEFORMATEX mAudioFormat;
michael@0 61
michael@0 62 bool mIsFlushing;
michael@0 63 bool mAtEOS;
michael@0 64 };
michael@0 65
michael@0 66 } // namespace mozilla
michael@0 67 #endif // SampleSink_h_

mercurial