Chromium Code Reviews| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 wants.max_pixel_count_step_up); | 217 wants.max_pixel_count_step_up); |
| 218 } | 218 } |
| 219 } | 219 } |
| 220 | 220 |
| 221 void VideoCapturer::OnFrameCaptured(VideoCapturer*, | 221 void VideoCapturer::OnFrameCaptured(VideoCapturer*, |
| 222 const CapturedFrame* captured_frame) { | 222 const CapturedFrame* captured_frame) { |
| 223 if (!broadcaster_.frame_wanted()) { | 223 if (!broadcaster_.frame_wanted()) { |
| 224 return; | 224 return; |
| 225 } | 225 } |
| 226 | 226 |
| 227 int64_t timestamp_us = | |
|
perkj_webrtc
2016/04/08 08:22:48
do this in the frame factory instead.
nisse-webrtc
2016/04/08 09:15:43
Moving the logic there makes sense, I'll give it a
| |
| 228 captured_frame->time_stamp / rtc::kNumNanosecsPerMicrosec; | |
| 229 | |
| 230 if (!timestamp_offset_valid_) { | |
| 231 timestamp_offset_ = rtc::TimeMicros() - timestamp_us; | |
| 232 timestamp_offset_valid_ = true; | |
| 233 } | |
| 234 | |
| 235 // Add offset, to get time stamps with the same epoch as the | |
| 236 // system monotonic clock, rtc::TimeMicros(). | |
| 237 timestamp_us += timestamp_offset_; | |
| 238 | |
| 227 // Use a temporary buffer to scale | 239 // Use a temporary buffer to scale |
| 228 std::unique_ptr<uint8_t[]> scale_buffer; | 240 std::unique_ptr<uint8_t[]> scale_buffer; |
| 229 if (IsScreencast()) { | 241 if (IsScreencast()) { |
| 230 int scaled_width, scaled_height; | 242 int scaled_width, scaled_height; |
| 231 int desired_screencast_fps = | 243 int desired_screencast_fps = |
| 232 capture_format_.get() | 244 capture_format_.get() |
| 233 ? VideoFormat::IntervalToFps(capture_format_->interval) | 245 ? VideoFormat::IntervalToFps(capture_format_->interval) |
| 234 : kDefaultScreencastFps; | 246 : kDefaultScreencastFps; |
| 235 ComputeScale(captured_frame->width, captured_frame->height, | 247 ComputeScale(captured_frame->width, captured_frame->height, |
| 236 desired_screencast_fps, &scaled_width, &scaled_height); | 248 desired_screencast_fps, &scaled_width, &scaled_height); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 adapted_width, adapted_height)); | 401 adapted_width, adapted_height)); |
| 390 | 402 |
| 391 if (!adapted_frame) { | 403 if (!adapted_frame) { |
| 392 // TODO(fbarchard): LOG more information about captured frame attributes. | 404 // TODO(fbarchard): LOG more information about captured frame attributes. |
| 393 LOG(LS_ERROR) << "Couldn't convert to I420! " | 405 LOG(LS_ERROR) << "Couldn't convert to I420! " |
| 394 << "From " << ToString(captured_frame) << " To " | 406 << "From " << ToString(captured_frame) << " To " |
| 395 << cropped_width << " x " << cropped_height; | 407 << cropped_width << " x " << cropped_height; |
| 396 return; | 408 return; |
| 397 } | 409 } |
| 398 | 410 |
| 411 // Overrides the timestamp set by the FrameFactory. | |
| 412 // TODO(nisse): Arrange to either get the FrameFactory to set the | |
| 413 // timestamp with correct offset, or not set the timestamp at all. | |
| 414 adapted_frame->set_timestamp_us(timestamp_us); | |
| 415 | |
| 399 OnFrame(this, adapted_frame.get()); | 416 OnFrame(this, adapted_frame.get()); |
| 400 UpdateInputSize(captured_frame); | 417 UpdateInputSize(captured_frame); |
| 401 } | 418 } |
| 402 | 419 |
| 403 void VideoCapturer::OnFrame(VideoCapturer* capturer, const VideoFrame* frame) { | 420 void VideoCapturer::OnFrame(VideoCapturer* capturer, const VideoFrame* frame) { |
| 404 broadcaster_.OnFrame(*frame); | 421 broadcaster_.OnFrame(*frame); |
|
perkj_webrtc
2016/04/08 08:22:48
Unfortunately there are capturers that does not us
nisse-webrtc
2016/04/08 09:15:43
That code then has to produce the right timestamps
| |
| 405 } | 422 } |
| 406 | 423 |
| 407 void VideoCapturer::SetCaptureState(CaptureState state) { | 424 void VideoCapturer::SetCaptureState(CaptureState state) { |
| 408 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 425 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 409 if (state == capture_state_) { | 426 if (state == capture_state_) { |
| 410 // Don't trigger a state changed callback if the state hasn't changed. | 427 // Don't trigger a state changed callback if the state hasn't changed. |
| 411 return; | 428 return; |
| 412 } | 429 } |
| 413 capture_state_ = state; | 430 capture_state_ = state; |
| 414 SignalStateChange(this, capture_state_); | 431 SignalStateChange(this, capture_state_); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 void VideoCapturer::UpdateInputSize(const CapturedFrame* captured_frame) { | 562 void VideoCapturer::UpdateInputSize(const CapturedFrame* captured_frame) { |
| 546 // Update stats protected from fetches from different thread. | 563 // Update stats protected from fetches from different thread. |
| 547 rtc::CritScope cs(&frame_stats_crit_); | 564 rtc::CritScope cs(&frame_stats_crit_); |
| 548 | 565 |
| 549 input_size_valid_ = true; | 566 input_size_valid_ = true; |
| 550 input_width_ = captured_frame->width; | 567 input_width_ = captured_frame->width; |
| 551 input_height_ = captured_frame->height; | 568 input_height_ = captured_frame->height; |
| 552 } | 569 } |
| 553 | 570 |
| 554 } // namespace cricket | 571 } // namespace cricket |
| OLD | NEW |