| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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_VIDEO_FRAME_H_ | 11 #ifndef WEBRTC_VIDEO_FRAME_H_ |
| 12 #define WEBRTC_VIDEO_FRAME_H_ | 12 #define WEBRTC_VIDEO_FRAME_H_ |
| 13 | 13 |
| 14 #include "webrtc/base/scoped_ref_ptr.h" | 14 #include "webrtc/base/scoped_ref_ptr.h" |
| 15 #include "webrtc/common_types.h" | 15 #include "webrtc/common_types.h" |
| 16 #include "webrtc/common_video/include/video_frame_buffer.h" | 16 #include "webrtc/common_video/include/video_frame_buffer.h" |
| 17 #include "webrtc/common_video/rotation.h" | 17 #include "webrtc/common_video/rotation.h" |
| 18 #include "webrtc/typedefs.h" | 18 #include "webrtc/typedefs.h" |
| 19 | 19 |
| 20 namespace webrtc { | 20 namespace webrtc { |
| 21 | 21 |
| 22 class VideoFrame { | 22 class VideoFrame { |
| 23 public: | 23 public: |
| 24 VideoFrame(); | 24 VideoFrame(); |
| 25 VideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, | 25 VideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, |
| 26 uint32_t timestamp, | 26 uint32_t timestamp, |
| 27 int64_t render_time_ms, | 27 int64_t render_time_ms, |
| 28 VideoRotation rotation); | 28 VideoRotation rotation); |
| 29 | 29 |
| 30 // TODO(pbos): Make all create/copy functions void, they should not be able to |
| 31 // fail (which should be RTC_DCHECK/CHECKed instead). |
| 32 |
| 30 // CreateEmptyFrame: Sets frame dimensions and allocates buffers based | 33 // CreateEmptyFrame: Sets frame dimensions and allocates buffers based |
| 31 // on set dimensions - height and plane stride. | 34 // on set dimensions - height and plane stride. |
| 32 // If required size is bigger than the allocated one, new buffers of adequate | 35 // If required size is bigger than the allocated one, new buffers of adequate |
| 33 // size will be allocated. | 36 // size will be allocated. |
| 34 void CreateEmptyFrame(int width, | 37 // Return value: 0 on success, -1 on error. |
| 35 int height, | 38 int CreateEmptyFrame(int width, |
| 36 int stride_y, | 39 int height, |
| 37 int stride_u, | 40 int stride_y, |
| 38 int stride_v); | 41 int stride_u, |
| 42 int stride_v); |
| 39 | 43 |
| 40 // CreateFrame: Sets the frame's members and buffers. If required size is | 44 // CreateFrame: Sets the frame's members and buffers. If required size is |
| 41 // bigger than allocated one, new buffers of adequate size will be allocated. | 45 // bigger than allocated one, new buffers of adequate size will be allocated. |
| 42 void CreateFrame(const uint8_t* buffer_y, | 46 // Return value: 0 on success, -1 on error. |
| 43 const uint8_t* buffer_u, | 47 int CreateFrame(const uint8_t* buffer_y, |
| 44 const uint8_t* buffer_v, | 48 const uint8_t* buffer_u, |
| 45 int width, | 49 const uint8_t* buffer_v, |
| 46 int height, | 50 int width, |
| 47 int stride_y, | 51 int height, |
| 48 int stride_u, | 52 int stride_y, |
| 49 int stride_v, | 53 int stride_u, |
| 50 VideoRotation rotation); | 54 int stride_v); |
| 55 |
| 56 // TODO(guoweis): remove the previous CreateFrame when chromium has this code. |
| 57 int CreateFrame(const uint8_t* buffer_y, |
| 58 const uint8_t* buffer_u, |
| 59 const uint8_t* buffer_v, |
| 60 int width, |
| 61 int height, |
| 62 int stride_y, |
| 63 int stride_u, |
| 64 int stride_v, |
| 65 VideoRotation rotation); |
| 51 | 66 |
| 52 // CreateFrame: Sets the frame's members and buffers. If required size is | 67 // CreateFrame: Sets the frame's members and buffers. If required size is |
| 53 // bigger than allocated one, new buffers of adequate size will be allocated. | 68 // bigger than allocated one, new buffers of adequate size will be allocated. |
| 54 // |buffer| must be a packed I420 buffer. | 69 // |buffer| must be a packed I420 buffer. |
| 55 void CreateFrame(const uint8_t* buffer, | 70 // Return value: 0 on success, -1 on error. |
| 71 int CreateFrame(const uint8_t* buffer, |
| 56 int width, | 72 int width, |
| 57 int height, | 73 int height, |
| 58 VideoRotation rotation); | 74 VideoRotation rotation); |
| 59 | 75 |
| 60 // Deep copy frame: If required size is bigger than allocated one, new | 76 // Deep copy frame: If required size is bigger than allocated one, new |
| 61 // buffers of adequate size will be allocated. | 77 // buffers of adequate size will be allocated. |
| 62 void CopyFrame(const VideoFrame& videoFrame); | 78 // Return value: 0 on success, -1 on error. |
| 79 int CopyFrame(const VideoFrame& videoFrame); |
| 63 | 80 |
| 64 // Creates a shallow copy of |videoFrame|, i.e, the this object will retain a | 81 // Creates a shallow copy of |videoFrame|, i.e, the this object will retain a |
| 65 // reference to the video buffer also retained by |videoFrame|. | 82 // reference to the video buffer also retained by |videoFrame|. |
| 66 void ShallowCopy(const VideoFrame& videoFrame); | 83 void ShallowCopy(const VideoFrame& videoFrame); |
| 67 | 84 |
| 68 // Release frame buffer and reset time stamps. | 85 // Release frame buffer and reset time stamps. |
| 69 void Reset(); | 86 void Reset(); |
| 70 | 87 |
| 71 // Get pointer to buffer per plane. | 88 // Get pointer to buffer per plane. |
| 72 uint8_t* buffer(PlaneType type); | 89 uint8_t* buffer(PlaneType type); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer() const; | 151 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer() const; |
| 135 | 152 |
| 136 // Set the underlying buffer. | 153 // Set the underlying buffer. |
| 137 void set_video_frame_buffer( | 154 void set_video_frame_buffer( |
| 138 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer); | 155 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer); |
| 139 | 156 |
| 140 // Convert native-handle frame to memory-backed I420 frame. Should not be | 157 // Convert native-handle frame to memory-backed I420 frame. Should not be |
| 141 // called on a non-native-handle frame. | 158 // called on a non-native-handle frame. |
| 142 VideoFrame ConvertNativeToI420Frame() const; | 159 VideoFrame ConvertNativeToI420Frame() const; |
| 143 | 160 |
| 161 bool EqualsFrame(const VideoFrame& frame) const; |
| 162 |
| 144 private: | 163 private: |
| 145 // An opaque reference counted handle that stores the pixel data. | 164 // An opaque reference counted handle that stores the pixel data. |
| 146 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_; | 165 rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_; |
| 147 uint32_t timestamp_; | 166 uint32_t timestamp_; |
| 148 int64_t ntp_time_ms_; | 167 int64_t ntp_time_ms_; |
| 149 int64_t render_time_ms_; | 168 int64_t render_time_ms_; |
| 150 VideoRotation rotation_; | 169 VideoRotation rotation_; |
| 151 }; | 170 }; |
| 152 | 171 |
| 153 | 172 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 uint8_t* _buffer; | 205 uint8_t* _buffer; |
| 187 size_t _length; | 206 size_t _length; |
| 188 size_t _size; | 207 size_t _size; |
| 189 bool _completeFrame = false; | 208 bool _completeFrame = false; |
| 190 AdaptReason adapt_reason_; | 209 AdaptReason adapt_reason_; |
| 191 int qp_ = -1; // Quantizer value. | 210 int qp_ = -1; // Quantizer value. |
| 192 }; | 211 }; |
| 193 | 212 |
| 194 } // namespace webrtc | 213 } // namespace webrtc |
| 195 #endif // WEBRTC_VIDEO_FRAME_H_ | 214 #endif // WEBRTC_VIDEO_FRAME_H_ |
| OLD | NEW |