summaryrefslogtreecommitdiffstats
path: root/remoting/capturer/video_frame.h
blob: 77105b78fbcd74a055d883acd44833a29dae0961 (plain)
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
59
60
61
62
63
// Copyright (c) 2012 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.

#ifndef REMOTING_CAPTURER_VIDEO_FRAME_H_
#define REMOTING_CAPTURER_VIDEO_FRAME_H_

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "remoting/capturer/shared_buffer.h"
#include "third_party/skia/include/core/SkSize.h"
#include "third_party/skia/include/core/SkTypes.h"

namespace remoting {

// Represents a video frame.
class VideoFrame {
 public:
  virtual ~VideoFrame();

  int bytes_per_row() const { return bytes_per_row_; }
  const SkISize& dimensions() const { return dimensions_; }
  uint8* pixels() const { return pixels_; }
  const scoped_refptr<SharedBuffer>& shared_buffer() const {
    return shared_buffer_;
  }

 protected:
  // Initializes an empty video frame. Derived classes are expected to allocate
  // memory for the frame in a platform-specific way and set the properties of
  // the allocated frame.
  VideoFrame();

  void set_bytes_per_row(int bytes_per_row) {
    bytes_per_row_ = bytes_per_row;
  }

  void set_dimensions(const SkISize& dimensions) { dimensions_ = dimensions; }
  void set_pixels(uint8* ptr) { pixels_ = ptr; }
  void set_shared_buffer(scoped_refptr<SharedBuffer> shared_buffer) {
    shared_buffer_ = shared_buffer;
  }

 private:
  // Bytes per row of pixels including necessary padding.
  int bytes_per_row_;

  // Dimensions of the buffer in pixels.
  SkISize dimensions_;

  // Points to the pixel buffer.
  uint8* pixels_;

  // Points to an optional shared memory buffer that backs up |pixels_| buffer.
  scoped_refptr<SharedBuffer> shared_buffer_;

  DISALLOW_COPY_AND_ASSIGN(VideoFrame);
};

}  // namespace remoting

#endif  // REMOTING_CAPTURER_VIDEO_FRAME_H_