| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 114 |
| 115 bool WebRtcVideoFrame::IsExclusive() const { | 115 bool WebRtcVideoFrame::IsExclusive() const { |
| 116 return video_frame_buffer_->HasOneRef(); | 116 return video_frame_buffer_->HasOneRef(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void* WebRtcVideoFrame::GetNativeHandle() const { | 119 void* WebRtcVideoFrame::GetNativeHandle() const { |
| 120 return video_frame_buffer_ ? video_frame_buffer_->native_handle() : nullptr; | 120 return video_frame_buffer_ ? video_frame_buffer_->native_handle() : nullptr; |
| 121 } | 121 } |
| 122 | 122 |
| 123 rtc::scoped_refptr<webrtc::VideoFrameBuffer> | 123 rtc::scoped_refptr<webrtc::VideoFrameBuffer> |
| 124 WebRtcVideoFrame::GetVideoFrameBuffer() const { | 124 WebRtcVideoFrame::video_frame_buffer() const { |
| 125 return video_frame_buffer_; | 125 return video_frame_buffer_; |
| 126 } | 126 } |
| 127 | 127 |
| 128 VideoFrame* WebRtcVideoFrame::Copy() const { | 128 VideoFrame* WebRtcVideoFrame::Copy() const { |
| 129 WebRtcVideoFrame* new_frame = new WebRtcVideoFrame( | 129 WebRtcVideoFrame* new_frame = new WebRtcVideoFrame( |
| 130 video_frame_buffer_, time_stamp_ns_, rotation_); | 130 video_frame_buffer_, time_stamp_ns_, rotation_); |
| 131 return new_frame; | 131 return new_frame; |
| 132 } | 132 } |
| 133 | 133 |
| 134 size_t WebRtcVideoFrame::ConvertToRgbBuffer(uint32_t to_fourcc, | 134 size_t WebRtcVideoFrame::ConvertToRgbBuffer(uint32_t to_fourcc, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 void WebRtcVideoFrame::InitToEmptyBuffer(int w, int h, | 206 void WebRtcVideoFrame::InitToEmptyBuffer(int w, int h, |
| 207 int64_t time_stamp_ns) { | 207 int64_t time_stamp_ns) { |
| 208 video_frame_buffer_ = new rtc::RefCountedObject<webrtc::I420Buffer>(w, h); | 208 video_frame_buffer_ = new rtc::RefCountedObject<webrtc::I420Buffer>(w, h); |
| 209 time_stamp_ns_ = time_stamp_ns; | 209 time_stamp_ns_ = time_stamp_ns; |
| 210 rotation_ = webrtc::kVideoRotation_0; | 210 rotation_ = webrtc::kVideoRotation_0; |
| 211 } | 211 } |
| 212 | 212 |
| 213 const VideoFrame* WebRtcVideoFrame::GetCopyWithRotationApplied() const { | 213 const VideoFrame* WebRtcVideoFrame::GetCopyWithRotationApplied() const { |
| 214 // If the frame is not rotated, the caller should reuse this frame instead of | 214 // If the frame is not rotated, the caller should reuse this frame instead of |
| 215 // making a redundant copy. | 215 // making a redundant copy. |
| 216 if (GetVideoRotation() == webrtc::kVideoRotation_0) { | 216 if (rotation() == webrtc::kVideoRotation_0) { |
| 217 return this; | 217 return this; |
| 218 } | 218 } |
| 219 | 219 |
| 220 // If the video frame is backed up by a native handle, it resides in the GPU | 220 // If the video frame is backed up by a native handle, it resides in the GPU |
| 221 // memory which we can't rotate here. The assumption is that the renderers | 221 // memory which we can't rotate here. The assumption is that the renderers |
| 222 // which uses GPU to render should be able to rotate themselves. | 222 // which uses GPU to render should be able to rotate themselves. |
| 223 RTC_DCHECK(!GetNativeHandle()); | 223 RTC_DCHECK(!GetNativeHandle()); |
| 224 | 224 |
| 225 if (rotated_frame_) { | 225 if (rotated_frame_) { |
| 226 return rotated_frame_.get(); | 226 return rotated_frame_.get(); |
| 227 } | 227 } |
| 228 | 228 |
| 229 int orig_width = width(); | 229 int orig_width = width(); |
| 230 int orig_height = height(); | 230 int orig_height = height(); |
| 231 | 231 |
| 232 int rotated_width = orig_width; | 232 int rotated_width = orig_width; |
| 233 int rotated_height = orig_height; | 233 int rotated_height = orig_height; |
| 234 if (GetVideoRotation() == webrtc::kVideoRotation_90 || | 234 if (rotation() == webrtc::kVideoRotation_90 || |
| 235 GetVideoRotation() == webrtc::kVideoRotation_270) { | 235 rotation() == webrtc::kVideoRotation_270) { |
| 236 rotated_width = orig_height; | 236 rotated_width = orig_height; |
| 237 rotated_height = orig_width; | 237 rotated_height = orig_width; |
| 238 } | 238 } |
| 239 | 239 |
| 240 rotated_frame_.reset(CreateEmptyFrame(rotated_width, rotated_height, | 240 rotated_frame_.reset(CreateEmptyFrame(rotated_width, rotated_height, |
| 241 GetTimeStamp())); | 241 GetTimeStamp())); |
| 242 | 242 |
| 243 // TODO(guoweis): Add a function in webrtc_libyuv.cc to convert from | 243 // TODO(guoweis): Add a function in webrtc_libyuv.cc to convert from |
| 244 // VideoRotation to libyuv::RotationMode. | 244 // VideoRotation to libyuv::RotationMode. |
| 245 int ret = libyuv::I420Rotate( | 245 int ret = libyuv::I420Rotate( |
| 246 GetYPlane(), GetYPitch(), GetUPlane(), GetUPitch(), GetVPlane(), | 246 GetYPlane(), GetYPitch(), GetUPlane(), GetUPitch(), GetVPlane(), |
| 247 GetVPitch(), rotated_frame_->GetYPlane(), rotated_frame_->GetYPitch(), | 247 GetVPitch(), rotated_frame_->GetYPlane(), rotated_frame_->GetYPitch(), |
| 248 rotated_frame_->GetUPlane(), rotated_frame_->GetUPitch(), | 248 rotated_frame_->GetUPlane(), rotated_frame_->GetUPitch(), |
| 249 rotated_frame_->GetVPlane(), rotated_frame_->GetVPitch(), | 249 rotated_frame_->GetVPlane(), rotated_frame_->GetVPitch(), |
| 250 orig_width, orig_height, | 250 orig_width, orig_height, |
| 251 static_cast<libyuv::RotationMode>(GetVideoRotation())); | 251 static_cast<libyuv::RotationMode>(rotation())); |
| 252 if (ret == 0) { | 252 if (ret == 0) { |
| 253 return rotated_frame_.get(); | 253 return rotated_frame_.get(); |
| 254 } | 254 } |
| 255 return nullptr; | 255 return nullptr; |
| 256 } | 256 } |
| 257 | 257 |
| 258 } // namespace cricket | 258 } // namespace cricket |
| OLD | NEW |