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

Side by Side Diff: webrtc/media/base/videoframe.h

Issue 1688953003: Revert of Initial cleanup of cricket::VideoFrame. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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/base/fakevideocapturer.h ('k') | webrtc/media/base/videoframe.cc » ('j') | 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) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 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
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 // Returns the underlying video frame buffer. This function is ok to call 71 // Returns the underlying video frame buffer. This function is ok to call
72 // multiple times, but the returned object will refer to the same memory. 72 // multiple times, but the returned object will refer to the same memory.
73 virtual rtc::scoped_refptr<webrtc::VideoFrameBuffer> GetVideoFrameBuffer() 73 virtual rtc::scoped_refptr<webrtc::VideoFrameBuffer> GetVideoFrameBuffer()
74 const = 0; 74 const = 0;
75 75
76 virtual int64_t GetTimeStamp() const = 0; 76 virtual int64_t GetTimeStamp() const = 0;
77 virtual void SetTimeStamp(int64_t time_stamp) = 0; 77 virtual void SetTimeStamp(int64_t time_stamp) = 0;
78 78
79 // Indicates the rotation angle in degrees. 79 // Indicates the rotation angle in degrees.
80 virtual webrtc::VideoRotation GetVideoRotation() const = 0; 80 // TODO(guoweis): Remove this function, rename GetVideoRotation and remove the
81 // skeleton implementation of GetRotation once chrome is updated.
82 virtual int GetRotation() const { return GetVideoRotation(); }
83 virtual webrtc::VideoRotation GetVideoRotation() const {
84 return webrtc::kVideoRotation_0;
85 }
81 86
82 // Make a shallow copy of the frame. The frame buffer itself is not copied. 87 // Make a shallow copy of the frame. The frame buffer itself is not copied.
83 // Both the current and new VideoFrame will share a single reference-counted 88 // Both the current and new VideoFrame will share a single reference-counted
84 // frame buffer. 89 // frame buffer.
85 virtual VideoFrame *Copy() const = 0; 90 virtual VideoFrame *Copy() const = 0;
86 91
87 // Since VideoFrame supports shallow copy and the internal frame buffer might 92 // Since VideoFrame supports shallow copy and the internal frame buffer might
88 // be shared, this function can be used to check exclusive ownership. 93 // be shared, this function can be used to check exclusive ownership.
89 virtual bool IsExclusive() const = 0; 94 virtual bool IsExclusive() const = 0;
90 95
91 // In case VideoFrame needs exclusive access of the frame buffer, user can 96 // In case VideoFrame needs exclusive access of the frame buffer, user can
92 // call MakeExclusive() to make sure the frame buffer is exclusively 97 // call MakeExclusive() to make sure the frame buffer is exclusively
93 // accessible to the current object. This might mean a deep copy of the frame 98 // accessible to the current object. This might mean a deep copy of the frame
94 // buffer if it is currently shared by other objects. 99 // buffer if it is currently shared by other objects.
95 virtual bool MakeExclusive() = 0; 100 virtual bool MakeExclusive() = 0;
96 101
102 // Writes the frame into the given frame buffer, provided that it is of
103 // sufficient size. Returns the frame's actual size, regardless of whether
104 // it was written or not (like snprintf). If there is insufficient space,
105 // nothing is written.
106 virtual size_t CopyToBuffer(uint8_t* buffer, size_t size) const;
107
108 // Writes the frame into the given planes, stretched to the given width and
109 // height. The parameter "interpolate" controls whether to interpolate or just
110 // take the nearest-point. The parameter "crop" controls whether to crop this
111 // frame to the aspect ratio of the given dimensions before stretching.
112 virtual bool CopyToPlanes(uint8_t* dst_y,
113 uint8_t* dst_u,
114 uint8_t* dst_v,
115 int32_t dst_pitch_y,
116 int32_t dst_pitch_u,
117 int32_t dst_pitch_v) const;
118
97 // Writes the frame into the target VideoFrame. 119 // Writes the frame into the target VideoFrame.
98 virtual void CopyToFrame(VideoFrame* target) const; 120 virtual void CopyToFrame(VideoFrame* target) const;
99 121
100 // Return a copy of frame which has its pending rotation applied. The 122 // Return a copy of frame which has its pending rotation applied. The
101 // ownership of the returned frame is held by this frame. 123 // ownership of the returned frame is held by this frame.
102 virtual const VideoFrame* GetCopyWithRotationApplied() const = 0; 124 virtual const VideoFrame* GetCopyWithRotationApplied() const = 0;
103 125
126 // Writes the frame into the given stream and returns the StreamResult.
127 // See webrtc/base/stream.h for a description of StreamResult and error.
128 // Error may be NULL. If a non-success value is returned from
129 // StreamInterface::Write(), we immediately return with that value.
130 virtual rtc::StreamResult Write(rtc::StreamInterface* stream,
131 int* error) const;
132
104 // Converts the I420 data to RGB of a certain type such as ARGB and ABGR. 133 // Converts the I420 data to RGB of a certain type such as ARGB and ABGR.
105 // Returns the frame's actual size, regardless of whether it was written or 134 // Returns the frame's actual size, regardless of whether it was written or
106 // not (like snprintf). Parameters size and stride_rgb are in units of bytes. 135 // not (like snprintf). Parameters size and stride_rgb are in units of bytes.
107 // If there is insufficient space, nothing is written. 136 // If there is insufficient space, nothing is written.
108 virtual size_t ConvertToRgbBuffer(uint32_t to_fourcc, 137 virtual size_t ConvertToRgbBuffer(uint32_t to_fourcc,
109 uint8_t* buffer, 138 uint8_t* buffer,
110 size_t size, 139 size_t size,
111 int stride_rgb) const; 140 int stride_rgb) const;
112 141
113 // Writes the frame into the given planes, stretched to the given width and 142 // Writes the frame into the given planes, stretched to the given width and
(...skipping 28 matching lines...) Expand all
142 // Sets the video frame to black. 171 // Sets the video frame to black.
143 virtual bool SetToBlack(); 172 virtual bool SetToBlack();
144 173
145 // Tests if sample is valid. Returns true if valid. 174 // Tests if sample is valid. Returns true if valid.
146 static bool Validate(uint32_t fourcc, 175 static bool Validate(uint32_t fourcc,
147 int w, 176 int w,
148 int h, 177 int h,
149 const uint8_t* sample, 178 const uint8_t* sample,
150 size_t sample_size); 179 size_t sample_size);
151 180
181 // Size of an I420 image of given dimensions when stored as a frame buffer.
182 static size_t SizeOf(size_t w, size_t h) {
183 return w * h + ((w + 1) / 2) * ((h + 1) / 2) * 2;
184 }
185
152 protected: 186 protected:
153 // Writes the frame into the given planes, stretched to the given width and
154 // height. The parameter "interpolate" controls whether to interpolate or just
155 // take the nearest-point. The parameter "crop" controls whether to crop this
156 // frame to the aspect ratio of the given dimensions before stretching.
157 virtual bool CopyToPlanes(uint8_t* dst_y,
158 uint8_t* dst_u,
159 uint8_t* dst_v,
160 int32_t dst_pitch_y,
161 int32_t dst_pitch_u,
162 int32_t dst_pitch_v) const;
163
164 // Creates an empty frame. 187 // Creates an empty frame.
165 virtual VideoFrame *CreateEmptyFrame(int w, int h, 188 virtual VideoFrame *CreateEmptyFrame(int w, int h,
166 int64_t time_stamp) const = 0; 189 int64_t time_stamp) const = 0;
167 virtual void SetRotation(webrtc::VideoRotation rotation) = 0; 190 virtual void SetRotation(webrtc::VideoRotation rotation) = 0;
168 }; 191 };
169 192
170 } // namespace cricket 193 } // namespace cricket
171 194
172 #endif // WEBRTC_MEDIA_BASE_VIDEOFRAME_H_ 195 #endif // WEBRTC_MEDIA_BASE_VIDEOFRAME_H_
OLDNEW
« no previous file with comments | « webrtc/media/base/fakevideocapturer.h ('k') | webrtc/media/base/videoframe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698