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