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