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; | |
31 int width() const override; | 30 int width() const override; |
32 int height() const override; | 31 int height() const override; |
33 const uint8_t* DataY() const override; | 32 const uint8_t* DataY() const override; |
34 const uint8_t* DataU() const override; | 33 const uint8_t* DataU() const override; |
35 const uint8_t* DataV() const override; | 34 const uint8_t* DataV() const override; |
36 int StrideY() const override; | 35 int StrideY() const override; |
37 int StrideU() const override; | 36 int StrideU() const override; |
38 int StrideV() const override; | 37 int StrideV() const override; |
39 | 38 |
40 void* native_handle() const override; | 39 void* native_handle() const override; |
41 | 40 |
42 protected: | 41 protected: |
43 void* native_handle_; | 42 void* native_handle_; |
44 const int width_; | 43 const int width_; |
45 const int height_; | 44 const int height_; |
46 }; | 45 }; |
47 | 46 |
48 class WrappedI420Buffer : public PlanarYuvBuffer { | 47 class WrappedI420Buffer : public webrtc::VideoFrameBuffer { |
49 public: | 48 public: |
50 WrappedI420Buffer(int width, | 49 WrappedI420Buffer(int width, |
51 int height, | 50 int height, |
52 const uint8_t* y_plane, | 51 const uint8_t* y_plane, |
53 int y_stride, | 52 int y_stride, |
54 const uint8_t* u_plane, | 53 const uint8_t* u_plane, |
55 int u_stride, | 54 int u_stride, |
56 const uint8_t* v_plane, | 55 const uint8_t* v_plane, |
57 int v_stride, | 56 int v_stride, |
58 const rtc::Callback0<void>& no_longer_used); | 57 const rtc::Callback0<void>& no_longer_used); |
59 Type type() const override; | |
60 | |
61 int width() const override; | 58 int width() const override; |
62 int height() const override; | 59 int height() const override; |
63 | 60 |
64 const uint8_t* DataY() const override; | 61 const uint8_t* DataY() const override; |
65 const uint8_t* DataU() const override; | 62 const uint8_t* DataU() const override; |
66 const uint8_t* DataV() const override; | 63 const uint8_t* DataV() const override; |
67 int StrideY() const override; | 64 int StrideY() const override; |
68 int StrideU() const override; | 65 int StrideU() const override; |
69 int StrideV() const override; | 66 int StrideV() const override; |
70 | 67 |
| 68 void* native_handle() const override; |
| 69 |
| 70 rtc::scoped_refptr<VideoFrameBuffer> NativeToI420Buffer() override; |
| 71 |
71 private: | 72 private: |
72 friend class rtc::RefCountedObject<WrappedI420Buffer>; | 73 friend class rtc::RefCountedObject<WrappedI420Buffer>; |
73 ~WrappedI420Buffer() override; | 74 ~WrappedI420Buffer() override; |
74 | 75 |
75 const int width_; | 76 const int width_; |
76 const int height_; | 77 const int height_; |
77 const uint8_t* const y_plane_; | 78 const uint8_t* const y_plane_; |
78 const uint8_t* const u_plane_; | 79 const uint8_t* const u_plane_; |
79 const uint8_t* const v_plane_; | 80 const uint8_t* const v_plane_; |
80 const int y_stride_; | 81 const int y_stride_; |
81 const int u_stride_; | 82 const int u_stride_; |
82 const int v_stride_; | 83 const int v_stride_; |
83 rtc::Callback0<void> no_longer_used_cb_; | 84 rtc::Callback0<void> no_longer_used_cb_; |
84 }; | 85 }; |
85 | 86 |
86 } // namespace webrtc | 87 } // namespace webrtc |
87 | 88 |
88 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ | 89 #endif // WEBRTC_COMMON_VIDEO_INCLUDE_VIDEO_FRAME_BUFFER_H_ |
OLD | NEW |