Chromium Code Reviews| 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 MEDIA_BASE_VIDEO_FRAME_POOL_H_ | 5 #ifndef MEDIA_BASE_VIDEO_FRAME_POOL_H_ |
| 6 #define MEDIA_BASE_VIDEO_FRAME_POOL_H_ | 6 #define MEDIA_BASE_VIDEO_FRAME_POOL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "media/base/media_export.h" | 11 #include "media/base/media_export.h" |
| 12 #include "media/base/video_frame.h" | 12 #include "media/base/video_frame.h" |
| 13 | 13 |
| 14 namespace media { | 14 namespace media { |
| 15 | 15 |
| 16 class VideoFramePoolDelegate { | |
|
sandersd (OOO until July 31)
2016/12/15 00:38:01
I am opposed to the name Delegate on the grounds t
| |
| 17 public: | |
| 18 virtual ~VideoFramePoolDelegate() {} | |
| 19 virtual scoped_refptr<VideoFrame> CreateZeroInitializedFrame( | |
| 20 VideoPixelFormat format, | |
| 21 const gfx::Size& coded_size, | |
| 22 const gfx::Rect& visible_rect, | |
| 23 const gfx::Size& natural_size, | |
| 24 base::TimeDelta timestamp) = 0; | |
| 25 | |
| 26 virtual scoped_refptr<VideoFrame> WrapVideoFrame( | |
| 27 const scoped_refptr<VideoFrame>& frame) = 0; | |
| 28 }; | |
| 29 | |
| 16 // Simple VideoFrame pool used to avoid unnecessarily allocating and destroying | 30 // Simple VideoFrame pool used to avoid unnecessarily allocating and destroying |
| 17 // VideoFrame objects. The pool manages the memory for the VideoFrame | 31 // VideoFrame objects. The pool manages the memory for the VideoFrame |
| 18 // returned by CreateFrame(). When one of these VideoFrames is destroyed, | 32 // returned by CreateFrame(). When one of these VideoFrames is destroyed, |
| 19 // the memory is returned to the pool for use by a subsequent CreateFrame() | 33 // the memory is returned to the pool for use by a subsequent CreateFrame() |
| 20 // call. The memory in the pool is retained for the life of the | 34 // call. The memory in the pool is retained for the life of the |
| 21 // VideoFramePool object. If the parameters passed to CreateFrame() change | 35 // VideoFramePool object. If the parameters passed to CreateFrame() change |
| 22 // during the life of this object, then the memory used by frames with the old | 36 // during the life of this object, then the memory used by frames with the old |
| 23 // parameter values will be purged from the pool. | 37 // parameter values will be purged from the pool. |
| 24 class MEDIA_EXPORT VideoFramePool { | 38 class MEDIA_EXPORT VideoFramePool { |
| 25 public: | 39 public: |
| 26 VideoFramePool(); | 40 VideoFramePool(); |
| 27 ~VideoFramePool(); | 41 ~VideoFramePool(); |
| 28 | 42 |
| 29 // Returns a frame from the pool that matches the specified | 43 // Returns a frame from the pool that matches the specified |
| 30 // parameters or creates a new frame if no suitable frame exists in | 44 // parameters or creates a new frame if no suitable frame exists in |
| 31 // the pool. The pool is drained if no matching frame is found. | 45 // the pool. The pool is drained if no matching frame is found. |
| 32 // The buffer for the new frame will be zero initialized. Reused frames will | 46 // The buffer for the new frame will be zero initialized. Reused frames will |
| 33 // not be zero initialized. | 47 // not be zero initialized. |
| 34 scoped_refptr<VideoFrame> CreateFrame(VideoPixelFormat format, | 48 scoped_refptr<VideoFrame> CreateFrame(VideoPixelFormat format, |
| 35 const gfx::Size& coded_size, | 49 const gfx::Size& coded_size, |
| 36 const gfx::Rect& visible_rect, | 50 const gfx::Rect& visible_rect, |
| 37 const gfx::Size& natural_size, | 51 const gfx::Size& natural_size, |
| 38 base::TimeDelta timestamp); | 52 base::TimeDelta timestamp); |
| 39 | 53 |
| 40 protected: | 54 void SetDelegate(std::unique_ptr<VideoFramePoolDelegate> delegate); |
|
sandersd (OOO until July 31)
2016/12/15 00:38:01
It seems like the pool doesn't work without callin
| |
| 55 | |
| 56 protected: | |
| 41 friend class VideoFramePoolTest; | 57 friend class VideoFramePoolTest; |
| 42 | 58 |
| 43 // Returns the number of frames in the pool for testing purposes. | 59 // Returns the number of frames in the pool for testing purposes. |
| 44 size_t GetPoolSizeForTesting() const; | 60 size_t GetPoolSizeForTesting() const; |
| 45 | 61 |
| 46 private: | 62 private: |
| 47 class PoolImpl; | 63 class PoolImpl; |
| 48 scoped_refptr<PoolImpl> pool_; | 64 scoped_refptr<PoolImpl> pool_; |
| 65 std::unique_ptr<VideoFramePoolDelegate> delegate_; | |
| 49 | 66 |
| 50 DISALLOW_COPY_AND_ASSIGN(VideoFramePool); | 67 DISALLOW_COPY_AND_ASSIGN(VideoFramePool); |
| 51 }; | 68 }; |
| 52 | 69 |
| 53 } // namespace media | 70 } // namespace media |
| 54 | 71 |
| 55 #endif // MEDIA_BASE_VIDEO_FRAME_POOL_H_ | 72 #endif // MEDIA_BASE_VIDEO_FRAME_POOL_H_ |
| OLD | NEW |