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.

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

mercurial