Media CAS Proxy SDK release: 1.5.5
This commit is contained in:
140
sdk/external/common/wvpl/wvpl_sdk_environment.h
vendored
140
sdk/external/common/wvpl/wvpl_sdk_environment.h
vendored
@@ -1,140 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Google LLC.
|
||||
//
|
||||
// This software is licensed under the terms defined in the Widevine Master
|
||||
// License Agreement. For a copy of this agreement, please contact
|
||||
// widevine-licensing@google.com.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SDK_EXTERNAL_COMMON_WVPL_WVPL_SDK_ENVIRONMENT_H_
|
||||
#define SDK_EXTERNAL_COMMON_WVPL_WVPL_SDK_ENVIRONMENT_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "sdk/external/common/wvpl/wvpl_types.h"
|
||||
|
||||
namespace widevine {
|
||||
class DeviceCertificateStatusList;
|
||||
class DrmRootCertificate;
|
||||
class ProvisionedDeviceInfo;
|
||||
} // namespace widevine
|
||||
namespace widevine_server {
|
||||
namespace wv_pl_sdk {
|
||||
|
||||
// These fields show the configuration options that can be initialized via
|
||||
// the implementation classes (WvPLEnvironment and WvPLProxyEnvironment).
|
||||
const char kDeviceCertificateExpiration[] = "device_certificate_expiration";
|
||||
const char kAllowUnknownDevice[] = "allow_unknown_device";
|
||||
const char kProvider[] = "provider";
|
||||
const char kProviderIv[] = "provider_iv";
|
||||
const char kProviderKey[] = "provider_key";
|
||||
const char kApiVerInKcb[] = "api_ver_in_kcb";
|
||||
const char kLimitUsageStatsToErrorsOnly[] = "limit_usage_stats_to_errors_only";
|
||||
// Valid values are 'test' and 'prod'.
|
||||
const char kDrmCertificateType[] = "drm_certificate_type";
|
||||
|
||||
/**
|
||||
* Parent class of SDK environment. This class is not be instantiated directly,
|
||||
* but its API can be accessed via the derived environment classes.
|
||||
*/
|
||||
class WvPLSDKEnvironment {
|
||||
public:
|
||||
virtual ~WvPLSDKEnvironment();
|
||||
// Generates a license response containing a message generated in response to
|
||||
// an error condition. |create_session_status| is a previous error status
|
||||
// returned by the CreateSession(). |license_response| points to a std::string to
|
||||
// contain the license response and may not be NULL. This method returns true
|
||||
// if there is an error license to be sent to the client, or false
|
||||
// otherwise.
|
||||
static bool GenerateErrorResponse(const WvPLStatus& create_session_status,
|
||||
std::string* license_response);
|
||||
|
||||
/**
|
||||
* Add a service certificate system-wide at the sdk. |service_certificate|
|
||||
* is a Google-generated certificate used to authenticate the service
|
||||
* provider. |service_private_key| is the encrypted PKCS#8 private RSA key
|
||||
* corresponding to the service certificate. |service_private_key_passphrase|
|
||||
* is the password required to decrypt |service_private_key|. This is a
|
||||
* thread-safe call.
|
||||
*
|
||||
* @param service_certificate
|
||||
* @param service_private_key
|
||||
* @param service_private_key_passphrase
|
||||
*
|
||||
* @return WvPLStatus enumeration
|
||||
*/
|
||||
virtual WvPLStatus SetDrmServiceCertificate(
|
||||
const std::string& service_certificate, const std::string& service_private_key,
|
||||
const std::string& service_private_key_passphrase);
|
||||
|
||||
// Returns the DRM root certificate configured for this environment.
|
||||
const widevine::DrmRootCertificate* drm_root_certificate() const {
|
||||
return drm_root_certificate_.get();
|
||||
}
|
||||
|
||||
protected:
|
||||
// Return the signature for the provider specified in the |config_values|
|
||||
// parameter in the constructor. |signature| is owned by the caller.
|
||||
static WvPLStatus GenerateSignature(const std::string& plain_text,
|
||||
std::string* signature);
|
||||
/**
|
||||
* Insert or update provisionedDeviceInfoMap with device info in
|
||||
* certificate_status_list.
|
||||
*/
|
||||
static WvPLStatus UpdateProvisionedDeviceInfoMap(
|
||||
const widevine::DeviceCertificateStatusList&
|
||||
certificate_status_list);
|
||||
|
||||
WvPLStatus SetDeviceCertificateStatusList(const std::string& cert_list) const;
|
||||
|
||||
static void SetConfigValue(const std::map<std::string, std::string>& config_values);
|
||||
|
||||
// Number of seconds until the certificate status list expires after its
|
||||
// creation time. Default value is 604800 seconds.
|
||||
uint32_t device_certificate_expiration_seconds_ = 604800;
|
||||
// "config_values" setting for "kDrmCertificateType".
|
||||
// Supported values are "test" and "prod". Default value is "prod".
|
||||
std::string drm_certificate_type_ = "prod";
|
||||
// name of the provider hosting this service.
|
||||
std::string provider_;
|
||||
// value of the "iv" specified for the provider.
|
||||
std::string* provider_iv_;
|
||||
// value of the "key" specified for the provider.
|
||||
std::string* provider_key_;
|
||||
static std::map<std::string, std::string>* config_values_;
|
||||
// is_service_certificate_loaded_ is not thread safe.
|
||||
bool is_service_certificate_loaded_ = false;
|
||||
// If true, allow devices not in the certificate status list.
|
||||
bool allow_unknown_device_ = false;
|
||||
// DRM root certificate used for verifying all other DRM certificates.
|
||||
std::unique_ptr<widevine::DrmRootCertificate> drm_root_certificate_;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Return provisioned_device_info if the device_info_map_ contains system_id.
|
||||
*
|
||||
* @return WvPLStatus - Status::OK if success, else error.
|
||||
*/
|
||||
static WvPLStatus LookupDeviceInfo(
|
||||
uint32_t system_id,
|
||||
widevine::ProvisionedDeviceInfo* provisioned_device_info);
|
||||
|
||||
/**
|
||||
* Add a device to the current environment/session.
|
||||
*/
|
||||
static void AddDeviceInfo(
|
||||
const widevine::ProvisionedDeviceInfo& provisioned_device_info);
|
||||
|
||||
static std::map<std::string, std::string>* GetConfigValue();
|
||||
|
||||
friend class WvPLSDKSession;
|
||||
friend class WvPLProxySession;
|
||||
friend class WvPLProxySessionTest;
|
||||
friend class WvPLSessionTest;
|
||||
};
|
||||
|
||||
} // namespace wv_pl_sdk
|
||||
} // namespace widevine_server
|
||||
|
||||
#endif // SDK_EXTERNAL_COMMON_WVPL_WVPL_SDK_ENVIRONMENT_H_
|
||||
258
sdk/external/common/wvpl/wvpl_sdk_session.h
vendored
258
sdk/external/common/wvpl/wvpl_sdk_session.h
vendored
@@ -1,258 +0,0 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2018 Google LLC.
|
||||
//
|
||||
// This software is licensed under the terms defined in the Widevine Master
|
||||
// License Agreement. For a copy of this agreement, please contact
|
||||
// widevine-licensing@google.com.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SDK_EXTERNAL_COMMON_WVPL_WVPL_SDK_SESSION_H_
|
||||
#define SDK_EXTERNAL_COMMON_WVPL_WVPL_SDK_SESSION_H_
|
||||
|
||||
#include <memory>
|
||||
#include "sdk/external/common/wvpl/wvpl_types.h"
|
||||
|
||||
namespace widevine {
|
||||
class ClientIdentification;
|
||||
class DrmRootCertificate;
|
||||
class LicenseRequest;
|
||||
class License_KeyContainer_OutputProtection;
|
||||
class License_KeyContainer;
|
||||
class License_Policy;
|
||||
class ProvisionedDeviceInfo;
|
||||
class SessionInit;
|
||||
class SessionState;
|
||||
class SignedMessage;
|
||||
} // namespace widevine
|
||||
namespace widevine_server {
|
||||
namespace wv_pl_sdk {
|
||||
|
||||
class WvPLSDKSession {
|
||||
public:
|
||||
explicit WvPLSDKSession(
|
||||
const widevine::DrmRootCertificate* drm_root_certificate);
|
||||
virtual ~WvPLSDKSession();
|
||||
|
||||
public:
|
||||
// Add WvPLKey.
|
||||
virtual WvPLStatus AddKey(const WvPLKey& key);
|
||||
|
||||
// Get the WvPLKey.
|
||||
virtual const std::vector<WvPLKey>& key() const { return keys_; }
|
||||
|
||||
// Set the license policy.
|
||||
virtual void set_policy(const WvPLPlaybackPolicy& policy) {
|
||||
policy_ = policy;
|
||||
}
|
||||
|
||||
// Get the license policy.
|
||||
virtual const WvPLPlaybackPolicy& policy() const { return policy_; }
|
||||
|
||||
// Set the Session Init.
|
||||
virtual void set_session_init(const WvPLSessionInit& session_init) {
|
||||
session_init_ = session_init;
|
||||
}
|
||||
|
||||
// Get the Session Init.
|
||||
virtual const WvPLSessionInit& session_init() const { return session_init_; }
|
||||
|
||||
virtual bool IsChromeCDM() const;
|
||||
|
||||
/**
|
||||
* Returns the Widevine PSSH data for the license request handled by this
|
||||
* session.
|
||||
*
|
||||
* @param wvpl_widevine_pssh_data.
|
||||
* @return WvPLStatus - Status::OK if success, else error.
|
||||
*/
|
||||
virtual WvPLStatus GetPsshData(
|
||||
WvPLWidevinePsshData* wvpl_widevine_pssh_data) const;
|
||||
|
||||
/**
|
||||
* Returns the ClientIdentification information for the license request
|
||||
* handled by this session.
|
||||
*
|
||||
* @param client_info
|
||||
* @return WvPLStatus - Status::OK if success, else error.
|
||||
*/
|
||||
virtual WvPLStatus GetClientInfo(WvPLClientInfo* client_info) const;
|
||||
/**
|
||||
* Returns the WvPL Client Capabilities information for the license request
|
||||
* handled by this session.
|
||||
*
|
||||
* @param client_capabilities.
|
||||
* @return WvPLStatus - Status::OK if success, else error.
|
||||
*/
|
||||
virtual WvPLStatus GetClientCapabilities(
|
||||
WvPLClientCapabilities* client_capabilities) const;
|
||||
|
||||
/**
|
||||
* Returns the WvPLDeviceInfo information for the license request
|
||||
* handled by this session.
|
||||
*
|
||||
* @param device_info
|
||||
* @return WvPLStatus - Status::OK if success, else error.
|
||||
*/
|
||||
virtual WvPLStatus GetDeviceInfo(WvPLDeviceInfo* device_info) const;
|
||||
|
||||
/**
|
||||
* Returns the type of the message handled by this session.
|
||||
*
|
||||
* @return MessageType enumeration.
|
||||
* @deprecated use request_type instead.
|
||||
* @since end of Q1, 2019
|
||||
*/
|
||||
virtual MessageType message_type() const;
|
||||
|
||||
virtual PlatformVerificationStatus VerifyPlatform() = 0;
|
||||
|
||||
virtual WvPLRequestType request_type() const { return type_; }
|
||||
|
||||
/**
|
||||
* Returns true if the license type is offline, otherwise return false.
|
||||
*
|
||||
* @return bool.
|
||||
*/
|
||||
virtual bool is_offline_license() const;
|
||||
|
||||
/**
|
||||
* A session id that remains constant throughout a session. All license
|
||||
* and heartbeat requests in a session have the same session id.
|
||||
*
|
||||
* @return string.
|
||||
*/
|
||||
virtual std::string session_id() const;
|
||||
|
||||
/**
|
||||
* Returns the license request contains client id or not.
|
||||
*
|
||||
* @return bool.
|
||||
*/
|
||||
virtual bool has_client_id() const { return has_client_id_; }
|
||||
|
||||
/**
|
||||
* Returns true if remote_attestation_cert_serial_number is not empty.
|
||||
* Otherwise return false.
|
||||
*
|
||||
* @return bool.
|
||||
*/
|
||||
virtual bool remote_attestation_verified() {
|
||||
return !remote_attestation_cert_serial_number_.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if license request has encrypted_client_id. Otherwise return
|
||||
* false.
|
||||
*
|
||||
* @return bool.
|
||||
*/
|
||||
virtual bool has_encrypted_client_id() { return has_encrypted_client_id_; }
|
||||
|
||||
protected:
|
||||
const widevine::DrmRootCertificate* drm_root_certificate_;
|
||||
std::string user_agent_;
|
||||
std::vector<WvPLKey> keys_;
|
||||
WvPLPlaybackPolicy policy_;
|
||||
WvPLSessionInit session_init_;
|
||||
WvPLWidevinePsshData pssh_data_;
|
||||
std::unique_ptr<widevine::ClientIdentification> client_id_;
|
||||
bool has_pssh_data_ = false;
|
||||
bool has_client_id_ = false;
|
||||
MessageType message_type_ = UNKNOWN;
|
||||
PlatformVerificationStatus platform_verification_status_ =
|
||||
PLATFORM_NO_VERIFICATION;
|
||||
std::unique_ptr<widevine::SignedMessage>
|
||||
signed_message_request_from_cdm_;
|
||||
std::string license_request_from_cdm_;
|
||||
std::string remote_attestation_cert_serial_number_;
|
||||
std::unique_ptr<widevine::LicenseRequest> sdk_license_request_;
|
||||
WvPLRequestType type_;
|
||||
bool has_session_state_ = false;
|
||||
bool has_encrypted_client_id_ = false;
|
||||
|
||||
virtual WvPLStatus VerifyRemoteAttestation();
|
||||
|
||||
// Returns the WvPL Client Capabilities information for the license request
|
||||
// handled by this session.
|
||||
WvPLStatus GetWvPLClientCapabilities(
|
||||
const widevine::ClientIdentification& client_id,
|
||||
WvPLClientCapabilities* client_capabilities) const;
|
||||
|
||||
// Copy and translates the Key fields from a WvPL Key into an SDK
|
||||
// key container.
|
||||
// Copies
|
||||
// (1) key id
|
||||
// (2) key
|
||||
// (3) video_resolution_constraints
|
||||
// (4) output protection using CopyOutputProtection
|
||||
// (5) security_level using CopySecurityLevel
|
||||
// Translates
|
||||
// (1) key type
|
||||
void CopyKey(const WvPLKey& wvpl_key,
|
||||
widevine::License_KeyContainer* sdk_key_container);
|
||||
|
||||
// Copies/translates output_protection in WvPL Key into an SDK key container.
|
||||
void CopyOutputProtection(
|
||||
const WvPLOutputProtection& wvpl_output_protection,
|
||||
widevine::License_KeyContainer_OutputProtection* output_protection);
|
||||
|
||||
// Copies/translatessecurity_level in WvPL Key into an SDK key container.
|
||||
virtual void CopySecurityLevel(
|
||||
const WvPLOutputProtection& output_protection, TrackType track_type,
|
||||
widevine::License_KeyContainer* key_container);
|
||||
|
||||
// Copies/translates the policy from a WvPL policy into an SDK policy. A
|
||||
// helper function for GenerateLicenseRequestAsJSON.
|
||||
virtual void CopyPlaybackPolicy(const WvPLPlaybackPolicy& wvpl_policy,
|
||||
widevine::License_Policy* sdk_policy);
|
||||
|
||||
// Copy the |hdcp_value| into the key container.
|
||||
virtual void CopyHDCP(
|
||||
HDCP hdcp_value,
|
||||
widevine::License_KeyContainer_OutputProtection* output_protection);
|
||||
|
||||
// Copy the WvPLSession Init into Session Init.
|
||||
virtual void CopySessionInit(const WvPLSessionInit& wvpl_session_init,
|
||||
widevine::SessionInit* session_init);
|
||||
|
||||
// Copy the WvPLDeviceInfo into ProvisionedDeviceInfo.
|
||||
virtual void CopyProvisionedDeviceInfo(
|
||||
const WvPLDeviceInfo& wvpl_device_info,
|
||||
widevine::ProvisionedDeviceInfo* device_info);
|
||||
|
||||
// Populate deviceInfo, clientIdentification and psshdata for license request.
|
||||
WvPLStatus ParseLicenseRequest();
|
||||
|
||||
// Copy the WvPLSessionState to SessionState.
|
||||
void CopySessionState(const WvPLSessionState& wvpl_session_state,
|
||||
widevine::SessionState* session_state);
|
||||
|
||||
// Set system_id value.
|
||||
virtual void SetSystemId(uint32_t system_id);
|
||||
|
||||
// Return has_system_id_ value. True if session has system id.
|
||||
virtual bool HasSystemId() const;
|
||||
|
||||
// Return system_id value in uint32_t. The function will crash if it does not
|
||||
// have system_id.
|
||||
virtual uint32_t GetSystemId() const;
|
||||
|
||||
/**
|
||||
* Use system_id to loop up device info.
|
||||
*
|
||||
* @return WvPLStatus - Status::OK if success, else error.
|
||||
*/
|
||||
virtual WvPLStatus LookupDeviceInfo(
|
||||
uint32_t system_id,
|
||||
widevine::ProvisionedDeviceInfo* provisioned_device_info) const;
|
||||
|
||||
virtual const std::string TrackTypeToString(TrackType track_type) const;
|
||||
|
||||
private:
|
||||
std::unique_ptr<uint32_t> system_id_;
|
||||
};
|
||||
|
||||
} // namespace wv_pl_sdk
|
||||
} // namespace widevine_server
|
||||
|
||||
#endif // SDK_EXTERNAL_COMMON_WVPL_WVPL_SDK_SESSION_H_
|
||||
1068
sdk/external/common/wvpl/wvpl_types.h
vendored
1068
sdk/external/common/wvpl/wvpl_types.h
vendored
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user