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> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "media/base/pipeline_status.h" | 15 #include "media/base/pipeline_status.h" |
16 #include "media/base/video_decoder.h" | 16 #include "media/base/video_decoder.h" |
17 #include "media/video/video_decode_accelerator.h" | 17 #include "media/video/video_decode_accelerator.h" |
18 | 18 |
19 template <class T> class scoped_refptr; | 19 template <class T> class scoped_refptr; |
20 | 20 |
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; | |
27 | |
28 namespace media { | 26 namespace media { |
29 | 27 |
30 class DecoderBuffer; | 28 class DecoderBuffer; |
| 29 class GpuVideoDecoderFactories; |
31 class VDAClientProxy; | 30 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. | 34 // All methods internally trampoline to the |message_loop| passed to the ctor. |
36 class MEDIA_EXPORT GpuVideoDecoder | 35 class MEDIA_EXPORT GpuVideoDecoder |
37 : public VideoDecoder, | 36 : public VideoDecoder, |
38 public VideoDecodeAccelerator::Client { | 37 public VideoDecodeAccelerator::Client { |
39 public: | 38 public: |
40 // Helper interface for specifying factories needed to instantiate a | |
41 // GpuVideoDecoder. | |
42 class MEDIA_EXPORT Factories : public base::RefCountedThreadSafe<Factories> { | |
43 public: | |
44 // Caller owns returned pointer. | |
45 virtual VideoDecodeAccelerator* CreateVideoDecodeAccelerator( | |
46 VideoCodecProfile, VideoDecodeAccelerator::Client*) = 0; | |
47 | |
48 // Allocate & delete native textures. | |
49 virtual uint32 CreateTextures(int32 count, const gfx::Size& size, | |
50 std::vector<uint32>* texture_ids, | |
51 std::vector<gpu::Mailbox>* texture_mailboxes, | |
52 uint32 texture_target) = 0; | |
53 virtual void DeleteTexture(uint32 texture_id) = 0; | |
54 | |
55 virtual void WaitSyncPoint(uint32 sync_point) = 0; | |
56 | |
57 // Read pixels from a native texture and store into |pixels| as RGBA. | |
58 virtual void ReadPixels(uint32 texture_id, uint32 texture_target, | |
59 const gfx::Size& size, const SkBitmap& pixels) = 0; | |
60 | |
61 // Allocate & return a shared memory segment. Caller is responsible for | |
62 // Close()ing the returned pointer. | |
63 virtual base::SharedMemory* CreateSharedMemory(size_t size) = 0; | |
64 | |
65 // Returns the message loop the VideoDecodeAccelerator runs on. | |
66 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() = 0; | |
67 | |
68 // Abort any outstanding factory operations and error any future | |
69 // attempts at factory operations | |
70 virtual void Abort() = 0; | |
71 | |
72 // Returns true if Abort() has been called. | |
73 virtual bool IsAborted() = 0; | |
74 | |
75 protected: | |
76 friend class base::RefCountedThreadSafe<Factories>; | |
77 virtual ~Factories(); | |
78 }; | |
79 | |
80 GpuVideoDecoder(const scoped_refptr<base::MessageLoopProxy>& message_loop, | 39 GpuVideoDecoder(const scoped_refptr<base::MessageLoopProxy>& message_loop, |
81 const scoped_refptr<Factories>& factories); | 40 const scoped_refptr<GpuVideoDecoderFactories>& factories); |
82 | 41 |
83 // VideoDecoder implementation. | 42 // VideoDecoder implementation. |
84 virtual void Initialize(const VideoDecoderConfig& config, | 43 virtual void Initialize(const VideoDecoderConfig& config, |
85 const PipelineStatusCB& status_cb) OVERRIDE; | 44 const PipelineStatusCB& status_cb) OVERRIDE; |
86 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 45 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
87 const ReadCB& read_cb) OVERRIDE; | 46 const ReadCB& read_cb) OVERRIDE; |
88 virtual void Reset(const base::Closure& closure) OVERRIDE; | 47 virtual void Reset(const base::Closure& closure) OVERRIDE; |
89 virtual void Stop(const base::Closure& closure) OVERRIDE; | 48 virtual void Stop(const base::Closure& closure) OVERRIDE; |
90 virtual bool HasAlpha() const OVERRIDE; | 49 virtual bool HasAlpha() const OVERRIDE; |
91 virtual bool NeedsBitstreamConversion() const OVERRIDE; | 50 virtual bool NeedsBitstreamConversion() const OVERRIDE; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // if they arrive on other loops. | 124 // if they arrive on other loops. |
166 scoped_refptr<base::MessageLoopProxy> gvd_loop_proxy_; | 125 scoped_refptr<base::MessageLoopProxy> gvd_loop_proxy_; |
167 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_; | 126 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_; |
168 base::WeakPtr<GpuVideoDecoder> weak_this_; | 127 base::WeakPtr<GpuVideoDecoder> weak_this_; |
169 | 128 |
170 // Message loop on which to makes all calls to vda_. (beware this loop may be | 129 // 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 | 130 // paused during the Pause/Flush/Stop dance PipelineImpl::Stop() goes |
172 // through). | 131 // through). |
173 scoped_refptr<base::MessageLoopProxy> vda_loop_proxy_; | 132 scoped_refptr<base::MessageLoopProxy> vda_loop_proxy_; |
174 | 133 |
175 scoped_refptr<Factories> factories_; | 134 scoped_refptr<GpuVideoDecoderFactories> factories_; |
176 | 135 |
177 // Proxies calls from |vda_| to |gvd_loop_proxy_| and used to safely detach | 136 // Proxies calls from |vda_| to |gvd_loop_proxy_| and used to safely detach |
178 // during shutdown. | 137 // during shutdown. |
179 scoped_refptr<VDAClientProxy> client_proxy_; | 138 scoped_refptr<VDAClientProxy> client_proxy_; |
180 | 139 |
181 // Populated during Initialize() via SetVDA() (on success) and unchanged | 140 // Populated during Initialize() via SetVDA() (on success) and unchanged |
182 // until an error occurs. | 141 // until an error occurs. |
183 scoped_ptr<VideoDecodeAccelerator> vda_; | 142 scoped_ptr<VideoDecodeAccelerator> vda_; |
184 // Used to post tasks from the GVD thread to the VDA thread safely. | 143 // Used to post tasks from the GVD thread to the VDA thread safely. |
185 base::WeakPtr<VideoDecodeAccelerator> weak_vda_; | 144 base::WeakPtr<VideoDecodeAccelerator> weak_vda_; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // Set during ProvidePictureBuffers(), used for checking and implementing | 198 // Set during ProvidePictureBuffers(), used for checking and implementing |
240 // HasAvailableOutputFrames(). | 199 // HasAvailableOutputFrames(). |
241 int available_pictures_; | 200 int available_pictures_; |
242 | 201 |
243 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); | 202 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); |
244 }; | 203 }; |
245 | 204 |
246 } // namespace media | 205 } // namespace media |
247 | 206 |
248 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ | 207 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ |
OLD | NEW |