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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 WebRtcVideoFrame::GetVideoFrameBuffer() const { | 124 WebRtcVideoFrame::GetVideoFrameBuffer() 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 bool WebRtcVideoFrame::MakeExclusive() { | |
135 RTC_DCHECK(video_frame_buffer_->native_handle() == nullptr); | |
136 if (IsExclusive()) | |
137 return true; | |
138 | |
139 // Not exclusive already, need to copy buffer. | |
140 rtc::scoped_refptr<webrtc::VideoFrameBuffer> new_buffer = | |
141 new rtc::RefCountedObject<webrtc::I420Buffer>( | |
142 video_frame_buffer_->width(), video_frame_buffer_->height(), | |
143 video_frame_buffer_->stride(kYPlane), | |
144 video_frame_buffer_->stride(kUPlane), | |
145 video_frame_buffer_->stride(kVPlane)); | |
146 | |
147 if (!CopyToPlanes( | |
148 new_buffer->MutableData(kYPlane), new_buffer->MutableData(kUPlane), | |
149 new_buffer->MutableData(kVPlane), new_buffer->stride(kYPlane), | |
150 new_buffer->stride(kUPlane), new_buffer->stride(kVPlane))) { | |
151 return false; | |
152 } | |
153 | |
154 video_frame_buffer_ = new_buffer; | |
155 return true; | |
156 } | |
157 | |
158 size_t WebRtcVideoFrame::ConvertToRgbBuffer(uint32_t to_fourcc, | 134 size_t WebRtcVideoFrame::ConvertToRgbBuffer(uint32_t to_fourcc, |
159 uint8_t* buffer, | 135 uint8_t* buffer, |
160 size_t size, | 136 size_t size, |
161 int stride_rgb) const { | 137 int stride_rgb) const { |
162 RTC_CHECK(video_frame_buffer_); | 138 RTC_CHECK(video_frame_buffer_); |
163 RTC_CHECK(video_frame_buffer_->native_handle() == nullptr); | 139 RTC_CHECK(video_frame_buffer_->native_handle() == nullptr); |
164 return VideoFrame::ConvertToRgbBuffer(to_fourcc, buffer, size, stride_rgb); | 140 return VideoFrame::ConvertToRgbBuffer(to_fourcc, buffer, size, stride_rgb); |
165 } | 141 } |
166 | 142 |
167 bool WebRtcVideoFrame::Reset(uint32_t format, | 143 bool WebRtcVideoFrame::Reset(uint32_t format, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 rotated_frame_->GetUPlane(), rotated_frame_->GetUPitch(), | 248 rotated_frame_->GetUPlane(), rotated_frame_->GetUPitch(), |
273 rotated_frame_->GetVPlane(), rotated_frame_->GetVPitch(), width, height, | 249 rotated_frame_->GetVPlane(), rotated_frame_->GetVPitch(), width, height, |
274 static_cast<libyuv::RotationMode>(GetVideoRotation())); | 250 static_cast<libyuv::RotationMode>(GetVideoRotation())); |
275 if (ret == 0) { | 251 if (ret == 0) { |
276 return rotated_frame_.get(); | 252 return rotated_frame_.get(); |
277 } | 253 } |
278 return nullptr; | 254 return nullptr; |
279 } | 255 } |
280 | 256 |
281 } // namespace cricket | 257 } // namespace cricket |
OLD | NEW |