content/media/wmf/WMFReader.h

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

     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/. */
     6 #if !defined(WMFReader_h_)
     7 #define WMFReader_h_
     9 #include "WMF.h"
    10 #include "MediaDecoderReader.h"
    11 #include "nsAutoPtr.h"
    12 #include "mozilla/RefPtr.h"
    13 #include "nsRect.h"
    15 namespace mozilla {
    17 class WMFByteStream;
    18 class WMFSourceReaderCallback;
    19 class DXVA2Manager;
    21 namespace dom {
    22 class TimeRanges;
    23 }
    25 // Decoder backend for reading H.264/AAC in MP4/M4A, and MP3 files using
    26 // Windows Media Foundation.
    27 class WMFReader : public MediaDecoderReader
    28 {
    29 public:
    30   WMFReader(AbstractMediaDecoder* aDecoder);
    32   virtual ~WMFReader();
    34   nsresult Init(MediaDecoderReader* aCloneDonor) MOZ_OVERRIDE;
    36   bool DecodeAudioData() MOZ_OVERRIDE;
    37   bool DecodeVideoFrame(bool &aKeyframeSkip,
    38                         int64_t aTimeThreshold) MOZ_OVERRIDE;
    40   bool HasAudio() MOZ_OVERRIDE;
    41   bool HasVideo() MOZ_OVERRIDE;
    43   nsresult ReadMetadata(MediaInfo* aInfo,
    44                         MetadataTags** aTags) MOZ_OVERRIDE;
    46   nsresult Seek(int64_t aTime,
    47                 int64_t aStartTime,
    48                 int64_t aEndTime,
    49                 int64_t aCurrentTime) MOZ_OVERRIDE;
    50 private:
    52   HRESULT CreateSourceReader();
    53   HRESULT ConfigureAudioDecoder();
    54   HRESULT ConfigureVideoDecoder();
    55   HRESULT ConfigureVideoFrameGeometry(IMFMediaType* aMediaType);
    56   void GetSupportedAudioCodecs(const GUID** aCodecs, uint32_t* aNumCodecs);
    58   HRESULT CreateBasicVideoFrame(IMFSample* aSample,
    59                                 int64_t aTimestampUsecs,
    60                                 int64_t aDurationUsecs,
    61                                 int64_t aOffsetBytes,
    62                                 VideoData** aOutVideoData);
    64   HRESULT CreateD3DVideoFrame(IMFSample* aSample,
    65                               int64_t aTimestampUsecs,
    66                               int64_t aDurationUsecs,
    67                               int64_t aOffsetBytes,
    68                               VideoData** aOutVideoData);
    70   // Attempt to initialize DXVA. Returns true on success.
    71   bool InitializeDXVA();  
    73   RefPtr<IMFSourceReader> mSourceReader;
    74   RefPtr<WMFByteStream> mByteStream;
    75   RefPtr<WMFSourceReaderCallback> mSourceReaderCallback;
    76   nsAutoPtr<DXVA2Manager> mDXVA2Manager;
    78   // Region inside the video frame that makes up the picture. Pixels outside
    79   // of this region should not be rendered.
    80   nsIntRect mPictureRegion;
    82   uint32_t mAudioChannels;
    83   uint32_t mAudioBytesPerSample;
    84   uint32_t mAudioRate;
    86   uint32_t mVideoWidth;
    87   uint32_t mVideoHeight;
    88   uint32_t mVideoStride;
    90   // The offset, in audio frames, at which playback started since the
    91   // last discontinuity.
    92   int64_t mAudioFrameOffset;
    93   // The number of audio frames that we've played since the last
    94   // discontinuity.
    95   int64_t mAudioFrameSum;
    96   // True if we need to re-initialize mAudioFrameOffset and mAudioFrameSum
    97   // from the next audio packet we decode. This happens after a seek, since
    98   // WMF doesn't mark a stream as having a discontinuity after a seek(0).
    99   bool mMustRecaptureAudioPosition;
   101   bool mHasAudio;
   102   bool mHasVideo;
   103   bool mUseHwAccel;
   105   // We can't call WMFDecoder::IsMP3Supported() on non-main threads, since it
   106   // checks a pref, so we cache its value in mIsMP3Enabled and use that on
   107   // the decode thread.
   108   const bool mIsMP3Enabled;
   110   bool mCOMInitialized;
   111 };
   113 } // namespace mozilla
   115 #endif

mercurial