DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
key_source.h
1 // Copyright 2014 Google Inc. 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 MEDIA_BASE_KEY_SOURCE_H_
8 #define MEDIA_BASE_KEY_SOURCE_H_
9 
10 #include <string>
11 #include <vector>
12 
13 #include "packager/media/base/protection_system_specific_info.h"
14 #include "packager/media/base/status.h"
15 
16 namespace shaka {
17 namespace media {
18 
21 enum class EmeInitDataType {
22  UNKNOWN,
24  CENC,
26  WEBM,
28  KEYIDS,
30  WIDEVINE_CLASSIC,
31  MAX = WIDEVINE_CLASSIC
32 };
33 
34 struct EncryptionKey {
35  EncryptionKey();
36  ~EncryptionKey();
37 
38  std::vector<ProtectionSystemSpecificInfo> key_system_info;
39  std::vector<uint8_t> key_id;
40  std::vector<uint8_t> key;
41  std::vector<uint8_t> iv;
42 };
43 
45 class KeySource {
46  public:
47  KeySource();
48  virtual ~KeySource();
49 
54  virtual Status FetchKeys(EmeInitDataType init_data_type,
55  const std::vector<uint8_t>& init_data) = 0;
56 
62  virtual Status GetKey(const std::string& stream_label,
63  EncryptionKey* key) = 0;
64 
70  virtual Status GetKey(const std::vector<uint8_t>& key_id,
71  EncryptionKey* key) = 0;
72 
80  virtual Status GetCryptoPeriodKey(uint32_t crypto_period_index,
81  const std::string& stream_label,
82  EncryptionKey* key) = 0;
83 
84  private:
85  DISALLOW_COPY_AND_ASSIGN(KeySource);
86 };
87 
88 } // namespace media
89 } // namespace shaka
90 
91 #endif // MEDIA_BASE_KEY_SOURCE_H_
virtual Status GetCryptoPeriodKey(uint32_t crypto_period_index, const std::string &stream_label, EncryptionKey *key)=0
virtual Status GetKey(const std::string &stream_label, EncryptionKey *key)=0
virtual Status FetchKeys(EmeInitDataType init_data_type, const std::vector< uint8_t > &init_data)=0
KeySource is responsible for encryption key acquisition.
Definition: key_source.h:45