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/fourccs.h>
18#include <packager/media/base/protection_system_specific_info.h>
19#include <packager/media/base/pssh_generator.h>
20#include <packager/status.h>
21
22namespace shaka {
23namespace media {
24
27enum class EmeInitDataType {
28 UNKNOWN,
30 CENC,
32 WEBM,
34 KEYIDS,
36 WIDEVINE_CLASSIC,
37 MAX = WIDEVINE_CLASSIC
38};
39
41 std::vector<ProtectionSystemSpecificInfo> key_system_info;
43 std::vector<uint8_t> key_id;
45 std::vector<std::vector<uint8_t>> key_ids;
46 std::vector<uint8_t> key;
47 std::vector<uint8_t> iv;
48};
49
50typedef std::map<std::string, std::unique_ptr<EncryptionKey>> EncryptionKeyMap;
51
53class KeySource {
54 public:
55 KeySource();
56
57 virtual ~KeySource();
58
63 virtual Status FetchKeys(EmeInitDataType init_data_type,
64 const std::vector<uint8_t>& init_data) = 0;
65
71 virtual Status GetKey(const std::string& stream_label,
72 EncryptionKey* key) = 0;
73
79 virtual Status GetKey(const std::vector<uint8_t>& key_id,
80 EncryptionKey* key) = 0;
81
91 virtual Status GetCryptoPeriodKey(uint32_t crypto_period_index,
92 int32_t crypto_period_duration_in_seconds,
93 const std::string& stream_label,
94 EncryptionKey* key) = 0;
95
96 private:
97 DISALLOW_COPY_AND_ASSIGN(KeySource);
98};
99
100} // namespace media
101} // namespace shaka
102
103#endif // PACKAGER_MEDIA_BASE_KEY_SOURCE_H_
KeySource is responsible for encryption key acquisition.
Definition key_source.h:53
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:45
std::vector< uint8_t > key_id
The ID of this key.
Definition key_source.h:43