| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // Simple class that implements the VideoFrame interface with memory allocated | 5 // Simple class that implements the VideoFrame interface with memory allocated |
| 6 // on the system heap. This class supports every format defined in the | 6 // on the system heap. This class supports every format defined in the |
| 7 // VideoSurface::Format enum. The implementation attempts to properly align | 7 // VideoSurface::Format enum. The implementation attempts to properly align |
| 8 // allocations for maximum system bus efficency. | 8 // allocations for maximum system bus efficency. |
| 9 #ifndef MEDIA_BASE_VIDEO_FRAME_IMPL_H_ | 9 #ifndef MEDIA_BASE_VIDEO_FRAME_IMPL_H_ |
| 10 #define MEDIA_BASE_VIDEO_FRAME_IMPL_H_ | 10 #define MEDIA_BASE_VIDEO_FRAME_IMPL_H_ |
| 11 | 11 |
| 12 #include "media/base/buffers.h" | 12 #include "media/base/buffers.h" |
| 13 | 13 |
| 14 namespace media { | 14 namespace media { |
| 15 | 15 |
| 16 class VideoFrameImpl : public VideoFrame { | 16 class VideoFrameImpl : public VideoFrame { |
| 17 public: | 17 public: |
| 18 static void CreateFrame(VideoSurface::Format format, | 18 static void CreateFrame(VideoSurface::Format format, |
| 19 size_t width, | 19 size_t width, |
| 20 size_t height, | 20 size_t height, |
| 21 base::TimeDelta timestamp, | 21 base::TimeDelta timestamp, |
| 22 base::TimeDelta duration, | 22 base::TimeDelta duration, |
| 23 scoped_refptr<VideoFrame>* frame_out); | 23 scoped_refptr<VideoFrame>* frame_out); |
| 24 | 24 |
| 25 // Creates a frame with format equals to VideoSurface::EMPTY, width, height | 25 // Creates a frame with format equals to VideoSurface::EMPTY, width, height |
| 26 // timestamp and duration are all 0. | 26 // timestamp and duration are all 0. |
| 27 static void CreateEmptyFrame(scoped_refptr<VideoFrame>* frame_out); | 27 static void CreateEmptyFrame(scoped_refptr<VideoFrame>* frame_out); |
| 28 | 28 |
| 29 // Allocates YV12 frame based on |width| and |height|, and sets its data to |
| 30 // the YUV equivalent of RGB(0,0,0). |
| 31 static void CreateBlackFrame(int width, int height, |
| 32 scoped_refptr<VideoFrame>* frame_out); |
| 33 |
| 29 // Implementation of VideoFrame. | 34 // Implementation of VideoFrame. |
| 30 virtual bool Lock(VideoSurface* surface); | 35 virtual bool Lock(VideoSurface* surface); |
| 31 virtual void Unlock(); | 36 virtual void Unlock(); |
| 32 virtual bool IsEndOfStream() const; | 37 virtual bool IsEndOfStream() const; |
| 33 | 38 |
| 34 private: | 39 private: |
| 35 // Clients must use the static CreateFrame() method to create a new frame. | 40 // Clients must use the static CreateFrame() method to create a new frame. |
| 36 VideoFrameImpl(VideoSurface::Format format, | 41 VideoFrameImpl(VideoSurface::Format format, |
| 37 size_t video_width, | 42 size_t video_width, |
| 38 size_t video_height); | 43 size_t video_height); |
| 39 | 44 |
| 40 virtual ~VideoFrameImpl(); | 45 virtual ~VideoFrameImpl(); |
| 41 | 46 |
| 42 bool AllocateRGB(size_t bytes_per_pixel); | 47 bool AllocateRGB(size_t bytes_per_pixel); |
| 43 bool AllocateYUV(); | 48 bool AllocateYUV(); |
| 44 | 49 |
| 45 bool locked_; | 50 bool locked_; |
| 46 VideoSurface surface_; | 51 VideoSurface surface_; |
| 47 | 52 |
| 48 DISALLOW_COPY_AND_ASSIGN(VideoFrameImpl); | 53 DISALLOW_COPY_AND_ASSIGN(VideoFrameImpl); |
| 49 }; | 54 }; |
| 50 | 55 |
| 51 } // namespace media | 56 } // namespace media |
| 52 | 57 |
| 53 #endif // MEDIA_BASE_VIDEO_FRAME_IMPL_H_ | 58 #endif // MEDIA_BASE_VIDEO_FRAME_IMPL_H_ |
| OLD | NEW |