Shaka Packager SDK
Loading...
Searching...
No Matches
key_source.h
1// Copyright 2014 Google LLC. All rights reserved.
2//
3// Use of this source code is governed by a BSD-style
4// license that can be found in the LICENSE file or at
5// https://developers.google.com/open-source/licenses/bsd
6
7#ifndef PACKAGER_MEDIA_BASE_KEY_SOURCE_H_
8#define PACKAGER_MEDIA_BASE_KEY_SOURCE_H_
9
10#include <cstdint>
11#include <map>
12#include <memory>
13#include <string>
14#include <vector>
15
16#include <packager/macros/classes.h>
17#include <packager/media/base/protection_system_specific_info.h>
18#include <packager/status.h>
19
20namespace shaka {
21namespace media {
22
25enum class EmeInitDataType {
26 UNKNOWN,
28 CENC,
30 WEBM,
32 KEYIDS,
34 WIDEVINE_CLASSIC,
35 MAX = WIDEVINE_CLASSIC
36};
37
39 std::vector<ProtectionSystemSpecificInfo> key_system_info;
41 std::vector<uint8_t> key_id;
43 std::vector<std::vector<uint8_t>> key_ids;
44 std::vector<uint8_t> key;
45 std::vector<uint8_t> iv;
51};
52
53typedef std::map<std::string, std::unique_ptr<EncryptionKey>> EncryptionKeyMap;
54
56class KeySource {
57 public:
58 KeySource();
59
60 virtual ~KeySource();
61
66 virtual Status FetchKeys(EmeInitDataType init_data_type,
67 const std::vector<uint8_t>& init_data) = 0;
68
74 virtual Status GetKey(const std::string& stream_label,
75 EncryptionKey* key) = 0;
76
82 virtual Status GetKey(const std::vector<uint8_t>& key_id,
83 EncryptionKey* key) = 0;
84
94 virtual Status GetCryptoPeriodKey(uint32_t crypto_period_index,
95 int32_t crypto_period_duration_in_seconds,
96 const std::string& stream_label,
97 EncryptionKey* key) = 0;
98
99 private:
100 DISALLOW_COPY_AND_ASSIGN(KeySource);
101};
102
103} // namespace media
104} // namespace shaka
105
106#endif // PACKAGER_MEDIA_BASE_KEY_SOURCE_H_
KeySource is responsible for encryption key acquisition.
Definition key_source.h:56
virtual Status GetCryptoPeriodKey(uint32_t crypto_period_index, int32_t crypto_period_duration_in_seconds, const std::string &stream_label, EncryptionKey *key)=0
virtual Status FetchKeys(EmeInitDataType init_data_type, const std::vector< uint8_t > &init_data)=0
virtual Status GetKey(const std::vector< uint8_t > &key_id, EncryptionKey *key)=0
virtual Status GetKey(const std::string &stream_label, EncryptionKey *key)=0
All the methods that are virtual are virtual for mocking.
std::vector< std::vector< uint8_t > > key_ids
The IDs of the other keys to include in PSSH info.
Definition key_source.h:43
std::string common_encryption_scheme
Definition key_source.h:50
std::vector< uint8_t > key_id
The ID of this key.
Definition key_source.h:41