Initial import of Widevine Common Encryption DRM engine
Builds libwvmdrmengine.so, which is loaded by the new MediaDrm APIs to support playback of Widevine/CENC protected content. Change-Id: I6f57dd37083dfd96c402cb9dd137c7d74edc8f1c
This commit is contained in:
57
libwvdrmengine/cdm/src/timer.cpp
Normal file
57
libwvdrmengine/cdm/src/timer.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Timer class - provides a simple Android specific timer implementation
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "timer.h"
|
||||
#include "utils/Thread.h"
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
class Timer::Impl : public android::Thread {
|
||||
public:
|
||||
Impl() : Thread(false), handler_(NULL), period_(0) {}
|
||||
virtual ~Impl() {};
|
||||
|
||||
void Start(TimerHandler *handler, uint32_t time_in_secs) {
|
||||
handler_ = handler;
|
||||
period_ = time_in_secs;
|
||||
run();
|
||||
}
|
||||
|
||||
private:
|
||||
virtual bool threadLoop() {
|
||||
sleep(period_);
|
||||
handler_->OnTimerEvent();
|
||||
return true;
|
||||
}
|
||||
|
||||
TimerHandler *handler_;
|
||||
uint32_t period_;
|
||||
};
|
||||
|
||||
Timer::Timer() : impl_(new Timer::Impl()) {
|
||||
}
|
||||
|
||||
Timer::~Timer() {
|
||||
if (IsRunning())
|
||||
Stop();
|
||||
|
||||
delete impl_;
|
||||
impl_ = NULL;
|
||||
}
|
||||
|
||||
void Timer::Start(TimerHandler *handler, uint32_t time_in_secs) {
|
||||
impl_->Start(handler, time_in_secs);
|
||||
}
|
||||
|
||||
void Timer::Stop() {
|
||||
impl_->requestExitAndWait();
|
||||
}
|
||||
|
||||
bool Timer::IsRunning() {
|
||||
return impl_->getTid() < 0;
|
||||
}
|
||||
|
||||
} // namespace wvcdm
|
||||
Reference in New Issue
Block a user