74 lines
2.6 KiB
C++
74 lines
2.6 KiB
C++
// Copyright 2017 Google Inc. All rights reserved.
|
|
//
|
|
// 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_
|
|
|
|
#include <vector>
|
|
|
|
#include "packager/base/optional.h"
|
|
#include "packager/media/base/protection_system_specific_info.h"
|
|
#include "packager/status.h"
|
|
|
|
// TODO(hmchen): move pssh related files into a sperate folder.
|
|
namespace shaka {
|
|
namespace media {
|
|
|
|
struct EncryptionKey;
|
|
|
|
class PsshGenerator {
|
|
public:
|
|
PsshGenerator();
|
|
virtual ~PsshGenerator() = 0;
|
|
|
|
/// @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.
|
|
virtual base::Optional<std::vector<uint8_t>> GeneratePsshDataFromKeyIds(
|
|
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.
|
|
virtual base::Optional<std::vector<uint8_t>> GeneratePsshDataFromKeyIdAndKey(
|
|
const std::vector<uint8_t>& key_id,
|
|
const std::vector<uint8_t>& key) const = 0;
|
|
|
|
/// Return the PSSH box version.
|
|
virtual uint8_t PsshBoxVersion() const = 0;
|
|
|
|
/// Return the System ID.
|
|
virtual const std::vector<uint8_t>& SystemId() const = 0;
|
|
};
|
|
|
|
} // namespace media
|
|
} // namespace shaka
|
|
|
|
#endif // PACKAGER_MEDIA_BASE_PSSH_GENERATOR_H_
|