Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // 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 { | 80 virtual webrtc::VideoRotation GetVideoRotation() const { |
|
pbos-webrtc
2016/02/10 15:15:32
Can this be pure virtual now?
nisse-webrtc
2016/02/10 15:28:06
At least the compiler doesn't complain. And WebRtc
| |
| 84 return webrtc::kVideoRotation_0; | 81 return webrtc::kVideoRotation_0; |
| 85 } | 82 } |
| 86 | 83 |
| 87 // Make a shallow copy of the frame. The frame buffer itself is not copied. | 84 // Make a shallow copy of the frame. The frame buffer itself is not copied. |
| 88 // Both the current and new VideoFrame will share a single reference-counted | 85 // Both the current and new VideoFrame will share a single reference-counted |
| 89 // frame buffer. | 86 // frame buffer. |
| 90 virtual VideoFrame *Copy() const = 0; | 87 virtual VideoFrame *Copy() const = 0; |
| 91 | 88 |
| 92 // Since VideoFrame supports shallow copy and the internal frame buffer might | 89 // Since VideoFrame supports shallow copy and the internal frame buffer might |
| 93 // be shared, this function can be used to check exclusive ownership. | 90 // be shared, this function can be used to check exclusive ownership. |
| 94 virtual bool IsExclusive() const = 0; | 91 virtual bool IsExclusive() const = 0; |
| 95 | 92 |
| 96 // In case VideoFrame needs exclusive access of the frame buffer, user can | 93 // In case VideoFrame needs exclusive access of the frame buffer, user can |
| 97 // call MakeExclusive() to make sure the frame buffer is exclusively | 94 // call MakeExclusive() to make sure the frame buffer is exclusively |
| 98 // accessible to the current object. This might mean a deep copy of the frame | 95 // accessible to the current object. This might mean a deep copy of the frame |
| 99 // buffer if it is currently shared by other objects. | 96 // buffer if it is currently shared by other objects. |
| 100 virtual bool MakeExclusive() = 0; | 97 virtual bool MakeExclusive() = 0; |
| 101 | 98 |
| 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 | |
| 119 // Writes the frame into the target VideoFrame. | 99 // Writes the frame into the target VideoFrame. |
| 120 virtual void CopyToFrame(VideoFrame* target) const; | 100 virtual void CopyToFrame(VideoFrame* target) const; |
| 121 | 101 |
| 122 // Return a copy of frame which has its pending rotation applied. The | 102 // Return a copy of frame which has its pending rotation applied. The |
| 123 // ownership of the returned frame is held by this frame. | 103 // ownership of the returned frame is held by this frame. |
| 124 virtual const VideoFrame* GetCopyWithRotationApplied() const = 0; | 104 virtual const VideoFrame* GetCopyWithRotationApplied() const = 0; |
| 125 | 105 |
| 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 | |
| 133 // Converts the I420 data to RGB of a certain type such as ARGB and ABGR. | 106 // Converts the I420 data to RGB of a certain type such as ARGB and ABGR. |
| 134 // Returns the frame's actual size, regardless of whether it was written or | 107 // Returns the frame's actual size, regardless of whether it was written or |
| 135 // not (like snprintf). Parameters size and stride_rgb are in units of bytes. | 108 // not (like snprintf). Parameters size and stride_rgb are in units of bytes. |
| 136 // If there is insufficient space, nothing is written. | 109 // If there is insufficient space, nothing is written. |
| 137 virtual size_t ConvertToRgbBuffer(uint32_t to_fourcc, | 110 virtual size_t ConvertToRgbBuffer(uint32_t to_fourcc, |
| 138 uint8_t* buffer, | 111 uint8_t* buffer, |
| 139 size_t size, | 112 size_t size, |
| 140 int stride_rgb) const; | 113 int stride_rgb) const; |
| 141 | 114 |
| 142 // Writes the frame into the given planes, stretched to the given width and | 115 // Writes the frame into the given planes, stretched to the given width and |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 171 // Sets the video frame to black. | 144 // Sets the video frame to black. |
| 172 virtual bool SetToBlack(); | 145 virtual bool SetToBlack(); |
| 173 | 146 |
| 174 // Tests if sample is valid. Returns true if valid. | 147 // Tests if sample is valid. Returns true if valid. |
| 175 static bool Validate(uint32_t fourcc, | 148 static bool Validate(uint32_t fourcc, |
| 176 int w, | 149 int w, |
| 177 int h, | 150 int h, |
| 178 const uint8_t* sample, | 151 const uint8_t* sample, |
| 179 size_t sample_size); | 152 size_t sample_size); |
| 180 | 153 |
| 181 // Size of an I420 image of given dimensions when stored as a frame buffer. | 154 protected: |
| 182 static size_t SizeOf(size_t w, size_t h) { | 155 // Writes the frame into the given planes, stretched to the given width and |
| 183 return w * h + ((w + 1) / 2) * ((h + 1) / 2) * 2; | 156 // height. The parameter "interpolate" controls whether to interpolate or just |
| 184 } | 157 // take the nearest-point. The parameter "crop" controls whether to crop this |
| 158 // frame to the aspect ratio of the given dimensions before stretching. | |
| 159 virtual bool CopyToPlanes(uint8_t* dst_y, | |
| 160 uint8_t* dst_u, | |
| 161 uint8_t* dst_v, | |
| 162 int32_t dst_pitch_y, | |
| 163 int32_t dst_pitch_u, | |
| 164 int32_t dst_pitch_v) const; | |
| 185 | 165 |
| 186 protected: | |
| 187 // Creates an empty frame. | 166 // Creates an empty frame. |
| 188 virtual VideoFrame *CreateEmptyFrame(int w, int h, | 167 virtual VideoFrame *CreateEmptyFrame(int w, int h, |
| 189 int64_t time_stamp) const = 0; | 168 int64_t time_stamp) const = 0; |
| 190 virtual void SetRotation(webrtc::VideoRotation rotation) = 0; | 169 virtual void SetRotation(webrtc::VideoRotation rotation) = 0; |
| 191 }; | 170 }; |
| 192 | 171 |
| 193 } // namespace cricket | 172 } // namespace cricket |
| 194 | 173 |
| 195 #endif // WEBRTC_MEDIA_BASE_VIDEOFRAME_H_ | 174 #endif // WEBRTC_MEDIA_BASE_VIDEOFRAME_H_ |
| OLD | NEW |