2017-01-05 17:32:17 +00:00
|
|
|
// 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
|
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#ifndef PACKAGER_MEDIA_BASE_PLAYREADY_SOURCE_H_
|
|
|
|
#define PACKAGER_MEDIA_BASE_PLAYREADY_SOURCE_H_
|
2017-01-05 17:32:17 +00:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "packager/media/base/key_source.h"
|
|
|
|
|
|
|
|
namespace shaka {
|
|
|
|
namespace media {
|
|
|
|
|
2018-08-06 23:12:19 +00:00
|
|
|
/// A key source that uses PlayReady for encryption.
|
2017-01-05 17:32:17 +00:00
|
|
|
class PlayReadyKeySource : public KeySource {
|
|
|
|
public:
|
|
|
|
/// Creates a new PlayReadyKeySource from the given packaging information.
|
|
|
|
/// @param server_url PlayReady packaging server url.
|
2020-05-29 18:45:57 +00:00
|
|
|
/// @param protection_systems is the enum indicating which PSSH should
|
2018-04-20 17:46:14 +00:00
|
|
|
/// be included.
|
|
|
|
PlayReadyKeySource(const std::string& server_url,
|
2020-06-01 22:26:31 +00:00
|
|
|
ProtectionSystem protection_systems);
|
2017-01-05 17:32:17 +00:00
|
|
|
/// Creates a new PlayReadyKeySource from the given packaging information.
|
|
|
|
/// @param server_url PlayReady packaging server url.
|
|
|
|
/// @param client_cert_file absolute path to a client certificate.
|
|
|
|
/// @param client_cert_private_key_file absolute path to the private file
|
|
|
|
/// for the client certificate.
|
|
|
|
/// @param client_cert_private_key_password password for the private key.
|
2020-05-29 18:45:57 +00:00
|
|
|
/// @param protection_systems is the enum indicating which PSSH should
|
2018-04-20 17:46:14 +00:00
|
|
|
/// be included.
|
2017-01-05 17:32:17 +00:00
|
|
|
PlayReadyKeySource(const std::string& server_url,
|
|
|
|
const std::string& client_cert_file,
|
|
|
|
const std::string& client_cert_private_key_file,
|
2018-04-20 17:46:14 +00:00
|
|
|
const std::string& client_cert_private_key_password,
|
2020-06-01 22:26:31 +00:00
|
|
|
ProtectionSystem protection_systems);
|
2017-01-05 17:32:17 +00:00
|
|
|
~PlayReadyKeySource() override;
|
|
|
|
|
|
|
|
/// @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;
|
2017-01-05 17:32:17 +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,
|
2017-01-05 17:32:17 +00:00
|
|
|
EncryptionKey* key) override;
|
|
|
|
/// @}
|
|
|
|
virtual Status FetchKeysWithProgramIdentifier(const std::string& program_identifier);
|
|
|
|
|
2017-06-14 23:18:16 +00:00
|
|
|
/// Creates a new PlayReadyKeySource from the given data.
|
2017-01-05 17:32:17 +00:00
|
|
|
/// Returns null if the strings are invalid.
|
|
|
|
/// Note: GetKey on the created key source will always return the same key
|
|
|
|
/// for all track types.
|
|
|
|
static std::unique_ptr<PlayReadyKeySource> CreateFromKeyAndKeyId(
|
2017-06-14 23:18:16 +00:00
|
|
|
const std::vector<uint8_t>& key_id,
|
|
|
|
const std::vector<uint8_t>& key);
|
2017-01-05 17:32:17 +00:00
|
|
|
/// Sets the Certificate Authority file for validating self-signed certificates.
|
|
|
|
void SetCaFile(const std::string& ca_file) {
|
|
|
|
ca_file_ = ca_file;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Status GetKeyInternal();
|
|
|
|
Status GetCryptoPeriodKeyInternal();
|
|
|
|
|
2018-08-10 20:31:17 +00:00
|
|
|
// Indicates whether PlayReady protection system should be generated.
|
|
|
|
bool generate_playready_protection_system_ = true;
|
|
|
|
|
2017-01-05 17:32:17 +00:00
|
|
|
std::unique_ptr<EncryptionKey> encryption_key_;
|
|
|
|
std::string server_url_;
|
|
|
|
std::string ca_file_;
|
|
|
|
std::string client_cert_file_;
|
|
|
|
std::string client_cert_private_key_file_;
|
|
|
|
std::string client_cert_private_key_password_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(PlayReadyKeySource);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
|
|
|
} // namespace shaka
|
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#endif // PACKAGER_MEDIA_BASE_PLAYREADY_SOURCE_H_
|