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

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

Issue 331863004: Revert 276344 "Add callback in VideoDecoder and AudioDecoder to ..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2049/src/
Patch Set: Created 6 years, 6 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 <set> 10 #include <set>
(...skipping 26 matching lines...) Expand all
37 : public VideoDecoder, 37 : public VideoDecoder,
38 public VideoDecodeAccelerator::Client { 38 public VideoDecodeAccelerator::Client {
39 public: 39 public:
40 explicit GpuVideoDecoder( 40 explicit GpuVideoDecoder(
41 const scoped_refptr<GpuVideoAcceleratorFactories>& factories, 41 const scoped_refptr<GpuVideoAcceleratorFactories>& factories,
42 const scoped_refptr<MediaLog>& media_log); 42 const scoped_refptr<MediaLog>& media_log);
43 43
44 // VideoDecoder implementation. 44 // VideoDecoder implementation.
45 virtual void Initialize(const VideoDecoderConfig& config, 45 virtual void Initialize(const VideoDecoderConfig& config,
46 bool live_mode, 46 bool live_mode,
47 const PipelineStatusCB& status_cb, 47 const PipelineStatusCB& status_cb) OVERRIDE;
48 const OutputCB& output_cb) OVERRIDE;
49 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, 48 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer,
50 const DecodeCB& decode_cb) OVERRIDE; 49 const DecodeCB& decode_cb) OVERRIDE;
51 virtual void Reset(const base::Closure& closure) OVERRIDE; 50 virtual void Reset(const base::Closure& closure) OVERRIDE;
52 virtual void Stop() OVERRIDE; 51 virtual void Stop() OVERRIDE;
53 virtual bool NeedsBitstreamConversion() const OVERRIDE; 52 virtual bool NeedsBitstreamConversion() const OVERRIDE;
54 virtual bool CanReadWithoutStalling() const OVERRIDE; 53 virtual bool CanReadWithoutStalling() const OVERRIDE;
55 virtual int GetMaxDecodeRequests() const OVERRIDE;
56 54
57 // VideoDecodeAccelerator::Client implementation. 55 // VideoDecodeAccelerator::Client implementation.
58 virtual void ProvidePictureBuffers(uint32 count, 56 virtual void ProvidePictureBuffers(uint32 count,
59 const gfx::Size& size, 57 const gfx::Size& size,
60 uint32 texture_target) OVERRIDE; 58 uint32 texture_target) OVERRIDE;
61 virtual void DismissPictureBuffer(int32 id) OVERRIDE; 59 virtual void DismissPictureBuffer(int32 id) OVERRIDE;
62 virtual void PictureReady(const media::Picture& picture) OVERRIDE; 60 virtual void PictureReady(const media::Picture& picture) OVERRIDE;
63 virtual void NotifyEndOfBitstreamBuffer(int32 id) OVERRIDE; 61 virtual void NotifyEndOfBitstreamBuffer(int32 id) OVERRIDE;
64 virtual void NotifyFlushDone() OVERRIDE; 62 virtual void NotifyFlushDone() OVERRIDE;
65 virtual void NotifyResetDone() OVERRIDE; 63 virtual void NotifyResetDone() OVERRIDE;
(...skipping 12 matching lines...) Expand all
78 76
79 // A shared memory segment and its allocated size. 77 // A shared memory segment and its allocated size.
80 struct SHMBuffer { 78 struct SHMBuffer {
81 SHMBuffer(base::SharedMemory* m, size_t s); 79 SHMBuffer(base::SharedMemory* m, size_t s);
82 ~SHMBuffer(); 80 ~SHMBuffer();
83 base::SharedMemory* shm; 81 base::SharedMemory* shm;
84 size_t size; 82 size_t size;
85 }; 83 };
86 84
87 // A SHMBuffer and the DecoderBuffer its data came from. 85 // A SHMBuffer and the DecoderBuffer its data came from.
88 struct PendingDecoderBuffer { 86 struct BufferPair {
89 PendingDecoderBuffer(SHMBuffer* s, 87 BufferPair(SHMBuffer* s, const scoped_refptr<DecoderBuffer>& b);
90 const scoped_refptr<DecoderBuffer>& b, 88 ~BufferPair();
91 const DecodeCB& done_cb);
92 ~PendingDecoderBuffer();
93 SHMBuffer* shm_buffer; 89 SHMBuffer* shm_buffer;
94 scoped_refptr<DecoderBuffer> buffer; 90 scoped_refptr<DecoderBuffer> buffer;
95 DecodeCB done_cb;
96 }; 91 };
97 92
98 typedef std::map<int32, PictureBuffer> PictureBufferMap; 93 typedef std::map<int32, PictureBuffer> PictureBufferMap;
99 94
100 void DeliverFrame(const scoped_refptr<VideoFrame>& frame); 95 // Return true if more decode work can be piled on to the VDA.
96 bool CanMoreDecodeWorkBeDone();
97
98 // Enqueue a frame for later delivery (or drop it on the floor if a
99 // vda->Reset() is in progress) and trigger out-of-line delivery of the oldest
100 // ready frame to the client if there is a pending read. A NULL |frame|
101 // merely triggers delivery, and requires the ready_video_frames_ queue not be
102 // empty.
103 void EnqueueFrameAndTriggerFrameDelivery(
104 const scoped_refptr<VideoFrame>& frame);
101 105
102 // Static method is to allow it to run even after GVD is deleted. 106 // Static method is to allow it to run even after GVD is deleted.
103 static void ReleaseMailbox( 107 static void ReleaseMailbox(
104 base::WeakPtr<GpuVideoDecoder> decoder, 108 base::WeakPtr<GpuVideoDecoder> decoder,
105 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories, 109 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories,
106 int64 picture_buffer_id, 110 int64 picture_buffer_id,
107 uint32 texture_id, 111 uint32 texture_id,
108 const std::vector<uint32>& release_sync_points); 112 const std::vector<uint32>& release_sync_points);
109 // Indicate the picture buffer can be reused by the decoder. 113 // Indicate the picture buffer can be reused by the decoder.
110 void ReusePictureBuffer(int64 picture_buffer_id); 114 void ReusePictureBuffer(int64 picture_buffer_id);
(...skipping 19 matching lines...) Expand all
130 void DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() const; 134 void DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() const;
131 135
132 bool needs_bitstream_conversion_; 136 bool needs_bitstream_conversion_;
133 137
134 scoped_refptr<GpuVideoAcceleratorFactories> factories_; 138 scoped_refptr<GpuVideoAcceleratorFactories> factories_;
135 139
136 // Populated during Initialize() (on success) and unchanged until an error 140 // Populated during Initialize() (on success) and unchanged until an error
137 // occurs. 141 // occurs.
138 scoped_ptr<VideoDecodeAccelerator> vda_; 142 scoped_ptr<VideoDecodeAccelerator> vda_;
139 143
140 OutputCB output_cb_; 144 // Callbacks that are !is_null() only during their respective operation being
141 145 // asynchronously executed.
142 DecodeCB eos_decode_cb_; 146 DecodeCB pending_decode_cb_;
143
144 // Not null only during reset.
145 base::Closure pending_reset_cb_; 147 base::Closure pending_reset_cb_;
146 148
147 State state_; 149 State state_;
148 150
149 VideoDecoderConfig config_; 151 VideoDecoderConfig config_;
150 152
151 // Shared-memory buffer pool. Since allocating SHM segments requires a 153 // Shared-memory buffer pool. Since allocating SHM segments requires a
152 // round-trip to the browser process, we keep allocation out of the 154 // round-trip to the browser process, we keep allocation out of the
153 // steady-state of the decoder. 155 // steady-state of the decoder.
154 std::vector<SHMBuffer*> available_shm_segments_; 156 std::vector<SHMBuffer*> available_shm_segments_;
155 157
156 scoped_refptr<MediaLog> media_log_; 158 scoped_refptr<MediaLog> media_log_;
157 159
158 std::map<int32, PendingDecoderBuffer> bitstream_buffers_in_decoder_; 160 std::map<int32, BufferPair> bitstream_buffers_in_decoder_;
159 PictureBufferMap assigned_picture_buffers_; 161 PictureBufferMap assigned_picture_buffers_;
160 // PictureBuffers given to us by VDA via PictureReady, which we sent forward 162 // PictureBuffers given to us by VDA via PictureReady, which we sent forward
161 // as VideoFrames to be rendered via decode_cb_, and which will be returned 163 // as VideoFrames to be rendered via decode_cb_, and which will be returned
162 // to us via ReusePictureBuffer. 164 // to us via ReusePictureBuffer.
163 typedef std::map<int32 /* picture_buffer_id */, uint32 /* texture_id */> 165 typedef std::map<int32 /* picture_buffer_id */, uint32 /* texture_id */>
164 PictureBufferTextureMap; 166 PictureBufferTextureMap;
165 PictureBufferTextureMap picture_buffers_at_display_; 167 PictureBufferTextureMap picture_buffers_at_display_;
166 168
167 // The texture target used for decoded pictures. 169 // The texture target used for decoded pictures.
168 uint32 decoder_texture_target_; 170 uint32 decoder_texture_target_;
169 171
170 struct BufferData { 172 struct BufferData {
171 BufferData(int32 bbid, base::TimeDelta ts, const gfx::Rect& visible_rect, 173 BufferData(int32 bbid, base::TimeDelta ts, const gfx::Rect& visible_rect,
172 const gfx::Size& natural_size); 174 const gfx::Size& natural_size);
173 ~BufferData(); 175 ~BufferData();
174 int32 bitstream_buffer_id; 176 int32 bitstream_buffer_id;
175 base::TimeDelta timestamp; 177 base::TimeDelta timestamp;
176 gfx::Rect visible_rect; 178 gfx::Rect visible_rect;
177 gfx::Size natural_size; 179 gfx::Size natural_size;
178 }; 180 };
179 std::list<BufferData> input_buffer_data_; 181 std::list<BufferData> input_buffer_data_;
180 182
181 // picture_buffer_id and the frame wrapping the corresponding Picture, for 183 // picture_buffer_id and the frame wrapping the corresponding Picture, for
182 // frames that have been decoded but haven't been requested by a Decode() yet. 184 // frames that have been decoded but haven't been requested by a Decode() yet.
185 std::list<scoped_refptr<VideoFrame> > ready_video_frames_;
183 int32 next_picture_buffer_id_; 186 int32 next_picture_buffer_id_;
184 int32 next_bitstream_buffer_id_; 187 int32 next_bitstream_buffer_id_;
185 188
186 // Set during ProvidePictureBuffers(), used for checking and implementing 189 // Set during ProvidePictureBuffers(), used for checking and implementing
187 // HasAvailableOutputFrames(). 190 // HasAvailableOutputFrames().
188 int available_pictures_; 191 int available_pictures_;
189 192
190 // Bound to factories_->GetMessageLoop(). 193 // Bound to factories_->GetMessageLoop().
191 // NOTE: Weak pointers must be invalidated before all other member variables. 194 // NOTE: Weak pointers must be invalidated before all other member variables.
192 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_; 195 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_;
193 196
194 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); 197 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder);
195 }; 198 };
196 199
197 } // namespace media 200 } // namespace media
198 201
199 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ 202 #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