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 {
|
|
|
|
|
Fairplay key system support
Support generation of fairplay key system tag: "com.apple.streamingkeydelivery" when --pssh
includes fairplay key system id:
// Unofficial fairplay system id extracted from
// https://forums.developer.apple.com/thread/6185.
const uint8_t kFairplaySystemId[] = {0x29, 0x70, 0x1F, 0xE4, 0x3C, 0xC7,
0x4A, 0x34, 0x8C, 0x5B, 0xAE, 0x90,
0xC7, 0x43, 0x9A, 0x47};
Closes #258
2017-08-08 17:31:40 +00:00
|
|
|
// Unofficial fairplay system id extracted from
|
|
|
|
// https://forums.developer.apple.com/thread/6185.
|
|
|
|
const uint8_t kFairplaySystemId[] = {0x29, 0x70, 0x1F, 0xE4, 0x3C, 0xC7,
|
|
|
|
0x4A, 0x34, 0x8C, 0x5B, 0xAE, 0x90,
|
|
|
|
0xC7, 0x43, 0x9A, 0x47};
|
|
|
|
|
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,
|
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.
|
2017-10-17 23:03:08 +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:
|
2017-09-20 22:49:00 +00:00
|
|
|
typedef std::map<std::string, std::unique_ptr<EncryptionKey>>
|
|
|
|
EncryptionKeyMap;
|
2017-10-17 23:03:08 +00:00
|
|
|
explicit RawKeySource(EncryptionKeyMap&& encryption_key_map);
|
|
|
|
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_
|