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

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

mercurial