2016-02-19 20:23:37 +00:00
|
|
|
// Copyright 2016 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
|
|
|
|
|
2017-10-17 23:03:08 +00:00
|
|
|
#ifndef PACKAGER_MEDIA_BASE_RAW_KEY_SOURCE_H_
|
|
|
|
#define PACKAGER_MEDIA_BASE_RAW_KEY_SOURCE_H_
|
2016-02-19 20:23:37 +00:00
|
|
|
|
2016-08-17 17:41:40 +00:00
|
|
|
#include <memory>
|
2016-02-19 20:23:37 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "packager/media/base/key_source.h"
|
2017-09-20 22:49:00 +00:00
|
|
|
#include "packager/media/public/crypto_params.h"
|
2016-02-19 20:23:37 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2016-02-19 20:23:37 +00:00
|
|
|
namespace media {
|
|
|
|
|
2017-10-17 23:03:08 +00:00
|
|
|
/// A key source that uses raw keys for encryption.
|
|
|
|
class RawKeySource : public KeySource {
|
2016-02-19 20:23:37 +00:00
|
|
|
public:
|
2017-10-17 23:03:08 +00:00
|
|
|
~RawKeySource() override;
|
2016-02-19 20:23:37 +00:00
|
|
|
|
|
|
|
/// @name KeySource implementation overrides.
|
|
|
|
/// @{
|
2017-04-04 19:43:41 +00:00
|
|
|
Status FetchKeys(EmeInitDataType init_data_type,
|
|
|
|
const std::vector<uint8_t>& init_data) override;
|
2017-06-13 21:54:12 +00:00
|
|
|
Status GetKey(const std::string& stream_label, EncryptionKey* key) override;
|
2016-02-19 20:23:37 +00:00
|
|
|
Status GetKey(const std::vector<uint8_t>& key_id,
|
|
|
|
EncryptionKey* key) override;
|
|
|
|
Status GetCryptoPeriodKey(uint32_t crypto_period_index,
|
2019-01-24 18:39:54 +00:00
|
|
|
uint32_t crypto_period_duration_in_seconds,
|
2017-06-13 21:54:12 +00:00
|
|
|
const std::string& stream_label,
|
2016-02-19 20:23:37 +00:00
|
|
|
EncryptionKey* key) override;
|
|
|
|
/// @}
|
|
|
|
|
2017-10-17 23:03:08 +00:00
|
|
|
/// Creates a new RawKeySource from the given data. Returns null
|
2017-09-20 22:49:00 +00:00
|
|
|
/// if the parameter is malformed.
|
|
|
|
/// @param raw_key contains parameters to setup the key source.
|
2020-05-29 18:45:57 +00:00
|
|
|
/// @param protection_systems is the enum indicating which PSSH should
|
2018-08-07 21:43:42 +00:00
|
|
|
/// be included.
|
|
|
|
/// @param protection_scheme is the Protection Scheme to be used for
|
|
|
|
/// encryption. It needs to be signalled in Widevine PSSH. This
|
|
|
|
/// argument can be ignored if Widevine PSSH is not generated.
|
2020-05-29 18:45:57 +00:00
|
|
|
static std::unique_ptr<RawKeySource> Create(
|
|
|
|
const RawKeyParams& raw_key,
|
|
|
|
ProtectionSystem protection_systems,
|
|
|
|
FourCC protection_scheme);
|
2016-02-19 20:23:37 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// Allow default constructor for mock key sources.
|
2017-10-17 23:03:08 +00:00
|
|
|
RawKeySource();
|
2016-02-19 20:23:37 +00:00
|
|
|
|
|
|
|
private:
|
2018-08-07 21:43:42 +00:00
|
|
|
RawKeySource(EncryptionKeyMap&& encryption_key_map,
|
2020-05-29 18:45:57 +00:00
|
|
|
ProtectionSystem protection_systems,
|
2018-08-07 21:43:42 +00:00
|
|
|
FourCC protection_scheme);
|
2017-10-17 23:03:08 +00:00
|
|
|
RawKeySource(const RawKeySource&) = delete;
|
|
|
|
RawKeySource& operator=(const RawKeySource&) = delete;
|
2016-02-19 20:23:37 +00:00
|
|
|
|
2017-09-20 22:49:00 +00:00
|
|
|
EncryptionKeyMap encryption_key_map_;
|
2016-02-19 20:23:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2016-02-19 20:23:37 +00:00
|
|
|
|
2017-10-17 23:03:08 +00:00
|
|
|
#endif // PACKAGER_MEDIA_BASE_RAW_KEY_SOURCE_H_
|