OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CONTENT_RENDERER_MEDIA_GPU_RTC_VIDEO_DECODER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_GPU_RTC_VIDEO_DECODER_H_ |
6 #define CONTENT_RENDERER_MEDIA_GPU_RTC_VIDEO_DECODER_H_ | 6 #define CONTENT_RENDERER_MEDIA_GPU_RTC_VIDEO_DECODER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <deque> | 11 #include <deque> |
12 #include <list> | 12 #include <list> |
13 #include <map> | 13 #include <map> |
| 14 #include <memory> |
14 #include <set> | 15 #include <set> |
15 #include <utility> | 16 #include <utility> |
16 | 17 |
17 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
18 #include "base/macros.h" | 19 #include "base/macros.h" |
19 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
20 #include "base/synchronization/lock.h" | 21 #include "base/synchronization/lock.h" |
21 #include "base/threading/thread.h" | 22 #include "base/threading/thread.h" |
22 #include "content/common/content_export.h" | 23 #include "content/common/content_export.h" |
23 #include "media/base/bitstream_buffer.h" | 24 #include "media/base/bitstream_buffer.h" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 // The texture target used for decoded pictures. | 232 // The texture target used for decoded pictures. |
232 uint32_t decoder_texture_target_; | 233 uint32_t decoder_texture_target_; |
233 | 234 |
234 // The format of the decoded pictures. | 235 // The format of the decoded pictures. |
235 media::VideoPixelFormat pixel_format_; | 236 media::VideoPixelFormat pixel_format_; |
236 | 237 |
237 // Metadata of the buffers that have been sent for decode. | 238 // Metadata of the buffers that have been sent for decode. |
238 std::list<BufferData> input_buffer_data_; | 239 std::list<BufferData> input_buffer_data_; |
239 | 240 |
240 // A map from bitstream buffer IDs to bitstream buffers that are being | 241 // A map from bitstream buffer IDs to bitstream buffers that are being |
241 // processed by VDA. The map owns SHM buffers. | 242 // processed by VDA. |
242 std::map<int32_t, base::SharedMemory*> bitstream_buffers_in_decoder_; | 243 std::map<int32_t, std::unique_ptr<base::SharedMemory>> |
| 244 bitstream_buffers_in_decoder_; |
243 | 245 |
244 // A map from picture buffer IDs to texture-backed picture buffers. | 246 // A map from picture buffer IDs to texture-backed picture buffers. |
245 std::map<int32_t, media::PictureBuffer> assigned_picture_buffers_; | 247 std::map<int32_t, media::PictureBuffer> assigned_picture_buffers_; |
246 | 248 |
247 // PictureBuffers given to us by VDA via PictureReady, which we sent forward | 249 // PictureBuffers given to us by VDA via PictureReady, which we sent forward |
248 // as VideoFrames to be rendered via read_cb_, and which will be returned | 250 // as VideoFrames to be rendered via read_cb_, and which will be returned |
249 // to us via ReusePictureBuffer. | 251 // to us via ReusePictureBuffer. |
250 typedef std::map<int32_t /* picture_buffer_id */, uint32_t /* texture_id */> | 252 typedef std::map<int32_t /* picture_buffer_id */, uint32_t /* texture_id */> |
251 PictureBufferTextureMap; | 253 PictureBufferTextureMap; |
252 PictureBufferTextureMap picture_buffers_at_display_; | 254 PictureBufferTextureMap picture_buffers_at_display_; |
(...skipping 11 matching lines...) Expand all Loading... |
264 State state_; | 266 State state_; |
265 | 267 |
266 // Guarded by |lock_|. | 268 // Guarded by |lock_|. |
267 webrtc::DecodedImageCallback* decode_complete_callback_; | 269 webrtc::DecodedImageCallback* decode_complete_callback_; |
268 | 270 |
269 // Total number of allocated SHM buffers. Guarded by |lock_|. | 271 // Total number of allocated SHM buffers. Guarded by |lock_|. |
270 size_t num_shm_buffers_; | 272 size_t num_shm_buffers_; |
271 | 273 |
272 // Shared-memory buffer pool. Since allocating SHM segments requires a | 274 // Shared-memory buffer pool. Since allocating SHM segments requires a |
273 // round-trip to the browser process, we keep allocation out of the | 275 // round-trip to the browser process, we keep allocation out of the |
274 // steady-state of the decoder. The vector owns SHM buffers. Guarded by | 276 // steady-state of the decoder. Guarded by |lock_|. |
275 // |lock_|. | 277 std::vector<std::unique_ptr<base::SharedMemory>> available_shm_segments_; |
276 std::vector<base::SharedMemory*> available_shm_segments_; | |
277 | 278 |
278 // A queue storing WebRTC encoding images (and their metadata) that are | 279 // A queue storing WebRTC encoding images (and their metadata) that are |
279 // waiting for the shared memory. Guarded by |lock_|. | 280 // waiting for the shared memory. Guarded by |lock_|. |
280 std::deque<std::pair<webrtc::EncodedImage, BufferData>> pending_buffers_; | 281 std::deque<std::pair<webrtc::EncodedImage, BufferData>> pending_buffers_; |
281 | 282 |
282 // A queue storing buffers (and their metadata) that will be sent to VDA for | 283 // A queue storing buffers (and their metadata) that will be sent to VDA for |
283 // decode. The queue owns SHM buffers. Guarded by |lock_|. | 284 // decode. Guarded by |lock_|. |
284 std::deque<std::pair<base::SharedMemory*, BufferData>> decode_buffers_; | 285 std::deque<std::pair<std::unique_ptr<base::SharedMemory>, BufferData>> |
| 286 decode_buffers_; |
285 | 287 |
286 // The id that will be given to the next bitstream buffer. Guarded by |lock_|. | 288 // The id that will be given to the next bitstream buffer. Guarded by |lock_|. |
287 int32_t next_bitstream_buffer_id_; | 289 int32_t next_bitstream_buffer_id_; |
288 | 290 |
289 // A buffer that has an id less than this should be dropped because Reset or | 291 // A buffer that has an id less than this should be dropped because Reset or |
290 // Release has been called. Guarded by |lock_|. | 292 // Release has been called. Guarded by |lock_|. |
291 int32_t reset_bitstream_buffer_id_; | 293 int32_t reset_bitstream_buffer_id_; |
292 | 294 |
293 // Minimum and maximum supported resolutions for the current profile/VDA. | 295 // Minimum and maximum supported resolutions for the current profile/VDA. |
294 gfx::Size min_resolution_; | 296 gfx::Size min_resolution_; |
295 gfx::Size max_resolution_; | 297 gfx::Size max_resolution_; |
296 | 298 |
297 // Must be destroyed, or invalidated, on the media thread. | 299 // Must be destroyed, or invalidated, on the media thread. |
298 // NOTE: Weak pointers must be invalidated before all other member variables. | 300 // NOTE: Weak pointers must be invalidated before all other member variables. |
299 base::WeakPtrFactory<RTCVideoDecoder> weak_factory_; | 301 base::WeakPtrFactory<RTCVideoDecoder> weak_factory_; |
300 | 302 |
301 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); | 303 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); |
302 }; | 304 }; |
303 | 305 |
304 } // namespace content | 306 } // namespace content |
305 | 307 |
306 #endif // CONTENT_RENDERER_MEDIA_GPU_RTC_VIDEO_DECODER_H_ | 308 #endif // CONTENT_RENDERER_MEDIA_GPU_RTC_VIDEO_DECODER_H_ |
OLD | NEW |