michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: #if !defined(MediaPluginReader_h_) michael@0: #define MediaPluginReader_h_ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "MediaResource.h" michael@0: #include "MediaDecoderReader.h" michael@0: #include "ImageContainer.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "mozilla/layers/SharedRGBImage.h" michael@0: michael@0: #include "MPAPI.h" michael@0: michael@0: class nsACString; michael@0: michael@0: namespace mozilla { michael@0: michael@0: class AbstractMediaDecoder; michael@0: michael@0: namespace layers { michael@0: class ImageContainer; michael@0: } michael@0: michael@0: namespace dom { michael@0: class TimeRanges; michael@0: } michael@0: michael@0: class MediaPluginReader : public MediaDecoderReader michael@0: { michael@0: nsCString mType; michael@0: MPAPI::Decoder *mPlugin; michael@0: bool mHasAudio; michael@0: bool mHasVideo; michael@0: nsIntRect mPicture; michael@0: nsIntSize mInitialFrame; michael@0: int64_t mVideoSeekTimeUs; michael@0: int64_t mAudioSeekTimeUs; michael@0: nsAutoPtr mLastVideoFrame; michael@0: public: michael@0: MediaPluginReader(AbstractMediaDecoder* aDecoder, michael@0: const nsACString& aContentType); michael@0: ~MediaPluginReader(); michael@0: michael@0: virtual nsresult Init(MediaDecoderReader* aCloneDonor); michael@0: virtual nsresult ResetDecode(); michael@0: michael@0: virtual bool DecodeAudioData(); michael@0: virtual bool DecodeVideoFrame(bool &aKeyframeSkip, michael@0: int64_t aTimeThreshold); michael@0: michael@0: virtual bool HasAudio() michael@0: { michael@0: return mHasAudio; michael@0: } michael@0: michael@0: virtual bool HasVideo() michael@0: { michael@0: return mHasVideo; michael@0: } michael@0: michael@0: virtual nsresult ReadMetadata(MediaInfo* aInfo, michael@0: MetadataTags** aTags); michael@0: virtual nsresult Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime, int64_t aCurrentTime); michael@0: michael@0: class ImageBufferCallback : public MPAPI::BufferCallback { michael@0: typedef mozilla::layers::Image Image; michael@0: michael@0: public: michael@0: ImageBufferCallback(mozilla::layers::ImageContainer *aImageContainer); michael@0: void *operator()(size_t aWidth, size_t aHeight, michael@0: MPAPI::ColorFormat aColorFormat) MOZ_OVERRIDE; michael@0: already_AddRefed GetImage(); michael@0: michael@0: private: michael@0: uint8_t *CreateI420Image(size_t aWidth, size_t aHeight); michael@0: michael@0: mozilla::layers::ImageContainer *mImageContainer; michael@0: nsRefPtr mImage; michael@0: }; michael@0: michael@0: }; michael@0: michael@0: } // namespace mozilla michael@0: michael@0: #endif