forked from WebPlatformForEmbedded/OCDM-Widevine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHostImplementation.h
96 lines (78 loc) · 2.64 KB
/
HostImplementation.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef WIDEVINE_HOST_IMPLEMENTATION_H
#define WIDEVINE_HOST_IMPLEMENTATION_H
#include "cdm.h"
#include "override.h"
#include <core/core.h>
namespace CDMi {
class HostImplementation :
public widevine::Cdm::IStorage,
public widevine::Cdm::IClock,
public widevine::Cdm::ITimer {
private:
HostImplementation(HostImplementation&) = delete;
HostImplementation& operator= (HostImplementation&) = delete;
typedef std::map<std::string, std::string> StorageMap;
class Timer {
public:
Timer() : _client(nullptr), _context(nullptr) {
}
Timer(IClient* client, void* context) : _client(client), _context(context) {
ASSERT(client != nullptr);
}
Timer(const Timer& copy) : _client(copy._client), _context(copy._context) {
}
~Timer () {
}
Timer& operator= (const Timer& RHS) {
_client = RHS._client;
_context = RHS._context;
return (*this);
}
public:
inline bool operator== (const Timer& RHS) const {
return (_client == RHS._client);
}
inline bool operator!= (const Timer& RHS) const {
return (_client != RHS._client);
}
inline uint64_t Timed (const uint64_t /* scheduledTime */) {
_client->onTimerExpired(_context);
return(0); // No need to reschedule.
}
private:
IClient* _client;
void* _context;
};
public:
HostImplementation();
~HostImplementation ();
public:
//
// Add methods for testing purpose. No real-life functionality.
void Reset();
int NumTimers() const;
inline void SaveProvisioningInformation() {
_saveDeviceCert = true;
}
// widevine::Cdm::IStorage implementation
// ---------------------------------------------------------------------------
virtual bool read(const std::string& name, std::string* data) OVERRIDE;
virtual bool write(const std::string& name, const std::string& data) OVERRIDE;
virtual bool exists(const std::string& name) OVERRIDE;
virtual bool remove(const std::string& name) OVERRIDE;
virtual int32_t size(const std::string& name) OVERRIDE;
virtual bool list(std::vector<std::string>* names) OVERRIDE;
// widevine::Cdm::IClock implementation
// ---------------------------------------------------------------------------
virtual int64_t now() OVERRIDE;
// widevine::Cdm::ITimer implementation
// ---------------------------------------------------------------------------
virtual void setTimeout(int64_t delay_ms, IClient* client, void* context) OVERRIDE;
virtual void cancel(IClient* client) OVERRIDE;
private:
bool _saveDeviceCert;
WPEFramework::Core::TimerType<Timer> _timer;
StorageMap _files;
};
} // namespace CDMi
#endif // WIDEVINE_HOST_IMPLEMENTATION_H