Chromium Code Reviews| 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 11 matching lines...) Expand all Loading... | |
| 22 | 22 |
| 23 // DesktopFrame represents a video frame captured from the screen. | 23 // DesktopFrame represents a video frame captured from the screen. |
| 24 class DesktopFrame { | 24 class DesktopFrame { |
| 25 public: | 25 public: |
| 26 // DesktopFrame objects always hold RGBA data. | 26 // DesktopFrame objects always hold RGBA data. |
| 27 static const int kBytesPerPixel = 4; | 27 static const int kBytesPerPixel = 4; |
| 28 | 28 |
| 29 virtual ~DesktopFrame(); | 29 virtual ~DesktopFrame(); |
| 30 | 30 |
| 31 // Size of the frame. | 31 // Size of the frame. |
| 32 const DesktopSize& size() const { return size_; } | 32 virtual const DesktopSize& size() const; |
|
Sergey Ulanov
2016/04/08 21:22:26
Why do you need to make any of these methods virtu
| |
| 33 | 33 |
| 34 // Distance in the buffer between two neighboring rows in bytes. | 34 // Distance in the buffer between two neighboring rows in bytes. |
| 35 int stride() const { return stride_; } | 35 virtual int stride() const; |
| 36 | 36 |
| 37 // Data buffer used for the frame. | 37 // Data buffer used for the frame. |
| 38 uint8_t* data() const { return data_; } | 38 virtual uint8_t* data() const; |
| 39 | 39 |
| 40 // SharedMemory used for the buffer or NULL if memory is allocated on the | 40 // SharedMemory used for the buffer or NULL if memory is allocated on the |
| 41 // heap. The result is guaranteed to be deleted only after the frame is | 41 // heap. The result is guaranteed to be deleted only after the frame is |
| 42 // deleted (classes that inherit from DesktopFrame must ensure it). | 42 // deleted (classes that inherit from DesktopFrame must ensure it). |
| 43 SharedMemory* shared_memory() const { return shared_memory_; } | 43 virtual SharedMemory* shared_memory() const; |
| 44 | 44 |
| 45 // Indicates region of the screen that has changed since the previous frame. | 45 // Indicates region of the screen that has changed since the previous frame. |
| 46 const DesktopRegion& updated_region() const { return updated_region_; } | 46 virtual const DesktopRegion& updated_region() const; |
| 47 DesktopRegion* mutable_updated_region() { return &updated_region_; } | 47 virtual DesktopRegion* mutable_updated_region(); |
| 48 | 48 |
| 49 // DPI of the screen being captured. May be set to zero, e.g. if DPI is | 49 // DPI of the screen being captured. May be set to zero, e.g. if DPI is |
| 50 // unknown. | 50 // unknown. |
| 51 const DesktopVector& dpi() const { return dpi_; } | 51 virtual const DesktopVector& dpi() const; |
| 52 void set_dpi(const DesktopVector& dpi) { dpi_ = dpi; } | 52 virtual void set_dpi(const DesktopVector& dpi); |
| 53 | 53 |
| 54 // Time taken to capture the frame in milliseconds. | 54 // Time taken to capture the frame in milliseconds. |
| 55 int64_t capture_time_ms() const { return capture_time_ms_; } | 55 virtual int64_t capture_time_ms() const; |
| 56 void set_capture_time_ms(int64_t time_ms) { capture_time_ms_ = time_ms; } | 56 virtual void set_capture_time_ms(int64_t 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 virtual const DesktopRegion* shape() const; |
| 61 void set_shape(DesktopRegion* shape) { shape_.reset(shape); } | 61 virtual void set_shape(DesktopRegion* 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 virtual void CopyPixelsFrom(uint8_t* src_buffer, |
| 66 const DesktopRect& dest_rect); | 66 int src_stride, |
| 67 void CopyPixelsFrom(const DesktopFrame& src_frame, | 67 const DesktopRect& dest_rect); |
| 68 const DesktopVector& src_pos, | 68 virtual void CopyPixelsFrom(const DesktopFrame& src_frame, |
| 69 const DesktopRect& dest_rect); | 69 const DesktopVector& src_pos, |
| 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 virtual 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 |
| 81 // TODO(zijiehe): Most of follow variables should belong to an inheritance. | |
| 80 const DesktopSize size_; | 82 const DesktopSize size_; |
| 81 const int stride_; | 83 const int stride_; |
| 82 | 84 |
| 83 // Ownership of the buffers is defined by the classes that inherit from this | 85 // 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 | 86 // class. They must guarantee that the buffer is not deleted before the frame |
| 85 // is deleted. | 87 // is deleted. |
| 88 // Inheritances can set the pointer after construction. | |
| 86 uint8_t* const data_; | 89 uint8_t* const data_; |
| 87 SharedMemory* const shared_memory_; | 90 SharedMemory* const shared_memory_; |
| 88 | 91 |
| 89 DesktopRegion updated_region_; | 92 DesktopRegion updated_region_; |
| 90 DesktopVector dpi_; | 93 DesktopVector dpi_; |
| 91 int64_t capture_time_ms_; | 94 int64_t capture_time_ms_; |
| 92 std::unique_ptr<DesktopRegion> shape_; | 95 std::unique_ptr<DesktopRegion> shape_; |
| 93 | 96 |
| 94 private: | 97 private: |
| 95 RTC_DISALLOW_COPY_AND_ASSIGN(DesktopFrame); | 98 RTC_DISALLOW_COPY_AND_ASSIGN(DesktopFrame); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 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 |