OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 int64_t capture_time_ms() const { return capture_time_ms_; } | 56 int64_t capture_time_ms() const { return capture_time_ms_; } |
57 void set_capture_time_ms(int64_t time_ms) { capture_time_ms_ = time_ms; } | 57 void set_capture_time_ms(int64_t time_ms) { capture_time_ms_ = time_ms; } |
58 | 58 |
59 // Optional shape for the frame. Frames may be shaped e.g. if | 59 // Optional shape for the frame. Frames may be shaped e.g. if |
60 // capturing the contents of a shaped window. | 60 // capturing the contents of a shaped window. |
61 const DesktopRegion* shape() const { return shape_.get(); } | 61 const DesktopRegion* shape() const { return shape_.get(); } |
62 void set_shape(DesktopRegion* shape) { shape_.reset(shape); } | 62 void set_shape(DesktopRegion* shape) { shape_.reset(shape); } |
63 | 63 |
64 // Copies pixels from a buffer or another frame. |dest_rect| rect must lay | 64 // Copies pixels from a buffer or another frame. |dest_rect| rect must lay |
65 // within bounds of this frame. | 65 // within bounds of this frame. |
66 void CopyPixelsFrom(uint8_t* src_buffer, int src_stride, | 66 void CopyPixelsFrom(uint8_t* src_buffer, |
67 int src_stride, | |
67 const DesktopRect& dest_rect); | 68 const DesktopRect& dest_rect); |
68 void CopyPixelsFrom(const DesktopFrame& src_frame, | 69 void CopyPixelsFrom(const DesktopFrame& src_frame, |
69 const DesktopVector& src_pos, | 70 const DesktopVector& src_pos, |
70 const DesktopRect& dest_rect); | 71 const DesktopRect& dest_rect); |
71 | 72 |
72 // A helper to return the data pointer of a frame at the specified position. | 73 // A helper to return the data pointer of a frame at the specified position. |
73 uint8_t* GetFrameDataAtPos(const DesktopVector& pos) const; | 74 uint8_t* GetFrameDataAtPos(const DesktopVector& pos) const; |
74 | 75 |
75 protected: | 76 protected: |
76 DesktopFrame(DesktopSize size, | 77 DesktopFrame(DesktopSize size, |
77 int stride, | 78 int stride, |
78 uint8_t* data, | 79 uint8_t* data, |
79 SharedMemory* shared_memory); | 80 SharedMemory* shared_memory); |
80 | 81 |
81 const DesktopSize size_; | |
82 const int stride_; | |
83 | |
84 // Ownership of the buffers is defined by the classes that inherit from this | 82 // Ownership of the buffers is defined by the classes that inherit from this |
85 // class. They must guarantee that the buffer is not deleted before the frame | 83 // class. They must guarantee that the buffer is not deleted before the frame |
86 // is deleted. | 84 // is deleted. |
87 uint8_t* const data_; | 85 uint8_t* const data_; |
88 SharedMemory* const shared_memory_; | 86 SharedMemory* const shared_memory_; |
89 | 87 |
88 private: | |
89 const DesktopSize size_; | |
90 const int stride_; | |
91 | |
90 DesktopRegion updated_region_; | 92 DesktopRegion updated_region_; |
91 DesktopVector dpi_; | 93 DesktopVector dpi_; |
92 int64_t capture_time_ms_; | 94 int64_t capture_time_ms_; |
93 std::unique_ptr<DesktopRegion> shape_; | 95 std::unique_ptr<DesktopRegion> shape_; |
94 | 96 |
95 private: | |
96 RTC_DISALLOW_COPY_AND_ASSIGN(DesktopFrame); | 97 RTC_DISALLOW_COPY_AND_ASSIGN(DesktopFrame); |
97 }; | 98 }; |
98 | 99 |
99 // A DesktopFrame that stores data in the heap. | 100 // A DesktopFrame that stores data in the heap. |
100 class BasicDesktopFrame : public DesktopFrame { | 101 class BasicDesktopFrame : public DesktopFrame { |
101 public: | 102 public: |
102 explicit BasicDesktopFrame(DesktopSize size); | 103 explicit BasicDesktopFrame(DesktopSize size); |
103 ~BasicDesktopFrame() override; | 104 ~BasicDesktopFrame() override; |
104 | 105 |
105 // Creates a BasicDesktopFrame that contains copy of |frame|. | 106 // Creates a BasicDesktopFrame that contains copy of |frame|. |
106 static DesktopFrame* CopyOf(const DesktopFrame& frame); | 107 static DesktopFrame* CopyOf(const DesktopFrame& frame); |
107 | 108 |
108 private: | 109 private: |
109 RTC_DISALLOW_COPY_AND_ASSIGN(BasicDesktopFrame); | 110 RTC_DISALLOW_COPY_AND_ASSIGN(BasicDesktopFrame); |
110 }; | 111 }; |
111 | 112 |
112 // A DesktopFrame that stores data in shared memory. | 113 // A DesktopFrame that stores data in shared memory. |
113 class SharedMemoryDesktopFrame : public DesktopFrame { | 114 class SharedMemoryDesktopFrame : public DesktopFrame { |
114 public: | 115 public: |
115 static std::unique_ptr<DesktopFrame> Create( | 116 static std::unique_ptr<DesktopFrame> Create( |
116 DesktopSize size, | 117 DesktopSize size, |
117 SharedMemoryFactory* shared_memory_factory); | 118 SharedMemoryFactory* shared_memory_factory); |
118 | 119 |
120 static std::unique_ptr<DesktopFrame> Create( | |
121 DesktopSize size, | |
122 std::unique_ptr<SharedMemory> shared_memory); | |
123 | |
119 // Takes ownership of |shared_memory|. | 124 // Takes ownership of |shared_memory|. |
120 // TODO(sergeyu): Remove this constructor and keep the second one. | 125 // TODO(zijiehe): Hide constructors after fake_desktop_capturer.cc has been |
126 // migrated, Create function is preferred. | |
Sergey Ulanov
2016/05/13 19:38:11
s/Create function/Create()/
Hzj_jie
2016/05/16 18:17:28
Done.
| |
121 SharedMemoryDesktopFrame(DesktopSize size, | 127 SharedMemoryDesktopFrame(DesktopSize size, |
122 int stride, | 128 int stride, |
123 SharedMemory* shared_memory); | 129 SharedMemory* shared_memory); |
124 SharedMemoryDesktopFrame(DesktopSize size, | |
125 int stride, | |
126 std::unique_ptr<SharedMemory> shared_memory); | |
127 ~SharedMemoryDesktopFrame() override; | 130 ~SharedMemoryDesktopFrame() override; |
128 | 131 |
129 private: | 132 private: |
130 RTC_DISALLOW_COPY_AND_ASSIGN(SharedMemoryDesktopFrame); | 133 RTC_DISALLOW_COPY_AND_ASSIGN(SharedMemoryDesktopFrame); |
131 }; | 134 }; |
132 | 135 |
133 } // namespace webrtc | 136 } // namespace webrtc |
134 | 137 |
135 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_H_ | 138 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_H_ |
136 | 139 |
OLD | NEW |