content/media/BufferDecoder.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef BUFFER_DECODER_H_
     8 #define BUFFER_DECODER_H_
    10 #include "AbstractMediaDecoder.h"
    11 #include "mozilla/Attributes.h"
    12 #include "mozilla/ReentrantMonitor.h"
    14 namespace mozilla {
    16 /**
    17  * This class provides a decoder object which decodes a media file that lives in
    18  * a memory buffer.
    19  */
    20 class BufferDecoder : public AbstractMediaDecoder
    21 {
    22 public:
    23   // This class holds a weak pointer to MediaResource.  It's the responsibility
    24   // of the caller to manage the memory of the MediaResource object.
    25   explicit BufferDecoder(MediaResource* aResource);
    26   virtual ~BufferDecoder();
    28   NS_DECL_THREADSAFE_ISUPPORTS
    30   // This has to be called before decoding begins
    31   void BeginDecoding(nsIThread* aDecodeThread);
    33   virtual ReentrantMonitor& GetReentrantMonitor() MOZ_OVERRIDE;
    35   virtual bool IsShutdown() const MOZ_FINAL MOZ_OVERRIDE;
    37   virtual bool OnStateMachineThread() const MOZ_OVERRIDE;
    39   virtual bool OnDecodeThread() const MOZ_OVERRIDE;
    41   virtual MediaResource* GetResource() const MOZ_OVERRIDE;
    43   virtual void NotifyBytesConsumed(int64_t aBytes, int64_t aOffset) MOZ_FINAL MOZ_OVERRIDE;
    45   virtual void NotifyDecodedFrames(uint32_t aParsed, uint32_t aDecoded) MOZ_FINAL MOZ_OVERRIDE;
    47   virtual int64_t GetEndMediaTime() const MOZ_FINAL MOZ_OVERRIDE;
    49   virtual int64_t GetMediaDuration() MOZ_OVERRIDE;
    51   virtual void SetMediaDuration(int64_t aDuration) MOZ_OVERRIDE;
    53   virtual void UpdateEstimatedMediaDuration(int64_t aDuration) MOZ_OVERRIDE;
    55   virtual void SetMediaSeekable(bool aMediaSeekable) MOZ_OVERRIDE;
    57   virtual void SetTransportSeekable(bool aTransportSeekable) MOZ_OVERRIDE;
    59   virtual VideoFrameContainer* GetVideoFrameContainer() MOZ_FINAL MOZ_OVERRIDE;
    60   virtual layers::ImageContainer* GetImageContainer() MOZ_OVERRIDE;
    62   virtual bool IsTransportSeekable() MOZ_FINAL MOZ_OVERRIDE;
    64   virtual bool IsMediaSeekable() MOZ_FINAL MOZ_OVERRIDE;
    66   virtual void MetadataLoaded(int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags) MOZ_FINAL MOZ_OVERRIDE;
    67   virtual void QueueMetadata(int64_t aTime, int aChannels, int aRate, bool aHasAudio, bool aHasVideo, MetadataTags* aTags) MOZ_FINAL MOZ_OVERRIDE;
    69   virtual void SetMediaEndTime(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE;
    71   virtual void UpdatePlaybackPosition(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE;
    73   virtual void OnReadMetadataCompleted() MOZ_FINAL MOZ_OVERRIDE;
    75   virtual MediaDecoderOwner* GetOwner() MOZ_OVERRIDE;
    77   virtual void NotifyWaitingForResourcesStatusChanged() MOZ_FINAL MOZ_OVERRIDE;
    79 protected:
    80   // This monitor object is not really used to synchronize access to anything.
    81   // It's just there in order for us to be able to override
    82   // GetReentrantMonitor correctly.
    83   ReentrantMonitor mReentrantMonitor;
    84   nsCOMPtr<nsIThread> mDecodeThread;
    85   nsRefPtr<MediaResource> mResource;
    86 };
    88 } // namespace mozilla
    90 #endif /* BUFFER_DECODER_H_ */

mercurial