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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // unknown. | 51 // unknown. |
52 const DesktopVector& dpi() const { return dpi_; } | 52 const DesktopVector& dpi() const { return dpi_; } |
53 void set_dpi(const DesktopVector& dpi) { dpi_ = dpi; } | 53 void set_dpi(const DesktopVector& dpi) { dpi_ = dpi; } |
54 | 54 |
55 // Time taken to capture the frame in milliseconds. | 55 // Time taken to capture the frame in milliseconds. |
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 // Copies pixels from a buffer or another frame. |dest_rect| rect must lay | 59 // Copies pixels from a buffer or another frame. |dest_rect| rect must lay |
60 // within bounds of this frame. | 60 // within bounds of this frame. |
61 void CopyPixelsFrom(uint8_t* src_buffer, int src_stride, | 61 void CopyPixelsFrom(uint8_t* src_buffer, |
| 62 int src_stride, |
62 const DesktopRect& dest_rect); | 63 const DesktopRect& dest_rect); |
63 void CopyPixelsFrom(const DesktopFrame& src_frame, | 64 void CopyPixelsFrom(const DesktopFrame& src_frame, |
64 const DesktopVector& src_pos, | 65 const DesktopVector& src_pos, |
65 const DesktopRect& dest_rect); | 66 const DesktopRect& dest_rect); |
66 | 67 |
67 // A helper to return the data pointer of a frame at the specified position. | 68 // A helper to return the data pointer of a frame at the specified position. |
68 uint8_t* GetFrameDataAtPos(const DesktopVector& pos) const; | 69 uint8_t* GetFrameDataAtPos(const DesktopVector& pos) const; |
69 | 70 |
70 protected: | 71 protected: |
71 DesktopFrame(DesktopSize size, | 72 DesktopFrame(DesktopSize size, |
72 int stride, | 73 int stride, |
73 uint8_t* data, | 74 uint8_t* data, |
74 SharedMemory* shared_memory); | 75 SharedMemory* shared_memory); |
75 | 76 |
76 const DesktopSize size_; | |
77 const int stride_; | |
78 | |
79 // Ownership of the buffers is defined by the classes that inherit from this | 77 // 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 | 78 // class. They must guarantee that the buffer is not deleted before the frame |
81 // is deleted. | 79 // is deleted. |
82 uint8_t* const data_; | 80 uint8_t* const data_; |
83 SharedMemory* const shared_memory_; | 81 SharedMemory* const shared_memory_; |
84 | 82 |
| 83 private: |
| 84 const DesktopSize size_; |
| 85 const int stride_; |
| 86 |
85 DesktopRegion updated_region_; | 87 DesktopRegion updated_region_; |
86 DesktopVector dpi_; | 88 DesktopVector dpi_; |
87 int64_t capture_time_ms_; | 89 int64_t capture_time_ms_; |
88 | 90 |
89 private: | |
90 RTC_DISALLOW_COPY_AND_ASSIGN(DesktopFrame); | 91 RTC_DISALLOW_COPY_AND_ASSIGN(DesktopFrame); |
91 }; | 92 }; |
92 | 93 |
93 // A DesktopFrame that stores data in the heap. | 94 // A DesktopFrame that stores data in the heap. |
94 class BasicDesktopFrame : public DesktopFrame { | 95 class BasicDesktopFrame : public DesktopFrame { |
95 public: | 96 public: |
96 explicit BasicDesktopFrame(DesktopSize size); | 97 explicit BasicDesktopFrame(DesktopSize size); |
97 ~BasicDesktopFrame() override; | 98 ~BasicDesktopFrame() override; |
98 | 99 |
99 // Creates a BasicDesktopFrame that contains copy of |frame|. | 100 // Creates a BasicDesktopFrame that contains copy of |frame|. |
100 static DesktopFrame* CopyOf(const DesktopFrame& frame); | 101 static DesktopFrame* CopyOf(const DesktopFrame& frame); |
101 | 102 |
102 private: | 103 private: |
103 RTC_DISALLOW_COPY_AND_ASSIGN(BasicDesktopFrame); | 104 RTC_DISALLOW_COPY_AND_ASSIGN(BasicDesktopFrame); |
104 }; | 105 }; |
105 | 106 |
106 // A DesktopFrame that stores data in shared memory. | 107 // A DesktopFrame that stores data in shared memory. |
107 class SharedMemoryDesktopFrame : public DesktopFrame { | 108 class SharedMemoryDesktopFrame : public DesktopFrame { |
108 public: | 109 public: |
109 static std::unique_ptr<DesktopFrame> Create( | 110 static std::unique_ptr<DesktopFrame> Create( |
110 DesktopSize size, | 111 DesktopSize size, |
111 SharedMemoryFactory* shared_memory_factory); | 112 SharedMemoryFactory* shared_memory_factory); |
112 | 113 |
| 114 static std::unique_ptr<DesktopFrame> Create( |
| 115 DesktopSize size, |
| 116 std::unique_ptr<SharedMemory> shared_memory); |
| 117 |
113 // Takes ownership of |shared_memory|. | 118 // Takes ownership of |shared_memory|. |
114 // TODO(sergeyu): Remove this constructor and keep the second one. | 119 // TODO(zijiehe): Hide constructors after fake_desktop_capturer.cc has been |
| 120 // migrated, Create() is preferred. |
115 SharedMemoryDesktopFrame(DesktopSize size, | 121 SharedMemoryDesktopFrame(DesktopSize size, |
116 int stride, | 122 int stride, |
117 SharedMemory* shared_memory); | 123 SharedMemory* shared_memory); |
118 SharedMemoryDesktopFrame(DesktopSize size, | |
119 int stride, | |
120 std::unique_ptr<SharedMemory> shared_memory); | |
121 ~SharedMemoryDesktopFrame() override; | 124 ~SharedMemoryDesktopFrame() override; |
122 | 125 |
123 private: | 126 private: |
124 RTC_DISALLOW_COPY_AND_ASSIGN(SharedMemoryDesktopFrame); | 127 RTC_DISALLOW_COPY_AND_ASSIGN(SharedMemoryDesktopFrame); |
125 }; | 128 }; |
126 | 129 |
127 } // namespace webrtc | 130 } // namespace webrtc |
128 | 131 |
129 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_H_ | 132 #endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_FRAME_H_ |
130 | 133 |
OLD | NEW |