2022-08-26 15:44:59 +00:00
|
|
|
// Copyright 2017 Google LLC. All rights reserved.
|
2017-09-12 19:22:39 +00:00
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
2023-10-10 23:51:11 +00:00
|
|
|
#include <packager/media/base/pssh_generator_util.h>
|
2017-09-12 19:22:39 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2023-10-10 23:51:11 +00:00
|
|
|
#include <packager/media/base/widevine_pssh_data.pb.h>
|
2017-09-12 19:22:39 +00:00
|
|
|
|
|
|
|
namespace shaka {
|
|
|
|
namespace media {
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
std::vector<uint8_t> StringToBytes(const std::string& string) {
|
|
|
|
return std::vector<uint8_t>(string.begin(), string.end());
|
|
|
|
}
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
std::vector<uint8_t> GenerateWidevinePsshDataFromKeyIds(
|
|
|
|
const std::vector<std::vector<uint8_t>>& key_ids) {
|
|
|
|
media::WidevinePsshData widevine_pssh_data;
|
|
|
|
for (const std::vector<uint8_t>& key_id : key_ids)
|
|
|
|
widevine_pssh_data.add_key_id(key_id.data(), key_id.size());
|
|
|
|
return StringToBytes(widevine_pssh_data.SerializeAsString());
|
|
|
|
}
|
|
|
|
} // namespace media
|
|
|
|
} // namespace shaka
|