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