1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/BufferDecoder.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,90 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef BUFFER_DECODER_H_ 1.11 +#define BUFFER_DECODER_H_ 1.12 + 1.13 +#include "AbstractMediaDecoder.h" 1.14 +#include "mozilla/Attributes.h" 1.15 +#include "mozilla/ReentrantMonitor.h" 1.16 + 1.17 +namespace mozilla { 1.18 + 1.19 +/** 1.20 + * This class provides a decoder object which decodes a media file that lives in 1.21 + * a memory buffer. 1.22 + */ 1.23 +class BufferDecoder : public AbstractMediaDecoder 1.24 +{ 1.25 +public: 1.26 + // This class holds a weak pointer to MediaResource. It's the responsibility 1.27 + // of the caller to manage the memory of the MediaResource object. 1.28 + explicit BufferDecoder(MediaResource* aResource); 1.29 + virtual ~BufferDecoder(); 1.30 + 1.31 + NS_DECL_THREADSAFE_ISUPPORTS 1.32 + 1.33 + // This has to be called before decoding begins 1.34 + void BeginDecoding(nsIThread* aDecodeThread); 1.35 + 1.36 + virtual ReentrantMonitor& GetReentrantMonitor() MOZ_OVERRIDE; 1.37 + 1.38 + virtual bool IsShutdown() const MOZ_FINAL MOZ_OVERRIDE; 1.39 + 1.40 + virtual bool OnStateMachineThread() const MOZ_OVERRIDE; 1.41 + 1.42 + virtual bool OnDecodeThread() const MOZ_OVERRIDE; 1.43 + 1.44 + virtual MediaResource* GetResource() const MOZ_OVERRIDE; 1.45 + 1.46 + virtual void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) MOZ_FINAL MOZ_OVERRIDE; 1.47 + 1.48 + virtual void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded) MOZ_FINAL MOZ_OVERRIDE; 1.49 + 1.50 + virtual int64_t GetEndMediaTime() const MOZ_FINAL MOZ_OVERRIDE; 1.51 + 1.52 + virtual int64_t GetMediaDuration() MOZ_OVERRIDE; 1.53 + 1.54 + virtual void SetMediaDuration(int64_t aDuration) MOZ_OVERRIDE; 1.55 + 1.56 + virtual void UpdateEstimatedMediaDuration(int64_t aDuration) MOZ_OVERRIDE; 1.57 + 1.58 + virtual void SetMediaSeekable(bool aMediaSeekable) MOZ_OVERRIDE; 1.59 + 1.60 + virtual void SetTransportSeekable(bool aTransportSeekable) MOZ_OVERRIDE; 1.61 + 1.62 + virtual VideoFrameContainer* GetVideoFrameContainer() MOZ_FINAL MOZ_OVERRIDE; 1.63 + virtual layers::ImageContainer* GetImageContainer() MOZ_OVERRIDE; 1.64 + 1.65 + virtual bool IsTransportSeekable() MOZ_FINAL MOZ_OVERRIDE; 1.66 + 1.67 + virtual bool IsMediaSeekable() MOZ_FINAL MOZ_OVERRIDE; 1.68 + 1.69 + virtual void MetadataLoaded(int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags) MOZ_FINAL MOZ_OVERRIDE; 1.70 + virtual void QueueMetadata(int64_t aTime, int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags) MOZ_FINAL MOZ_OVERRIDE; 1.71 + 1.72 + virtual void SetMediaEndTime(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE; 1.73 + 1.74 + virtual void UpdatePlaybackPosition(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE; 1.75 + 1.76 + virtual void OnReadMetadataCompleted() MOZ_FINAL MOZ_OVERRIDE; 1.77 + 1.78 + virtual MediaDecoderOwner* GetOwner() MOZ_OVERRIDE; 1.79 + 1.80 + virtual void NotifyWaitingForResourcesStatusChanged() MOZ_FINAL MOZ_OVERRIDE; 1.81 + 1.82 +protected: 1.83 + // This monitor object is not really used to synchronize access to anything. 1.84 + // It's just there in order for us to be able to override 1.85 + // GetReentrantMonitor correctly. 1.86 + ReentrantMonitor mReentrantMonitor; 1.87 + nsCOMPtr<nsIThread> mDecodeThread; 1.88 + nsRefPtr<MediaResource> mResource; 1.89 +}; 1.90 + 1.91 +} // namespace mozilla 1.92 + 1.93 +#endif /* BUFFER_DECODER_H_ */