|
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_ |
|
8 |
|
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" |
|
15 |
|
16 #include "MPAPI.h" |
|
17 |
|
18 class nsACString; |
|
19 |
|
20 namespace mozilla { |
|
21 |
|
22 class AbstractMediaDecoder; |
|
23 |
|
24 namespace layers { |
|
25 class ImageContainer; |
|
26 } |
|
27 |
|
28 namespace dom { |
|
29 class TimeRanges; |
|
30 } |
|
31 |
|
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(); |
|
47 |
|
48 virtual nsresult Init(MediaDecoderReader* aCloneDonor); |
|
49 virtual nsresult ResetDecode(); |
|
50 |
|
51 virtual bool DecodeAudioData(); |
|
52 virtual bool DecodeVideoFrame(bool &aKeyframeSkip, |
|
53 int64_t aTimeThreshold); |
|
54 |
|
55 virtual bool HasAudio() |
|
56 { |
|
57 return mHasAudio; |
|
58 } |
|
59 |
|
60 virtual bool HasVideo() |
|
61 { |
|
62 return mHasVideo; |
|
63 } |
|
64 |
|
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); |
|
68 |
|
69 class ImageBufferCallback : public MPAPI::BufferCallback { |
|
70 typedef mozilla::layers::Image Image; |
|
71 |
|
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(); |
|
77 |
|
78 private: |
|
79 uint8_t *CreateI420Image(size_t aWidth, size_t aHeight); |
|
80 |
|
81 mozilla::layers::ImageContainer *mImageContainer; |
|
82 nsRefPtr<Image> mImage; |
|
83 }; |
|
84 |
|
85 }; |
|
86 |
|
87 } // namespace mozilla |
|
88 |
|
89 #endif |