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 // TODO(nisse): This class duplicates cricket::VideoFrame. There's |
| 23 // ongoing work to merge the classes. See |
| 24 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5682. |
22 class VideoFrame { | 25 class VideoFrame { |
23 public: | 26 public: |
24 VideoFrame(); | 27 VideoFrame(); |
| 28 |
| 29 // Preferred constructor. |
25 VideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, | 30 VideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, |
26 uint32_t timestamp, | 31 uint32_t timestamp, |
27 int64_t render_time_ms, | 32 int64_t render_time_ms, |
28 VideoRotation rotation); | 33 VideoRotation rotation); |
29 | 34 |
30 // CreateEmptyFrame: Sets frame dimensions and allocates buffers based | 35 // CreateEmptyFrame: Sets frame dimensions and allocates buffers based |
31 // on set dimensions - height and plane stride. | 36 // on set dimensions - height and plane stride. |
32 // If required size is bigger than the allocated one, new buffers of adequate | 37 // If required size is bigger than the allocated one, new buffers of adequate |
33 // size will be allocated. | 38 // size will be allocated. |
| 39 // TODO(nisse): Should be deleted in the cricket::VideoFrame and |
| 40 // webrtc::VideoFrame merge. |
34 void CreateEmptyFrame(int width, | 41 void CreateEmptyFrame(int width, |
35 int height, | 42 int height, |
36 int stride_y, | 43 int stride_y, |
37 int stride_u, | 44 int stride_u, |
38 int stride_v); | 45 int stride_v); |
39 | 46 |
40 // CreateFrame: Sets the frame's members and buffers. If required size is | 47 // 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. | 48 // bigger than allocated one, new buffers of adequate size will be allocated. |
| 49 // TODO(nisse): Should be deleted in the cricket::VideoFrame and |
| 50 // webrtc::VideoFrame merge. |
42 void CreateFrame(const uint8_t* buffer_y, | 51 void CreateFrame(const uint8_t* buffer_y, |
43 const uint8_t* buffer_u, | 52 const uint8_t* buffer_u, |
44 const uint8_t* buffer_v, | 53 const uint8_t* buffer_v, |
45 int width, | 54 int width, |
46 int height, | 55 int height, |
47 int stride_y, | 56 int stride_y, |
48 int stride_u, | 57 int stride_u, |
49 int stride_v, | 58 int stride_v, |
50 VideoRotation rotation); | 59 VideoRotation rotation); |
51 | 60 |
52 // CreateFrame: Sets the frame's members and buffers. If required size is | 61 // 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. | 62 // bigger than allocated one, new buffers of adequate size will be allocated. |
54 // |buffer| must be a packed I420 buffer. | 63 // |buffer| must be a packed I420 buffer. |
| 64 // TODO(nisse): Should be deleted in the cricket::VideoFrame and |
| 65 // webrtc::VideoFrame merge. |
55 void CreateFrame(const uint8_t* buffer, | 66 void CreateFrame(const uint8_t* buffer, |
56 int width, | 67 int width, |
57 int height, | 68 int height, |
58 VideoRotation rotation); | 69 VideoRotation rotation); |
59 | 70 |
60 // Deep copy frame: If required size is bigger than allocated one, new | 71 // Deep copy frame: If required size is bigger than allocated one, new |
61 // buffers of adequate size will be allocated. | 72 // buffers of adequate size will be allocated. |
| 73 // TODO(nisse): Should be deleted in the cricket::VideoFrame and |
| 74 // webrtc::VideoFrame merge. |
62 void CopyFrame(const VideoFrame& videoFrame); | 75 void CopyFrame(const VideoFrame& videoFrame); |
63 | 76 |
64 // Creates a shallow copy of |videoFrame|, i.e, the this object will retain a | 77 // Creates a shallow copy of |videoFrame|, i.e, the this object will retain a |
65 // reference to the video buffer also retained by |videoFrame|. | 78 // reference to the video buffer also retained by |videoFrame|. |
| 79 // TODO(nisse): Should be deleted in the cricket::VideoFrame and |
| 80 // webrtc::VideoFrame merge. |
66 void ShallowCopy(const VideoFrame& videoFrame); | 81 void ShallowCopy(const VideoFrame& videoFrame); |
67 | 82 |
68 // Get allocated size per plane. | 83 // Get allocated size per plane. |
| 84 // TODO(nisse): Should be deleted in the cricket::VideoFrame and |
| 85 // webrtc::VideoFrame merge. |
69 int allocated_size(PlaneType type) const; | 86 int allocated_size(PlaneType type) const; |
70 | 87 |
71 // Get frame width. | 88 // Get frame width. |
72 int width() const; | 89 int width() const; |
73 | 90 |
74 // Get frame height. | 91 // Get frame height. |
75 int height() const; | 92 int height() const; |
76 | 93 |
| 94 // TODO(nisse): After the cricket::VideoFrame and webrtc::VideoFrame |
| 95 // merge, we'll have methods timestamp_us and set_timestamp_us, all |
| 96 // other frame timestamps will likely be deprecated. |
| 97 |
77 // Set frame timestamp (90kHz). | 98 // Set frame timestamp (90kHz). |
78 void set_timestamp(uint32_t timestamp) { timestamp_ = timestamp; } | 99 void set_timestamp(uint32_t timestamp) { timestamp_ = timestamp; } |
79 | 100 |
80 // Get frame timestamp (90kHz). | 101 // Get frame timestamp (90kHz). |
81 uint32_t timestamp() const { return timestamp_; } | 102 uint32_t timestamp() const { return timestamp_; } |
82 | 103 |
83 // Set capture ntp time in miliseconds. | 104 // Set capture ntp time in milliseconds. |
84 void set_ntp_time_ms(int64_t ntp_time_ms) { | 105 void set_ntp_time_ms(int64_t ntp_time_ms) { |
85 ntp_time_ms_ = ntp_time_ms; | 106 ntp_time_ms_ = ntp_time_ms; |
86 } | 107 } |
87 | 108 |
88 // Get capture ntp time in miliseconds. | 109 // Get capture ntp time in milliseconds. |
89 int64_t ntp_time_ms() const { return ntp_time_ms_; } | 110 int64_t ntp_time_ms() const { return ntp_time_ms_; } |
90 | 111 |
91 // Naming convention for Coordination of Video Orientation. Please see | 112 // Naming convention for Coordination of Video Orientation. Please see |
92 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126
114v120700p.pdf | 113 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126
114v120700p.pdf |
93 // | 114 // |
94 // "pending rotation" or "pending" = a frame that has a VideoRotation > 0. | 115 // "pending rotation" or "pending" = a frame that has a VideoRotation > 0. |
95 // | 116 // |
96 // "not pending" = a frame that has a VideoRotation == 0. | 117 // "not pending" = a frame that has a VideoRotation == 0. |
97 // | 118 // |
98 // "apply rotation" = modify a frame from being "pending" to being "not | 119 // "apply rotation" = modify a frame from being "pending" to being "not |
99 // pending" rotation (a no-op for "unrotated"). | 120 // pending" rotation (a no-op for "unrotated"). |
100 // | 121 // |
101 VideoRotation rotation() const { return rotation_; } | 122 VideoRotation rotation() const { return rotation_; } |
102 void set_rotation(VideoRotation rotation) { | 123 void set_rotation(VideoRotation rotation) { |
103 rotation_ = rotation; | 124 rotation_ = rotation; |
104 } | 125 } |
105 | 126 |
106 // Set render time in miliseconds. | 127 // Set render time in milliseconds. |
107 void set_render_time_ms(int64_t render_time_ms) { | 128 void set_render_time_ms(int64_t render_time_ms) { |
108 render_time_ms_ = render_time_ms; | 129 render_time_ms_ = render_time_ms; |
109 } | 130 } |
110 | 131 |
111 // Get render time in miliseconds. | 132 // Get render time in milliseconds. |
112 int64_t render_time_ms() const { return render_time_ms_; } | 133 int64_t render_time_ms() const { return render_time_ms_; } |
113 | 134 |
114 // Return true if underlying plane buffers are of zero size, false if not. | 135 // Return true if underlying plane buffers are of zero size, false if not. |
| 136 // TODO(nisse): Should be deleted in the cricket::VideoFrame and |
| 137 // webrtc::VideoFrame merge. |
115 bool IsZeroSize() const; | 138 bool IsZeroSize() const; |
116 | 139 |
117 // Return the underlying buffer. Never nullptr for a properly | 140 // Return the underlying buffer. Never nullptr for a properly |
118 // initialized VideoFrame. | 141 // initialized VideoFrame. |
119 // Creating a new reference breaks the HasOneRef and IsMutable | 142 // Creating a new reference breaks the HasOneRef and IsMutable |
120 // logic. So return a const ref to our reference. | 143 // logic. So return a const ref to our reference. |
121 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& video_frame_buffer() | 144 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& video_frame_buffer() |
122 const; | 145 const; |
123 | 146 |
124 // Return true if the frame is stored in a texture. | 147 // Return true if the frame is stored in a texture. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 int qp_ = -1; // Quantizer value. | 202 int qp_ = -1; // Quantizer value. |
180 | 203 |
181 // When an application indicates non-zero values here, it is taken as an | 204 // When an application indicates non-zero values here, it is taken as an |
182 // indication that all future frames will be constrained with those limits | 205 // indication that all future frames will be constrained with those limits |
183 // until the application indicates a change again. | 206 // until the application indicates a change again. |
184 PlayoutDelay playout_delay_ = {-1, -1}; | 207 PlayoutDelay playout_delay_ = {-1, -1}; |
185 }; | 208 }; |
186 | 209 |
187 } // namespace webrtc | 210 } // namespace webrtc |
188 #endif // WEBRTC_VIDEO_FRAME_H_ | 211 #endif // WEBRTC_VIDEO_FRAME_H_ |
OLD | NEW |