Note: We no longer publish the latest version of our code here. We primarily use a kumc-bmi github organization. The heron ETL repository, in particular, is not public. Peers in the informatics community should see MultiSiteDev for details on requesting access.

source: webrtc/webrtc/modules/desktop_capture/desktop_frame.h @ 0:4bda6873e34c

pub_scrub_3792 tip
Last change on this file since 0:4bda6873e34c was 0:4bda6873e34c, checked in by Michael Prittie <mprittie@…>, 6 years ago

Scrubbed password for publication.

File size: 4.2 KB
Line 
1/*
2 *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 *
4 *  Use of this source code is governed by a BSD-style license
5 *  that can be found in the LICENSE file in the root of the source
6 *  tree. An additional intellectual property rights grant can be found
7 *  in the file PATENTS.  All contributing project authors may
8 *  be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_H_
12#define WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_H_
13
14#include "webrtc/modules/desktop_capture/desktop_geometry.h"
15#include "webrtc/modules/desktop_capture/desktop_region.h"
16#include "webrtc/modules/desktop_capture/shared_memory.h"
17#include "webrtc/system_wrappers/interface/scoped_ptr.h"
18#include "webrtc/typedefs.h"
19
20namespace webrtc {
21
22// DesktopFrame represents a video frame captured from the screen.
23class DesktopFrame {
24 public:
25  // DesktopFrame objects always hold RGBA data.
26  static const int kBytesPerPixel = 4;
27
28  virtual ~DesktopFrame();
29
30  // Size of the frame.
31  const DesktopSize& size() const { return size_; }
32
33  // Distance in the buffer between two neighboring rows in bytes.
34  int stride() const { return stride_; }
35
36  // Data buffer used for the frame.
37  uint8_t* data() const { return data_; }
38
39  // SharedMemory used for the buffer or NULL if memory is allocated on the
40  // heap. The result is guaranteed to be deleted only after the frame is
41  // deleted (classes that inherit from DesktopFrame must ensure it).
42  SharedMemory* shared_memory() const { return shared_memory_; }
43
44  // Indicates region of the screen that has changed since the previous frame.
45  const DesktopRegion& updated_region() const { return updated_region_; }
46  DesktopRegion* mutable_updated_region() { return &updated_region_; }
47
48  // DPI of the screen being captured. May be set to zero, e.g. if DPI is
49  // unknown.
50  const DesktopVector& dpi() const { return dpi_; }
51  void set_dpi(const DesktopVector& dpi) { dpi_ = dpi; }
52
53  // Time taken to capture the frame in milliseconds.
54  int32_t capture_time_ms() const { return capture_time_ms_; }
55  void set_capture_time_ms(int32_t time_ms) { capture_time_ms_ = time_ms; }
56
57  // Optional shape for the frame. Frames may be shaped e.g. if
58  // capturing the contents of a shaped window.
59  const DesktopRegion* shape() const { return shape_.get(); }
60  void set_shape(DesktopRegion* shape) { shape_.reset(shape); }
61
62  // Copies pixels from a buffer or another frame. |dest_rect| rect must lay
63  // within bounds of this frame.
64  void CopyPixelsFrom(uint8_t* src_buffer, int src_stride,
65                      const DesktopRect& dest_rect);
66  void CopyPixelsFrom(const DesktopFrame& src_frame,
67                      const DesktopVector& src_pos,
68                      const DesktopRect& dest_rect);
69
70 protected:
71  DesktopFrame(DesktopSize size,
72               int stride,
73               uint8_t* data,
74               SharedMemory* shared_memory);
75
76  const DesktopSize size_;
77  const int stride_;
78
79  // Ownership of the buffers is defined by the classes that inherit from this
80  // class. They must guarantee that the buffer is not deleted before the frame
81  // is deleted.
82  uint8_t* const data_;
83  SharedMemory* const shared_memory_;
84
85  DesktopRegion updated_region_;
86  DesktopVector dpi_;
87  int32_t capture_time_ms_;
88  scoped_ptr<DesktopRegion> shape_;
89
90 private:
91  DISALLOW_COPY_AND_ASSIGN(DesktopFrame);
92};
93
94// A DesktopFrame that stores data in the heap.
95class BasicDesktopFrame : public DesktopFrame {
96 public:
97  explicit BasicDesktopFrame(DesktopSize size);
98  virtual ~BasicDesktopFrame();
99
100  // Creates a BasicDesktopFrame that contains copy of |frame|.
101  static DesktopFrame* CopyOf(const DesktopFrame& frame);
102
103 private:
104  DISALLOW_COPY_AND_ASSIGN(BasicDesktopFrame);
105};
106
107// A DesktopFrame that stores data in shared memory.
108class SharedMemoryDesktopFrame : public DesktopFrame {
109 public:
110  // Takes ownership of |shared_memory|.
111  SharedMemoryDesktopFrame(DesktopSize size,
112                           int stride,
113                           SharedMemory* shared_memory);
114  virtual ~SharedMemoryDesktopFrame();
115
116 private:
117  DISALLOW_COPY_AND_ASSIGN(SharedMemoryDesktopFrame);
118};
119
120}  // namespace webrtc
121
122#endif  // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_H_
123
Note: See TracBrowser for help on using the repository browser.