Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: media/filters/gpu_video_decoder.h

Issue 19534002: Make RendererGpuVideoDecoderFactories live on arbitrary threads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.
40 // TODO(wuchengli): move this out of GpuVideoDecoder because RTCVideoDecoder
Ami GONE FROM CHROMIUM 2013/07/22 19:46:21 Rebase makes this unnecessary?
wuchengli 2013/07/23 16:29:28 I couldn't submit that CL today because of submit
41 // also uses this.
42 class MEDIA_EXPORT Factories : public base::RefCountedThreadSafe<Factories> { 42 class MEDIA_EXPORT Factories : public base::RefCountedThreadSafe<Factories> {
43 public: 43 public:
44 // Caller owns returned pointer. 44 // Caller owns returned pointer.
45 virtual VideoDecodeAccelerator* CreateVideoDecodeAccelerator( 45 virtual VideoDecodeAccelerator* CreateVideoDecodeAccelerator(
46 VideoCodecProfile, VideoDecodeAccelerator::Client*) = 0; 46 VideoCodecProfile, VideoDecodeAccelerator::Client*) = 0;
47 47
48 // Allocate & delete native textures. 48 // Allocate & delete native textures.
49 virtual uint32 CreateTextures(int32 count, const gfx::Size& size, 49 virtual uint32 CreateTextures(int32 count, const gfx::Size& size,
50 std::vector<uint32>* texture_ids, 50 std::vector<uint32>* texture_ids,
51 std::vector<gpu::Mailbox>* texture_mailboxes, 51 std::vector<gpu::Mailbox>* texture_mailboxes,
(...skipping 13 matching lines...) Expand all
65 // Returns the message loop the VideoDecodeAccelerator runs on. 65 // Returns the message loop the VideoDecodeAccelerator runs on.
66 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() = 0; 66 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() = 0;
67 67
68 // Abort any outstanding factory operations and error any future 68 // Abort any outstanding factory operations and error any future
69 // attempts at factory operations 69 // attempts at factory operations
70 virtual void Abort() = 0; 70 virtual void Abort() = 0;
71 71
72 // Returns true if Abort() has been called. 72 // Returns true if Abort() has been called.
73 virtual bool IsAborted() = 0; 73 virtual bool IsAborted() = 0;
74 74
75 // Makes a copy of |this|.
76 virtual scoped_refptr<Factories> Clone() = 0;
77
75 protected: 78 protected:
76 friend class base::RefCountedThreadSafe<Factories>; 79 friend class base::RefCountedThreadSafe<Factories>;
77 virtual ~Factories(); 80 virtual ~Factories();
78 }; 81 };
79 82
83 // |message_loop| should be the same as the one running |factories|.
Ami GONE FROM CHROMIUM 2013/07/22 19:46:21 Why not drop this param and just use factories->Ge
wuchengli 2013/07/23 16:29:28 That was recommended by Andrew. https://codereview
80 GpuVideoDecoder(const scoped_refptr<base::MessageLoopProxy>& message_loop, 84 GpuVideoDecoder(const scoped_refptr<base::MessageLoopProxy>& message_loop,
81 const scoped_refptr<Factories>& factories); 85 const scoped_refptr<Factories>& factories);
82 86
83 // VideoDecoder implementation. 87 // VideoDecoder implementation.
84 virtual void Initialize(const VideoDecoderConfig& config, 88 virtual void Initialize(const VideoDecoderConfig& config,
85 const PipelineStatusCB& status_cb) OVERRIDE; 89 const PipelineStatusCB& status_cb) OVERRIDE;
86 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, 90 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer,
87 const ReadCB& read_cb) OVERRIDE; 91 const ReadCB& read_cb) OVERRIDE;
88 virtual void Reset(const base::Closure& closure) OVERRIDE; 92 virtual void Reset(const base::Closure& closure) OVERRIDE;
89 virtual void Stop(const base::Closure& closure) OVERRIDE; 93 virtual void Stop(const base::Closure& closure) OVERRIDE;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 const scoped_refptr<VideoFrame>& frame); 130 const scoped_refptr<VideoFrame>& frame);
127 131
128 // Indicate the picture buffer can be reused by the decoder. 132 // Indicate the picture buffer can be reused by the decoder.
129 void ReusePictureBuffer(int64 picture_buffer_id, uint32 sync_point); 133 void ReusePictureBuffer(int64 picture_buffer_id, uint32 sync_point);
130 134
131 void RecordBufferData( 135 void RecordBufferData(
132 const BitstreamBuffer& bitstream_buffer, const DecoderBuffer& buffer); 136 const BitstreamBuffer& bitstream_buffer, const DecoderBuffer& buffer);
133 void GetBufferData(int32 id, base::TimeDelta* timetamp, 137 void GetBufferData(int32 id, base::TimeDelta* timetamp,
134 gfx::Rect* visible_rect, gfx::Size* natural_size); 138 gfx::Rect* visible_rect, gfx::Size* natural_size);
135 139
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(); 140 void DestroyVDA();
144 141
145 // A shared memory segment and its allocated size. 142 // A shared memory segment and its allocated size.
146 struct SHMBuffer { 143 struct SHMBuffer {
147 SHMBuffer(base::SharedMemory* m, size_t s); 144 SHMBuffer(base::SharedMemory* m, size_t s);
148 ~SHMBuffer(); 145 ~SHMBuffer();
149 base::SharedMemory* shm; 146 base::SharedMemory* shm;
150 size_t size; 147 size_t size;
151 }; 148 };
152 149
153 // Request a shared-memory segment of at least |min_size| bytes. Will 150 // Request a shared-memory segment of at least |min_size| bytes. Will
154 // allocate as necessary. Caller does not own returned pointer. 151 // allocate as necessary. Caller does not own returned pointer.
155 SHMBuffer* GetSHM(size_t min_size); 152 SHMBuffer* GetSHM(size_t min_size);
156 153
157 // Return a shared-memory segment to the available pool. 154 // Return a shared-memory segment to the available pool.
158 void PutSHM(SHMBuffer* shm_buffer); 155 void PutSHM(SHMBuffer* shm_buffer);
159 156
160 void DestroyTextures(); 157 void DestroyTextures();
161 158
162 bool needs_bitstream_conversion_; 159 bool needs_bitstream_conversion_;
163 160
164 // Message loop on which to fire callbacks and trampoline calls to this class 161 // Message loop which this class and |factories_| run on.
165 // if they arrive on other loops.
166 scoped_refptr<base::MessageLoopProxy> gvd_loop_proxy_; 162 scoped_refptr<base::MessageLoopProxy> gvd_loop_proxy_;
167 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_; 163 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_;
168 base::WeakPtr<GpuVideoDecoder> weak_this_; 164 base::WeakPtr<GpuVideoDecoder> weak_this_;
169 165
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_; 166 scoped_refptr<Factories> factories_;
176 167
177 // Proxies calls from |vda_| to |gvd_loop_proxy_| and used to safely detach 168 // Populated during Initialize() (on success) and unchanged until an error
178 // during shutdown. 169 // 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_; 170 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 171
187 // Callbacks that are !is_null() only during their respective operation being 172 // Callbacks that are !is_null() only during their respective operation being
188 // asynchronously executed. 173 // asynchronously executed.
189 ReadCB pending_read_cb_; 174 ReadCB pending_read_cb_;
190 base::Closure pending_reset_cb_; 175 base::Closure pending_reset_cb_;
191 176
192 State state_; 177 State state_;
193 178
194 VideoDecoderConfig config_; 179 VideoDecoderConfig config_;
195 180
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // Set during ProvidePictureBuffers(), used for checking and implementing 224 // Set during ProvidePictureBuffers(), used for checking and implementing
240 // HasAvailableOutputFrames(). 225 // HasAvailableOutputFrames().
241 int available_pictures_; 226 int available_pictures_;
242 227
243 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); 228 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder);
244 }; 229 };
245 230
246 } // namespace media 231 } // namespace media
247 232
248 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ 233 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698