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

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

Issue 12989009: Remove reference counting from media::VideoDecoder and friends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « media/filters/ffmpeg_video_decoder_unittest.cc ('k') | media/filters/gpu_video_decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/memory/weak_ptr.h"
13 #include "media/base/pipeline_status.h" 14 #include "media/base/pipeline_status.h"
14 #include "media/base/demuxer_stream.h" 15 #include "media/base/demuxer_stream.h"
15 #include "media/base/video_decoder.h" 16 #include "media/base/video_decoder.h"
16 #include "media/video/video_decode_accelerator.h" 17 #include "media/video/video_decode_accelerator.h"
17 18
18 template <class T> class scoped_refptr; 19 template <class T> class scoped_refptr;
19 20
20 namespace base { 21 namespace base {
21 class MessageLoopProxy; 22 class MessageLoopProxy;
22 class SharedMemory; 23 class SharedMemory;
23 } 24 }
24 25
25 class SkBitmap; 26 class SkBitmap;
26 27
27 namespace media { 28 namespace media {
28 29
29 class DecoderBuffer; 30 class DecoderBuffer;
31 class VDAClientProxy;
30 32
31 // GPU-accelerated video decoder implementation. Relies on 33 // GPU-accelerated video decoder implementation. Relies on
32 // AcceleratedVideoDecoderMsg_Decode and friends. 34 // AcceleratedVideoDecoderMsg_Decode and friends.
33 // All methods internally trampoline to the |message_loop| passed to the ctor. 35 // All methods internally trampoline to the |message_loop| passed to the ctor.
34 class MEDIA_EXPORT GpuVideoDecoder 36 class MEDIA_EXPORT GpuVideoDecoder
35 : public VideoDecoder, 37 : public VideoDecoder,
36 public VideoDecodeAccelerator::Client { 38 public VideoDecodeAccelerator::Client {
37 public: 39 public:
38 // Helper interface for specifying factories needed to instantiate a 40 // Helper interface for specifying factories needed to instantiate a
39 // GpuVideoDecoder. 41 // GpuVideoDecoder.
(...skipping 17 matching lines...) Expand all
57 // Close()ing the returned pointer. 59 // Close()ing the returned pointer.
58 virtual base::SharedMemory* CreateSharedMemory(size_t size) = 0; 60 virtual base::SharedMemory* CreateSharedMemory(size_t size) = 0;
59 61
60 // Returns the message loop the VideoDecodeAccelerator runs on. 62 // Returns the message loop the VideoDecodeAccelerator runs on.
61 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() = 0; 63 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() = 0;
62 64
63 // Abort any outstanding factory operations and error any future 65 // Abort any outstanding factory operations and error any future
64 // attempts at factory operations 66 // attempts at factory operations
65 virtual void Abort() = 0; 67 virtual void Abort() = 0;
66 68
67 // Returns true if Abort has been called. 69 // Returns true if Abort() has been called.
68 virtual bool IsAborted() = 0; 70 virtual bool IsAborted() = 0;
69 71
70 protected: 72 protected:
71 friend class base::RefCountedThreadSafe<Factories>; 73 friend class base::RefCountedThreadSafe<Factories>;
72 virtual ~Factories(); 74 virtual ~Factories();
73 }; 75 };
74 76
75 GpuVideoDecoder(const scoped_refptr<base::MessageLoopProxy>& message_loop, 77 GpuVideoDecoder(const scoped_refptr<base::MessageLoopProxy>& message_loop,
76 const scoped_refptr<Factories>& factories); 78 const scoped_refptr<Factories>& factories);
77 79
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 const scoped_refptr<VideoFrame>& frame); 134 const scoped_refptr<VideoFrame>& frame);
133 135
134 // Indicate the picturebuffer can be reused by the decoder. 136 // Indicate the picturebuffer can be reused by the decoder.
135 void ReusePictureBuffer(int64 picture_buffer_id); 137 void ReusePictureBuffer(int64 picture_buffer_id);
136 138
137 void RecordBufferData( 139 void RecordBufferData(
138 const BitstreamBuffer& bitstream_buffer, const DecoderBuffer& buffer); 140 const BitstreamBuffer& bitstream_buffer, const DecoderBuffer& buffer);
139 void GetBufferData(int32 id, base::TimeDelta* timetamp, 141 void GetBufferData(int32 id, base::TimeDelta* timetamp,
140 gfx::Rect* visible_rect, gfx::Size* natural_size); 142 gfx::Rect* visible_rect, gfx::Size* natural_size);
141 143
142 // Set |vda_| and |weak_vda_| on the VDA thread (in practice the render 144 // Sets |vda_| and |weak_vda_| on the GVD thread and runs |status_cb|.
143 // thread). 145 void SetVDA(const PipelineStatusCB& status_cb,
144 void SetVDA(VideoDecodeAccelerator* vda); 146 VideoDecodeAccelerator* vda,
147 base::WeakPtr<VideoDecodeAccelerator> weak_vda);
145 148
146 // Call VDA::Destroy() on |vda_loop_proxy_| ensuring that |this| outlives the 149 // Call VDA::Destroy() on |vda_loop_proxy_| ensuring that |this| outlives the
147 // Destroy() call. 150 // Destroy() call.
148 void DestroyVDA(); 151 void DestroyVDA();
149 152
150 // A shared memory segment and its allocated size. 153 // A shared memory segment and its allocated size.
151 struct SHMBuffer { 154 struct SHMBuffer {
152 SHMBuffer(base::SharedMemory* m, size_t s); 155 SHMBuffer(base::SharedMemory* m, size_t s);
153 ~SHMBuffer(); 156 ~SHMBuffer();
154 base::SharedMemory* shm; 157 base::SharedMemory* shm;
(...skipping 10 matching lines...) Expand all
165 void DestroyTextures(); 168 void DestroyTextures();
166 169
167 StatisticsCB statistics_cb_; 170 StatisticsCB statistics_cb_;
168 171
169 // Pointer to the demuxer stream that will feed us compressed buffers. 172 // Pointer to the demuxer stream that will feed us compressed buffers.
170 scoped_refptr<DemuxerStream> demuxer_stream_; 173 scoped_refptr<DemuxerStream> demuxer_stream_;
171 174
172 // MessageLoop on which to fire callbacks and trampoline calls to this class 175 // MessageLoop on which to fire callbacks and trampoline calls to this class
173 // if they arrive on other loops. 176 // if they arrive on other loops.
174 scoped_refptr<base::MessageLoopProxy> gvd_loop_proxy_; 177 scoped_refptr<base::MessageLoopProxy> gvd_loop_proxy_;
178 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_;
179 base::WeakPtr<GpuVideoDecoder> weak_this_;
175 180
176 // Message loop on which to makes all calls to vda_. (beware this loop may be 181 // Message loop on which to makes all calls to vda_. (beware this loop may be
177 // paused during the Pause/Flush/Stop dance PipelineImpl::Stop() goes 182 // paused during the Pause/Flush/Stop dance PipelineImpl::Stop() goes
178 // through). 183 // through).
179 scoped_refptr<base::MessageLoopProxy> vda_loop_proxy_; 184 scoped_refptr<base::MessageLoopProxy> vda_loop_proxy_;
180 185
181 scoped_refptr<Factories> factories_; 186 scoped_refptr<Factories> factories_;
182 187
188 // Proxies calls from |vda_| to |gvd_loop_proxy_| and used to safely detach
189 // during shutdown.
190 scoped_refptr<VDAClientProxy> client_proxy_;
191
183 // Populated during Initialize() via SetVDA() (on success) and unchanged 192 // Populated during Initialize() via SetVDA() (on success) and unchanged
184 // until an error occurs 193 // until an error occurs.
185 scoped_ptr<VideoDecodeAccelerator> vda_; 194 scoped_ptr<VideoDecodeAccelerator> vda_;
186 // Used to post tasks from the GVD thread to the VDA thread safely. 195 // Used to post tasks from the GVD thread to the VDA thread safely.
187 base::WeakPtr<VideoDecodeAccelerator> weak_vda_; 196 base::WeakPtr<VideoDecodeAccelerator> weak_vda_;
188 197
189 // Callbacks that are !is_null() only during their respective operation being 198 // Callbacks that are !is_null() only during their respective operation being
190 // asynchronously executed. 199 // asynchronously executed.
191 ReadCB pending_read_cb_; 200 ReadCB pending_read_cb_;
192 base::Closure pending_reset_cb_; 201 base::Closure pending_reset_cb_;
193 202
194 State state_; 203 State state_;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 // Set during ProvidePictureBuffers(), used for checking and implementing 246 // Set during ProvidePictureBuffers(), used for checking and implementing
238 // HasAvailableOutputFrames(). 247 // HasAvailableOutputFrames().
239 int available_pictures_; 248 int available_pictures_;
240 249
241 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); 250 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder);
242 }; 251 };
243 252
244 } // namespace media 253 } // namespace media
245 254
246 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ 255 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_video_decoder_unittest.cc ('k') | media/filters/gpu_video_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698