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: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
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 | |
michael@0 | 7 | #ifndef BUFFER_DECODER_H_ |
michael@0 | 8 | #define BUFFER_DECODER_H_ |
michael@0 | 9 | |
michael@0 | 10 | #include "AbstractMediaDecoder.h" |
michael@0 | 11 | #include "mozilla/Attributes.h" |
michael@0 | 12 | #include "mozilla/ReentrantMonitor.h" |
michael@0 | 13 | |
michael@0 | 14 | namespace mozilla { |
michael@0 | 15 | |
michael@0 | 16 | /** |
michael@0 | 17 | * This class provides a decoder object which decodes a media file that lives in |
michael@0 | 18 | * a memory buffer. |
michael@0 | 19 | */ |
michael@0 | 20 | class BufferDecoder : public AbstractMediaDecoder |
michael@0 | 21 | { |
michael@0 | 22 | public: |
michael@0 | 23 | // This class holds a weak pointer to MediaResource. It's the responsibility |
michael@0 | 24 | // of the caller to manage the memory of the MediaResource object. |
michael@0 | 25 | explicit BufferDecoder(MediaResource* aResource); |
michael@0 | 26 | virtual ~BufferDecoder(); |
michael@0 | 27 | |
michael@0 | 28 | NS_DECL_THREADSAFE_ISUPPORTS |
michael@0 | 29 | |
michael@0 | 30 | // This has to be called before decoding begins |
michael@0 | 31 | void BeginDecoding(nsIThread* aDecodeThread); |
michael@0 | 32 | |
michael@0 | 33 | virtual ReentrantMonitor& GetReentrantMonitor() MOZ_OVERRIDE; |
michael@0 | 34 | |
michael@0 | 35 | virtual bool IsShutdown() const MOZ_FINAL MOZ_OVERRIDE; |
michael@0 | 36 | |
michael@0 | 37 | virtual bool OnStateMachineThread() const MOZ_OVERRIDE; |
michael@0 | 38 | |
michael@0 | 39 | virtual bool OnDecodeThread() const MOZ_OVERRIDE; |
michael@0 | 40 | |
michael@0 | 41 | virtual MediaResource* GetResource() const MOZ_OVERRIDE; |
michael@0 | 42 | |
michael@0 | 43 | virtual void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) MOZ_FINAL MOZ_OVERRIDE; |
michael@0 | 44 | |
michael@0 | 45 | virtual void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded) MOZ_FINAL MOZ_OVERRIDE; |
michael@0 | 46 | |
michael@0 | 47 | virtual int64_t GetEndMediaTime() const MOZ_FINAL MOZ_OVERRIDE; |
michael@0 | 48 | |
michael@0 | 49 | virtual int64_t GetMediaDuration() MOZ_OVERRIDE; |
michael@0 | 50 | |
michael@0 | 51 | virtual void SetMediaDuration(int64_t aDuration) MOZ_OVERRIDE; |
michael@0 | 52 | |
michael@0 | 53 | virtual void UpdateEstimatedMediaDuration(int64_t aDuration) MOZ_OVERRIDE; |
michael@0 | 54 | |
michael@0 | 55 | virtual void SetMediaSeekable(bool aMediaSeekable) MOZ_OVERRIDE; |
michael@0 | 56 | |
michael@0 | 57 | virtual void SetTransportSeekable(bool aTransportSeekable) MOZ_OVERRIDE; |
michael@0 | 58 | |
michael@0 | 59 | virtual VideoFrameContainer* GetVideoFrameContainer() MOZ_FINAL MOZ_OVERRIDE; |
michael@0 | 60 | virtual layers::ImageContainer* GetImageContainer() MOZ_OVERRIDE; |
michael@0 | 61 | |
michael@0 | 62 | virtual bool IsTransportSeekable() MOZ_FINAL MOZ_OVERRIDE; |
michael@0 | 63 | |
michael@0 | 64 | virtual bool IsMediaSeekable() MOZ_FINAL MOZ_OVERRIDE; |
michael@0 | 65 | |
michael@0 | 66 | virtual void MetadataLoaded(int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags) MOZ_FINAL MOZ_OVERRIDE; |
michael@0 | 67 | virtual void QueueMetadata(int64_t aTime, int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags) MOZ_FINAL MOZ_OVERRIDE; |
michael@0 | 68 | |
michael@0 | 69 | virtual void SetMediaEndTime(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE; |
michael@0 | 70 | |
michael@0 | 71 | virtual void UpdatePlaybackPosition(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE; |
michael@0 | 72 | |
michael@0 | 73 | virtual void OnReadMetadataCompleted() MOZ_FINAL MOZ_OVERRIDE; |
michael@0 | 74 | |
michael@0 | 75 | virtual MediaDecoderOwner* GetOwner() MOZ_OVERRIDE; |
michael@0 | 76 | |
michael@0 | 77 | virtual void NotifyWaitingForResourcesStatusChanged() MOZ_FINAL MOZ_OVERRIDE; |
michael@0 | 78 | |
michael@0 | 79 | protected: |
michael@0 | 80 | // This monitor object is not really used to synchronize access to anything. |
michael@0 | 81 | // It's just there in order for us to be able to override |
michael@0 | 82 | // GetReentrantMonitor correctly. |
michael@0 | 83 | ReentrantMonitor mReentrantMonitor; |
michael@0 | 84 | nsCOMPtr<nsIThread> mDecodeThread; |
michael@0 | 85 | nsRefPtr<MediaResource> mResource; |
michael@0 | 86 | }; |
michael@0 | 87 | |
michael@0 | 88 | } // namespace mozilla |
michael@0 | 89 | |
michael@0 | 90 | #endif /* BUFFER_DECODER_H_ */ |