Source release 17.1.0

This commit is contained in:
John "Juce" Bruce
2022-07-07 17:14:31 -07:00
parent 8c17574083
commit 694cf6fb25
2233 changed files with 272026 additions and 223371 deletions

View File

@@ -1,6 +1,6 @@
// Copyright 2019 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine Master
// License Agreement.
// source code may only be used and distributed under the Widevine License
// Agreement.
#include "test_sleep.h"
@@ -9,6 +9,9 @@
#else
# include <sys/types.h>
#endif
#ifdef __APPLE__
# include <TargetConditionals.h>
#endif
#include <errno.h>
#include <string.h>
@@ -19,7 +22,7 @@
#include "clock.h"
#include "log.h"
namespace wvcdm {
namespace wvutil {
bool TestSleep::real_sleep_ = true;
TestSleep::CallBack* TestSleep::callback_ = nullptr;
@@ -55,6 +58,21 @@ void TestSleep::SyncFakeClock() {
Sleep(0);
}
void TestSleep::SetFakeClock(int64_t time_seconds) {
if (real_sleep_) {
LOGE("SetFakeClock when using a real clock. Expect other failures.");
}
// Delta could be positive or negative. If the fake clock had been initialized
// by the current time on a real clock, and then the command line
// re-initializes it to 0, then delta is negative.
int64_t delta = time_seconds - Clock().GetCurrentTime();
if (callback_ != nullptr) {
callback_->ElapseTime(delta * 1000);
} else {
LOGE("Setting fake clock with no callback. This won't work.");
}
}
bool TestSleep::RollbackSystemTime(int seconds) {
if (real_sleep_) {
#ifdef _WIN32
@@ -73,10 +91,13 @@ bool TestSleep::RollbackSystemTime(int seconds) {
file_time.dwHighDateTime = long_time >> 32;
if (!FileTimeToSystemTime(&file_time, &time)) return false;
if (!SetSystemTime(&time)) return false;
#elif TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
LOGE("iOS time rollback: cannot set system time.");
return false;
#else
auto time = std::chrono::system_clock::now();
auto modified_time = time - std::chrono::seconds(seconds);
;
timespec time_spec;
time_spec.tv_sec = std::chrono::duration_cast<std::chrono::seconds>(
modified_time.time_since_epoch())
@@ -140,6 +161,9 @@ bool TestSleep::CanChangeSystemTime() {
}
LOGE("Win32 time rollback: cannot set system time.");
return false;
#elif TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
LOGE("iOS time rollback: cannot set system time.");
return false;
#else
// Otherwise, the test needs to be run as root.
const uid_t uid = getuid();
@@ -148,4 +172,4 @@ bool TestSleep::CanChangeSystemTime() {
return false;
#endif
}
} // namespace wvcdm
} // namespace wvutil