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

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

Issue 14348007: Reland: Remove reference counting from media::VideoDecoder and friends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 const scoped_refptr<VideoFrame>& frame); 129 const scoped_refptr<VideoFrame>& frame);
128 130
129 // Indicate the picture buffer can be reused by the decoder. 131 // Indicate the picture buffer can be reused by the decoder.
130 void ReusePictureBuffer(int64 picture_buffer_id); 132 void ReusePictureBuffer(int64 picture_buffer_id);
131 133
132 void RecordBufferData( 134 void RecordBufferData(
133 const BitstreamBuffer& bitstream_buffer, const DecoderBuffer& buffer); 135 const BitstreamBuffer& bitstream_buffer, const DecoderBuffer& buffer);
134 void GetBufferData(int32 id, base::TimeDelta* timetamp, 136 void GetBufferData(int32 id, base::TimeDelta* timetamp,
135 gfx::Rect* visible_rect, gfx::Size* natural_size); 137 gfx::Rect* visible_rect, gfx::Size* natural_size);
136 138
137 // Set |vda_| and |weak_vda_| on the VDA thread (in practice the render 139 // Sets |vda_| and |weak_vda_| on the GVD thread and runs |status_cb|.
138 // thread). 140 void SetVDA(const PipelineStatusCB& status_cb,
139 void SetVDA(VideoDecodeAccelerator* vda); 141 VideoDecodeAccelerator* vda,
142 base::WeakPtr<VideoDecodeAccelerator> weak_vda);
140 143
141 // Call VDA::Destroy() on |vda_loop_proxy_| ensuring that |this| outlives the 144 // Call VDA::Destroy() on |vda_loop_proxy_| ensuring that |this| outlives the
142 // Destroy() call. 145 // Destroy() call.
143 void DestroyVDA(); 146 void DestroyVDA();
144 147
145 // A shared memory segment and its allocated size. 148 // A shared memory segment and its allocated size.
146 struct SHMBuffer { 149 struct SHMBuffer {
147 SHMBuffer(base::SharedMemory* m, size_t s); 150 SHMBuffer(base::SharedMemory* m, size_t s);
148 ~SHMBuffer(); 151 ~SHMBuffer();
149 base::SharedMemory* shm; 152 base::SharedMemory* shm;
(...skipping 10 matching lines...) Expand all
160 void DestroyTextures(); 163 void DestroyTextures();
161 164
162 StatisticsCB statistics_cb_; 165 StatisticsCB statistics_cb_;
163 166
164 // Pointer to the demuxer stream that will feed us compressed buffers. 167 // Pointer to the demuxer stream that will feed us compressed buffers.
165 scoped_refptr<DemuxerStream> demuxer_stream_; 168 scoped_refptr<DemuxerStream> demuxer_stream_;
166 169
167 // MessageLoop on which to fire callbacks and trampoline calls to this class 170 // MessageLoop on which to fire callbacks and trampoline calls to this class
168 // if they arrive on other loops. 171 // if they arrive on other loops.
169 scoped_refptr<base::MessageLoopProxy> gvd_loop_proxy_; 172 scoped_refptr<base::MessageLoopProxy> gvd_loop_proxy_;
173 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_;
174 base::WeakPtr<GpuVideoDecoder> weak_this_;
170 175
171 // Message loop on which to makes all calls to vda_. (beware this loop may be 176 // Message loop on which to makes all calls to vda_. (beware this loop may be
172 // paused during the Pause/Flush/Stop dance PipelineImpl::Stop() goes 177 // paused during the Pause/Flush/Stop dance PipelineImpl::Stop() goes
173 // through). 178 // through).
174 scoped_refptr<base::MessageLoopProxy> vda_loop_proxy_; 179 scoped_refptr<base::MessageLoopProxy> vda_loop_proxy_;
175 180
176 scoped_refptr<Factories> factories_; 181 scoped_refptr<Factories> factories_;
177 182
183 // Proxies calls from |vda_| to |gvd_loop_proxy_| and used to safely detach
184 // during shutdown.
185 scoped_refptr<VDAClientProxy> client_proxy_;
186
178 // Populated during Initialize() via SetVDA() (on success) and unchanged 187 // Populated during Initialize() via SetVDA() (on success) and unchanged
179 // until an error occurs 188 // until an error occurs.
180 scoped_ptr<VideoDecodeAccelerator> vda_; 189 scoped_ptr<VideoDecodeAccelerator> vda_;
181 // Used to post tasks from the GVD thread to the VDA thread safely. 190 // Used to post tasks from the GVD thread to the VDA thread safely.
182 base::WeakPtr<VideoDecodeAccelerator> weak_vda_; 191 base::WeakPtr<VideoDecodeAccelerator> weak_vda_;
183 192
184 // Callbacks that are !is_null() only during their respective operation being 193 // Callbacks that are !is_null() only during their respective operation being
185 // asynchronously executed. 194 // asynchronously executed.
186 ReadCB pending_read_cb_; 195 ReadCB pending_read_cb_;
187 base::Closure pending_reset_cb_; 196 base::Closure pending_reset_cb_;
188 197
189 State state_; 198 State state_;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // Set during ProvidePictureBuffers(), used for checking and implementing 241 // Set during ProvidePictureBuffers(), used for checking and implementing
233 // HasAvailableOutputFrames(). 242 // HasAvailableOutputFrames().
234 int available_pictures_; 243 int available_pictures_;
235 244
236 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); 245 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder);
237 }; 246 };
238 247
239 } // namespace media 248 } // namespace media
240 249
241 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ 250 #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