| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 |
| 11 #ifndef WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ | 11 #ifndef WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ |
| 12 #define WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ | 12 #define WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ |
| 13 | 13 |
| 14 #include <memory> | 14 #include <memory> |
| 15 | 15 |
| 16 #include "webrtc/api/video/video_frame_buffer.h" | 16 #include "webrtc/api/video/video_frame_buffer.h" |
| 17 #include "webrtc/base/callback.h" | 17 #include "webrtc/base/callback.h" |
| 18 #include "webrtc/base/scoped_ref_ptr.h" | 18 #include "webrtc/base/scoped_ref_ptr.h" |
| 19 | 19 |
| 20 namespace webrtc { | 20 namespace webrtc { |
| 21 | 21 |
| 22 // Base class for native-handle buffer is a wrapper around a |native_handle|. | 22 // Base class for native-handle buffer is a wrapper around a |native_handle|. |
| 23 // This is used for convenience as most native-handle implementations can share | 23 // This is used for convenience as most native-handle implementations can share |
| 24 // many VideoFrame implementations, but need to implement a few others (such | 24 // many VideoFrame implementations, but need to implement a few others (such |
| 25 // as their own destructors or conversion methods back to software I420). | 25 // as their own destructors or conversion methods back to software I420). |
| 26 class NativeHandleBuffer : public VideoFrameBuffer { | 26 class NativeHandleBuffer : public VideoFrameBuffer { |
| 27 public: | 27 public: |
| 28 NativeHandleBuffer(void* native_handle, int width, int height); | 28 NativeHandleBuffer(void* native_handle, int width, int height); |
| 29 | 29 |
| 30 Type type() const override; |
| 30 int width() const override; | 31 int width() const override; |
| 31 int height() const override; | 32 int height() const override; |
| 32 const uint8_t* DataY() const override; | 33 const uint8_t* DataY() const override; |
| 33 const uint8_t* DataU() const override; | 34 const uint8_t* DataU() const override; |
| 34 const uint8_t* DataV() const override; | 35 const uint8_t* DataV() const override; |
| 35 int StrideY() const override; | 36 int StrideY() const override; |
| 36 int StrideU() const override; | 37 int StrideU() const override; |
| 37 int StrideV() const override; | 38 int StrideV() const override; |
| 38 | 39 |
| 39 void* native_handle() const override; | 40 void* native_handle() const override; |
| 40 | 41 |
| 41 protected: | 42 protected: |
| 42 void* native_handle_; | 43 void* native_handle_; |
| 43 const int width_; | 44 const int width_; |
| 44 const int height_; | 45 const int height_; |
| 45 }; | 46 }; |
| 46 | 47 |
| 47 class WrappedI420Buffer : public webrtc::VideoFrameBuffer { | 48 class WrappedI420Buffer : public PlanarYuvBuffer { |
| 48 public: | 49 public: |
| 49 WrappedI420Buffer(int width, | 50 WrappedI420Buffer(int width, |
| 50 int height, | 51 int height, |
| 51 const uint8_t* y_plane, | 52 const uint8_t* y_plane, |
| 52 int y_stride, | 53 int y_stride, |
| 53 const uint8_t* u_plane, | 54 const uint8_t* u_plane, |
| 54 int u_stride, | 55 int u_stride, |
| 55 const uint8_t* v_plane, | 56 const uint8_t* v_plane, |
| 56 int v_stride, | 57 int v_stride, |
| 57 const rtc::Callback0<void>& no_longer_used); | 58 const rtc::Callback0<void>& no_longer_used); |
| 59 Type type() const override; |
| 60 |
| 58 int width() const override; | 61 int width() const override; |
| 59 int height() const override; | 62 int height() const override; |
| 60 | 63 |
| 61 const uint8_t* DataY() const override; | 64 const uint8_t* DataY() const override; |
| 62 const uint8_t* DataU() const override; | 65 const uint8_t* DataU() const override; |
| 63 const uint8_t* DataV() const override; | 66 const uint8_t* DataV() const override; |
| 64 int StrideY() const override; | 67 int StrideY() const override; |
| 65 int StrideU() const override; | 68 int StrideU() const override; |
| 66 int StrideV() const override; | 69 int StrideV() const override; |
| 67 | 70 |
| 68 void* native_handle() const override; | |
| 69 | |
| 70 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override; | |
| 71 | |
| 72 private: | 71 private: |
| 73 friend class rtc::RefCountedObject<WrappedI420Buffer>; | 72 friend class rtc::RefCountedObject<WrappedI420Buffer>; |
| 74 ~WrappedI420Buffer() override; | 73 ~WrappedI420Buffer() override; |
| 75 | 74 |
| 76 const int width_; | 75 const int width_; |
| 77 const int height_; | 76 const int height_; |
| 78 const uint8_t* const y_plane_; | 77 const uint8_t* const y_plane_; |
| 79 const uint8_t* const u_plane_; | 78 const uint8_t* const u_plane_; |
| 80 const uint8_t* const v_plane_; | 79 const uint8_t* const v_plane_; |
| 81 const int y_stride_; | 80 const int y_stride_; |
| 82 const int u_stride_; | 81 const int u_stride_; |
| 83 const int v_stride_; | 82 const int v_stride_; |
| 84 rtc::Callback0<void> no_longer_used_cb_; | 83 rtc::Callback0<void> no_longer_used_cb_; |
| 85 }; | 84 }; |
| 86 | 85 |
| 87 } // namespace webrtc | 86 } // namespace webrtc |
| 88 | 87 |
| 89 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ | 88 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ |
| OLD | NEW |