OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ | 5 #ifndef MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ |
6 #define MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ | 6 #define MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 10 matching lines...) Expand all Loading... | |
21 namespace base { | 21 namespace base { |
22 class MessageLoopProxy; | 22 class MessageLoopProxy; |
23 class SharedMemory; | 23 class SharedMemory; |
24 } | 24 } |
25 | 25 |
26 class SkBitmap; | 26 class SkBitmap; |
27 | 27 |
28 namespace media { | 28 namespace media { |
29 | 29 |
30 class DecoderBuffer; | 30 class DecoderBuffer; |
31 class VDAClientProxy; | |
32 | 31 |
33 // GPU-accelerated video decoder implementation. Relies on | 32 // GPU-accelerated video decoder implementation. Relies on |
34 // AcceleratedVideoDecoderMsg_Decode and friends. | 33 // AcceleratedVideoDecoderMsg_Decode and friends. |
35 // All methods internally trampoline to the |message_loop| passed to the ctor. | |
36 class MEDIA_EXPORT GpuVideoDecoder | 34 class MEDIA_EXPORT GpuVideoDecoder |
37 : public VideoDecoder, | 35 : public VideoDecoder, |
38 public VideoDecodeAccelerator::Client { | 36 public VideoDecodeAccelerator::Client { |
39 public: | 37 public: |
40 // Helper interface for specifying factories needed to instantiate a | 38 // Helper interface for specifying factories needed to instantiate a |
41 // GpuVideoDecoder. | 39 // GpuVideoDecoder. |
42 class MEDIA_EXPORT Factories : public base::RefCountedThreadSafe<Factories> { | 40 class MEDIA_EXPORT Factories : public base::RefCountedThreadSafe<Factories> { |
43 public: | 41 public: |
44 // Caller owns returned pointer. | 42 // Caller owns returned pointer. |
45 virtual VideoDecodeAccelerator* CreateVideoDecodeAccelerator( | 43 virtual VideoDecodeAccelerator* CreateVideoDecodeAccelerator( |
(...skipping 24 matching lines...) Expand all Loading... | |
70 virtual void Abort() = 0; | 68 virtual void Abort() = 0; |
71 | 69 |
72 // Returns true if Abort() has been called. | 70 // Returns true if Abort() has been called. |
73 virtual bool IsAborted() = 0; | 71 virtual bool IsAborted() = 0; |
74 | 72 |
75 protected: | 73 protected: |
76 friend class base::RefCountedThreadSafe<Factories>; | 74 friend class base::RefCountedThreadSafe<Factories>; |
77 virtual ~Factories(); | 75 virtual ~Factories(); |
78 }; | 76 }; |
79 | 77 |
80 GpuVideoDecoder(const scoped_refptr<base::MessageLoopProxy>& message_loop, | 78 GpuVideoDecoder(const scoped_refptr<Factories>& factories); |
scherkus (not reviewing)
2013/07/18 00:54:43
this is a bit backwards ... for media::VideoDecode
wuchengli
2013/07/18 09:42:00
Done. I added DCHECK. GetMessageLoop() are only us
| |
81 const scoped_refptr<Factories>& factories); | |
82 | 79 |
83 // VideoDecoder implementation. | 80 // VideoDecoder implementation. |
84 virtual void Initialize(const VideoDecoderConfig& config, | 81 virtual void Initialize(const VideoDecoderConfig& config, |
85 const PipelineStatusCB& status_cb) OVERRIDE; | 82 const PipelineStatusCB& status_cb) OVERRIDE; |
86 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 83 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
87 const ReadCB& read_cb) OVERRIDE; | 84 const ReadCB& read_cb) OVERRIDE; |
88 virtual void Reset(const base::Closure& closure) OVERRIDE; | 85 virtual void Reset(const base::Closure& closure) OVERRIDE; |
89 virtual void Stop(const base::Closure& closure) OVERRIDE; | 86 virtual void Stop(const base::Closure& closure) OVERRIDE; |
90 virtual bool HasAlpha() const OVERRIDE; | 87 virtual bool HasAlpha() const OVERRIDE; |
91 virtual bool NeedsBitstreamConversion() const OVERRIDE; | 88 virtual bool NeedsBitstreamConversion() const OVERRIDE; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 const scoped_refptr<VideoFrame>& frame); | 123 const scoped_refptr<VideoFrame>& frame); |
127 | 124 |
128 // Indicate the picture buffer can be reused by the decoder. | 125 // Indicate the picture buffer can be reused by the decoder. |
129 void ReusePictureBuffer(int64 picture_buffer_id, uint32 sync_point); | 126 void ReusePictureBuffer(int64 picture_buffer_id, uint32 sync_point); |
130 | 127 |
131 void RecordBufferData( | 128 void RecordBufferData( |
132 const BitstreamBuffer& bitstream_buffer, const DecoderBuffer& buffer); | 129 const BitstreamBuffer& bitstream_buffer, const DecoderBuffer& buffer); |
133 void GetBufferData(int32 id, base::TimeDelta* timetamp, | 130 void GetBufferData(int32 id, base::TimeDelta* timetamp, |
134 gfx::Rect* visible_rect, gfx::Size* natural_size); | 131 gfx::Rect* visible_rect, gfx::Size* natural_size); |
135 | 132 |
136 // Sets |vda_| and |weak_vda_| on the GVD thread and runs |status_cb|. | |
137 void SetVDA(const PipelineStatusCB& status_cb, | |
138 VideoDecodeAccelerator* vda, | |
139 base::WeakPtr<VideoDecodeAccelerator> weak_vda); | |
140 | |
141 // Call VDA::Destroy() on |vda_loop_proxy_| ensuring that |this| outlives the | |
142 // Destroy() call. | |
143 void DestroyVDA(); | 133 void DestroyVDA(); |
144 | 134 |
145 // A shared memory segment and its allocated size. | 135 // A shared memory segment and its allocated size. |
146 struct SHMBuffer { | 136 struct SHMBuffer { |
147 SHMBuffer(base::SharedMemory* m, size_t s); | 137 SHMBuffer(base::SharedMemory* m, size_t s); |
148 ~SHMBuffer(); | 138 ~SHMBuffer(); |
149 base::SharedMemory* shm; | 139 base::SharedMemory* shm; |
150 size_t size; | 140 size_t size; |
151 }; | 141 }; |
152 | 142 |
153 // Request a shared-memory segment of at least |min_size| bytes. Will | 143 // Request a shared-memory segment of at least |min_size| bytes. Will |
154 // allocate as necessary. Caller does not own returned pointer. | 144 // allocate as necessary. Caller does not own returned pointer. |
155 SHMBuffer* GetSHM(size_t min_size); | 145 SHMBuffer* GetSHM(size_t min_size); |
156 | 146 |
157 // Return a shared-memory segment to the available pool. | 147 // Return a shared-memory segment to the available pool. |
158 void PutSHM(SHMBuffer* shm_buffer); | 148 void PutSHM(SHMBuffer* shm_buffer); |
159 | 149 |
160 void DestroyTextures(); | 150 void DestroyTextures(); |
161 | 151 |
162 bool needs_bitstream_conversion_; | 152 bool needs_bitstream_conversion_; |
163 | 153 |
164 // Message loop on which to fire callbacks and trampoline calls to this class | 154 // Message loop which this class and |factories_| run on. |
165 // if they arrive on other loops. | |
166 scoped_refptr<base::MessageLoopProxy> gvd_loop_proxy_; | 155 scoped_refptr<base::MessageLoopProxy> gvd_loop_proxy_; |
167 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_; | 156 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_; |
168 base::WeakPtr<GpuVideoDecoder> weak_this_; | 157 base::WeakPtr<GpuVideoDecoder> weak_this_; |
169 | 158 |
170 // Message loop on which to makes all calls to vda_. (beware this loop may be | |
171 // paused during the Pause/Flush/Stop dance PipelineImpl::Stop() goes | |
172 // through). | |
173 scoped_refptr<base::MessageLoopProxy> vda_loop_proxy_; | |
174 | |
175 scoped_refptr<Factories> factories_; | 159 scoped_refptr<Factories> factories_; |
176 | 160 |
177 // Proxies calls from |vda_| to |gvd_loop_proxy_| and used to safely detach | 161 // Populated during Initialize() (on success) and unchanged until an error |
178 // during shutdown. | 162 // occurs. |
179 scoped_refptr<VDAClientProxy> client_proxy_; | |
180 | |
181 // Populated during Initialize() via SetVDA() (on success) and unchanged | |
182 // until an error occurs. | |
183 scoped_ptr<VideoDecodeAccelerator> vda_; | 163 scoped_ptr<VideoDecodeAccelerator> vda_; |
184 // Used to post tasks from the GVD thread to the VDA thread safely. | |
185 base::WeakPtr<VideoDecodeAccelerator> weak_vda_; | |
186 | 164 |
187 // Callbacks that are !is_null() only during their respective operation being | 165 // Callbacks that are !is_null() only during their respective operation being |
188 // asynchronously executed. | 166 // asynchronously executed. |
189 ReadCB pending_read_cb_; | 167 ReadCB pending_read_cb_; |
190 base::Closure pending_reset_cb_; | 168 base::Closure pending_reset_cb_; |
191 | 169 |
192 State state_; | 170 State state_; |
193 | 171 |
194 VideoDecoderConfig config_; | 172 VideoDecoderConfig config_; |
195 | 173 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 // Set during ProvidePictureBuffers(), used for checking and implementing | 217 // Set during ProvidePictureBuffers(), used for checking and implementing |
240 // HasAvailableOutputFrames(). | 218 // HasAvailableOutputFrames(). |
241 int available_pictures_; | 219 int available_pictures_; |
242 | 220 |
243 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); | 221 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); |
244 }; | 222 }; |
245 | 223 |
246 } // namespace media | 224 } // namespace media |
247 | 225 |
248 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ | 226 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ |
OLD | NEW |