2016-01-13 01:32:48 +00:00
|
|
|
// Copyright 2016 Google Inc. All rights reserved.
|
2014-02-14 23:21:05 +00:00
|
|
|
//
|
|
|
|
// 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
|
2013-10-11 21:44:55 +00:00
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#ifndef PACKAGER_MEDIA_BASE_DECRYPTOR_SOURCE_H_
|
|
|
|
#define PACKAGER_MEDIA_BASE_DECRYPTOR_SOURCE_H_
|
2013-10-11 21:44:55 +00:00
|
|
|
|
2016-01-13 01:32:48 +00:00
|
|
|
#include <map>
|
2016-08-30 23:01:19 +00:00
|
|
|
#include <memory>
|
2016-01-13 01:32:48 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2016-03-17 17:03:19 +00:00
|
|
|
#include "packager/media/base/aes_decryptor.h"
|
2016-01-13 01:32:48 +00:00
|
|
|
#include "packager/media/base/decrypt_config.h"
|
|
|
|
#include "packager/media/base/key_source.h"
|
2013-10-11 21:44:55 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2013-10-11 21:44:55 +00:00
|
|
|
namespace media {
|
|
|
|
|
2016-01-13 01:32:48 +00:00
|
|
|
/// DecryptorSource wraps KeySource and is responsible for decryptor management.
|
2013-10-11 21:44:55 +00:00
|
|
|
class DecryptorSource {
|
|
|
|
public:
|
2017-09-18 23:31:00 +00:00
|
|
|
/// Constructs a DecryptorSource object.
|
|
|
|
/// @param key_source points to the key source that contains the keys.
|
2016-01-13 01:32:48 +00:00
|
|
|
explicit DecryptorSource(KeySource* key_source);
|
|
|
|
~DecryptorSource();
|
2013-10-11 21:44:55 +00:00
|
|
|
|
2017-09-18 23:31:00 +00:00
|
|
|
/// Decrypt encrypted buffer.
|
|
|
|
/// @param decrypt_config contains decrypt configuration, e.g. protection
|
|
|
|
/// scheme, subsample information etc.
|
|
|
|
/// @param encrypted_buffer points to the encrypted buffer that is to be
|
|
|
|
/// decrypted. It should not overlap with @a decrypted_buffer.
|
|
|
|
/// @param buffer_size is the size of encrypted buffer and decrypted buffer.
|
|
|
|
/// @param decrypted_buffer points to the decrypted buffer. It should not
|
|
|
|
/// overlap with @a encrypted_buffer.
|
|
|
|
/// @return true if success, false otherwise.
|
2016-01-13 01:32:48 +00:00
|
|
|
bool DecryptSampleBuffer(const DecryptConfig* decrypt_config,
|
2017-09-18 23:31:00 +00:00
|
|
|
const uint8_t* encrypted_buffer,
|
|
|
|
size_t buffer_size,
|
|
|
|
uint8_t* decrypted_buffer);
|
2013-10-11 21:44:55 +00:00
|
|
|
|
|
|
|
private:
|
2016-01-13 01:32:48 +00:00
|
|
|
KeySource* key_source_;
|
2016-08-30 23:01:19 +00:00
|
|
|
std::map<std::vector<uint8_t>, std::unique_ptr<AesCryptor>> decryptor_map_;
|
2016-01-13 01:32:48 +00:00
|
|
|
|
2013-10-11 21:44:55 +00:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(DecryptorSource);
|
|
|
|
};
|
|
|
|
|
2014-01-24 18:46:46 +00:00
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2013-10-11 21:44:55 +00:00
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#endif // PACKAGER_MEDIA_BASE_DECRYPTOR_SOURCE_H_
|