Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Unified Diff: webrtc/modules/video_capture/video_capture_impl.cc

Issue 1888593004: Delete all use of tick_util.h. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Address Stefan's comments. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 b1e697edc22eae7b21bfbc306d5e550c54bceebe..3f356e3d177ee4e1d217c5cadd2efd686d2f747a 100644
--- a/webrtc/modules/video_capture/video_capture_impl.cc
+++ b/webrtc/modules/video_capture/video_capture_impl.cc
@@ -13,6 +13,7 @@
#include <stdlib.h>
#include "webrtc/base/refcount.h"
+#include "webrtc/base/timeutils.h"
#include "webrtc/base/trace_event.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/modules/include/module_common_types.h"
@@ -20,7 +21,6 @@
#include "webrtc/system_wrappers/include/clock.h"
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
#include "webrtc/system_wrappers/include/logging.h"
-#include "webrtc/system_wrappers/include/tick_util.h"
namespace webrtc {
namespace videocapturemodule {
@@ -85,7 +85,8 @@ int64_t VideoCaptureImpl::TimeUntilNextProcess()
CriticalSectionScoped cs(&_callBackCs);
const int64_t kProcessIntervalMs = 300;
return kProcessIntervalMs -
- (TickTime::Now() - _lastProcessTime).Milliseconds();
+ (rtc::TimeNanos() - _lastProcessTimeNanos) /
+ rtc::kNumNanosecsPerMillisec;
}
// Process any pending tasks such as timeouts
@@ -93,12 +94,12 @@ void VideoCaptureImpl::Process()
{
CriticalSectionScoped cs(&_callBackCs);
- const TickTime now = TickTime::Now();
- _lastProcessTime = TickTime::Now();
+ const int64_t now_ns = rtc::TimeNanos();
stefan-webrtc 2016/04/19 12:40:47 Doesn't seem right that we store this in an int64_
nisse-webrtc 2016/04/19 13:48:51 I agree this isn't ideal, but it's no change: It's
+ _lastProcessTimeNanos = rtc::TimeNanos();
// Handle No picture alarm
- if (_lastProcessFrameCount.Ticks() == _incomingFrameTimes[0].Ticks() &&
+ if (_lastProcessFrameTimeNanos == _incomingFrameTimesNanos[0] &&
_captureAlarm != Raised)
{
if (_noPictureAlarmCallBack && _captureCallBack)
@@ -107,7 +108,7 @@ void VideoCaptureImpl::Process()
_captureCallBack->OnNoPictureAlarm(_id, _captureAlarm);
}
}
- else if (_lastProcessFrameCount.Ticks() != _incomingFrameTimes[0].Ticks() &&
+ else if (_lastProcessFrameTimeNanos != _incomingFrameTimesNanos[0] &&
_captureAlarm != Cleared)
{
if (_noPictureAlarmCallBack && _captureCallBack)
@@ -119,19 +120,20 @@ void VideoCaptureImpl::Process()
}
// Handle frame rate callback
- if ((now - _lastFrameRateCallbackTime).Milliseconds()
+ if ((now_ns - _lastFrameRateCallbackTimeNanos) /
+ rtc::kNumNanosecsPerMillisec
> kFrameRateCallbackInterval)
{
if (_frameRateCallBack && _captureCallBack)
{
- const uint32_t frameRate = CalculateFrameRate(now);
+ const uint32_t frameRate = CalculateFrameRate(now_ns);
_captureCallBack->OnCaptureFrameRate(_id, frameRate);
}
- _lastFrameRateCallbackTime = now; // Can be set by EnableFrameRateCallback
+ _lastFrameRateCallbackTimeNanos = now_ns; // Can be set by EnableFrameRateCallback
}
- _lastProcessFrameCount = _incomingFrameTimes[0];
+ _lastProcessFrameTimeNanos = _incomingFrameTimesNanos[0];
}
VideoCaptureImpl::VideoCaptureImpl(const int32_t id)
@@ -141,15 +143,15 @@ VideoCaptureImpl::VideoCaptureImpl(const int32_t id)
_captureDelay(0),
_requestedCapability(),
_callBackCs(*CriticalSectionWrapper::CreateCriticalSection()),
- _lastProcessTime(TickTime::Now()),
- _lastFrameRateCallbackTime(TickTime::Now()),
+ _lastProcessTimeNanos(rtc::TimeNanos()),
+ _lastFrameRateCallbackTimeNanos(rtc::TimeNanos()),
_frameRateCallBack(false),
_noPictureAlarmCallBack(false),
_captureAlarm(Cleared),
_setCaptureDelay(0),
_dataCallBack(NULL),
_captureCallBack(NULL),
- _lastProcessFrameCount(TickTime::Now()),
+ _lastProcessFrameTimeNanos(rtc::TimeNanos()),
_rotateFrame(kVideoRotation_0),
apply_rotation_(false) {
_requestedCapability.width = kDefaultWidth;
@@ -157,7 +159,7 @@ VideoCaptureImpl::VideoCaptureImpl(const int32_t id)
_requestedCapability.maxFPS = 30;
_requestedCapability.rawType = kVideoI420;
_requestedCapability.codecType = kVideoCodecUnknown;
- memset(_incomingFrameTimes, 0, sizeof(_incomingFrameTimes));
+ memset(_incomingFrameTimesNanos, 0, sizeof(_incomingFrameTimesNanos));
}
VideoCaptureImpl::~VideoCaptureImpl()
@@ -295,7 +297,7 @@ int32_t VideoCaptureImpl::IncomingFrame(
_captureFrame.set_rotation(kVideoRotation_0);
}
_captureFrame.set_ntp_time_ms(captureTime);
- _captureFrame.set_render_time_ms(TickTime::MillisecondTimestamp());
+ _captureFrame.set_render_time_ms(rtc::Time64());
DeliverCapturedFrame(_captureFrame);
}
@@ -321,7 +323,7 @@ void VideoCaptureImpl::EnableFrameRateCallback(const bool enable) {
_frameRateCallBack = enable;
if (enable)
{
- _lastFrameRateCallbackTime = TickTime::Now();
+ _lastFrameRateCallbackTimeNanos = rtc::TimeNanos();
}
}
@@ -341,7 +343,7 @@ void VideoCaptureImpl::EnableNoPictureAlarm(const bool enable) {
void VideoCaptureImpl::UpdateFrameCount()
{
- if (_incomingFrameTimes[0].MicrosecondTimestamp() == 0)
+ if (_incomingFrameTimesNanos[0] / rtc::kNumNanosecsPerMicrosec == 0)
{
// first no shift
}
@@ -350,20 +352,22 @@ void VideoCaptureImpl::UpdateFrameCount()
// shift
for (int i = (kFrameRateCountHistorySize - 2); i >= 0; i--)
{
- _incomingFrameTimes[i + 1] = _incomingFrameTimes[i];
+ _incomingFrameTimesNanos[i + 1] = _incomingFrameTimesNanos[i];
}
}
- _incomingFrameTimes[0] = TickTime::Now();
+ _incomingFrameTimesNanos[0] = rtc::TimeNanos();
}
-uint32_t VideoCaptureImpl::CalculateFrameRate(const TickTime& now)
+uint32_t VideoCaptureImpl::CalculateFrameRate(int64_t now_ns)
{
int32_t num = 0;
int32_t nrOfFrames = 0;
for (num = 1; num < (kFrameRateCountHistorySize - 1); num++)
{
- if (_incomingFrameTimes[num].Ticks() <= 0
- || (now - _incomingFrameTimes[num]).Milliseconds() > kFrameRateHistoryWindowMs) // don't use data older than 2sec
+ if (_incomingFrameTimesNanos[num] <= 0 ||
+ (now_ns - _incomingFrameTimesNanos[num]) /
+ rtc::kNumNanosecsPerMillisec >
+ kFrameRateHistoryWindowMs) // don't use data older than 2sec
{
break;
}
@@ -374,7 +378,8 @@ uint32_t VideoCaptureImpl::CalculateFrameRate(const TickTime& now)
}
if (num > 1)
{
- int64_t diff = (now - _incomingFrameTimes[num - 1]).Milliseconds();
+ int64_t diff = (now_ns - _incomingFrameTimesNanos[num - 1]) /
+ rtc::kNumNanosecsPerMillisec;
if (diff > 0)
{
return uint32_t((nrOfFrames * 1000.0f / diff) + 0.5f);
« no previous file with comments | « webrtc/modules/video_capture/video_capture_impl.h ('k') | webrtc/modules/video_coding/codecs/test/videoprocessor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698