content/media/plugins/MediaPluginReader.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/plugins/MediaPluginReader.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,89 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */
     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 file,
     1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +#if !defined(MediaPluginReader_h_)
    1.10 +#define MediaPluginReader_h_
    1.11 +
    1.12 +#include "mozilla/Attributes.h"
    1.13 +#include "MediaResource.h"
    1.14 +#include "MediaDecoderReader.h"
    1.15 +#include "ImageContainer.h"
    1.16 +#include "nsAutoPtr.h"
    1.17 +#include "mozilla/layers/SharedRGBImage.h"
    1.18 + 
    1.19 +#include "MPAPI.h"
    1.20 +
    1.21 +class nsACString;
    1.22 +
    1.23 +namespace mozilla {
    1.24 +
    1.25 +class AbstractMediaDecoder;
    1.26 +
    1.27 +namespace layers {
    1.28 +class ImageContainer;
    1.29 +}
    1.30 +
    1.31 +namespace dom {
    1.32 +class TimeRanges;
    1.33 +}
    1.34 + 
    1.35 +class MediaPluginReader : public MediaDecoderReader
    1.36 +{
    1.37 +  nsCString mType;
    1.38 +  MPAPI::Decoder *mPlugin;
    1.39 +  bool mHasAudio;
    1.40 +  bool mHasVideo;
    1.41 +  nsIntRect mPicture;
    1.42 +  nsIntSize mInitialFrame;
    1.43 +  int64_t mVideoSeekTimeUs;
    1.44 +  int64_t mAudioSeekTimeUs;
    1.45 +  nsAutoPtr<VideoData> mLastVideoFrame;
    1.46 +public:
    1.47 +  MediaPluginReader(AbstractMediaDecoder* aDecoder,
    1.48 +                    const nsACString& aContentType);
    1.49 +  ~MediaPluginReader();
    1.50 +
    1.51 +  virtual nsresult Init(MediaDecoderReader* aCloneDonor);
    1.52 +  virtual nsresult ResetDecode();
    1.53 +
    1.54 +  virtual bool DecodeAudioData();
    1.55 +  virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
    1.56 +                                int64_t aTimeThreshold);
    1.57 +
    1.58 +  virtual bool HasAudio()
    1.59 +  {
    1.60 +    return mHasAudio;
    1.61 +  }
    1.62 +
    1.63 +  virtual bool HasVideo()
    1.64 +  {
    1.65 +    return mHasVideo;
    1.66 +  }
    1.67 +
    1.68 +  virtual nsresult ReadMetadata(MediaInfo* aInfo,
    1.69 +                                MetadataTags** aTags);
    1.70 +  virtual nsresult Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime, int64_t aCurrentTime);
    1.71 +
    1.72 +  class ImageBufferCallback : public MPAPI::BufferCallback {
    1.73 +    typedef mozilla::layers::Image Image;
    1.74 +
    1.75 +  public:
    1.76 +    ImageBufferCallback(mozilla::layers::ImageContainer *aImageContainer);
    1.77 +    void *operator()(size_t aWidth, size_t aHeight,
    1.78 +                     MPAPI::ColorFormat aColorFormat) MOZ_OVERRIDE;
    1.79 +    already_AddRefed<Image> GetImage();
    1.80 +
    1.81 +  private:
    1.82 +    uint8_t *CreateI420Image(size_t aWidth, size_t aHeight);
    1.83 +
    1.84 +    mozilla::layers::ImageContainer *mImageContainer;
    1.85 +    nsRefPtr<Image> mImage;
    1.86 +  };
    1.87 +
    1.88 +};
    1.89 +
    1.90 +} // namespace mozilla
    1.91 +
    1.92 +#endif

mercurial