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 <map>
11#include <memory>
12#include <string>
13#include <vector>
14
15#include <packager/macros/classes.h>
16#include <packager/media/base/fourccs.h>
17#include <packager/media/base/protection_system_specific_info.h>
18#include <packager/media/base/pssh_generator.h>
19#include <packager/status.h>
20
21namespace shaka {
22namespace media {
23
26enum class EmeInitDataType {
27 UNKNOWN,
29 CENC,
31 WEBM,
33 KEYIDS,
35 WIDEVINE_CLASSIC,
36 MAX = WIDEVINE_CLASSIC
37};
38
40 std::vector<ProtectionSystemSpecificInfo> key_system_info;
42 std::vector<uint8_t> key_id;
44 std::vector<std::vector<uint8_t>> key_ids;
45 std::vector<uint8_t> key;
46 std::vector<uint8_t> iv;
47};
48
49typedef std::map<std::string, std::unique_ptr<EncryptionKey>> EncryptionKeyMap;
50
52class KeySource {
53 public:
54 KeySource();
55
56 virtual ~KeySource();
57
62 virtual Status FetchKeys(EmeInitDataType init_data_type,
63 const std::vector<uint8_t>& init_data) = 0;
64
70 virtual Status GetKey(const std::string& stream_label,
71 EncryptionKey* key) = 0;
72
78 virtual Status GetKey(const std::vector<uint8_t>& key_id,
79 EncryptionKey* key) = 0;
80
90 virtual Status GetCryptoPeriodKey(uint32_t crypto_period_index,
91 int32_t crypto_period_duration_in_seconds,
92 const std::string& stream_label,
93 EncryptionKey* key) = 0;
94
95 private:
96 DISALLOW_COPY_AND_ASSIGN(KeySource);
97};
98
99} // namespace media
100} // namespace shaka
101
102#endif // PACKAGER_MEDIA_BASE_KEY_SOURCE_H_
KeySource is responsible for encryption key acquisition.
Definition key_source.h:52
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:44
std::vector< uint8_t > key_id
The ID of this key.
Definition key_source.h:42