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
|
|
|
|
|
|
|
|
#ifndef PACKAGER_MEDIA_BASE_PSSH_GENERATOR_H_
|
|
|
|
#define PACKAGER_MEDIA_BASE_PSSH_GENERATOR_H_
|
|
|
|
|
2022-11-04 22:46:41 +00:00
|
|
|
#include <optional>
|
2017-09-12 19:22:39 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2023-10-10 23:51:11 +00:00
|
|
|
#include <packager/media/base/protection_system_specific_info.h>
|
2023-10-14 16:36:01 +00:00
|
|
|
#include <packager/status.h>
|
2017-09-12 19:22:39 +00:00
|
|
|
|
|
|
|
// TODO(hmchen): move pssh related files into a sperate folder.
|
|
|
|
namespace shaka {
|
|
|
|
namespace media {
|
|
|
|
|
|
|
|
class PsshGenerator {
|
|
|
|
public:
|
2018-08-07 20:47:53 +00:00
|
|
|
/// @param system_id is the protection system id for the PSSH.
|
|
|
|
/// @param box_version specifies the version of the new PSSH box.
|
|
|
|
PsshGenerator(const std::vector<uint8_t>& system_id, uint8_t box_version);
|
|
|
|
virtual ~PsshGenerator();
|
2017-09-12 19:22:39 +00:00
|
|
|
|
|
|
|
/// @return whether the PSSH generates the PSSH box based on multiple key
|
|
|
|
/// IDs.
|
|
|
|
virtual bool SupportMultipleKeys() = 0;
|
|
|
|
|
|
|
|
/// Generate the PSSH and set the ProtectionSystemSpecificInfo.
|
|
|
|
/// @param key_ids is a vector of key IDs for all tracks.
|
|
|
|
/// @param info is a pointer to the ProtectionSystemSpecificInfo for setting
|
|
|
|
/// the PSSH box.
|
|
|
|
Status GeneratePsshFromKeyIds(
|
|
|
|
const std::vector<std::vector<uint8_t>>& key_ids,
|
|
|
|
ProtectionSystemSpecificInfo* info) const;
|
|
|
|
|
|
|
|
/// Generate the PSSH and set the ProtectionSystemSpecificInfo.
|
|
|
|
/// @param key_id is a the unique identifier for the key.
|
|
|
|
/// @param key is the content key.
|
|
|
|
/// @param info is a pointer to the ProtectionSystemSpecificInfo for setting
|
|
|
|
/// the PSSH box.
|
|
|
|
Status GeneratePsshFromKeyIdAndKey(const std::vector<uint8_t>& key_id,
|
|
|
|
const std::vector<uint8_t>& key,
|
|
|
|
ProtectionSystemSpecificInfo* info) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// Return the PSSH data generated from multiple |key_ids| on success. If
|
|
|
|
/// error happens, it returns no value.
|
|
|
|
/// @param key_ids is a set of key IDs for all tracks.
|
2022-11-04 22:46:41 +00:00
|
|
|
virtual std::optional<std::vector<uint8_t>> GeneratePsshDataFromKeyIds(
|
2017-09-12 19:22:39 +00:00
|
|
|
const std::vector<std::vector<uint8_t>>& key_ids) const = 0;
|
|
|
|
|
|
|
|
/// Return the PSSH data generated from a pair of |key_id| and |key| on
|
|
|
|
/// success. If error happens, it returns no value.
|
|
|
|
/// @param key_id is a the unique identifier for the key.
|
|
|
|
/// @param key is the key for generating the PSSH box.
|
2022-11-04 22:46:41 +00:00
|
|
|
virtual std::optional<std::vector<uint8_t>> GeneratePsshDataFromKeyIdAndKey(
|
2017-09-12 19:22:39 +00:00
|
|
|
const std::vector<uint8_t>& key_id,
|
|
|
|
const std::vector<uint8_t>& key) const = 0;
|
|
|
|
|
2018-08-07 20:47:53 +00:00
|
|
|
std::vector<uint8_t> system_id_;
|
|
|
|
uint8_t box_version_ = 0;
|
2017-09-12 19:22:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
|
|
|
} // namespace shaka
|
|
|
|
|
|
|
|
#endif // PACKAGER_MEDIA_BASE_PSSH_GENERATOR_H_
|