michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 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 michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef BUFFER_DECODER_H_ michael@0: #define BUFFER_DECODER_H_ michael@0: michael@0: #include "AbstractMediaDecoder.h" michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/ReentrantMonitor.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: /** michael@0: * This class provides a decoder object which decodes a media file that lives in michael@0: * a memory buffer. michael@0: */ michael@0: class BufferDecoder : public AbstractMediaDecoder michael@0: { michael@0: public: michael@0: // This class holds a weak pointer to MediaResource. It's the responsibility michael@0: // of the caller to manage the memory of the MediaResource object. michael@0: explicit BufferDecoder(MediaResource* aResource); michael@0: virtual ~BufferDecoder(); michael@0: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: michael@0: // This has to be called before decoding begins michael@0: void BeginDecoding(nsIThread* aDecodeThread); michael@0: michael@0: virtual ReentrantMonitor& GetReentrantMonitor() MOZ_OVERRIDE; michael@0: michael@0: virtual bool IsShutdown() const MOZ_FINAL MOZ_OVERRIDE; michael@0: michael@0: virtual bool OnStateMachineThread() const MOZ_OVERRIDE; michael@0: michael@0: virtual bool OnDecodeThread() const MOZ_OVERRIDE; michael@0: michael@0: virtual MediaResource* GetResource() const MOZ_OVERRIDE; michael@0: michael@0: virtual void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) MOZ_FINAL MOZ_OVERRIDE; michael@0: michael@0: virtual void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded) MOZ_FINAL MOZ_OVERRIDE; michael@0: michael@0: virtual int64_t GetEndMediaTime() const MOZ_FINAL MOZ_OVERRIDE; michael@0: michael@0: virtual int64_t GetMediaDuration() MOZ_OVERRIDE; michael@0: michael@0: virtual void SetMediaDuration(int64_t aDuration) MOZ_OVERRIDE; michael@0: michael@0: virtual void UpdateEstimatedMediaDuration(int64_t aDuration) MOZ_OVERRIDE; michael@0: michael@0: virtual void SetMediaSeekable(bool aMediaSeekable) MOZ_OVERRIDE; michael@0: michael@0: virtual void SetTransportSeekable(bool aTransportSeekable) MOZ_OVERRIDE; michael@0: michael@0: virtual VideoFrameContainer* GetVideoFrameContainer() MOZ_FINAL MOZ_OVERRIDE; michael@0: virtual layers::ImageContainer* GetImageContainer() MOZ_OVERRIDE; michael@0: michael@0: virtual bool IsTransportSeekable() MOZ_FINAL MOZ_OVERRIDE; michael@0: michael@0: virtual bool IsMediaSeekable() MOZ_FINAL MOZ_OVERRIDE; michael@0: michael@0: virtual void MetadataLoaded(int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags) MOZ_FINAL MOZ_OVERRIDE; michael@0: virtual void QueueMetadata(int64_t aTime, int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags) MOZ_FINAL MOZ_OVERRIDE; michael@0: michael@0: virtual void SetMediaEndTime(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE; michael@0: michael@0: virtual void UpdatePlaybackPosition(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE; michael@0: michael@0: virtual void OnReadMetadataCompleted() MOZ_FINAL MOZ_OVERRIDE; michael@0: michael@0: virtual MediaDecoderOwner* GetOwner() MOZ_OVERRIDE; michael@0: michael@0: virtual void NotifyWaitingForResourcesStatusChanged() MOZ_FINAL MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: // This monitor object is not really used to synchronize access to anything. michael@0: // It's just there in order for us to be able to override michael@0: // GetReentrantMonitor correctly. michael@0: ReentrantMonitor mReentrantMonitor; michael@0: nsCOMPtr mDecodeThread; michael@0: nsRefPtr mResource; michael@0: }; michael@0: michael@0: } // namespace mozilla michael@0: michael@0: #endif /* BUFFER_DECODER_H_ */