Fri, 16 Jan 2015 04:50:19 +0100
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 file, |
michael@0 | 5 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | #if !defined(MediaPluginReader_h_) |
michael@0 | 7 | #define MediaPluginReader_h_ |
michael@0 | 8 | |
michael@0 | 9 | #include "mozilla/Attributes.h" |
michael@0 | 10 | #include "MediaResource.h" |
michael@0 | 11 | #include "MediaDecoderReader.h" |
michael@0 | 12 | #include "ImageContainer.h" |
michael@0 | 13 | #include "nsAutoPtr.h" |
michael@0 | 14 | #include "mozilla/layers/SharedRGBImage.h" |
michael@0 | 15 | |
michael@0 | 16 | #include "MPAPI.h" |
michael@0 | 17 | |
michael@0 | 18 | class nsACString; |
michael@0 | 19 | |
michael@0 | 20 | namespace mozilla { |
michael@0 | 21 | |
michael@0 | 22 | class AbstractMediaDecoder; |
michael@0 | 23 | |
michael@0 | 24 | namespace layers { |
michael@0 | 25 | class ImageContainer; |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | namespace dom { |
michael@0 | 29 | class TimeRanges; |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | class MediaPluginReader : public MediaDecoderReader |
michael@0 | 33 | { |
michael@0 | 34 | nsCString mType; |
michael@0 | 35 | MPAPI::Decoder *mPlugin; |
michael@0 | 36 | bool mHasAudio; |
michael@0 | 37 | bool mHasVideo; |
michael@0 | 38 | nsIntRect mPicture; |
michael@0 | 39 | nsIntSize mInitialFrame; |
michael@0 | 40 | int64_t mVideoSeekTimeUs; |
michael@0 | 41 | int64_t mAudioSeekTimeUs; |
michael@0 | 42 | nsAutoPtr<VideoData> mLastVideoFrame; |
michael@0 | 43 | public: |
michael@0 | 44 | MediaPluginReader(AbstractMediaDecoder* aDecoder, |
michael@0 | 45 | const nsACString& aContentType); |
michael@0 | 46 | ~MediaPluginReader(); |
michael@0 | 47 | |
michael@0 | 48 | virtual nsresult Init(MediaDecoderReader* aCloneDonor); |
michael@0 | 49 | virtual nsresult ResetDecode(); |
michael@0 | 50 | |
michael@0 | 51 | virtual bool DecodeAudioData(); |
michael@0 | 52 | virtual bool DecodeVideoFrame(bool &aKeyframeSkip, |
michael@0 | 53 | int64_t aTimeThreshold); |
michael@0 | 54 | |
michael@0 | 55 | virtual bool HasAudio() |
michael@0 | 56 | { |
michael@0 | 57 | return mHasAudio; |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | virtual bool HasVideo() |
michael@0 | 61 | { |
michael@0 | 62 | return mHasVideo; |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | virtual nsresult ReadMetadata(MediaInfo* aInfo, |
michael@0 | 66 | MetadataTags** aTags); |
michael@0 | 67 | virtual nsresult Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime, int64_t aCurrentTime); |
michael@0 | 68 | |
michael@0 | 69 | class ImageBufferCallback : public MPAPI::BufferCallback { |
michael@0 | 70 | typedef mozilla::layers::Image Image; |
michael@0 | 71 | |
michael@0 | 72 | public: |
michael@0 | 73 | ImageBufferCallback(mozilla::layers::ImageContainer *aImageContainer); |
michael@0 | 74 | void *operator()(size_t aWidth, size_t aHeight, |
michael@0 | 75 | MPAPI::ColorFormat aColorFormat) MOZ_OVERRIDE; |
michael@0 | 76 | already_AddRefed<Image> GetImage(); |
michael@0 | 77 | |
michael@0 | 78 | private: |
michael@0 | 79 | uint8_t *CreateI420Image(size_t aWidth, size_t aHeight); |
michael@0 | 80 | |
michael@0 | 81 | mozilla::layers::ImageContainer *mImageContainer; |
michael@0 | 82 | nsRefPtr<Image> mImage; |
michael@0 | 83 | }; |
michael@0 | 84 | |
michael@0 | 85 | }; |
michael@0 | 86 | |
michael@0 | 87 | } // namespace mozilla |
michael@0 | 88 | |
michael@0 | 89 | #endif |