OEMCrypto v16.1 Documentation and Headers

This commit contains the updated v16.1 documentation dated Nov 12th,
as well has the headers and update ODK library.

Unit tests and reference code is partially implemented, but not yet
complete.
This commit is contained in:
Fred Gylys-Colwell
2019-11-15 15:45:18 -08:00
parent 4de11d11e8
commit 2f232e2939
50 changed files with 6364 additions and 2780 deletions

44
util/test/test_sleep.cpp Normal file
View File

@@ -0,0 +1,44 @@
// 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.
#include "test_sleep.h"
#include <unistd.h>
#include <chrono>
#include "clock.h"
namespace wvcdm {
bool TestSleep::real_sleep_ = true;
TestSleep::CallBack* TestSleep::callback_ = nullptr;
void TestSleep::Sleep(unsigned int seconds) {
int64_t milliseconds = 1000 * seconds;
if (real_sleep_) {
// This next bit of logic is to avoid slow drift apart of the real clock and
// the fake clock. We compute how far from the real clock has advanced in
// total since the start, and then compare to a running total of sleep
// calls. We sleep for approximately x second, and then advance the clock by
// the amount of time that has actually passed.
static auto start_real = std::chrono::steady_clock().now();
static int64_t fake_clock = 0;
sleep(seconds);
auto now_real = std::chrono::steady_clock().now();
int64_t total_real = (now_real - start_real) / std::chrono::milliseconds(1);
// We want to advance the fake clock by the difference between the real
// clock, and the previous value on the fake clock.
milliseconds = total_real - fake_clock;
fake_clock += milliseconds;
}
if (callback_ != nullptr) callback_->ElapseTime(milliseconds);
}
void TestSleep::SyncFakeClock() {
// Syncing can be done by sleeping 0 seconds.
Sleep(0);
}
} // namespace wvcdm