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> |
| 11 #include <utility> |
11 | 12 |
12 #include "media/base/pipeline_status.h" | 13 #include "media/base/pipeline_status.h" |
13 #include "media/base/demuxer_stream.h" | 14 #include "media/base/demuxer_stream.h" |
14 #include "media/base/video_decoder.h" | 15 #include "media/base/video_decoder.h" |
15 #include "media/video/video_decode_accelerator.h" | 16 #include "media/video/video_decode_accelerator.h" |
16 | 17 |
17 class MessageLoop; | 18 class MessageLoop; |
18 template <class T> class scoped_refptr; | 19 template <class T> class scoped_refptr; |
19 namespace base { | 20 namespace base { |
20 class MessageLoopProxy; | 21 class MessageLoopProxy; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // merely triggers delivery, and requires the ready_video_frames_ queue not be | 112 // merely triggers delivery, and requires the ready_video_frames_ queue not be |
112 // empty. | 113 // empty. |
113 void EnqueueFrameAndTriggerFrameDelivery( | 114 void EnqueueFrameAndTriggerFrameDelivery( |
114 const scoped_refptr<VideoFrame>& frame); | 115 const scoped_refptr<VideoFrame>& frame); |
115 | 116 |
116 // Indicate the picturebuffer can be reused by the decoder. | 117 // Indicate the picturebuffer can be reused by the decoder. |
117 void ReusePictureBuffer(int64 picture_buffer_id); | 118 void ReusePictureBuffer(int64 picture_buffer_id); |
118 | 119 |
119 void RecordBufferTimeData( | 120 void RecordBufferTimeData( |
120 const BitstreamBuffer& bitstream_buffer, const Buffer& buffer); | 121 const BitstreamBuffer& bitstream_buffer, const Buffer& buffer); |
121 void GetBufferTimeData( | 122 base::TimeDelta GetBufferTimestamp(int32 id); |
122 int32 id, base::TimeDelta* timestamp, base::TimeDelta* duration); | |
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 | 145 // TODO(scherkus): I think this should be calculated by VideoRenderers based |
146 // on information provided by VideoDecoders (i.e., aspect ratio). | 146 // on information provided by VideoDecoders (i.e., aspect ratio). |
147 gfx::Size natural_size_; | 147 gfx::Size natural_size_; |
148 | 148 |
149 // Frame duration specified in the video stream's configuration, or 0 if not | |
150 // present. | |
151 base::TimeDelta config_frame_duration_; | |
152 | |
153 // Pointer to the demuxer stream that will feed us compressed buffers. | 149 // Pointer to the demuxer stream that will feed us compressed buffers. |
154 scoped_refptr<DemuxerStream> demuxer_stream_; | 150 scoped_refptr<DemuxerStream> demuxer_stream_; |
155 | 151 |
156 // MessageLoop on which to fire callbacks and trampoline calls to this class | 152 // MessageLoop on which to fire callbacks and trampoline calls to this class |
157 // if they arrive on other loops. | 153 // if they arrive on other loops. |
158 scoped_refptr<base::MessageLoopProxy> gvd_loop_proxy_; | 154 scoped_refptr<base::MessageLoopProxy> gvd_loop_proxy_; |
159 | 155 |
160 // Message loop on which to makes all calls to vda_. (beware this loop may be | 156 // Message loop on which to makes all calls to vda_. (beware this loop may be |
161 // paused during the Pause/Flush/Stop dance PipelineImpl::Stop() goes | 157 // paused during the Pause/Flush/Stop dance PipelineImpl::Stop() goes |
162 // through). | 158 // through). |
(...skipping 28 matching lines...) Expand all Loading... |
191 ~BufferPair(); | 187 ~BufferPair(); |
192 SHMBuffer* shm_buffer; | 188 SHMBuffer* shm_buffer; |
193 scoped_refptr<DecoderBuffer> buffer; | 189 scoped_refptr<DecoderBuffer> buffer; |
194 }; | 190 }; |
195 std::map<int32, BufferPair> bitstream_buffers_in_decoder_; | 191 std::map<int32, BufferPair> bitstream_buffers_in_decoder_; |
196 std::map<int32, PictureBuffer> picture_buffers_in_decoder_; | 192 std::map<int32, PictureBuffer> picture_buffers_in_decoder_; |
197 | 193 |
198 // The texture target used for decoded pictures. | 194 // The texture target used for decoded pictures. |
199 uint32 decoder_texture_target_; | 195 uint32 decoder_texture_target_; |
200 | 196 |
201 struct BufferTimeData { | 197 // Maintains bitstream buffer ID to timestamp mappings. |
202 BufferTimeData(int32 bbid, base::TimeDelta ts, base::TimeDelta dur); | 198 typedef std::pair<int32, base::TimeDelta> BufferTimeData; |
203 ~BufferTimeData(); | |
204 int32 bitstream_buffer_id; | |
205 base::TimeDelta timestamp; | |
206 base::TimeDelta duration; | |
207 }; | |
208 std::list<BufferTimeData> input_buffer_time_data_; | 199 std::list<BufferTimeData> input_buffer_time_data_; |
209 | 200 |
210 // picture_buffer_id and the frame wrapping the corresponding Picture, for | 201 // picture_buffer_id and the frame wrapping the corresponding Picture, for |
211 // frames that have been decoded but haven't been requested by a Read() yet. | 202 // frames that have been decoded but haven't been requested by a Read() yet. |
212 std::list<scoped_refptr<VideoFrame> > ready_video_frames_; | 203 std::list<scoped_refptr<VideoFrame> > ready_video_frames_; |
213 int64 next_picture_buffer_id_; | 204 int64 next_picture_buffer_id_; |
214 int64 next_bitstream_buffer_id_; | 205 int64 next_bitstream_buffer_id_; |
215 | 206 |
216 // Indicates PrepareForShutdownHack()'s been called. Makes further calls to | 207 // Indicates PrepareForShutdownHack()'s been called. Makes further calls to |
217 // this class not require the render thread's loop to be processing. | 208 // this class not require the render thread's loop to be processing. |
218 bool shutting_down_; | 209 bool shutting_down_; |
219 | 210 |
220 // Indicates decoding error occurred. | 211 // Indicates decoding error occurred. |
221 bool error_occured_; | 212 bool error_occured_; |
222 | 213 |
223 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); | 214 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); |
224 }; | 215 }; |
225 | 216 |
226 } // namespace media | 217 } // namespace media |
227 | 218 |
228 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ | 219 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ |
OLD | NEW |