content/media/plugins/MediaPluginReader.h

Fri, 16 Jan 2015 04:50:19 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 04:50:19 +0100
branch
TOR_BUG_9701
changeset 13
44a2da4a2ab2
permissions
-rw-r--r--

Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
     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 file,
     5  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #if !defined(MediaPluginReader_h_)
     7 #define MediaPluginReader_h_
     9 #include "mozilla/Attributes.h"
    10 #include "MediaResource.h"
    11 #include "MediaDecoderReader.h"
    12 #include "ImageContainer.h"
    13 #include "nsAutoPtr.h"
    14 #include "mozilla/layers/SharedRGBImage.h"
    16 #include "MPAPI.h"
    18 class nsACString;
    20 namespace mozilla {
    22 class AbstractMediaDecoder;
    24 namespace layers {
    25 class ImageContainer;
    26 }
    28 namespace dom {
    29 class TimeRanges;
    30 }
    32 class MediaPluginReader : public MediaDecoderReader
    33 {
    34   nsCString mType;
    35   MPAPI::Decoder *mPlugin;
    36   bool mHasAudio;
    37   bool mHasVideo;
    38   nsIntRect mPicture;
    39   nsIntSize mInitialFrame;
    40   int64_t mVideoSeekTimeUs;
    41   int64_t mAudioSeekTimeUs;
    42   nsAutoPtr<VideoData> mLastVideoFrame;
    43 public:
    44   MediaPluginReader(AbstractMediaDecoder* aDecoder,
    45                     const nsACString& aContentType);
    46   ~MediaPluginReader();
    48   virtual nsresult Init(MediaDecoderReader* aCloneDonor);
    49   virtual nsresult ResetDecode();
    51   virtual bool DecodeAudioData();
    52   virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
    53                                 int64_t aTimeThreshold);
    55   virtual bool HasAudio()
    56   {
    57     return mHasAudio;
    58   }
    60   virtual bool HasVideo()
    61   {
    62     return mHasVideo;
    63   }
    65   virtual nsresult ReadMetadata(MediaInfo* aInfo,
    66                                 MetadataTags** aTags);
    67   virtual nsresult Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime, int64_t aCurrentTime);
    69   class ImageBufferCallback : public MPAPI::BufferCallback {
    70     typedef mozilla::layers::Image Image;
    72   public:
    73     ImageBufferCallback(mozilla::layers::ImageContainer *aImageContainer);
    74     void *operator()(size_t aWidth, size_t aHeight,
    75                      MPAPI::ColorFormat aColorFormat) MOZ_OVERRIDE;
    76     already_AddRefed<Image> GetImage();
    78   private:
    79     uint8_t *CreateI420Image(size_t aWidth, size_t aHeight);
    81     mozilla::layers::ImageContainer *mImageContainer;
    82     nsRefPtr<Image> mImage;
    83   };
    85 };
    87 } // namespace mozilla
    89 #endif

mercurial