Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: webrtc/video_frame.h

Issue 2088193002: Add TODO comments on deprecated VideoFrame methods. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Provide per-method advice for deprecated methods. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/media/engine/webrtcvideoframe.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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:
27 // TODO(nisse): Deprecated. Using the default constructor violates the
28 // reasonable assumption that video_frame_buffer() returns a valid buffer.
24 VideoFrame(); 29 VideoFrame();
30
31 // Preferred constructor.
25 VideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer, 32 VideoFrame(const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& buffer,
26 uint32_t timestamp, 33 uint32_t timestamp,
27 int64_t render_time_ms, 34 int64_t render_time_ms,
28 VideoRotation rotation); 35 VideoRotation rotation);
29 36
30 // CreateEmptyFrame: Sets frame dimensions and allocates buffers based 37 // CreateEmptyFrame: Sets frame dimensions and allocates buffers based
31 // on set dimensions - height and plane stride. 38 // on set dimensions - height and plane stride.
32 // If required size is bigger than the allocated one, new buffers of adequate 39 // If required size is bigger than the allocated one, new buffers of adequate
33 // size will be allocated. 40 // size will be allocated.
41
42 // TODO(nisse): Deprecated. Should be deleted in the cricket::VideoFrame and
43 // webrtc::VideoFrame merge. If you need to write into the frame, create a
44 // VideoFrameBuffer of the desired size, e.g, using I420Buffer::Create and
45 // write to that. And if you need to wrap it into a VideoFrame, pass it to the
46 // constructor.
34 void CreateEmptyFrame(int width, 47 void CreateEmptyFrame(int width,
35 int height, 48 int height,
36 int stride_y, 49 int stride_y,
37 int stride_u, 50 int stride_u,
38 int stride_v); 51 int stride_v);
39 52
40 // CreateFrame: Sets the frame's members and buffers. If required size is 53 // 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. 54 // bigger than allocated one, new buffers of adequate size will be allocated.
55
56 // TODO(nisse): Deprecated. Should be deleted in the cricket::VideoFrame and
57 // webrtc::VideoFrame merge. Instead, create a VideoFrameBuffer and pass to
58 // the constructor. E.g, use I420Buffer::Copy(WrappedI420Buffer(...)).
42 void CreateFrame(const uint8_t* buffer_y, 59 void CreateFrame(const uint8_t* buffer_y,
43 const uint8_t* buffer_u, 60 const uint8_t* buffer_u,
44 const uint8_t* buffer_v, 61 const uint8_t* buffer_v,
45 int width, 62 int width,
46 int height, 63 int height,
47 int stride_y, 64 int stride_y,
48 int stride_u, 65 int stride_u,
49 int stride_v, 66 int stride_v,
50 VideoRotation rotation); 67 VideoRotation rotation);
51 68
52 // CreateFrame: Sets the frame's members and buffers. If required size is 69 // 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. 70 // bigger than allocated one, new buffers of adequate size will be allocated.
54 // |buffer| must be a packed I420 buffer. 71 // |buffer| must be a packed I420 buffer.
72
73 // TODO(nisse): Deprecated, see above method for advice.
55 void CreateFrame(const uint8_t* buffer, 74 void CreateFrame(const uint8_t* buffer,
56 int width, 75 int width,
57 int height, 76 int height,
58 VideoRotation rotation); 77 VideoRotation rotation);
59 78
60 // Deep copy frame: If required size is bigger than allocated one, new 79 // Deep copy frame: If required size is bigger than allocated one, new
61 // buffers of adequate size will be allocated. 80 // buffers of adequate size will be allocated.
81 // TODO(nisse): Should be deleted in the cricket::VideoFrame and
82 // webrtc::VideoFrame merge. Instead, use I420Buffer::Copy to make a copy of
83 // the pixel data, and use the constructor to wrap it into a VideoFrame.
62 void CopyFrame(const VideoFrame& videoFrame); 84 void CopyFrame(const VideoFrame& videoFrame);
63 85
64 // Creates a shallow copy of |videoFrame|, i.e, the this object will retain a 86 // Creates a shallow copy of |videoFrame|, i.e, the this object will retain a
65 // reference to the video buffer also retained by |videoFrame|. 87 // reference to the video buffer also retained by |videoFrame|.
88 // TODO(nisse): Deprecated. Should be deleted in the cricket::VideoFrame and
89 // webrtc::VideoFrame merge. Instead, pass video_frame_buffer() and timestamps
90 // to the constructor.
66 void ShallowCopy(const VideoFrame& videoFrame); 91 void ShallowCopy(const VideoFrame& videoFrame);
67 92
68 // Get allocated size per plane. 93 // Get allocated size per plane.
94
95 // TODO(nisse): Deprecated. Should be deleted in the cricket::VideoFrame and
96 // webrtc::VideoFrame merge. When used with memset, consider using
97 // libyuv::I420Rect instead.
69 int allocated_size(PlaneType type) const; 98 int allocated_size(PlaneType type) const;
70 99
71 // Get frame width. 100 // Get frame width.
72 int width() const; 101 int width() const;
73 102
74 // Get frame height. 103 // Get frame height.
75 int height() const; 104 int height() const;
76 105
106 // TODO(nisse): After the cricket::VideoFrame and webrtc::VideoFrame
107 // merge, we'll have methods timestamp_us and set_timestamp_us, all
108 // other frame timestamps will likely be deprecated.
109
77 // Set frame timestamp (90kHz). 110 // Set frame timestamp (90kHz).
78 void set_timestamp(uint32_t timestamp) { timestamp_ = timestamp; } 111 void set_timestamp(uint32_t timestamp) { timestamp_ = timestamp; }
79 112
80 // Get frame timestamp (90kHz). 113 // Get frame timestamp (90kHz).
81 uint32_t timestamp() const { return timestamp_; } 114 uint32_t timestamp() const { return timestamp_; }
82 115
83 // Set capture ntp time in miliseconds. 116 // Set capture ntp time in milliseconds.
84 void set_ntp_time_ms(int64_t ntp_time_ms) { 117 void set_ntp_time_ms(int64_t ntp_time_ms) {
85 ntp_time_ms_ = ntp_time_ms; 118 ntp_time_ms_ = ntp_time_ms;
86 } 119 }
87 120
88 // Get capture ntp time in miliseconds. 121 // Get capture ntp time in milliseconds.
89 int64_t ntp_time_ms() const { return ntp_time_ms_; } 122 int64_t ntp_time_ms() const { return ntp_time_ms_; }
90 123
91 // Naming convention for Coordination of Video Orientation. Please see 124 // 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 125 // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126 114v120700p.pdf
93 // 126 //
94 // "pending rotation" or "pending" = a frame that has a VideoRotation > 0. 127 // "pending rotation" or "pending" = a frame that has a VideoRotation > 0.
95 // 128 //
96 // "not pending" = a frame that has a VideoRotation == 0. 129 // "not pending" = a frame that has a VideoRotation == 0.
97 // 130 //
98 // "apply rotation" = modify a frame from being "pending" to being "not 131 // "apply rotation" = modify a frame from being "pending" to being "not
99 // pending" rotation (a no-op for "unrotated"). 132 // pending" rotation (a no-op for "unrotated").
100 // 133 //
101 VideoRotation rotation() const { return rotation_; } 134 VideoRotation rotation() const { return rotation_; }
102 void set_rotation(VideoRotation rotation) { 135 void set_rotation(VideoRotation rotation) {
103 rotation_ = rotation; 136 rotation_ = rotation;
104 } 137 }
105 138
106 // Set render time in miliseconds. 139 // Set render time in milliseconds.
107 void set_render_time_ms(int64_t render_time_ms) { 140 void set_render_time_ms(int64_t render_time_ms) {
108 render_time_ms_ = render_time_ms; 141 render_time_ms_ = render_time_ms;
109 } 142 }
110 143
111 // Get render time in miliseconds. 144 // Get render time in milliseconds.
112 int64_t render_time_ms() const { return render_time_ms_; } 145 int64_t render_time_ms() const { return render_time_ms_; }
113 146
114 // Return true if underlying plane buffers are of zero size, false if not. 147 // Return true if and only if video_frame_buffer() is null. Which is possible
148 // only if the object was default-constructed.
149 // TODO(nisse): Deprecated. Should be deleted in the cricket::VideoFrame and
150 // webrtc::VideoFrame merge. The intention is that video_frame_buffer() never
151 // should return nullptr. To handle potentially uninitialized or non-existent
152 // frames, consider using rtc::Optional. Otherwise, IsZeroSize() can be
153 // replaced by video_frame_buffer() == nullptr.
115 bool IsZeroSize() const; 154 bool IsZeroSize() const;
116 155
117 // Return the underlying buffer. Never nullptr for a properly 156 // Return the underlying buffer. Never nullptr for a properly
118 // initialized VideoFrame. 157 // initialized VideoFrame.
119 // Creating a new reference breaks the HasOneRef and IsMutable 158 // Creating a new reference breaks the HasOneRef and IsMutable
120 // logic. So return a const ref to our reference. 159 // logic. So return a const ref to our reference.
121 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& video_frame_buffer() 160 const rtc::scoped_refptr<webrtc::VideoFrameBuffer>& video_frame_buffer()
122 const; 161 const;
123 162
124 // Return true if the frame is stored in a texture. 163 // Return true if the frame is stored in a texture.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 int qp_ = -1; // Quantizer value. 218 int qp_ = -1; // Quantizer value.
180 219
181 // When an application indicates non-zero values here, it is taken as an 220 // 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 221 // indication that all future frames will be constrained with those limits
183 // until the application indicates a change again. 222 // until the application indicates a change again.
184 PlayoutDelay playout_delay_ = {-1, -1}; 223 PlayoutDelay playout_delay_ = {-1, -1};
185 }; 224 };
186 225
187 } // namespace webrtc 226 } // namespace webrtc
188 #endif // WEBRTC_VIDEO_FRAME_H_ 227 #endif // WEBRTC_VIDEO_FRAME_H_
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoframe.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698