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-06-01 22:26:31 +00:00
|
|
|
static std::unique_ptr<RawKeySource> Create(const RawKeyParams& raw_key);
|
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:
|
2020-06-01 22:26:31 +00:00
|
|
|
RawKeySource(EncryptionKeyMap&& encryption_key_map);
|
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_
|