120 lines
4.3 KiB
C++
120 lines
4.3 KiB
C++
// Copyright 2017 Google LLC. All rights reserved.
|
|
|
|
#ifndef VIDEO_WIDEVINE_EXPORT_SDK_EXTERNAL_CPP_WVPL_LICENSE_SERVER_SDK_WVPL_SESSION_H_
|
|
#define VIDEO_WIDEVINE_EXPORT_SDK_EXTERNAL_CPP_WVPL_LICENSE_SERVER_SDK_WVPL_SESSION_H_
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "sdk/external/cpp/wvdrm/license_server_sdk/session.h"
|
|
#include "sdk/external/cpp/wvpl/common/wvpl_sdk_session.h"
|
|
#include "sdk/external/cpp/wvpl/common/wvpl_types.h"
|
|
#include "protos/public/errors.pb.h"
|
|
#include "protos/public/license_server_sdk.pb.h"
|
|
#include "protos/public/oem_key_container.pb.h"
|
|
#include "protos/public/playready.pb.h"
|
|
#include "protos/public/widevine_pssh.pb.h"
|
|
|
|
namespace video_widevine {
|
|
class Session;
|
|
} // namespace video_widevine
|
|
|
|
namespace video_widevine_server {
|
|
namespace wv_pl_sdk {
|
|
// Because we do not want to export wvpl_license_counter.h outside google3, add
|
|
// WvPLLicenseCounter here.
|
|
class WvPLLicenseCounter;
|
|
|
|
// major version to line up with latest released OEMCryptoAPI version.
|
|
const uint32_t kMajorVersion = 17;
|
|
const uint32_t kMinorVersion = 0;
|
|
const uint32_t kRelease = 1;
|
|
|
|
// Once a Widevine environment object is successfully initialized, generate a
|
|
// Widevine session object for each license request. CreateSession() parses
|
|
// the request and validates the request by verifying the signature. If
|
|
// successful, a session object is created and OK is returned.
|
|
// Once a Widevine session object is successfully created, setup the session
|
|
// object with the policy and keys. Call AddKey() multiple times for each key.
|
|
|
|
class WvPLSession : public WvPLSDKSession {
|
|
public:
|
|
WvPLSession();
|
|
~WvPLSession() override;
|
|
|
|
// Generates the license for sending back to the Widevine client. Caller owns
|
|
// |license|.
|
|
virtual WvPLStatus GenerateLicense(std::string* license);
|
|
|
|
// Set the session state.
|
|
virtual void set_session_state(const WvPLSessionState& wvpl_session_state) {
|
|
wvpl_session_state_ = wvpl_session_state;
|
|
has_session_state_ = true;
|
|
}
|
|
|
|
// Get the session state.
|
|
virtual const WvPLSessionState& session_state() const {
|
|
return wvpl_session_state_;
|
|
}
|
|
|
|
bool has_sdk_session() { return !(sdk_session_ == nullptr); }
|
|
|
|
PlatformVerificationStatus VerifyPlatform() override;
|
|
|
|
// Returns a std::string containing the WVPL version in the form:
|
|
// <major_version>.<minor_version>.<release>
|
|
static std::string GetVersionString();
|
|
|
|
// TODO(b/193921795): this API will be deprecated since end-Q3 2021 release.
|
|
// Please use GetDeviceInfo() instead.
|
|
// Returns true if a provisioned device info exists. Populates the specified
|
|
// |device_info| structure.
|
|
virtual bool GetProvisionedDeviceInfo(WvPLDeviceInfo* device_info) const;
|
|
|
|
// Populates the specified |device_info| structure. This API works only for
|
|
// * NEW license requests.
|
|
// * RENEWAL/RELEASE requests that include a Client Identification.
|
|
WvPLStatus GetDeviceInfo(WvPLDeviceInfo* device_info) const override;
|
|
|
|
protected:
|
|
// This class takes ownership of |sdk_session|. This class keeps a pointer
|
|
// to |license_counter| but the caller maintains ownership of
|
|
// |license_counter|. Both arguments must not be NULL.
|
|
WvPLSession(
|
|
const video_widevine::DrmRootCertificate* drm_root_certificate,
|
|
video_widevine::Session* sdk_session, WvPLLicenseCounter* license_counter,
|
|
const video_widevine::SecurityProfileList* device_security_profile_list);
|
|
|
|
video_widevine::Session* sdk_session() { return sdk_session_; }
|
|
|
|
void set_sdk_session(video_widevine::Session* sdk_session) {
|
|
sdk_session_ = sdk_session;
|
|
}
|
|
|
|
// Sets the license counter to use. The caller maintains ownership of
|
|
// |license_counter| but this class keeps a pointer to |license_counter|.
|
|
void set_license_counter(WvPLLicenseCounter* license_counter) {
|
|
license_counter_ = license_counter;
|
|
}
|
|
|
|
void CopyOemKey(const WvPLKey& wvpl_key,
|
|
video_widevine::OemKeyContainer* oem_key_container);
|
|
|
|
private:
|
|
friend class WvPLEnvironment;
|
|
friend class WvPLEnvironmentTest;
|
|
friend class WvPLSessionTest;
|
|
|
|
video_widevine::Session* sdk_session_ = nullptr;
|
|
WvPLLicenseCounter* license_counter_ = nullptr;
|
|
WvPLSessionState wvpl_session_state_;
|
|
video_widevine::SessionState session_state_;
|
|
};
|
|
|
|
} // namespace wv_pl_sdk
|
|
} // namespace video_widevine_server
|
|
|
|
#endif // VIDEO_WIDEVINE_EXPORT_SDK_EXTERNAL_CPP_WVPL_LICENSE_SERVER_SDK_WVPL_SESSION_H_
|