OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2010 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 } | 209 } |
210 | 210 |
211 if (video_adapter()) { | 211 if (video_adapter()) { |
212 video_adapter()->OnResolutionRequest(wants.max_pixel_count, | 212 video_adapter()->OnResolutionRequest(wants.max_pixel_count, |
213 wants.max_pixel_count_step_up); | 213 wants.max_pixel_count_step_up); |
214 } | 214 } |
215 } | 215 } |
216 | 216 |
217 bool VideoCapturer::AdaptFrame(int width, | 217 bool VideoCapturer::AdaptFrame(int width, |
218 int height, | 218 int height, |
219 // TODO(nisse): Switch to us unit. | 219 int64_t camera_time_us, |
220 int64_t capture_time_ns, | 220 int64_t system_time_us, |
221 int* out_width, | 221 int* out_width, |
222 int* out_height, | 222 int* out_height, |
223 int* crop_width, | 223 int* crop_width, |
224 int* crop_height, | 224 int* crop_height, |
225 int* crop_x, | 225 int* crop_x, |
226 int* crop_y) { | 226 int* crop_y, |
| 227 int64_t* translated_camera_time_us) { |
| 228 int64_t offset_us = |
| 229 translated_camera_time_us |
| 230 ? timestamp_aligner_.UpdateOffset(camera_time_us, system_time_us) |
| 231 : 0; |
| 232 |
227 if (!broadcaster_.frame_wanted()) { | 233 if (!broadcaster_.frame_wanted()) { |
228 return false; | 234 return false; |
229 } | 235 } |
230 | 236 |
231 if (enable_video_adapter_ && !IsScreencast()) { | 237 if (enable_video_adapter_ && !IsScreencast()) { |
232 if (!video_adapter_.AdaptFrameResolution( | 238 if (!video_adapter_.AdaptFrameResolution( |
233 width, height, capture_time_ns, | 239 width, height, camera_time_us * rtc::kNumNanosecsPerMicrosec, |
234 crop_width, crop_height, out_width, out_height)) { | 240 crop_width, crop_height, out_width, out_height)) { |
235 // VideoAdapter dropped the frame. | 241 // VideoAdapter dropped the frame. |
236 return false; | 242 return false; |
237 } | 243 } |
238 *crop_x = (width - *crop_width) / 2; | 244 *crop_x = (width - *crop_width) / 2; |
239 *crop_y = (height - *crop_height) / 2; | 245 *crop_y = (height - *crop_height) / 2; |
240 } else { | 246 } else { |
241 *out_width = width; | 247 *out_width = width; |
242 *out_height = height; | 248 *out_height = height; |
243 *crop_width = width; | 249 *crop_width = width; |
244 *crop_height = height; | 250 *crop_height = height; |
245 *crop_x = 0; | 251 *crop_x = 0; |
246 *crop_y = 0; | 252 *crop_y = 0; |
247 } | 253 } |
| 254 |
| 255 if (translated_camera_time_us) { |
| 256 *translated_camera_time_us = timestamp_aligner_.ClipTimestamp( |
| 257 camera_time_us + offset_us, system_time_us); |
| 258 } |
248 return true; | 259 return true; |
249 } | 260 } |
250 | 261 |
251 void VideoCapturer::OnFrameCaptured(VideoCapturer*, | 262 void VideoCapturer::OnFrameCaptured(VideoCapturer*, |
252 const CapturedFrame* captured_frame) { | 263 const CapturedFrame* captured_frame) { |
253 int out_width; | 264 int out_width; |
254 int out_height; | 265 int out_height; |
255 int crop_width; | 266 int crop_width; |
256 int crop_height; | 267 int crop_height; |
257 int crop_x; | 268 int crop_x; |
258 int crop_y; | 269 int crop_y; |
259 | 270 |
| 271 // TODO(nisse): We don't do timestamp translation on this input |
| 272 // path. It seems straight-forward to enable translation, but that |
| 273 // breaks the WebRtcVideoEngine2Test.PropagatesInputFrameTimestamp |
| 274 // test. Probably not worth the effort to fix, instead, try to |
| 275 // delete or refactor all code using VideoFrameFactory and |
| 276 // SignalCapturedFrame. |
260 if (!AdaptFrame(captured_frame->width, captured_frame->height, | 277 if (!AdaptFrame(captured_frame->width, captured_frame->height, |
261 captured_frame->time_stamp, | 278 captured_frame->time_stamp / rtc::kNumNanosecsPerMicrosec, |
| 279 0, |
262 &out_width, &out_height, | 280 &out_width, &out_height, |
263 &crop_width, &crop_height, &crop_x, &crop_y)) { | 281 &crop_width, &crop_height, &crop_x, &crop_y, nullptr)) { |
264 return; | 282 return; |
265 } | 283 } |
266 | 284 |
267 if (!frame_factory_) { | 285 if (!frame_factory_) { |
268 LOG(LS_ERROR) << "No video frame factory."; | 286 LOG(LS_ERROR) << "No video frame factory."; |
269 return; | 287 return; |
270 } | 288 } |
271 | 289 |
272 // TODO(nisse): Reorganize frame factory methods. crop_x and crop_y | 290 // TODO(nisse): Reorganize frame factory methods. crop_x and crop_y |
273 // are ignored for now. | 291 // are ignored for now. |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 void VideoCapturer::UpdateInputSize(int width, int height) { | 451 void VideoCapturer::UpdateInputSize(int width, int height) { |
434 // Update stats protected from fetches from different thread. | 452 // Update stats protected from fetches from different thread. |
435 rtc::CritScope cs(&frame_stats_crit_); | 453 rtc::CritScope cs(&frame_stats_crit_); |
436 | 454 |
437 input_size_valid_ = true; | 455 input_size_valid_ = true; |
438 input_width_ = width; | 456 input_width_ = width; |
439 input_height_ = height; | 457 input_height_ = height; |
440 } | 458 } |
441 | 459 |
442 } // namespace cricket | 460 } // namespace cricket |
OLD | NEW |