Export media_cas_proxy_sdk
This commit is contained in:
33
strings/serialize.cc
Normal file
33
strings/serialize.cc
Normal file
@@ -0,0 +1,33 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "strings/serialize.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "glog/logging.h"
|
||||
|
||||
namespace widevine {
|
||||
namespace strings {
|
||||
|
||||
uint32_t KeyToUint32(const std::string& key) {
|
||||
CHECK_GE(key.size(), 4);
|
||||
return static_cast<uint8_t>(key[0]) << 24 |
|
||||
static_cast<uint8_t>(key[1]) << 16 |
|
||||
static_cast<uint8_t>(key[2]) << 8 | static_cast<uint8_t>(key[3]);
|
||||
}
|
||||
|
||||
std::string EncodeUint64(uint64_t value) {
|
||||
std::string s;
|
||||
s.resize(sizeof(value));
|
||||
memcpy(&s[0], &value, sizeof(value));
|
||||
return s;
|
||||
}
|
||||
|
||||
} // namespace strings
|
||||
} // namespace widevine
|
||||
Reference in New Issue
Block a user