| Index: webrtc/modules/video_capture/video_capture_impl.cc
|
| diff --git a/webrtc/modules/video_capture/video_capture_impl.cc b/webrtc/modules/video_capture/video_capture_impl.cc
|
| index 0afa9aabeed2a4164f2c23bcdf7d7aa14b6a6640..a0908f027b0c1924966fcd01ce5df2356535e8a9 100644
|
| --- a/webrtc/modules/video_capture/video_capture_impl.cc
|
| +++ b/webrtc/modules/video_capture/video_capture_impl.cc
|
| @@ -32,8 +32,9 @@
|
| return implementation;
|
| }
|
|
|
| -const char* VideoCaptureImpl::CurrentDeviceName() const {
|
| - return _deviceUniqueId;
|
| +const char* VideoCaptureImpl::CurrentDeviceName() const
|
| +{
|
| + return _deviceUniqueId;
|
| }
|
|
|
| // static
|
| @@ -135,13 +136,14 @@
|
|
|
| // Not encoded, convert to I420.
|
| const VideoType commonVideoType =
|
| - RawVideoTypeToCommonVideoVideoType(frameInfo.rawType);
|
| + RawVideoTypeToCommonVideoVideoType(frameInfo.rawType);
|
|
|
| if (frameInfo.rawType != kVideoMJPEG &&
|
| - CalcBufferSize(commonVideoType, width, abs(height)) !=
|
| - videoFrameLength) {
|
| - LOG(LS_ERROR) << "Wrong incoming frame length.";
|
| - return -1;
|
| + CalcBufferSize(commonVideoType, width,
|
| + abs(height)) != videoFrameLength)
|
| + {
|
| + LOG(LS_ERROR) << "Wrong incoming frame length.";
|
| + return -1;
|
| }
|
|
|
| int stride_y = width;
|
| @@ -172,14 +174,16 @@
|
| commonVideoType, videoFrame, 0, 0, // No cropping
|
| width, height, videoFrameLength,
|
| apply_rotation ? _rotateFrame : kVideoRotation_0, buffer.get());
|
| - if (conversionResult < 0) {
|
| + if (conversionResult < 0)
|
| + {
|
| LOG(LS_ERROR) << "Failed to convert capture frame from type "
|
| << frameInfo.rawType << "to I420.";
|
| - return -1;
|
| - }
|
| -
|
| - VideoFrame captureFrame(buffer, 0, rtc::TimeMillis(),
|
| - !apply_rotation ? _rotateFrame : kVideoRotation_0);
|
| + return -1;
|
| + }
|
| +
|
| + VideoFrame captureFrame(
|
| + buffer, 0, rtc::TimeMillis(),
|
| + !apply_rotation ? _rotateFrame : kVideoRotation_0);
|
| captureFrame.set_ntp_time_ms(captureTime);
|
|
|
| DeliverCapturedFrame(captureFrame);
|
| @@ -201,40 +205,52 @@
|
| return true;
|
| }
|
|
|
| -void VideoCaptureImpl::UpdateFrameCount() {
|
| - if (_incomingFrameTimesNanos[0] / rtc::kNumNanosecsPerMicrosec == 0) {
|
| - // first no shift
|
| - } else {
|
| - // shift
|
| - for (int i = (kFrameRateCountHistorySize - 2); i >= 0; --i) {
|
| - _incomingFrameTimesNanos[i + 1] = _incomingFrameTimesNanos[i];
|
| - }
|
| - }
|
| - _incomingFrameTimesNanos[0] = rtc::TimeNanos();
|
| -}
|
| -
|
| -uint32_t VideoCaptureImpl::CalculateFrameRate(int64_t now_ns) {
|
| - int32_t num = 0;
|
| - int32_t nrOfFrames = 0;
|
| - for (num = 1; num < (kFrameRateCountHistorySize - 1); ++num) {
|
| - if (_incomingFrameTimesNanos[num] <= 0 ||
|
| - (now_ns - _incomingFrameTimesNanos[num]) /
|
| - rtc::kNumNanosecsPerMillisec >
|
| - kFrameRateHistoryWindowMs) { // don't use data older than 2sec
|
| - break;
|
| - } else {
|
| - nrOfFrames++;
|
| - }
|
| - }
|
| - if (num > 1) {
|
| - int64_t diff = (now_ns - _incomingFrameTimesNanos[num - 1]) /
|
| - rtc::kNumNanosecsPerMillisec;
|
| - if (diff > 0) {
|
| - return uint32_t((nrOfFrames * 1000.0f / diff) + 0.5f);
|
| - }
|
| - }
|
| -
|
| - return nrOfFrames;
|
| +void VideoCaptureImpl::UpdateFrameCount()
|
| +{
|
| + if (_incomingFrameTimesNanos[0] / rtc::kNumNanosecsPerMicrosec == 0)
|
| + {
|
| + // first no shift
|
| + }
|
| + else
|
| + {
|
| + // shift
|
| + for (int i = (kFrameRateCountHistorySize - 2); i >= 0; i--)
|
| + {
|
| + _incomingFrameTimesNanos[i + 1] = _incomingFrameTimesNanos[i];
|
| + }
|
| + }
|
| + _incomingFrameTimesNanos[0] = rtc::TimeNanos();
|
| +}
|
| +
|
| +uint32_t VideoCaptureImpl::CalculateFrameRate(int64_t now_ns)
|
| +{
|
| + int32_t num = 0;
|
| + int32_t nrOfFrames = 0;
|
| + for (num = 1; num < (kFrameRateCountHistorySize - 1); num++)
|
| + {
|
| + if (_incomingFrameTimesNanos[num] <= 0 ||
|
| + (now_ns - _incomingFrameTimesNanos[num]) /
|
| + rtc::kNumNanosecsPerMillisec >
|
| + kFrameRateHistoryWindowMs) // don't use data older than 2sec
|
| + {
|
| + break;
|
| + }
|
| + else
|
| + {
|
| + nrOfFrames++;
|
| + }
|
| + }
|
| + if (num > 1)
|
| + {
|
| + int64_t diff = (now_ns - _incomingFrameTimesNanos[num - 1]) /
|
| + rtc::kNumNanosecsPerMillisec;
|
| + if (diff > 0)
|
| + {
|
| + return uint32_t((nrOfFrames * 1000.0f / diff) + 0.5f);
|
| + }
|
| + }
|
| +
|
| + return nrOfFrames;
|
| }
|
| } // namespace videocapturemodule
|
| } // namespace webrtc
|
|
|