Create some utility types/functions to help partners to create CasEncryptionRequest in JSON format and process CasEncryptionResponse in JSON format.
The idea is that partner can take the CasEncryptionRequest in JSON to construct a signed license request, send it to Widevine license service (using whatever tool they have); and once they have a response, they can use another utility here to parse and understand what is in the response JSON. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=229422648
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -10,6 +10,9 @@
|
|||||||
#define MEDIA_CAS_PACKAGER_SDK_PUBLIC_WV_CAS_TYPES_H_
|
#define MEDIA_CAS_PACKAGER_SDK_PUBLIC_WV_CAS_TYPES_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "common/status.h"
|
||||||
|
|
||||||
namespace widevine {
|
namespace widevine {
|
||||||
namespace cas {
|
namespace cas {
|
||||||
@@ -64,6 +67,63 @@ bool CryptoModeToString(CryptoMode mode, std::string* str);
|
|||||||
// Returns false if str is not a valid CryptoMode.
|
// Returns false if str is not a valid CryptoMode.
|
||||||
bool StringToCryptoMode(const std::string& str, CryptoMode* mode);
|
bool StringToCryptoMode(const std::string& str, CryptoMode* mode);
|
||||||
|
|
||||||
|
struct WvCasEncryptionRequest {
|
||||||
|
std::string content_id;
|
||||||
|
std::string provider;
|
||||||
|
// Track types such as "AUDIO", SD" or "HD".
|
||||||
|
std::vector<std::string> track_types;
|
||||||
|
// Indicates if the client is using key rotation. If true, the server will
|
||||||
|
// return one key for EVEN and one key for ODD, otherwise only a single key is
|
||||||
|
// returned.
|
||||||
|
bool key_rotation = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct WvCasEncryptionResponse {
|
||||||
|
enum class Status {
|
||||||
|
STATUS_UNSPECIFIED = 0,
|
||||||
|
OK = 1,
|
||||||
|
SIGNATURE_FAILED = 2,
|
||||||
|
ACCESS_DENIED = 3,
|
||||||
|
INTERNAL_ERROR = 4,
|
||||||
|
INVALID_ARGUMENT = 5,
|
||||||
|
PROVIDER_ID_MISSING = 6,
|
||||||
|
CONTENT_ID_MISSING = 7,
|
||||||
|
TRACK_TYPE_MISSING = 8
|
||||||
|
};
|
||||||
|
struct KeyInfo {
|
||||||
|
enum class KeySlot {
|
||||||
|
KEY_SLOT_UNSPECIFIED = 0,
|
||||||
|
SINGLE = 1,
|
||||||
|
EVEN = 2,
|
||||||
|
ODD = 3
|
||||||
|
};
|
||||||
|
std::string key_id;
|
||||||
|
std::string key;
|
||||||
|
// Optional label used for the key.
|
||||||
|
std::string track_type;
|
||||||
|
KeySlot key_slot;
|
||||||
|
};
|
||||||
|
Status status;
|
||||||
|
std::string status_message;
|
||||||
|
std::string content_id;
|
||||||
|
std::vector<KeyInfo> entitlement_keys;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Returns a WvCasEncryptionRequest in JSON format.
|
||||||
|
// This request JSON can be later put into the 'request' field of a signed
|
||||||
|
// request JSON message.
|
||||||
|
// And that signed JSON message can be sent to Widevine license server for
|
||||||
|
// aquiring entitlement keys.
|
||||||
|
Status CreateWvCasEncryptionRequestJson(const WvCasEncryptionRequest& request,
|
||||||
|
std::string* request_json);
|
||||||
|
|
||||||
|
// Parses a WvCasEncryptionResponse in JSON format, returns a
|
||||||
|
// WvCasEncryptionResponse.
|
||||||
|
// |response_json| is supposed to be the 'response' field in the signed
|
||||||
|
// response from Widevine license server.
|
||||||
|
Status ParseWvCasEncryptionResponseJson(const std::string& response_json,
|
||||||
|
WvCasEncryptionResponse* response);
|
||||||
|
|
||||||
} // namespace cas
|
} // namespace cas
|
||||||
} // namespace widevine
|
} // namespace widevine
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user