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