OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_VIDEO_GPU_MEMORY_BUFFER_VIDEO_FRAME_POOL_H_ | 5 #ifndef MEDIA_VIDEO_GPU_MEMORY_BUFFER_VIDEO_FRAME_POOL_H_ |
6 #define MEDIA_VIDEO_GPU_MEMORY_BUFFER_VIDEO_FRAME_POOL_H_ | 6 #define MEDIA_VIDEO_GPU_MEMORY_BUFFER_VIDEO_FRAME_POOL_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/task_runner.h" |
10 #include "media/base/video_frame.h" | 11 #include "media/base/video_frame.h" |
11 | 12 |
12 namespace base { | 13 namespace base { |
13 class SingleThreadTaskRunner; | 14 class SingleThreadTaskRunner; |
14 } | 15 } |
15 | 16 |
16 namespace media { | 17 namespace media { |
17 class GpuVideoAcceleratorFactories; | 18 class GpuVideoAcceleratorFactories; |
18 | 19 |
19 // Interface to a pool of GpuMemoryBuffers/textues/images that can be used to | 20 // Interface to a pool of GpuMemoryBuffers/textues/images that can be used to |
20 // transform software VideoFrames to VideoFrames backed by native textures. | 21 // transform software VideoFrames to VideoFrames backed by native textures. |
21 // The resources used by the VideoFrame created by the pool will be | 22 // The resources used by the VideoFrame created by the pool will be |
22 // automatically put back into the pool once the frame is destroyed. | 23 // automatically put back into the pool once the frame is destroyed. |
23 // The pool recycles resources to a void unnecessarily allocating and | 24 // The pool recycles resources to a void unnecessarily allocating and |
24 // destroying textures, images and GpuMemoryBuffer that could result | 25 // destroying textures, images and GpuMemoryBuffer that could result |
25 // in a round trip to the browser/GPU process. | 26 // in a round trip to the browser/GPU process. |
26 class MEDIA_EXPORT GpuMemoryBufferVideoFramePool { | 27 class MEDIA_EXPORT GpuMemoryBufferVideoFramePool { |
27 public: | 28 public: |
28 GpuMemoryBufferVideoFramePool( | 29 GpuMemoryBufferVideoFramePool( |
29 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 30 const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner, |
| 31 const scoped_refptr<base::TaskRunner>& worker_task_runner, |
30 const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories); | 32 const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories); |
31 ~GpuMemoryBufferVideoFramePool(); | 33 ~GpuMemoryBufferVideoFramePool(); |
32 | 34 |
33 // Returns a new VideoFrame containing only mailboxes to native resources. | 35 // Callback used by MaybeCreateHardwareFrame to deliver a new VideoFrame |
34 // The content of the returned object is copied from the software-allocated | 36 // after it has been copied to GpuMemoryBuffers. |
| 37 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> FrameReadyCB; |
| 38 |
| 39 // Calls |cb| on |media_worker_pool| with a new VideoFrame containing only |
| 40 // mailboxes to native resources. |cb| will be destroyed on |
| 41 // |media_worker_pool|. |
| 42 // The content of the new object is copied from the software-allocated |
35 // |video_frame|. | 43 // |video_frame|. |
36 // If it's not possible to create a new hardware VideoFrame, |video_frame| | 44 // If it's not possible to create a new hardware VideoFrame, |video_frame| |
37 // itself will be returned. | 45 // itself will passed to |cb|. |
38 scoped_refptr<VideoFrame> MaybeCreateHardwareFrame( | 46 void MaybeCreateHardwareFrame(const scoped_refptr<VideoFrame>& video_frame, |
39 const scoped_refptr<VideoFrame>& video_frame); | 47 const FrameReadyCB& frame_ready_cb); |
40 | 48 |
41 private: | 49 private: |
42 class PoolImpl; | 50 class PoolImpl; |
43 scoped_refptr<PoolImpl> pool_impl_; | 51 scoped_refptr<PoolImpl> pool_impl_; |
44 | 52 |
45 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferVideoFramePool); | 53 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferVideoFramePool); |
46 }; | 54 }; |
47 | 55 |
48 } // namespace media | 56 } // namespace media |
49 | 57 |
50 #endif // MEDIA_VIDEO_GPU_MEMORY_BUFFER_VIDEO_FRAME_POOL_H_ | 58 #endif // MEDIA_VIDEO_GPU_MEMORY_BUFFER_VIDEO_FRAME_POOL_H_ |
OLD | NEW |