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