OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 if (_rotateFrame == kVideoRotation_90 || | 268 if (_rotateFrame == kVideoRotation_90 || |
269 _rotateFrame == kVideoRotation_270) { | 269 _rotateFrame == kVideoRotation_270) { |
270 target_width = abs(height); | 270 target_width = abs(height); |
271 target_height = width; | 271 target_height = width; |
272 } | 272 } |
273 } | 273 } |
274 | 274 |
275 // Setting absolute height (in case it was negative). | 275 // Setting absolute height (in case it was negative). |
276 // In Windows, the image starts bottom left, instead of top left. | 276 // In Windows, the image starts bottom left, instead of top left. |
277 // Setting a negative source height, inverts the image (within LibYuv). | 277 // Setting a negative source height, inverts the image (within LibYuv). |
278 _captureFrame.CreateEmptyFrame(target_width, | 278 |
279 abs(target_height), | 279 // TODO(nisse): Use a pool? |
280 stride_y, | 280 rtc::scoped_refptr<I420Buffer> buffer = I420Buffer::Create( |
281 stride_uv, stride_uv); | 281 target_width, abs(target_height), stride_y, stride_uv, stride_uv); |
282 const int conversionResult = ConvertToI420( | 282 const int conversionResult = ConvertToI420( |
283 commonVideoType, videoFrame, 0, 0, // No cropping | 283 commonVideoType, videoFrame, 0, 0, // No cropping |
284 width, height, videoFrameLength, | 284 width, height, videoFrameLength, |
285 apply_rotation ? _rotateFrame : kVideoRotation_0, &_captureFrame); | 285 apply_rotation ? _rotateFrame : kVideoRotation_0, buffer.get()); |
286 if (conversionResult < 0) | 286 if (conversionResult < 0) |
287 { | 287 { |
288 LOG(LS_ERROR) << "Failed to convert capture frame from type " | 288 LOG(LS_ERROR) << "Failed to convert capture frame from type " |
289 << frameInfo.rawType << "to I420."; | 289 << frameInfo.rawType << "to I420."; |
290 return -1; | 290 return -1; |
291 } | 291 } |
292 | 292 |
293 if (!apply_rotation) { | 293 VideoFrame captureFrame( |
294 _captureFrame.set_rotation(_rotateFrame); | 294 buffer, 0, rtc::TimeMillis(), |
295 } else { | 295 !apply_rotation ? _rotateFrame : kVideoRotation_0); |
296 _captureFrame.set_rotation(kVideoRotation_0); | 296 captureFrame.set_ntp_time_ms(captureTime); |
297 } | |
298 _captureFrame.set_ntp_time_ms(captureTime); | |
299 _captureFrame.set_render_time_ms(rtc::TimeMillis()); | |
perkj_webrtc
2016/09/13 15:29:22
render_time_ms set somewhere else?
nisse-webrtc
2016/09/14 06:59:05
Besides test code, it seems it is called in webrtc
| |
300 | 297 |
301 DeliverCapturedFrame(_captureFrame); | 298 DeliverCapturedFrame(captureFrame); |
302 } | 299 } |
303 else // Encoded format | 300 else // Encoded format |
304 { | 301 { |
305 assert(false); | 302 assert(false); |
306 return -1; | 303 return -1; |
307 } | 304 } |
308 | 305 |
309 return 0; | 306 return 0; |
310 } | 307 } |
311 | 308 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 if (diff > 0) | 379 if (diff > 0) |
383 { | 380 { |
384 return uint32_t((nrOfFrames * 1000.0f / diff) + 0.5f); | 381 return uint32_t((nrOfFrames * 1000.0f / diff) + 0.5f); |
385 } | 382 } |
386 } | 383 } |
387 | 384 |
388 return nrOfFrames; | 385 return nrOfFrames; |
389 } | 386 } |
390 } // namespace videocapturemodule | 387 } // namespace videocapturemodule |
391 } // namespace webrtc | 388 } // namespace webrtc |
OLD | NEW |