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