From fbf5af444b67d8fabf15dd77823fdebee7b41d72 Mon Sep 17 00:00:00 2001 From: "henrik.lundin@webrtc.org" Date: Wed, 14 Dec 2011 10:36:10 +0000 Subject: [PATCH] Adding a mockable wrapper class for TickTime in VCM The class is called TickTimeInterface, with a fake implementation in FakeTickTime. Review URL: http://webrtc-codereview.appspot.com/323012 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1183 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../source/mock/fake_tick_time_interface.h | 42 +++++++++++++++++++ .../main/source/tick_time_interface.h | 36 ++++++++++++++++ .../main/source/video_coding.gypi | 1 + 3 files changed, 79 insertions(+) create mode 100644 src/modules/video_coding/main/source/mock/fake_tick_time_interface.h create mode 100644 src/modules/video_coding/main/source/tick_time_interface.h diff --git a/src/modules/video_coding/main/source/mock/fake_tick_time_interface.h b/src/modules/video_coding/main/source/mock/fake_tick_time_interface.h new file mode 100644 index 000000000..0b8cbaa67 --- /dev/null +++ b/src/modules/video_coding/main/source/mock/fake_tick_time_interface.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "modules/video_coding/main/source/tick_time_wrapper.h" + +#ifndef WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_MOCK_FAKE_TICK_TIME_WRAPPER_H_ +#define WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_MOCK_FAKE_TICK_TIME_WRAPPER_H_ + +namespace webrtc { + +class FakeTickTime : public TickTimeInterface +{ + public: + FakeTickTime(int64_t start_time_ms) + : fake_now_(TickTime::Now()) { + fake_now_ += (MillisecondsToTicks(start_time_ms) - fake_now_.Ticks()); + } + virtual TickTime Now() const { return fake_now_; } + virtual int64_t MillisecondTimestamp() const { + return TicksToMilliseconds(Now().Ticks()); + } + virtual int64_t MicrosecondTimestamp() const { + return 1000 * TicksToMilliseconds(Now().Ticks()); + } + virtual void IncrementDebugClock(int64_t increase_ms) { + fake_now_ += MillisecondsToTicks(increase_ms); + } + + private: + TickTime fake_now_; +}; + +} // namespace + +#endif // WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_MOCK_FAKE_TICK_TIME_WRAPPER_H_ diff --git a/src/modules/video_coding/main/source/tick_time_interface.h b/src/modules/video_coding/main/source/tick_time_interface.h new file mode 100644 index 000000000..1ab63e278 --- /dev/null +++ b/src/modules/video_coding/main/source/tick_time_interface.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "system_wrappers/interface/tick_util.h" + +#ifndef WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_TICK_TIME_WRAPPER_H_ +#define WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_TICK_TIME_WRAPPER_H_ + +namespace webrtc { + +class TickTimeInterface : public TickTime { + public: + // Current time in the tick domain. + virtual TickTime Now() const { return TickTime::Now(); } + + // Now in the time domain in ms. + virtual int64_t MillisecondTimestamp() const { + return TickTime::MillisecondTimestamp(); + } + + // Now in the time domain in us. + virtual int64_t MicrosecondTimestamp() const { + return TickTime::MicrosecondTimestamp(); + } +}; + +} // namespace + +#endif // WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_TICK_TIME_WRAPPER_H_ diff --git a/src/modules/video_coding/main/source/video_coding.gypi b/src/modules/video_coding/main/source/video_coding.gypi index 3b790389a..21598965d 100644 --- a/src/modules/video_coding/main/source/video_coding.gypi +++ b/src/modules/video_coding/main/source/video_coding.gypi @@ -64,6 +64,7 @@ 'rtt_filter.h', 'session_info.h', 'tick_time.h', + 'tick_time_interface.h', 'timestamp_extrapolator.h', 'timestamp_map.h', 'timing.h',