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 <deque> | 8 #include <deque> |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 MessageLoop* vda_loop, | 60 MessageLoop* vda_loop, |
61 const scoped_refptr<Factories>& factories); | 61 const scoped_refptr<Factories>& factories); |
62 | 62 |
63 // VideoDecoder implementation. | 63 // VideoDecoder implementation. |
64 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, | 64 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, |
65 const PipelineStatusCB& status_cb, | 65 const PipelineStatusCB& status_cb, |
66 const StatisticsCB& statistics_cb) OVERRIDE; | 66 const StatisticsCB& statistics_cb) OVERRIDE; |
67 virtual void Read(const ReadCB& read_cb) OVERRIDE; | 67 virtual void Read(const ReadCB& read_cb) OVERRIDE; |
68 virtual void Reset(const base::Closure& closure) OVERRIDE; | 68 virtual void Reset(const base::Closure& closure) OVERRIDE; |
69 virtual void Stop(const base::Closure& closure) OVERRIDE; | 69 virtual void Stop(const base::Closure& closure) OVERRIDE; |
70 virtual const gfx::Size& natural_size() OVERRIDE; | |
71 virtual bool HasAlpha() const OVERRIDE; | 70 virtual bool HasAlpha() const OVERRIDE; |
72 virtual void PrepareForShutdownHack() OVERRIDE; | 71 virtual void PrepareForShutdownHack() OVERRIDE; |
73 | 72 |
74 // VideoDecodeAccelerator::Client implementation. | 73 // VideoDecodeAccelerator::Client implementation. |
75 virtual void NotifyInitializeDone() OVERRIDE; | 74 virtual void NotifyInitializeDone() OVERRIDE; |
76 virtual void ProvidePictureBuffers(uint32 count, | 75 virtual void ProvidePictureBuffers(uint32 count, |
77 const gfx::Size& size, | 76 const gfx::Size& size, |
78 uint32 texture_target) OVERRIDE; | 77 uint32 texture_target) OVERRIDE; |
79 virtual void DismissPictureBuffer(int32 id) OVERRIDE; | 78 virtual void DismissPictureBuffer(int32 id) OVERRIDE; |
80 virtual void PictureReady(const media::Picture& picture) OVERRIDE; | 79 virtual void PictureReady(const media::Picture& picture) OVERRIDE; |
(...skipping 29 matching lines...) Expand all Loading... |
110 // vda->Reset() is in progress) and trigger out-of-line delivery of the oldest | 109 // vda->Reset() is in progress) and trigger out-of-line delivery of the oldest |
111 // ready frame to the client if there is a pending read. A NULL |frame| | 110 // ready frame to the client if there is a pending read. A NULL |frame| |
112 // merely triggers delivery, and requires the ready_video_frames_ queue not be | 111 // merely triggers delivery, and requires the ready_video_frames_ queue not be |
113 // empty. | 112 // empty. |
114 void EnqueueFrameAndTriggerFrameDelivery( | 113 void EnqueueFrameAndTriggerFrameDelivery( |
115 const scoped_refptr<VideoFrame>& frame); | 114 const scoped_refptr<VideoFrame>& frame); |
116 | 115 |
117 // Indicate the picturebuffer can be reused by the decoder. | 116 // Indicate the picturebuffer can be reused by the decoder. |
118 void ReusePictureBuffer(int64 picture_buffer_id); | 117 void ReusePictureBuffer(int64 picture_buffer_id); |
119 | 118 |
120 void RecordBufferTimeData( | 119 void RecordBufferData( |
121 const BitstreamBuffer& bitstream_buffer, const Buffer& buffer); | 120 const BitstreamBuffer& bitstream_buffer, const Buffer& buffer); |
122 base::TimeDelta GetBufferTimestamp(int32 id); | 121 void GetBufferData(int32 id, base::TimeDelta* timetamp, |
| 122 gfx::Size* natural_size); |
123 | 123 |
124 // Set |vda_| and |weak_vda_| on the VDA thread (in practice the render | 124 // Set |vda_| and |weak_vda_| on the VDA thread (in practice the render |
125 // thread). | 125 // thread). |
126 void SetVDA(VideoDecodeAccelerator* vda); | 126 void SetVDA(VideoDecodeAccelerator* vda); |
127 | 127 |
128 // A shared memory segment and its allocated size. | 128 // A shared memory segment and its allocated size. |
129 struct SHMBuffer { | 129 struct SHMBuffer { |
130 SHMBuffer(base::SharedMemory* m, size_t s); | 130 SHMBuffer(base::SharedMemory* m, size_t s); |
131 ~SHMBuffer(); | 131 ~SHMBuffer(); |
132 base::SharedMemory* shm; | 132 base::SharedMemory* shm; |
133 size_t size; | 133 size_t size; |
134 }; | 134 }; |
135 | 135 |
136 // Request a shared-memory segment of at least |min_size| bytes. Will | 136 // Request a shared-memory segment of at least |min_size| bytes. Will |
137 // allocate as necessary. Caller does not own returned pointer. | 137 // allocate as necessary. Caller does not own returned pointer. |
138 SHMBuffer* GetSHM(size_t min_size); | 138 SHMBuffer* GetSHM(size_t min_size); |
139 | 139 |
140 // Return a shared-memory segment to the available pool. | 140 // Return a shared-memory segment to the available pool. |
141 void PutSHM(SHMBuffer* shm_buffer); | 141 void PutSHM(SHMBuffer* shm_buffer); |
142 | 142 |
143 StatisticsCB statistics_cb_; | 143 StatisticsCB statistics_cb_; |
144 | 144 |
145 // TODO(scherkus): I think this should be calculated by VideoRenderers based | |
146 // on information provided by VideoDecoders (i.e., aspect ratio). | |
147 gfx::Size natural_size_; | |
148 | |
149 // Pointer to the demuxer stream that will feed us compressed buffers. | 145 // Pointer to the demuxer stream that will feed us compressed buffers. |
150 scoped_refptr<DemuxerStream> demuxer_stream_; | 146 scoped_refptr<DemuxerStream> demuxer_stream_; |
151 | 147 |
152 // MessageLoop on which to fire callbacks and trampoline calls to this class | 148 // MessageLoop on which to fire callbacks and trampoline calls to this class |
153 // if they arrive on other loops. | 149 // if they arrive on other loops. |
154 scoped_refptr<base::MessageLoopProxy> gvd_loop_proxy_; | 150 scoped_refptr<base::MessageLoopProxy> gvd_loop_proxy_; |
155 | 151 |
156 // Message loop on which to makes all calls to vda_. (beware this loop may be | 152 // Message loop on which to makes all calls to vda_. (beware this loop may be |
157 // paused during the Pause/Flush/Stop dance PipelineImpl::Stop() goes | 153 // paused during the Pause/Flush/Stop dance PipelineImpl::Stop() goes |
158 // through). | 154 // through). |
(...skipping 28 matching lines...) Expand all Loading... |
187 ~BufferPair(); | 183 ~BufferPair(); |
188 SHMBuffer* shm_buffer; | 184 SHMBuffer* shm_buffer; |
189 scoped_refptr<DecoderBuffer> buffer; | 185 scoped_refptr<DecoderBuffer> buffer; |
190 }; | 186 }; |
191 std::map<int32, BufferPair> bitstream_buffers_in_decoder_; | 187 std::map<int32, BufferPair> bitstream_buffers_in_decoder_; |
192 std::map<int32, PictureBuffer> picture_buffers_in_decoder_; | 188 std::map<int32, PictureBuffer> picture_buffers_in_decoder_; |
193 | 189 |
194 // The texture target used for decoded pictures. | 190 // The texture target used for decoded pictures. |
195 uint32 decoder_texture_target_; | 191 uint32 decoder_texture_target_; |
196 | 192 |
197 // Maintains bitstream buffer ID to timestamp mappings. | 193 struct BufferData { |
198 typedef std::pair<int32, base::TimeDelta> BufferTimeData; | 194 BufferData(int32 bbid, base::TimeDelta ts, |
199 std::list<BufferTimeData> input_buffer_time_data_; | 195 const gfx::Size& natural_size); |
| 196 ~BufferData(); |
| 197 int32 bitstream_buffer_id; |
| 198 base::TimeDelta timestamp; |
| 199 gfx::Size natural_size; |
| 200 }; |
| 201 std::list<BufferData> input_buffer_data_; |
200 | 202 |
201 // picture_buffer_id and the frame wrapping the corresponding Picture, for | 203 // picture_buffer_id and the frame wrapping the corresponding Picture, for |
202 // frames that have been decoded but haven't been requested by a Read() yet. | 204 // frames that have been decoded but haven't been requested by a Read() yet. |
203 std::list<scoped_refptr<VideoFrame> > ready_video_frames_; | 205 std::list<scoped_refptr<VideoFrame> > ready_video_frames_; |
204 int64 next_picture_buffer_id_; | 206 int64 next_picture_buffer_id_; |
205 int64 next_bitstream_buffer_id_; | 207 int64 next_bitstream_buffer_id_; |
206 | 208 |
207 // Indicates PrepareForShutdownHack()'s been called. Makes further calls to | 209 // Indicates PrepareForShutdownHack()'s been called. Makes further calls to |
208 // this class not require the render thread's loop to be processing. | 210 // this class not require the render thread's loop to be processing. |
209 bool shutting_down_; | 211 bool shutting_down_; |
210 | 212 |
211 // Indicates decoding error occurred. | 213 // Indicates decoding error occurred. |
212 bool error_occured_; | 214 bool error_occured_; |
213 | 215 |
214 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); | 216 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); |
215 }; | 217 }; |
216 | 218 |
217 } // namespace media | 219 } // namespace media |
218 | 220 |
219 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ | 221 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ |
OLD | NEW |