File util, generic crypto, and key query
This CL merges several CLs from the widevine repo: http://go/wvgerrit/18012 Add support for querying allowed usage for key. http://go/wvgerrit/17971 Add per-origin storage. http://go/wvgerrit/18152 Add OEMCrypto's generic crypto operations to CDM. http://go/wvgerrit/17911 QueryKeyControlInfo => QueryOemCryptoSessionId Note: numbering in wv_cdm_types.h was added in this CL and will be back ported to wvgerrit in a future CL. Change-Id: Idb9e9a67e94f62f25dc16c5307f75a08b3430b64
This commit is contained in:
33
libwvdrmengine/cdm/include/file_utils.h
Normal file
33
libwvdrmengine/cdm/include/file_utils.h
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright 2016 Google Inc. All Rights Reserved.
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "wv_cdm_types.h"
|
||||
|
||||
namespace wvcdm {
|
||||
|
||||
const char kCurrentDirectory[] = ".";
|
||||
const char kParentDirectory[] = "..";
|
||||
const char kDirectoryDelimiter = '/';
|
||||
const char kWildcard[] = "*";
|
||||
bool IsCurrentOrParentDirectory(char* dir);
|
||||
|
||||
class FileUtils {
|
||||
public:
|
||||
static bool Exists(const std::string& src);
|
||||
static bool Remove(const std::string& src);
|
||||
static bool Copy(const std::string& src, const std::string& dest);
|
||||
static bool List(const std::string& path, std::vector<std::string>* files);
|
||||
static bool IsRegularFile(const std::string& path);
|
||||
static bool IsDirectory(const std::string& path);
|
||||
static bool CreateDirectory(const std::string& path);
|
||||
|
||||
// Certificate and offline licenses are now stored in security
|
||||
// level specific directories. In an earlier version they were
|
||||
// stored in a common directory and need to be copied over.
|
||||
static void SecurityLevelPathBackwardCompatibility(
|
||||
CdmSecurityLevel security_level);
|
||||
};
|
||||
|
||||
} // namespace wvcdm
|
||||
@@ -3,9 +3,12 @@
|
||||
#ifndef CDM_BASE_WV_CONTENT_DECRYPTION_MODULE_H_
|
||||
#define CDM_BASE_WV_CONTENT_DECRYPTION_MODULE_H_
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <UniquePtr.h>
|
||||
#include <utils/RefBase.h>
|
||||
|
||||
#include "file_store.h"
|
||||
#include "lock.h"
|
||||
#include "timer.h"
|
||||
#include "wv_cdm_types.h"
|
||||
@@ -71,9 +74,9 @@ class WvContentDecryptionModule : public android::RefBase, public TimerHandler {
|
||||
virtual CdmResponseType QueryKeyStatus(const CdmSessionId& session_id,
|
||||
CdmQueryMap* key_info);
|
||||
|
||||
// Query session control information
|
||||
virtual CdmResponseType QueryKeyControlInfo(const CdmSessionId& session_id,
|
||||
CdmQueryMap* key_info);
|
||||
// Query OEMCrypto session ID
|
||||
virtual CdmResponseType QueryOemCryptoSessionId(const CdmSessionId& session_id,
|
||||
CdmQueryMap* response);
|
||||
|
||||
// Provisioning related methods
|
||||
virtual CdmResponseType GetProvisioningRequest(
|
||||
@@ -118,6 +121,19 @@ class WvContentDecryptionModule : public android::RefBase, public TimerHandler {
|
||||
virtual bool IsValidServiceCertificate(const std::string& certificate);
|
||||
|
||||
private:
|
||||
struct CdmInfo {
|
||||
CdmInfo();
|
||||
|
||||
FileSystem file_system;
|
||||
UniquePtr<CdmEngine> cdm_engine;
|
||||
};
|
||||
|
||||
// Finds the CdmEngine instance for the given origin, creating one if needed.
|
||||
CdmEngine* EnsureCdmForOrigin(const std::string& origin);
|
||||
// Finds the CdmEngine instance for the given session id, returning NULL if
|
||||
// not found.
|
||||
CdmEngine* GetCdmForSessionId(const std::string& session_id);
|
||||
|
||||
uint32_t GenerateSessionSharingId();
|
||||
|
||||
// timer related methods to drive policy decisions
|
||||
@@ -130,7 +146,10 @@ class WvContentDecryptionModule : public android::RefBase, public TimerHandler {
|
||||
Timer policy_timer_;
|
||||
|
||||
// instance variables
|
||||
UniquePtr<CdmEngine> cdm_engine_;
|
||||
// This manages the lifetime of the CDM instances.
|
||||
std::map<std::string, CdmInfo> cdms_;
|
||||
// This contains weak pointers to the CDM instances contained in |cdms_|.
|
||||
std::map<std::string, CdmEngine*> cdm_by_session_id_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(WvContentDecryptionModule);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user